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:`798154dfe6f02312abe2ebb46dcac5b55267091e`},e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[new e.Error().stack]=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n!=null)for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},e._sentryModuleMetadata[new e.Error().stack],{"_sentryBundlerPluginAppKey:listening-web":!0});var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`b0f45a38-18a2-4068-a90b-66b3d4ae24ad`,e._sentryDebugIdIdentifier=`sentry-dbid-b0f45a38-18a2-4068-a90b-66b3d4ae24ad`)}catch{}})();import{a as e,n as t}from"./jsx-runtime-HLTtilDO.js";import{G as n,H as r,J as i,K as a,U as o,W as s,X as c,Y as l,at as u,bt as d,ft as f,gt as p,mt as m,q as h,rt as g}from"./api-contract-CCE5gx-b.js";import{t as _}from"./queryOptions-DE5Kx4Uw.js";import{t as v}from"./compiler-runtime-UO9gZYRt.js";import{n as y}from"./react-helpers-EueCGTnS.js";import{i as b,l as x,n as S}from"./ts-utils-D2QbVWoH.js";import{i as C}from"./hooks-BaFHpKzn.js";function w(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var T=class extends u{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,g.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!p(e,n)});(o||s)&&(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(w(e,n).forEach(e=>{e.destroy()}),w(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(e),t.forEach(t=>{t.observer.trackProp(e)}))})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=m(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new c(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&g.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},E=e(t(),1);function D({queries:e,...t},u){let p=d(u),m=l(),_=i(),v=t.subscribed!==!1,y=E.useMemo(()=>e.map(e=>{let t=p.defaultQueryOptions(e);return t._optimisticResults=m?`isRestoring`:v?`optimistic`:void 0,t}),[e,p,m,v]);y.forEach(e=>{r(e);let t=p.getQueryCache().get(e.queryHash);n(e,_,t)}),h(_);let[b]=E.useState(()=>new T(p,y,t)),[x,S,C]=b.getOptimisticResult(y,t.combine),w=!m&&v;E.useSyncExternalStore(E.useCallback(e=>w?b.subscribe(g.batchCalls(e)):f,[b,w]),()=>b.getCurrentResult(),()=>b.getCurrentResult()),E.useEffect(()=>{b.setQueries(y,t)},[y,t,b]);let D=x.some((e,t)=>s(y[t],e))?x.flatMap((e,t)=>{let n=y[t];if(n&&s(n,e)){let e=new c(p,n);return o(n,e,_)}return[]}):[];if(D.length>0)throw Promise.all(D);let O=x.find((e,t)=>{let n=y[t];return n&&a({result:e,errorResetBoundary:_,throwOnError:n.throwOnError,query:p.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(O)throw O.error;return S(C())}var O=v();function k(e,t=2){return Math.floor(e/t)}
1function A(e,t,n=2){let r=b(t,n);return r.map((t,i)=>({audioId:e,cursor:i===0?``:S(S(r[i-1]).at(-1)).id,limit:n}))}function j({chunkCount:e,anchorChapterIndices:t,behind:n,ahead:r,alwaysFirstChunk:i,chunkSize:a=2}){let o=new Set;i&&e>0&&o.add(0);for(let i of t){if(i<0)continue;let t=k(i,a);if(t>=e)continue;let s=Math.max(0,t-n),c=Math.min(e-1,t+r);for(let e=s;e<=c;e+=1)o.add(e)}return o}var M=6e5,N=e=>[`text-extraction-data`,e],P=(e,t)=>_({queryKey:N(e),queryFn:()=>t(e),staleTime:1/0,gcTime:M}),F={status:`idle`,isPending:!0,isFetching:!1,isError:!1,error:null,data:void 0},I=(e,t)=>e.status===t.status&&e.isFetching===t.isFetching&&e.isError===t.isError&&e.error===t.error&&e.data===t.data,L=e=>[...new Set(e)].toSorted((e,t)=>e<t?-1:+(e>t));function R(e){let t=(0,O.c)(10),n=e===void 0?500:e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,E.useState)(r),o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],t[1]=o):o=t[1];let s=(0,E.useRef)(o),c=(0,E.useRef)(null),l=(0,E.useRef)(null),u,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>()=>{l.current!==null&&clearTimeout(l.current)},d=[],t[2]=u,t[3]=d):(u=t[2],d=t[3]),(0,E.useEffect)(u,d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{l.current!==null&&(clearTimeout(l.current),l.current=null),c.current!==null&&(a(c.current),c.current=null)},t[4]=f):f=t[4];let p=f,m;t[5]===n?m=t[6]:(m=e=>{let t=L(e);x(t,s.current)||(s.current=t,c.current=t,l.current!==null&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,c.current=null,a(t)},n))},t[5]=n,t[6]=m);let h=m,g;return t[7]!==h||t[8]!==i?(g={value:i,update:h,flush:p},t[7]=h,t[8]=i,t[9]=g):g=t[9],g}function z({audioId:e,chapters:t,fetchChunk:n,enabled:r=!0,currentChapterIndex:i,currentChapterPending:a=!1,visibleChapterIndices:o,alwaysFirstChunk:s,chunkSize:c}){let l=(0,E.useMemo)(()=>{let e=a?[]:o;return L(i===void 0||i<0?e:[...e,i])},[i,a,o]),u=(0,E.useMemo)(()=>A(e,t,c),[e,t,c]),f=(0,E.useMemo)(()=>L(j({chunkCount:u.length,anchorChapterIndices:l,behind:1,ahead:1,alwaysFirstChunk:s,chunkSize:c})),[s,l,u.length,c]),p=d(),m=D({queries:f.map(e=>{let t=u[e];if(t===void 0)throw Error(`chunk index out of range`);let i=P(t,n);return _({...i,enabled:r,initialData:p.getQueryData(i.queryKey)})})}),h=Array.from({length:u.length},()=>F);f.forEach((e,t)=>{let n=m[t];n&&(h[e]={status:n.status===`success`?`success`:n.status===`error`?`error`:`pending`,isPending:n.status!==`success`&&n.status!==`error`,isFetching:n.isFetching,isError:n.isError,error:n.error,data:n.data})});let g=(0,E.useRef)([]),v=g.current,y=v.length===h.length&&h.every((e,t)=>{let n=v[t];return n!==void 0&&I(n,e)})?v:h.map((e,t)=>{let n=v[t];return n!==void 0&&I(n,e)?n:e});g.current=y;let b=(0,E.useRef)([]),S=y.map(e=>e.data);return x(b.current,S)||(b.current=S),{chunkParams:u,chunkStates:y,chunkData:b.current}}var B=(0,E.createContext)(null),V=2,H=3e3,U=(e,t)=>P(e,t),W=e=>{let t=(0,O.c)(28),[n,r]=(0,E.useState)(!1),i=e.onIsActiveVisibleChange,a;t[0]===i?a=t[1]:(a=e=>{r(e),i?.(e)},t[0]=i,t[1]=a);let o=a,{fetchChapters:s,documentSummary:c}=y(B),l=C(q),u;if(t[2]!==l||t[3]!==c.chapters){let e;t[5]===l?e=t[6]:(e=e=>e.id===l,t[5]=l,t[6]=e),u=c.chapters.findIndex(e),t[2]=l,t[3]=c.chapters,t[4]=u}else u=t[4];let d=u,f=d===-1?void 0:d,p=R(),m=!e.chapterFetchingDisabled,h;t[7]!==f||t[8]!==c.chapters||t[9]!==c.id||t[10]!==s||t[11]!==m||t[12]!==p.value?(h={audioId:c.id,chapters:c.chapters,fetchChunk:s,enabled:m,currentChapterIndex:f,visibleChapterIndices:p.value,alwaysFirstChunk:!0},t[7]=f,t[8]=c.chapters,t[9]=c.id,t[10]=s,t[11]=m,t[12]=p.value,t[13]=h):h=t[13];let g=z(h),_;t[14]===g.chunkData?_=t[15]:(_=g.chunkData.map(J),t[14]=g.chunkData,t[15]=_);let v=_,b;t[16]!==p.flush||t[17]!==p.update?(b={maybeExecute:p.update,flush:p.flush},t[16]=p.flush,t[17]=p.update,t[18]=b):b=t[18];let x=b,S;t[19]!==o||t[20]!==n?(S=[n,o],t[19]=o,t[20]=n,t[21]=S):S=t[21];let w=S,T;return t[22]!==g.chunkParams||t[23]!==g.chunkStates||t[24]!==x||t[25]!==v||t[26]!==w?(T={queries:g.chunkStates,queriesDataStable:v,chapterChunksFetchParams:g.chunkParams,isActiveVisibleState:w,debouncedUpdateViewedChapters:x},t[22]=g.chunkParams,t[23]=g.chunkStates,t[24]=x,t[25]=v,t[26]=w,t[27]=T):T=t[27],T};function G(e){let t=(0,O.c)(8),{virtualizerHandleRef:n,core:r,scrollToChunk:i,ready:a}=e,o=a===void 0||a,[s,c]=(0,E.useState)(!1),l=C(K),{logger:u}=y(B),d=(0,E.useRef)(l),f,p;t[0]!==r.debouncedUpdateViewedChapters||t[1]!==u||t[2]!==o||t[3]!==i||t[4]!==s||t[5]!==n?(f=()=>{o&&n.current&&d.current&&(s||(u.info({initialAudioState:d.current},`Scrolling to initial chunk`),i(d.current),c(!0),r.debouncedUpdateViewedChapters.flush()))},p=[o,i,u,s,n,r.debouncedUpdateViewedChapters],t[0]=r.debouncedUpdateViewedChapters,t[1]=u,t[2]=o,t[3]=i,t[4]=s,t[5]=n,t[6]=f,t[7]=p):(f=t[6],p=t[7]),(0,E.useLayoutEffect)(f,p)}function K(e){return e.ttsId}function q(e){return e.chapterId}function J(e){return e?.data}export{W as a,A as c,U as i,B as n,G as o,H as r,N as s,V as t}; 2//# sourceMappingURL=core-DhCVPoyc.js.map
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.