var R=Object.defineProperty;var S=(s,e,a)=>e in s?R(s,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[e]=a;var r=(s,e,a)=>(S(s,typeof e!="symbol"?e+"":e,a),a);import{R as l,r as A,j as E}from"./vendor/react-core.DpiZP4mS.min.js";import{c as F,L as i,p as g,dz as D,dA as f,db as T,dB as _,dC as y,aZ as I,dD as O}from"../assets/forum-DnJUJbS9.js";import{E as P}from"./types.Bnp7nMni.min.js";const t=F("@@search");class o{}r(o,"performSearchACs",t.async("SEARCH")),r(o,"updateSearchFormAC",t("UPDATE_FORM")),r(o,"resetFormAC",t("RESET_FORM")),r(o,"performDomainSearchACs",t.async("DOMAIN_SEARCH"));const p={domain:f,query:"",page:1,sort:"relevance",scope:T,initialized:!1},m={form:p,response:{status:i.PENDING},domainSearchResponse:{}},M=["sort","domain","scope","page","pageURL"],v=g(D().case(o.updateSearchFormAC,(s,e)=>{let a=!1;if(s.form.initialized)for(const n of M)e[n]!==void 0&&s.form[n]!==e[n]&&(a=!0);!s.form.initialized&&e.initialized&&(a=!0);const c={...s.form,...e,needsResearch:a};return e.initialized||"page"in e||(c.page=1),s.form=c,s}).case(o.performSearchACs.started,(s,e)=>(s.form.needsResearch=!1,s.form.initialized=!0,s.response.status=i.LOADING,s)).case(o.performSearchACs.done,(s,e)=>(s.response.status=i.SUCCESS,s.response.data=e.result,s)).case(o.performSearchACs.failed,(s,e)=>(s.response.status=i.ERROR,s.response.error=e.error,s)).case(o.performDomainSearchACs.started,(s,e)=>{const{domain:a}=e;return s.domainSearchResponse[a]={status:i.LOADING},s}).case(o.performDomainSearchACs.done,(s,e)=>{const{domain:a}=e.params;return s.domainSearchResponse[a].status=i.SUCCESS,s.domainSearchResponse[a].data=e.result,s}).case(o.performDomainSearchACs.failed,(s,e)=>{const{domain:a}=e.params;return s.domainSearchResponse[a].status=i.ERROR,s.domainSearchResponse[a].error=e.error,s}).case(o.resetFormAC,s=>(s.form={...p},s.response={status:i.PENDING},s)));class N{constructor(){r(this,"ResultComponent",_);r(this,"defaultFormValues");r(this,"PanelComponent");r(this,"subTypes",[]);r(this,"addSubType",e=>{this.subTypes.find(a=>a.type===e.type)||this.subTypes.push(e)});r(this,"additionalFilterSchemaFields",[]);r(this,"isIsolatedType",!1);r(this,"ResultWrapper");r(this,"MetaComponent");r(this,"SpecificRecordPanelComponent");r(this,"SpecificRecordComponent");r(this,"showSpecificRecordCrumbs",!1)}getAllowedFields(e){return[]}getFilterSchema(e){return P}addFieldToFilterSchema(e){this.additionalFilterSchemaFields.push(e)}get sortValues(){return[]}mapResultToProps(e){var n,d,u;const a=e.type?((n=this.subTypes.find(C=>C.type===e.type))==null?void 0:n.icon)??this.icon:this.icon??null,c={imageSet:y(((d=e==null?void 0:e.image)==null?void 0:d.urlSrcSet)??{})};return{name:e.name,url:e.url,excerpt:e.body,image:(u=e.image)==null?void 0:u.url,highlight:e.highlight,icon:a,tags:e==null?void 0:e.tags,...c.imageSet.length>0?c:{}}}}const h=new class extends N{constructor(){super(...arguments);r(this,"key",f);r(this,"sort",0);r(this,"name","All");r(this,"icon",E.jsx(O,{}));r(this,"recordTypes",[])}},L=l.createContext({updateForm:()=>{},resetForm:()=>{},response:m.response,domainSearchResponse:m.domainSearchResponse,form:m.form,search:async()=>{},domains:[h],currentDomain:h,handleSourceChange:async s=>{},defaultFormValues:p,currentSource:I.sources[0]??void 0});function V(){return A.useContext(L)}export{p as D,m as I,N as S,o as a,L as b,v as s,V as u};
