PageSourceSearch

https://www.esportsradio.cat/_astro/Player.tMIvvvAr.js

js esportsradio.cat collected 2026-09-25 09:28:52 UTC 37,051 bytes, 1 lines download raw bytes

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]=`671d491e-72a2-4496-915b-ddc51e205032`,e._sentryDebugIdIdentifier=`sentry-dbid-671d491e-72a2-4496-915b-ddc51e205032`)}catch{}})();import{o as e}from"./preact.module.mZSZn8bf.js";import{o as t,r as n,t as r}from"./hooks.module.DRx_XRgS.js";import{n as i}from"./translations.B0E2yZ7v.js";import{t as a}from"./jsxRuntime.module.apuerNTr.js";import{t as o}from"./createLucideIcon.jIepBLoM.js";import{t as s}from"./chevron-down.BGzPMDVp.js";import{t as c}from"./chevron-left.DhGoXlpF.js";import{t as l}from"./chevron-right.B5WHRIPA.js";import{t as u}from"./chevron-up.BJL01iad.js";import{t as d}from"./clock.BAVsha6e.js";import{t as f}from"./file-text.nreoT-F5.js";import{t as p}from"./pause.wZibBrAv.js";import{t as m}from"./play.LkTyV_a8.js";import{i as h,n as g,r as _,t as v}from"./app.config.h4yMK2cJ.js";import{n as y,t as ee}from"./rotate-cw.DrrgcrPP.js";import{t as b}from"./x.vsOnPbgo.js";import{C as x,E as S,O as C,S as w,T,_ as E,b as D,c as O,d as k,f as A,g as j,h as M,i as te,k as N,l as P,m as F,o as I,p as L,r as ne,s as R,t as z,u as B,v as re,w as ie,x as V,y as H}from"./state.guQlMkTw.js";import{t as U}from"./format.CZu2en6-.js";import{i as ae,n as oe,r as se}from"./episodeProgress.B6XR1Rbb.js";import{i as ce}from"./imagekit.C6dwaTIq.js";import{t as W}from"./api.DG5DyD3r.js";import{t as le}from"./analytics.CbiebyUQ.js";import{a as ue,c as de,o as G}from"./markerActions.DjmqtcPC.js";var fe=o(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),pe=o(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),me=o(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),he=3e4,K=null,q=[],ge=!1,J=`astro_player`;function _e(){try{if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID()}catch{}return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function ve(){return`${W().replace(/\/$/,``)}/events/`}function ye(e,t=!1){if(e.length===0||typeof window>`u`)return;let n=JSON.stringify({events:e});try{if(t&&typeof navigator<`u`&&typeof navigator.sendBeacon==`function`){navigator.sendBeacon(ve(),new Blob([n],{type:`text/plain`}));return}fetch(ve(),{method:`POST`,headers:{"Content-Type":`application/json`},body:n,keepalive:!0}).catch(()=>void 0)}catch{}}function Y(e=!1){if(q.length===0)return;let t=q;q=[],ye(t,e)}function X(e,t=!0){q.push(e),t&&Y()}function be(){ge||typeof window>`u`||(ge=!0,window.addEventListener(`pagehide`,()=>{Z(!0),Y(!0)}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&(Z(!0),Y(!0))}))}function xe(){if(!K||K.startedAt===null)return 0;let e=Date.now(),t=Math.max(0,Math.round((e-K.startedAt)/1e3));return K.startedAt=e,Math.min(t,Math.round(he/1e3*2))}function Z(e=!0){if(!K)return;let t=xe();t<=0||X({object_type:`podcast`,object_id:K.episodeId,kind:`progress`,session_id:K.sessionId,position_s:Math.round(K.getPosition()),listened_s:t,source:J,ts_client:Date.now()},e)}function Se(){!K||K.timer!==null||(K.timer=window.setInterval(()=>Z(!0),he))}function Ce(){!K||K.timer===null||(window.clearInterval(K.timer),K.timer=null)}function we(e,t){if(!(!e||typeof window>`u`)){if(be(),K&&K.episodeId===e){K.startedAt===null&&(K.startedAt=Date.now()),K.getPosition=t,Se();return}K&&Q(),K={episodeId:e,sessionId:_e(),startedAt:Date.now(),timer:null,completed:!1,getPosition:t},X({object_type:`podcast`,object_id:e,kind:`play_start`,session_id:K.sessionId,position_s:Math.round(t()),listened_s:0,source:J,ts_client:Date.now()}),Se()}}function Te(){K&&(K.startedAt=null)}function Ee(){K&&(Z(!0),Te(),Ce())}function Q(){K&&=(Z(!0),Te(),Ce(),null)}function De(){if(K){if(Z(!1),Te(),Ce(),K.completed){Y();return}K.completed=!0,X({object_type:`podcast`,object_id:K.episodeId,kind:`complete`,session_id:K.sessionId,position_s:Math.round(K.getPosition()),source:J,ts_client:Date.now()})}}function Oe(e,t){let n=()=>{let n=t();n&&!e.paused&&!e.ended&&we(n,()=>e.currentTime)},r=()=>Ee(),i={playing:n,pause:r,waiting:r,seeking:r,seeked:()=>{e.readyState>=3&&n()},stalled:()=>{e.readyState<3&&Ee()},ended:()=>De(),error:r,emptied:r};for(let[t,n]of Object.entries(i))e.addEventListener(t,n);return()=>{for(let[t,n]of Object.entries(i))e.removeEventListener(t,n);Q()}}function ke({language:e=`en`}){return a(`span`,{class:`flex flex-shrink-0 items-center gap-1.5 text-[11px] font-bold tracking-wide text-red-600 uppercase dark:text-red-400`,children:[a(`span`,{class:`h-1.5 w-1.5 animate-pulse rounded-full bg-red-600 dark:bg-red-400`,"aria-hidden":`true`}),i(`player.live`,e)]})}function Ae({radioInfo:e,liveProgram:t}){let n=e?.language||`en`,r=t?.current_program?.name||e?.name||i(`player.liveRadio`,n);if(H.value===`idle`)return a(`button`,{onClick:()=>{C(),w.value=`standard`},class:`group flex w-full cursor-pointer items-center gap-3 p-2 pr-6 text-left`,"aria-label":i(`header.listenLive`,
1n),children:[a(`span`,{class:`player-primary-action flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full`,children:a(m,{size:20,class:`ml-0.5 text-white`,fill:`currentColor`})}),a(`span`,{class:`min-w-0`,children:[a(ke,{language:n}),a(`span`,{class:`block truncate text-base font-bold text-gray-900 dark:text-white`,children:r})]})]});let o=()=>{w.value=`standard`},s=()=>{L.value=!L.value},c=M.value?r:I.value?.title||i(`player.noContent`,n);return a(`div`,{class:`flex w-full items-center gap-2 p-2`,children:[a(`button`,{onClick:s,class:`player-primary-action flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full`,"aria-label":L.value?i(`player.pause`,n):i(`player.play`,n),children:L.value?a(p,{size:20,class:`text-white`}):a(m,{size:20,class:`ml-0.5 text-white`,fill:`currentColor`})}),a(`button`,{onClick:o,class:`min-w-0 flex-1 cursor-pointer text-left`,"aria-label":i(`player.expand`,n),children:[M.value?a(ke,{language:n}):B.value>0&&a(`span`,{class:`block text-[11px] tabular-nums text-gray-500 dark:text-gray-400`,children:[U(P.value),` / `,U(B.value)]}),a(`span`,{class:`block truncate text-sm font-bold text-gray-900 dark:text-white`,children:c})]}),a(`button`,{onClick:o,class:`player-control flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full`,"aria-label":i(`player.expand`,n),children:a(u,{size:16})}),a(`button`,{onClick:te,class:`player-control flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full`,"aria-label":i(`player.close`,n),children:a(b,{size:16})})]})}function je({audioPlayer:e,progress:t,language:n=`en`}){return a(`div`,{class:`relative flex flex-auto touch-none items-center w-full`,children:a(`input`,{"aria-orientation":`horizontal`,role:`slider`,"aria-label":i(`player.audioTimeline`,n),"aria-valuemin":0,"aria-valuemax":Math.floor(e.current?.duration??0),"aria-valuenow":Math.floor(e.current?.currentTime??0),"aria-valuetext":`${Math.floor(e.current?.currentTime??0)} seconds`,class:`slider group w-full cursor-pointer accent-[var(--primary)]`,type:`range`,max:`100`,value:t,onInput:t=>{if(e?.current){let n=Number(t.target.value)/100*e.current.duration;e.current.currentTime=n}}})})}var $=[1,1.2,1.5,2];function Me({audioPlayer:e,language:t=`en`}){let[r,o]=n($[0]);return a(`button`,{type:`button`,className:`w-10 h-10 rounded-full player-control flex items-center justify-center`,onClick:()=>{o(t=>{let n=$[($.indexOf(t)+1)%$.length];return e.current&&(e.current.playbackRate=n),n})},"aria-label":i(`player.playbackRate`,t),children:a(`span`,{class:`text-xs font-medium`,children:[r,`x`]})})}function Ne({hasHD:e,language:t=`en`}){if(!e)return null;let n=()=>{F.value=!F.value},r=F.value?i(`player.switchToSD`,t):i(`player.switchToHD`,t);return a(`button`,{onClick:n,className:`hd-toggle-button cursor-pointer ${F.value?`active`:``}`,title:r,"aria-label":r,children:a(`span`,{className:`hd-label`,children:F.value?`HD`:`SD`})})}function Pe({language:e=`en`}){let t=A.value||N.value===0;return a(`div`,{class:`flex items-center gap-1.5`,children:[a(`button`,{onClick:()=>{if(N.value===0){N.value=1,A.value=!1;return}A.value=!A.value},class:`player-control flex h-10 w-10 items-center justify-center rounded-full`,"aria-label":i(t?`player.unmute`:`player.mute`,e),children:a(t?g:_,{size:18})}),a(`input`,{type:`range`,min:`0`,max:`1`,step:`0.05`,value:A.value?0:N.value,onInput:e=>{let t=Number(e.target.value);N.value=t,A.value&&t>0&&(A.value=!1)},class:`hidden w-24 cursor-pointer accent-[var(--primary)] md:block`,"aria-label":i(`player.volume`,e)})]})}var Fe=[`0s`,`0.25s`,`0.1s`,`0.4s`];function Ie({playing:e}){return a(`div`,{class:`flex h-5 items-end gap-[3px]`,"aria-hidden":`true`,children:Fe.map(t=>a(`span`,{class:`player-eq-bar h-full w-1 rounded-full bg-[var(--primary)] ${e?``:`paused`}`,style:{animationDelay:t}},t))})}function Le(e,t,n){return e?e.episodeImage||e.image||n?.logo_square_256||null:t?.current_program?.logo_square_400||n?.logo_square_256||null}var Re=e=>!!e&&!e.includes(`_out_of_schedule`)&&!e.endsWith(`_live`);function ze({radioInfo:e,audioPlayer:t,liveProgram:n,markers:r}){let o=e?.language||`en`,c=()=>{L.value=!L.value},l=()=>{M.value||!t.current||(t.current.currentTime=Math.max(0,t.current.currentTime-15))},u=()=>{M.value||!t.current||(t.current.currentTime=Math.min(t.current.duration,t.current.currentTime+30))},f=()=>{w.value=`mini`},g=B.value>0?P.value/B.value*100:0,_=e&&e.stream_hd_url!==e.stream_sd_url,v=!M.value&&!!I.value,b=I.value?.recording_type===`automatically_recorded`?I.value?.ai_detected_start_offset_seconds??0:0,x=I.value?.podcastSlug||I.value?.programCodename||``,S=M.value?n?.current_program?.name||e?.name||i(`player.liveRadio`,o):I.value?.title||i(`player.noContent`,o),T=M.value?Re(n?.current_program?.codename)?`${e?.BASE_URL||`/`}podcasts/${n.current_program.codename}/`:null:v&&Re(x)&&I.value.episodeSlug?`${e?.BASE_URL||`/`}podcasts/${x}/${I.value.episodeSlug}/`:null,k=Le(v?I.value:null,n,e),A=k?ce(k,{width:128,height:128,autoFocus:!0}):null,j=`truncate text-sm sm:text-base font-bold text-gray-900 dark:text-white`;return a(`div`,{children:[v&&a(`div`,{class:`relative h-1 bg-gray-200 dark:bg-slate-700`,children:[a(`div`,{class:`h-full bg-[var(--primary)] transition-all duration-300`,style:{width:`${g}%`}}),r&&r.length>0&&B.value>0&&r.map(e=>{let t=e.startsecond??e.start_time??0;return t===0?null:a(`div`,{class:`absolute top-0 bottom-0 w-0.5 bg-gray-400 opacity-60 dark:bg-gray-600`,style:{left:`${(t+b)/B.value*100}%`,transform:`translateX(-50%)`}},e.id)})]}),a(`div`,{class:`px-3 py-2.5 sm:px-4 sm:py-3`,children:[a(`div`,{class:`flex items-center gap-2 sm:gap-3`,children:[v&&a(`button`,{onClick:l,class:`player-control hidden h-10 w-10 items-center justify-center rounded-full sm:flex`,"aria-label":i(`player.skipB
1ack`,o),title:`-15s`,children:a(`div`,{class:`relative flex items-center justify-center`,children:[a(y,{size:22}),a(`span`,{class:`absolute text-[8px] font-bold`,children:`15`})]})}),a(`button`,{onClick:c,class:`player-primary-action flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full`,"aria-label":L.value?i(`player.pause`,o):i(`player.play`,o),children:L.value?a(p,{size:20,class:`text-white`}):a(m,{size:20,class:`ml-0.5 text-white`,fill:`currentColor`})}),v&&a(`button`,{onClick:u,class:`player-control hidden h-10 w-10 items-center justify-center rounded-full sm:flex`,"aria-label":i(`player.skipForward`,o),title:`+30s`,children:a(`div`,{class:`relative flex items-center justify-center`,children:[a(ee,{size:22}),a(`span`,{class:`absolute text-[8px] font-bold`,children:`30`})]})}),A&&a(`div`,{class:`hidden h-12 w-12 flex-shrink-0 overflow-hidden rounded-lg bg-gray-200 sm:block sm:h-14 sm:w-14 dark:bg-slate-700`,children:a(`img`,{src:A,alt:S,class:`h-full w-full object-cover`})}),a(`div`,{class:`min-w-0 flex-1`,children:[a(`div`,{class:`flex items-center gap-2`,children:[T?a(`a`,{href:T,class:`${j} transition-colors hover:text-[var(--primary)]`,children:S}):a(`h3`,{class:j,children:S}),M.value&&a(ke,{language:o})]}),a(`div`,{class:`mt-0.5 truncate text-xs text-gray-500 dark:text-gray-400`,children:M.value?n?.next_program?a(`span`,{children:[i(`player.nextProgramAt`,o).split(`{program}`)[0],Re(n.next_program.codename)?a(`a`,{href:`${e?.BASE_URL||`/`}podcasts/${n.next_program.codename}/`,class:`transition-colors hover:text-[var(--primary)]`,children:n.next_program.name}):a(`span`,{children:n.next_program.name}),i(`player.nextProgramAt`,o).split(`{program}`)[1]?.replace(`{time}`,n.next_schedule?.start_time_local?.slice(0,5)||``)]}):a(`span`,{children:e?.name||i(`player.liveRadio`,o)}):v?a(`span`,{class:`flex items-center gap-2`,children:[R.value>=0&&E.value.length>1&&a(`span`,{children:i(`player.queuePosition`,o,{current:String(R.value+1),total:String(E.value.length)})}),O.value&&a(`span`,{class:`flex min-w-0 items-center gap-1 text-[var(--primary)]`,children:[a(d,{size:10,class:`flex-shrink-0`}),a(`span`,{class:`truncate`,children:O.value.name||O.value.title})]})]}):null})]}),a(`div`,{class:`flex flex-shrink-0 items-center gap-1.5 sm:gap-2`,children:[a(`div`,{class:`hidden sm:block`,children:a(Ie,{playing:L.value})}),v&&e?.stream_sd_url&&a(`button`,{onClick:C,class:`flex items-center gap-1.5 rounded-full bg-red-500/15 px-2.5 py-2 text-xs font-medium text-red-600 transition-colors hover:bg-red-500/25 dark:text-red-400`,"aria-label":i(`player.backToLive`,o),title:i(`player.backToLive`,o),children:[a(h,{size:14}),a(`span`,{class:`hidden lg:inline`,children:i(`player.backToLive`,o)})]}),v&&t.current&&a(`div`,{class:`hidden md:block`,children:a(Me,{audioPlayer:t,language:o})}),M.value&&_&&a(`div`,{class:`hidden md:block`,children:a(Ne,{hasHD:_,language:o})}),a(Pe,{language:o}),v&&r&&r.length>0&&a(`button`,{onClick:()=>{V.value=`sections`,D.value=!0},class:`player-control relative flex h-10 w-10 items-center justify-center rounded-full`,"aria-label":i(`player.sections`,o),title:i(`player.sections`,o),children:[a(fe,{size:18}),a(`span`,{class:`absolute -top-1 -right-1 flex h-4 w-4 items-center justify-center rounded-full bg-[var(--primary)] text-[10px] text-white`,children:r.length})]}),v&&E.value.length>1&&a(`button`,{onClick:()=>{V.value=`queue`,D.value=!0},class:`player-control relative flex h-10 w-10 items-center justify-center rounded-full`,"aria-label":i(`player.queue`,o),title:i(`player.queue`,o),children:[a(me,{size:18}),a(`span`,{class:`absolute -top-1 -right-1 flex h-4 w-4 items-center justify-center rounded-full bg-[var(--primary)] text-[10px] text-white`,children:E.value.length})]}),a(`button`,{onClick:f,class:`player-control flex h-10 w-10 items-center justify-center rounded-full`,"aria-label":i(`player.collapse`,o),title:i(`player.collapse`,o),children:a(s,{size:18})})]})]}),v&&a(`div`,{class:`mt-2.5 flex items-center gap-3 sm:mt-3`,children:[a(`span`,{class:`min-w-[40px] text-right text-xs tabular-nums text-gray-500 dark:text-gray-400`,children:U(P.value)}),a(`div`,{class:`flex-1`,children:a(je,{audioPlayer:t,progress:g,language:o})}),a(`span`,{class:`min-w-[40px] text-xs tabular-nums text-gray-500 dark:text-gray-400`,children:[`-`,U(B.value-P.value)]})]})]})]})}function Be({markers:e,audioPlayer:n,language:r=`en`}){let o=()=>de(I.value??{});t(()=>{O.value=ue(e,I.value??{},P.value,B.value)},[P.value,e]);let s=e=>{let t=G(e)+o();S.value=t,n.current&&(n.current.currentTime=t)},u=()=>{let t=P.value,n=o(),r=e.findIndex(e=>t<G(e)+n),i=r>0?r-2:e.length-1;i>=0&&e[i]&&s(e[i])},d=()=>{let t=P.value,n=o(),r=e.find(e=>G(e)+n>t+1);r&&s(r)},f=e=>`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,`0`)}`;return!e||e.length===0?a(`div`,{class:`flex flex-col items-center justify-center h-full min-h-[400px] text-gray-500 dark:text-gray-400 p-4`,children:[a(`svg`,{class:`w-12 h-12 mb-2`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:a(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`})}),a(`p`,{class:`text-sm`,children:i(`player.noSections`,r)}
1),a(`p`,{class:`text-xs mt-1`,children:i(`player.noSectionsHint`,r)})]}):a(`div`,{class:`flex flex-col h-full p-4`,children:[a(`div`,{class:`flex items-center justify-between pb-4 border-b border-gray-200 dark:border-slate-700`,children:[a(`button`,{onClick:u,class:`flex items-center gap-1 text-sm text-gray-600 dark:text-gray-400 hover:text-[var(--primary)] transition-colors`,children:[a(c,{size:16}),`Previous`]}),a(`span`,{class:`text-sm font-medium text-gray-600 dark:text-gray-400`,children:[e.length,` section`,e.length===1?``:`s`]}),a(`button`,{onClick:d,class:`flex items-center gap-1 text-sm text-gray-600 dark:text-gray-400 hover:text-[var(--primary)] transition-colors`,children:[`Next`,a(l,{size:16})]})]}),a(`div`,{class:`relative py-6`,children:a(`div`,{class:`relative h-2 bg-gray-200 dark:bg-slate-700 rounded-full overflow-hidden`,children:[a(`div`,{class:`absolute top-0 left-0 h-full bg-[var(--primary)] transition-all duration-300`,style:{width:`${P.value/B.value*100}%`}}),e.map((e,t)=>{let n=((e.start_time||e.startsecond||0)+o())/B.value*100,r=O.value?.id===e.id;return t>0?a(`div`,{class:`absolute top-1/2 -translate-y-1/2 w-1 h-4 bg-white dark:bg-slate-800 cursor-pointer hover:bg-[var(--primary)] transition-colors ${r?`bg-[var(--primary)]`:``}`,style:{left:`${n}%`},onClick:()=>s(e),title:e.title||e.name},e.id):null})]})}),a(`div`,{class:`flex-1 overflow-y-auto space-y-2 min-h-0`,children:e.map(e=>{let t=e.start_time||e.startsecond||0,n=O.value?.id===e.id;return a(`div`,{onClick:()=>s(e),class:`p-3 rounded-lg border cursor-pointer transition-all ${n?`border-[var(--primary)] bg-[var(--primary)]/10`:`border-gray-200 dark:border-slate-700 hover:border-[var(--primary)]/50`}`,children:a(`div`,{class:`flex items-start gap-3`,children:[e.image?a(`div`,{class:`relative w-12 h-12 flex-shrink-0 group/image overflow-hidden rounded`,children:[a(`img`,{src:e.image,alt:e.title||e.name||``,class:`w-full h-full object-cover`}),a(`div`,{class:`absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 transition-opacity group-hover/image:opacity-100`,children:a(`div`,{class:`w-8 h-8 rounded-full bg-white/90 text-gray-900 backdrop-blur-sm shadow-sm flex items-center justify-center`,children:a(m,{size:14,class:`ml-0.5`})})})]}):a(`div`,{class:`w-12 h-12 flex-shrink-0 rounded bg-gray-200 dark:bg-slate-700 flex items-center justify-center`,children:a(`svg`,{class:`w-6 h-6 text-gray-400`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:a(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M9 19V6l12-3v13M9 19c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zm12-3c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zM9 10l12-3`})})}),a(`div`,{class:`flex-1 min-w-0`,children:[a(`div`,{class:`flex items-center justify-between gap-2`,children:[a(`h4`,{class:`text-sm font-medium truncate ${n?`text-[var(--primary)]`:`text-gray-900 dark:text-white`}`,children:e.title||e.name}),a(`span`,{class:`text-xs text-gray-500 dark:text-gray-400 flex-shrink-0`,children:f(t)})]}),e.descr&&a(`p`,{class:`text-xs text-gray-600 dark:text-gray-400 mt-1 line-clamp-2`,children:e.descr})]})]})},e.id)})})]})}function Ve({radioInfo:t}){let[r,o]=n(null),[s,c]=n(null),l=(e,t)=>{o(t),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t)))},u=(e,t)=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),c(t)},p=()=>{o(null),c(null)},h=(e,t)=>{e.preventDefault();let n=parseInt(e.dataTransfer?.getData(`text/plain`)||`0`);n!==t&&T(n,t),o(null),c(null)},g=e=>`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,`0`)}`;return E.value.length===0?a(`div`,{class:`flex flex-col items-center justify-center h-full min-h-[400px] text-gray-500 dark:text-gray-400 p-4`,children:[a(`svg`,{class:`w-12 h-12 mb-2`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:a(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10`})}),a(`p`,{class:`text-sm`,children:i(`player.queueEmpty`,t?.language||`en`)}),a(`p`,{class:`text-xs mt-1`,children:i(`player.queueEmptyHint`,t?.language||`en`)})]}):a(`div`,{class:`flex flex-col h-full p-4`,children:[a(`div`,{class:`flex items-center justify-between pb-4 border-b border-gray-200 dark:border-slate-700`,children:[a(`p`,{class:`text-sm font-medium text-gray-600 dark:text-gray-400`,children:[E.value.length,` `,E.value.length===1?i(`player.queueItem`,t?.language||`en`):i(`player.queueItems`,t?.language||`en`)]}),a(`button`,{onClick:ne,class:`text-xs text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 transition-colors`,children:i(`player.clearQueue`,t?.language||`en`)})]}),a(`div`,{class:`flex-1 overflow-y-auto space-y-2 pt-4 min-h-0`,children:E.value.map((n,o)=>a(`div`,{draggable:!0,onDragStart:e=>l(e,o),onDragOver:e=>u(e,o),onDragEnd:p,onDrop:e=>h(e,o),class:`queue-item p-3 cursor-move ${r===o?`dragging`:``} ${s===o?`border-[var(--primary)]`:``} ${R.value===o?`border-[var(--primary)] bg-[var(--primary)]/5`:``}`,children:a(`div`,{class:`flex items-center gap-3`,children:[a(`div`,{class:`text-gray-400 dark:text-gray-600`,children:a(pe,{size:16})}),a(`div`,{class:`w-10 h-10 rounded bg-gray-200 dark:bg-slate-700 flex-shrink-0 overflow-hidden`,children:n.episode.image?a(`img`,{src:n.episode.image,alt:n.episode.title,class:`w-full h-full object-cover`}):a(`div`,{class:`w-full h-full flex items-center justify-center text-gray-400`,children:a(`svg`,{class:`w-5 h-5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:a(`path`,{d:`M12 3v10.55c-.59-.34-1.27-.55-2-.55-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4V7h4V3h-6z`})})})}),a(`div`,{class:`flex-1 min-w-0`,children:[a(`div`,{class:`flex items-center gap-2`,children:[a(`h4`,{class:`text-sm font-medium text-gray-900 dark:text-white truncate`,children:n.episode.title}),n.type===`moment`&&a(`span`,{class:`text-xs px-1.5 py-0.5 bg-blue-100 dar
1k:bg-blue-900 text-blue-700 dark:text-blue-300 rounded`,children:i(`player.moment`,t?.language||`en`)})]}),a(`div`,{class:`flex items-center gap-3 text-xs text-gray-500 dark:text-gray-400`,children:n.type===`moment`&&n.moment?a(e,{children:[a(`span`,{class:`flex items-center gap-1`,children:[a(d,{size:12}),g(n.moment.startTime),n.moment.endTime&&` - ${g(n.moment.endTime)}`]}),n.moment.sourceTitle&&a(`span`,{class:`flex items-center gap-1 truncate`,children:[a(f,{size:12}),n.moment.sourceTitle]})]}):a(`span`,{children:n.episode.programTitle})})]}),a(`div`,{class:`flex items-center gap-1`,children:[R.value!==o&&a(`button`,{onClick:()=>{R.value=o,re(n)},class:`w-8 h-8 rounded-full player-control flex items-center justify-center`,"aria-label":i(`player.playNow`,t?.language||`en`),children:a(m,{size:14})}),a(`button`,{onClick:()=>ie(o),class:`w-8 h-8 rounded-full player-control flex items-center justify-center text-red-600 dark:text-red-400`,"aria-label":i(`player.removeFromQueue`,t?.language||`en`),children:a(b,{size:14})})]})]})},n.id))})]})}function He({radioInfo:r,audioPlayer:o,markers:s=[]}){let[c,l]=n(!1),[u,d]=n(!1);t(()=>{if(D.value)d(!0),requestAnimationFrame(()=>{l(!0)});else{l(!1);let e=setTimeout(()=>{d(!1)},300);return()=>clearTimeout(e)}},[D.value]),t(()=>{let e=e=>{e.key===`Escape`&&D.value&&(D.value=!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let f=e=>{e.target?.classList.contains(`panel-backdrop`)&&(D.value=!1)};if(!u)return null;let p=V.value===`sections`?i(`player.sections`,r?.language||`en`):i(`player.queue`,r?.language||`en`);return a(e,{children:[a(`div`,{class:`panel-backdrop fixed inset-0 bg-black/30 z-[60] transition-opacity duration-300 ${c?`opacity-100`:`opacity-0`}`,onClick:f}),a(`div`,{class:`fixed right-0 top-0 bottom-0 w-full max-w-md bg-white dark:bg-slate-900 shadow-xl z-[61] transform transition-transform duration-300 ease-out ${c?`translate-x-0`:`translate-x-full`}`,children:[a(`div`,{class:`sticky top-0 z-10 flex items-center justify-between p-4 border-b border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900`,children:[a(`h2`,{class:`text-lg font-semibold text-gray-900 dark:text-white`,children:p}),a(`button`,{onClick:()=>D.value=!1,class:`w-8 h-8 rounded-full hover:bg-gray-100 dark:hover:bg-slate-800 flex items-center justify-center transition-colors`,"aria-label":i(`player.close`,r?.language||`en`),children:a(b,{size:18,class:`text-gray-600 dark:text-gray-400`})})]}),a(`div`,{class:`h-[calc(100vh-64px)] overflow-hidden`,children:V.value===`sections`?a(Be,{markers:s,audioPlayer:o,language:r?.language||`en`}):a(Ve,{radioInfo:r})})]})]})}function Ue(){let i=r(null),o=r(null),[s,c]=n(null),[l,u]=n(null),[d,f]=n([]),p=r(null),m=r(null),h=r(!1),g=r(0);t(()=>{typeof window<`u`&&(window.radioCodename&&(x.value=window.radioCodename),window.radioInfo&&c(window.radioInfo))},[]);let _=r({playing:!1,key:``,name:``});t(()=>{let e=L.value,t=I.value,n=!t,r=n?`live`:`ep:${t.id}`,i=n?s?.name||`live`:[t.programTitle,t.title].filter(Boolean).join(` — `)||String(t.id),a=_.current;e&&(!a.playing||a.key!==r)?le(`Player`,n?`Play Live`:`Play Episode`,i):!e&&a.playing&&le(`Player`,a.key===`live`?`Pause Live`:`Pause Episode`,a.name||i),_.current={playing:e,key:r,name:i}},[L.value,I.value]),t(()=>{!I.value||M.value?Q():L.value||Ee()},[L.value,I.value?.id,M.value]),t(()=>{if(typeof window>`u`)return;function e(e){let t=e,n=Number(t.detail?.t??0);n>0&&(S.value=n),t.detail?.autoplay&&(L.value=!0)}function t(){try{let e=new URL(window.location.href),t=e.searchParams.get(`t`),n=e.searchParams.get(`autoplay`);if(t==null&&n==null)return;let r=Math.max(0,Math.floor(Number(t)||0));r>0&&(S.value=r),(n===`1`||n===`true`)&&(L.value=!0),e.searchParams.delete(`t`),e.searchParams.delete(`autoplay`),`replaceState`in window.history&&window.history.replaceState(null,``,e.toString())}catch{}}return window.addEventListener(`rag-handoff`,e),t(),document.addEventListener(`astro:page-load`,t),()=>{window.removeEventListener(`rag-handoff`,e),document.removeEventListener(`astro:page-load`,t)}},[]),t(()=>{let e=()=>{let t=i.current?.currentTime;t!==void 0&&Math.abs(t-P.peek())>=.25&&(P.value=t,B.value=i.current.duration||0,d.length>0&&!M.value&&(O.value=ue(d,I.value??{},t,B.value))),o.current=requestAnimationFrame(e)};return L.value&&!M.value?o.current=requestAnimationFrame(e):o.current&&cancelAnimationFrame(o.current),()=>{o.current&&cancelAnimationFrame(o.current)}},[L.value,M.value,d]),t(()=>{if(typeof window>`u`)return;async function e(){if(!(!x.value||x.value.trim()===``)){(s?.now_playing_program_codename||s?.now_playing_program_id)&&u({current_program:{name:s.now_playing_program_codename,id:s.now_playing_program_id}});try{let e=`${W()}/now_playing/?page_size=100&radio=${x.value}`,t=await fetch(e);t.ok&&u(await t.json())}catch(e){console.error(`Error fetching live data:`,e)}}}e();let t=setInterval(e,v.PLAYER.LIVE_DATA_REFRESH);return()=>clearInterval(t)},[x.value,s?.now_playing_program_codename]),t(()=>{if(typeof window>`u`||(f([]),!I.value))return;if(I.value.markers){f(I.value.markers);return}async function e(){if(I.value?.episodeNumber)try{let e=await fetch(`${W()}/podcasts/${I.value.episodeNumber}/markers/?ts=${Date.now()}`);e.ok?f((await e.json()).results||[]):f([])}catch(e){console.error(`Error fetching markers:`,e),f([])}}e()},[I.value?.id]),t(()=>{if(I.value===null&&s&&i.current){let e=F.value?s.stream_hd_url:s.stream_sd_url;e&&(i.current.src=e,M.value=!0,O.value=null,L.value&&(C.current=i.current.play().then(()=>{C.current=null}).catch(e=>{C.current=null,console.error(`Error playing live stream:`,e),L.value=!1})))}},[s,F.value,I.value]),t(()=>{if(M.value&&s&&i.current){let e=L.value,t=F.value?s.stream_hd_url:s.stream_sd_url;i.current.src=t,e&&(C.current=i.current.play().then(()=>{C.current=null}).catch(e=>{C.current=null,console.error(`Error playing live stream after HD toggle:`,e),L.value=!1}))}},[F.value]),t(()=>{if(S.value!==null&&i.current&&I.value&&!M.value&&L.value&&i.current.src===I.value.audio){let e=S.value;if(i.current.readyState>=2)i.current.currentTime=e,S.value=null;else{let t=()=>{i.current&&(i.current.currentTime=e,S.value=null),i.current?.removeEventListener(`canplay`,t)};i.current.addEventListener(`canplay`,t)}}},[S.value]);let y=H.value!==`bar`,ee=!!(s?.stream_sd_url||s?.stream_hd_url),b=H.value!==`idle`||ee;t(()=>{if(typeof window>`u`||!(`mediaSession`in navigator))return;(()=>{try{if(M.value&&s){let e=[{size:`96x96`},{size:`128x128`},{size:`192x192`},{size:`256x256`},{size:`384x384`},{size:`512x512`}],t=Le(null,l,s);
1navigator.mediaSession.metadata=new MediaMetadata({title:l?.current_program?.name||`Escoltant ${s.name}`,artist:s.name,album:`Ràdio en directe`,artwork:t?e.map(e=>({src:t,sizes:e.size,type:`image/png`})):[]})}else if(I.value){let e=I.value,t=Le(e,l,s),n=[{size:`96x96`},{size:`128x128`},{size:`192x192`},{size:`256x256`},{size:`384x384`},{size:`512x512`}],r=e.title;if(O.value){let t=O.value.name||O.value.title;t&&(r=`${e.title} - ${t}`)}if(navigator.mediaSession.metadata=new MediaMetadata({title:r,artist:e.programTitle||s?.name||``,album:s?.name||`Podcast`,artwork:t?n.map(e=>({src:t,sizes:e.size,type:`image/png`})):[]}),`setPositionState`in navigator.mediaSession&&B.value>0)try{navigator.mediaSession.setPositionState({duration:B.value,playbackRate:1,position:P.value||0})}catch(e){console.error(`Error setting position state:`,e)}}}catch(e){console.error(`Error updating MediaSession:`,e)}})(),(()=>{try{navigator.mediaSession.setActionHandler(`play`,()=>{L.value=!0}),navigator.mediaSession.setActionHandler(`pause`,()=>{L.value=!1}),M.value?(navigator.mediaSession.setActionHandler(`seekbackward`,null),navigator.mediaSession.setActionHandler(`seekforward`,null),navigator.mediaSession.setActionHandler(`seekto`,null),navigator.mediaSession.setActionHandler(`nexttrack`,null),navigator.mediaSession.setActionHandler(`previoustrack`,null)):(navigator.mediaSession.setActionHandler(`seekbackward`,e=>{if(i.current){let t=e.seekOffset||10;i.current.currentTime=Math.max(0,i.current.currentTime-t)}}),navigator.mediaSession.setActionHandler(`seekforward`,e=>{if(i.current){let t=e.seekOffset||10;i.current.currentTime=Math.min(i.current.duration||0,i.current.currentTime+t)}}),navigator.mediaSession.setActionHandler(`seekto`,e=>{i.current&&e.seekTime!==void 0&&(i.current.currentTime=e.seekTime,e.fastSeek&&`fastSeek`in i.current&&i.current.fastSeek(e.seekTime))}),E.value.length>0?(navigator.mediaSession.setActionHandler(`nexttrack`,()=>{R.value<E.value.length-1&&j()}),R.value>0?navigator.mediaSession.setActionHandler(`previoustrack`,()=>{let e=R.value-1;if(e>=0){R.value=e;let t=E.value[e];I.value=t.episode,t.moment&&(S.value=t.moment.startTime),L.value=!0}}):navigator.mediaSession.setActionHandler(`previoustrack`,null)):(navigator.mediaSession.setActionHandler(`nexttrack`,null),navigator.mediaSession.setActionHandler(`previoustrack`,null)))}catch(e){console.error(`Error setting up MediaSession action handlers:`,e)}})();let e=null;return!M.value&&L.value&&B.value>0&&(e=setInterval(()=>{if(`setPositionState`in navigator.mediaSession&&i.current)try{navigator.mediaSession.setPositionState({duration:B.value,playbackRate:1,position:i.current.currentTime})}catch{}},1e3)),()=>{e&&clearInterval(e)}},[I.value,M.value,s,l,O.value,L.value,B.value,E.value.length,R.value]),t(()=>{if(!i.current)return;let e=i.current,t=()=>{Q(),k.value=!0},n=()=>{k.value=!1},r=()=>{L.value=!1,I.value&&!M.value&&(se(I.value.id,e.duration||B.value),De()),R.value<E.value.length-1&&j()},a=e=>{console.error(`Audio playback error:`,e),k.value=!1,L.value=!1},o=()=>{if(I.value&&!M.value&&e.duration>0){let t=Date.now();t-g.current>5e3&&(ae(I.value.id,e.currentTime,e.duration),g.current=t)}let t=z.value;if(t&&!M.value){let n=e.currentTime;p.current===t?n>=t.end&&n<t.end+1?(z.value=null,L.value=!1):(n>=t.end+1||n<t.start-1)&&(z.value=null):n>=t.start-1&&n<t.end&&(p.current=t)}if(I.value&&I.value.recording_type===`automatically_recorded`&&I.value.ai_detected_end_offset_seconds!==void 0&&!h.current&&!M.value){let t=e.currentTime,n=I.value.ai_detected_end_offset_seconds;t>=n&&t<n+.5&&(h.current=!0,L.value=!1)}I.value&&I.value.ai_detected_end_offset_seconds!==void 0&&h.current&&e.currentTime<I.value.ai_detected_end_offset_seconds-1&&(h.current=!1)},s=()=>{I.value&&!M.value&&e.duration>0&&(ae(I.value.id,e.currentTime,e.duration),g.current=Date.now())},c=Oe(e,()=>I.value&&!M.value?String(I.value.id):null);return e.addEventListener(`loadstart`,t),e.addEventListener(`canplay`,n),e.addEventListener(`ended`,r),e.addEventListener(`error`,a),e.addEventListener(`timeupdate`,o),e.addEventListener(`pause`,s),window.addEventListener(`beforeunload`,s),document.addEventListener(`visibilitychange`,s),()=>{c(),e.removeEventListener(`loadstart`,t),e.removeEventListener(`canplay`,n),e.removeEventListener(`ended`,r),e.removeEventListener(`error`,a),e.removeEventListener(`timeupdate`,o),e.removeEventListener(`pause`,s),window.removeEventListener(`beforeunload`,s),document.removeEventListener(`visibilitychange`,s)}},[]);let C=r(null);return t(()=>{if(i.current&&I.value){M.value=!1;let e=S.value||I.value._seekToTime||null,t=I.value;if(i.current.src===t.audio){if(e!==null){if(i.current.readyState>=2)i.current.currentTime=e;else{let t=()=>{i.current&&(i.current.currentTime=e),i.current?.removeEventListener(`canplay`,t)};i.current.addEventListener(`canplay`,t)}S.value=null,I.value&&I.value._seekToTime&&delete I.value._seekToTime}m.current=t.id,i.current.paused&&(C.current=i.current.play().then(()=>{C.current=null,L.value||=!0}
1).catch(e=>{C.current=null,console.error(`Error playing audio after seek:`,e),L.value=!1}));return}i.current.src=t.audio,h.current=!1;let n=e===null?oe(t.id):e;if(n!==null){let e=()=>{i.current&&(i.current.currentTime=n,S.value=null,I.value&&I.value._seekToTime&&delete I.value._seekToTime,m.current=t.id),i.current?.removeEventListener(`loadedmetadata`,e)};i.current.addEventListener(`loadedmetadata`,e)}else if(t.recording_type===`automatically_recorded`&&t.ai_detected_start_offset_seconds!==void 0&&t.ai_detected_start_offset_seconds>0&&m.current!==t.id){let e=()=>{i.current&&I.value?.id===t.id&&(i.current.currentTime=t.ai_detected_start_offset_seconds,m.current=t.id),i.current?.removeEventListener(`loadedmetadata`,e)};i.current.addEventListener(`loadedmetadata`,e)}else i.current.currentTime=0,m.current=t.id;C.current=i.current.play().then(()=>{C.current=null,L.value||=!0}).catch(e=>{C.current=null,console.error(`Error playing audio after episode change:`,e),L.value=!1}),O.value=null}},[I.value]),t(()=>{L.value?!C.current&&i.current&&(M.value&&i.current.currentTime>0&&i.current.load(),C.current=i.current.play().then(()=>{C.current=null}).catch(e=>{C.current=null,console.error(`Error playing audio:`,e),L.value=!1})):C.current?C.current.then(()=>{i.current?.pause()}).catch(()=>{}):i.current?.pause()},[L.value]),t(()=>{i.current&&(i.current.volume=N.value)},[N.value]),t(()=>{let e=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement))switch(e.key){case` `:e.preventDefault(),L.value=!L.value;break;case`ArrowLeft`:e.preventDefault(),i.current&&!M.value&&(i.current.currentTime=Math.max(0,i.current.currentTime-10));break;case`ArrowRight`:e.preventDefault(),i.current&&!M.value&&(i.current.currentTime=Math.min(i.current.duration,i.current.currentTime+10));break;case`m`:case`M`:e.preventDefault(),A.value=!A.value;break;case`Escape`:w.value===`mini`&&(w.value=`standard`);break}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),a(e,{children:[a(`div`,{class:`player pointer-events-none fixed inset-x-0 bottom-2 z-50 flex justify-end px-2 sm:bottom-4 sm:px-4`,children:[s&&b&&a(`div`,{class:`player-shell player-flat-elevated pointer-events-auto w-full overflow-hidden ${y?`max-w-sm rounded-full`:`max-w-4xl rounded-2xl`}`,children:y?a(Ae,{radioInfo:s,liveProgram:l}):a(ze,{radioInfo:s,audioPlayer:i,liveProgram:l,markers:d})}),a(`div`,{class:`hidden`,children:a(`audio`,{ref:i,muted:A.value,preload:`metadata`})})]}),a(He,{radioInfo:s,audioPlayer:i,markers:d})]})}export{Ue as default};

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.