1(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`28aae385f93eb517d4b3070be05311ea04212047`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`907420ab-a651-4280-abe0-d34e16673ed9`,e._sentryDebugIdIdentifier=`sentry-dbid-907420ab-a651-4280-abe0-d34e16673ed9`)}catch{}})();import{t as e}from"./client.DE1X0jkd.js";import{o as t}from"./preact.module.mZSZn8bf.js";import{o as n,r,t as i}from"./hooks.module.DRx_XRgS.js";import{n as a}from"./translations.B0E2yZ7v.js";import{t as o}from"./jsxRuntime.module.apuerNTr.js";import{i as s}from"./imagekit.C6dwaTIq.js";import{t as c}from"./stripHtml.IWkPCf-J.js";import{t as l}from"./typesense-docs.CjyEMASW.js";import{t as u}from"./api.DG5DyD3r.js";function d(e){let t=Date.now()/1e3-e,n=Math.floor(t/(1440*60));if(n===0){let e=Math.floor(t/3600);if(e===0){let e=Math.floor(t/60);return e<=1?`now`:`${e}m ago`}return`${e}h ago`}else if(n===1)return`1d ago`;else if(n===2)return`2d ago`;else if(n===3)return`3d ago`;else return new Date(e*1e3).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}function f({radiocodename:f,baseUrl:p,language:m}){let[h,g]=r(!1),[_,v]=r(``),[y,b]=r([]),[x,S]=r(0),[C,w]=r(!1),[T,E]=r(`all`),[D,O]=r({all:0,news:0,podcast:0,program:0,moment:0}),k=i(null),A=i(null),[j,M]=r(`Ctrl+`);n(()=>{/Mac|iPhone|iPad|iPod/i.test(navigator.platform||navigator.userAgent)&&M(`â`)},[]);let N=[{id:`nav-home`,title:a(`general.home`,m),shortcut:!0,href:p,type:`navigation`},{id:`nav-podcasts`,title:a(`general.programs`,m),shortcut:!0,href:`${p}podcasts/`,type:`navigation`},{id:`nav-podcasts-featured`,title:`${a(`general.programs`,m)} ⺠${a(`podcasts.featuredShows`,m)}`,href:`${p}podcasts/#featured`,type:`navigation`},{id:`nav-podcasts-recent`,title:`${a(`general.programs`,m)} ⺠${a(`podcasts.lastRecordings`,m)}`,href:`${p}podcasts/#recent`,type:`navigation`},{id:`nav-podcasts-all`,title:`${a(`general.programs`,m)} ⺠${a(`podcasts.allPodcasts`,m)}`,href:`${p}podcasts/#all`,type:`navigation`},{id:`nav-podcasts-archived`,title:`${a(`general.programs`,m)} ⺠${a(`podcasts.archivedShows`,m)}`,href:`${p}podcasts/#archived`,type:`navigation`},{id:`nav-news`,title:a(`general.news`,m),shortcut:!0,href:`${p}news/`,type:`navigation`},{id:`nav-schedules`,title:a(`general.schedules`,m),shortcut:!0,href:`${p}schedules/`,type:`navigation`}],P=N.filter(e=>e.shortcut),F=(()=>
1{if(_.length<2)return N;let e=N.filter(e=>e.title.toLowerCase().includes(_.toLowerCase())),t=[];if(T===`all`)t=[...e,...y];else if(t=y.filter(e=>e.type===T),!C){if(T===`news`&&D.news>5){let e=D.news-5;t.push({id:`view-all-news`,title:`${a(`search.view_more_results`,m)} (+${e})`,type:`navigation`,href:`${p}news/?q=${_}`})}else if(T===`podcast`&&D.podcast>5){let e=D.podcast-5;t.push({id:`view-all-podcasts`,title:`${a(`search.view_more_results`,m)} (+${e})`,type:`navigation`,href:`${p}podcasts/all-episodes/?q=${_}`})}else if(T===`program`&&D.program>5){let e=D.program-5;t.push({id:`view-all-programs`,title:`${a(`search.view_more_results`,m)} (+${e})`,type:`navigation`,href:`${p}podcasts/?q=${_}`})}else if(T===`moment`&&D.moment>5){let e=D.moment-5;t.push({id:`view-all-moments`,title:`${a(`search.view_more_results`,m)} (+${e})`,type:`navigation`,href:`${p}podcasts/all-episodes/?q=${_}`})}}return t})();n(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),g(!h))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[h]),n(()=>{h&&k.current&&(k.current.focus(),S(0),v(``),E(`all`))},[h]);let I=i({selectedIndex:x,visibleItems:F,activeTab:T,search:_});return I.current={selectedIndex:x,visibleItems:F,activeTab:T,search:_},n(()=>{if(!h)return;let t=t=>{let{visibleItems:n,activeTab:r,search:i,selectedIndex:a}=I.current;if((t.metaKey||t.ctrlKey)&&t.key>=`1`&&t.key<=`9`){let n=parseInt(t.key)-1;P[n]&&(t.preventDefault(),e(P[n].href),g(!1));return}switch(t.key){case`Tab`:if(t.preventDefault(),i.length>=2){let e=[`all`,`news`,`podcast`,`program`,`moment`],n=e.indexOf(r);t.shiftKey?E(e[n===0?e.length-1:n-1]):E(e[n===e.length-1?0:n+1]),S(0)}break;case`ArrowDown`:t.preventDefault(),S(e=>e<n.length-1?e+1:0);break;case`ArrowUp`:t.preventDefault(),S(e=>e>0?e-1:n.length-1);break;case`Enter`:{t.preventDefault();let r=n[a];r&&(r.onClick?r.onClick():r.href&&e(r.href),g(!1));break}case`Escape`:t.preventDefault(),g(!1);break}};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[h]),n(()=>{A.current&&A.current.querySelector(`[data-index="${x}"]`)?.scrollIntoView({block:`nearest`})},[x]),n(()=>{if(_.length<2){b([]);return}let t=setTimeout(async()=>{w(!0);try{let t=Math.floor(Date.now()/1e3),n=encodeURIComponent(_),r={"X-TYPESENSE-API-KEY":`azX92P4d73j0FsXmiytDe3IcFYzsiOLv`},[i,a,o,m]=await Promise.all([fetch(`https://search.enacast.com/collections/enacast___news/documents/search?q=${n}&filter_by=radioCodename:${f}&per_page=5&page=1&query_by=headline,body&sort_by=datetime_to_publish_ts:desc`,{headers:r}),fetch(`https://search.enacast.com/collections/enacast___podcasts/documents/search?q=${n}&filter_by=radioCodename:${f}&per_page=5&page=1&query_by=podcastTitle,podcastDescription&sort_by=recorded_ts:desc`,{headers:r}),fetch(`${u()}/programs/?page=1&page_size=5&radio=${f}&search=${n}&ts=${t}`),fetch(`https://search.enacast.com/collections/enacast___podcasts-chunks/documents/search?q=${n}&filter_by=radioCodename:${f}&per_page=5&page=1&query_by=transcription&sort_by=recorded_ts:desc`,{headers:r})]),[h,g,v,y]=await Promise.all([i.json(),a.json(),o.json(),m.json()]),x=[];h.hits&&h.hits.forEach(e=>{let t=e.document;x.push({id:`news-${t.id}`,title:t.headline?.replace(/<[^>]*>/g,``)||`Untitled News`,subtitle:t.body?c(t.body).substring(0,100)+`...`:``,href:`${p}news/${t.slug}/`,type:`news`,thumbnail:s(t.main_image,{width:125,height:125,autoFocus:!0}),date:t.datetime_to_publish_ts?d(t.datetime_to_publish_ts):void 0})}),g.hits&&g.hits.forEach(e=>{let t=e.document;t.programCodename&&x.push({id:`podcast-${t.id}`,title:t.podcastTitle||`Untitled Episode`,subtitle:t.podcastDescription?.substring(0,100)+`...`,href:`${p}podcasts/${t.programCodename}/${l(t)}/`,type:`podcast`,thumbnail:s(t.thumbnail||t.image,{width:125,height:125,autoFocus:!0}),date:t.recorded_ts?d(t.recorded_ts):void 0})}),v.results&&v.results.forEach(e=>{x.push({id:`program-${e.id}`,title:e.name||e.title||`Untitled Program`,subtitle:e.description,href:`${p}podcasts/${e.codename}/`,type:`program`,thumbnail:s(e.logo_square_256||e.thumbnail||e.image,{width:125,height:125,autoFocus:!0}),date:e.updated_at?d(Math.floor(new Date(e.updated_at).getTime()/1e3)):void 0})}
1),y.hits&&y.hits.forEach(t=>{let n=t.document,r=t.highlights?.[0]?.snippet||n.transcription;x.push({id:`moment-${n.id}`,title:r.replace(/<mark>/g,``).replace(/<\/mark>/g,``),subtitle:n.podcastTitle||`Untitled Episode`,href:`${p}podcasts/${n.programCodename}/${l(n)}/`,type:`moment`,timestamp:n.start,audio:n.audio_direct_non_metrics_url||n.audio,thumbnail:s(n.thumbnail,{width:125,height:125,autoFocus:!0}),date:n.recorded_ts?d(n.recorded_ts):void 0,onClick:()=>{e(`${p}podcasts/${n.programCodename}/${l(n)}/?t=${n.start}`)}})}),O({news:h.found||0,podcast:g.found||0,program:v.count||0,moment:y.found||0,all:(h.found||0)+(g.found||0)+(v.count||0)+(y.found||0)}),b(x)}catch(e){console.error(`Search error:`,e),b([])}finally{w(!1)}},300);return()=>clearTimeout(t)},[_,f,p]),n(()=>{S(0)},[F.length]),h?o(t,{children:o(`div`,{class:`fixed inset-0 z-[110] flex items-start justify-center pt-[20vh] px-4`,onClick:()=>g(!1),children:[o(`div`,{class:`fixed inset-0 bg-black/50 backdrop-blur-sm`}),o(`div`,{class:`relative w-full max-w-2xl max-h-[70vh] flex flex-col rounded-lg bg-white shadow-2xl dark:bg-slate-900`,onClick:e=>e.stopPropagation(),children:[o(`div`,{class:`border-b border-gray-200 p-4 dark:border-slate-700`,children:o(`input`,{ref:k,type:`text`,value:_,onInput:e=>v(e.currentTarget.value),placeholder:a(`search.placeholder`,m),class:`w-full bg-transparent text-lg outline-none placeholder:text-gray-400 dark:placeholder:text-slate-500`})}),_.length>=2&&o(`div`,{class:`flex overflow-x-auto scrollbar-hide border-b border-gray-200 dark:border-slate-700`,children:[{key:`all`,label:a(`search.tabs.all`,m)},{key:`news`,label:a(`search.tabs.news`,m)},{key:`podcast`,label:a(`search.tabs.podcasts`,m)},{key:`program`,label:a(`search.tabs.programs`,m)},{key:`moment`,label:a(`search.tabs.moments`,m)}].map(e=>o(`button`,{onClick:()=>
1{E(e.key),S(0)},class:`flex shrink-0 items-center gap-2 whitespace-nowrap px-4 py-2 text-sm font-medium transition-colors ${T===e.key?`border-b-2 border-[var(--primary)] text-[var(--primary)]`:`text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-200`}`,children:[e.label,D[e.key]>0&&o(`span`,{class:`rounded-full px-2 py-0.5 text-xs ${T===e.key?`bg-[var(--primary)] text-white`:`bg-gray-200 text-gray-600 dark:bg-gray-700 dark:text-gray-300`}`,children:D[e.key]})]},e.key))}),o(`div`,{ref:A,class:`max-h-[60vh] sm:max-h-[450px] overflow-y-auto p-2`,children:[C&&o(`div`,{class:`p-4 text-center text-gray-500 dark:text-slate-400`,children:a(`search.loading`,m)}),!C&&F.length===0&&o(`div`,{class:`p-4 text-center text-gray-500 dark:text-slate-400`,children:a(`search.no_results`,m)}),!C&&F.map((t,n)=>{let r=t.type===`navigation`,i=P.findIndex(e=>e.id===t.id),s=T===`all`&&_.length>=2&&n>0&&!r&&F[n-1].type===`navigation`,c=t.id?.startsWith(`view-all-`);return o(`div`,{children:[s&&o(`div`,{class:`mx-2 my-1 border-t border-gray-200 dark:border-slate-700`}),c&&n>0&&o(`div`,{class:`mx-2 my-1 border-t border-gray-200 dark:border-slate-700`}),o(`button`,{"data-index":n,onClick:()=>{t.onClick?t.onClick():t.href&&e(t.href),g(!1)},class:`flex w-full items-center rounded-md px-3 py-2 text-left transition-colors ${n===x?`bg-[var(--primary)] text-white`:`hover:bg-gray-100 dark:hover:bg-slate-800`}`,children:[t.thumbnail&&!c&&o(`div`,{class:`mr-3 flex-shrink-0`,children:o(`img`,{src:t.thumbnail,alt:``,class:`h-12 w-12 rounded object-cover`,loading:`lazy`})}),o(`div`,{class:`flex-1 ${c?`text-center font-medium`:``}`,children:[o(`div`,{class:`font-medium`,children:t.title}),t.subtitle&&o(`div`,{class:`text-sm opacity-75`,children:t.subtitle})]}),!c&&o(`div`,{class:`ml-2 flex flex-col items-end text-xs opacity-50`,children:[t.date&&o(`div`,{class:`mb-1 text-xs opacity-60`,children:t.date}),o(`div`,{class:`flex items-center gap-2`,children:[r&&i>=0&&o(`span`,{class:`rounded px-1.5 py-0.5 ${n===x?`bg-white/20 text-white`:`bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400`}`,children:[j,i+1]}),o(`span`,{children:[t.type===`navigation`&&a(`search.sections.navigation`,m),t.type===`news`&&a(`search.sections.news`,m),t.type===`podcast`&&a(`search.sections.podcasts`,m),t.type===`program`&&a(`search.sections.programs`,m),t.type===`moment`&&a(`search.sections.moments`,m)]})]})]})]})]},t.id)})]}),o(`div`,{class:`border-t border-gray-200 px-4 py-2 text-xs text-gray-500 dark:border-slate-700 dark:text-slate-400`,children:[o(`span`,{class:`mr-4`,children:[`ââ `,a(`search.navigate`,m)]}),o(`span`,{class:`mr-4`,children:[`âµ `,a(`search.select`,m)]}),_.length>=2&&o(`span`,{class:`mr-4`,children:[`Tab `,a(`search.tabs.all`,m)]}),o(`span`,{children:[`ESC `,a(`search.close`,m)]})]})]})]})}):null}export{f as CommandPaletteSimple};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.