(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[32138],{92235:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/sok",function(){return s(89489)}])},9021:function(e,t,s){"use strict";s.d(t,{X:function(){return n}});var r=s(52676),l=s(60289);let n=e=>{var t;let{register:s,name:n,label:a,required:c,errors:i,value:u,onChange:o,checked:d,description:x}=e,m="mt-[0.1em] h-[1.25em] w-[1.25em] text-dark focus:ring-dark";return(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"flex cursor-pointer gap-[0.6em]",children:[s?(0,r.jsx)("input",{...s(n),type:"checkbox",className:m,required:c}):(0,r.jsx)("input",{value:u,onChange:o,type:"checkbox",className:m,checked:d}),(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsxs)("p",{className:(0,l.cn)("text-left",x&&"font-semibold"),children:[a,c&&(0,r.jsx)("span",{className:"text-danger",children:"*"})]}),x&&(0,r.jsx)("div",{children:x})]})]}),(null==i?void 0:i[n])&&(0,r.jsx)("p",{className:"mt-2 bg-danger/10 px-2 py-1 text-xs text-danger",children:null===(t=i[n])||void 0===t?void 0:t.message})]})}},47151:function(e,t,s){"use strict";s.d(t,{G:function(){return l}});var r=s(52676);let l=e=>{let{children:t}=e;return(0,r.jsx)("div",{className:"flex min-h-[8rem] items-center justify-center border-2 border-dashed border-dark/10 p-5 text-center text-lg text-dark text-opacity-70",children:(0,r.jsx)("p",{children:t})})}},52773:function(e,t,s){"use strict";s.d(t,{v:function(){return n}});var r=s(59538),l=s(33270);let n=s.n(l)()(r.O.NEXT_PUBLIC_ALGOLIA_APP_ID,r.O.NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY)},89489:function(e,t,s){"use strict";s.r(t),s.d(t,{__N_SSG:function(){return A},default:function(){return T}});var r=s(52676),l=s(9021),n=s(60399),a=s(47151),c=s(74355),i=s(47681),u=s(971),o=s(59538),d=s(52773),x=s(86606),m=s(96550),p=s(27322),h=s(96019),f=s(75271),v=s(29996),g=s(98289),j=s(70640),b=s(66985);let N=()=>{let[e,t]=(0,f.useState)(""),[s,l]=(0,f.useState)([]),[a,i]=(0,f.useState)([]);return(0,r.jsxs)(n.W,{className:"mt-6 mb-16 max-w-3xl text-center md:mb-28",children:[(0,r.jsx)(c.X,{level:1,className:"mb-6 md:mb-8 2xl:mb-12",children:"S\xf8k p\xe5 siden"}),(0,r.jsxs)("div",{className:"mb-10 flex flex-col gap-y-4 sm:mb-14 md:gap-y-6",children:[(0,r.jsxs)(v.p,{searchClient:d.v,indexName:o.O.NEXT_PUBLIC_ALGOLIA_GLOBAL_INDEX_NAME,future:{preserveSharedStateOnUnmount:!1},children:[(0,r.jsx)(g.T,{}),(0,r.jsx)(S,{searchTerm:e,setSearchTerm:t,setSearchResults:i})]}),(0,r.jsx)(_,{searchResults:a,activeDocTypes:s,setActiveDocTypes:l})]}),(0,r.jsx)(k,{searchResults:a.filter(e=>s.includes(e._type)||!s.length),searchTerm:e})]})},_=e=>{let{searchResults:t,activeDocTypes:s,setActiveDocTypes:l}=e;if(!t||(null==t?void 0:t.length)<1)return null;let n=e=>{switch(e){case"page":return"Sider";case"article":return"Artikler";case"event":return"Arrangementer";case"resource":return"Ressurser";case"resourceCollection":return"Ressurssamlinger";case"person":return"Personer";default:return e}},a=t.reduce((e,t)=>{let s=null==e?void 0:e.find(e=>e._type===t._type);return s?s.count++:e.push({_type:t._type,count:1,title:n(t._type)}),e},[]);return(0,r.jsxs)("div",{className:"flex flex-col items-start gap-3 text-xs",children:[(0,r.jsx)("p",{children:"Filtrer s\xf8k:"}),(0,r.jsx)("div",{className:"grid w-full grid-cols-2 gap-y-3 gap-x-5 sm:grid-cols-3 md:flex md:flex-wrap",children:a.map(e=>(0,r.jsx)(y,{...e,activeDocTypes:s,setActiveDocTypes:l},e._type))})]})},y=e=>{let{_type:t,title:s,count:n,activeDocTypes:a,setActiveDocTypes:c}=e;return(0,r.jsx)(l.X,{name:t,checked:a.includes(t),onChange:()=>{a.includes(t)?c(e=>e.filter(e=>e!==t)):c(e=>[...e,t])},label:(0,r.jsxs)("span",{className:"font-semibold",children:[s," ",(0,r.jsx)("span",{className:"font-normal text-muted",children:n})]})})},k=e=>{let{searchResults:t,searchTerm:s}=e;return s&&(null==t?void 0:t.length)<1?(0,r.jsx)(a.G,{children:"Ingen resultater. Pr\xf8v et annet s\xf8keord."}):(null==t?void 0:t.length)<1?null:(0,r.jsx)("ul",{className:"flex flex-col divide-y divide-dark/10 border-y border-dark/10",children:null==t?void 0:t.map(e=>(0,r.jsx)(w,{...e},e.objectID))})},w=e=>{var t,s,l,n;let{_type:a,slug:o,title:d,description:x,_highlightResult:p}=e,h=null!==(l=null==p?void 0:null===(t=p.title)||void 0===t?void 0:t.value)&&void 0!==l?l:d,f=null!==(n=null==p?void 0:null===(s=p.description)||void 0===s?void 0:s.value)&&void 0!==n?n:x;return f&&f.length>300&&(f=f.slice(0,300)+"…"),(0,r.jsx)("li",{children:(0,r.jsx)(u.S,{linkType:"internal",type:a,link:o,className:"group flex flex-col items-start gap-1 py-6",children:(0,r.jsxs)("div",{className:"flex w-full items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex flex-col text-left items-start gap-2",children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-muted group-hover:text-dark transition-colors",children:(e=>{switch(e){case"page":return"Side";case"article":return"Artikkel";case"event":return"Arrangement";case"resource":return"Ressurs";case"resourceCollection":return"Ressurssamling";case"person":return"Person";default:return e}})(a)}),(0,r.jsx)(c.X,{level:2,size:4,children:(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:h},className:"[&>em]:not-italic [&>em]:bg-success/30 group-hover:[&>em]:bg-success/70"})}),f&&(0,r.jsx)("p",{dangerouslySetInnerHTML:{__html:f},className:"text-sm text-muted group-hover:text-dark [&>em]:not-italic [&>em]:bg-success/30 transition-colors group-hover:[&>em]:bg-success/70"})]}),(0,r.jsx)(i.J,{icon:m.default,weight:"bold",className:"shrink-0 transition-transform group-hover:translate-x-2"})]})})})},S=e=>{let{searchTerm:t,setSearchTerm:s,setSearchResults:l}=e;(0,x.useRouter)();let{query:n,refine:a}=(0,j.l)(),{results:{hits:c}}=(0,b.b)(),u=(0,f.useRef)(null),o=e=>{s(e),a(e),l(e?c:[])};return(0,r.jsxs)("form",{role:"search",noValidate:!0,onSubmit:e=>{e.preventDefault(),e.stopPropagation(),u.current&&u.current.focus()},onReset:e=>{e.preventDefault(),e.stopPropagation(),o(""),u.current&&u.current.focus()},className:"relative",children:[(0,r.jsx)("input",{ref:u,autoFocus:!0,type:"search",className:"flex w-full appearance-none items-center justify-between gap-4 border border-dark/30 bg-transparent px-5 py-4 text-lg transition-colors hover:border-dark/80 focus:border-dark/100 focus:bg-white/50 focus:outline-0 focus:ring-0 sm:px-6 sm:py-5 sm:text-xl",placeholder:"S\xf8k...",value:t,onChange:e=>{o(e.currentTarget.value)}}),(0,r.jsxs)("div",{className:"absolute right-0 top-0 flex items-center h-full pr-4",children:[(n||t)&&(0,r.jsx)("button",{type:"reset","aria-label":"Fjern s\xf8kefiltering",className:"flex size-[2.2em] items-center justify-center rounded-full transition-colors hover:bg-white",children:(0,r.jsx)(i.J,{icon:p.default,weight:"bold"})}),(0,r.jsx)("button",{type:"submit","aria-label":"S\xf8k",className:"flex size-[2.2em] items-center justify-center rounded-full transition-colors hover:bg-white",children:(0,r.jsx)(i.J,{icon:h.default,weight:"bold"})})]})]})};var A=!0,T=()=>(0,r.jsx)(N,{})}},function(e){e.O(0,[20993,92888,49774,40179],function(){return e(e.s=92235)}),_N_E=e.O()}]);