@readerseye2/cr_viewer 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/var Tr;function Fs(){if(Tr)return wn;Tr=1;var e=m;function t(S,
|
|
10
|
+
*/var Tr;function Fs(){if(Tr)return wn;Tr=1;var e=m;function t(S,h){return S===h&&(S!==0||1/S===1/h)||S!==S&&h!==h}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,i=e.useDebugValue;function u(S,h){var g=h(),v=r({inst:{value:g,getSnapshot:h}}),w=v[0].inst,c=v[1];return s(function(){w.value=g,w.getSnapshot=h,a(w)&&c({inst:w})},[S,g,h]),o(function(){return a(w)&&c({inst:w}),S(function(){a(w)&&c({inst:w})})},[S]),i(g),g}function a(S){var h=S.getSnapshot;S=S.value;try{var g=h();return!n(S,g)}catch{return!0}}function l(S,h){return h()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:u;return wn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,wn}var Cn={};/**
|
|
11
11
|
* @license React
|
|
12
12
|
* use-sync-external-store-shim.development.js
|
|
13
13
|
*
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* This source code is licensed under the MIT license found in the
|
|
17
17
|
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/var kr;function Ns(){return kr||(kr=1,process.env.NODE_ENV!=="production"&&(function(){function e(
|
|
18
|
+
*/var kr;function Ns(){return kr||(kr=1,process.env.NODE_ENV!=="production"&&(function(){function e(g,v){return g===v&&(g!==0||1/g===1/v)||g!==g&&v!==v}function t(g,v){d||o.startTransition===void 0||(d=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var w=v();if(!S){var c=v();s(w,c)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),S=!0)}c=i({inst:{value:w,getSnapshot:v}});var f=c[0].inst,p=c[1];return a(function(){f.value=w,f.getSnapshot=v,n(f)&&p({inst:f})},[g,w,v]),u(function(){return n(f)&&p({inst:f}),g(function(){n(f)&&p({inst:f})})},[g]),l(w),w}function n(g){var v=g.getSnapshot;g=g.value;try{var w=v();return!s(g,w)}catch{return!0}}function r(g,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=m,s=typeof Object.is=="function"?Object.is:e,i=o.useState,u=o.useEffect,a=o.useLayoutEffect,l=o.useDebugValue,d=!1,S=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:t;Cn.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:h,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Cn}var Rr;function Bo(){return Rr||(Rr=1,process.env.NODE_ENV==="production"?Zt.exports=Fs():Zt.exports=Ns()),Zt.exports}/**
|
|
19
19
|
* @license React
|
|
20
20
|
* use-sync-external-store-shim/with-selector.production.js
|
|
21
21
|
*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the MIT license found in the
|
|
25
25
|
* LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/var _r;function Ds(){if(_r)return yn;_r=1;var e=m,t=Bo();function n(l,d){return l===d&&(l!==0||1/l===1/d)||l!==l&&d!==d}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,i=e.useEffect,u=e.useMemo,a=e.useDebugValue;return yn.useSyncExternalStoreWithSelector=function(l,d,S,g
|
|
26
|
+
*/var _r;function Ds(){if(_r)return yn;_r=1;var e=m,t=Bo();function n(l,d){return l===d&&(l!==0||1/l===1/d)||l!==l&&d!==d}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,i=e.useEffect,u=e.useMemo,a=e.useDebugValue;return yn.useSyncExternalStoreWithSelector=function(l,d,S,h,g){var v=s(null);if(v.current===null){var w={hasValue:!1,value:null};v.current=w}else w=v.current;v=u(function(){function f(j){if(!p){if(p=!0,C=j,j=h(j),g!==void 0&&w.hasValue){var b=w.value;if(g(b,j))return T=b}return T=j}if(b=T,r(C,j))return b;var y=h(j);return g!==void 0&&g(b,y)?(C=j,b):(C=j,T=y)}var p=!1,C,T,I=S===void 0?null:S;return[function(){return f(d())},I===null?void 0:function(){return f(I())}]},[d,S,h,g]);var c=o(l,v[0],v[1]);return i(function(){w.hasValue=!0,w.value=c},[c]),a(c),c},yn}var In={};/**
|
|
27
27
|
* @license React
|
|
28
28
|
* use-sync-external-store-shim/with-selector.development.js
|
|
29
29
|
*
|
|
@@ -31,4 +31,4 @@
|
|
|
31
31
|
*
|
|
32
32
|
* This source code is licensed under the MIT license found in the
|
|
33
33
|
* LICENSE file in the root directory of this source tree.
|
|
34
|
-
*/var Mr;function Ws(){return Mr||(Mr=1,process.env.NODE_ENV!=="production"&&(function(){function e(l,d){return l===d&&(l!==0||1/l===1/d)||l!==l&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=m,n=Bo(),r=typeof Object.is=="function"?Object.is:e,o=n.useSyncExternalStore,s=t.useRef,i=t.useEffect,u=t.useMemo,a=t.useDebugValue;In.useSyncExternalStoreWithSelector=function(l,d,S,g,h){var v=s(null);if(v.current===null){var w={hasValue:!1,value:null};v.current=w}else w=v.current;v=u(function(){function f(j){if(!p){if(p=!0,C=j,j=g(j),h!==void 0&&w.hasValue){var b=w.value;if(h(b,j))return T=b}return T=j}if(b=T,r(C,j))return b;var y=g(j);return h!==void 0&&h(b,y)?(C=j,b):(C=j,T=y)}var p=!1,C,T,I=S===void 0?null:S;return[function(){return f(d())},I===null?void 0:function(){return f(I())}]},[d,S,g,h]);var c=o(l,v[0],v[1]);return i(function(){w.hasValue=!0,w.value=c},[c]),a(c),c},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),In}var Er;function qs(){return Er||(Er=1,process.env.NODE_ENV==="production"?Yt.exports=Ds():Yt.exports=Ws()),Yt.exports}var Vs=qs();const $s=Po(Vs),jr=e=>{let t;const n=new Set,r=(l,d)=>{const S=typeof l=="function"?l(t):l;if(!Object.is(S,t)){const g=t;t=d??(typeof S!="object"||S===null)?S:Object.assign({},t,S),n.forEach(h=>h(t,g))}},o=()=>t,u={setState:r,getState:o,getInitialState:()=>a,subscribe:l=>(n.add(l),()=>n.delete(l))},a=t=e(r,o,u);return u},Vt=(e=>e?jr(e):jr),{useSyncExternalStoreWithSelector:Us}=$s,Ks=e=>e;function $t(e,t=Ks,n){const r=Us(e.subscribe,e.getState,e.getInitialState,t,n);return m.useDebugValue(r),r}function X(e,t){const n=m.useContext(ir);if(!n)throw new Error("useCRViewerScopedStore must be used inside <InternalCRViewerProvider>");return $t(n,e,t)}function gn(){const e=m.useContext(ir);if(!e)throw new Error("useCRViewerStoreApi must be used inside <InternalCRViewerProvider>");return e}const mt=m.createContext(void 0),Lo=m.createContext(void 0);function Xs(){return Vt((e,t)=>({emitCallback:null,isPlaybackMode:!1,playbackScale:1,dispatchHandler:null,applySnapshotHandler:null,wordAvgDistancePx:0,setEmitCallback:n=>e({emitCallback:n}),emit:(n,r)=>{const{emitCallback:o,isPlaybackMode:s}=t();s||o&&o({...n,timestamp:r??Date.now()})},setPlaybackMode:n=>e({isPlaybackMode:n}),setPlaybackScale:n=>e({playbackScale:n}),setDispatchHandler:n=>e({dispatchHandler:n}),dispatch:n=>{const{dispatchHandler:r,isPlaybackMode:o}=t();if(!o){console.warn("[ViewerEventBridge] dispatch called but not in playback mode");return}r?r(n):console.warn("[ViewerEventBridge] dispatch called but no handler registered")},setApplySnapshotHandler:n=>e({applySnapshotHandler:n}),applySnapshot:n=>{const{applySnapshotHandler:r,isPlaybackMode:o}=t();if(!o){console.warn("[ViewerEventBridge] applySnapshot called but not in playback mode");return}r?r(n):console.warn("[ViewerEventBridge] applySnapshot called but no handler registered")}}))}function Qs({children:e,onViewerEvent:t,isPlaybackMode:n=!1,playbackScale:r=1,viewerRef:o}){const s=m.useMemo(()=>Xs(),[]);return m.useLayoutEffect(()=>(s.getState().setEmitCallback(t??null),()=>s.getState().setEmitCallback(null)),[t,s]),m.useLayoutEffect(()=>{s.getState().setPlaybackMode(n)},[n,s]),m.useLayoutEffect(()=>{s.getState().setPlaybackScale(r)},[r,s]),m.useLayoutEffect(()=>()=>{o&&(o.current=null)},[o]),x.jsx(mt.Provider,{value:s,children:x.jsx(Lo.Provider,{value:o,children:e})})}function Go(e,t){const n=m.useContext(mt);if(!n)throw new Error("useViewerEventBridgeStore must be used inside <ViewerEventBridgeProvider>");return $t(n,e,t)}function bt(){const e=m.useContext(mt);if(!e)throw new Error("useViewerEventBridgeStoreApi must be used inside <ViewerEventBridgeProvider>");return e}const lr=m.createContext(void 0);function lt(){const e=m.useContext(lr);if(!e)throw new Error("useProgressStoreApi must be used within InternalCRViewerProgressProvider");return e}function V(e,t){const n=m.useContext(lr);if(!n)throw new Error("useProgressStore must be used within InternalCRViewerProgressProvider");return $t(n,o=>e(o.progress),t)}function Ys({onSingle:e,onDouble:t,delay:n=250,shouldIgnoreTarget:r}){const o=m.useRef(null);m.useEffect(()=>()=>{o.current!=null&&(clearTimeout(o.current),o.current=null)},[]);const s=m.useCallback(u=>{if(!(r!=null&&r(u.target))&&u.detail===1){if(o.current!=null)return;o.current=window.setTimeout(()=>{o.current=null,e==null||e(u)},n)}},[n,e,r]),i=m.useCallback(u=>{r!=null&&r(u.target)||o.current!=null&&(clearTimeout(o.current),o.current=null)},[t,r]);return{onClick:s,onDoubleClick:i}}const sn={light:{bg:"#ffffff",fg:"#111827",overlayBg:"#ffffff",overlayFg:"#111827",borderColor:"#333333"},dark:{bg:"#0b0b0b",fg:"#e5e7eb",overlayBg:"#0b0b0b",overlayFg:"#e5e7eb",borderColor:"#ffffff"},sepia:{bg:"#f4ecd8",fg:"#3e2f1c",overlayBg:"#f4ecd8",overlayFg:"#3e2f1c",borderColor:"#bfa87a"},green:{bg:"#e9f5e1",fg:"#1b3d1f",overlayBg:"#e9f5e1",overlayFg:"#1b3d1f",borderColor:"#93b48b"}},Tn=[8,16,24,40,64],kn=[1.2,1.4,1.6,1.8,2,2.2,2.4],Rn=[4,8,12,16,24],Zn=e=>Math.round(12+(e-1)*(16/11)),Zs=e=>{let t=1,n=1/0;for(let r=1;r<=12;r++){const o=Zn(r),s=Math.abs(o-e);s<n&&(t=r,n=s)}return t},_n=(e,t)=>{let n=0,r=1/0;return t.forEach((o,s)=>{const i=Math.abs(o-e);i<r&&(r=i,n=s)}),n+1},Ho=[{label:"고딕체",value:"'Noto Sans KR', sans-serif"},{label:"명조체",value:"'Noto Serif KR', serif"},{label:"바탕체",value:"'Nanum Myeongjo', serif"}],He={mode:"page",theme:"light",fontFamily:Ho.find(e=>e.label==="명조체").value,fontSizePx:18,lineHeight:1.8,marginX:20,marginY:24,showOverlays:!0,overlayCompactMode:!0,isSettingsOpen:!1,pointerStyle:"highlight",pointerColor:"#fff59d",breakMarks:{slash:!0},breakGapPx:8,muteAudio:!1,audioSpeed:1,showPointer:!0,showSplit:!0,viewportWidth:0,viewportHeight:0,isDev:!1};function Js(e){const{init:t,recorderStore:n}=e??{};return Vt((r,o)=>({...He,...t,setMode:s=>r({mode:s}),setTheme:s=>r({theme:s}),setFontFamily:s=>r({fontFamily:s}),setFontSizePx:s=>r({fontSizePx:s}),setLineHeight:s=>r({lineHeight:s}),setMarginX:s=>r({marginX:s}),setMarginY:s=>r({marginY:s}),setShowOverlays:s=>r({showOverlays:s}),toggleOverlays:()=>{const s=!o().showOverlays;r({showOverlays:s,...s&&{overlayCompactMode:!0}})},setOverlayCompactMode:s=>r({overlayCompactMode:s}),toggleOverlayCompactMode:()=>r({overlayCompactMode:!o().overlayCompactMode}),setSettingsOpen:s=>r({isSettingsOpen:s}),resetToDefaults:()=>r(s=>({mode:He.mode,theme:He.theme,fontFamily:He.fontFamily,fontSizePx:He.fontSizePx,lineHeight:He.lineHeight,marginX:He.marginX,marginY:He.marginY,showOverlays:!1,isSettingsOpen:!0,pointerStyle:He.pointerStyle,pointerColor:He.pointerColor,breakMarks:He.breakMarks,breakGapPx:He.breakGapPx,muteAudio:He.muteAudio,audioSpeed:He.audioSpeed,showPointer:He.showPointer,showSplit:He.showSplit})),maps:{MARGIN_MAP:Tn,LINEHEIGHT_MAP:kn,BREAK_GAP_MAP:Rn,fontSizeFromLevel:Zn},setPointerStyle:s=>r({pointerStyle:s}),setPointerColor:s=>r({pointerColor:s}),toggleBreakMark:s=>{const i=o().breakMarks;r({breakMarks:{...i,[s]:!i[s]}})},setBreakMarks:s=>{r({breakMarks:{...o().breakMarks,...s}})},setBreakGapPx:s=>r({breakGapPx:s}),setBreakGapLevel:s=>{const i=Rn[Math.max(1,Math.min(5,s))-1];r({breakGapPx:i})},getBreakGapLevel:()=>_n(o().breakGapPx,Rn),getFontLevel:()=>Zs(o().fontSizePx),getLineLevel:()=>_n(o().lineHeight,kn),getMarginLevel:()=>_n(o().marginX,Tn),setFontLevel:s=>r({fontSizePx:Zn(Math.max(1,Math.min(12,s)))}),setLineLevel:s=>r({lineHeight:kn[Math.max(1,Math.min(7,s))-1]}),setMarginLevel:s=>{const i=Tn[Math.max(1,Math.min(5,s))-1];r({marginX:i,marginY:i})},setMuteAudio:s=>{r({muteAudio:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"muteAudio",value:s}})},toggleMuteAudio:()=>{const s=!o().muteAudio;r({muteAudio:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"muteAudio",value:s}})},setAudioSpeed:s=>{const i=Math.max(.3,Math.min(2,s));r({audioSpeed:i}),n==null||n.getState().emit({type:"settings_change",payload:{key:"audioSpeed",value:i}})},incAudioSpeed:()=>{const s=Math.min(2,Math.round((o().audioSpeed+.05)*100)/100);r({audioSpeed:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"audioSpeed",value:s}})},decAudioSpeed:()=>{const s=Math.max(.3,Math.round((o().audioSpeed-.05)*100)/100);r({audioSpeed:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"audioSpeed",value:s}})},setShowPointer:s=>r({showPointer:s}),toggleShowPointer:()=>r({showPointer:!o().showPointer}),setShowSplit:s=>r({showSplit:s}),toggleShowSplit:()=>r({showSplit:!o().showSplit}),setViewportSize:(s,i)=>r({viewportWidth:s,viewportHeight:i})}))}const hn=0,xt=1,jt=2,Fo=4;function Or(e){return()=>e}function ei(e){e()}function No(e,t){return n=>e(t(n))}function zr(e,t){return()=>e(t)}function ti(e,t){return n=>e(t,n)}function ar(e){return e!==void 0}function ni(...e){return()=>{e.map(ei)}}function Ot(){}function mn(e,t){return t(e),e}function ri(e,t){return t(e)}function ke(...e){return e}function Se(e,t){return e(xt,t)}function pe(e,t){e(hn,t)}function cr(e){e(jt)}function Me(e){return e(Fo)}function ne(e,t){return Se(e,ti(t,hn))}function tt(e,t){const n=e(xt,r=>{n(),t(r)});return n}function Ar(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Do(e,t){return e===t}function Te(e=Do){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ae(e){return t=>n=>{e(n)&&t(n)}}function Y(e){return t=>No(t,e)}function st(e){return t=>()=>{t(e)}}function L(e,...t){const n=oi(...t);return((r,o)=>{switch(r){case jt:cr(e);return;case xt:return Se(e,n(o))}})}function it(e,t){return n=>r=>{n(t=e(t,r))}}function wt(e){return t=>n=>{e>0?e--:t(n)}}function dt(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function he(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const u=Math.pow(2,i);Se(s,a=>{const l=n;n=n|u,t[i]=a,l!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const u=()=>{s([i].concat(t))};n===o?u():r=u}}function oi(...e){return t=>e.reduceRight(ri,t)}function si(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case xt:return s?n===s?void 0:(r(),n=s,t=Se(e,s),t):(r(),Ot);case jt:r(),n=null;return}}}function W(e){let t=e;const n=me();return((r,o)=>{switch(r){case hn:t=o;break;case xt:{o(t);break}case Fo:return t}return n(r,o)})}function Ne(e,t){return mn(W(t),n=>ne(e,n))}function me(){const e=[];return((t,n)=>{switch(t){case hn:e.slice().forEach(r=>{r(n)});return;case jt:e.splice(0,e.length);return;case xt:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}})}function Xe(e){return mn(me(),t=>ne(e,t))}function be(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:ii(),singleton:n}}const ii=()=>Symbol();function li(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const u=r(o.map(a=>n(a)));return i&&t.set(s,u),u};return n(e)}function Pe(...e){const t=me(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const u=Math.pow(2,i);Se(s,a=>{n[i]=a,r=r|u,r===o&&pe(t,n)})}),function(s,i){switch(s){case jt:{cr(t);return}case xt:return r===o&&i(n),Se(t,i)}}}function le(e,t=Do){return L(e,Te(t))}function Jn(...e){return function(t,n){switch(t){case jt:return;case xt:return ni(...e.map(r=>Se(r,n)))}}}var qe=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(qe||{});const ai={0:"debug",3:"error",1:"log",2:"warn"},ci=()=>typeof globalThis>"u"?window:globalThis,vt=be(()=>{const e=W(3);return{log:W((t,n,r=1)=>{var o;const s=(o=ci().VIRTUOSO_LOG_LEVEL)!=null?o:Me(e);r>=s&&console[ai[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Ct(e,t,n){return ur(e,t,n).callbackRef}function ur(e,t,n){const r=m.useRef(null);let o=i=>{};const s=m.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const u=()=>{const a=i[0].target;a.offsetParent!==null&&e(a)};n?u():requestAnimationFrame(u)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function ui(e,t,n,r,o,s,i,u,a){const l=m.useCallback(d=>{const S=di(d.children,t,u?"offsetWidth":"offsetHeight",o);let g=d.parentElement;for(;!g.dataset.virtuosoScroller;)g=g.parentElement;const h=g.lastElementChild.dataset.viewportType==="window";let v;h&&(v=g.ownerDocument.defaultView);const w=i?u?i.scrollLeft:i.scrollTop:h?u?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:u?g.scrollLeft:g.scrollTop,c=i?u?i.scrollWidth:i.scrollHeight:h?u?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:u?g.scrollWidth:g.scrollHeight,f=i?u?i.offsetWidth:i.offsetHeight:h?u?v.innerWidth:v.innerHeight:u?g.offsetWidth:g.offsetHeight;r({scrollHeight:c,scrollTop:Math.max(w,0),viewportHeight:f}),s==null||s(u?Pr("column-gap",getComputedStyle(d).columnGap,o):Pr("row-gap",getComputedStyle(d).rowGap,o)),S!==null&&e(S)},[e,t,o,s,i,r,u]);return ur(l,n,a)}function di(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const u=e.item(i);if(u.dataset.index===void 0)continue;const a=parseInt(u.dataset.index),l=parseFloat(u.dataset.knownSize),d=t(u,n);if(d===0&&r("Zero-sized element, this should not happen",{child:u},qe.ERROR),d===l)continue;const S=s[s.length-1];s.length===0||S.size!==d||S.endIndex!==a-1?s.push({endIndex:a,size:d,startIndex:a}):s[s.length-1].endIndex++}return s}function Pr(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,qe.WARN),t==="normal"?0:parseInt(t??"0",10)}function Wo(e,t,n){const r=m.useRef(null),o=m.useCallback(a=>{if(!(a!=null&&a.offsetParent))return;const l=a.getBoundingClientRect(),d=l.width;let S,g;if(t){const h=t.getBoundingClientRect(),v=l.top-h.top;g=h.height-Math.max(0,v),S=v+t.scrollTop}else{const h=i.current.ownerDocument.defaultView;g=h.innerHeight-Math.max(0,l.top),S=l.top+h.scrollY}r.current={offsetTop:S,visibleHeight:g,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ur(o,!0,n),u=m.useCallback(()=>{o(i.current)},[o,i]);return m.useEffect(()=>{var a;if(t){t.addEventListener("scroll",u);const l=new ResizeObserver(()=>{requestAnimationFrame(u)});return l.observe(t),()=>{t.removeEventListener("scroll",u),l.unobserve(t)}}else{const l=(a=i.current)==null?void 0:a.ownerDocument.defaultView;return l==null||l.addEventListener("scroll",u),l==null||l.addEventListener("resize",u),()=>{l==null||l.removeEventListener("scroll",u),l==null||l.removeEventListener("resize",u)}}},[u,t,i]),s}const De=be(()=>{const e=me(),t=me(),n=W(0),r=me(),o=W(0),s=me(),i=me(),u=W(0),a=W(0),l=W(0),d=W(0),S=me(),g=me(),h=W(!1),v=W(!1),w=W(!1);return ne(L(e,Y(({scrollTop:c})=>c)),t),ne(L(e,Y(({scrollHeight:c})=>c)),i),ne(t,o),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:a,footerHeight:d,headerHeight:u,horizontalDirection:v,scrollBy:g,scrollContainerState:e,scrollHeight:i,scrollingInProgress:h,scrollTo:S,scrollTop:t,skipAnimationFrameInResizeObserver:w,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Lt={lvl:0};function qo(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:u,value:a}=t(e[i]);s.push({end:u-1,start:r,value:o}),r=u,o=a}return s.push({end:1/0,start:r,value:o}),s}function ye(e){return e===Lt}function Gt(e,t){if(!ye(e))return t===e.k?e.v:t<e.k?Gt(e.l,t):Gt(e.r,t)}function nt(e,t,n="k"){if(ye(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=nt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return nt(e.l,t,n)}function Ke(e,t,n){return ye(e)?Uo(t,n,1):t===e.k?Le(e,{k:t,v:n}):t<e.k?Br(Le(e,{l:Ke(e.l,t,n)})):Br(Le(e,{r:Ke(e.r,t,n)}))}function _t(){return Lt}function Mt(e,t,n){if(ye(e))return[];const r=nt(e,t)[0];return fi(tr(e,r,n))}function er(e,t){if(ye(e))return Lt;const{k:n,l:r,r:o}=e;if(t===n){if(ye(r))return o;if(ye(o))return r;{const[s,i]=$o(r);return rn(Le(e,{k:s,l:Vo(r),v:i}))}}else return t<n?rn(Le(e,{l:er(r,t)})):rn(Le(e,{r:er(o,t)}))}function yt(e){return ye(e)?[]:[...yt(e.l),{k:e.k,v:e.v},...yt(e.r)]}function tr(e,t,n){if(ye(e))return[];const{k:r,l:o,r:s,v:i}=e;let u=[];return r>t&&(u=u.concat(tr(o,t,n))),r>=t&&r<=n&&u.push({k:r,v:i}),r<=n&&(u=u.concat(tr(s,t,n))),u}function rn(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(Mn(t))return Ko(Le(e,{lvl:n-1}));if(!ye(t)&&!ye(t.r))return Le(t.r,{l:Le(t,{r:t.r.l}),lvl:n,r:Le(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Mn(e))return nr(Le(e,{lvl:n-1}));if(!ye(r)&&!ye(r.l)){const o=r.l,s=Mn(o)?r.lvl-1:r.lvl;return Le(o,{l:Le(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:nr(Le(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Le(e,t){return Uo(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Vo(e){return ye(e.r)?e.l:rn(Le(e,{r:Vo(e.r)}))}function Mn(e){return ye(e)||e.lvl>e.r.lvl}function $o(e){return ye(e.r)?[e.k,e.v]:$o(e.r)}function Uo(e,t,n,r=Lt,o=Lt){return{k:e,l:r,lvl:n,r:o,v:t}}function Br(e){return nr(Ko(e))}function Ko(e){const{l:t}=e;return!ye(t)&&t.lvl===e.lvl?Le(t,{r:Le(e,{l:t.r})}):e}function nr(e){const{lvl:t,r:n}=e;return!ye(n)&&!ye(n.r)&&n.lvl===t&&n.r.lvl===t?Le(n,{l:Le(e,{r:n.l}),lvl:t+1}):e}function fi(e){return qo(e,({k:t,v:n})=>({index:t,value:n}))}function Xo(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Ht(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const dr=be(()=>({recalcInProgress:W(!1)}),[],{singleton:!0});function Qo(e,t,n){return e[ln(e,t,n)]}function ln(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],u=n(i,t);if(u===0)return s;if(u===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function pi(e,t,n,r){const o=ln(e,t,r),s=ln(e,n,r,o);return e.slice(o,s+1)}function ht(e,t){return Math.round(e.getBoundingClientRect()[t])}function bn(e){return!ye(e.groupOffsetTree)}function fr({index:e},t){return t===e?0:t<e?-1:1}function gi(){return{groupIndices:[],groupOffsetTree:_t(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:_t()}}function hi(e,t){let n=ye(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ye(e)){e=Ke(e,0,s);continue}const u=Mt(e,i-1,o+1);if(u.some(wi(r)))continue;let a=!1,l=!1;for(const{end:d,start:S,value:g}of u)a?(o>=S||s===g)&&(e=er(e,S)):(l=g!==s,a=!0),d>o&&o>=S&&g!==s&&(e=Ke(e,o+1,g));l&&(e=Ke(e,i,s))}return[e,n]}function mi(e){return typeof e.groupIndex<"u"}function bi({offset:e},t){return t===e?0:t<e?-1:1}function Ft(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Qo(t,e,fr),i=e-r,u=s*i+(i-1)*n+o;return u>0?u+n:u}function Yo(e,t){if(!bn(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Zo(e,t,n){if(mi(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Yo(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function xi(e,t,n,r=0){return r>0&&(t=Math.max(t,Qo(e,r,fr).offset)),qo(pi(e,t,n,bi),yi)}function vi(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,qe.DEBUG);const s=e.sizeTree;let i=s,u=0;if(n.length>0&&ye(s)&&t.length===2){const g=t[0].size,h=t[1].size;i=n.reduce((v,w)=>Ke(Ke(v,w,g),w+1,h),i)}else[i,u]=hi(i,t);if(i===s)return e;const{lastIndex:a,lastOffset:l,lastSize:d,offsetTree:S}=rr(e.offsetTree,u,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((g,h)=>Ke(g,h,Ft(h,S,o)),_t()),lastIndex:a,lastOffset:l,lastSize:d,offsetTree:S,sizeTree:i}}function Si(e){return yt(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function Lr(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function rr(e,t,n,r){let o=e,s=0,i=0,u=0,a=0;if(t!==0){a=ln(o,t-1,fr),u=o[a].offset;const l=nt(n,t-1);s=l[0],i=l[1],o.length&&o[a].size===nt(n,t)[1]&&(a-=1),o=o.slice(0,a+1)}else o=[];for(const{start:l,value:d}of Mt(n,t,1/0)){const S=l-s,g=S*i+u+S*r;o.push({index:l,offset:g,size:d}),s=l,u=g,i=d}return{lastIndex:s,lastOffset:u,lastSize:i,offsetTree:o}}function yi(e){return{index:e.index,value:e}}function wi(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const Ci={offsetHeight:"height",offsetWidth:"width"},at=be(([{log:e},{recalcInProgress:t}])=>{const n=me(),r=me(),o=Ne(r,0),s=me(),i=me(),u=W(0),a=W([]),l=W(void 0),d=W(void 0),S=W(void 0),g=W(void 0),h=W((b,y)=>ht(b,Ci[y])),v=W(void 0),w=W(0),c=gi(),f=Ne(L(n,he(a,e,w),it(vi,c),Te()),c),p=Ne(L(a,Te(),it((b,y)=>({current:y,prev:b.current}),{current:[],prev:[]}),Y(({prev:b})=>b)),[]);ne(L(a,ae(b=>b.length>0),he(f,w),Y(([b,y,k])=>{const R=b.reduce((_,z,B)=>Ke(_,z,Ft(z,y.offsetTree,k)||B),_t());return{...y,groupIndices:b,groupOffsetTree:R}})),f),ne(L(r,he(f),ae(([b,{lastIndex:y}])=>b<y),Y(([b,{lastIndex:y,lastSize:k}])=>[{endIndex:y,size:k,startIndex:b}])),n),ne(l,d);const C=Ne(L(l,Y(b=>b===void 0)),!0);ne(L(d,ae(b=>b!==void 0&&ye(Me(f).sizeTree)),Y(b=>{const y=Me(S),k=Me(a).length>0;return y?k?[{endIndex:0,size:y,startIndex:0},{endIndex:1,size:b,startIndex:1}]:[]:[{endIndex:0,size:b,startIndex:0}]})),n),ne(L(g,ae(b=>b!==void 0&&b.length>0&&ye(Me(f).sizeTree)),Y(b=>{const y=[];let k=b[0],R=0;for(let _=1;_<b.length;_++){const z=b[_];z!==k&&(y.push({endIndex:_-1,size:k,startIndex:R}),k=z,R=_)}return y.push({endIndex:b.length-1,size:k,startIndex:R}),y})),n),ne(L(a,he(S,d),ae(([,b,y])=>b!==void 0&&y!==void 0),Y(([b,y,k])=>{const R=[];for(let _=0;_<b.length;_++){const z=b[_],B=b[_+1];R.push({startIndex:z,endIndex:z,size:y}),B!==void 0&&R.push({startIndex:z+1,endIndex:B-1,size:k})}return R})),n);const T=Xe(L(n,he(f),it(({sizes:b},[y,k])=>({changed:k!==b,sizes:k}),{changed:!1,sizes:c}),Y(b=>b.changed)));Se(L(u,it((b,y)=>({diff:b.prev-y,prev:y}),{diff:0,prev:0}),Y(b=>b.diff)),b=>{const{groupIndices:y}=Me(f);if(b>0)pe(t,!0),pe(s,b+Lr(b,y));else if(b<0){const k=Me(p);k.length>0&&(b-=Lr(-b,k)),pe(i,b)}}),Se(L(u,he(e)),([b,y])=>{b<0&&y("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:u},qe.ERROR)});const I=Xe(s);ne(L(s,he(f),Y(([b,y])=>{const k=y.groupIndices.length>0,R=[],_=y.lastSize;if(k){const z=Gt(y.sizeTree,0);let B=0,E=0;for(;B<b;){const F=y.groupIndices[E],M=y.groupIndices.length===E+1?1/0:y.groupIndices[E+1]-F-1;R.push({endIndex:F,size:z,startIndex:F}),R.push({endIndex:F+1+M-1,size:_,startIndex:F+1}),E++,B+=M+1}const P=yt(y.sizeTree);return B!==b&&P.shift(),P.reduce((F,{k:M,v:O})=>{let Q=F.ranges;return F.prevSize!==0&&(Q=[...F.ranges,{endIndex:M+b-1,size:F.prevSize,startIndex:F.prevIndex}]),{prevIndex:M+b,prevSize:O,ranges:Q}},{prevIndex:b,prevSize:0,ranges:R}).ranges}return yt(y.sizeTree).reduce((z,{k:B,v:E})=>({prevIndex:B+b,prevSize:E,ranges:[...z.ranges,{endIndex:B+b-1,size:z.prevSize,startIndex:z.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const j=Xe(L(i,he(f,w),Y(([b,{offsetTree:y},k])=>{const R=-b;return Ft(R,y,k)})));return ne(L(i,he(f,w),Y(([b,y,k])=>{if(y.groupIndices.length>0){if(ye(y.sizeTree))return y;let R=_t();const _=Me(p);let z=0,B=0,E=0;for(;z<-b;){E=_[B];const P=_[B+1]-E-1;B++,z+=P+1}if(R=yt(y.sizeTree).reduce((P,{k:F,v:M})=>Ke(P,Math.max(0,F+b),M),R),z!==-b){const P=Gt(y.sizeTree,E);R=Ke(R,0,P);const F=nt(y.sizeTree,-b+1)[1];R=Ke(R,1,F)}return{...y,sizeTree:R,...rr(y.offsetTree,0,R,k)}}else{const R=yt(y.sizeTree).reduce((_,{k:z,v:B})=>Ke(_,Math.max(0,z+b),B),_t());return{...y,sizeTree:R,...rr(y.offsetTree,0,R,k)}}})),f),{beforeUnshiftWith:I,data:v,defaultItemSize:d,firstItemIndex:u,fixedItemSize:l,fixedGroupSize:S,gap:w,groupIndices:a,heightEstimates:g,itemSize:h,listRefresh:T,shiftWith:i,shiftWithOffset:j,sizeRanges:n,sizes:f,statefulTotalCount:o,totalCount:r,trackItemSizes:C,unshiftWith:s}},ke(vt,dr),{singleton:!0});function Ii(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Jo=be(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=me(),i=me(),u=Xe(L(s,Y(Ii)));return ne(L(u,Y(a=>a.totalCount)),n),ne(L(u,Y(a=>a.groupIndices)),e),ne(L(Pe(o,t,r),ae(([a,l])=>bn(l)),Y(([a,l,d])=>nt(l.groupOffsetTree,Math.max(a-d,0),"v")[0]),Te(),Y(a=>[a])),i),{groupCounts:s,topItemsIndexes:i}},ke(at,De)),St=be(([{log:e}])=>{const t=W(!1),n=Xe(L(t,ae(r=>r),Te()));return Se(t,r=>{r&&Me(e)("props updated",{},qe.DEBUG)}),{didMount:n,propsReady:t}},ke(vt),{singleton:!0}),Ti=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function es(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Ti)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Ut=be(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:u,scrollingInProgress:a,scrollTo:l,smoothScrollTargetReached:d,viewportHeight:S},{log:g}])=>{const h=me(),v=me(),w=W(0);let c=null,f=null,p=null;function C(){c&&(c(),c=null),p&&(p(),p=null),f&&(clearTimeout(f),f=null),pe(a,!1)}return ne(L(h,he(n,S,r,w,u,i,g),he(e,s,o),Y(([[T,I,j,b,y,k,R,_],z,B,E])=>{const P=es(T),{align:F,behavior:M,offset:O}=P,Q=b-1,re=Zo(P,I,Q);let oe=Ft(re,I.offsetTree,z)+k;F==="end"?(oe+=B+nt(I.sizeTree,re)[1]-j+E,re===Q&&(oe+=R)):F==="center"?oe+=(B+nt(I.sizeTree,re)[1]-j+E)/2:oe-=y,O&&(oe+=O);const ie=ue=>{C(),ue?(_("retrying to scroll to",{location:T},qe.DEBUG),pe(h,T)):(pe(v,!0),_("list did not change, scroll successful",{},qe.DEBUG))};if(C(),M==="smooth"){let ue=!1;p=Se(t,xe=>{ue=ue||xe}),c=tt(d,()=>{ie(ue)})}else c=tt(L(t,ki(150)),ie);return f=setTimeout(()=>{C()},1200),pe(a,!0),_("scrolling from index to",{behavior:M,index:re,top:oe},qe.DEBUG),{behavior:M,top:oe}})),l),{scrollTargetReached:v,scrollToIndex:h,topListHeight:w}},ke(at,De,vt),{singleton:!0});function ki(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function pr(e,t){e==0?t():requestAnimationFrame(()=>{pr(e-1,t)})}function gr(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Kt=be(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const u=W(!0),a=W(0),l=W(!0);return ne(L(i,he(a),ae(([d,S])=>!!S),st(!1)),u),ne(L(i,he(a),ae(([d,S])=>!!S),st(!1)),l),Se(L(Pe(t,i),he(u,n,e,l),ae(([[,d],S,{sizeTree:g},h,v])=>d&&(!ye(g)||ar(h))&&!S&&!v),he(a)),([,d])=>{tt(o,()=>{pe(l,!0)}),pr(4,()=>{tt(r,()=>{pe(u,!0)}),pe(s,d)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:a,scrolledToInitialItem:u}},ke(at,De,Ut,St),{singleton:!0});function ts(e,t){return Math.abs(e-t)<1.01}const Nt="up",Pt="down",Ri="none",_i={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Mi=0,Xt=be(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=W(!1),u=W(!0),a=me(),l=me(),d=W(4),S=W(Mi),g=Ne(L(Jn(L(le(o),wt(1),st(!0)),L(le(o),wt(1),st(!1),Ar(100))),Te()),!1),h=Ne(L(Jn(L(n,st(!0)),L(n,st(!1),Ar(200))),Te()),!1);ne(L(Pe(le(o),le(S)),Y(([p,C])=>p<=C),Te()),u),ne(L(u,dt(50)),l);const v=Xe(L(Pe(r,le(s),le(t),le(e),le(d)),it((p,[{scrollHeight:C,scrollTop:T},I,j,b,y])=>{const k=T+I-C>-y,R={scrollHeight:C,scrollTop:T,viewportHeight:I};if(k){let z,B;return T>p.state.scrollTop?(z="SCROLLED_DOWN",B=p.state.scrollTop-T):(z="SIZE_DECREASED",B=p.state.scrollTop-T||p.scrollTopDelta),{atBottom:!0,atBottomBecause:z,scrollTopDelta:B,state:R}}let _;return R.scrollHeight>p.state.scrollHeight?_="SIZE_INCREASED":I<p.state.viewportHeight?_="VIEWPORT_HEIGHT_DECREASING":T<p.state.scrollTop?_="SCROLLING_UPWARDS":_="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:_,state:R}},_i),Te((p,C)=>p&&p.atBottom===C.atBottom))),w=Ne(L(r,it((p,{scrollHeight:C,scrollTop:T,viewportHeight:I})=>{if(ts(p.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:T};{const j=C-(T+I)<1;return p.scrollTop!==T&&j?{changed:!0,jump:p.scrollTop-T,scrollHeight:C,scrollTop:T}:{changed:!0,jump:0,scrollHeight:C,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ae(p=>p.changed),Y(p=>p.jump)),0);ne(L(v,Y(p=>p.atBottom)),i),ne(L(i,dt(50)),a);const c=W(Pt);ne(L(r,Y(({scrollTop:p})=>p),Te(),it((p,C)=>Me(h)?{direction:p.direction,prevScrollTop:C}:{direction:C<p.prevScrollTop?Nt:Pt,prevScrollTop:C},{direction:Pt,prevScrollTop:0}),Y(p=>p.direction)),c),ne(L(r,dt(50),st(Ri)),c);const f=W(0);return ne(L(g,ae(p=>!p),st(0)),f),ne(L(o,dt(100),he(g),ae(([p,C])=>C),it(([p,C],[T])=>[C,T],[0,0]),Y(([p,C])=>C-p)),f),{atBottomState:v,atBottomStateChange:a,atBottomThreshold:d,atTopStateChange:l,atTopThreshold:S,isAtBottom:i,isAtTop:u,isScrolling:g,lastJumpDueToItemResize:w,scrollDirection:c,scrollVelocity:f}},ke(De)),Dt="top",Wt="bottom",Gr="none";function Hr(e,t,n){return typeof e=="number"?n===Nt&&t===Dt||n===Pt&&t===Wt?e:0:n===Nt?t===Dt?e.main:e.reverse:t===Wt?e.main:e.reverse}function Fr(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const hr=be(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=me(),i=W(0),u=W(0),a=W(0),l=Ne(L(Pe(le(r),le(o),le(n),le(s,Ht),le(a),le(i),le(t),le(e),le(u)),Y(([d,S,g,[h,v],w,c,f,p,C])=>{const T=d-p,I=c+f,j=Math.max(g-T,0);let b=Gr;const y=Fr(C,Dt),k=Fr(C,Wt);return h-=p,h+=g+f,v+=g+f,v-=p,h>d+I-y&&(b=Nt),v<d-j+S+k&&(b=Pt),b!==Gr?[Math.max(T-g-Hr(w,Dt,b)-y,0),T-j-f+S+Hr(w,Wt,b)+k]:null}),ae(d=>d!=null),Te(Ht)),[0,0]);return{increaseViewportBy:u,listBoundary:s,overscan:a,topListHeight:i,visibleRange:l}},ke(De),{singleton:!0});function Ei(e,t,n){if(bn(t)){const r=Yo(e,t);return[{index:nt(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const En={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function on(e,t,n,r,o,s){const{lastIndex:i,lastOffset:u,lastSize:a}=o;let l=0,d=0;if(e.length>0){l=e[0].offset;const w=e[e.length-1];d=w.offset+w.size}const S=n-i,g=u+S*a+(S-1)*r,h=l,v=g-d;return{bottom:d,firstItemIndex:s,items:Nr(e,o,s),offsetBottom:v,offsetTop:l,top:h,topItems:Nr(t,o,s),topListHeight:t.reduce((w,c)=>c.size+w,0),totalCount:n}}function ns(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const u=e+i,a=gr(t,u),l=Array.from({length:u}).map((d,S)=>({data:s[S+a],index:S+a,offset:0,size:0}));return on(l,[],u,o,n,r)}function Nr(e,t,n){if(e.length===0)return[];if(!bn(t))return e.map(l=>({...l,index:l.index+n,originalIndex:l.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Mt(t.groupOffsetTree,r,o);let u,a=0;for(const l of e){(!u||u.end<l.index)&&(u=i.shift(),a=t.groupIndices.indexOf(u.start));let d;l.index===u.start?d={index:a,type:"group"}:d={groupIndex:a,index:l.index-(a+1)+n},s.push({...d,data:l.data,offset:l.offset,originalIndex:l.index,size:l.size})}return s}function Dr(e,t){var n;return e===void 0?0:typeof e=="number"?e:(n=e[t])!=null?n:0}const It=be(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:u,visibleRange:a},{initialTopMostItemIndex:l,scrolledToInitialItem:d},{topListHeight:S},g,{didMount:h},{recalcInProgress:v}])=>{const w=W([]),c=W(0),f=me(),p=W(0);ne(s.topItemsIndexes,w);const C=Ne(L(Pe(h,v,le(a,Ht),le(o),le(r),le(l),d,le(w),le(t),le(n),le(p),e),ae(([b,y,,k,,,,,,,,R])=>{const _=R&&R.length!==k;return b&&!y&&!_}),Y(([,,[b,y],k,R,_,z,B,E,P,F,M])=>{var O,Q,re,oe;const ie=R,{offsetTree:ue,sizeTree:xe}=ie,N=Me(c);if(k===0)return{...En,totalCount:k};if(b===0&&y===0)return N===0?{...En,totalCount:k}:ns(N,_,R,E,P,M||[]);if(ye(xe))return N>0?null:on(Ei(gr(_,k),ie,M),[],k,P,ie,E);const D=[];if(B.length>0){const $=B[0],Z=B[B.length-1];let ee=0;for(const J of Mt(xe,$,Z)){const ce=J.value,se=Math.max(J.start,$),ve=Math.min(J.end,Z);for(let ge=se;ge<=ve;ge++)D.push({data:M==null?void 0:M[ge],index:ge,offset:ee,size:ce}),ee+=ce}}if(!z)return on([],D,k,P,ie,E);const q=B.length>0?B[B.length-1]+1:0,A=xi(ue,b,y,q);if(A.length===0)return null;const G=k-1,K=mn([],$=>{for(const Z of A){const ee=Z.value;let J=ee.offset,ce=Z.start;const se=ee.size;if(ee.offset<b){ce+=Math.floor((b-ee.offset+P)/(se+P));const ge=ce-Z.start;J+=ge*se+ge*P}ce<q&&(J+=(q-ce)*se,ce=q);const ve=Math.min(Z.end,G);for(let ge=ce;ge<=ve&&!(J>=y);ge++)$.push({data:M==null?void 0:M[ge],index:ge,offset:J,size:se}),J+=se+P}}),H=Dr(F,Dt),te=Dr(F,Wt);if(K.length>0&&(H>0||te>0)){const $=K[0],Z=K[K.length-1];if(H>0&&$.index>q){const ee=Math.min(H,$.index-q),J=[];let ce=$.offset;for(let se=$.index-1;se>=$.index-ee;se--){const ve=(Q=(O=Mt(xe,se,se)[0])==null?void 0:O.value)!=null?Q:$.size;ce-=ve+P,J.unshift({data:M==null?void 0:M[se],index:se,offset:ce,size:ve})}K.unshift(...J)}if(te>0&&Z.index<G){const ee=Math.min(te,G-Z.index);let J=Z.offset+Z.size+P;for(let ce=Z.index+1;ce<=Z.index+ee;ce++){const se=(oe=(re=Mt(xe,ce,ce)[0])==null?void 0:re.value)!=null?oe:Z.size;K.push({data:M==null?void 0:M[ce],index:ce,offset:J,size:se}),J+=se+P}}}return on(K,D,k,P,ie,E)}),ae(b=>b!==null),Te()),En);ne(L(e,ae(ar),Y(b=>b==null?void 0:b.length)),o),ne(L(C,Y(b=>b.topListHeight)),S),ne(S,u),ne(L(C,Y(b=>[b.top,b.bottom])),i),ne(L(C,Y(b=>b.items)),f);const T=Xe(L(C,ae(({items:b})=>b.length>0),he(o,e),ae(([{items:b},y])=>b[b.length-1].originalIndex===y-1),Y(([,b,y])=>[b-1,y]),Te(Ht),Y(([b])=>b))),I=Xe(L(C,dt(200),ae(({items:b,topItems:y})=>b.length>0&&b[0].originalIndex===y.length),Y(({items:b})=>b[0].index),Te())),j=Xe(L(C,ae(({items:b})=>b.length>0),Y(({items:b})=>{let y=0,k=b.length-1;for(;b[y].type==="group"&&y<k;)y++;for(;b[k].type==="group"&&k>y;)k--;return{endIndex:b[k].index,startIndex:b[y].index}}),Te(Xo)));return{endReached:T,initialItemCount:c,itemsRendered:f,listState:C,minOverscanItemCount:p,rangeChanged:j,startReached:I,topItemsIndexes:w,...g}},ke(at,Jo,hr,Kt,Ut,Xt,St,dr),{singleton:!0}),rs=be(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=me(),i=Ne(L(Pe(n,e,r,t,o),Y(([u,a,l,d,S])=>u+a+l+d+S.offsetBottom+S.bottom)),0);return ne(le(i),s),{totalListHeight:i,totalListHeightChanged:s}},ke(De,It),{singleton:!0}),ji=be(([{viewportHeight:e},{totalListHeight:t}])=>{const n=W(!1),r=Ne(L(Pe(n,e,t),ae(([o])=>o),Y(([,o,s])=>Math.max(0,o-s)),dt(0),Te()),0);return{alignToBottom:n,paddingTopAddition:r}},ke(De,rs),{singleton:!0}),os=be(()=>({context:W(null)})),Oi=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,ss=be(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:u,viewportHeight:a},{scrollToIndex:l}])=>{const d=me();return ne(L(d,he(t,a,n,s,o,r,u),he(e),Y(([[S,g,h,v,w,c,f,p],C])=>{const{align:T,behavior:I,calculateViewLocation:j=Oi,done:b,...y}=S,k=Zo(S,g,v-1),R=Ft(k,g.offsetTree,C)+w+c,_=R+nt(g.sizeTree,k)[1],z=p+c,B=p+h-f,E=j({itemBottom:_,itemTop:R,locationParams:{align:T,behavior:I,...y},viewportBottom:B,viewportTop:z});return E?b&&tt(L(i,ae(P=>!P),wt(Me(i)?1:2)),b):b==null||b(),E}),ae(S=>S!==null)),l),{scrollIntoView:d}},ke(at,De,Ut,It,vt),{singleton:!0});function Wr(e){return e?e==="smooth"?"smooth":"auto":!1}const zi=(e,t)=>typeof e=="function"?Wr(e(t)):t&&Wr(e),Ai=be(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:u},{didMount:a,propsReady:l},{log:d},{scrollingInProgress:S},{context:g},{scrollIntoView:h}])=>{const v=W(!1),w=me();let c=null;function f(I){pe(i,{align:"end",behavior:I,index:"LAST"})}Se(L(Pe(L(le(t),wt(1)),a),he(le(v),s,u,S),Y(([[I,j],b,y,k,R])=>{let _=j&&k,z="auto";return _&&(z=zi(b,y||R),_=_&&!!z),{followOutputBehavior:z,shouldFollow:_,totalCount:I}}),ae(({shouldFollow:I})=>I)),({followOutputBehavior:I,totalCount:j})=>{c&&(c(),c=null),Me(n)?requestAnimationFrame(()=>{Me(d)("following output to ",{totalCount:j},qe.DEBUG),f(I)}):c=tt(e,()=>{Me(d)("following output to ",{totalCount:j},qe.DEBUG),f(I),c=null})});function p(I){const j=tt(o,b=>{I&&!b.atBottom&&b.notAtBottomBecause==="SIZE_INCREASED"&&!c&&(Me(d)("scrolling to bottom due to increased size",{},qe.DEBUG),f("auto"))});setTimeout(j,100)}Se(L(Pe(le(v),t,l),ae(([I,,j])=>I&&j),it(({value:I},[,j])=>({refreshed:I===j,value:j}),{refreshed:!1,value:0}),ae(({refreshed:I})=>I),he(v,t)),([,I])=>{Me(u)&&p(I!==!1)}),Se(w,()=>{p(Me(v)!==!1)}),Se(Pe(le(v),o),([I,j])=>{I&&!j.atBottom&&j.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&f("auto")});const C=W(null),T=me();return ne(Jn(L(le(r),Y(I=>{var j;return(j=I==null?void 0:I.length)!=null?j:0})),L(le(t))),T),Se(L(Pe(L(T,wt(1)),a),he(le(C),u,S,g),Y(([[I,j],b,y,k,R])=>j&&y&&(b==null?void 0:b({context:R,totalCount:I,scrollingInProgress:k}))),ae(I=>!!I),dt(0)),I=>{c&&(c(),c=null),Me(n)?requestAnimationFrame(()=>{Me(d)("scrolling into view",{}),pe(h,I)}):c=tt(e,()=>{Me(d)("scrolling into view",{}),pe(h,I),c=null})}),{autoscrollToBottom:w,followOutput:v,scrollIntoViewOnChange:C}},ke(at,Xt,Ut,Kt,St,vt,De,os,ss)),Pi=be(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:u}])=>(ne(L(u,he(s),ae(([,a])=>a!==0),he(o,r,t,n,e),Y(([[,a],l,d,S,g,h=[]])=>ns(a,l,d,S,g,h))),i),{}),ke(at,Kt,It,St),{singleton:!0}),Bi=be(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=W(0);return Se(L(e,he(r),ae(([,o])=>o!==0),Y(([,o])=>({top:o}))),o=>{tt(L(n,wt(1),ae(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{pe(t,o)})})}),{initialScrollTop:r}},ke(St,De,It),{singleton:!0}),is=be(([{scrollVelocity:e}])=>{const t=W(!1),n=me(),r=W(!1);return ne(L(e,he(r,t,n),ae(([o,s])=>!!s),Y(([o,s,i,u])=>{const{enter:a,exit:l}=s;if(i){if(l(o,u))return!1}else if(a(o,u))return!0;return i}),Te()),t),Se(L(Pe(t,e,n),he(r)),([[o,s,i],u])=>{o&&u&&u.change&&u.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ke(Xt),{singleton:!0}),mr=be(([{scrollContainerState:e,scrollTo:t}])=>{const n=me(),r=me(),o=me(),s=W(!1),i=W(void 0);return ne(L(Pe(n,r),Y(([{scrollHeight:u,scrollTop:a,viewportHeight:l},{offsetTop:d}])=>({scrollHeight:u,scrollTop:Math.max(0,a-d),viewportHeight:l}))),e),ne(L(t,he(r),Y(([u,{offsetTop:a}])=>({...u,top:u.top+a}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ke(De)),Li=be(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:u,windowViewportRect:a}])=>{const l=me(),d=W(void 0),S=W(null),g=W(null);return ne(u,S),ne(a,g),Se(L(l,he(t,r,i,S,g,n)),([h,v,w,c,f,p,C])=>{const T=Si(v.sizeTree);c&&f!==null&&p!==null&&(w=f.scrollTop-p.offsetTop),w-=C,h({ranges:T,scrollTop:w})}),ne(L(d,ae(ar),Y(Gi)),o),ne(L(s,he(d),ae(([,h])=>h!==void 0),Te(),Y(([,h])=>h.ranges)),e),{getState:l,restoreStateFrom:d}},ke(at,De,Kt,St,mr));function Gi(e){return{align:"start",index:0,offset:e.scrollTop}}const Hi=be(([{topItemsIndexes:e}])=>{const t=W(0);return ne(L(t,ae(n=>n>=0),Y(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ke(It));function ls(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}const Fi=ls(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Ni=be(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:u},{listState:a},{beforeUnshiftWith:l,gap:d,shiftWithOffset:S,sizes:g},{log:h},{recalcInProgress:v}])=>{const w=Xe(L(a,he(i),it(([,f,p,C],[{bottom:T,items:I,offsetBottom:j,totalCount:b},y])=>{const k=T+j;let R=0;return p===b&&f.length>0&&I.length>0&&(I[0].originalIndex===0&&f[0].originalIndex===0||(R=k-C,R!==0&&(R+=y))),[R,I,b,k]},[0,[],0,0]),ae(([f])=>f!==0),he(r,u,n,o,h,v),ae(([,f,p,C,,,T])=>!T&&!C&&f!==0&&p===Nt),Y(([[f],,,,,p])=>(p("Upward scrolling compensation",{amount:f},qe.DEBUG),f))));function c(f){f>0?(pe(t,{behavior:"auto",top:-f}),pe(e,0)):(pe(e,0),pe(t,{behavior:"auto",top:-f}))}return Se(L(w,he(e,s)),([f,p,C])=>{C&&Fi()?pe(e,p-f):c(-f)}),Se(L(Pe(Ne(s,!1),e,v),ae(([f,p,C])=>!f&&!C&&p!==0),Y(([f,p])=>p),dt(1)),c),ne(L(S,Y(f=>({top:-f}))),t),Se(L(l,he(g,d),Y(([f,{groupIndices:p,lastSize:C,sizeTree:T},I])=>{function j(b){return b*(C+I)}if(p.length===0)return j(f);{let b=0;const y=Gt(T,0);let k=0,R=0;for(;k<f;){k++,b+=y;let _=p.length===R+1?1/0:p[R+1]-p[R]-1;k+_>f&&(b-=y,_=f-k+1),k+=_,b+=j(_),R++}return b}})),f=>{pe(e,f),requestAnimationFrame(()=>{pe(t,{top:f}),requestAnimationFrame(()=>{pe(e,0),pe(v,!1)})})}),{deviation:e}},ke(De,Xt,It,at,vt,dr)),Di=be(([e,t,n,r,o,s,i,u,a,l,d])=>({...e,...t,...n,...r,...o,...s,...i,...u,...a,...l,...d}),ke(hr,Pi,St,is,rs,Bi,ji,mr,ss,vt,os)),as=be(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:o,gap:s,groupIndices:i,heightEstimates:u,itemSize:a,sizeRanges:l,sizes:d,statefulTotalCount:S,totalCount:g,trackItemSizes:h},{initialItemFinalLocationReached:v,initialTopMostItemIndex:w,scrolledToInitialItem:c},f,p,C,T,{scrollToIndex:I},j,{topItemCount:b},{groupCounts:y},k])=>{const{listState:R,minOverscanItemCount:_,topItemsIndexes:z,rangeChanged:B,...E}=T;return ne(B,k.scrollSeekRangeChanged),ne(L(k.windowViewportRect,Y(P=>P.visibleHeight)),f.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:o,gap:s,groupCounts:y,heightEstimates:u,initialItemFinalLocationReached:v,initialTopMostItemIndex:w,scrolledToInitialItem:c,sizeRanges:l,topItemCount:b,topItemsIndexes:z,totalCount:g,...C,groupIndices:i,itemSize:a,listState:R,minOverscanItemCount:_,scrollToIndex:I,statefulTotalCount:S,trackItemSizes:h,rangeChanged:B,...E,...k,...f,sizes:d,...p}},ke(at,Kt,De,Li,Ai,It,Ut,Ni,Hi,Jo,Di));function Wi(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const Jt=typeof document<"u"?m.useLayoutEffect:m.useEffect;function cs(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),u=m.createContext({});function a(c,f){c.propsReady&&pe(c.propsReady,!1);for(const p of r){const C=c[t.required[p]];pe(C,f[p])}for(const p of o)if(p in f){const C=c[t.optional[p]];pe(C,f[p])}c.propsReady&&pe(c.propsReady,!0)}function l(c){return s.reduce((f,p)=>(f[p]=C=>{const T=c[t.methods[p]];pe(T,C)},f),{})}function d(c){return i.reduce((f,p)=>(f[p]=si(c[t.events[p]]),f),{})}const S=m.forwardRef((c,f)=>{const{children:p,...C}=c,[T]=m.useState(()=>mn(li(e),b=>{a(b,C)})),[I]=m.useState(zr(d,T));Jt(()=>{for(const b of i)b in C&&Se(I[b],C[b]);return()=>{Object.values(I).map(cr)}},[C,I,T]),Jt(()=>{a(T,C)}),m.useImperativeHandle(f,Or(l(T)));const j=n;return x.jsx(u.Provider,{value:T,children:n?x.jsx(j,{...Wi([...r,...o,...i],C),children:p}):p})}),g=c=>{const f=m.useContext(u);return m.useCallback(p=>{pe(f[c],p)},[f,c])},h=c=>{const f=m.useContext(u)[c],p=m.useCallback(C=>Se(f,C),[f]);return m.useSyncExternalStore(p,()=>Me(f),()=>Me(f))},v=c=>{const f=m.useContext(u)[c],[p,C]=m.useState(zr(Me,f));return Jt(()=>Se(f,T=>{T!==p&&C(Or(T))}),[f,p]),p},w=m.version.startsWith("18")?h:v;return{Component:S,useEmitter:(c,f)=>{const p=m.useContext(u)[c];Jt(()=>Se(p,f),[f,p])},useEmitterValue:w,usePublisher:g}}const us=m.createContext(void 0),ds=m.createContext(void 0),fs=typeof document<"u"?m.useLayoutEffect:m.useEffect;function jn(e){return"self"in e}function qi(e){return"body"in e}function ps(e,t,n,r=Ot,o,s){const i=m.useRef(null),u=m.useRef(null),a=m.useRef(null),l=m.useCallback(g=>{let h,v,w;const c=g.target;if(qi(c)||jn(c)){const p=jn(c)?c:c.defaultView;w=s?p.scrollX:p.scrollY,h=s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight,v=s?p.innerWidth:p.innerHeight}else w=s?c.scrollLeft:c.scrollTop,h=s?c.scrollWidth:c.scrollHeight,v=s?c.offsetWidth:c.offsetHeight;const f=()=>{e({scrollHeight:h,scrollTop:Math.max(w,0),viewportHeight:v})};g.suppressFlushSync?f():Gs.flushSync(f),u.current!==null&&(w===u.current||w<=0||w===h-v)&&(u.current=null,t(!0),a.current&&(clearTimeout(a.current),a.current=null))},[e,t,s]);m.useEffect(()=>{const g=o||i.current;return r(o||i.current),l({suppressFlushSync:!0,target:g}),g.addEventListener("scroll",l,{passive:!0}),()=>{r(null),g.removeEventListener("scroll",l)}},[i,l,n,r,o]);function d(g){const h=i.current;if(!h||(s?"offsetWidth"in h&&h.offsetWidth===0:"offsetHeight"in h&&h.offsetHeight===0))return;const v=g.behavior==="smooth";let w,c,f;jn(h)?(c=Math.max(ht(h.document.documentElement,s?"width":"height"),s?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),w=s?h.innerWidth:h.innerHeight,f=s?window.scrollX:window.scrollY):(c=h[s?"scrollWidth":"scrollHeight"],w=ht(h,s?"width":"height"),f=h[s?"scrollLeft":"scrollTop"]);const p=c-w;if(g.top=Math.ceil(Math.max(Math.min(p,g.top),0)),ts(w,c)||g.top===f){e({scrollHeight:c,scrollTop:f,viewportHeight:w}),v&&t(!0);return}v?(u.current=g.top,a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,u.current=null,t(!0)},1e3)):u.current=null,s&&(g={behavior:g.behavior,left:g.top}),h.scrollTo(g)}function S(g){s&&(g={behavior:g.behavior,left:g.top}),i.current.scrollBy(g)}return{scrollByCallback:S,scrollerRef:i,scrollToCallback:d}}const On="-webkit-sticky",qr="sticky",br=ls(()=>{if(typeof document>"u")return qr;const e=document.createElement("div");return e.style.position=On,e.style.position===On?On:qr});function xr(e){return e}const Vi=be(()=>{const e=W(u=>`Item ${u}`),t=W(u=>`Group ${u}`),n=W({}),r=W(xr),o=W("div"),s=W(Ot),i=(u,a=null)=>Ne(L(n,Y(l=>l[u]),Te()),a);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),$i=be(([e,t])=>({...e,...t}),ke(as,Vi)),Ui=({height:e})=>x.jsx("div",{style:{height:e}}),Ki={overflowAnchor:"none",position:br(),zIndex:1},gs={overflowAnchor:"none"},Xi={...gs,display:"inline-block",height:"100%"},Vr=m.memo(function({showTopList:e=!1}){const t=de("listState"),n=Ze("sizeRanges"),r=de("useWindowScroll"),o=de("customScrollParent"),s=Ze("windowScrollContainerState"),i=Ze("scrollContainerState"),u=o||r?s:i,a=de("itemContent"),l=de("context"),d=de("groupContent"),S=de("trackItemSizes"),g=de("itemSize"),h=de("log"),v=Ze("gap"),w=de("horizontalDirection"),{callbackRef:c}=ui(n,g,S,e?Ot:u,h,v,o,w,de("skipAnimationFrameInResizeObserver")),[f,p]=m.useState(0);vr("deviation",E=>{f!==E&&p(E)});const C=de("EmptyPlaceholder"),T=de("ScrollSeekPlaceholder")||Ui,I=de("ListComponent"),j=de("ItemComponent"),b=de("GroupComponent"),y=de("computeItemKey"),k=de("isSeeking"),R=de("groupIndices").length>0,_=de("alignToBottom"),z=de("initialItemFinalLocationReached"),B=e?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:f!==0?f:_?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:f!==0?f:_?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...z?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?x.jsx(C,{...Fe(C,l)}):x.jsx(I,{...Fe(I,l),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:c,style:B,children:(e?t.topItems:t.items).map(E=>{const P=E.originalIndex,F=y(P+t.firstItemIndex,E.data,l);return k?m.createElement(T,{...Fe(T,l),height:E.size,index:E.index,key:F,type:E.type||"item",...E.type==="group"?{}:{groupIndex:E.groupIndex}}):E.type==="group"?m.createElement(b,{...Fe(b,l),"data-index":P,"data-item-index":E.index,"data-known-size":E.size,key:F,style:Ki},d(E.index,l)):m.createElement(j,{...Fe(j,l),...Ji(j,E.data),"data-index":P,"data-item-group-index":E.groupIndex,"data-item-index":E.index,"data-known-size":E.size,key:F,style:w?Xi:gs},R?a(E.index,E.groupIndex,E.data,l):a(E.index,E.data,l))})})}),Qi={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Yi={outline:"none",overflowX:"auto",position:"relative"},xn=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Zi={position:br(),top:0,width:"100%",zIndex:1};function Fe(e,t){if(typeof e!="string")return{context:t}}function Ji(e,t){return{item:typeof e=="string"?void 0:t}}const el=m.memo(function(){const e=de("HeaderComponent"),t=Ze("headerHeight"),n=de("HeaderFooterTag"),r=Ct(m.useMemo(()=>s=>{t(ht(s,"height"))},[t]),!0,de("skipAnimationFrameInResizeObserver")),o=de("context");return e?x.jsx(n,{ref:r,children:x.jsx(e,{...Fe(e,o)})}):null}),tl=m.memo(function(){const e=de("FooterComponent"),t=Ze("footerHeight"),n=de("HeaderFooterTag"),r=Ct(m.useMemo(()=>s=>{t(ht(s,"height"))},[t]),!0,de("skipAnimationFrameInResizeObserver")),o=de("context");return e?x.jsx(n,{ref:r,children:x.jsx(e,{...Fe(e,o)})}):null});function hs({useEmitter:e,useEmitterValue:t,usePublisher:n}){return m.memo(function({children:r,style:o,context:s,...i}){const u=n("scrollContainerState"),a=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("scrollerRef"),S=t("horizontalDirection")||!1,{scrollByCallback:g,scrollerRef:h,scrollToCallback:v}=ps(u,l,a,d,void 0,S);return e("scrollTo",v),e("scrollBy",g),x.jsx(a,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:h,style:{...S?Yi:Qi,...o},tabIndex:0,...i,...Fe(a,s),children:r})})}function ms({useEmitter:e,useEmitterValue:t,usePublisher:n}){return m.memo(function({children:r,style:o,context:s,...i}){const u=n("windowScrollContainerState"),a=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("totalListHeight"),S=t("deviation"),g=t("customScrollParent"),h=m.useRef(null),v=t("scrollerRef"),{scrollByCallback:w,scrollerRef:c,scrollToCallback:f}=ps(u,l,a,v,g);return fs(()=>{var p;return c.current=g||((p=h.current)==null?void 0:p.ownerDocument.defaultView),()=>{c.current=null}},[c,g]),e("windowScrollTo",f),e("scrollBy",w),x.jsx(a,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+S}:{}},...i,...Fe(a,s),children:r})})}const nl=({children:e})=>{const t=m.useContext(us),n=Ze("viewportHeight"),r=Ze("fixedItemHeight"),o=de("alignToBottom"),s=de("horizontalDirection"),i=m.useMemo(()=>No(n,a=>ht(a,s?"width":"height")),[n,s]),u=Ct(i,!0,de("skipAnimationFrameInResizeObserver"));return m.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),x.jsx("div",{"data-viewport-type":"element",ref:u,style:xn(o),children:e})},rl=({children:e})=>{const t=m.useContext(us),n=Ze("windowViewportRect"),r=Ze("fixedItemHeight"),o=de("customScrollParent"),s=Wo(n,o,de("skipAnimationFrameInResizeObserver")),i=de("alignToBottom");return m.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),x.jsx("div",{"data-viewport-type":"window",ref:s,style:xn(i),children:e})},ol=({children:e})=>{const t=de("TopItemListComponent")||"div",n=de("headerHeight"),r={...Zi,marginTop:`${n}px`},o=de("context");return x.jsx(t,{style:r,...Fe(t,o),children:e})},sl=m.memo(function(e){const t=de("useWindowScroll"),n=de("topItemsIndexes").length>0,r=de("customScrollParent"),o=de("context");return x.jsxs(r||t?al:ll,{...e,context:o,children:[n&&x.jsx(ol,{children:x.jsx(Vr,{showTopList:!0})}),x.jsxs(r||t?rl:nl,{children:[x.jsx(el,{}),x.jsx(Vr,{}),x.jsx(tl,{})]})]})}),{Component:il,useEmitter:vr,useEmitterValue:de,usePublisher:Ze}=cs($i,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},sl),ll=hs({useEmitter:vr,useEmitterValue:de,usePublisher:Ze}),al=ms({useEmitter:vr,useEmitterValue:de,usePublisher:Ze}),cl=il,ul=be(()=>{const e=W(l=>x.jsxs("td",{children:["Item $",l]})),t=W(null),n=W(l=>x.jsxs("td",{colSpan:1e3,children:["Group ",l]})),r=W(null),o=W(null),s=W({}),i=W(xr),u=W(Ot),a=(l,d=null)=>Ne(L(s,Y(S=>S[l]),Te()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:a("EmptyPlaceholder"),FillerRow:a("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:a("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:a("ScrollSeekPlaceholder"),TableBodyComponent:a("TableBody","tbody"),TableComponent:a("Table","table"),TableFooterComponent:a("TableFoot","tfoot"),TableHeadComponent:a("TableHead","thead"),TableRowComponent:a("TableRow","tr"),GroupComponent:a("Group","tr")}});ke(as,ul);br();const $r={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},dl={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ur,floor:an,max:Bt,min:zn,round:Kr}=Math;function Xr(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function fl(e){return{...dl,items:e}}function en(e,t){return e&&e.width===t.width&&e.height===t.height}function pl(e,t){return e&&e.column===t.column&&e.row===t.row}const gl=be(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:u,scrollTo:a,scrollTop:l,smoothScrollTargetReached:d,viewportHeight:S},g,h,{didMount:v,propsReady:w},{customScrollParent:c,useWindowScroll:f,windowScrollContainerState:p,windowScrollTo:C,windowViewportRect:T},I])=>{const j=W(0),b=W(0),y=W($r),k=W({height:0,width:0}),R=W({height:0,width:0}),_=me(),z=me(),B=W(0),E=W(null),P=W({column:0,row:0}),F=me(),M=me(),O=W(!1),Q=W(0),re=W(!0),oe=W(!1),ie=W(!1);Se(L(v,he(Q),ae(([A,G])=>!!G)),()=>{pe(re,!1)}),Se(L(Pe(v,re,R,k,Q,oe),ae(([A,G,K,H,,te])=>A&&!G&&K.height!==0&&H.height!==0&&!te)),([,,,,A])=>{pe(oe,!0),pr(1,()=>{pe(_,A)}),tt(L(l),()=>{pe(t,[0,0]),pe(re,!0)})}),ne(L(M,ae(A=>A!=null&&A.scrollTop>0),st(0)),b),Se(L(v,he(M),ae(([,A])=>A!=null)),([,A])=>{A&&(pe(k,A.viewport),pe(R,A.item),pe(P,A.gap),A.scrollTop>0&&(pe(O,!0),tt(L(l,wt(1)),G=>{pe(O,!1)}),pe(a,{top:A.scrollTop})))}),ne(L(k,Y(({height:A})=>A)),S),ne(L(Pe(le(k,en),le(R,en),le(P,(A,G)=>A&&A.column===G.column&&A.row===G.row),le(l)),Y(([A,G,K,H])=>({gap:K,item:G,scrollTop:H,viewport:A}))),F),ne(L(Pe(le(j),r,le(P,pl),le(R,en),le(k,en),le(E),le(b),le(O),le(re),le(Q)),ae(([,,,,,,,A])=>!A),Y(([A,[G,K],H,te,$,Z,ee,,J,ce])=>{const{column:se,row:ve}=H,{height:ge,width:Ce}=te,{width:Re}=$;if(ee===0&&(A===0||Re===0))return $r;if(Ce===0){const Tt=gr(ce,A),Sn=Tt+Math.max(ee-1,0);return fl(Xr(Tt,Sn,Z))}const Ae=bs(Re,Ce,se);let je,Ge;J?G===0&&K===0&&ee>0?(je=0,Ge=ee-1):(je=Ae*an((G+ve)/(ge+ve)),Ge=Ae*Ur((K+ve)/(ge+ve))-1,Ge=zn(A-1,Bt(Ge,Ae-1)),je=zn(Ge,Bt(0,je))):(je=0,Ge=-1);const rt=Xr(je,Ge,Z),{bottom:$e,top:Oe}=Qr($,H,te,rt),et=Ur(A/Ae),Qe=et*ge+(et-1)*ve-$e;return{bottom:$e,itemHeight:ge,items:rt,itemWidth:Ce,offsetBottom:Qe,offsetTop:Oe,top:Oe}})),y),ne(L(E,ae(A=>A!==null),Y(A=>A.length)),j),ne(L(Pe(k,R,y,P),ae(([A,G,{items:K}])=>K.length>0&&G.height!==0&&A.height!==0),Y(([A,G,{items:K},H])=>{const{bottom:te,top:$}=Qr(A,H,G,K);return[$,te]}),Te(Ht)),t);const ue=W(!1);ne(L(l,he(ue),Y(([A,G])=>G||A!==0)),ue);const xe=Xe(L(Pe(y,j),ae(([{items:A}])=>A.length>0),he(ue),ae(([[A,G],K])=>{const H=A.items[A.items.length-1].index===G-1;return(K||A.bottom>0&&A.itemHeight>0&&A.offsetBottom===0&&A.items.length===G)&&H}),Y(([[,A]])=>A-1),Te())),N=Xe(L(le(y),ae(({items:A})=>A.length>0&&A[0].index===0),st(0),Te())),D=Xe(L(le(y),he(O),ae(([{items:A},G])=>A.length>0&&!G),Y(([{items:A}])=>({endIndex:A[A.length-1].index,startIndex:A[0].index})),Te(Xo),dt(0)));ne(D,h.scrollSeekRangeChanged),ne(L(_,he(k,R,j,P),Y(([A,G,K,H,te])=>{const $=es(A),{align:Z,behavior:ee,offset:J}=$;let ce=$.index;ce==="LAST"&&(ce=H-1),ce=Bt(0,ce,zn(H-1,ce));let se=or(G,te,K,ce);return Z==="end"?se=Kr(se-G.height+K.height):Z==="center"&&(se=Kr(se-G.height/2+K.height/2)),J&&(se+=J),{behavior:ee,top:se}})),a);const q=Ne(L(y,Y(A=>A.offsetBottom+A.bottom)),0);return ne(L(T,Y(A=>({height:A.visibleHeight,width:A.visibleWidth}))),k),{customScrollParent:c,data:E,deviation:B,footerHeight:o,gap:P,headerHeight:s,increaseViewportBy:e,initialItemCount:b,itemDimensions:R,overscan:n,restoreStateFrom:M,scrollBy:i,scrollContainerState:u,scrollHeight:z,scrollTo:a,scrollToIndex:_,scrollTop:l,smoothScrollTargetReached:d,totalCount:j,useWindowScroll:f,viewportDimensions:k,windowScrollContainerState:p,windowScrollTo:C,windowViewportRect:T,...h,gridState:y,horizontalDirection:ie,initialTopMostItemIndex:Q,totalListHeight:q,...g,endReached:xe,propsReady:w,rangeChanged:D,startReached:N,stateChanged:F,stateRestoreInProgress:O,...I}},ke(hr,De,Xt,is,St,mr,vt));function bs(e,t,n){return Bt(1,an((e+n)/(an(t)+n)))}function Qr(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=or(e,t,n,r[0].index);return{bottom:or(e,t,n,r[r.length-1].index)+o,top:s}}function or(e,t,n,r){const o=bs(e.width,n.width,t.column),s=an(r/o),i=s*n.height+Bt(0,s-1)*t.row;return i>0?i+t.row:i}const hl=be(()=>{const e=W(S=>`Item ${S}`),t=W({}),n=W(null),r=W("virtuoso-grid-item"),o=W("virtuoso-grid-list"),s=W(xr),i=W("div"),u=W(Ot),a=(S,g=null)=>Ne(L(t,Y(h=>h[S]),Te()),g),l=W(!1),d=W(!1);return ne(le(d),l),{components:t,computeItemKey:s,context:n,FooterComponent:a("Footer"),HeaderComponent:a("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:a("Item","div"),itemContent:e,listClassName:o,ListComponent:a("List","div"),readyStateChanged:l,reportReadyState:d,ScrollerComponent:a("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:a("ScrollSeekPlaceholder","div")}}),ml=be(([e,t])=>({...e,...t}),ke(gl,hl)),bl=m.memo(function(){const e=_e("gridState"),t=_e("listClassName"),n=_e("itemClassName"),r=_e("itemContent"),o=_e("computeItemKey"),s=_e("isSeeking"),i=Je("scrollHeight"),u=_e("ItemComponent"),a=_e("ListComponent"),l=_e("ScrollSeekPlaceholder"),d=_e("context"),S=Je("itemDimensions"),g=Je("gap"),h=_e("log"),v=_e("stateRestoreInProgress"),w=Je("reportReadyState"),c=Ct(m.useMemo(()=>f=>{const p=f.parentElement.parentElement.scrollHeight;i(p);const C=f.firstChild;if(C){const{height:T,width:I}=C.getBoundingClientRect();S({height:T,width:I})}g({column:Yr("column-gap",getComputedStyle(f).columnGap,h),row:Yr("row-gap",getComputedStyle(f).rowGap,h)})},[i,S,g,h]),!0,!1);return fs(()=>{e.itemHeight>0&&e.itemWidth>0&&w(!0)},[e]),v?null:x.jsx(a,{className:t,ref:c,...Fe(a,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(f=>{const p=o(f.index,f.data,d);return s?x.jsx(l,{...Fe(l,d),height:e.itemHeight,index:f.index,width:e.itemWidth},p):m.createElement(u,{...Fe(u,d),className:n,"data-index":f.index,key:p},r(f.index,f.data,d))})})}),xl=m.memo(function(){const e=_e("HeaderComponent"),t=Je("headerHeight"),n=_e("headerFooterTag"),r=Ct(m.useMemo(()=>s=>{t(ht(s,"height"))},[t]),!0,!1),o=_e("context");return e?x.jsx(n,{ref:r,children:x.jsx(e,{...Fe(e,o)})}):null}),vl=m.memo(function(){const e=_e("FooterComponent"),t=Je("footerHeight"),n=_e("headerFooterTag"),r=Ct(m.useMemo(()=>s=>{t(ht(s,"height"))},[t]),!0,!1),o=_e("context");return e?x.jsx(n,{ref:r,children:x.jsx(e,{...Fe(e,o)})}):null}),Sl=({children:e})=>{const t=m.useContext(ds),n=Je("itemDimensions"),r=Je("viewportDimensions"),o=Ct(m.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return m.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),x.jsx("div",{ref:o,style:xn(!1),children:e})},yl=({children:e})=>{const t=m.useContext(ds),n=Je("windowViewportRect"),r=Je("itemDimensions"),o=_e("customScrollParent"),s=Wo(n,o,!1);return m.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),x.jsx("div",{ref:s,style:xn(!1),children:e})},wl=m.memo(function({...e}){const t=_e("useWindowScroll"),n=_e("customScrollParent"),r=n||t?Il:Cl,o=n||t?yl:Sl,s=_e("context");return x.jsx(r,{...e,...Fe(r,s),children:x.jsxs(o,{children:[x.jsx(xl,{}),x.jsx(bl,{}),x.jsx(vl,{})]})})}),{useEmitter:xs,useEmitterValue:_e,usePublisher:Je}=cs(ml,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},wl),Cl=hs({useEmitter:xs,useEmitterValue:_e,usePublisher:Je}),Il=ms({useEmitter:xs,useEmitterValue:_e,usePublisher:Je});function Yr(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,qe.WARN),t==="normal"?0:parseInt(t??"0",10)}const vn=m.createContext(void 0);function we(e,t){const n=m.useContext(vn);if(!n)throw new Error("useAudioStore must be used within CRAudioProvider");return $t(n,e,t)}function cn(){const e=m.useContext(vn);if(!e)throw new Error("useAudioStoreApi must be used within CRAudioProvider");return e}let vs=!1;function Ss(){return vs}function Zr(e){vs=e}const Tl="_run_zzb61_3",kl="_runWrap_zzb61_7",Rl="_highlight_zzb61_13",_l="_highlightleft_zzb61_14",Ml="_highlightright_zzb61_15",El="_highlightcenter_zzb61_16",jl="_underline_zzb61_48",Ol="_underlineleft_zzb61_49",zl="_underlineright_zzb61_50",Al="_underlinecenter_zzb61_51",ot={run:Tl,runWrap:kl,highlight:Rl,highlightleft:_l,highlightright:Ml,highlightcenter:El,underline:jl,underlineleft:Ol,underlineright:zl,underlinecenter:Al},Jr=e=>Symbol.iterator in e,eo=e=>"entries"in e,to=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(const[o,s]of n)if(!r.has(o)||!Object.is(s,r.get(o)))return!1;return!0},Pl=(e,t)=>{const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let o=n.next(),s=r.next();for(;!o.done&&!s.done;){if(!Object.is(o.value,s.value))return!1;o=n.next(),s=r.next()}return!!o.done&&!!s.done};function Bl(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Jr(e)&&Jr(t)?eo(e)&&eo(t)?to(e,t):Pl(e,t):to({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function qt(e){const t=m.useRef(void 0);return n=>{const r=e(n);return Bl(t.current,r)?t.current:t.current=r}}function Ll(e){const t=e.replace("#",""),n=parseInt(t.length===3?t.repeat(2):t,16),r=n>>16&255,o=n>>8&255,s=n&255;return{r,g:o,b:s}}function Gl(e){const t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return t?{r:+t[1],g:+t[2],b:+t[3]}:null}const Hl=Object.freeze({showPointer:void 0,pointerStyle:void 0,pointerColor:void 0}),ys=m.memo(function({runs:t,ns:n,baseIndex:r,preGroups:o}){const s=we(_=>_.setClipIndex),i=we(_=>_.seek),u=V(_=>_.setCurrentGlobalRunIndex),a=cn(),l=V(_=>_.rangeStartGI),d=V(_=>_.rangeEndGI),S=V(_=>_.setRange),g=l!=null&&d!=null,h=m.useCallback(_=>{var Q;const z=(Q=_.target)==null?void 0:Q.closest("[data-g]");if(!z)return;const B=Number(z.dataset.g),E=B-r;if(E<0||E>=t.length)return;const P=t[E],F=P.text??"";if(!F.trim()||!/[가-힣a-zA-Z0-9]/.test(F))return;u(B,"program");const M=P.audioChunkIndex,O=P.audioTimeMs;M!=null&&O!=null&&(s(M),i(O))},[t,r,i,s,u]),v=m.useRef(null),w=m.useRef(!1),c=m.useRef({x:0,y:0}),f=m.useCallback(_=>{var P;const z=(P=_.target)==null?void 0:P.closest("[data-g]");if(!z)return;const B=Number(z.dataset.g),E=B-r;E<0||E>=t.length||(w.current=!1,c.current={x:_.clientX,y:_.clientY},v.current&&(window.clearTimeout(v.current),v.current=null),v.current=window.setTimeout(()=>{a.getState().status!=="playing"&&(S(B,B),w.current=!0,v.current=null)},800))},[t,r,S,a]),p=m.useCallback(()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]),C=m.useCallback(_=>{if(!v.current)return;const z=_.clientX-c.current.x,B=_.clientY-c.current.y;(Math.abs(z)>5||Math.abs(B)>5)&&p()},[p]),T=m.useCallback(()=>{p()},[p]),I=p,j=p,b=V(_=>_.clearRange),y=m.useCallback(_=>{var E;if(w.current){w.current=!1;return}if(Ss())return;const z=(E=_.target)==null?void 0:E.closest("[data-g]");if(!z)return;const B=Number(z.dataset.g);isNaN(B)||g&&l!=null&&d!=null&&(b(),_.stopPropagation())},[g,l,d,b]),k=o,R=r+t.length-1;return x.jsx("span",{onClick:y,onDoubleClick:h,onPointerDown:f,onPointerMove:C,onPointerUp:T,onPointerCancel:I,onPointerLeave:j,children:k.map((_,z)=>x.jsx(Nl,{ns:n,group:_,runs:t,paraLastG:R,rangeStartGI:l,rangeEndGI:d},`${n}/grp:${z}-${_.startG}`))})},(e,t)=>e.ns===t.ns&&e.baseIndex===t.baseIndex&&e.runs===t.runs&&e.sectionId===t.sectionId),Fl=m.memo(function(){const t=m.useCallback(r=>({showSplit:r.showSplit,slash:r.breakMarks.slash,breakGapPx:r.breakGapPx}),[]),n=X(qt(t));return n.showSplit?x.jsxs(x.Fragment,{children:[x.jsx("span",{style:{display:"inline-block",width:n.breakGapPx/2}}),n.slash&&x.jsx("span",{children:" / "}),x.jsx("span",{style:{display:"inline-block",width:n.breakGapPx/2}})]}):null}),Nl=m.memo(function({ns:t,group:n,runs:r,paraLastG:o,rangeStartGI:s,rangeEndGI:i}){const u=m.useCallback(c=>{const f=c.currentGlobalRunIndex;return f!=null&&f>=n.startG&&f<=n.endG},[n]),a=V(qt(u)),l=m.useCallback(c=>a?{showPointer:c.showPointer,pointerStyle:c.pointerStyle,pointerColor:c.pointerColor}:Hl,[a]),d=X(qt(l)),S=n.r0??0,g=n.len??Math.max(0,n.endG-n.startG+1),h=a&&d.showPointer&&d.pointerStyle!=="underline",v=a&&d.showPointer&&d.pointerStyle==="underline",w=h||v?{"--hl-color":d.pointerColor,"--ul-color":d.pointerColor,"--ul-thickness":"0.3em","--ul-offset":"0.35em"}:void 0;return x.jsx(x.Fragment,{children:Array.from({length:g}).map((c,f)=>{const C=r[S+f],T=n.startG+f,I=`${t}/run:${T}`,j=!!C.split&&T!==o;let b=`${ot.runWrap}`;return h&&(g===1?b+=` ${ot.highlight}`:f===0?b+=` ${ot.highlightleft}`:f+1===g?b+=` ${ot.highlightright}`:b+=` ${ot.highlightcenter}`),v&&(g===1?b+=` ${ot.underline}`:f===0?b+=` ${ot.underlineleft}`:f+1===g?b+=` ${ot.underlineright}`:b+=` ${ot.underlinecenter}`),x.jsxs(m.Fragment,{children:[x.jsx("span",{className:b,style:w,children:x.jsx(Dl,{gi:n.startG,g:T,run:C,active:a,pointerCfg:d,isInRange:s!=null&&i!=null&&T>=s&&T<=i})}),j&&x.jsx(Fl,{})]},I)})})},(e,t)=>e.group===t.group&&e.runs===t.runs&&e.ns===t.ns&&e.rangeStartGI===t.rangeStartGI&&e.rangeEndGI===t.rangeEndGI),Dl=m.memo(function({gi:t,g:n,run:r,active:o,pointerCfg:s,isInRange:i}){const u=m.useMemo(()=>{const a={whiteSpace:"pre-wrap"};if(r.bold&&(a.fontWeight=700),r.italic&&(a.fontStyle="italic"),r.underline&&(a.textDecoration="underline"),o&&s.showPointer){const l=s.pointerColor;if(s.pointerStyle!=="underline"){a.backgroundColor=l;const d=l.startsWith("#")?Ll(l):Gl(l);d&&(.299*d.r+.587*d.g+.114*d.b)/255<.6&&(a.color="#fff")}}return i&&(a.boxShadow="inset 0 0 0 100px rgba(59, 130, 246, 0.3)"),a},[r.bold,r.italic,r.underline,o,s,i]);return x.jsx("span",{className:ot.run,style:u,"data-g":n,"data-gi":t,"data-test":(r==null?void 0:r.audioChunkIndex)||-1,children:r.text||""})},(e,t)=>e.g===t.g&&e.run===t.run&&e.active===t.active&&e.pointerCfg===t.pointerCfg&&e.isInRange===t.isInRange);function Wl({block:e,computedMarker:t,ns:n,baseIndex:r,sectionId:o,preGroups:s}){var l;const i=e.list?e.list.level*24:0,u=((l=e.list)==null?void 0:l.kind)==="bullet"?e.list.glyph??"•":void 0,a=t??u;return x.jsxs("p",{style:{width:"100%",margin:"8px 0",paddingLeft:i,textAlign:e.textAlign,boxSizing:"border-box"},children:[e.list?x.jsx("span",{style:{minWidth:16,display:"inline-block",whiteSpace:"nowrap",userSelect:"none"},children:a||""}):null,x.jsx(ys,{preGroups:s,runs:e.runs,ns:n,baseIndex:r,sectionId:o})]})}const ql=m.memo(Wl,(e,t)=>e.block===t.block&&e.computedMarker===t.computedMarker&&e.baseIndex===t.baseIndex&&e.ns===t.ns);function Vl(e,t){switch((t||"decimal").toLowerCase().replace(/[\s_-]+/g,"")){case"decimal":return String(e);case"decimalleadingzero":return e<10?`0${e}`:String(e);case"loweralpha":case"lowerlatin":return ro(e,!1);case"upperalpha":case"upperlatin":return ro(e,!0);case"lowerroman":return no(e,!1);case"upperroman":return no(e,!0);case"decimalenclosedcircle":return $l(e);default:return String(e)}}function $l(e){return e>=1&&e<=20?String.fromCharCode(9312+(e-1)):`(${e})`}function no(e,t=!0){if(e<=0)return"";const n=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];let r=e,o="";for(const[s,i]of n)for(;r>=s;)o+=i,r-=s;return t?o:o.toLowerCase()}function ro(e,t=!1){let n=e,r="";for(;n>0;)n--,r=String.fromCharCode(97+n%26)+r,n=Math.floor(n/26);return t?r.toUpperCase():r}function Sr(e){const t=new Map;return{next(n,r){const o=`${n}-${r}`,s=(t.get(o)??0)+1;return t.set(o,s),s},reset(){t.clear()}}}function yr(e,t){const n=e.list;if(!n||n.kind!=="ordered")return;const r=t.next(n.numId??0,n.level),o=Vl(r,n.format),s=(n.format||"").toLowerCase();return!/enclosed|paren/.test(s)&&s!=="decimalleadingzero"?`${o}.`:o}function Ul(e){return e.map(t=>t.type==="image"?0:t.runs.length)}function Kl(e){const t=new Array(e.length+1).fill(0);for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n];return t}function Xl(e,t){const n=[];if(!e.length)return n;const r=(o,s,i)=>{n.push({splitIndex:i??o,runs:e.slice(o,s+1),startG:t+o,endG:t+s})};for(let o=0;o<e.length;o++){const s=e[o].splitIndex;if(s===void 0){r(o,o,void 0);continue}let i=o+1;for(;i<e.length&&e[i].splitIndex===s;)i++;r(o,i-1,s),o=i-1}return n}const Ql="_scroller_kqkmq_3",Yl={scroller:Ql},Zl=m.forwardRef(function({className:t,style:n,...r},o){return x.jsx("div",{ref:o,className:`${Yl.scroller}${t?" "+t:""}`,style:n,...r})}),sr=e=>/[가-힣a-zA-Z0-9]/.test(e),Jl=e=>((e==null?void 0:e.textContent)??"").trim(),un=(e,t)=>e.querySelector(`[data-g="${t}"]`);function ea(e,t=12,n=1.5,r=.5){if(!e)return-1;const o=e.getBoundingClientRect(),s=o.top+t;let i=-1,u=1/0,a=1/0,l=-1,d=1/0,S=1/0;const g=e.querySelectorAll("[data-g]");for(let h=0;h<g.length;h++){const v=g[h];if(!v||!v.isConnected)continue;const w=Jl(v);if(!w||!sr(w))continue;const c=v.getBoundingClientRect();if(c.height<=r||c.width<=r||c.bottom<=o.top||c.top>=o.bottom)continue;if(c.top<s){const C=Math.abs(c.top-s);(C<d||C===d&&(c.top<S||l!==-1&&Number(v.dataset.g)<l))&&(d=C,l=Number(v.dataset.g),S=c.top);continue}const f=Number(v.dataset.g);if(Number.isNaN(f))continue;c.top<a-n?(a=c.top,u=c.top,i=f):c.top<=a+n&&(c.top<u||c.top===u&&(i===-1||f<i))&&(u=c.top,i=f);const p=Math.abs(c.top-s);(p<d||p===d&&(c.top<S||l!==-1&&f<l))&&(d=p,l=f,S=c.top)}return i!==-1?i:l}const ws=async(e,t,{timeoutMs:n=1200,intervalMs:r=16}={})=>{const o=performance.now();let s=un(e,t);for(;!s;){if(performance.now()-o>n)return null;await new Promise(i=>setTimeout(i,r)),s=un(e,t)}return s},Cs=e=>{const t=e.getBoundingClientRect(),n=t.top+t.height*.15,r=t.top+t.height*.8,o=Array.from(e.querySelectorAll("[data-g]"));let s=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const u of o){const a=u.getBoundingClientRect();if(a.bottom<n||a.top>r||a.height<=0)continue;const l=Number(u.dataset.g);Number.isNaN(l)||(l<s&&(s=l),l>i&&(i=l))}return!Number.isFinite(s)||!Number.isFinite(i)?null:{first:s,last:i}},ta=(e,t,{topPaddingRatio:n=.15,behavior:r="auto"}={})=>{const o=un(e,t);if(!o)return!1;const s=e.getBoundingClientRect(),i=o.getBoundingClientRect(),u=s.height*n,a=i.top-(s.top+u);return e.scrollTo({top:e.scrollTop+a,behavior:r}),!0};function na(e,t=120){return new Promise(n=>{let r=null;const o=()=>{r!=null&&window.clearTimeout(r),r=window.setTimeout(()=>{e.removeEventListener("scroll",o,{capture:!0}),n()},t)};e.addEventListener("scroll",o,{passive:!0,capture:!0}),o()})}const oo=async(e,t,{topPaddingRatio:n=.15,behavior:r="smooth",quietMs:o=120}={})=>{if(!ta(e,t,{topPaddingRatio:n,behavior:r}))return!1;await na(e,o);const i=un(e,t);if(!i)return!1;const u=e.getBoundingClientRect(),a=i.getBoundingClientRect(),l=u.height*n,d=u.top+l,S=a.top-d;return Math.abs(S)<=1},gt=()=>new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>e())})}),wr=m.createContext(null);function Is(){const e=m.useContext(wr);if(!e)throw new Error("useQuizStoreApi must be used within QuizProgressProvider");return e}function Ue(e,t){const n=m.useContext(wr);if(!n)throw new Error("useQuizStore must be used within QuizProgressProvider");return $t(n,e,t)}const Ts=()=>{const e=V(l=>l.section),t=Is(),n=Ue(l=>l.retryAllowed),r=Ue(l=>l.previousResult),o=r!=null,s=e.quizzes;if(!s||!s.length)return null;const i=o?n?`퀴즈 다시 풀기 (${s.length})`:"퀴즈 결과 보기":`퀴즈 풀기 (${s.length})`,u=o&&!n?"#64748b":"#2563eb",a=o&&!n?"0 6px 16px rgba(100,116,139,0.3)":"0 6px 16px rgba(37,99,235,0.3)";return x.jsxs("button",{onClick:()=>{t.getState().openFromSection(e)},style:{width:300,background:u,color:"white",border:"none",borderRadius:"10px",padding:"14px 28px",fontSize:"16px",fontWeight:600,cursor:"pointer",boxShadow:a,transition:"all 0.15s ease"},children:[i,o&&!n&&x.jsxs("div",{style:{fontSize:"12px",fontWeight:400,marginTop:"4px",opacity:.8},children:["이미 풀었습니다 (",r.rate,"%)"]})]})},ra="_navBtn_1fciy_2",oa="_disabled_1fciy_26",sa="_label_1fciy_32",Et={navBtn:ra,disabled:oa,label:sa};var ks={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},so=m.createContext&&m.createContext(ks),ia=["attr","size","title"];function la(e,t){if(e==null)return{};var n=aa(e,t),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)r=s[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function aa(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function dn(){return dn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},dn.apply(this,arguments)}function io(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function fn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?io(Object(n),!0).forEach(function(r){ca(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):io(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function ca(e,t,n){return t=ua(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ua(e){var t=da(e,"string");return typeof t=="symbol"?t:t+""}function da(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Rs(e){return e&&e.map((t,n)=>m.createElement(t.tag,fn({key:n},t.attr),Rs(t.child)))}function Ve(e){return t=>m.createElement(fa,dn({attr:fn({},e.attr)},t),Rs(e.child))}function fa(e){var t=n=>{var{attr:r,size:o,title:s}=e,i=la(e,ia),u=o||n.size||"1em",a;return n.className&&(a=n.className),e.className&&(a=(a?a+" ":"")+e.className),m.createElement("svg",dn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,i,{className:a,style:fn(fn({color:e.color||n.color},n.style),e.style),height:u,width:u,xmlns:"http://www.w3.org/2000/svg"}),s&&m.createElement("title",null,s),e.children)};return so!==void 0?m.createElement(so.Consumer,null,n=>t(n)):t(ks)}function lo(e){return Ve({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M18.464 2.114a.998.998 0 0 0-1.033.063l-13 9a1.003 1.003 0 0 0 0 1.645l13 9A1 1 0 0 0 19 21V3a1 1 0 0 0-.536-.886zM17 19.091 6.757 12 17 4.909v14.182z"},child:[]}]})(e)}function ao(e){return Ve({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M5.536 21.886a1.004 1.004 0 0 0 1.033-.064l13-9a1 1 0 0 0 0-1.644l-13-9A.998.998 0 0 0 5 3v18a1 1 0 0 0 .536.886zM7 4.909 17.243 12 7 19.091V4.909z"},child:[]}]})(e)}const pa=({isIcon:e=!0})=>{const t=V(i=>i.isCanPrev),n=V(i=>i.onSectionNav),r=!t,o=m.useCallback(i=>{i.stopPropagation(),i.preventDefault(),t&&(n==null||n("prev"))},[t,n]),s=t?"이전 섹션으로":"이전 섹션 없음";return e?x.jsxs("button",{type:"button",className:`${Et.navBtn} ${r?Et.disabled:""}`,disabled:r,title:s,onMouseDown:o,onClick:i=>i.stopPropagation(),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},children:[x.jsx(lo,{size:18}),x.jsx("span",{className:Et.label,children:"이전"})]}):x.jsx("button",{type:"button",disabled:r,title:s,onClick:o,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},style:{width:300,background:r?"#9ca3af":"#2563eb",color:"white",border:"none",borderRadius:"10px",padding:"14px 28px",fontSize:"16px",fontWeight:600,cursor:r?"not-allowed":"pointer",boxShadow:r?"none":"0 6px 16px rgba(37,99,235,0.3)",transition:"all 0.15s ease",opacity:r?.5:1},children:r?"첫섹션입니다":x.jsxs(x.Fragment,{children:[x.jsx(lo,{size:18,style:{display:"inline",marginRight:"8px",verticalAlign:"middle"}}),"PrevSection"]})})},pn=({isIcon:e=!0})=>{const t=V(i=>i.isCanNext),n=V(i=>i.onSectionNav),r=!t,o=m.useCallback(i=>{i.stopPropagation(),i.preventDefault(),t&&(n==null||n("next"))},[t,n]),s=t?"다음 섹션으로":"다음 섹션 없음";return e?x.jsxs("button",{type:"button",className:`${Et.navBtn} ${r?Et.disabled:""}`,disabled:r,title:s,onMouseDown:o,onClick:i=>i.stopPropagation(),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},children:[x.jsx(ao,{size:18}),x.jsx("span",{className:Et.label,children:"다음"})]}):x.jsx("button",{type:"button",disabled:r,title:s,onClick:o,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},style:{width:300,background:r?"#9ca3af":"#2563eb",color:"white",border:"none",borderRadius:"10px",padding:"14px 28px",fontSize:"16px",fontWeight:600,cursor:r?"not-allowed":"pointer",boxShadow:r?"none":"0 6px 16px rgba(37,99,235,0.3)",transition:"all 0.15s ease",opacity:r?.5:1},children:r?"마지막섹션입니다":x.jsxs(x.Fragment,{children:["NextSection",x.jsx(ao,{size:18,style:{display:"inline",marginLeft:"8px",verticalAlign:"middle"}})]})})};function _s(e,t){let n=0,r=e.length-1;for(;n<r;){const o=Math.floor((n+r+1)/2);e[o]<=t?n=o:r=o-1}return n}function co(e,t,n=.2,r=.8){const o=e.querySelector(`[data-g="${t}"]`);if(!o)return!1;const s=e.getBoundingClientRect(),i=o.getBoundingClientRect();if(i.height<=0||s.height<=0)return!1;const u=(i.top+i.height/2-s.top)/s.height;return u>=n&&u<=r}const ga=e=>e==="instant"?"auto":e;function ha(e){const{sc:t,virtRef:n,prefix:r,recorderStoreApi:o,programmaticScrollRef:s,scrollToGISeqRef:i}=e,u=p=>{const C=t.scrollTop,T=t.scrollHeight-t.clientHeight,I=T>0?C/T:0;let j=0;const b=t.querySelector(`[data-g="${p}"]`);if(b){const y=t.getBoundingClientRect(),k=b.getBoundingClientRect(),R=y.height>0?y.height/t.clientHeight:1,_=(k.top-y.top)/R/t.clientHeight;j=Math.max(0,Math.min(_,1))}o.getState().emit({type:"scroll",payload:{scrollTop:C,scrollRatio:I,anchorGI:p,anchorOffsetRatio:j}})},a=async(p,C="smooth")=>{var I;const T=_s(r,p);(I=n.current)==null||I.scrollToIndex({index:T,align:"start",behavior:ga(C)}),await ws(t,p)},l=()=>new Promise(p=>requestAnimationFrame(()=>p())),d=async p=>{if(co(t,p,.1,.7))return u(p),!0;if(t.scrollTop>=t.scrollHeight-t.clientHeight-1){const y=t.querySelector(`[data-g="${p}"]`);if(y){const k=t.getBoundingClientRect(),R=y.getBoundingClientRect();if(R.bottom>k.top&&R.top<k.bottom)return u(p),!0}}s.current=!0;const T=t.querySelector(`[data-g="${p}"]`),I=t.getBoundingClientRect();let j=t.scrollTop<=1?0:.1;if(T){const y=T.getBoundingClientRect();j=((y.top+y.height/2-I.top)/I.height>.5,.15)}return!!T?(await oo(t,p,{behavior:"smooth",topPaddingRatio:j}),await l()):(await a(p,"auto"),await oo(t,p,{behavior:"auto",topPaddingRatio:.15})),s.current=!1,u(p),co(t,p,.1,.7)};return{ensureVisibleGI:d,scrollToGI:async p=>d(p),getVisibleRange:()=>Cs(t),getScrollTop:()=>t.scrollTop,setScrollTop:p=>{var C;(C=n.current)==null||C.scrollTo({top:p})},getAnchorOffsetRatio:p=>{const C=t.querySelector(`[data-g="${p}"]`);if(!C)return 0;const T=C.getBoundingClientRect(),I=t.getBoundingClientRect(),j=I.height>0?I.height/t.clientHeight:1;return(T.top-I.top)/j/t.clientHeight},scrollToGIAtOffset:async(p,C)=>{var j,b;const T=t.querySelector(`[data-g="${p}"]`);if(T){const y=T.getBoundingClientRect(),k=t.getBoundingClientRect(),R=k.height>0?k.height/t.clientHeight:1,_=(y.top-k.top)/R,z=C*t.clientHeight;if(Math.abs(_-z)<=3)return}const I=++i.current;s.current=!0;try{const y=()=>new Promise(B=>requestAnimationFrame(()=>B())),k=()=>{const B=t.querySelector(`[data-g="${p}"]`);if(!B)return null;const E=B.getBoundingClientRect(),P=t.getBoundingClientRect(),F=P.height>0?P.height/t.clientHeight:1,M=(E.top-P.top)/F,O=C*t.clientHeight;return{delta:M-O,cur:M,tgt:O}};if(I!==i.current||(await a(p,"auto"),I!==i.current)||(await y(),await y(),await y(),I!==i.current))return;const R=k(),_=t.scrollTop>=t.scrollHeight-t.clientHeight-1,z=t.scrollTop<=1;if(R&&Math.abs(R.delta)>1&&!(_&&R.delta>0)&&!(z&&R.delta<0)){const B=t.scrollTop;if((j=n.current)==null||j.scrollBy({top:R.delta}),await y(),I!==i.current)return;for(let E=0;E<3;E++){const P=k();if(!P||Math.abs(P.delta)<=2)break;const F=t.scrollTop;if((b=n.current)==null||b.scrollBy({top:P.delta}),await y(),I!==i.current)return;if(Math.abs(t.scrollTop-F)<1)break}}}finally{I===i.current&&(s.current=!1)}},getScrollRatio:()=>{const p=t.scrollHeight-t.clientHeight;return p>0?t.scrollTop/p:0}}}const ma=({scrollContainerRef:e,virtRef:t,prefix:n})=>{const r=V(M=>M.setCurrentGlobalRunIndex),o=V(M=>M.registerSectionScrollApi),s=we(M=>M.scrollLock),i=we(M=>M.syncToGI),u=bt(),a=lt(),l=Go(M=>M.isPlaybackMode),d=m.useRef(!1),S=m.useRef(null),g=m.useRef(null),h=m.useRef(0),v=m.useRef(null),w=m.useRef(-1),c=m.useCallback(()=>{if(l||s)return;S.current=null;const M=g.current;if(!M)return;const O=ea(M,5);O!==-1&&O!==w.current&&(w.current=O,i(O))},[l,s,i]),f=m.useCallback(M=>{g.current=M,S.current==null&&(S.current=requestAnimationFrame(c))},[c]),p=m.useCallback(M=>{var re;g.current=M,(re=v.current)==null||re.abort();const O=new AbortController;v.current=O,new Promise(oe=>{"onscrollend"in M?M.addEventListener("scrollend",()=>oe(),{once:!0}):setTimeout(oe,150)}).then(()=>{if(O.signal.aborted)return;v.current=null,c();const oe=w.current;oe!==-1&&r(oe,"scroll"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(O.signal.aborted)return;const ie=w.current;if(ie===-1)return;const ue=M.scrollTop,xe=M.scrollHeight-M.clientHeight,N=xe>0?ue/xe:0;let D=0;const q=M.querySelector(`[data-g="${ie}"]`);if(q){const A=M.getBoundingClientRect(),G=q.getBoundingClientRect(),K=A.height>0?A.height/M.clientHeight:1,H=(G.top-A.top)/K/M.clientHeight;D=Math.max(0,Math.min(H,1))}u.getState().emit({type:"scroll",payload:{scrollTop:ue,scrollRatio:N,anchorGI:ie,anchorOffsetRatio:D}})})})})},[c,u,r]),C=m.useRef(!1),T=m.useCallback(M=>{l||s||d.current&&(C.current||(f(M),p(M)))},[l,s,f,p]),I=m.useRef(void 0),j=m.useRef(void 0),b=m.useRef(void 0),y=m.useRef(void 0);m.useEffect(()=>{const M=e.current;if(M)return I.current=()=>{d.current=!0},j.current=()=>{d.current=!0},b.current=()=>{d.current=!0},y.current=()=>T(M),M.addEventListener("wheel",I.current,{passive:!0}),M.addEventListener("touchmove",j.current,{passive:!0}),window.addEventListener("keydown",b.current,{passive:!0}),M.addEventListener("scroll",y.current,{passive:!0}),()=>{var O;M.removeEventListener("wheel",I.current),M.removeEventListener("touchmove",j.current),window.removeEventListener("keydown",b.current),M.removeEventListener("scroll",y.current),S.current!=null&&cancelAnimationFrame(S.current),(O=v.current)==null||O.abort()}},[T,e]),m.useEffect(()=>{const M=e.current;if(!M||!s)return;const O=ie=>{ie.preventDefault(),ie.stopPropagation(),d.current=!1},Q=ie=>{ie.preventDefault(),ie.stopPropagation(),d.current=!1},re=ie=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(ie.key)&&(ie.preventDefault(),ie.stopPropagation(),d.current=!1)},oe={overscrollBehavior:M.style.overscrollBehavior,touchAction:M.style.touchAction};return M.style.overscrollBehavior="contain",M.style.touchAction="none",M.addEventListener("wheel",O,{passive:!1}),M.addEventListener("touchmove",Q,{passive:!1}),window.addEventListener("keydown",re,{passive:!1}),()=>{M.removeEventListener("wheel",O),M.removeEventListener("touchmove",Q),window.removeEventListener("keydown",re),M.style.overscrollBehavior=oe.overscrollBehavior,M.style.touchAction=oe.touchAction}},[s,e]);const k=m.useRef({first:-1,last:-1}),R=m.useRef(!1),_=m.useCallback(()=>{const M=e.current;if(!M)return;const O=Cs(M),Q=(O==null?void 0:O.first)??-1,re=(O==null?void 0:O.last)??-1;k.current={first:Q,last:re}},[e]),z=m.useRef(!1),B=m.useCallback(()=>{const M=e.current;if(!M||z.current)return;z.current=!0;const O=Math.min(M.scrollTop+Math.floor(M.clientHeight*.6),M.scrollHeight-M.clientHeight);requestAnimationFrame(()=>{M.scrollTo({top:O,behavior:"instant"})})},[e]);m.useEffect(()=>{!R.current&&s&&(z.current=!1,_()),R.current=s},[s,_]);const E=m.useRef(0),P=m.useRef(0);m.useEffect(()=>{if(!s||l)return;const M=Q=>{const re=e.current;if(!re)return;const{first:oe,last:ie}=k.current;if(oe===-1||ie===-1){B();return}const ue=re.querySelector(`[data-g="${Q}"]`);if(ue){const N=re.getBoundingClientRect(),D=ue.getBoundingClientRect();if(N.height>0){const q=(D.top-N.top)/N.height,A=(D.bottom-N.top)/N.height;if(q>=.02&&A<=.95){_();return}}}const xe=++E.current;window.clearTimeout(P.current),P.current=window.setTimeout(()=>{if(xe!==E.current)return;const N=a.getState().progress.getSectionScrollApi();N?N.ensureVisibleGI(Q).then(D=>{xe===E.current&&(D?_():B())}):B()},80)};M(a.getState().progress.currentGlobalRunIndex);const O=a.subscribe((Q,re)=>{const oe=Q.progress.currentGlobalRunIndex;oe!==re.progress.currentGlobalRunIndex&&M(oe)});return()=>{O(),E.current+=1;const Q=P.current;window.clearTimeout(Q)}},[s,l,B,_,e,a]);const F=m.useCallback(()=>{const M=e.current;if(M)return ha({sc:M,virtRef:t,prefix:n,recorderStoreApi:u,programmaticScrollRef:C,scrollToGISeqRef:h})},[e,t,n,u]);return m.useEffect(()=>(o(F()),()=>o(void 0)),[F,o]),null};function ba({section:e,blocks:t,nsPrefix:n}){const r=m.useMemo(()=>{const R=[],_=Sr();return t.forEach((z,B)=>{z.type==="paragraph"&&(R[B]=yr(z,_))}),R},[t]),o=V(R=>{var _;return((_=R.layout)==null?void 0:_.prefix)??[]}),s=V(R=>{var _;return((_=R.derivedNav)==null?void 0:_.splitGroupsPerBlock)??[]}),i=X(R=>R.marginX),u=X(R=>R.viewportHeight),a=m.useRef({start:0,end:0}),l=m.useCallback(R=>{const _=t[R],z=`${n}blk-${_.id}`;if(_.type==="image"){const{src:P,alt:F,width:M,height:O}=_,Q=M&&O?`${M} / ${O}`:"4 / 3",re=R>=a.current.start&&R<=a.current.end,oe=u>80?Math.floor((u-80)*.6):void 0;return x.jsxs("div",{style:{margin:"12px 0",textAlign:"center",width:"100%"},children:[x.jsx("div",{style:{position:"relative",width:"100%",maxHeight:oe,aspectRatio:Q},children:x.jsx("img",{src:P,alt:F||"",loading:re?"eager":"lazy",style:{pointerEvents:"none",position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"contain",display:"block"}})}),F&&x.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:F})]})}const B=r[R]??void 0,E=s[R];return x.jsx("div",{style:{maxWidth:860,display:"flex"},children:x.jsx(ql,{block:_,computedMarker:B,ns:z,baseIndex:o[R],sectionId:e.section_id,preGroups:E})})},[t,r,o,n,e,s,u]),d=m.useRef(null),S=m.useCallback(R=>{d.current=R},[]),g=m.useMemo(()=>m.memo(R=>{const{style:_,children:z,...B}=R;return x.jsx("div",{...B,style:_,children:x.jsx("div",{style:{boxSizing:"border-box",paddingRight:`${i}px`,paddingLeft:`${i}px`,maxWidth:860,margin:"0 auto",width:"100%",height:"100%"},children:z})})}),[i]),h=m.useRef(null),v=m.useMemo(()=>t.map(R=>R.id),[t]),w=Go(R=>R.isPlaybackMode),[c,f]=m.useState(!1);m.useEffect(()=>{f(w)},[t,w]);const p=m.useCallback(()=>{f(!0)},[]),C=m.useCallback(()=>{const R=Math.max(80,Math.floor(u*.5));if(!c)return x.jsx("div",{style:{height:R}});const _=e.quizzes;return _&&_.length?x.jsxs("div",{style:{display:"block"},children:[x.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:x.jsx(Ts,{})}),x.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:x.jsx(pn,{isIcon:!1})}),x.jsx("div",{style:{height:R,width:"100%"}})]}):x.jsxs("div",{children:[x.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:x.jsx(pn,{isIcon:!1})}),x.jsx("div",{style:{height:R}})]})},[c,e,u]),T=m.useMemo(()=>({Item:g,Header:()=>x.jsx("div",{style:{height:40}}),Footer:C,Scroller:Zl}),[C,g]),I=m.useCallback(R=>v[R],[v]),j=lt(),[b]=m.useState(()=>j.getState().progress.currentGlobalRunIndex??0),y=m.useMemo(()=>{if(!o.length)return 0;const R=o[o.length-1],_=Math.max(0,Math.min(b,R));return _s(o,_)},[o,b]),k=lt();return m.useEffect(()=>{let R=!1;return(async()=>{let _=d.current;if(!_){for(let P=0;P<20;P++){if(await new Promise(F=>setTimeout(F,50)),R)return;if(_=d.current,_)break}if(!_)return}const z=k.getState().progress.currentGlobalRunIndex,B=k.getState().progress.setSectionLoading,E=z!=null&&z>=0?z:0;await ws(_,E),!R&&(await gt(),await gt(),await gt(),await gt(),!R&&B(!1))})(),()=>{R=!0}},[d,k]),x.jsxs(x.Fragment,{children:[x.jsx(cl,{ref:h,style:{height:"100%",width:"100%",boxSizing:"border-box"},defaultItemHeight:99,computeItemKey:I,totalCount:t.length,itemContent:l,initialTopMostItemIndex:y,increaseViewportBy:{top:100,bottom:100},endReached:p,components:T,scrollerRef:S}),x.jsx(ma,{scrollContainerRef:d,virtRef:h,prefix:o})]})}function xa(e){var r,o;const t=e;if(!t)return!1;const n=((o=(r=t.tagName)==null?void 0:r.toLowerCase)==null?void 0:o.call(r))??"";return!!(["a","button","input","textarea","select","label"].includes(n)||t.isContentEditable)}function va(){const e=V(v=>v.section),t=X(v=>v.theme),n=X(v=>v.fontFamily),r=X(v=>v.fontSizePx),o=X(v=>v.lineHeight),s=sn[t],{blocks:i,nsPrefix:u}=m.useMemo(()=>({sectionId:e.section_id,blocks:e.ast.blocks,nsPrefix:`sec-${e.section_id??"0"}/`}),[e]),a=gn(),l=m.useCallback(()=>{const{isSettingsOpen:v,setSettingsOpen:w,toggleOverlays:c}=a.getState();v?w(!1):c()},[a]),{onClick:d,onDoubleClick:S}=Ys({onSingle:l,onDouble:()=>{},delay:250,shouldIgnoreTarget:xa}),g=m.useMemo(()=>({flex:1,fontFamily:n,background:s.bg,color:s.fg,fontSize:r,lineHeight:o,overflow:"hidden",WebkitTextSizeAdjust:"none",MozTextSizeAdjust:"none",textSizeAdjust:"none"}),[n,s.bg,s.fg,r,o]),h=m.useMemo(()=>({margin:"0 auto",width:"100%",height:"100%"}),[]);return x.jsx("div",{onClick:d,onDoubleClick:S,style:g,children:x.jsx("div",{style:h,children:x.jsx(ba,{section:e,blocks:i,nsPrefix:u})})})}function Sa(e){return Ve({attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z",clipRule:"evenodd"},child:[]}]})(e)}function ya(e){return Ve({attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0A9.972 9.972 0 0119 10a9.972 9.972 0 01-2.929 7.071 1 1 0 01-1.414-1.414A7.971 7.971 0 0017 10c0-2.21-.894-4.208-2.343-5.657a1 1 0 010-1.414zm-2.829 2.828a1 1 0 011.415 0A5.983 5.983 0 0115 10a5.984 5.984 0 01-1.757 4.243 1 1 0 01-1.415-1.415A3.984 3.984 0 0013 10a3.983 3.983 0 00-1.172-2.828 1 1 0 010-1.415z",clipRule:"evenodd"},child:[]}]})(e)}function wa(e){return Ve({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(e)}function Ca(e){return Ve({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M9.64 7.64c.23-.5.36-1.05.36-1.64 0-2.21-1.79-4-4-4S2 3.79 2 6s1.79 4 4 4c.59 0 1.14-.13 1.64-.36L10 12l-2.36 2.36C7.14 14.13 6.59 14 6 14c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.59-.13-1.14-.36-1.64L12 14l7 7h3v-1L9.64 7.64zM6 8c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm0 12c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm6-7.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM19 3l-6 6 2 2 7-7V3h-3z"},child:[]}]})(e)}function Ia(e){return Ve({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z",opacity:".87"},child:[]},{tag:"path",attr:{d:"M17.51 3.87 15.73 2.1 5.84 12l9.9 9.9 1.77-1.77L9.38 12l8.13-8.13z"},child:[]}]})(e)}function Ta(e){return Ve({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"},child:[]},{tag:"path",attr:{d:"M12 18c-.328 0 -.652 -.017 -.97 -.05c-3.172 -.332 -5.85 -2.315 -8.03 -5.95c2.4 -4 5.4 -6 9 -6c3.465 0 6.374 1.853 8.727 5.558"},child:[]},{tag:"path",attr:{d:"M18 18m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M20.2 20.2l1.8 1.8"},child:[]}]})(e)}function ka(e){return Ve({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},child:[]},{tag:"path",attr:{d:"M4 8v-2a2 2 0 0 1 2 -2h2"},child:[]},{tag:"path",attr:{d:"M4 16v2a2 2 0 0 0 2 2h2"},child:[]},{tag:"path",attr:{d:"M16 4h2a2 2 0 0 1 2 2v2"},child:[]},{tag:"path",attr:{d:"M16 20h2a2 2 0 0 0 2 -2v-2"},child:[]}]})(e)}const Ra="_wrap_1hfub_4",_a="_visible_1hfub_25",Ma="_compact_1hfub_31",Ea="_row2_1hfub_34",ja="_controls_1hfub_44",Oa="_row1_1hfub_52",za="_groupExpand_1hfub_80",Aa="_groupPlayback_1hfub_81",Pa="_groupSpeed_1hfub_82",Ba="_groupFeatures_1hfub_83",La="_groupNav_1hfub_84",Ga="_btn_1hfub_116",Ha="_btnForbidden_1hfub_141",Fa="_btnActive_1hfub_147",Na="_label_1hfub_158",Da="_compactBtn_1hfub_168",Ie={wrap:Ra,visible:_a,compact:Ma,row2:Ea,controls:ja,row1:Oa,groupExpand:za,groupPlayback:Aa,groupSpeed:Pa,groupFeatures:Ba,groupNav:La,btn:Ga,btnForbidden:Ha,btnActive:Fa,label:Na,compactBtn:Da},Wa=m.memo(function(){const t=m.useRef(null),n=m.useContext(mt),r=(n==null?void 0:n.getState().isPlaybackMode)??!1,o=we(y=>y.status),s=we(y=>y.currentTimeMs),i=we(y=>y.currentClip),u=we(y=>y.playbackKind),a=X(y=>y.muteAudio),l=X(y=>y.audioSpeed),d=we(y=>y.getClipSrc),S=we(y=>y._onTime),g=we(y=>y._onEnded),h=we(y=>y._onError),v=V(y=>y.setCurrentGlobalRunIndex),w=V(y=>y.getSectionScrollApi),c=V(y=>y.snapToReadable),f=V(y=>y.edgeReadable),p=m.useRef(null),C=m.useRef(null),T=m.useRef(!1),I=m.useRef(null);m.useEffect(()=>{u==="real"&&(T.current=!0)},[u]);const j=m.useMemo(()=>{const y=d(i);if(!y)return null;try{return new URL(y,window.location.href).href}catch{return y}},[i,d]);m.useEffect(()=>{T.current=!0},[j]),m.useEffect(()=>{const y=t.current;if(!y)return;const k=()=>{if(y.paused||y.ended)return;const z=y.currentTime*1e3;T.current&&z===0||(z>0&&(T.current=!1),S(z))},R=()=>{var B,E;g();const z=f(1);if(typeof z=="number"&&z>=0){v(z,"audio");const P=w();(B=P==null?void 0:P.ensureVisibleGI)==null||B.call(P,z),(E=P==null?void 0:P.stepPage)==null||E.call(P,1)}},_=z=>{const B=z.currentTarget;console.warn("Audio error",{networkState:B.networkState,readyState:B.readyState}),h()};return y.addEventListener("timeupdate",k),y.addEventListener("ended",R),y.addEventListener("error",_),()=>{y.removeEventListener("timeupdate",k),y.removeEventListener("ended",R),y.removeEventListener("error",_)}},[S,g,h,f,v,w]),m.useEffect(()=>{if(r)return;const y=t.current;if(!y)return;if(!j){try{y.pause()}catch(z){console.log("pause error",z)}C.current=null;return}const k=y.currentSrc||y.src||null,R=!k||k!==j;if(R){try{y.pause()}catch(z){console.log("pause error",z)}y.src=j;try{y.load()}catch(z){console.log("load error",z)}C.current=j}y.muted=!!a,y.volume=1,y.playbackRate=typeof l=="number"?l:1;const _=async()=>{R&&await new Promise(z=>{let B=!1;const E=()=>{B||(B=!0,y.removeEventListener("loadedmetadata",E),y.removeEventListener("canplay",E),z())};y.addEventListener("loadedmetadata",E),y.addEventListener("canplay",E),y.readyState>=1&&E()});try{await y.play()}catch(z){console.warn("el.play() failed",z)}};if(o==="loading"||o==="playing")_();else try{y.pause()}catch(z){console.log("pause error",z)}},[j,a,o,l,r]),m.useEffect(()=>{if(r)return;const y=t.current;if(!y||u!=="real")return;const k=s/1e3;if(Number.isFinite(k)){if(y.readyState<1){p.current=s;const R=()=>{if(p.current!=null){const _=p.current/1e3;try{y.currentTime=_}catch(z){console.log("currentTime보정 오류",z)}p.current=null}y.removeEventListener("loadedmetadata",R),y.removeEventListener("canplay",R)};y.addEventListener("loadedmetadata",R),y.addEventListener("canplay",R);return}if(Math.abs(y.currentTime-k)>.2)try{y.currentTime=k}catch(R){console.log("currentTime보정오류",R)}}},[s,u,r]);const b=we(y=>y.getGIFromCT);return m.useEffect(()=>{var R,_;if(r||u!=="real"||o!=="playing"&&o!=="loading")return;const y=b(i,s);if(y<0)return;const k=c(y);k!==I.current&&(I.current=k,v(k,"audio"),k%5===0&&((_=(R=w())==null?void 0:R.ensureVisibleGI)==null||_.call(R,k)))},[o,i,s,u,b,c,v,w,r]),x.jsx("audio",{ref:t,preload:"auto",style:{display:"none"}})});function qa(){return x.jsx(Wa,{})}const Va="_scrubberWrap_uw0cd_2",$a="_labels_uw0cd_9",Ua="_index_uw0cd_15",Ka="_controls_uw0cd_19",Xa="_percent_uw0cd_25",Qa="_range_uw0cd_46",kt={scrubberWrap:Va,labels:$a,index:Ua,controls:Ka,percent:Xa,range:Qa};function Ya(){const e=X(I=>I.isDev),t=V(I=>I.currentGlobalRunIndex),n=V(I=>I.totalRuns),r=V(I=>I.setCurrentGlobalRunIndex),o=V(I=>I.getSectionScrollApi),s=V(I=>I.giToPercentTotal),i=V(I=>I.percentToGITotal),u=V(I=>I.snapToReadable),a=we(I=>I.scrollLock),l=we(I=>I.pause),d=we(I=>I.play),S=we(I=>I.syncToGI),[g,h]=m.useState(()=>s(t||0));m.useEffect(()=>{h(s(t||0))},[t,s]);const v=m.useRef(!1),w=m.useMemo(()=>Math.max(0,Math.min(t??0,Math.max(0,(n??1)-1)))+1,[t,n]),c=m.useCallback(()=>{a&&(l(),v.current=!0)},[a,l]),f=m.useCallback(I=>{h(Number(I.currentTarget.value))},[]),p=m.useCallback(async()=>{const I=i(g),j=u(I);l(),r(j,"scrubber-commit"),S(j);const b=o();b!=null&&b.ensureVisibleGI&&await b.ensureVisibleGI(j),v.current&&(v.current=!1,d())},[g,i,u,l,r,S,o,d]),C=m.useMemo(()=>({"--pct":`${g}%`}),[g]),T=m.useMemo(()=>Math.round(g),[g]);return x.jsxs("div",{className:kt.scrubberWrap,children:[e&&x.jsx("div",{className:kt.labels,children:x.jsxs("span",{className:kt.index,children:[w," / ",n||0]})}),x.jsxs("div",{className:kt.controls,children:[x.jsx("input",{type:"range",className:kt.range,min:0,max:100,step:.5,value:g,style:C,onMouseDown:c,onTouchStart:c,onChange:f,onMouseUp:()=>{p()},onTouchEnd:()=>{p()},onKeyUp:I=>I.key==="Enter"||I.key===" "?void p():void 0,"aria-label":"진행률"}),x.jsxs("span",{className:kt.percent,children:[T,"%"]})]})]})}const Za=m.memo(Ya),Ja=m.memo(function(){const t=m.useContext(mt),n=(t==null?void 0:t.getState().isPlaybackMode)??!1,r=we(k=>k.playbackKind),o=we(k=>k.status),s=we(k=>k.fake),i=X(k=>k.audioSpeed),u=we(k=>k.pause),a=V(k=>k.totalRuns),l=V(k=>k.currentGlobalRunIndex),d=V(k=>k.setCurrentGlobalRunIndex),S=V(k=>k.getSectionScrollApi),g=V(k=>k.nextReadableFrom),h=V(k=>k.edgeReadable),v=m.useRef(null),w=m.useRef(null),c=m.useRef(0),f=m.useRef(-1),p=m.useRef(!1),C=!n&&r==="fake"&&o==="playing",T=Math.max(1,(s==null?void 0:s.totalWords)??1),I=m.useMemo(()=>{const k=200*i;return T/k*6e4},[T,i]),j=m.useMemo(()=>!a||a<=1||I<=0?0:(a-1)/I,[a,I]);m.useEffect(()=>{if(!C)return;const k=Math.max(0,Math.min(l??0,Math.max(0,(a??1)-1)));c.current=k,f.current=k,w.current=null,p.current=!1},[C,l,a]);const b=m.useRef(-1);m.useEffect(()=>{if(!a){b.current=-1;return}const k=h(1);b.current=k??-1},[h,a]);const y=m.useCallback(k=>{(async()=>{var Q,re,oe;if(!C){v.current=null;return}if(!a||a<=1||j<=0){v.current=null;return}const R=w.current;w.current=k;const _=R==null?0:Math.max(0,k-R),z=a-1;c.current=Math.min(z,c.current+j*_);const B=Math.floor(c.current),E=S(),P=b.current>=0?b.current:z,F=g(B,1);if(F==null||c.current>=z){if(f.current<P){f.current=P,d(P,"audio"),await((Q=E==null?void 0:E.ensureVisibleGI)==null?void 0:Q.call(E,P)),v.current=requestAnimationFrame(y);return}if(!p.current){p.current=!0,v.current=requestAnimationFrame(y);return}p.current=!1,u(),(re=E==null?void 0:E.stepPage)==null||re.call(E,1),v.current=null;return}const O=F;O!==f.current&&(f.current=O,d(O,"audio"),O%5===0&&await((oe=E==null?void 0:E.ensureVisibleGI)==null?void 0:oe.call(E,O))),v.current=requestAnimationFrame(y)})().catch(console.error)},[C,a,j,g,d,S,u]);return m.useEffect(()=>(C?v.current==null&&(v.current=requestAnimationFrame(y)):(v.current&&(cancelAnimationFrame(v.current),v.current=null),w.current=null),()=>{v.current&&(cancelAnimationFrame(v.current),v.current=null)}),[C,y]),null}),ec=m.memo(function(){return x.jsx(Ja,{})}),tc="data:image/svg+xml,%3csvg%20width='111'%20height='111'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20overflow='hidden'%3e%3cg%20transform='translate(-435%2011)'%3e%3cpath%20d='M532.723%2046.8125C530.242%2046.8292%20527.8%2047.4292%20525.593%2048.5642%20523.298%2049.7713%20520.952%2050.8767%20518.608%2051.8815%20517.451%2031.9953%20500.391%2016.8128%20480.505%2017.9704%20462.359%2019.0268%20447.834%2033.4215%20446.615%2051.5578L438.476%2048.1353%20438.476%2049.9344C438.473%2054.7251%20441.432%2059.0185%20445.91%2060.721%20446.509%2060.9604%20447.138%2061.1708%20447.767%2061.3801%20448.053%2061.4761%20448.339%2061.5709%20448.622%2061.6692L447.745%2066.7254C447.463%2068.2415%20447.818%2069.8071%20448.728%2071.0521%20449.635%2072.2874%20450.984%2073.1242%20452.493%2073.3877L452.768%2073.4282C453.011%2073.488%20453.259%2073.5198%20453.509%2073.523%20456.31%2073.5182%20458.699%2071.4953%20459.166%2068.7338L459.781%2064.8673C468.886%2066.8727%20478.184%2067.875%20487.508%2067.8562%20493.267%2067.8674%20499.021%2067.5125%20504.736%2066.7937%20504.893%2066.7613%20505.041%2066.7405%20505.184%2066.7231L505.562%2068.8379C505.986%2071.6231%20508.396%2073.6706%20511.213%2073.6375%20511.583%2073.648%20511.953%2073.5977%20512.307%2073.4883%20515.422%2072.958%20517.518%2070.0024%20516.988%2066.8869%20516.984%2066.8688%20516.981%2066.8509%20516.978%2066.833L516.758%2065.6767C522.066%2065.3125%20527.42%2065.3125%20532.607%2065.3125L532.723%2065.3125C537.831%2065.6255%20542.226%2061.7378%20542.539%2056.6292%20542.852%2051.5205%20538.965%2047.1255%20533.856%2046.8125%20533.479%2046.7894%20533.1%2046.7894%20532.723%2046.8125ZM516.326%2052.7256C511.914%2054.5082%20507.352%2055.8913%20502.693%2056.858L492.697%2041.007%20501.916%2026.3469C510.579%2032.4029%20515.911%2042.1631%20516.326%2052.7256ZM500.254%2057.3217C497.133%2057.8531%20493.977%2058.1542%20490.811%2058.2224L487.449%2058.2224C480.061%2058.2766%20472.682%2057.6921%20465.394%2056.4753L474.504%2042.1644%20490.692%2042.1644ZM482.602%2020.2188C488.73%2020.2155%20494.742%2021.8953%20499.981%2025.075L490.693%2039.8507%20474.491%2039.8195%20465.194%2025.0415C470.449%2021.8782%20476.468%2020.2107%20482.602%2020.2188ZM463.254%2026.2995%20472.504%2041.0023%20462.938%2056.0267C458.169%2055.1133%20453.47%2053.8672%20448.875%2052.2977%20449.378%2041.8709%20454.689%2032.2672%20463.254%2026.2995ZM456.876%2068.3719C456.595%2070.0115%20455.173%2071.2097%20453.509%2071.2094%20453.431%2071.2042%20453.354%2071.191%20453.278%2071.1701%20453.133%2071.1343%20452.984%2071.1101%20452.835%2071.0972%20451.94%2070.9264%20451.142%2070.4243%20450.601%2069.6912%20450.063%2068.9533%20449.853%2068.0254%20450.023%2067.1278L450.844%2062.3872%20457.525%2064.2962ZM514.123%2069.8103C513.566%2070.5637%20512.74%2071.0728%20511.817%2071.2313L511.657%2071.2718C511.514%2071.32%20511.363%2071.3392%20511.213%2071.3285%20509.525%2071.3698%20508.075%2070.1378%20507.844%2068.4656L507.486%2066.4688%20514.501%2065.8548%20514.701%2067.2527C514.87%2068.1485%20514.661%2069.0742%20514.123%2069.8103ZM532.723%2063%20532.607%2063C526.955%2063%20521.113%2063%20515.284%2063.4625L515.276%2063.4625%20515.276%2063.4625%20505.9%2064.2904%20504.36%2064.5078C498.77%2065.2064%20493.141%2065.5509%20487.508%2065.5391%20477.952%2065.5601%20468.425%2064.4858%20459.114%2062.3375L450.263%2059.8168%20446.738%2058.5658C443.792%2057.4525%20441.62%2054.9086%20440.982%2051.8237%20454.33%2057.5309%20470.023%2060.5383%20486.577%2060.5383%20486.868%2060.5383%20487.161%2060.5383%20487.452%2060.5383L490.828%2060.5383C500.421%2060.2575%20509.874%2058.1665%20518.689%2054.3755L518.797%2054.3304C521.437%2053.2216%20524.086%2051.9728%20526.649%2050.6235%20528.526%2049.6491%20530.608%2049.1354%20532.723%2049.125%20536.554%2048.8199%20539.908%2051.6785%20540.213%2055.5099%20540.518%2059.3414%20537.659%2062.6949%20533.828%2063%20533.46%2063.0293%20533.091%2063.0293%20532.723%2063Z'/%3e%3cpath%20d='M534.442%2053.75C534.442%2055.0272%20533.407%2056.0625%20532.13%2056.0625%20530.852%2056.0625%20529.817%2055.0272%20529.817%2053.75%20529.817%2052.4728%20530.852%2051.4375%20532.13%2051.4375%20533.407%2051.4375%20534.442%2052.4728%20534.442%2053.75Z'/%3e%3c/g%3e%3c/svg%3e",nc="data:image/svg+xml,%3csvg%20width='159'%20height='159'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20overflow='hidden'%3e%3cg%20transform='translate(-392%20-84)'%3e%3cpath%20d='M496.776%20189.601C496.122%20189.934%20495.77%20190.663%20495.916%20191.383L499.911%20210.219C500.074%20210.985%20500.75%20211.532%20501.533%20211.531L501.929%20211.531C503.729%20211.515%20505.222%20212.919%20505.319%20214.716%20505.389%20216.544%20503.964%20218.083%20502.136%20218.154%20502.093%20218.155%20502.05%20218.156%20502.006%20218.156L497.503%20218.156C495.941%20218.15%20494.594%20217.058%20494.263%20215.531L490.363%20197.147C490.174%20196.252%20489.294%20195.68%20488.4%20195.87%20488.399%20195.87%20488.399%20195.87%20488.399%20195.87%20488.174%20195.918%20487.962%20196.014%20487.776%20196.15L481.184%20200.898C479.925%20201.758%20478.809%20202.45%20477.776%20203.015%20476.998%20203.429%20476.669%20204.372%20477.022%20205.18%20477.402%20206.011%20478.385%20206.378%20479.217%20205.998%20479.253%20205.981%20479.288%20205.964%20479.322%20205.945%20480.618%20205.229%20481.877%20204.447%20483.094%20203.604L487.657%20200.313%20491.031%20216.213C491.677%20219.273%20494.376%20221.464%20497.503%20221.469L501.882%20221.469C505.577%20221.473%20508.587%20218.502%20508.631%20214.807%20508.608%20211.503%20506.158%20208.719%20502.883%20208.277L499.416%20191.93C502.051%20190.581%20506.719%20188.344%20509.619%20188.344%20515.225%20188.346%20520.812%20187.662%20526.252%20186.307%20530.081%20185.36%20533.152%20182.51%20534.381%20178.762L534.535%20178.295C535.676%20175.09%20535.323%20171.542%20533.573%20168.624L525.126%20154.2C522.254%20149.369%20517.625%20145.835%20512.207%20144.337%20512.364%20138.624%20511.516%20132.927%20509.7%20127.508%20504.714%20113.244%20488.452%20105.977%20487.761%20105.669%20487.336%20105.48%20486.851%20105.48%20486.426%20105.669%20485.959%20105.876%20484.987%20106.308%20483.1%20111.962%20482.811%20112.832%20483.281%20113.77%20484.15%20114.059%20485.019%20114.348%20485.958%20113.878%20486.247%20113.009%20486.649%20111.744%20487.129%20110.505%20487.685%20109.299%20491.474%20111.245%20502.818%20117.831%20506.566%20128.543%20508.418%20133.972%20509.183%20139.713%20508.815%20145.437%20508.734%20146.277%20509.297%20147.043%20510.122%20147.217%20515.212%20148.269%20519.626%20151.41%20522.287%20155.875L530.744%20170.299C532.007%20172.379%20532.256%20174.921%20531.42%20177.207L531.254%20177.727C530.378%20180.388%20528.194%20182.41%20525.474%20183.079%20520.288%20184.375%20514.964%20185.031%20509.619%20185.031%20505.93%20185.031%20501.061%20187.35%20496.776%20189.601Z'/%3e%3cpath%20d='M422.439%20192.966C421.946%20190.791%20421.681%20188.571%20421.649%20186.341%20421.7%20185.427%20421.001%20184.643%20420.086%20184.592%20419.171%20184.54%20418.388%20185.239%20418.336%20186.154%20418.324%20187.879%20418.47%20189.602%20418.772%20191.3%20412.577%20189.633%20408.907%20183.26%20410.574%20177.065%20411.942%20171.981%20416.559%20168.453%20421.824%20168.469%20422.661%20168.473%20423.491%20168.611%20424.284%20168.88%20425.056%20169.133%20425.898%20168.787%20426.271%20168.065%20435.26%20150.783%20455.639%20142.806%20473.971%20149.392%20474.837%20150.636%20475.5%20151.557%20475.559%20151.638%20476.094%20152.38%20477.129%20152.549%20477.872%20152.014%20478.614%20151.479%20478.782%20150.444%20478.248%20149.702%20478.216%20149.657%20475.101%20145.338%20473.444%20142.62%20467.845%20132.798%20470.283%20120.115%20471.358%20115.817%20475.617%20117.014%20487.816%20121.194%20493.442%20131.039%20496.082%20135.531%20497.921%20140.449%20498.876%20145.571%20499.017%20146.361%20499.705%20146.936%20500.508%20146.936L503.929%20146.936C504.816%20146.948%20505.561%20146.274%20505.639%20145.391%20505.7%20144.478%20505.01%20143.688%20504.097%20143.627%20504.059%20143.624%20504.021%20143.623%20503.982%20143.623L501.871%20143.623C500.778%20138.613%20498.902%20133.806%20496.312%20129.38%20488.742%20116.13%20471.271%20112.337%20470.533%20112.183%20469.704%20112.01%20468.879%20112.489%20468.618%20113.294%20468.385%20114.011%20463.013%20131.036%20470.568%20144.256%20470.579%20144.276%20470.745%20144.576%20470.978%20144.973%20470.99%20144.991%20470.978%20145.003%20470.96%20144.998%20452.498%20140.481%20433.287%20148.811%20423.966%20165.375%20423.261%20165.231%20422.543%20165.158%20421.824%20165.156%20413.582%20165.183%20406.923%20171.886%20406.95%20180.128%20406.974%20187.414%20412.256%20193.618%20419.446%20194.803L419.446%20194.803C419.532%20195.194%20419.611%20195.585%20419.706%20195.972L419.8%20196.329C422.428%20206.56%20428.796%20215.436%20437.646%20221.204%20437.917%20221.379%20438.232%20221.473%20438.554%20221.474L473.068%20221.474C476.748%20221.495%20479.756%20218.542%20479.801%20214.862%20479.847%20211.242%20476.95%20208.27%20473.329%20208.224%20473.278%20208.223%20473.227%20208.223%20473.176%20208.224L465.158%20208.224C474.765%20201.216%20476.873%20187.747%20469.866%20178.14%20465.812%20172.583%20459.348%20169.297%20452.47%20169.297%20450.573%20169.261%20448.682%20169.507%20446.858%20170.029%20445.981%20170.293%20445.484%20171.219%20445.749%20172.096%20446.013%20172.973%20446.938%20173.47%20447.816%20173.206%20449.328%20172.775%20450.897%20172.574%20452.47%20172.609%20462.532%20172.632%20470.67%20180.807%20470.648%20190.869%20470.63%20198.914%20465.337%20205.995%20457.626%20208.29%20456.784%20208.543%20456.286%20209.408%20456.491%20210.263%20456.686%20211.016%20457.369%20211.54%20458.147%20211.533L473.107%20211.533C474.951%20211.521%20476.458%20213.001%20476.48%20214.845%20476.52%20216.635%20475.102%20218.118%20473.312%20218.158%20473.264%20218.159%20473.216%20218.159%20473.168%20218.158L439.054%20218.158C431.004%20212.776%20425.251%20204.584%20422.922%20195.184%20422.853%20194.889%20422.795%20194.619%20422.733%20194.339Z'/%3e%3cpath%20d='M519.521%20163.831C519.708%20162.011%20518.383%20160.385%20516.563%20160.199%20514.743%20160.012%20513.117%20161.337%20512.931%20163.157%20512.744%20164.977%20514.069%20166.603%20515.889%20166.789%20516.113%20166.812%20516.339%20166.812%20516.563%20166.789%20518.126%20166.629%20519.361%20165.394%20519.521%20163.831Z'/%3e%3c/g%3e%3c/svg%3e",rc="_WPMSpeedButtonsWrap_r3byt_1",oc="_btnWrap_r3byt_7",sc="_label_r3byt_14",ic="_iconBtn_r3byt_22",zt={WPMSpeedButtonsWrap:rc,btnWrap:oc,label:sc,iconBtn:ic},uo=350,lc=40,ac=.85,cc=m.memo(function(){const t=X(g=>g.audioSpeed),n=X(g=>g.incAudioSpeed),r=X(g=>g.decAudioSpeed),o=m.useRef(null),s=m.useRef(uo),i=m.useRef(null),u=m.useCallback(g=>{const h=t;if(g==="inc"){if(h>=2)return!1;n()}else{if(h<=.3)return!1;r()}return!0},[t,n,r]),a=m.useCallback(()=>{i.current=null,o.current&&(clearTimeout(o.current),o.current=null)},[]),l=m.useCallback(()=>{i.current&&(s.current=Math.max(lc,Math.floor(s.current*ac)),o.current=window.setTimeout(()=>{u(i.current)?l():a()},s.current))},[u,a]),d=m.useCallback(g=>{if(i.current)return;i.current=g,s.current=uo,u(g)&&l();const v=()=>a();window.addEventListener("mouseup",v,{once:!0}),window.addEventListener("touchend",v,{once:!0})},[l,u,a]);m.useEffect(()=>a,[a]);const S=`${(t*100).toFixed(0)}%`;return x.jsx("div",{onMouseLeave:a,className:zt.WPMSpeedButtonsWrap,children:x.jsxs("div",{className:zt.btnWrap,children:[x.jsx("button",{className:zt.iconBtn,type:"button",title:"속도 느리게",onMouseDown:()=>d("dec"),onTouchStart:g=>{g.preventDefault(),d("dec")},onMouseUp:a,children:x.jsx("img",{src:tc,alt:"느리게"})}),x.jsx("div",{className:zt.label,style:{minWidth:"44px",textAlign:"center"},children:x.jsx("div",{children:S})}),x.jsx("button",{className:zt.iconBtn,type:"button",title:"속도 빠르게",onMouseDown:()=>d("inc"),onTouchStart:g=>{g.preventDefault(),d("inc")},onMouseUp:a,children:x.jsx("img",{src:nc,alt:"빠르게"})})]})})}),uc="_StepBtn_1qqzt_1",dc={StepBtn:uc};function fc(e){return Ve({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M208,48V208a8,8,0,0,1-13.66,5.66L128,147.31V208a8,8,0,0,1-13.66,5.66l-80-80a8,8,0,0,1,0-11.32l80-80A8,8,0,0,1,128,48v60.69l66.34-66.35A8,8,0,0,1,208,48Z"},child:[]}]})(e)}function pc(e){return Ve({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M221.66,133.66l-80,80A8,8,0,0,1,128,208V147.31L61.66,213.66A8,8,0,0,1,48,208V48a8,8,0,0,1,13.66-5.66L128,108.69V48a8,8,0,0,1,13.66-5.66l80,80A8,8,0,0,1,221.66,133.66Z"},child:[]}]})(e)}function fo({direction:e}){const t=V(f=>f.currentGlobalRunIndex),n=V(f=>f.totalRuns),r=V(f=>f.hasReadableInDir),o=V(f=>f.computeStepTarget),s=V(f=>f.edgeReadable),i=V(f=>f.snapToReadable),u=V(f=>f.setCurrentGlobalRunIndex),a=we(f=>f.syncToGI),l=V(f=>f.getSectionScrollApi),d=lt(),S=V(f=>f.pageIndex),g=V(f=>f.totalPages),h=g>1&&S>=g-1,v=m.useCallback(async f=>{var y,k,R,_;const{progress:p}=d.getState(),C=p.pageIndex,T=p.totalPages,I=T>1&&C>=T-1,j=Math.max(t,Math.min(0,Math.max(0,(n??1)-1)));if(f===-1&&I){p.setPageIndex(C-1);return}if(f===1){const z=i(j),B=s(1);if(B!=null&&z>=B){(k=(y=l())==null?void 0:y.stepPage)==null||k.call(y,1);return}}const b=o(j,f);u(b,"scrubber-step"),a(b),await((_=(R=l())==null?void 0:R.ensureVisibleGI)==null?void 0:_.call(R,b))},[t,n,o,i,s,u,a,l,d]),w=m.useMemo(()=>{const f=Math.max(t,Math.min(0,Math.max(0,(n??1)-1))),p=i(f),C=s(1),T=s(-1),I=g>0,j=C!=null&&p>=C,b=T!=null&&p<=T,y=h||!I&&j||!n||!r(f,1),k=b||!n||!r(f,-1);return e==="left"?k:y},[e,n,g,t,r,h,i,s]),c=m.useCallback(()=>{v(e==="left"?-1:1)},[e,v]);return x.jsx("button",{className:dc.StepBtn,type:"button",onClick:c,disabled:w,title:e==="left"?"이전":"다음",children:e==="left"?x.jsx(fc,{}):x.jsx(pc,{})})}const gc="_GCPlayBtn_16fre_1",hc="_playing_16fre_39",po={GCPlayBtn:gc,playing:hc},mc=({size:e=60,color:t="#333",bgColor:n="#fff",isPlaying:r,disabled:o=!1,onClick:s,tooltip:i="재생",title:u=""})=>x.jsx("button",{className:`${po.GCPlayBtn} ${r?po.playing:""}`,onClick:s,disabled:o,"data-tip":i,title:u,style:{"--btn-size":`${e}px`,"--icon-color":t,"--btn-bg":n}});function bc(e){return Ve({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 294.1L383 167c9.4-9.4 24.6-9.4 33.9 0s9.3 24.6 0 34L273 345c-9.1 9.1-23.7 9.3-33.1.7L95 201.1c-4.7-4.7-7-10.9-7-17s2.3-12.3 7-17c9.4-9.4 24.6-9.4 33.9 0l127.1 127z"},child:[]}]})(e)}function xc(e){return Ve({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 217.9L383 345c9.4 9.4 24.6 9.4 33.9 0 9.4-9.4 9.3-24.6 0-34L273 167c-9.1-9.1-23.7-9.3-33.1-.7L95 310.9c-4.7 4.7-7 10.9-7 17s2.3 12.3 7 17c9.4 9.4 24.6 9.4 33.9 0l127.1-127z"},child:[]}]})(e)}function vc(){var M;const e=X(O=>O.showOverlays),t=V(O=>O.section),n=!!t.ast.isAddedSplit,r=!!((M=t.audios)!=null&&M.length),o=V(O=>O.pageIndex),s=V(O=>O.totalPages),i=s>1&&o>=s-1,u=V(O=>O.currentGlobalRunIndex),a=V(O=>O.snapToReadable),l=V(O=>O.edgeReadable),d=(()=>{const O=l(1);return O==null?!1:a(u??0)>=O})(),S=i||d,g=V(O=>O.canTracking),h=V(O=>O.canToggleShowGaze),v=V(O=>O.showGaze),w=V(O=>O.onToggleShowGaze),c=X(O=>O.muteAudio),f=X(O=>O.showPointer),p=X(O=>O.showSplit),C=X(O=>O.toggleMuteAudio),T=X(O=>O.toggleShowPointer),I=X(O=>O.toggleShowSplit),j=X(O=>O.overlayCompactMode),b=X(O=>O.toggleOverlayCompactMode),y=cn(),k=lt();m.useEffect(()=>{const O=y.getState(),{syncToGI:Q,useFake:re,useReal:oe}=O,ie=O.playbackKind,ue=k.getState().progress.currentGlobalRunIndex??0;if(!r){ie!=="fake"&&re();return}c?ie!=="fake"&&re():ie!=="real"&&(Q(ue),oe())},[r,c,k,y]);const R=we(O=>O.play),_=we(O=>O.pause),z=we(O=>O.status),B=cn(),E=lt(),P=m.useCallback(O=>{var ue,xe,N;if(O.stopPropagation(),z==="playing"||z==="loading"){_();return}const{progress:Q}=E.getState(),re=Q.currentGlobalRunIndex??0,oe=Q.snapToReadable(re),ie=Q.edgeReadable(1);if(ie!=null&&oe>=ie){(N=(xe=(ue=Q.getSectionScrollApi)==null?void 0:ue.call(Q))==null?void 0:xe.stepPage)==null||N.call(xe,1);return}R()},[z,R,_,E]),F=m.useCallback(async O=>{var H,te;if(O.stopPropagation(),z==="playing"||z==="loading"){_();return}const{progress:Q}=E.getState(),{currentGlobalRunIndex:re,snapToReadable:oe,edgeReadable:ie,setCurrentGlobalRunIndex:ue,getSectionScrollApi:xe}=Q,N=B.getState(),D=N.currentClip,q=xe==null?void 0:xe(),A=typeof re=="number"?re:0,G=typeof oe=="function"?oe(A):A,K=typeof ie=="function"?ie(1):null;if(K!=null&&G>=K){ue==null||ue(K,"audio"),(H=q==null?void 0:q.stepPage)==null||H.call(q,1);return}ue==null||ue(G,"audio"),await((te=q==null?void 0:q.ensureVisibleGI)==null?void 0:te.call(q,G)),N.syncToGI(G),R(D)},[z,_,R,B,E]);return x.jsxs("div",{className:`${Ie.wrap} ${e?Ie.visible:""} ${j?Ie.compact:""}`,onClick:O=>{O.stopPropagation()},onTouchStart:O=>{O.stopPropagation()},children:[!j&&x.jsx(Za,{}),x.jsx("div",{style:j?{display:"none"}:void 0,children:r&&!c?x.jsx(qa,{}):x.jsx(ec,{})}),x.jsxs("div",{className:Ie.controls,children:[x.jsxs("div",{className:Ie.row1,children:[x.jsx("div",{className:Ie.groupExpand,children:x.jsx("button",{type:"button",onClick:O=>{O.stopPropagation(),b()},className:Ie.compactBtn,title:j?"오버레이 확대":"오버레이 축소",children:j?x.jsx(xc,{size:24}):x.jsx(bc,{size:24})})}),x.jsxs("div",{className:Ie.groupPlayback,children:[x.jsx(fo,{direction:"left"}),x.jsx(mc,{size:34,isPlaying:z==="playing",disabled:S,onClick:c?F:P,title:z==="playing"?"일시정지":"재생"}),x.jsx(fo,{direction:"right"})]}),x.jsx("div",{className:Ie.groupSpeed,children:x.jsx(cc,{})})]}),x.jsxs("div",{className:Ie.row2,children:[x.jsxs("div",{className:Ie.groupFeatures,children:[r&&x.jsxs("button",{type:"button",onClick:O=>{O.stopPropagation(),C()},className:`${Ie.btn} ${c?"":Ie.btnActive}`,title:"오디오북 음소거 전환",children:[c?x.jsx(Sa,{size:18}):x.jsx(ya,{size:18}),x.jsx("span",{className:Ie.label,children:"오디오북"})]}),x.jsxs("button",{type:"button",onClick:O=>{O.stopPropagation(),T()},className:`${Ie.btn} ${f?Ie.btnActive:""}`,title:"포인터 표시",children:[x.jsx(wa,{size:18}),x.jsx("span",{className:Ie.label,children:"포인터"})]}),n&&x.jsxs("button",{type:"button",onClick:O=>{O.stopPropagation(),I()},disabled:!n,className:`${Ie.btn} ${p?Ie.btnActive:""} ${n?"":Ie.btnForbidden}`,title:"끊어읽기 표시",children:[x.jsx(Ca,{size:18}),x.jsx("span",{className:Ie.label,children:"끊어읽기"})]}),x.jsxs("button",{type:"button",onClick:O=>{O.stopPropagation(),w==null||w()},disabled:!g||!h,className:`${Ie.btn} ${g&&v?Ie.btnActive:""} ${g?"":Ie.btnForbidden}`,title:"시선 표시",children:[x.jsx(Ta,{size:18}),x.jsx("span",{className:Ie.label,children:"시선"})]})]}),x.jsxs("div",{className:Ie.groupNav,children:[x.jsx(pa,{}),x.jsx(pn,{})]})]})]})]})}const Sc=m.memo(vc);function yc(e){return Ve({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32",d:"M262.29 192.31a64 64 0 1 0 57.4 57.4 64.13 64.13 0 0 0-57.4-57.4zM416.39 256a154.34 154.34 0 0 1-1.53 20.79l45.21 35.46a10.81 10.81 0 0 1 2.45 13.75l-42.77 74a10.81 10.81 0 0 1-13.14 4.59l-44.9-18.08a16.11 16.11 0 0 0-15.17 1.75A164.48 164.48 0 0 1 325 400.8a15.94 15.94 0 0 0-8.82 12.14l-6.73 47.89a11.08 11.08 0 0 1-10.68 9.17h-85.54a11.11 11.11 0 0 1-10.69-8.87l-6.72-47.82a16.07 16.07 0 0 0-9-12.22 155.3 155.3 0 0 1-21.46-12.57 16 16 0 0 0-15.11-1.71l-44.89 18.07a10.81 10.81 0 0 1-13.14-4.58l-42.77-74a10.8 10.8 0 0 1 2.45-13.75l38.21-30a16.05 16.05 0 0 0 6-14.08c-.36-4.17-.58-8.33-.58-12.5s.21-8.27.58-12.35a16 16 0 0 0-6.07-13.94l-38.19-30A10.81 10.81 0 0 1 49.48 186l42.77-74a10.81 10.81 0 0 1 13.14-4.59l44.9 18.08a16.11 16.11 0 0 0 15.17-1.75A164.48 164.48 0 0 1 187 111.2a15.94 15.94 0 0 0 8.82-12.14l6.73-47.89A11.08 11.08 0 0 1 213.23 42h85.54a11.11 11.11 0 0 1 10.69 8.87l6.72 47.82a16.07 16.07 0 0 0 9 12.22 155.3 155.3 0 0 1 21.46 12.57 16 16 0 0 0 15.11 1.71l44.89-18.07a10.81 10.81 0 0 1 13.14 4.58l42.77 74a10.8 10.8 0 0 1-2.45 13.75l-38.21 30a16.05 16.05 0 0 0-6.05 14.08c.33 4.14.55 8.3.55 12.47z"},child:[]}]})(e)}const wc="_host_gafql_3",Cc="_topbar_gafql_11",Ic="_visible_gafql_32",Tc="_backBtn_gafql_37",kc="_title_gafql_58",Rc="_calibrationBtn_gafql_67",_c="_disabled_gafql_87",Mc="_settingsBtn_gafql_95",pt={host:wc,topbar:Cc,visible:Ic,backBtn:Tc,title:kc,calibrationBtn:Rc,disabled:_c,settingsBtn:Mc};function Ec(){const e=X(h=>h.showOverlays),t=X(h=>h.overlayCompactMode),n=V(h=>h.onViewerClose),o=V(h=>h.section).ast.title,s=V(h=>h.canTracking),i=V(h=>h.handleAskCalibration),u=we(h=>h.status==="playing"),a=s&&!u,l=X(h=>h.setSettingsOpen),d=X(h=>h.setShowOverlays),S=m.useCallback(()=>{n==null||n()},[n]),g=m.useCallback(()=>{l(!0),d(!1)},[l,d]);return x.jsx("div",{className:pt.host,children:x.jsxs("div",{className:`${pt.topbar} ${e&&!t?pt.visible:""}`,children:[x.jsx("button",{type:"button",className:pt.backBtn,onClick:S,"aria-label":"뒤로가기",children:x.jsx(Ia,{size:28})}),x.jsx("div",{className:pt.title,children:x.jsx("span",{className:"truncate",children:o||"섹션 없음"})}),x.jsx("button",{type:"button",className:`${pt.calibrationBtn} ${a?"":pt.disabled}`,onClick:i,disabled:!a,"aria-label":"시선보정",title:"시선보정",children:x.jsx(ka,{size:24})}),x.jsx("button",{type:"button",className:pt.settingsBtn,onClick:g,"aria-label":"뷰어 설정",children:x.jsx(yc,{size:28})})]})})}const jc=m.memo(Ec),Oc="_wrap_62su0_7",zc="_wrapHidden_62su0_29",Ac="_wrapVisible_62su0_35",Pc="_scrollArea_62su0_71",Bc="_row_62su0_81",Lc="_label_62su0_89",Gc="_btn_62su0_95",Hc="_btnActive_62su0_106",Fc="_btnSmall_62su0_110",Nc="_pill_62su0_122",Dc="_themeCircle_62su0_133",Wc="_themeCircleActive_62su0_146",qc="_stepRow_62su0_151",Vc="_stepLabel_62su0_159",$c="_levelBox_62su0_172",Uc="_inlineFlex_62su0_177",Ee={wrap:Oc,wrapHidden:zc,wrapVisible:Ac,scrollArea:Pc,row:Bc,label:Lc,btn:Gc,btnActive:Hc,btnSmall:Fc,pill:Nc,themeCircle:Dc,themeCircleActive:Wc,stepRow:qc,stepLabel:Vc,levelBox:$c,inlineFlex:Uc};function Kc({visible:e}){const t=X(b=>b.mode),n=X(b=>b.setMode),r=X(b=>b.theme),o=X(b=>b.setTheme),s=X(b=>b.fontFamily),i=X(b=>b.setFontFamily),u=X(b=>b.resetToDefaults),a=X(b=>b.getFontLevel()),l=X(b=>b.getLineLevel()),d=X(b=>b.getMarginLevel()),S=X(b=>b.setFontLevel),g=X(b=>b.setLineLevel),h=X(b=>b.setMarginLevel),v=X(b=>b.pointerStyle),w=X(b=>b.setPointerStyle),c=X(b=>b.pointerColor),f=X(b=>b.setPointerColor),p=X(b=>b.breakMarks),C=X(b=>b.toggleBreakMark),T=X(b=>b.getBreakGapLevel()),I=X(b=>b.setBreakGapLevel),j=`${Ee.wrap} ${e?Ee.wrapVisible:Ee.wrapHidden}`;return x.jsxs("div",{className:j,role:"dialog","aria-modal":"true","aria-label":"뷰어 설정",children:[x.jsxs("div",{className:Ee.scrollArea,children:[x.jsx(At,{label:"열람방식",children:x.jsxs("div",{className:Ee.inlineFlex,children:[x.jsx(Rt,{active:t==="page",onClick:()=>n("page"),children:"페이지"}),x.jsx(Rt,{active:t==="scroll",onClick:()=>n("scroll"),children:"스크롤"})]})}),x.jsx(At,{label:"테마",children:x.jsx("div",{className:Ee.inlineFlex,children:Object.keys(sn).map(b=>{const y=b,k=sn[y];return x.jsx("button",{type:"button",onClick:()=>o(y),className:`${Ee.themeCircle} ${r===b?Ee.themeCircleActive:""}`,style:{background:k.bg,color:k.fg,fontFamily:s},title:String(b),"aria-label":`테마: ${String(b)}`,children:"A"},`${b}_tc_button`)})})}),x.jsx(At,{label:"글꼴",children:x.jsx("div",{className:Ee.inlineFlex,children:Ho.map(b=>x.jsx(Rt,{active:s===b.value,onClick:()=>i(b.value),title:b.value,children:b.label},b.label))})}),x.jsx(tn,{label:"글자 크기",level:a,min:1,max:12,onDec:()=>S(Math.max(1,a-1)),onInc:()=>S(Math.min(12,a+1))}),x.jsx(tn,{label:"줄 간격",level:l,min:1,max:7,onDec:()=>g(Math.max(1,l-1)),onInc:()=>g(Math.min(7,l+1))}),x.jsx(tn,{label:"여백",level:d,min:1,max:5,onDec:()=>h(Math.max(1,d-1)),onInc:()=>h(Math.min(5,d+1))}),x.jsx(At,{label:"포인터",children:x.jsxs("div",{className:Ee.inlineFlex,children:[x.jsx(Rt,{active:v==="highlight",onClick:()=>w("highlight"),children:"형광펜"}),x.jsx(Rt,{active:v==="underline",onClick:()=>w("underline"),children:"밑줄"}),x.jsx("input",{type:"color",value:c,onChange:b=>f(b.target.value),"aria-label":"포인터 색상",style:{width:36,height:28,padding:0,border:"none",background:"transparent"}})]})}),x.jsx(At,{label:"끊기표시",children:x.jsx("div",{className:Ee.inlineFlex,children:x.jsx(Rt,{active:p.slash,onClick:()=>C("slash"),children:"슬래쉬"})})}),x.jsx(tn,{label:"끊기간격",level:T,min:1,max:5,onDec:()=>I(Math.max(1,T-1)),onInc:()=>I(Math.min(5,T+1))})]}),x.jsx("div",{className:Ee.inlineFlex,style:{justifyContent:"center"},children:x.jsx("button",{type:"button",onClick:u,className:Ee.pill,children:"보기 설정 초기화"})})]})}function At({label:e,children:t}){return x.jsxs("div",{className:Ee.row,children:[x.jsx("label",{className:Ee.label,children:e}),t]})}function Rt({active:e,onClick:t,title:n,children:r}){return x.jsx("button",{type:"button",onClick:t,title:n,className:`${Ee.btn} ${e?Ee.btnActive:""}`,children:r})}function tn({label:e,level:t,min:n,max:r,onDec:o,onInc:s}){const i=t<=n,u=t>=r;return x.jsxs("div",{className:Ee.stepRow,children:[x.jsx("label",{className:Ee.stepLabel,children:e}),x.jsxs("div",{className:Ee.inlineFlex,children:[x.jsx("button",{type:"button",onClick:o,disabled:i,className:Ee.btnSmall,"aria-label":"감소",children:"−"}),x.jsx("div",{className:Ee.levelBox,children:t}),x.jsx("button",{type:"button",onClick:s,disabled:u,className:Ee.btnSmall,"aria-label":"증가",children:"+"})]})]})}const Xc=m.memo(function(){const t=X(i=>i.showOverlays),n=X(i=>i.isSettingsOpen),r=V(i=>i.rangeStartGI),o=V(i=>i.rangeEndGI);return r!=null&&o!=null?null:x.jsxs("div",{"aria-hidden":!0,style:{pointerEvents:"none",position:"absolute",inset:0,containerType:"size",containerName:"viewer"},children:[x.jsx(jc,{}),x.jsx(Sc,{}),x.jsx("div",{style:{pointerEvents:"auto"},children:x.jsx(Kc,{visible:!t&&n})})]})}),Qc=e=>(t,n,r)=>{const o=r.subscribe;return r.subscribe=((i,u,a)=>{let l=i;if(u){const d=(a==null?void 0:a.equalityFn)||Object.is;let S=i(r.getState());l=g=>{const h=i(g);if(!d(S,h)){const v=S;u(S=h,v)}},a!=null&&a.fireImmediately&&u(S,S)}return o(l)}),e(t,n,r)},Yc=Qc;function Zc(e){return e?e.kind==="saved"?e.cdnUrl:e.blobUrl:null}function Jc(e){var o,s,i;if(!e||!/\S/.test(e))return 0;const t=((o=e.match(/[A-Za-z0-9]+(?:['’-][A-Za-z0-9]+)*/g))==null?void 0:o.length)??0,n=((s=e.match(/[\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A]+/g))==null?void 0:s.length)??0,r=((i=e.match(/[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\u3040-\u30FF\u31FF\uAC00-\uD7AF\u1100-\u11FF\u3130-\u318F]/g))==null?void 0:i.length)??0;return t+n+Math.floor(r/2)}function eu(e){let t=0;for(const n of e.ast.blocks??[])if(n.type==="paragraph")for(const r of n.runs??[])t+=Jc((r==null?void 0:r.text)??"");return t}function tu(e){const t=e==null?void 0:e.recorderStore;let n=e==null?void 0:e.map,r=e==null?void 0:e.initialIndex;const o=h=>{if(!n)return null;const{g2ct:v}=n;if(!v)return null;const w=v[h];if(w)return{clip:w.clip,t:w.t};for(let c=1;c<=100&&h-c>=0;c++){const f=v[h-c];if(f)return{clip:f.clip,t:f.t}}for(let c=1;c<=100;c++){const f=v[h+c];if(f)return{clip:f.clip,t:f.t}}return null},s=(e==null?void 0:e.clips)??[];let i=0,u=0;const a=Math.max(1,eu(e.section)||150);if(typeof(e==null?void 0:e.initialIndex)=="number"&&n){const h=o(e.initialIndex);h&&(i=h.clip,u=h.t,r=void 0)}const l=s.length>0,d=l?"paused":"idle",S=l?"real":"fake",g=l?null:{totalWords:a};return Vt(Yc((h,v)=>({clips:s,currentClip:Math.max(0,Math.min(i,Math.max(0,s.length-1))),currentTimeMs:Math.max(0,u),status:d,scrollLock:!1,playbackKind:S,fake:g,useFake:()=>h(w=>({playbackKind:"fake",fake:{totalWords:a},scrollLock:w.status==="playing"})),useReal:()=>h(w=>({playbackKind:"real",fake:{totalWords:a},scrollLock:w.status==="playing"})),injectMap:w=>{if(n=w,typeof r=="number"){const c=o(r);c&&h(f=>({currentClip:Math.max(0,Math.min(c.clip,Math.max(0,f.clips.length-1))),currentTimeMs:Math.max(0,c.t)})),r=void 0}},setClipAndMs:(w,c)=>h(f=>{const p=Math.max(0,f.clips.length-1);return{currentClip:Math.max(0,Math.min(w,p)),currentTimeMs:Math.max(0,c),status:f.status,scrollLock:f.scrollLock}}),setClips:w=>h(c=>{const f=Array.isArray(w)?w:[],p=f.length>0;return{clips:f,currentClip:0,currentTimeMs:0,status:p?"paused":"idle",playbackKind:p?"real":"fake",fake:p?null:c.fake??{totalWords:a},scrollLock:!1}}),clear:()=>h(w=>({clips:[],currentClip:0,currentTimeMs:0,status:"idle",playbackKind:"fake",fake:w.fake??{totalWords:a},scrollLock:!1})),play:(w,c)=>{t==null||t.getState().emit({type:"audio_control",payload:{action:"play"}}),h(f=>{if(f.playbackKind==="fake")return{status:"playing",scrollLock:!0};const p=typeof w=="number"?w:f.currentClip,C=typeof c=="number"?c:f.currentTimeMs;return{status:"loading",currentClip:Math.max(0,Math.min(p,Math.max(0,f.clips.length-1))),currentTimeMs:C,scrollLock:!0}})},pause:()=>{t==null||t.getState().emit({type:"audio_control",payload:{action:"pause"}}),h({status:"paused",scrollLock:!1})},seek:w=>h(c=>({currentTimeMs:Math.max(0,w),status:c.status})),stop:()=>h({status:"idle",currentTimeMs:0,scrollLock:!1}),nextClip:()=>h(w=>{if(w.playbackKind==="fake")return w;const c=Math.max(0,w.clips.length-1);return{currentClip:Math.min(w.currentClip+1,c),currentTimeMs:0,status:"loading",scrollLock:!0}}),prevClip:()=>h(w=>w.playbackKind==="fake"?w:{currentClip:Math.max(0,w.currentClip-1),currentTimeMs:0,status:"loading",scrollLock:!0}),setClipIndex:w=>h(c=>c.playbackKind==="fake"||w<0||w>=c.clips.length?c:{currentClip:w,currentTimeMs:0}),getClipSrc:w=>{const c=v();if(!c.clips.length)return null;const f=typeof w=="number"?w:c.currentClip;return Zc(c.clips[f])},getGIFromCT:(w,c)=>{if(!n)return-1;const f=n.byClip[w];if(!f||f.length===0)return-1;let p=0,C=f.length-1,T=0;for(;p<=C;){const I=p+C>>1;f[I].t<=c?(T=I,p=I+1):C=I-1}return f[Math.max(0,Math.min(T,f.length-1))].g},getCTFromGI:w=>{if(!n)return null;const{g2ct:c}=n;if(!c)return null;let f=c[w];if(!f){let p=w-1;const C=Math.max(0,w-100);for(;p>=C;){if(c[p]){f=c[p];break}p--}if(!f){let T=w+1;const I=w+100;for(;c[T]==null&&T<=I;)T++;c[T]&&(f=c[T])}}return f?{clip:f.clip,timeMs:f.t}:null},getMetaByGI:w=>{const c=v().getCTFromGI(w);return c?{clipIndex:c.clip,timeMs:c.timeMs}:null},syncToGI:w=>{const c=v().getMetaByGI(w);c&&v().setClipAndMs(c.clipIndex,c.timeMs)},_onTime:w=>h({currentTimeMs:w,status:"playing",scrollLock:!0}),_onEnded:()=>h(w=>{if(w.playbackKind==="fake")return{status:"ended",scrollLock:!1};const c=Math.max(0,w.clips.length-1);return w.currentClip>=c?{status:"ended",scrollLock:!1}:{currentClip:Math.min(w.currentClip+1,c),currentTimeMs:0,status:"loading",scrollLock:!0}}),_onError:()=>h({status:"error",scrollLock:!1}),_setStatusOnly:w=>h({status:w})})))}function nu({children:e,initialState:t}){const n=m.useContext(mt)??void 0,r=m.useMemo(()=>tu({...t,recorderStore:n}),[t,n]);return x.jsx(vn.Provider,{value:r,children:e})}function ru(e){var s,i;const t={},n=[],r=((s=e==null?void 0:e.ast)==null?void 0:s.blocks)??[];let o=0;for(const u of r){if((u==null?void 0:u.type)==="image")continue;const a=(u==null?void 0:u.runs)??[];for(let l=0;l<a.length;l++){const d=a[l],S=o+l;d.audioChunkIndex!=null&&d.audioTimeMs!=null&&((t[i=d.audioChunkIndex]||(t[i]=[])).push({t:d.audioTimeMs,g:S}),n[S]={clip:d.audioChunkIndex,t:d.audioTimeMs})}o+=a.length}return Object.values(t).forEach(u=>u.sort((a,l)=>a.t-l.t)),{byClip:t,g2ct:n}}function ou(e,t,n){if(n<=0)return-1;const r=Math.max(0,Math.min(t,n-1));if(e[r]===1)return r;for(let o=1;o<n;o++){const s=r-o;if(s>=0&&e[s]===1)return s;const i=r+o;return i<n&&e[i]===1?i:-1}return-1}function su(e){const t=Ul(e),n=Kl(t),r=t.reduce((d,S)=>d+(S||0),0),o=new Int32Array(Math.max(1,r)).fill(-1),s=new Uint8Array(Math.max(1,r)).fill(0),i=[],u=[];return e.forEach((d,S)=>{var c;if(d.type!=="paragraph")return;const g=n[S]??0,h=d.runs??[];for(let f=0;f<h.length;f++){const p=((c=h[f])==null?void 0:c.text)||"";sr(p)&&(s[g+f]=1)}const w=Xl(h,g).map(f=>{var I;const p=f.startG-g,C=f.endG-f.startG+1;let T=-1;for(let j=0;j<C;j++){const b=((I=h[p+j])==null?void 0:I.text)??"";if(sr(b)){T=f.startG+j;break}}return{startG:f.startG,endG:f.endG,r0:p,len:C,firstReadableGI:T,splitIndex:f.splitIndex}});u[S]=w;for(const f of w){const p=i.length;for(let C=f.startG;C<=f.endG;C++)o[C]=p;i.push(f)}}),{nav:{groups:i,giToGroupIdx:o,readableGi:s,splitGroupsPerBlock:u},layout:{prefix:n,totalRuns:r}}}function iu(e){const{section:t,onViewerClose:n,onSectionNav:r,isCanPrev:o,isCanNext:s,canTracking:i,canToggleShowGaze:u,showGaze:a,onToggleShowGaze:l,handleAskCalibration:d,nav:S,layout:g,initialIndex:h,mountTime:v}=e,w=g.totalRuns??0,c=typeof h=="number"?h:w>0?0:-1,f=c>=0?ou(S.readableGi,c,w):-1;return{section:t,sectionId:t.section_id,onViewerClose:n,onSectionNav:r,isCanPrev:o??!1,isCanNext:s??!1,canTracking:i??!1,canToggleShowGaze:u??!1,showGaze:a??!1,onToggleShowGaze:l,handleAskCalibration:d,currentGlobalRunIndex:f,lastUpdateBy:"program",totalRuns:w,pageIndex:0,totalPages:0,sectionLoading:!0,_loadingStartTime:v,_scrollApi:void 0,derivedNav:S,layout:g,rangeStartGI:null,rangeEndGI:null,translateOpen:!1,translateLoading:!1,translateText:void 0,translatedText:void 0,translateStartGI:void 0,translateEndGI:void 0}}function lu(e){const{section:t,initialIndex:n,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i,canTracking:u,canToggleShowGaze:a,showGaze:l,onToggleShowGaze:d,handleAskCalibration:S,eventBridgeStore:g}=e,h=t.ast.blocks,{nav:v,layout:w}=su(h),c=Date.now(),f=iu({section:t,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i,canTracking:u,canToggleShowGaze:a,showGaze:l,onToggleShowGaze:d,handleAskCalibration:S,nav:v,layout:w,initialIndex:n,mountTime:c});return g&&queueMicrotask(()=>{g.getState().emit({type:"render_start",payload:{sectionId:t.section_id}},c),g.getState().emit({type:"loading_start",payload:{}},c)}),Vt((p,C)=>{const T=N=>{p(D=>D.progress._scrollApi===N?D:{progress:{...D.progress,_scrollApi:N}})},I=()=>C().progress._scrollApi,j=N=>{p(D=>{const q=D.progress;if(q.totalRuns===N)return D;const A=q.currentGlobalRunIndex<0&&N>0;return{progress:{...q,totalRuns:N,currentGlobalRunIndex:A?0:q.currentGlobalRunIndex,lastUpdateBy:A?"program":q.lastUpdateBy}}})},b=(N,D="program")=>{const q=C().progress.currentGlobalRunIndex,A=C().progress,G=A.totalRuns>0?Math.max(-1,Math.min(N,A.totalRuns-1)):N;q===G&&A.lastUpdateBy===D||(p(K=>({progress:{...K.progress,currentGlobalRunIndex:G,lastUpdateBy:D}})),q!==G&&g&&g.getState().emit({type:"global_index_change",payload:{globalIndex:G}}))},y=N=>{const{sectionLoading:D,_loadingStartTime:q}=C().progress;if(D===N)return;const A=Date.now();if(N)p(G=>({progress:{...G.progress,sectionLoading:!0,_loadingStartTime:A}})),g&&g.getState().emit({type:"loading_start",payload:{}});else{const K=(q?A-q:0)/1e3;p(H=>({progress:{...H.progress,sectionLoading:!1,_loadingStartTime:null}})),g&&g.getState().emit({type:"loading_end",payload:{duration:K}})}},k=N=>{p(D=>({progress:{...D.progress,pageIndex:N}}))},R=N=>{p(D=>({progress:{...D.progress,totalPages:N}}))},_=(N,D)=>{const A=C().progress.rangeStartGI==null;if(p(G=>({progress:{...G.progress,rangeStartGI:Math.min(N,D),rangeEndGI:Math.max(N,D)}})),g){const G=E();g.getState().emit({type:A?"range_select":"range_change",payload:{startGI:Math.min(N,D),endGI:Math.max(N,D),text:G}})}},z=()=>{p(N=>({progress:{...N.progress,rangeStartGI:null,rangeEndGI:null}})),g&&g.getState().emit({type:"range_clear",payload:{}})},B=N=>{const{rangeStartGI:D,rangeEndGI:q}=C().progress;D==null||q==null||(N<D?p(A=>({progress:{...A.progress,rangeStartGI:N}})):N>q?p(A=>({progress:{...A.progress,rangeEndGI:N}})):z())},E=()=>{var te;const{rangeStartGI:N,rangeEndGI:D,section:q,layout:A}=C().progress;if(N==null||D==null||!A)return"";const G=((te=q.ast)==null?void 0:te.blocks)??[],K=A.prefix,H=[];for(let $=0;$<G.length;$++){const Z=G[$];if(Z.type!=="paragraph")continue;const ee=Z.runs??[],J=K[$]??0;for(let ce=0;ce<ee.length;ce++){const se=J+ce;se>=N&&se<=D&&H.push(ee[ce].text??"")}}return H.join("")},P=N=>{p(D=>({progress:{...D.progress,translateOpen:N.isOpen,translateLoading:N.isLoading??!1,translateText:N.text,translatedText:N.translatedText,translateStartGI:N.startGI,translateEndGI:N.endGI}}))},F=()=>{p(N=>({progress:{...N.progress,translateOpen:!1,translateLoading:!1,translateText:void 0,translatedText:void 0,translateStartGI:void 0,translateEndGI:void 0}}))},M=N=>{const{totalRuns:D,derivedNav:q}=C().progress,A=q==null?void 0:q.readableGi;if(!A||D<=0)return N;const G=D,K=Math.max(0,Math.min(N,G-1));if(A[K])return K;let H=K-1,te=K+1;for(;H>=0||te<G;){if(te<G&&A[te])return te;if(H>=0&&A[H])return H;te+=1,H-=1}return K},O=(N,D)=>{const{totalRuns:q,derivedNav:A}=C().progress,G=A==null?void 0:A.readableGi;if(!G||q<=0)return null;if(D>0){for(let K=Math.min(Math.max(N,0),q-1);K<q;K+=1)if(G[K])return K}else for(let K=Math.min(Math.max(N,0),q-1);K>=0;K-=1)if(G[K])return K;return null},Q=N=>{const{totalRuns:D,derivedNav:q}=C().progress,A=q==null?void 0:q.readableGi;if(!A||D<=0)return null;if(N>0){for(let G=D-1;G>=0;G-=1)if(A[G])return G}else for(let G=0;G<D;G+=1)if(A[G])return G;return null};return{progress:{...f,registerSectionScrollApi:T,getSectionScrollApi:I,setTotalRuns:j,setCurrentGlobalRunIndex:b,setSectionLoading:y,setPageIndex:k,setTotalPages:R,setTranslateState:P,clearTranslate:F,setRange:_,clearRange:z,extendRange:B,getRangeText:E,snapToReadable:M,nextReadableFrom:O,edgeReadable:Q,hasReadableInDir:(N,D)=>O(N+(D>0?1:-1),D)!=null,computeStepTarget:(N,D)=>{const{totalRuns:q,derivedNav:A}=C().progress;if(!q||q<=0)return N;const G=(A==null?void 0:A.groups)??[],K=A==null?void 0:A.giToGroupIdx;if(!G.length||!K){const J=q-1;return M(Math.max(0,Math.min(N+D,J)))}let H=K[N]??-1;if(H<0||H>=G.length)for(let ee=0;ee<G.length;ee+=1){const J=G[ee];if(N>=J.startG&&N<=J.endG){H=ee;break}}if(H<0||H>=G.length)return Q(D)??M(N);const te=ee=>ee>=0&&ee<G.length&&(G[ee].firstReadableGI??-1)>=0;let $=H+D;for(;$>=0&&$<G.length&&!te($);)$+=D;if($<0||$>=G.length)return Q(D)??M(N+D);const Z=G[$].firstReadableGI;return Z>=0?Z:M(N+D)},giToPercentTotal:N=>{const D=C().progress.totalRuns;return!D||D<=1?0:Math.max(0,Math.min(N,D-1))/(D-1)*100},percentToGITotal:N=>{const D=C().progress.totalRuns;if(!D||D<=1)return 0;const q=Math.max(0,Math.min(N,100)),A=Math.round(q/100*(D-1));return Math.max(0,Math.min(A,D-1))}}}})}function au({children:e,initialState:t,gazeSync:n}){const r=m.useContext(mt),o=m.useMemo(()=>lu({...t,...n?n.getSnapshot():{},eventBridgeStore:r}),[t,r]);return m.useEffect(()=>{if(!n)return;const s=()=>{const i=n.getSnapshot(),u=o.getState().progress;u.canTracking===i.canTracking&&u.canToggleShowGaze===i.canToggleShowGaze&&u.showGaze===i.showGaze&&u.onToggleShowGaze===i.onToggleShowGaze&&u.handleAskCalibration===i.handleAskCalibration||o.setState(a=>({progress:{...a.progress,canTracking:i.canTracking,canToggleShowGaze:i.canToggleShowGaze,showGaze:i.showGaze,onToggleShowGaze:i.onToggleShowGaze,handleAskCalibration:i.handleAskCalibration}}))};return s(),n.subscribe(s)},[o,n]),x.jsx(lr.Provider,{value:o,children:e})}function cu({children:e,initialState:t}){const n=m.useContext(mt)??void 0,r=m.useRef(Js({init:t,recorderStore:n}));return x.jsx(ir.Provider,{value:r.current,children:e})}const uu=({pages:e,pageIndex:t,maxWidth:n})=>{const r=V(p=>p.section),o=m.useMemo(()=>{var p;return((p=r.ast)==null?void 0:p.blocks)??[]},[r]),s=X(p=>p.marginX),i=X(p=>p.lineHeight),u=X(p=>p.fontSizePx),a=X(p=>p.fontFamily),l=X(p=>p.viewportHeight),d=V(p=>{var C;return((C=p.layout)==null?void 0:C.prefix)??[]}),S=V(p=>{var C;return((C=p.derivedNav)==null?void 0:C.splitGroupsPerBlock)??[]}),g=e[t],h=m.useMemo(()=>{const p=[];return o.forEach((C,T)=>{(C.type==="paragraph"||C.type==="image")&&p.push(T)}),p},[o]),v=m.useMemo(()=>{if(!g)return[];const p=[];for(let C=g.startBlock;C<=g.endBlock;C++){const T=h[C];T!=null&&p.push(T)}return p},[g,h]),w=m.useMemo(()=>{const p=[];for(const C of v){const T=o[C];(T==null?void 0:T.type)==="paragraph"&&p.push({b:T,originalBlockIndex:C})}return p},[v,o]),c=m.useMemo(()=>{const p=new Map,C=Sr();return w.forEach((T,I)=>{p.set(T.originalBlockIndex,{idx:I,marker:yr(T.b,C)})}),p},[w]),f=(p,C,T)=>{if(!p||p.length===0)return[];const I=[];for(const j of p){const b=j.startG,y=j.endG;if(y<C||b>T)continue;const k=Math.max(b,C),R=Math.min(y,T),_=k-b|0,z=Math.max(0,R-k+1);if(z<=0)continue;const B=(j.r0??0)+_;I.push({...j,startG:k,endG:R,r0:B,len:z})}return I};return x.jsx("div",{style:{position:"relative",width:"100%",height:"100%",minHeight:0,display:"flex",alignItems:"stretch",justifyContent:"center",fontFamily:a,fontSize:u,lineHeight:i,boxSizing:"border-box"},children:x.jsxs("div",{style:{width:"100%",maxWidth:n,height:"100%",boxSizing:"border-box",overflow:"hidden",display:"flex",flexDirection:"column",margin:"0 auto"},children:[x.jsx("div",{style:{height:40}}),x.jsx("div",{style:{flex:1,overflow:"hidden"},children:v.map((p,C)=>{var q;const T=o[p],I=C===0,j=C===v.length-1,b={boxSizing:"border-box",paddingRight:`${s}px`,paddingLeft:`${s}px`,maxWidth:n,margin:"0 auto",display:"flex",width:"100%",height:"auto"},y=`sec-${r.section_id}/blk-${T.id??p}`;if(T.type==="image"){const{src:A,alt:G,width:K,height:H}=T,te=K&&H?`${K} / ${H}`:"4 / 3",$=l>80?Math.floor((l-80)*.6):void 0;return x.jsx("div",{style:b,children:x.jsxs("div",{style:{margin:"12px 0",textAlign:"center",width:"100%"},children:[x.jsx("div",{style:{position:"relative",width:"100%",maxHeight:$,aspectRatio:te},children:x.jsx("img",{src:A,alt:G||"",loading:"eager",style:{pointerEvents:"none",position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"contain",display:"block"}})}),G&&x.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:G})]})},y)}const k=T,R=c.get(p),_=R==null?void 0:R.marker,z=k.runs??[],B=z.length;let E=0,P=Math.max(0,B-1);I&&g.startOffsetInBlock!=null&&(E=Math.min(Math.max(0,g.startOffsetInBlock),P)),j&&g.endOffsetInBlock!=null&&(P=Math.max(E,Math.min(g.endOffsetInBlock,P)));const F=E>0,M=d[p]??0,O=S[p]??[],Q=M+E,re=M+P;let oe=f(O,Q,re);const ie=M+E;oe=oe.map(A=>{const G=Math.max(0,(A.startG??Q)-ie),K=A.len??Math.max(1,(A.endG??re)-(A.startG??Q)+1);return{...A,r0:G,len:K}});const ue=E<=P?z.slice(E,P+1):[],xe=k.list?k.list.level*24:0,N=((q=k.list)==null?void 0:q.kind)==="bullet"?k.list.glyph??"•":void 0,D=F?void 0:_??N;return x.jsx("div",{style:b,children:x.jsxs("p",{style:{width:"100%",margin:"8px 0",paddingLeft:xe,textAlign:k.textAlign,whiteSpace:"pre-wrap",boxSizing:"border-box"},children:[k.list&&D?x.jsx("span",{"aria-hidden":!0,style:{minWidth:16,display:"inline-block",whiteSpace:"nowrap",userSelect:"none"},children:D||""}):null,x.jsx(ys,{preGroups:oe,runs:ue,ns:y,baseIndex:ie,sectionId:String(r.section_id)})]})},y)})})]})})},nn=.5;function du(e,t){const n=m.useRef(null),r=m.useRef(null),o=m.useRef(!1);m.useEffect(()=>{const s=()=>{n.current==null&&(n.current=requestAnimationFrame(()=>{n.current=null,t(),o.current=!0,requestAnimationFrame(()=>{o.current=!1})}))},i=new ResizeObserver(a=>{if(o.current)return;const l=a[0],{width:d,height:S}=l.contentRect,g=r.current;if(!g){r.current={w:d,h:S};return}Math.abs(g.w-d)<nn&&Math.abs(g.h-S)<nn||(r.current={w:d,h:S},s())});e.forEach(a=>{a.current&&i.observe(a.current)});const u=()=>{var l;const a=(l=e[0])==null?void 0:l.current;if(a&&r.current){const d=a.offsetWidth,S=a.offsetHeight;if(Math.abs(r.current.w-d)<nn&&Math.abs(r.current.h-S)<nn)return;r.current={w:d,h:S}}s()};return window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u),i.disconnect(),n.current!=null&&cancelAnimationFrame(n.current),n.current=null}},[e,t])}function fu(e){const{onPrev:t,onNext:n,onSingle:r,onDouble:o,shouldIgnoreTarget:s,shouldIgnoreSwipe:i,horizontalThreshold:u=120,velocityThreshold:a=.6,singleDelayMs:l=250,doubleClickWindowMs:d=300,onDragMove:S,onDragEnd:g,pageTransitionThreshold:h}=e,v=h??u,w=10,c=We.useRef({touchId:null,startX:0,startY:0,startT:0,swiping:!1,mouseDown:!1,mouseSwiping:!1,mStartX:0,mStartY:0,mStartT:0,capturedEl:null,prevUserSelect:"",lastTapT:0,singleTimer:null,suppressClick:!1}),f=()=>{c.current.singleTimer!=null&&(clearTimeout(c.current.singleTimer),c.current.singleTimer=null)},p=We.useCallback(E=>{if(s!=null&&s(E))return;const P=performance.now();P-c.current.lastTapT<=d&&c.current.lastTapT>0?(f(),c.current.lastTapT=0,o==null||o()):(f(),r&&(c.current.singleTimer=window.setTimeout(()=>{c.current.singleTimer=null,r()},l)),c.current.lastTapT=P)},[s,d,o,r,l]),C=We.useCallback((E,P)=>{const F=Math.abs(E)/Math.max(1,P);Math.abs(E)>=v||F>=a?E<0?n():t():g==null||g()},[v,a,n,t,g]),T=We.useCallback(E=>{if(E.touches.length!==1)return;const P=i??s;if(P!=null&&P(E.target))return;const F=E.touches[0];c.current.touchId=F.identifier,c.current.startX=F.clientX,c.current.startY=F.clientY,c.current.startT=E.timeStamp,c.current.swiping=!1},[i,s]),I=We.useCallback(E=>{if(c.current.touchId==null)return;const P=Array.from(E.touches).find(Q=>Q.identifier===c.current.touchId);if(!P)return;const F=P.clientX-c.current.startX,M=Math.abs(F),O=Math.abs(P.clientY-c.current.startY);if(!c.current.swiping)if(M>=w&&M>O)c.current.swiping=!0;else return;S==null||S(F)},[S]),j=We.useCallback(E=>{if(c.current.touchId==null)return;const P=Array.from(E.changedTouches).find(Q=>Q.identifier===c.current.touchId);if(!P)return;const F=P.clientX-c.current.startX,M=P.clientY-c.current.startY,O=E.timeStamp-c.current.startT;c.current.swiping?C(F,O):Math.abs(F)<10&&Math.abs(M)<10&&p(E.target),c.current.suppressClick=!0,c.current.touchId=null,c.current.swiping=!1},[C,p]),b=We.useCallback(()=>{c.current.swiping&&(g==null||g()),c.current.touchId=null,c.current.swiping=!1},[g]),y=We.useCallback(E=>{if(E.pointerType==="touch"||c.current.mouseDown)return;const P=i??s;P!=null&&P(E.target)||(c.current.mouseDown=!0,c.current.mouseSwiping=!1,c.current.mStartX=E.clientX,c.current.mStartY=E.clientY,c.current.mStartT=E.timeStamp,c.current.suppressClick=!1,c.current.capturedEl=E.currentTarget)},[i,s]),k=We.useCallback(E=>{if(E.pointerType==="touch"||!c.current.mouseDown)return;const P=E.clientX-c.current.mStartX,F=Math.abs(P),M=Math.abs(E.clientY-c.current.mStartY);if(!c.current.mouseSwiping)if(F>=w&&F>M){c.current.mouseSwiping=!0,c.current.suppressClick=!0;const O=c.current.capturedEl;if(O!=null&&O.setPointerCapture)try{O.setPointerCapture(E.pointerId)}catch{}c.current.prevUserSelect=document.body.style.userSelect,document.body.style.userSelect="none",E.preventDefault()}else return;S==null||S(P),E.preventDefault()},[S]),R=We.useCallback(E=>{var F;if(E.pointerType==="touch"||!c.current.mouseDown)return;if(c.current.mouseSwiping){const M=E.clientX-c.current.mStartX,O=E.timeStamp-c.current.mStartT;C(M,O),document.body.style.userSelect=c.current.prevUserSelect}const P=c.current.capturedEl;if((F=P==null?void 0:P.hasPointerCapture)!=null&&F.call(P,E.pointerId))try{P.releasePointerCapture(E.pointerId)}catch{}c.current.mouseDown=!1,c.current.mouseSwiping=!1,c.current.capturedEl=null},[C]),_=We.useCallback(E=>{E.pointerType!=="touch"&&(c.current.mouseSwiping&&(g==null||g(),document.body.style.userSelect=c.current.prevUserSelect),c.current.mouseDown=!1,c.current.mouseSwiping=!1,c.current.capturedEl=null)},[g]),z=We.useCallback(()=>{c.current.mouseSwiping&&(g==null||g(),document.body.style.userSelect=c.current.prevUserSelect),c.current.mouseDown=!1,c.current.mouseSwiping=!1,c.current.capturedEl=null},[g]),B=We.useCallback(E=>{if(c.current.suppressClick){c.current.suppressClick=!1;return}p(E.target)},[p]);return We.useEffect(()=>()=>{f(),document.body.style.userSelect=""},[]),{onTouchStart:T,onTouchMove:I,onTouchEnd:j,onTouchCancel:b,onPointerDown:y,onPointerMove:k,onPointerUp:R,onPointerCancel:_,onLostPointerCapture:z,onClick:B}}var An,go;function Ms(){if(go)return An;go=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return An=e,An}var Pn,ho;function pu(){if(ho)return Pn;ho=1;var e=typeof Qt=="object"&&Qt&&Qt.Object===Object&&Qt;return Pn=e,Pn}var Bn,mo;function Es(){if(mo)return Bn;mo=1;var e=pu(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Bn=n,Bn}var Ln,bo;function gu(){if(bo)return Ln;bo=1;var e=Es(),t=function(){return e.Date.now()};return Ln=t,Ln}var Gn,xo;function hu(){if(xo)return Gn;xo=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return Gn=t,Gn}var Hn,vo;function mu(){if(vo)return Hn;vo=1;var e=hu(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Hn=n,Hn}var Fn,So;function js(){if(So)return Fn;So=1;var e=Es(),t=e.Symbol;return Fn=t,Fn}var Nn,yo;function bu(){if(yo)return Nn;yo=1;var e=js(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,o=e?e.toStringTag:void 0;function s(i){var u=n.call(i,o),a=i[o];try{i[o]=void 0;var l=!0}catch{}var d=r.call(i);return l&&(u?i[o]=a:delete i[o]),d}return Nn=s,Nn}var Dn,wo;function xu(){if(wo)return Dn;wo=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return Dn=n,Dn}var Wn,Co;function vu(){if(Co)return Wn;Co=1;var e=js(),t=bu(),n=xu(),r="[object Null]",o="[object Undefined]",s=e?e.toStringTag:void 0;function i(u){return u==null?u===void 0?o:r:s&&s in Object(u)?t(u):n(u)}return Wn=i,Wn}var qn,Io;function Su(){if(Io)return qn;Io=1;function e(t){return t!=null&&typeof t=="object"}return qn=e,qn}var Vn,To;function yu(){if(To)return Vn;To=1;var e=vu(),t=Su(),n="[object Symbol]";function r(o){return typeof o=="symbol"||t(o)&&e(o)==n}return Vn=r,Vn}var $n,ko;function wu(){if(ko)return $n;ko=1;var e=mu(),t=Ms(),n=yu(),r=NaN,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,i=/^0o[0-7]+$/i,u=parseInt;function a(l){if(typeof l=="number")return l;if(n(l))return r;if(t(l)){var d=typeof l.valueOf=="function"?l.valueOf():l;l=t(d)?d+"":d}if(typeof l!="string")return l===0?l:+l;l=e(l);var S=s.test(l);return S||i.test(l)?u(l.slice(2),S?2:8):o.test(l)?r:+l}return $n=a,$n}var Un,Ro;function Cu(){if(Ro)return Un;Ro=1;var e=Ms(),t=gu(),n=wu(),r="Expected a function",o=Math.max,s=Math.min;function i(u,a,l){var d,S,g,h,v,w,c=0,f=!1,p=!1,C=!0;if(typeof u!="function")throw new TypeError(r);a=n(a)||0,e(l)&&(f=!!l.leading,p="maxWait"in l,g=p?o(n(l.maxWait)||0,a):g,C="trailing"in l?!!l.trailing:C);function T(B){var E=d,P=S;return d=S=void 0,c=B,h=u.apply(P,E),h}function I(B){return c=B,v=setTimeout(y,a),f?T(B):h}function j(B){var E=B-w,P=B-c,F=a-E;return p?s(F,g-P):F}function b(B){var E=B-w,P=B-c;return w===void 0||E>=a||E<0||p&&P>=g}function y(){var B=t();if(b(B))return k(B);v=setTimeout(y,j(B))}function k(B){return v=void 0,C&&d?T(B):(d=S=void 0,h)}function R(){v!==void 0&&clearTimeout(v),c=0,d=w=S=v=void 0}function _(){return v===void 0?h:k(t())}function z(){var B=t(),E=b(B);if(d=arguments,S=this,w=B,E){if(v===void 0)return I(w);if(p)return clearTimeout(v),v=setTimeout(y,a),T(w)}return v===void 0&&(v=setTimeout(y,a)),h}return z.cancel=R,z.flush=_,z}return Un=i,Un}var Iu=Cu();const Tu=Po(Iu);function ku(e,t=200,n,r){const o=m.useRef(e),s=m.useRef(n);m.useEffect(()=>{o.current=e},[e]),m.useEffect(()=>{s.current=n},[n]);const i=m.useMemo(()=>{const u=Tu((...l)=>{o.current(...l)},t,r),a=((...l)=>{var d;(d=s.current)==null||d.call(s),u(...l)});return a.cancel=u.cancel.bind(u),a.flush=u.flush.bind(u),a},[t,r]);return m.useEffect(()=>()=>i.cancel(),[i]),i}const Ru="https://fonts.googleapis.com/css2?family=Nanum+Myeongjo:wght@400;700&family=Noto+Sans+KR:wght@300;400;500;700&family=Noto+Serif+KR:wght@400;700&display=swap";let Kn=!1;function _u(){if(Kn||typeof document>"u")return;if(document.querySelector('link[href*="fonts.googleapis.com"][href*="Noto"]')){Kn=!0;return}const t=document.createElement("link");t.rel="stylesheet",t.href=Ru,document.head.appendChild(t),Kn=!0}const Os=new Map,zs=e=>Os.get(e)??0,Mu=e=>{const t=zs(e)+1;return Os.set(e,t),t};class As extends Error{constructor(){super("calcPages canceled due to a newer invocation");Ir(this,"code","CALC_PAGES_CANCELED");this.name="CalcPagesCanceled"}}const Ye=(e,t)=>{if(e!==zs(t))throw new As},Xn=e=>{const t=getComputedStyle(e),n=parseFloat(t.marginTop||"0")||0,r=parseFloat(t.marginBottom||"0")||0;return{mt:n,mb:r}},_o=e=>{const t=e.getClientRects(),n=t.length?t[0].top:e.getBoundingClientRect().top,r=e.querySelectorAll("[data-runbox]"),o=[];return r.forEach((s,i)=>{const u=s.getClientRects(),a=u.length?u[u.length-1].bottom:n;o[i]=Math.max(0,a-n)}),o},Eu=(e,t,n)=>{if(n<16)return async(o=24)=>{Ye(e,t)};let r=0;return async(o=24)=>{r++,r%o===0&&(Ye(e,t),await new Promise(s=>requestAnimationFrame(()=>s())),Ye(e,t))}};async function ju({viewHost:e,measureRoot:t,contentArea:n,items:r,cfgMaxWidth:o,marginX:s,fontFamily:i,fontSizePx:u,lineHeight:a,showSplit:l,breakGapPx:d=0,showSlash:S,paragraphMarkers:g,playbackScale:h=1,viewportHeight:v=0,instanceId:w="default"}){var f,p,C;const c=Mu(w);if(Ye(c,w),i&&typeof document<"u"&&document.fonts){_u();try{const T=`${u}px ${i}`;await document.fonts.load(T),document.fonts.check(T)||await document.fonts.ready}catch{}}Ye(c,w);try{const T=Math.abs(h-1)>.001,I=1/h;T&&(t.style.transform=`scale(${I})`,t.style.transformOrigin="top left");const j=Math.max(0,e.offsetWidth||0),b=Math.max(0,Math.min(j,o));t.style.maxWidth=`${b}px`,Ye(c,w);let y=Math.round(n.offsetHeight||0);y||(y=Math.max(0,n.clientHeight|0));const k=1.5,R=(H,te)=>te+H<=y-k,_=getComputedStyle(e),z={letterSpacing:_.letterSpacing,wordSpacing:_.wordSpacing,fontKerning:_.fontKerning||"normal",fontVariantLigatures:_.fontVariantLigatures||"normal",textTransform:_.textTransform||"none",direction:_.direction||"ltr",wordBreak:_.wordBreak||"keep-all",overflowWrap:_.overflowWrap||_.wordWrap||"break-word",hyphens:_.hyphens||"manual"},B=H=>{H.style.letterSpacing=z.letterSpacing||"",H.style.wordSpacing=z.wordSpacing||"",H.style.fontKerning=z.fontKerning||"",H.style.fontVariantLigatures=z.fontVariantLigatures||"",H.style.textTransform=z.textTransform||"",H.style.direction=z.direction||"",H.style.wordBreak=z.wordBreak||"",H.style.wordWrap=z.overflowWrap||"",H.style.overflowWrap=z.overflowWrap||"",H.style.hyphens=z.hyphens||""},E=b,P=Math.max(0,E-2*(s||0));n.innerHTML="";const F=document.createElement("div");F.style.boxSizing="border-box",F.style.width=`${E}px`,F.style.maxWidth=`${E}px`,F.style.margin="0 auto",F.style.display="flex",n.appendChild(F);const M=document.createElement("div");M.style.boxSizing="border-box",M.style.paddingRight=`${s}px`,M.style.paddingLeft=`${s}px`,M.style.width=`${E}px`,M.style.maxWidth=`${E}px`,M.style.margin="0 auto",M.style.display="flex",M.style.justifyContent="center",M.style.height="auto",F.appendChild(M);const O=new Map,Q={},re=Eu(c,w,r.length),oe=(H,te)=>{const $=document.createElement("p");return $.style.margin="8px 0",$.style.paddingLeft=te?`${te}px`:"0",$.style.textAlign=H.textAlign??"start",$.style.whiteSpace="pre-wrap",$.style.lineHeight=String(a),$.style.fontSize=`${u}px`,$.style.boxSizing="border-box",$.style.fontFamily=i??"",$.style.width="100%",B($),$},ie=(H,te)=>{const $=te??[],Z=document.createDocumentFragment();for(let ee=0;ee<$.length;ee++){const J=$[ee],ce=document.createElement("span");ce.dataset.runbox=String(ee),ce.style.whiteSpace="pre-wrap";const se=document.createElement("span");if(se.dataset.run=String(ee),se.textContent=(J==null?void 0:J.text)??"",se.style.whiteSpace="pre-wrap",J!=null&&J.bold&&(se.style.fontWeight="700"),J!=null&&J.italic&&(se.style.fontStyle="italic"),J!=null&&J.underline&&(se.style.textDecoration="underline"),ce.appendChild(se),l&&(J!=null&&J.split)&&ee!==$.length-1){const ve=Math.max(0,(d??0)/2),ge=document.createElement("span");ge.style.display="inline-block",ge.style.width=`${ve}px`;const Ce=document.createElement("span");if(Ce.style.display="inline-block",Ce.style.width=`${ve}px`,ce.appendChild(ge),S){const Re=document.createElement("span");Re.textContent=" / ",ce.appendChild(Re)}ce.appendChild(Ce)}Z.appendChild(ce)}H.appendChild(Z)},ue=v>80?Math.floor((v-80)*.6):void 0,xe=H=>{const te=H!=null&&H.width&&(H!=null&&H.height)?`${H.width} / ${H.height}`:"4 / 3",$=document.createElement("div");$.style.margin="12px 0",$.style.textAlign="center",$.style.width=`${P}px`;const Z=document.createElement("div");Z.style.position="relative",Z.style.width="100%",ue&&(Z.style.maxHeight=`${ue}px`),Z.style.aspectRatio=te;const ee=document.createElement("div");if(ee.style.position="absolute",ee.style.inset="0",ee.style.width="100%",ee.style.height="100%",Z.appendChild(ee),$.appendChild(Z),H!=null&&H.alt){const J=document.createElement("div");J.style.fontSize="12px",J.style.color="#6B7280",J.style.marginTop="4px",J.textContent=String(H.alt),B(J),$.appendChild(J)}return $};for(let H=0;H<r.length;H++){Ye(c,w);const te=r[H];if(M.dataset.block=String(H),M.innerHTML="",te.kind==="image"){const Ce=te.block,Re=xe(Ce);M.appendChild(Re);const Ae=Re.getBoundingClientRect(),{mt:je,mb:Ge}=Xn(Re);Q[H]={contentH:Math.ceil(Ae.height),mt:je,mb:Ge},await re(24);continue}const $=te.block,Z=$.list?($.list.level??0)*24:0,ee=te.paraIndex??0,J=g[ee]??(((f=$.list)==null?void 0:f.kind)==="bullet"?((p=$.list)==null?void 0:p.glyph)??"•":void 0);if(!!($.list&&J)){const Ce=oe($,Z);Ce.dataset.variant="with";const Re=oe($,Z);Re.dataset.variant="no";const Ae=document.createElement("span");Ae.textContent=`${J} `,Ae.style.minWidth="16px",Ae.style.display="inline-block",Ae.style.whiteSpace="nowrap",Ae.style.userSelect="none",Ce.appendChild(Ae),ie(Ce,$.runs),ie(Re,$.runs);const je=document.createDocumentFragment();je.appendChild(Ce),je.appendChild(Re),M.appendChild(je)}else{const Ce=oe($,Z);Ce.dataset.variant="with",ie(Ce,$.runs),M.appendChild(Ce)}const se=M.querySelector('p[data-variant="with"]'),ve=M.querySelector('p[data-variant="no"]'),ge=ve??se;if(se&&ge){const Ce=_o(se),Re=_o(ge),{mt:Ae,mb:je}=Xn(se),{mt:Ge,mb:rt}=Xn(ge),$e=((C=$.runs)==null?void 0:C.length)??0,Oe=ve?Re:Ce,et=ve?Ge:Ae,Qe=ve?rt:je;O.set(H,{runsLen:$e,lastBottomWith:Ce,lastBottomNo:Oe,mtWith:Ae,mbWith:je,mtNo:et,mbNo:Qe})}await re(24)}Ye(c,w),M.innerHTML="";const N=(H,te,$,Z)=>{if(te>$)return{top:0,content:0,mb:0};const ee=Z?H.lastBottomNo:H.lastBottomWith,J=Z?H.mtNo:H.mtWith,ce=Z?H.mbNo:H.mbWith,se=Z?0:J,ve=te>0?ee[te-1]??0:0,ge=Math.max(0,(ee[$]??0)-ve);return{top:se,content:ge,mb:ce}},D=[];let q=0,A,G=null,K=null;for(;q<r.length;){Ye(c,w);const H=q;let te=0,$=0,Z=A;Z!=null&&G===q&&K!=null&&(Z=Math.max(Z,K+1));let ee=-1,J;for(;q<r.length;){if(Ye(c,w),r[q].kind==="image"){const Oe=Q[q]??{contentH:0,mt:0,mb:0},Qe=(te===0?Oe.mt:$+Oe.mt)+Oe.contentH;if(R(Qe,te)){te+=Qe,ee=q,J=void 0,$=Oe.mb,q+=1,A=void 0,G=null,K=null;continue}if(te===0){D.push({startBlock:H,endBlock:q,...Z!=null?{startOffsetInBlock:Z}:{}}),q+=1,A=void 0,G=null,K=null,$=0;break}break}const se=O.get(q),ve=se.runsLen,ge=q===H&&Z!=null?Z:0;if(ge>=ve){q+=1,A=void 0,G=null,K=null;continue}const Ce=ge>0,Re=N(se,ge,ve-1,Ce),je=(te===0?Re.top:$+Re.top)+Re.content;if(R(je,te)){te+=je,ee=q,J=ve-1,$=Re.mb,q+=1,A=void 0,G=null,K=null;continue}let Ge=ge,rt=ve-1,$e=ge-1;for(;Ge<=rt;){Ye(c,w);const Oe=Ge+rt>>1,et=N(se,ge,Oe,Ce),Qe=(te===0?et.top:$+et.top)+et.content;R(Qe,te)?($e=Oe,Ge=Oe+1):rt=Oe-1}if($e>=ge){D.push({startBlock:H,endBlock:q,...Z!=null?{startOffsetInBlock:Z}:{},endOffsetInBlock:$e}),A=$e+1,G=q,K=$e,$=0;break}if(te>0){D.push({startBlock:H,endBlock:ee>=0?ee:Math.min(q-1,r.length-1),...Z!=null?{startOffsetInBlock:Z}:{},...J!=null?{endOffsetInBlock:J}:{}}),$=0;break}else{const Oe=ge;D.push({startBlock:H,endBlock:q,...Z!=null?{startOffsetInBlock:Z}:{},endOffsetInBlock:Oe}),A=Oe+1,G=q,K=Oe,$=0;break}}(D.length===0||D[D.length-1].startBlock!==H)&&D.push({startBlock:H,endBlock:ee>=0?ee:Math.min(q-1,r.length-1),...Z!=null?{startOffsetInBlock:Z}:{},...J!=null?{endOffsetInBlock:J}:{}})}return F.remove(),T&&(t.style.transform="",t.style.transformOrigin=""),Ye(c,w),{pages:D,pageByRunIndex:null}}catch(T){throw console.error(T),T}}function Ou(e){const t=[],n=[];let r=0;return e.forEach((o,s)=>{o.type==="paragraph"?(t.push({kind:"paragraph",block:o,originalIndex:s,paraIndex:r}),n.push(s),r+=1):o.type==="image"&&t.push({kind:"image",block:o,originalIndex:s})}),{items:t,paraIndexMap:n}}function Mo(e,t,n){var r;if(!e)return null;for(let o=e.startBlock;o<=e.endBlock;o++){const s=t[o];if(!s||s.kind!=="paragraph")continue;const i=((r=s.block.runs)==null?void 0:r.length)??0;if(!i)continue;const u=o===e.startBlock&&e.startOffsetInBlock!=null?Math.min(Math.max(0,e.startOffsetInBlock),i-1):0;return(n[s.originalIndex]??0)+u}return null}function zu(e,t,n,r){var o;for(let s=0;s<t.length;s++){const i=t[s];for(let u=i.startBlock;u<=i.endBlock;u++){const a=n[u];if(!a||a.kind!=="paragraph")continue;const l=((o=a.block.runs)==null?void 0:o.length)??0;if(!l)continue;let d=0,S=l-1;u===i.startBlock&&i.startOffsetInBlock!=null&&(d=Math.max(0,Math.min(i.startOffsetInBlock,S))),u===i.endBlock&&i.endOffsetInBlock!=null&&(S=Math.max(d,Math.min(i.endOffsetInBlock,S)));const g=r[a.originalIndex]??0,h=g+d,v=g+S;if(e>=h&&e<=v)return s}}return-1}function Au(e){var r,o;const t=e;if(!t)return!1;const n=((o=(r=t.tagName)==null?void 0:r.toLowerCase)==null?void 0:o.call(r))??"";return!!(["a","button","input","textarea","select","label"].includes(n)||t.isContentEditable)}function Pu(e){var n;const t=e;return t?!!((n=t.closest)!=null&&n.call(t,"[data-range-handle]")):!1}function Bu(){var Cr;const e=m.useId(),t=V(U=>U.section),n=V(U=>U.sectionLoading),r=lt(),o=m.useRef(!1);m.useEffect(()=>r.subscribe(U=>{o.current=U.progress.rangeStartGI!=null&&U.progress.rangeEndGI!=null}),[r]);const s=o.current,i=bt(),u=X(U=>U.theme),a=sn[u],l=X(U=>U.fontFamily),d=X(U=>U.fontSizePx),S=X(U=>U.lineHeight),g=X(U=>U.marginX),h=X(U=>U.viewportHeight),v=860,w=m.useRef(null),{items:c}=m.useMemo(()=>{var U;return Ou(((U=t==null?void 0:t.ast)==null?void 0:U.blocks)??[])},[t]),f=m.useMemo(()=>{const U=[],ze=Sr();return c.forEach(Be=>{if(Be.kind==="paragraph"){const ct=Be.paraIndex;U[ct]=yr(Be.block,ze)}}),U},[c]),[p,C]=m.useState({pages:[],pageByRunIndex:null}),T=V(U=>U.pageIndex),I=V(U=>U.setPageIndex),j=m.useRef(0),b=m.useRef(null),[y,k]=m.useState(!1),[R,_]=m.useState(null),[z,B]=m.useState(!1),E=m.useMemo(()=>({flex:1,fontFamily:l,background:a.bg,color:a.fg,fontSize:d,lineHeight:S,overflow:"hidden",width:"100%",height:"100%",position:"relative",boxSizing:"border-box",WebkitTextSizeAdjust:"none",MozTextSizeAdjust:"none",textSizeAdjust:"none"}),[l,a.bg,a.fg,d,S]),{showSplit:P,breakGapPx:F,slash:M}=X(qt(U=>{var ze;return{showSplit:U.showSplit,breakGapPx:U.breakGapPx??0,slash:((ze=U.breakMarks)==null?void 0:ze.slash)??!1}})),O=lt();m.useEffect(()=>{p&&p.pages.length&&(O.getState().progress.setTotalPages(p.pages.length+1),(async()=>{const U=O.getState().progress.setSectionLoading;await gt(),await gt(),await gt(),await gt(),U(!1)})())},[p,O]);const Q=m.useCallback(()=>{const U=w.current,ze=se.current,Be=ve.current;if(!U||!ze||!Be||c.length===0){C({pages:[],pageByRunIndex:null}),I(0),O.getState().progress.setTotalPages(0);return}(async()=>{performance.now();try{const ct=i.getState().playbackScale,{pages:ft,pageByRunIndex:ut}=await ju({viewHost:U,measureRoot:ze,contentArea:Be,items:c,cfgMaxWidth:v,marginX:g,fontFamily:l,fontSizePx:d,lineHeight:S,showSplit:P,breakGapPx:F,showSlash:M,paragraphMarkers:f,playbackScale:ct,viewportHeight:h,instanceId:e}),Gd=performance.now();C({pages:ft,pageByRunIndex:ut}),I(0)}catch(ct){if(ct instanceof As)return}})()},[I,c,v,g,l,d,S,P,F,M,f,i,h,e,O]),re=V(U=>U.setCurrentGlobalRunIndex),oe=V(U=>{var ze;return((ze=U.layout)==null?void 0:ze.prefix)??[]}),ie=we(U=>U.syncToGI),ue=m.useCallback(U=>{const ze=p.pages.length+1,Be=T+U;if(Be<0||Be>=ze)return;const ct=T===p.pages.length;if(Be===p.pages.length){I(Be);const ut=O.getState().progress.edgeReadable(1);ut!=null&&(re(ut,"extra-page"),ie(ut));return}if(ct&&U===-1){const ut=Mo(p.pages[Be],c,oe);ut!=null&&(re(ut,"scrubber-step"),ie(ut)),I(Be);return}const ft=Mo(p.pages[Be],c,oe);ft!=null?(re(ft,"scrubber-step"),ie(ft)):I(Be)},[T,p.pages,c,oe,re,I,ie,O]),xe=m.useCallback(()=>{y||j.current!==0?(_("prev"),k(!1)):ue(-1)},[y,ue]),N=m.useCallback(()=>{y||j.current!==0?(_("next"),k(!1)):ue(1)},[y,ue]),D=gn(),q=m.useCallback(()=>{const{isSettingsOpen:U,setSettingsOpen:ze,toggleOverlays:Be}=D.getState();U?ze(!1):Be()},[D]),A=p.pages.length+1,G=((Cr=w.current)==null?void 0:Cr.clientWidth)||400,K=m.useCallback(U=>{var ft;const ze=b.current;if(!ze)return;const Be=((ft=w.current)==null?void 0:ft.clientWidth)||1,ct=U/Be*33.333;ze.style.transform=`translate3d(${-33.333+ct}%, 0, 0)`},[]),H=m.useCallback(U=>{T===0&&U>0||T>=A-1&&U<0||(j.current=U,K(U),y||k(!0))},[T,A,K,y]),te=m.useCallback(()=>{j.current=0,k(!1);const U=b.current;U&&(U.style.transition="transform 250ms ease-out",U.style.transform="translate3d(-33.333%, 0, 0)")},[]),$=m.useCallback(U=>{if(U.target!==U.currentTarget||U.propertyName!=="transform")return;const ze=R;B(!0),_(null),j.current=0,ze==="prev"?ue(-1):ze==="next"&&ue(1)},[R,ue]);m.useLayoutEffect(()=>{z&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{B(!1)})})},[z]);const Z=cn(),ee=m.useCallback(U=>s||Pu(U)?!0:Au(U),[s]),J=m.useCallback(U=>Z.getState().status==="playing"?!0:ee(U),[Z,ee]),ce=fu({onPrev:xe,onNext:N,onSingle:q,onDouble:()=>{},shouldIgnoreTarget:ee,shouldIgnoreSwipe:J,horizontalThreshold:120,velocityThreshold:.6,singleDelayMs:250,doubleClickWindowMs:300,onDragMove:H,onDragEnd:te,pageTransitionThreshold:G*.5}),se=m.useRef(null),ve=m.useRef(null),ge=m.useCallback(()=>{const U=O.getState().progress.setSectionLoading;U(!0)},[O]),Ce=m.useMemo(()=>({trailing:!0,leading:!1,maxWait:1e3}),[]),Re=ku(Q,200,ge,Ce),Ae=m.useRef("");m.useEffect(()=>{if(h<=0)return;const U=`${l}|${d}|${S}|${g}|${P}|${F}|${M}|${h}|${t==null?void 0:t.section_id}`;Ae.current!==U&&(Ae.current=U,Re.cancel(),ge(),Q())},[Re,Q,ge,l,d,S,g,P,F,M,h,t==null?void 0:t.section_id]),du([w],Re);const je=V(U=>U.registerSectionScrollApi);m.useEffect(()=>(je({ensureVisibleGI:()=>Promise.resolve(!0),scrollToGI:()=>Promise.resolve(!0),getVisibleRange:()=>null,getScrollTop:()=>0,setScrollTop:()=>{},getAnchorOffsetRatio:()=>0,scrollToGIAtOffset:()=>Promise.resolve(),stepPage:ue}),()=>je(void 0)),[je,ue]);const Ge=t.quizzes&&t.quizzes.length>0,rt=p.pages.length>0&&T===p.pages.length,$e=T>0?T-1:null,Oe=T<A-1?T+1:null,et=m.useMemo(()=>R==="prev"?"translate3d(0%, 0, 0)":R==="next"?"translate3d(-66.666%, 0, 0)":"translate3d(-33.333%, 0, 0)",[R]),Qe=U=>n?null:U===p.pages.length?x.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,width:"100%",height:"100%"},children:[Ge&&x.jsx(Ts,{}),x.jsx(pn,{isIcon:!1})]}):x.jsx(uu,{pages:p.pages,pageIndex:U,maxWidth:v}),Tt={width:"33.333%",height:"100%",flexShrink:0,display:"flex",alignItems:"stretch",justifyContent:"center",overflow:"hidden",boxSizing:"border-box",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},Sn=!z&&(!y||R!==null);return x.jsxs("div",{ref:w,style:{...E,touchAction:"none"},...ce,children:[x.jsxs("div",{ref:b,style:{display:"flex",width:"300%",height:"100%",transform:et,transition:Sn?"transform 250ms ease-out":"none",willChange:"transform",boxSizing:"border-box",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},onTransitionEnd:R?$:void 0,children:[x.jsx("div",{style:Tt,children:$e!==null&&Qe($e)}),x.jsx("div",{style:Tt,children:Qe(T)}),x.jsx("div",{style:Tt,children:Oe!==null&&Qe(Oe)})]}),x.jsx("div",{ref:se,"aria-hidden":!0,style:{position:"absolute",contain:"layout style paint",left:-999999,top:-999999,zIndex:-999999,opacity:0,width:"100%",maxWidth:v,height:"100%",minHeight:0,boxSizing:"border-box",overflow:"hidden",fontFamily:l,fontSize:d,lineHeight:S,pointerEvents:"none",background:"pink"},children:x.jsxs("div",{style:{width:"100%",maxWidth:v,height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",margin:"0 auto",overflow:"hidden"},children:[x.jsx("div",{style:{height:40,background:"blue"}}),x.jsx("div",{ref:ve,style:{height:"calc(100% - 110px)",overflow:"hidden",boxSizing:"border-box",width:"100%"}})]})}),x.jsx(Lu,{pages:p.pages,items:c,onGotoPage:I,currentPageIndex:T,isOnExtraPage:rt})]})}const Lu=({pages:e,items:t,onGotoPage:n,currentPageIndex:r,isOnExtraPage:o})=>{const s=V(l=>l.currentGlobalRunIndex),i=V(l=>l.lastUpdateBy),u=V(l=>{var d;return((d=l.layout)==null?void 0:d.prefix)??[]}),a=m.useRef(null);return m.useEffect(()=>{if(s==null||e.length===0||o&&!(i==="scrubber-live"||i==="scrubber-commit"||i==="scrubber-step")||a.current===s)return;a.current=s;const l=zu(s,e,t,u);l>=0&&l!==r&&n(l)},[s,e,t,u,n,r,o,i]),x.jsx(x.Fragment,{})},Gu="_wrapper_dbk3n_1",Hu="_spinner_dbk3n_10",Eo={wrapper:Gu,spinner:Hu};function Fu({size:e=28,speed:t=.8}){return x.jsx("div",{className:`${Eo.wrapper}`,children:x.jsx("div",{className:Eo.spinner,style:{width:e,height:e,borderWidth:3,animationDuration:`${t}s`}})})}function Nu(){const e=V(qt(t=>t.sectionLoading===!0));return x.jsx(x.Fragment,{children:e===!0&&x.jsx(Fu,{})})}const Du="_Overlay_ybic8_3",Wu="_Dialog_ybic8_15",qu="_Body_ybic8_25",Vu="_Header_ybic8_32",$u="_Paging_ybic8_39",Uu="_Remaining_ybic8_48",Ku="_RemainingDanger_ybic8_55",Xu="_NextBtn_ybic8_59",Qu="_CloseBtn_ybic8_96",Yu="_Question_ybic8_113",Zu="_Score_ybic8_123",Ju="_Image_ybic8_130",ed="_Options_ybic8_140",td="_OptionBtn_ybic8_145",nd="_OptionBtnActive_ybic8_165",rd="_Footer_ybic8_172",od="_OptionBtnCorrect_ybic8_195",sd="_Judge_ybic8_201",id="_Correct_ybic8_212",ld="_Incorrect_ybic8_215",ad="_ResultHeader_ybic8_220",cd="_ResultActions_ybic8_233",ud="_CloseBtnSoft_ybic8_239",dd="_SummaryGrid_ybic8_249",fd="_StatCard_ybic8_257",pd="_StatLabel_ybic8_265",gd="_StatValue_ybic8_270",hd="_StatSub_ybic8_277",fe={Overlay:Du,Dialog:Wu,Body:qu,Header:Vu,Paging:$u,Remaining:Uu,RemainingDanger:Ku,NextBtn:Xu,CloseBtn:Qu,Question:Yu,Score:Zu,Image:Ju,Options:ed,OptionBtn:td,OptionBtnActive:nd,Footer:rd,OptionBtnCorrect:od,Judge:sd,Correct:id,Incorrect:ld,ResultHeader:ad,ResultActions:cd,CloseBtnSoft:ud,SummaryGrid:dd,StatCard:fd,StatLabel:pd,StatValue:gd,StatSub:hd};function md(e){return e?e.kind==="temp"?e.image_blob_url:e.image_cdn_url:null}function Ps(e){var t;return(((t=e.answers)==null?void 0:t.length)??0)>1}function bd(e){const t=e.answers??[],n=[];return t.forEach(r=>{const o=e.options.findIndex(s=>s===r);o>=0&&n.push(o)}),n.sort((r,o)=>r-o)}const xd=m.memo(function(){const t=Ue(c=>c.phase),n=Ue(c=>c.quizzes),r=Ue(c=>c.order),o=Ue(c=>c.currentIndex),s=Ue(c=>c.answers),i=Ue(c=>c.correctCount),u=Ue(c=>c.remainingSec),a=Ue(c=>c.uiReveal),l=Ue(c=>c.startedAt),d=Ue(c=>c.finishedAt),S=Ue(c=>c.perQ),g=Is();m.useEffect(()=>{if(t==="idle"||t!=="doing"||u==null)return;const c=window.setInterval(()=>g.getState().tick(),1e3);return()=>window.clearInterval(c)},[t,u,g]);const h=t==="doing"?n[r[o]]:void 0,v=t==="doing"&&h?s[h.qid]??[]:[],w=m.useMemo(()=>{if(t==="idle"||t!=="finished")return;const c=r.map(M=>n[M]),f=c.length,p=c.reduce((M,O)=>M+(O.score??0),0),C=c.reduce((M,O)=>{const Q=S[O.qid];return M+(Q!=null&&Q.isCorrect?O.score??0:0)},0),T=c.map(M=>S[M.qid]).filter(M=>!!M),I=typeof l=="number"&&typeof d=="number"?Math.max(0,d-l):T.reduce((M,O)=>M+(O.ms??0),0),j=f>0?Math.round(I/f):0,b=[...T].sort((M,O)=>M.ms-O.ms),y=b[0],k=b[b.length-1],R=T.filter(M=>!M.multi),_=T.filter(M=>M.multi),z=R.filter(M=>M.isCorrect).length,B=_.filter(M=>M.isCorrect).length,E=T.filter(M=>M.timedOut).length,P=T.filter(M=>M.revealed).length,F=T.filter(M=>!M.isCorrect).sort((M,O)=>O.ms-M.ms).slice(0,3);return{total:f,correct:i,rate:f?Math.round(i/f*100):0,timeMsTotal:I,avgMs:j,totalScore:p,gainedScore:C,fastest:y,slowest:k,singles:{total:R.length,correct:z},multis:{total:_.length,correct:B},timedOut:E,revealed:P,wrongTop3:F}},[t,r,n,S,l,d,i]);return t==="idle"?null:x.jsx("div",{className:fe.Overlay,role:"dialog","aria-modal":"true",children:x.jsx("div",{className:fe.Dialog,children:t==="doing"&&h?x.jsx(vd,{q:h,index:o,total:r.length,selected:v,uiReveal:a,onSelect:c=>{if(a)return;const f=g.getState();Ps(h)?f.selectToggle(c):f.selectSingle(c)},onBeforeNext:()=>g.getState().setReveal(!0),onNext:()=>g.getState().afterRevealNext(),remainingSec:u,onClose:()=>g.getState().close()}):x.jsx(Sd,{total:r.length,correct:i,summary:w,retryAllowed:g.getState().retryAllowed,onClose:()=>g.getState().close(),onRetry:()=>{const f=g.getState().quizzes;if(!f.length)return;const p=f[0];g.setState({phase:"doing",currentIndex:0,answers:{},correctCount:0,startedAt:Date.now(),finishedAt:void 0,questionStartedAt:Date.now(),remainingSec:p.limit_sec||void 0,uiReveal:!1,perQ:{}})}})})})});function vd(e){const{q:t,index:n,total:r,selected:o,uiReveal:s,onSelect:i,onBeforeNext:u,onNext:a,remainingSec:l,onClose:d}=e,S=Ps(t),g=m.useMemo(()=>{const c=t.options.map((f,p)=>({opt:f,i:p}));for(let f=c.length-1;f>0;f--){const p=Math.floor(Math.random()*(f+1));[c[f],c[p]]=[c[p],c[f]]}return c},[t.options]),h=m.useMemo(()=>md(t),[t]),v=m.useMemo(()=>bd(t),[t]),w=m.useMemo(()=>{const c=[...o].sort((f,p)=>f-p);if(c.length!==v.length)return!1;for(let f=0;f<c.length;f++)if(c[f]!==v[f])return!1;return!0},[o,v]);return x.jsxs("div",{className:fe.Body,children:[x.jsxs("div",{className:fe.Header,children:[x.jsx("div",{className:fe.Paging,children:`Quiz (${n+1}/${r})`}),x.jsx("button",{type:"button",onClick:d,className:fe.CloseBtn,children:"X"})]}),x.jsx("div",{className:fe.Question,children:t.question}),x.jsx("div",{className:fe.Score,children:` (${t.score}점${S?" ,모두선택":""})`}),x.jsx("div",{className:`${fe.Judge}${s?w?` ${fe.Correct}`:` ${fe.Incorrect}`:""}`,"aria-live":"polite",children:s?w?`Correct : +${t.score} point`:"Incorrect : 0 point":"a"}),x.jsx("div",{className:fe.Image,children:h&&x.jsx("img",{src:h,alt:""})}),x.jsx("div",{className:fe.Options,children:g.map(({opt:c,i:f})=>{const p=o.includes(f),C=v.includes(f),T=[fe.OptionBtn,p?fe.OptionBtnActive:"",s&&C?fe.OptionBtnCorrect:""].filter(Boolean).join(" ");return x.jsx("button",{type:"button",onClick:()=>i(f),className:T,disabled:s,children:c},f)})}),x.jsx("div",{className:fe.Footer,children:s?x.jsx("button",{type:"button",onClick:a,className:fe.NextBtn,children:n+1>=r?"Complete":"Next Quiz"}):x.jsxs("button",{type:"button",onClick:u,className:`${fe.NextBtn}`,children:["Submit",typeof l=="number"&&x.jsx("span",{className:`${fe.Remaining} ${l<=5?fe.RemainingDanger:""}`,children:` (${l} s )`})]})})]})}function jo(e){return e==null?"-":`${Math.round(e/1e3)}s`}function Sd(e){const{total:t,correct:n,summary:r,retryAllowed:o,onClose:s,onRetry:i}=e,u=(r==null?void 0:r.rate)??(t>0?Math.round(n/t*100):0);return x.jsxs("div",{className:fe.Body,children:[x.jsx("div",{className:fe.ResultHeader,children:"결과 요약"}),x.jsxs("div",{className:fe.SummaryGrid,role:"list",children:[x.jsxs("div",{className:fe.StatCard,role:"listitem",children:[x.jsx("div",{className:fe.StatLabel,children:"정답률"}),x.jsxs("div",{className:fe.StatValue,children:[u,"%"]}),x.jsx("div",{className:fe.StatSub,children:`정답수 ${n}/문제수${t}`})]}),x.jsxs("div",{className:fe.StatCard,role:"listitem",children:[x.jsx("div",{className:fe.StatLabel,children:"총 점수"}),x.jsx("div",{className:fe.StatValue,children:r?`${r.gainedScore}/${r.totalScore}`:"-"}),x.jsx("div",{className:fe.StatSub,children:"획득점수/최대점수"})]}),x.jsxs("div",{className:fe.StatCard,role:"listitem",children:[x.jsx("div",{className:fe.StatLabel,children:"총 소요 시간"}),x.jsx("div",{className:fe.StatValue,children:jo(r==null?void 0:r.timeMsTotal)}),x.jsx("div",{className:fe.StatSub,children:`평균 ${jo(r==null?void 0:r.avgMs)}`})]}),x.jsxs("div",{className:fe.StatCard,role:"listitem",children:[x.jsx("div",{className:fe.StatLabel,children:"타입오버 퀴즈수"}),x.jsx("div",{className:fe.StatValue,children:r?`${r.timedOut}`:"-"}),x.jsx("div",{className:fe.StatSub,children:"timeout"})]})]}),x.jsxs("div",{className:fe.ResultActions,children:[o&&x.jsx("button",{type:"button",onClick:i,className:fe.CloseBtnSoft,children:"다시 풀기"}),x.jsx("button",{type:"button",onClick:s,className:fe.CloseBtnSoft,children:"닫기"})]})]})}function yd(e){return e.map((t,n)=>n)}function wd(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Qn(e){var t;return(((t=e.answers)==null?void 0:t.length)??0)>1}function Yn(e){const t=e.answers??[],n=[];return t.forEach(r=>{const o=e.options.findIndex(s=>s===r);o>=0&&n.push(o)}),n.sort((r,o)=>r-o)}function Oo(e){if(!e)return{};const t=(e.quizzes??[]).slice().sort((n,r)=>n.index-r.index);return{sectionId:e.section_id,quizzes:t,order:yd(t),currentIndex:0,answers:{},correctCount:0,startedAt:void 0,finishedAt:void 0,questionStartedAt:void 0,remainingSec:void 0,uiReveal:!1,perQ:{}}}function Cd(e,t){const n=(t==null?void 0:t.retryAllowed)??!0,r=(t==null?void 0:t.previousResult)??null,o={phase:"idle",sectionId:void 0,quizzes:[],order:[],currentIndex:0,answers:{},correctCount:0,startedAt:void 0,finishedAt:void 0,questionStartedAt:void 0,remainingSec:void 0,uiReveal:!1,perQ:{},retryAllowed:n,previousResult:r},s=Oo(e);return Vt()((u,a)=>({...o,...s,hydrateFromSection:l=>{if(!l)return;const d=Oo(l);u(d)},openFromSection:l=>{l&&a().hydrateFromSection(l);const d=a();if(!d.quizzes.length)return;if(!d.retryAllowed&&d.previousResult){const g={};for(const h of d.previousResult.perQuestion)g[h.qid]={qid:h.qid,index:h.index,question:h.question,score:h.score,multi:h.correctIdxes.length>1,selected:h.selected,correctIdxes:h.correctIdxes,isCorrect:h.isCorrect,ms:h.ms,revealed:!0,timedOut:h.timedOut};u({phase:"finished",correctCount:d.previousResult.correct,perQ:g,startedAt:void 0,finishedAt:void 0});return}const S=d.quizzes[0];u({phase:"doing",startedAt:Date.now(),finishedAt:void 0,questionStartedAt:Date.now(),remainingSec:S.limit_sec||void 0,currentIndex:0,uiReveal:!1})},close:()=>{u({phase:"idle",sectionId:void 0,quizzes:[],order:[],currentIndex:0,answers:{},correctCount:0,startedAt:void 0,finishedAt:void 0,questionStartedAt:void 0,remainingSec:void 0,uiReveal:!1,perQ:{}})},selectToggle:l=>{const d=a();if(d.phase!=="doing"||d.uiReveal)return;const g=d.quizzes[d.order[d.currentIndex]].qid,h=d.answers[g]??[],v=h.includes(l)?h.filter(w=>w!==l):[...h,l].sort((w,c)=>w-c);u({answers:{...d.answers,[g]:v}})},selectSingle:l=>{const d=a();if(d.phase!=="doing"||d.uiReveal)return;const g=d.quizzes[d.order[d.currentIndex]].qid;u({answers:{...d.answers,[g]:[l]}})},submitCurrent:()=>{const l=a();if(l.phase!=="doing")return;const d=l.order[l.currentIndex],S=l.quizzes[d],g=S.qid,h=(l.answers[g]??[]).slice().sort((C,T)=>C-T),v=Yn(S),w=wd(h,v),c=l.questionStartedAt?Date.now()-l.questionStartedAt:0,f=l.perQ[g],p={qid:g,index:S.index,question:S.question,score:S.score??0,multi:Qn(S),selected:h,correctIdxes:v,isCorrect:w,ms:c,revealed:(f==null?void 0:f.revealed)??!1,timedOut:(f==null?void 0:f.timedOut)??!1};if(u({correctCount:l.correctCount+(w?1:0),perQ:{...l.perQ,[g]:p}}),l.currentIndex+1>=l.order.length)u({uiReveal:!1,remainingSec:void 0}),a().finish();else{const C=l.currentIndex+1;u({currentIndex:C,questionStartedAt:Date.now(),remainingSec:l.quizzes[l.order[C]].limit_sec||void 0,uiReveal:!1})}},setReveal:l=>{const d=a();if(d.phase==="doing"){if(l){const S=d.quizzes[d.order[d.currentIndex]],g=S.qid,h=d.perQ[g],v={qid:g,index:S.index,question:S.question,score:S.score??0,multi:Qn(S),selected:(h==null?void 0:h.selected)??[],correctIdxes:(h==null?void 0:h.correctIdxes)??Yn(S),isCorrect:(h==null?void 0:h.isCorrect)??!1,ms:(h==null?void 0:h.ms)??0,revealed:!0,timedOut:(h==null?void 0:h.timedOut)??!1};u({perQ:{...d.perQ,[g]:v}})}u({uiReveal:l})}},afterRevealNext:()=>{a().phase==="doing"&&a().submitCurrent()},next:()=>{const l=a();if(l.phase!=="doing"||l.currentIndex+1>=l.order.length)return;const d=l.currentIndex+1;u({currentIndex:d,questionStartedAt:Date.now(),remainingSec:l.quizzes[l.order[d]].limit_sec||void 0,uiReveal:!1})},prev:()=>{const l=a();if(l.phase!=="doing"||l.currentIndex<=0)return;const d=l.currentIndex-1;u({currentIndex:d,questionStartedAt:Date.now(),remainingSec:l.quizzes[l.order[d]].limit_sec||void 0,uiReveal:!1})},finish:()=>{u({phase:"finished",remainingSec:void 0,uiReveal:!1,finishedAt:Date.now()})},tick:()=>{const l=a();if(l.phase!=="doing"||l.remainingSec==null)return;const d=l.remainingSec-1;if(d<=0){const S=l.quizzes[l.order[l.currentIndex]],g=S.qid,h=l.perQ[g],v={qid:g,index:S.index,question:S.question,score:S.score??0,multi:Qn(S),selected:(h==null?void 0:h.selected)??[],correctIdxes:(h==null?void 0:h.correctIdxes)??Yn(S),isCorrect:(h==null?void 0:h.isCorrect)??!1,ms:(h==null?void 0:h.ms)??0,revealed:!0,timedOut:!0};u({remainingSec:0,uiReveal:!0,perQ:{...l.perQ,[g]:v}})}else u({remainingSec:d})}}))}function Id({children:e,initialState:t}){const n=m.useMemo(()=>Cd(t.section,{retryAllowed:t.quizRetryAllowed??!0,previousResult:t.previousQuizResult??null}),[t]),r=m.useRef(t.onQuizStart),o=m.useRef(t.onQuizComplete);return m.useEffect(()=>{r.current=t.onQuizStart},[t.onQuizStart]),m.useEffect(()=>{o.current=t.onQuizComplete},[t.onQuizComplete]),m.useEffect(()=>{const s=n.subscribe((i,u)=>{var a;if(u.phase!=="doing"&&i.phase==="doing"&&((a=r.current)==null||a.call(r)),u.phase!=="finished"&&i.phase==="finished"){const l=o.current;if(!l||!i.retryAllowed&&i.previousResult&&!i.startedAt)return;const{sectionId:d,quizzes:S,order:g,perQ:h,startedAt:v,finishedAt:w}=i,c=g.map(y=>S[y]),f=c.length,p=c.filter(y=>{var k;return(k=h[y.qid])==null?void 0:k.isCorrect}).length,C=c.reduce((y,k)=>y+(k.score??0),0),T=c.reduce((y,k)=>{const R=h[k.qid];return y+(R!=null&&R.isCorrect?k.score??0:0)},0),I=typeof v=="number"&&typeof w=="number"?Math.max(0,w-v):0,j=c.map(y=>{const k=h[y.qid];return{qid:y.qid,index:y.index,question:y.question,score:y.score??0,isCorrect:(k==null?void 0:k.isCorrect)??!1,selected:(k==null?void 0:k.selected)??[],correctIdxes:(k==null?void 0:k.correctIdxes)??[],ms:(k==null?void 0:k.ms)??0,timedOut:(k==null?void 0:k.timedOut)??!1}}),b={sectionId:d??"",total:f,correct:p,rate:f>0?Math.round(p/f*100):0,totalScore:C,gainedScore:T,timeMsTotal:I,perQuestion:j};l(b)}});return()=>s()},[n]),x.jsx(wr.Provider,{value:n,children:e})}const zo=["mode","theme","fontFamily","fontSizePx","lineHeight","marginX","marginY","pointerStyle","pointerColor","breakMarks","breakGapPx","muteAudio","audioSpeed","showPointer","showSplit","showOverlays","overlayCompactMode","isSettingsOpen"];function Td({containerRef:e}){const t=bt(),n=gn(),r=m.useRef(null);return m.useEffect(()=>{const o=e.current;if(!o)return;let s=o.clientWidth,i=o.clientHeight;n.getState().setViewportSize(s,i);const u=new ResizeObserver(()=>{const a=o.clientWidth,l=o.clientHeight;(a!==s||l!==i)&&(s=a,i=l,n.getState().setViewportSize(a,l),t.getState().emit({type:"viewport_resize",payload:{width:a,height:l}}))});return u.observe(o),()=>u.disconnect()},[t,n,e]),m.useEffect(()=>{const o=n.getState();r.current={};for(const i of zo)r.current[i]=o[i];const s=n.subscribe(i=>{const u=r.current;if(u)for(const a of zo){const l=u[a],d=i[a];l!==d&&(a==="mode"?t.getState().emit({type:"mode_change",payload:{mode:d}}):t.getState().emit({type:"settings_change",payload:{key:a,value:d}}),u[a]=d)}});return()=>{s(),r.current=null}},[t,n]),null}function kd(){const e=bt(),t=gn(),n=lt(),r=m.useContext(Lo),o=m.useContext(vn),s=m.useCallback(a=>{const{viewerState:l}=a;if(l){l.mode&&t.getState().setMode(l.mode);const{...g}=l;t.setState(g)}if(typeof a.globalIndex=="number"&&n.getState().progress.setCurrentGlobalRunIndex(a.globalIndex,"playback"),(l==null?void 0:l.mode)==="scroll"||!(l!=null&&l.mode)){const g=()=>{const h=n.getState().progress.getSectionScrollApi();if(!h)return!1;if(a.scrollY===0)h.setScrollTop(0);else if(h.scrollToGIAtOffset){const v=a.anchorGI??a.globalIndex;if(typeof v=="number"){const w=a.anchorOffsetRatio??0;h.scrollToGIAtOffset(v,w)}}return!0};if(!g()){let h=0;const v=setInterval(()=>{(g()||++h>=10)&&clearInterval(v)},50)}}a.audio&&o&&o.getState()._setStatusOnly(a.audio.status);const S=n.getState().progress;a.range?S.setRange(a.range.startGI,a.range.endGI):S.clearRange(),a.translate&&a.translate.isOpen?S.setTranslateState({isOpen:!0,isLoading:a.translate.isLoading,text:a.translate.text,translatedText:a.translate.translatedText,startGI:a.translate.startGI,endGI:a.translate.endGI}):S.clearTranslate()},[t,n,o]),i=m.useCallback(()=>{var I,j,b,y;const a=t.getState(),l=n.getState().progress,d=(I=l.getSectionScrollApi)==null?void 0:I.call(l),S=l.currentGlobalRunIndex??0,g=((j=d==null?void 0:d.getScrollTop)==null?void 0:j.call(d))??0,h=((b=d==null?void 0:d.getAnchorOffsetRatio)==null?void 0:b.call(d,S))??0,v=o==null?void 0:o.getState(),w=v?{status:v.status,currentClip:v.currentClip,currentTimeMs:v.currentTimeMs}:void 0,{rangeStartGI:c,rangeEndGI:f}=l,p=c!=null&&f!=null?{startGI:c,endGI:f,text:l.getRangeText()}:null,C=((y=d==null?void 0:d.getScrollRatio)==null?void 0:y.call(d))??0,T=l.translateOpen?{isOpen:!0,isLoading:l.translateLoading,text:l.translateText,translatedText:l.translatedText,startGI:l.translateStartGI,endGI:l.translateEndGI}:null;return{viewerState:{mode:a.mode,theme:a.theme,fontFamily:a.fontFamily,fontSizePx:a.fontSizePx,lineHeight:a.lineHeight,marginX:a.marginX,marginY:a.marginY,showOverlays:a.showOverlays,isSettingsOpen:a.isSettingsOpen,pointerStyle:a.pointerStyle,pointerColor:a.pointerColor,breakMarks:a.breakMarks,breakGapPx:a.breakGapPx,muteAudio:a.muteAudio,audioSpeed:a.audioSpeed,showPointer:a.showPointer,showSplit:a.showSplit,overlayCompactMode:a.overlayCompactMode,viewportWidth:a.viewportWidth,viewportHeight:a.viewportHeight},globalIndex:S,scrollY:g,scrollRatio:C,anchorGI:S,anchorOffsetRatio:h,currentPage:l.pageIndex??0,totalPages:l.totalPages,sectionId:l.sectionId??"",viewportWidth:a.viewportWidth,viewportHeight:a.viewportHeight,audio:w,range:p,translate:T}},[t,n,o]),u=m.useCallback(a=>{switch(a.type){case"global_index_change":{const{globalIndex:l}=a.payload;n.getState().progress.setCurrentGlobalRunIndex(l,"playback");break}case"scroll":{if(t.getState().mode==="page")break;const{scrollTop:d,anchorGI:S,anchorOffsetRatio:g}=a.payload,h=n.getState().progress.getSectionScrollApi();if(!h)break;d===0?h.setScrollTop(0):h.scrollToGIAtOffset&&typeof S=="number"&&h.scrollToGIAtOffset(S,g);break}case"settings_change":{const{key:l,value:d}=a.payload,S=t.getState();l in S&&typeof S[l]!="function"&&t.setState({[l]:d});break}case"mode_change":{const{mode:l}=a.payload;t.getState().setMode(l);break}case"audio_control":{if(!o)break;const{action:l}=a.payload;switch(l){case"play":o.getState()._setStatusOnly("playing");break;case"pause":o.getState()._setStatusOnly("paused");break;case"stop":o.getState()._setStatusOnly("idle");break}break}case"page_change":{const{pageIndex:l}=a.payload;n.getState().progress.setPageIndex(l);break}case"range_select":case"range_change":{const{startGI:l,endGI:d}=a.payload;n.getState().progress.setRange(l,d),n.getState().progress;break}case"range_clear":{n.getState().progress.clearRange();break}case"translate_request":{const{text:l,startGI:d,endGI:S}=a.payload;n.getState().progress.setTranslateState({isOpen:!0,isLoading:!0,text:l,startGI:d,endGI:S});break}case"translate_loading_start":{n.getState().progress.setTranslateState({isOpen:!0,isLoading:!0});break}case"translate_loading_end":{const{originalText:l,translatedText:d}=a.payload;n.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,text:l,translatedText:d});break}case"translate_modal_close":{n.getState().progress.clearTranslate();break}case"render_start":case"loading_start":case"loading_end":case"viewport_resize":break;default:console.log("[DirectPlaybackController] 미처리 이벤트:",a.type)}},[n,t,o]);return m.useLayoutEffect(()=>r?(r.current={dispatch:u,applySnapshot:s,getSnapshot:i,isReady:()=>!n.getState().progress.sectionLoading,waitUntilReady:()=>new Promise(l=>{if(!n.getState().progress.sectionLoading){l();return}const d=n.subscribe(S=>{S.progress.sectionLoading||(d(),l())})})},e.getState().isPlaybackMode&&(e.getState().setDispatchHandler(u),e.getState().setApplySnapshotHandler(s)),()=>{e.getState().setDispatchHandler(null),e.getState().setApplySnapshotHandler(null)}):void 0,[r,e,u,s,i,n]),m.useLayoutEffect(()=>e.subscribe((l,d)=>{l.isPlaybackMode&&!d.isPlaybackMode?(e.getState().setDispatchHandler(u),e.getState().setApplySnapshotHandler(s)):!l.isPlaybackMode&&d.isPlaybackMode&&(e.getState().setDispatchHandler(null),e.getState().setApplySnapshotHandler(null))}),[e,u,s]),null}function Rd(e){const t=e.querySelectorAll("[data-gi]");if(t.length<2)return 0;const n=[];let r=null,o=-1/0;for(let s=0;s<t.length;s++){const i=t[s].getBoundingClientRect();if(r&&Math.abs(i.top-o)<i.height*.5){const u=i.left-r.right;u>=0&&n.push(u)}r=i,o=i.top}return n.length===0?0:n.reduce((s,i)=>s+i,0)/n.length}function _d({containerRef:e}){const t=X(d=>d.fontSizePx),n=X(d=>d.fontFamily),r=X(d=>d.lineHeight),o=X(d=>d.marginX),s=X(d=>d.breakMarks),i=X(d=>d.breakGapPx),u=X(d=>d.showSplit),a=X(d=>d.viewportWidth),l=bt();return m.useEffect(()=>{const d=e.current;if(!d)return;let S;const g=requestAnimationFrame(()=>{S=requestAnimationFrame(()=>{const h=Rd(d);l.setState({wordAvgDistancePx:h})})});return()=>{cancelAnimationFrame(g),cancelAnimationFrame(S)}},[e,l,t,n,r,o,s,i,u,a]),null}const Md=({containerRef:e,onTranslate:t})=>{const n=V(g=>g.rangeStartGI),r=V(g=>g.rangeEndGI),o=V(g=>g.getRangeText),s=V(g=>g.clearRange),i=bt(),u=n!=null&&r!=null,[a,l]=m.useState(null);m.useEffect(()=>{if(!u)return;const g=e.current;if(!g)return;let h=!0;const v=new ResizeObserver(()=>{if(h){h=!1;return}s()});return v.observe(g),()=>v.disconnect()},[u,s,e]),m.useEffect(()=>{if(!u||n==null||r==null){l(null);return}const g=()=>{const c=e.current;if(!c)return;const f=c.getBoundingClientRect(),C=1/(i.getState().playbackScale||1),T=c.querySelector(`[data-g="${r}"]`);if(!T){l({x:f.width*C/2,y:80});return}const I=T.getBoundingClientRect(),j=c.querySelector(`[data-g="${n}"]`),b=j==null?void 0:j.getBoundingClientRect();let y=(I.left+I.width/2-f.left)*C;b&&(y=((b.left+I.right)/2-f.left)*C);const k=160,R=50,_=16,z=12,B=f.width*C,E=Math.max(_+k/2,Math.min(y,B-_-k/2)),P=(((b==null?void 0:b.top)??I.top)-f.top)*C-R-z;let F=P;P<_&&(F=(I.bottom-f.top)*C+z),l({x:E,y:F})};g();const h=e.current;let v=0;const w=()=>{v||(v=requestAnimationFrame(()=>{v=0,g()}))};return h&&h.addEventListener("scroll",w,!0),()=>{v&&cancelAnimationFrame(v),h&&h.removeEventListener("scroll",w,!0)}},[u,n,r,e,i]);const d=m.useCallback(()=>{const g=o();g&&navigator.clipboard.writeText(g).catch(h=>{console.error("복사 실패:",h)}),s()},[o,s]),S=m.useCallback(()=>{const g=o();g&&t&&t(g)},[o,t]);return!u||!a?null:x.jsxs("div",{"data-range-menu":!0,style:{position:"absolute",left:a.x,top:a.y,transform:"translateX(-50%)",display:"flex",gap:8,padding:"8px 12px",backgroundColor:"#fff",borderRadius:8,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.3)",zIndex:1e4},children:[x.jsx("button",{onClick:d,style:{padding:"8px 16px",backgroundColor:"#3b82f6",color:"#fff",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:"pointer",whiteSpace:"nowrap"},children:"복사"}),x.jsx("button",{onClick:S,style:{padding:"8px 16px",backgroundColor:"#10b981",color:"#fff",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:"pointer",whiteSpace:"nowrap"},children:"번역"})]})},Ed="_handleStart_1ihf3_16 _handle_1ihf3_1",jd="_handleEnd_1ihf3_21 _handle_1ihf3_1",Ao={handleStart:Ed,handleEnd:jd},Od=({containerRef:e})=>{const t=V(c=>c.rangeStartGI),n=V(c=>c.rangeEndGI),r=V(c=>c.setRange),o=bt(),s=t!=null&&n!=null,[i,u]=m.useState(null),[a,l]=m.useState(null),d=m.useRef(null),S=m.useRef({startGI:t,endGI:n});S.current={startGI:t,endGI:n};const g=m.useRef(r);g.current=r,m.useEffect(()=>{if(!s||t==null||n==null){u(null),l(null);return}const c=()=>{const p=e.current;if(!p)return;const C=p.getBoundingClientRect(),I=1/(o.getState().playbackScale||1),j=p.querySelector(`[data-g="${t}"]`),b=p.querySelector(`[data-g="${n}"]`);if(j){const y=j.getBoundingClientRect();u({x:(y.left-C.left)*I,y:(y.bottom-C.top)*I})}else u(null);if(b){const y=b.getBoundingClientRect();l({x:(y.right-C.left)*I,y:(y.bottom-C.top)*I})}else l(null)};c();const f=e.current;return f&&f.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{f&&f.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[s,t,n,e,o]);const h=m.useCallback((c,f)=>{var C;const p=document.elementsFromPoint(c,f);for(const T of p){const I=(C=T.getAttribute)==null?void 0:C.call(T,"data-g");if(I!=null)return parseInt(I,10)}return null},[]);m.useEffect(()=>{const c=p=>{if(!d.current)return;const{startGI:C,endGI:T}=S.current;if(C==null||T==null)return;const I=h(p.clientX,p.clientY);I!=null&&(d.current==="start"?I<=T?g.current(I,T):(g.current(T,I),d.current="end"):I>=C?g.current(C,I):(g.current(I,C),d.current="start"))},f=()=>{d.current=null,setTimeout(()=>{Zr(!1)},50)};return document.addEventListener("pointermove",c),document.addEventListener("pointerup",f),document.addEventListener("pointercancel",f),()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",f),document.removeEventListener("pointercancel",f)}},[h]);const v=m.useCallback(c=>f=>{f.preventDefault(),f.stopPropagation(),d.current=c,Zr(!0)},[]);return s?x.jsxs(x.Fragment,{children:[i&&x.jsx("div",{className:Ao.handleStart,"data-range-handle":"start",style:{left:i.x-26,top:i.y},onPointerDown:v("start")}),a&&x.jsx("div",{className:Ao.handleEnd,"data-range-handle":"end",style:{left:a.x,top:a.y},onPointerDown:v("end")})]}):null};function zd(){const e=V(o=>o.rangeStartGI),t=V(o=>o.rangeEndGI),n=V(o=>o.clearRange),r=e!=null&&t!=null;return m.useEffect(()=>{if(!r)return;const o=s=>{var u;if(Ss())return;const i=s.target;if(!(i.closest("[data-range-menu]")||i.closest("[data-range-handle]"))){if(i.closest("[data-g]")){const a=(u=i.closest("[data-g]"))==null?void 0:u.getAttribute("data-g");if(a){const l=parseInt(a,10),d=Math.min(e,t),S=Math.max(e,t);if(l>=d&&l<=S)return}}n()}};return document.addEventListener("click",o,!0),()=>document.removeEventListener("click",o,!0)},[r,e,t,n]),null}const Ad=({isOpen:e,isLoading:t=!1,onClose:n,text:r,translatedText:o})=>e?x.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:10001},onClick:n,children:x.jsxs("div",{style:{position:"relative",backgroundColor:"#fff",borderRadius:12,padding:"24px 32px",minWidth:280,maxWidth:"80%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.2)"},onClick:s=>s.stopPropagation(),children:[x.jsx("button",{onClick:n,style:{position:"absolute",top:12,right:12,width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"transparent",border:"none",borderRadius:"50%",cursor:"pointer",fontSize:20,color:"#666"},"aria-label":"닫기",children:"✕"}),x.jsx("h3",{style:{margin:"0 0 16px 0",fontSize:18,fontWeight:600,color:"#333"},children:"번역"}),r&&x.jsx("div",{style:{padding:12,backgroundColor:"#f5f5f5",borderRadius:8,fontSize:14,color:"#555",maxHeight:100,overflow:"auto",marginBottom:12},children:r}),t?x.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"16px 0",gap:8,color:"#888",fontSize:15},children:[x.jsx("span",{style:{display:"inline-block",width:18,height:18,border:"2px solid #ccc",borderTopColor:"#3b82f6",borderRadius:"50%",animation:"cr-translate-spin 0.8s linear infinite"}}),"번역 중...",x.jsx("style",{children:"@keyframes cr-translate-spin { to { transform: rotate(360deg); } }"})]}):o?x.jsx("div",{style:{padding:12,backgroundColor:"#eef7ff",borderRadius:8,fontSize:15,color:"#333",maxHeight:150,overflow:"auto",lineHeight:1.5},children:o}):x.jsx("p",{style:{margin:0,fontSize:16,color:"#666",textAlign:"center",padding:"16px 0"},children:"준비중입니다"})]})}):null,Pd=(e,t,n)=>Math.min(n,Math.max(t,e));function Bd({section:e,initialViewerState:t,initialProgressRunIndex:n,onViewerClose:r,onSectionNav:o,isCanPrev:s=!1,isCanNext:i=!1,onQuizStart:u,onQuizComplete:a,quizRetryAllowed:l,previousQuizResult:d,onViewerEvent:S,viewerRef:g,gazeSync:h,onRequestTranslate:v,isPlaybackMode:w=!1,playbackScale:c,isDev:f=!1}){const p=String((e==null?void 0:e.section_id)??"0"),C=m.useMemo(()=>{var k,R;const b=((k=e==null?void 0:e.ast)==null?void 0:k.blocks)??[];let y=0;for(const _ of b)(_==null?void 0:_.type)!=="image"&&(y+=((R=_==null?void 0:_.runs)==null?void 0:R.length)??0);return y},[e]),T=m.useMemo(()=>typeof n=="number"?Pd(n,C>0?0:-1,Math.max(C-1,-1)):(C>0,0),[n,C]),I=m.useMemo(()=>({section:e,initialIndex:T,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i}),[e,T,r,o,s,i]),j=m.useMemo(()=>{const b=(e==null?void 0:e.audios)??[],y=b.length>0?ru(e):void 0;return{clips:b,map:y,initialIndex:T,section:e}},[e,T]);return x.jsx(Qs,{onViewerEvent:S,isPlaybackMode:w,playbackScale:c,viewerRef:g,children:x.jsx(cu,{initialState:{...t,isDev:f},children:x.jsx(au,{initialState:I,gazeSync:h,children:x.jsx(nu,{initialState:j,children:x.jsx(Id,{initialState:{section:e,onQuizStart:u,onQuizComplete:a,quizRetryAllowed:l,previousQuizResult:d},children:x.jsx(Ld,{onRequestTranslate:v})},p)},p)},p)})})}function Ld({onRequestTranslate:e}){const t=X(v=>v.mode),n=m.useRef(null),r=bt(),o=lt();m.useEffect(()=>{if(t==="scroll"){const{progress:v}=o.getState();v.setTotalPages(0),v.setPageIndex(0)}},[t,o]);const s=V(v=>v.translateOpen),i=V(v=>v.translateLoading),u=V(v=>v.translateText),a=V(v=>v.translatedText),l=m.useRef(null),d=m.useCallback(v=>{var T;const{rangeStartGI:w,rangeEndGI:c}=o.getState().progress,f=w??0,p=c??0;if(r.getState().emit({type:"translate_request",payload:{text:v,startGI:f,endGI:p}}),!e){o.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,text:v,startGI:f,endGI:p});return}o.getState().progress.setTranslateState({isOpen:!0,isLoading:!0,text:v,startGI:f,endGI:p}),(T=l.current)==null||T.abort();const C=new AbortController;l.current=C,e(v,C.signal).then(I=>{if(!C.signal.aborted){if(I==null){o.getState().progress.clearTranslate();return}o.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,text:v,translatedText:I,startGI:f,endGI:p}),r.getState().emit({type:"translate_loading_end",payload:{originalText:v,translatedText:I}})}}).catch(I=>{if(C.signal.aborted)return;const j=I instanceof Error?I.message:"번역 실패";o.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,text:v,translatedText:`[오류] ${j}`,startGI:f,endGI:p})})},[r,o,e]),S=m.useCallback(()=>{var v;(v=l.current)==null||v.abort(),l.current=null,o.getState().progress.clearTranslate(),r.getState().emit({type:"translate_modal_close",payload:{}})},[r,o]),g=v=>{v.preventDefault()},h=v=>{v.preventDefault()};return x.jsxs("div",{ref:n,onContextMenu:g,onDragStart:h,style:{position:"relative",display:"flex",flexDirection:"column",height:"100%",width:"100%",WebkitTextSizeAdjust:"100%",textSizeAdjust:"100%",userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"none"},children:[t==="scroll"?x.jsx(va,{}):x.jsx(Bu,{}),x.jsx(Md,{containerRef:n,onTranslate:d}),x.jsx(Od,{containerRef:n}),x.jsx(Xc,{}),x.jsx(xd,{}),x.jsx(Nu,{}),x.jsx(zd,{}),x.jsx(Ad,{isOpen:s,isLoading:i,onClose:S,text:u,translatedText:a}),x.jsx(Td,{containerRef:n}),x.jsx(kd,{}),x.jsx(_d,{containerRef:n})]})}exports.CRViewer=Bd;
|
|
34
|
+
*/var Mr;function Ws(){return Mr||(Mr=1,process.env.NODE_ENV!=="production"&&(function(){function e(l,d){return l===d&&(l!==0||1/l===1/d)||l!==l&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=m,n=Bo(),r=typeof Object.is=="function"?Object.is:e,o=n.useSyncExternalStore,s=t.useRef,i=t.useEffect,u=t.useMemo,a=t.useDebugValue;In.useSyncExternalStoreWithSelector=function(l,d,S,h,g){var v=s(null);if(v.current===null){var w={hasValue:!1,value:null};v.current=w}else w=v.current;v=u(function(){function f(j){if(!p){if(p=!0,C=j,j=h(j),g!==void 0&&w.hasValue){var b=w.value;if(g(b,j))return T=b}return T=j}if(b=T,r(C,j))return b;var y=h(j);return g!==void 0&&g(b,y)?(C=j,b):(C=j,T=y)}var p=!1,C,T,I=S===void 0?null:S;return[function(){return f(d())},I===null?void 0:function(){return f(I())}]},[d,S,h,g]);var c=o(l,v[0],v[1]);return i(function(){w.hasValue=!0,w.value=c},[c]),a(c),c},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),In}var Er;function qs(){return Er||(Er=1,process.env.NODE_ENV==="production"?Yt.exports=Ds():Yt.exports=Ws()),Yt.exports}var Vs=qs();const $s=Po(Vs),jr=e=>{let t;const n=new Set,r=(l,d)=>{const S=typeof l=="function"?l(t):l;if(!Object.is(S,t)){const h=t;t=d??(typeof S!="object"||S===null)?S:Object.assign({},t,S),n.forEach(g=>g(t,h))}},o=()=>t,u={setState:r,getState:o,getInitialState:()=>a,subscribe:l=>(n.add(l),()=>n.delete(l))},a=t=e(r,o,u);return u},Vt=(e=>e?jr(e):jr),{useSyncExternalStoreWithSelector:Us}=$s,Ks=e=>e;function $t(e,t=Ks,n){const r=Us(e.subscribe,e.getState,e.getInitialState,t,n);return m.useDebugValue(r),r}function X(e,t){const n=m.useContext(ir);if(!n)throw new Error("useCRViewerScopedStore must be used inside <InternalCRViewerProvider>");return $t(n,e,t)}function gn(){const e=m.useContext(ir);if(!e)throw new Error("useCRViewerStoreApi must be used inside <InternalCRViewerProvider>");return e}const mt=m.createContext(void 0),Lo=m.createContext(void 0);function Xs(){return Vt((e,t)=>({emitCallback:null,isPlaybackMode:!1,playbackScale:1,dispatchHandler:null,applySnapshotHandler:null,wordAvgDistancePx:0,setEmitCallback:n=>e({emitCallback:n}),emit:(n,r)=>{const{emitCallback:o,isPlaybackMode:s}=t();s||o&&o({...n,timestamp:r??Date.now()})},setPlaybackMode:n=>e({isPlaybackMode:n}),setPlaybackScale:n=>e({playbackScale:n}),setDispatchHandler:n=>e({dispatchHandler:n}),dispatch:n=>{const{dispatchHandler:r,isPlaybackMode:o}=t();if(!o){console.warn("[ViewerEventBridge] dispatch called but not in playback mode");return}r?r(n):console.warn("[ViewerEventBridge] dispatch called but no handler registered")},setApplySnapshotHandler:n=>e({applySnapshotHandler:n}),applySnapshot:n=>{const{applySnapshotHandler:r,isPlaybackMode:o}=t();if(!o){console.warn("[ViewerEventBridge] applySnapshot called but not in playback mode");return}r?r(n):console.warn("[ViewerEventBridge] applySnapshot called but no handler registered")}}))}function Qs({children:e,onViewerEvent:t,isPlaybackMode:n=!1,playbackScale:r=1,viewerRef:o}){const s=m.useMemo(()=>Xs(),[]);return m.useLayoutEffect(()=>(s.getState().setEmitCallback(t??null),()=>s.getState().setEmitCallback(null)),[t,s]),m.useLayoutEffect(()=>{s.getState().setPlaybackMode(n)},[n,s]),m.useLayoutEffect(()=>{s.getState().setPlaybackScale(r)},[r,s]),m.useLayoutEffect(()=>()=>{o&&(o.current=null)},[o]),x.jsx(mt.Provider,{value:s,children:x.jsx(Lo.Provider,{value:o,children:e})})}function Go(e,t){const n=m.useContext(mt);if(!n)throw new Error("useViewerEventBridgeStore must be used inside <ViewerEventBridgeProvider>");return $t(n,e,t)}function bt(){const e=m.useContext(mt);if(!e)throw new Error("useViewerEventBridgeStoreApi must be used inside <ViewerEventBridgeProvider>");return e}const lr=m.createContext(void 0);function lt(){const e=m.useContext(lr);if(!e)throw new Error("useProgressStoreApi must be used within InternalCRViewerProgressProvider");return e}function V(e,t){const n=m.useContext(lr);if(!n)throw new Error("useProgressStore must be used within InternalCRViewerProgressProvider");return $t(n,o=>e(o.progress),t)}function Ys({onSingle:e,onDouble:t,delay:n=250,shouldIgnoreTarget:r}){const o=m.useRef(null);m.useEffect(()=>()=>{o.current!=null&&(clearTimeout(o.current),o.current=null)},[]);const s=m.useCallback(u=>{if(!(r!=null&&r(u.target))&&u.detail===1){if(o.current!=null)return;o.current=window.setTimeout(()=>{o.current=null,e==null||e(u)},n)}},[n,e,r]),i=m.useCallback(u=>{r!=null&&r(u.target)||o.current!=null&&(clearTimeout(o.current),o.current=null)},[t,r]);return{onClick:s,onDoubleClick:i}}const sn={light:{bg:"#ffffff",fg:"#111827",overlayBg:"#ffffff",overlayFg:"#111827",borderColor:"#333333"},dark:{bg:"#0b0b0b",fg:"#e5e7eb",overlayBg:"#0b0b0b",overlayFg:"#e5e7eb",borderColor:"#ffffff"},sepia:{bg:"#f4ecd8",fg:"#3e2f1c",overlayBg:"#f4ecd8",overlayFg:"#3e2f1c",borderColor:"#bfa87a"},green:{bg:"#e9f5e1",fg:"#1b3d1f",overlayBg:"#e9f5e1",overlayFg:"#1b3d1f",borderColor:"#93b48b"}},Tn=[8,16,24,40,64],kn=[1.2,1.4,1.6,1.8,2,2.2,2.4],Rn=[4,8,12,16,24],Zn=e=>Math.round(12+(e-1)*(16/11)),Zs=e=>{let t=1,n=1/0;for(let r=1;r<=12;r++){const o=Zn(r),s=Math.abs(o-e);s<n&&(t=r,n=s)}return t},_n=(e,t)=>{let n=0,r=1/0;return t.forEach((o,s)=>{const i=Math.abs(o-e);i<r&&(r=i,n=s)}),n+1},Ho=[{label:"고딕체",value:"'Noto Sans KR', sans-serif"},{label:"명조체",value:"'Noto Serif KR', serif"},{label:"바탕체",value:"'Nanum Myeongjo', serif"}],He={mode:"page",theme:"light",fontFamily:Ho.find(e=>e.label==="명조체").value,fontSizePx:18,lineHeight:1.8,marginX:20,marginY:24,showOverlays:!0,overlayCompactMode:!0,isSettingsOpen:!1,pointerStyle:"highlight",pointerColor:"#fff59d",breakMarks:{slash:!0},breakGapPx:8,muteAudio:!1,audioSpeed:1,showPointer:!0,showSplit:!0,viewportWidth:0,viewportHeight:0,isDev:!1};function Js(e){const{init:t,recorderStore:n}=e??{};return Vt((r,o)=>({...He,...t,setMode:s=>r({mode:s}),setTheme:s=>r({theme:s}),setFontFamily:s=>r({fontFamily:s}),setFontSizePx:s=>r({fontSizePx:s}),setLineHeight:s=>r({lineHeight:s}),setMarginX:s=>r({marginX:s}),setMarginY:s=>r({marginY:s}),setShowOverlays:s=>r({showOverlays:s}),toggleOverlays:()=>{const s=!o().showOverlays;r({showOverlays:s,...s&&{overlayCompactMode:!0}})},setOverlayCompactMode:s=>r({overlayCompactMode:s}),toggleOverlayCompactMode:()=>r({overlayCompactMode:!o().overlayCompactMode}),setSettingsOpen:s=>r({isSettingsOpen:s}),resetToDefaults:()=>r(s=>({mode:He.mode,theme:He.theme,fontFamily:He.fontFamily,fontSizePx:He.fontSizePx,lineHeight:He.lineHeight,marginX:He.marginX,marginY:He.marginY,showOverlays:!1,isSettingsOpen:!0,pointerStyle:He.pointerStyle,pointerColor:He.pointerColor,breakMarks:He.breakMarks,breakGapPx:He.breakGapPx,muteAudio:He.muteAudio,audioSpeed:He.audioSpeed,showPointer:He.showPointer,showSplit:He.showSplit})),maps:{MARGIN_MAP:Tn,LINEHEIGHT_MAP:kn,BREAK_GAP_MAP:Rn,fontSizeFromLevel:Zn},setPointerStyle:s=>r({pointerStyle:s}),setPointerColor:s=>r({pointerColor:s}),toggleBreakMark:s=>{const i=o().breakMarks;r({breakMarks:{...i,[s]:!i[s]}})},setBreakMarks:s=>{r({breakMarks:{...o().breakMarks,...s}})},setBreakGapPx:s=>r({breakGapPx:s}),setBreakGapLevel:s=>{const i=Rn[Math.max(1,Math.min(5,s))-1];r({breakGapPx:i})},getBreakGapLevel:()=>_n(o().breakGapPx,Rn),getFontLevel:()=>Zs(o().fontSizePx),getLineLevel:()=>_n(o().lineHeight,kn),getMarginLevel:()=>_n(o().marginX,Tn),setFontLevel:s=>r({fontSizePx:Zn(Math.max(1,Math.min(12,s)))}),setLineLevel:s=>r({lineHeight:kn[Math.max(1,Math.min(7,s))-1]}),setMarginLevel:s=>{const i=Tn[Math.max(1,Math.min(5,s))-1];r({marginX:i,marginY:i})},setMuteAudio:s=>{r({muteAudio:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"muteAudio",value:s}})},toggleMuteAudio:()=>{const s=!o().muteAudio;r({muteAudio:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"muteAudio",value:s}})},setAudioSpeed:s=>{const i=Math.max(.3,Math.min(2,s));r({audioSpeed:i}),n==null||n.getState().emit({type:"settings_change",payload:{key:"audioSpeed",value:i}})},incAudioSpeed:()=>{const s=Math.min(2,Math.round((o().audioSpeed+.05)*100)/100);r({audioSpeed:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"audioSpeed",value:s}})},decAudioSpeed:()=>{const s=Math.max(.3,Math.round((o().audioSpeed-.05)*100)/100);r({audioSpeed:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"audioSpeed",value:s}})},setShowPointer:s=>r({showPointer:s}),toggleShowPointer:()=>r({showPointer:!o().showPointer}),setShowSplit:s=>r({showSplit:s}),toggleShowSplit:()=>r({showSplit:!o().showSplit}),setViewportSize:(s,i)=>{const{viewportWidth:u,viewportHeight:a}=o();u===s&&a===i||r({viewportWidth:s,viewportHeight:i})}}))}const hn=0,xt=1,jt=2,Fo=4;function Or(e){return()=>e}function ei(e){e()}function No(e,t){return n=>e(t(n))}function zr(e,t){return()=>e(t)}function ti(e,t){return n=>e(t,n)}function ar(e){return e!==void 0}function ni(...e){return()=>{e.map(ei)}}function Ot(){}function mn(e,t){return t(e),e}function ri(e,t){return t(e)}function ke(...e){return e}function Se(e,t){return e(xt,t)}function pe(e,t){e(hn,t)}function cr(e){e(jt)}function Me(e){return e(Fo)}function ne(e,t){return Se(e,ti(t,hn))}function tt(e,t){const n=e(xt,r=>{n(),t(r)});return n}function Ar(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Do(e,t){return e===t}function Te(e=Do){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ae(e){return t=>n=>{e(n)&&t(n)}}function Y(e){return t=>No(t,e)}function st(e){return t=>()=>{t(e)}}function L(e,...t){const n=oi(...t);return((r,o)=>{switch(r){case jt:cr(e);return;case xt:return Se(e,n(o))}})}function it(e,t){return n=>r=>{n(t=e(t,r))}}function wt(e){return t=>n=>{e>0?e--:t(n)}}function dt(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function he(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const u=Math.pow(2,i);Se(s,a=>{const l=n;n=n|u,t[i]=a,l!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const u=()=>{s([i].concat(t))};n===o?u():r=u}}function oi(...e){return t=>e.reduceRight(ri,t)}function si(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case xt:return s?n===s?void 0:(r(),n=s,t=Se(e,s),t):(r(),Ot);case jt:r(),n=null;return}}}function W(e){let t=e;const n=me();return((r,o)=>{switch(r){case hn:t=o;break;case xt:{o(t);break}case Fo:return t}return n(r,o)})}function Ne(e,t){return mn(W(t),n=>ne(e,n))}function me(){const e=[];return((t,n)=>{switch(t){case hn:e.slice().forEach(r=>{r(n)});return;case jt:e.splice(0,e.length);return;case xt:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}})}function Xe(e){return mn(me(),t=>ne(e,t))}function be(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:ii(),singleton:n}}const ii=()=>Symbol();function li(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const u=r(o.map(a=>n(a)));return i&&t.set(s,u),u};return n(e)}function Pe(...e){const t=me(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const u=Math.pow(2,i);Se(s,a=>{n[i]=a,r=r|u,r===o&&pe(t,n)})}),function(s,i){switch(s){case jt:{cr(t);return}case xt:return r===o&&i(n),Se(t,i)}}}function le(e,t=Do){return L(e,Te(t))}function Jn(...e){return function(t,n){switch(t){case jt:return;case xt:return ni(...e.map(r=>Se(r,n)))}}}var qe=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(qe||{});const ai={0:"debug",3:"error",1:"log",2:"warn"},ci=()=>typeof globalThis>"u"?window:globalThis,vt=be(()=>{const e=W(3);return{log:W((t,n,r=1)=>{var o;const s=(o=ci().VIRTUOSO_LOG_LEVEL)!=null?o:Me(e);r>=s&&console[ai[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Ct(e,t,n){return ur(e,t,n).callbackRef}function ur(e,t,n){const r=m.useRef(null);let o=i=>{};const s=m.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const u=()=>{const a=i[0].target;a.offsetParent!==null&&e(a)};n?u():requestAnimationFrame(u)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function ui(e,t,n,r,o,s,i,u,a){const l=m.useCallback(d=>{const S=di(d.children,t,u?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const g=h.lastElementChild.dataset.viewportType==="window";let v;g&&(v=h.ownerDocument.defaultView);const w=i?u?i.scrollLeft:i.scrollTop:g?u?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:u?h.scrollLeft:h.scrollTop,c=i?u?i.scrollWidth:i.scrollHeight:g?u?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:u?h.scrollWidth:h.scrollHeight,f=i?u?i.offsetWidth:i.offsetHeight:g?u?v.innerWidth:v.innerHeight:u?h.offsetWidth:h.offsetHeight;r({scrollHeight:c,scrollTop:Math.max(w,0),viewportHeight:f}),s==null||s(u?Pr("column-gap",getComputedStyle(d).columnGap,o):Pr("row-gap",getComputedStyle(d).rowGap,o)),S!==null&&e(S)},[e,t,o,s,i,r,u]);return ur(l,n,a)}function di(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const u=e.item(i);if(u.dataset.index===void 0)continue;const a=parseInt(u.dataset.index),l=parseFloat(u.dataset.knownSize),d=t(u,n);if(d===0&&r("Zero-sized element, this should not happen",{child:u},qe.ERROR),d===l)continue;const S=s[s.length-1];s.length===0||S.size!==d||S.endIndex!==a-1?s.push({endIndex:a,size:d,startIndex:a}):s[s.length-1].endIndex++}return s}function Pr(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,qe.WARN),t==="normal"?0:parseInt(t??"0",10)}function Wo(e,t,n){const r=m.useRef(null),o=m.useCallback(a=>{if(!(a!=null&&a.offsetParent))return;const l=a.getBoundingClientRect(),d=l.width;let S,h;if(t){const g=t.getBoundingClientRect(),v=l.top-g.top;h=g.height-Math.max(0,v),S=v+t.scrollTop}else{const g=i.current.ownerDocument.defaultView;h=g.innerHeight-Math.max(0,l.top),S=l.top+g.scrollY}r.current={offsetTop:S,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ur(o,!0,n),u=m.useCallback(()=>{o(i.current)},[o,i]);return m.useEffect(()=>{var a;if(t){t.addEventListener("scroll",u);const l=new ResizeObserver(()=>{requestAnimationFrame(u)});return l.observe(t),()=>{t.removeEventListener("scroll",u),l.unobserve(t)}}else{const l=(a=i.current)==null?void 0:a.ownerDocument.defaultView;return l==null||l.addEventListener("scroll",u),l==null||l.addEventListener("resize",u),()=>{l==null||l.removeEventListener("scroll",u),l==null||l.removeEventListener("resize",u)}}},[u,t,i]),s}const De=be(()=>{const e=me(),t=me(),n=W(0),r=me(),o=W(0),s=me(),i=me(),u=W(0),a=W(0),l=W(0),d=W(0),S=me(),h=me(),g=W(!1),v=W(!1),w=W(!1);return ne(L(e,Y(({scrollTop:c})=>c)),t),ne(L(e,Y(({scrollHeight:c})=>c)),i),ne(t,o),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:a,footerHeight:d,headerHeight:u,horizontalDirection:v,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:g,scrollTo:S,scrollTop:t,skipAnimationFrameInResizeObserver:w,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Lt={lvl:0};function qo(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:u,value:a}=t(e[i]);s.push({end:u-1,start:r,value:o}),r=u,o=a}return s.push({end:1/0,start:r,value:o}),s}function ye(e){return e===Lt}function Gt(e,t){if(!ye(e))return t===e.k?e.v:t<e.k?Gt(e.l,t):Gt(e.r,t)}function nt(e,t,n="k"){if(ye(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=nt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return nt(e.l,t,n)}function Ke(e,t,n){return ye(e)?Uo(t,n,1):t===e.k?Le(e,{k:t,v:n}):t<e.k?Br(Le(e,{l:Ke(e.l,t,n)})):Br(Le(e,{r:Ke(e.r,t,n)}))}function _t(){return Lt}function Mt(e,t,n){if(ye(e))return[];const r=nt(e,t)[0];return fi(tr(e,r,n))}function er(e,t){if(ye(e))return Lt;const{k:n,l:r,r:o}=e;if(t===n){if(ye(r))return o;if(ye(o))return r;{const[s,i]=$o(r);return rn(Le(e,{k:s,l:Vo(r),v:i}))}}else return t<n?rn(Le(e,{l:er(r,t)})):rn(Le(e,{r:er(o,t)}))}function yt(e){return ye(e)?[]:[...yt(e.l),{k:e.k,v:e.v},...yt(e.r)]}function tr(e,t,n){if(ye(e))return[];const{k:r,l:o,r:s,v:i}=e;let u=[];return r>t&&(u=u.concat(tr(o,t,n))),r>=t&&r<=n&&u.push({k:r,v:i}),r<=n&&(u=u.concat(tr(s,t,n))),u}function rn(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(Mn(t))return Ko(Le(e,{lvl:n-1}));if(!ye(t)&&!ye(t.r))return Le(t.r,{l:Le(t,{r:t.r.l}),lvl:n,r:Le(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Mn(e))return nr(Le(e,{lvl:n-1}));if(!ye(r)&&!ye(r.l)){const o=r.l,s=Mn(o)?r.lvl-1:r.lvl;return Le(o,{l:Le(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:nr(Le(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Le(e,t){return Uo(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Vo(e){return ye(e.r)?e.l:rn(Le(e,{r:Vo(e.r)}))}function Mn(e){return ye(e)||e.lvl>e.r.lvl}function $o(e){return ye(e.r)?[e.k,e.v]:$o(e.r)}function Uo(e,t,n,r=Lt,o=Lt){return{k:e,l:r,lvl:n,r:o,v:t}}function Br(e){return nr(Ko(e))}function Ko(e){const{l:t}=e;return!ye(t)&&t.lvl===e.lvl?Le(t,{r:Le(e,{l:t.r})}):e}function nr(e){const{lvl:t,r:n}=e;return!ye(n)&&!ye(n.r)&&n.lvl===t&&n.r.lvl===t?Le(n,{l:Le(e,{r:n.l}),lvl:t+1}):e}function fi(e){return qo(e,({k:t,v:n})=>({index:t,value:n}))}function Xo(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Ht(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const dr=be(()=>({recalcInProgress:W(!1)}),[],{singleton:!0});function Qo(e,t,n){return e[ln(e,t,n)]}function ln(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],u=n(i,t);if(u===0)return s;if(u===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function pi(e,t,n,r){const o=ln(e,t,r),s=ln(e,n,r,o);return e.slice(o,s+1)}function ht(e,t){return Math.round(e.getBoundingClientRect()[t])}function bn(e){return!ye(e.groupOffsetTree)}function fr({index:e},t){return t===e?0:t<e?-1:1}function gi(){return{groupIndices:[],groupOffsetTree:_t(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:_t()}}function hi(e,t){let n=ye(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ye(e)){e=Ke(e,0,s);continue}const u=Mt(e,i-1,o+1);if(u.some(wi(r)))continue;let a=!1,l=!1;for(const{end:d,start:S,value:h}of u)a?(o>=S||s===h)&&(e=er(e,S)):(l=h!==s,a=!0),d>o&&o>=S&&h!==s&&(e=Ke(e,o+1,h));l&&(e=Ke(e,i,s))}return[e,n]}function mi(e){return typeof e.groupIndex<"u"}function bi({offset:e},t){return t===e?0:t<e?-1:1}function Ft(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Qo(t,e,fr),i=e-r,u=s*i+(i-1)*n+o;return u>0?u+n:u}function Yo(e,t){if(!bn(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Zo(e,t,n){if(mi(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Yo(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function xi(e,t,n,r=0){return r>0&&(t=Math.max(t,Qo(e,r,fr).offset)),qo(pi(e,t,n,bi),yi)}function vi(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,qe.DEBUG);const s=e.sizeTree;let i=s,u=0;if(n.length>0&&ye(s)&&t.length===2){const h=t[0].size,g=t[1].size;i=n.reduce((v,w)=>Ke(Ke(v,w,h),w+1,g),i)}else[i,u]=hi(i,t);if(i===s)return e;const{lastIndex:a,lastOffset:l,lastSize:d,offsetTree:S}=rr(e.offsetTree,u,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,g)=>Ke(h,g,Ft(g,S,o)),_t()),lastIndex:a,lastOffset:l,lastSize:d,offsetTree:S,sizeTree:i}}function Si(e){return yt(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function Lr(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function rr(e,t,n,r){let o=e,s=0,i=0,u=0,a=0;if(t!==0){a=ln(o,t-1,fr),u=o[a].offset;const l=nt(n,t-1);s=l[0],i=l[1],o.length&&o[a].size===nt(n,t)[1]&&(a-=1),o=o.slice(0,a+1)}else o=[];for(const{start:l,value:d}of Mt(n,t,1/0)){const S=l-s,h=S*i+u+S*r;o.push({index:l,offset:h,size:d}),s=l,u=h,i=d}return{lastIndex:s,lastOffset:u,lastSize:i,offsetTree:o}}function yi(e){return{index:e.index,value:e}}function wi(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const Ci={offsetHeight:"height",offsetWidth:"width"},at=be(([{log:e},{recalcInProgress:t}])=>{const n=me(),r=me(),o=Ne(r,0),s=me(),i=me(),u=W(0),a=W([]),l=W(void 0),d=W(void 0),S=W(void 0),h=W(void 0),g=W((b,y)=>ht(b,Ci[y])),v=W(void 0),w=W(0),c=gi(),f=Ne(L(n,he(a,e,w),it(vi,c),Te()),c),p=Ne(L(a,Te(),it((b,y)=>({current:y,prev:b.current}),{current:[],prev:[]}),Y(({prev:b})=>b)),[]);ne(L(a,ae(b=>b.length>0),he(f,w),Y(([b,y,k])=>{const R=b.reduce((_,z,B)=>Ke(_,z,Ft(z,y.offsetTree,k)||B),_t());return{...y,groupIndices:b,groupOffsetTree:R}})),f),ne(L(r,he(f),ae(([b,{lastIndex:y}])=>b<y),Y(([b,{lastIndex:y,lastSize:k}])=>[{endIndex:y,size:k,startIndex:b}])),n),ne(l,d);const C=Ne(L(l,Y(b=>b===void 0)),!0);ne(L(d,ae(b=>b!==void 0&&ye(Me(f).sizeTree)),Y(b=>{const y=Me(S),k=Me(a).length>0;return y?k?[{endIndex:0,size:y,startIndex:0},{endIndex:1,size:b,startIndex:1}]:[]:[{endIndex:0,size:b,startIndex:0}]})),n),ne(L(h,ae(b=>b!==void 0&&b.length>0&&ye(Me(f).sizeTree)),Y(b=>{const y=[];let k=b[0],R=0;for(let _=1;_<b.length;_++){const z=b[_];z!==k&&(y.push({endIndex:_-1,size:k,startIndex:R}),k=z,R=_)}return y.push({endIndex:b.length-1,size:k,startIndex:R}),y})),n),ne(L(a,he(S,d),ae(([,b,y])=>b!==void 0&&y!==void 0),Y(([b,y,k])=>{const R=[];for(let _=0;_<b.length;_++){const z=b[_],B=b[_+1];R.push({startIndex:z,endIndex:z,size:y}),B!==void 0&&R.push({startIndex:z+1,endIndex:B-1,size:k})}return R})),n);const T=Xe(L(n,he(f),it(({sizes:b},[y,k])=>({changed:k!==b,sizes:k}),{changed:!1,sizes:c}),Y(b=>b.changed)));Se(L(u,it((b,y)=>({diff:b.prev-y,prev:y}),{diff:0,prev:0}),Y(b=>b.diff)),b=>{const{groupIndices:y}=Me(f);if(b>0)pe(t,!0),pe(s,b+Lr(b,y));else if(b<0){const k=Me(p);k.length>0&&(b-=Lr(-b,k)),pe(i,b)}}),Se(L(u,he(e)),([b,y])=>{b<0&&y("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:u},qe.ERROR)});const I=Xe(s);ne(L(s,he(f),Y(([b,y])=>{const k=y.groupIndices.length>0,R=[],_=y.lastSize;if(k){const z=Gt(y.sizeTree,0);let B=0,E=0;for(;B<b;){const F=y.groupIndices[E],M=y.groupIndices.length===E+1?1/0:y.groupIndices[E+1]-F-1;R.push({endIndex:F,size:z,startIndex:F}),R.push({endIndex:F+1+M-1,size:_,startIndex:F+1}),E++,B+=M+1}const P=yt(y.sizeTree);return B!==b&&P.shift(),P.reduce((F,{k:M,v:O})=>{let Q=F.ranges;return F.prevSize!==0&&(Q=[...F.ranges,{endIndex:M+b-1,size:F.prevSize,startIndex:F.prevIndex}]),{prevIndex:M+b,prevSize:O,ranges:Q}},{prevIndex:b,prevSize:0,ranges:R}).ranges}return yt(y.sizeTree).reduce((z,{k:B,v:E})=>({prevIndex:B+b,prevSize:E,ranges:[...z.ranges,{endIndex:B+b-1,size:z.prevSize,startIndex:z.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const j=Xe(L(i,he(f,w),Y(([b,{offsetTree:y},k])=>{const R=-b;return Ft(R,y,k)})));return ne(L(i,he(f,w),Y(([b,y,k])=>{if(y.groupIndices.length>0){if(ye(y.sizeTree))return y;let R=_t();const _=Me(p);let z=0,B=0,E=0;for(;z<-b;){E=_[B];const P=_[B+1]-E-1;B++,z+=P+1}if(R=yt(y.sizeTree).reduce((P,{k:F,v:M})=>Ke(P,Math.max(0,F+b),M),R),z!==-b){const P=Gt(y.sizeTree,E);R=Ke(R,0,P);const F=nt(y.sizeTree,-b+1)[1];R=Ke(R,1,F)}return{...y,sizeTree:R,...rr(y.offsetTree,0,R,k)}}else{const R=yt(y.sizeTree).reduce((_,{k:z,v:B})=>Ke(_,Math.max(0,z+b),B),_t());return{...y,sizeTree:R,...rr(y.offsetTree,0,R,k)}}})),f),{beforeUnshiftWith:I,data:v,defaultItemSize:d,firstItemIndex:u,fixedItemSize:l,fixedGroupSize:S,gap:w,groupIndices:a,heightEstimates:h,itemSize:g,listRefresh:T,shiftWith:i,shiftWithOffset:j,sizeRanges:n,sizes:f,statefulTotalCount:o,totalCount:r,trackItemSizes:C,unshiftWith:s}},ke(vt,dr),{singleton:!0});function Ii(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Jo=be(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=me(),i=me(),u=Xe(L(s,Y(Ii)));return ne(L(u,Y(a=>a.totalCount)),n),ne(L(u,Y(a=>a.groupIndices)),e),ne(L(Pe(o,t,r),ae(([a,l])=>bn(l)),Y(([a,l,d])=>nt(l.groupOffsetTree,Math.max(a-d,0),"v")[0]),Te(),Y(a=>[a])),i),{groupCounts:s,topItemsIndexes:i}},ke(at,De)),St=be(([{log:e}])=>{const t=W(!1),n=Xe(L(t,ae(r=>r),Te()));return Se(t,r=>{r&&Me(e)("props updated",{},qe.DEBUG)}),{didMount:n,propsReady:t}},ke(vt),{singleton:!0}),Ti=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function es(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Ti)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Ut=be(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:u,scrollingInProgress:a,scrollTo:l,smoothScrollTargetReached:d,viewportHeight:S},{log:h}])=>{const g=me(),v=me(),w=W(0);let c=null,f=null,p=null;function C(){c&&(c(),c=null),p&&(p(),p=null),f&&(clearTimeout(f),f=null),pe(a,!1)}return ne(L(g,he(n,S,r,w,u,i,h),he(e,s,o),Y(([[T,I,j,b,y,k,R,_],z,B,E])=>{const P=es(T),{align:F,behavior:M,offset:O}=P,Q=b-1,re=Zo(P,I,Q);let oe=Ft(re,I.offsetTree,z)+k;F==="end"?(oe+=B+nt(I.sizeTree,re)[1]-j+E,re===Q&&(oe+=R)):F==="center"?oe+=(B+nt(I.sizeTree,re)[1]-j+E)/2:oe-=y,O&&(oe+=O);const ie=ue=>{C(),ue?(_("retrying to scroll to",{location:T},qe.DEBUG),pe(g,T)):(pe(v,!0),_("list did not change, scroll successful",{},qe.DEBUG))};if(C(),M==="smooth"){let ue=!1;p=Se(t,xe=>{ue=ue||xe}),c=tt(d,()=>{ie(ue)})}else c=tt(L(t,ki(150)),ie);return f=setTimeout(()=>{C()},1200),pe(a,!0),_("scrolling from index to",{behavior:M,index:re,top:oe},qe.DEBUG),{behavior:M,top:oe}})),l),{scrollTargetReached:v,scrollToIndex:g,topListHeight:w}},ke(at,De,vt),{singleton:!0});function ki(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function pr(e,t){e==0?t():requestAnimationFrame(()=>{pr(e-1,t)})}function gr(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Kt=be(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const u=W(!0),a=W(0),l=W(!0);return ne(L(i,he(a),ae(([d,S])=>!!S),st(!1)),u),ne(L(i,he(a),ae(([d,S])=>!!S),st(!1)),l),Se(L(Pe(t,i),he(u,n,e,l),ae(([[,d],S,{sizeTree:h},g,v])=>d&&(!ye(h)||ar(g))&&!S&&!v),he(a)),([,d])=>{tt(o,()=>{pe(l,!0)}),pr(4,()=>{tt(r,()=>{pe(u,!0)}),pe(s,d)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:a,scrolledToInitialItem:u}},ke(at,De,Ut,St),{singleton:!0});function ts(e,t){return Math.abs(e-t)<1.01}const Nt="up",Pt="down",Ri="none",_i={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Mi=0,Xt=be(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=W(!1),u=W(!0),a=me(),l=me(),d=W(4),S=W(Mi),h=Ne(L(Jn(L(le(o),wt(1),st(!0)),L(le(o),wt(1),st(!1),Ar(100))),Te()),!1),g=Ne(L(Jn(L(n,st(!0)),L(n,st(!1),Ar(200))),Te()),!1);ne(L(Pe(le(o),le(S)),Y(([p,C])=>p<=C),Te()),u),ne(L(u,dt(50)),l);const v=Xe(L(Pe(r,le(s),le(t),le(e),le(d)),it((p,[{scrollHeight:C,scrollTop:T},I,j,b,y])=>{const k=T+I-C>-y,R={scrollHeight:C,scrollTop:T,viewportHeight:I};if(k){let z,B;return T>p.state.scrollTop?(z="SCROLLED_DOWN",B=p.state.scrollTop-T):(z="SIZE_DECREASED",B=p.state.scrollTop-T||p.scrollTopDelta),{atBottom:!0,atBottomBecause:z,scrollTopDelta:B,state:R}}let _;return R.scrollHeight>p.state.scrollHeight?_="SIZE_INCREASED":I<p.state.viewportHeight?_="VIEWPORT_HEIGHT_DECREASING":T<p.state.scrollTop?_="SCROLLING_UPWARDS":_="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:_,state:R}},_i),Te((p,C)=>p&&p.atBottom===C.atBottom))),w=Ne(L(r,it((p,{scrollHeight:C,scrollTop:T,viewportHeight:I})=>{if(ts(p.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:T};{const j=C-(T+I)<1;return p.scrollTop!==T&&j?{changed:!0,jump:p.scrollTop-T,scrollHeight:C,scrollTop:T}:{changed:!0,jump:0,scrollHeight:C,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ae(p=>p.changed),Y(p=>p.jump)),0);ne(L(v,Y(p=>p.atBottom)),i),ne(L(i,dt(50)),a);const c=W(Pt);ne(L(r,Y(({scrollTop:p})=>p),Te(),it((p,C)=>Me(g)?{direction:p.direction,prevScrollTop:C}:{direction:C<p.prevScrollTop?Nt:Pt,prevScrollTop:C},{direction:Pt,prevScrollTop:0}),Y(p=>p.direction)),c),ne(L(r,dt(50),st(Ri)),c);const f=W(0);return ne(L(h,ae(p=>!p),st(0)),f),ne(L(o,dt(100),he(h),ae(([p,C])=>C),it(([p,C],[T])=>[C,T],[0,0]),Y(([p,C])=>C-p)),f),{atBottomState:v,atBottomStateChange:a,atBottomThreshold:d,atTopStateChange:l,atTopThreshold:S,isAtBottom:i,isAtTop:u,isScrolling:h,lastJumpDueToItemResize:w,scrollDirection:c,scrollVelocity:f}},ke(De)),Dt="top",Wt="bottom",Gr="none";function Hr(e,t,n){return typeof e=="number"?n===Nt&&t===Dt||n===Pt&&t===Wt?e:0:n===Nt?t===Dt?e.main:e.reverse:t===Wt?e.main:e.reverse}function Fr(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const hr=be(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=me(),i=W(0),u=W(0),a=W(0),l=Ne(L(Pe(le(r),le(o),le(n),le(s,Ht),le(a),le(i),le(t),le(e),le(u)),Y(([d,S,h,[g,v],w,c,f,p,C])=>{const T=d-p,I=c+f,j=Math.max(h-T,0);let b=Gr;const y=Fr(C,Dt),k=Fr(C,Wt);return g-=p,g+=h+f,v+=h+f,v-=p,g>d+I-y&&(b=Nt),v<d-j+S+k&&(b=Pt),b!==Gr?[Math.max(T-h-Hr(w,Dt,b)-y,0),T-j-f+S+Hr(w,Wt,b)+k]:null}),ae(d=>d!=null),Te(Ht)),[0,0]);return{increaseViewportBy:u,listBoundary:s,overscan:a,topListHeight:i,visibleRange:l}},ke(De),{singleton:!0});function Ei(e,t,n){if(bn(t)){const r=Yo(e,t);return[{index:nt(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const En={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function on(e,t,n,r,o,s){const{lastIndex:i,lastOffset:u,lastSize:a}=o;let l=0,d=0;if(e.length>0){l=e[0].offset;const w=e[e.length-1];d=w.offset+w.size}const S=n-i,h=u+S*a+(S-1)*r,g=l,v=h-d;return{bottom:d,firstItemIndex:s,items:Nr(e,o,s),offsetBottom:v,offsetTop:l,top:g,topItems:Nr(t,o,s),topListHeight:t.reduce((w,c)=>c.size+w,0),totalCount:n}}function ns(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const u=e+i,a=gr(t,u),l=Array.from({length:u}).map((d,S)=>({data:s[S+a],index:S+a,offset:0,size:0}));return on(l,[],u,o,n,r)}function Nr(e,t,n){if(e.length===0)return[];if(!bn(t))return e.map(l=>({...l,index:l.index+n,originalIndex:l.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Mt(t.groupOffsetTree,r,o);let u,a=0;for(const l of e){(!u||u.end<l.index)&&(u=i.shift(),a=t.groupIndices.indexOf(u.start));let d;l.index===u.start?d={index:a,type:"group"}:d={groupIndex:a,index:l.index-(a+1)+n},s.push({...d,data:l.data,offset:l.offset,originalIndex:l.index,size:l.size})}return s}function Dr(e,t){var n;return e===void 0?0:typeof e=="number"?e:(n=e[t])!=null?n:0}const It=be(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:u,visibleRange:a},{initialTopMostItemIndex:l,scrolledToInitialItem:d},{topListHeight:S},h,{didMount:g},{recalcInProgress:v}])=>{const w=W([]),c=W(0),f=me(),p=W(0);ne(s.topItemsIndexes,w);const C=Ne(L(Pe(g,v,le(a,Ht),le(o),le(r),le(l),d,le(w),le(t),le(n),le(p),e),ae(([b,y,,k,,,,,,,,R])=>{const _=R&&R.length!==k;return b&&!y&&!_}),Y(([,,[b,y],k,R,_,z,B,E,P,F,M])=>{var O,Q,re,oe;const ie=R,{offsetTree:ue,sizeTree:xe}=ie,N=Me(c);if(k===0)return{...En,totalCount:k};if(b===0&&y===0)return N===0?{...En,totalCount:k}:ns(N,_,R,E,P,M||[]);if(ye(xe))return N>0?null:on(Ei(gr(_,k),ie,M),[],k,P,ie,E);const D=[];if(B.length>0){const $=B[0],Z=B[B.length-1];let ee=0;for(const J of Mt(xe,$,Z)){const ce=J.value,se=Math.max(J.start,$),ve=Math.min(J.end,Z);for(let ge=se;ge<=ve;ge++)D.push({data:M==null?void 0:M[ge],index:ge,offset:ee,size:ce}),ee+=ce}}if(!z)return on([],D,k,P,ie,E);const q=B.length>0?B[B.length-1]+1:0,A=xi(ue,b,y,q);if(A.length===0)return null;const G=k-1,K=mn([],$=>{for(const Z of A){const ee=Z.value;let J=ee.offset,ce=Z.start;const se=ee.size;if(ee.offset<b){ce+=Math.floor((b-ee.offset+P)/(se+P));const ge=ce-Z.start;J+=ge*se+ge*P}ce<q&&(J+=(q-ce)*se,ce=q);const ve=Math.min(Z.end,G);for(let ge=ce;ge<=ve&&!(J>=y);ge++)$.push({data:M==null?void 0:M[ge],index:ge,offset:J,size:se}),J+=se+P}}),H=Dr(F,Dt),te=Dr(F,Wt);if(K.length>0&&(H>0||te>0)){const $=K[0],Z=K[K.length-1];if(H>0&&$.index>q){const ee=Math.min(H,$.index-q),J=[];let ce=$.offset;for(let se=$.index-1;se>=$.index-ee;se--){const ve=(Q=(O=Mt(xe,se,se)[0])==null?void 0:O.value)!=null?Q:$.size;ce-=ve+P,J.unshift({data:M==null?void 0:M[se],index:se,offset:ce,size:ve})}K.unshift(...J)}if(te>0&&Z.index<G){const ee=Math.min(te,G-Z.index);let J=Z.offset+Z.size+P;for(let ce=Z.index+1;ce<=Z.index+ee;ce++){const se=(oe=(re=Mt(xe,ce,ce)[0])==null?void 0:re.value)!=null?oe:Z.size;K.push({data:M==null?void 0:M[ce],index:ce,offset:J,size:se}),J+=se+P}}}return on(K,D,k,P,ie,E)}),ae(b=>b!==null),Te()),En);ne(L(e,ae(ar),Y(b=>b==null?void 0:b.length)),o),ne(L(C,Y(b=>b.topListHeight)),S),ne(S,u),ne(L(C,Y(b=>[b.top,b.bottom])),i),ne(L(C,Y(b=>b.items)),f);const T=Xe(L(C,ae(({items:b})=>b.length>0),he(o,e),ae(([{items:b},y])=>b[b.length-1].originalIndex===y-1),Y(([,b,y])=>[b-1,y]),Te(Ht),Y(([b])=>b))),I=Xe(L(C,dt(200),ae(({items:b,topItems:y})=>b.length>0&&b[0].originalIndex===y.length),Y(({items:b})=>b[0].index),Te())),j=Xe(L(C,ae(({items:b})=>b.length>0),Y(({items:b})=>{let y=0,k=b.length-1;for(;b[y].type==="group"&&y<k;)y++;for(;b[k].type==="group"&&k>y;)k--;return{endIndex:b[k].index,startIndex:b[y].index}}),Te(Xo)));return{endReached:T,initialItemCount:c,itemsRendered:f,listState:C,minOverscanItemCount:p,rangeChanged:j,startReached:I,topItemsIndexes:w,...h}},ke(at,Jo,hr,Kt,Ut,Xt,St,dr),{singleton:!0}),rs=be(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=me(),i=Ne(L(Pe(n,e,r,t,o),Y(([u,a,l,d,S])=>u+a+l+d+S.offsetBottom+S.bottom)),0);return ne(le(i),s),{totalListHeight:i,totalListHeightChanged:s}},ke(De,It),{singleton:!0}),ji=be(([{viewportHeight:e},{totalListHeight:t}])=>{const n=W(!1),r=Ne(L(Pe(n,e,t),ae(([o])=>o),Y(([,o,s])=>Math.max(0,o-s)),dt(0),Te()),0);return{alignToBottom:n,paddingTopAddition:r}},ke(De,rs),{singleton:!0}),os=be(()=>({context:W(null)})),Oi=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,ss=be(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:u,viewportHeight:a},{scrollToIndex:l}])=>{const d=me();return ne(L(d,he(t,a,n,s,o,r,u),he(e),Y(([[S,h,g,v,w,c,f,p],C])=>{const{align:T,behavior:I,calculateViewLocation:j=Oi,done:b,...y}=S,k=Zo(S,h,v-1),R=Ft(k,h.offsetTree,C)+w+c,_=R+nt(h.sizeTree,k)[1],z=p+c,B=p+g-f,E=j({itemBottom:_,itemTop:R,locationParams:{align:T,behavior:I,...y},viewportBottom:B,viewportTop:z});return E?b&&tt(L(i,ae(P=>!P),wt(Me(i)?1:2)),b):b==null||b(),E}),ae(S=>S!==null)),l),{scrollIntoView:d}},ke(at,De,Ut,It,vt),{singleton:!0});function Wr(e){return e?e==="smooth"?"smooth":"auto":!1}const zi=(e,t)=>typeof e=="function"?Wr(e(t)):t&&Wr(e),Ai=be(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:u},{didMount:a,propsReady:l},{log:d},{scrollingInProgress:S},{context:h},{scrollIntoView:g}])=>{const v=W(!1),w=me();let c=null;function f(I){pe(i,{align:"end",behavior:I,index:"LAST"})}Se(L(Pe(L(le(t),wt(1)),a),he(le(v),s,u,S),Y(([[I,j],b,y,k,R])=>{let _=j&&k,z="auto";return _&&(z=zi(b,y||R),_=_&&!!z),{followOutputBehavior:z,shouldFollow:_,totalCount:I}}),ae(({shouldFollow:I})=>I)),({followOutputBehavior:I,totalCount:j})=>{c&&(c(),c=null),Me(n)?requestAnimationFrame(()=>{Me(d)("following output to ",{totalCount:j},qe.DEBUG),f(I)}):c=tt(e,()=>{Me(d)("following output to ",{totalCount:j},qe.DEBUG),f(I),c=null})});function p(I){const j=tt(o,b=>{I&&!b.atBottom&&b.notAtBottomBecause==="SIZE_INCREASED"&&!c&&(Me(d)("scrolling to bottom due to increased size",{},qe.DEBUG),f("auto"))});setTimeout(j,100)}Se(L(Pe(le(v),t,l),ae(([I,,j])=>I&&j),it(({value:I},[,j])=>({refreshed:I===j,value:j}),{refreshed:!1,value:0}),ae(({refreshed:I})=>I),he(v,t)),([,I])=>{Me(u)&&p(I!==!1)}),Se(w,()=>{p(Me(v)!==!1)}),Se(Pe(le(v),o),([I,j])=>{I&&!j.atBottom&&j.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&f("auto")});const C=W(null),T=me();return ne(Jn(L(le(r),Y(I=>{var j;return(j=I==null?void 0:I.length)!=null?j:0})),L(le(t))),T),Se(L(Pe(L(T,wt(1)),a),he(le(C),u,S,h),Y(([[I,j],b,y,k,R])=>j&&y&&(b==null?void 0:b({context:R,totalCount:I,scrollingInProgress:k}))),ae(I=>!!I),dt(0)),I=>{c&&(c(),c=null),Me(n)?requestAnimationFrame(()=>{Me(d)("scrolling into view",{}),pe(g,I)}):c=tt(e,()=>{Me(d)("scrolling into view",{}),pe(g,I),c=null})}),{autoscrollToBottom:w,followOutput:v,scrollIntoViewOnChange:C}},ke(at,Xt,Ut,Kt,St,vt,De,os,ss)),Pi=be(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:u}])=>(ne(L(u,he(s),ae(([,a])=>a!==0),he(o,r,t,n,e),Y(([[,a],l,d,S,h,g=[]])=>ns(a,l,d,S,h,g))),i),{}),ke(at,Kt,It,St),{singleton:!0}),Bi=be(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=W(0);return Se(L(e,he(r),ae(([,o])=>o!==0),Y(([,o])=>({top:o}))),o=>{tt(L(n,wt(1),ae(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{pe(t,o)})})}),{initialScrollTop:r}},ke(St,De,It),{singleton:!0}),is=be(([{scrollVelocity:e}])=>{const t=W(!1),n=me(),r=W(!1);return ne(L(e,he(r,t,n),ae(([o,s])=>!!s),Y(([o,s,i,u])=>{const{enter:a,exit:l}=s;if(i){if(l(o,u))return!1}else if(a(o,u))return!0;return i}),Te()),t),Se(L(Pe(t,e,n),he(r)),([[o,s,i],u])=>{o&&u&&u.change&&u.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ke(Xt),{singleton:!0}),mr=be(([{scrollContainerState:e,scrollTo:t}])=>{const n=me(),r=me(),o=me(),s=W(!1),i=W(void 0);return ne(L(Pe(n,r),Y(([{scrollHeight:u,scrollTop:a,viewportHeight:l},{offsetTop:d}])=>({scrollHeight:u,scrollTop:Math.max(0,a-d),viewportHeight:l}))),e),ne(L(t,he(r),Y(([u,{offsetTop:a}])=>({...u,top:u.top+a}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ke(De)),Li=be(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:u,windowViewportRect:a}])=>{const l=me(),d=W(void 0),S=W(null),h=W(null);return ne(u,S),ne(a,h),Se(L(l,he(t,r,i,S,h,n)),([g,v,w,c,f,p,C])=>{const T=Si(v.sizeTree);c&&f!==null&&p!==null&&(w=f.scrollTop-p.offsetTop),w-=C,g({ranges:T,scrollTop:w})}),ne(L(d,ae(ar),Y(Gi)),o),ne(L(s,he(d),ae(([,g])=>g!==void 0),Te(),Y(([,g])=>g.ranges)),e),{getState:l,restoreStateFrom:d}},ke(at,De,Kt,St,mr));function Gi(e){return{align:"start",index:0,offset:e.scrollTop}}const Hi=be(([{topItemsIndexes:e}])=>{const t=W(0);return ne(L(t,ae(n=>n>=0),Y(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ke(It));function ls(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}const Fi=ls(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Ni=be(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:u},{listState:a},{beforeUnshiftWith:l,gap:d,shiftWithOffset:S,sizes:h},{log:g},{recalcInProgress:v}])=>{const w=Xe(L(a,he(i),it(([,f,p,C],[{bottom:T,items:I,offsetBottom:j,totalCount:b},y])=>{const k=T+j;let R=0;return p===b&&f.length>0&&I.length>0&&(I[0].originalIndex===0&&f[0].originalIndex===0||(R=k-C,R!==0&&(R+=y))),[R,I,b,k]},[0,[],0,0]),ae(([f])=>f!==0),he(r,u,n,o,g,v),ae(([,f,p,C,,,T])=>!T&&!C&&f!==0&&p===Nt),Y(([[f],,,,,p])=>(p("Upward scrolling compensation",{amount:f},qe.DEBUG),f))));function c(f){f>0?(pe(t,{behavior:"auto",top:-f}),pe(e,0)):(pe(e,0),pe(t,{behavior:"auto",top:-f}))}return Se(L(w,he(e,s)),([f,p,C])=>{C&&Fi()?pe(e,p-f):c(-f)}),Se(L(Pe(Ne(s,!1),e,v),ae(([f,p,C])=>!f&&!C&&p!==0),Y(([f,p])=>p),dt(1)),c),ne(L(S,Y(f=>({top:-f}))),t),Se(L(l,he(h,d),Y(([f,{groupIndices:p,lastSize:C,sizeTree:T},I])=>{function j(b){return b*(C+I)}if(p.length===0)return j(f);{let b=0;const y=Gt(T,0);let k=0,R=0;for(;k<f;){k++,b+=y;let _=p.length===R+1?1/0:p[R+1]-p[R]-1;k+_>f&&(b-=y,_=f-k+1),k+=_,b+=j(_),R++}return b}})),f=>{pe(e,f),requestAnimationFrame(()=>{pe(t,{top:f}),requestAnimationFrame(()=>{pe(e,0),pe(v,!1)})})}),{deviation:e}},ke(De,Xt,It,at,vt,dr)),Di=be(([e,t,n,r,o,s,i,u,a,l,d])=>({...e,...t,...n,...r,...o,...s,...i,...u,...a,...l,...d}),ke(hr,Pi,St,is,rs,Bi,ji,mr,ss,vt,os)),as=be(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:o,gap:s,groupIndices:i,heightEstimates:u,itemSize:a,sizeRanges:l,sizes:d,statefulTotalCount:S,totalCount:h,trackItemSizes:g},{initialItemFinalLocationReached:v,initialTopMostItemIndex:w,scrolledToInitialItem:c},f,p,C,T,{scrollToIndex:I},j,{topItemCount:b},{groupCounts:y},k])=>{const{listState:R,minOverscanItemCount:_,topItemsIndexes:z,rangeChanged:B,...E}=T;return ne(B,k.scrollSeekRangeChanged),ne(L(k.windowViewportRect,Y(P=>P.visibleHeight)),f.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:o,gap:s,groupCounts:y,heightEstimates:u,initialItemFinalLocationReached:v,initialTopMostItemIndex:w,scrolledToInitialItem:c,sizeRanges:l,topItemCount:b,topItemsIndexes:z,totalCount:h,...C,groupIndices:i,itemSize:a,listState:R,minOverscanItemCount:_,scrollToIndex:I,statefulTotalCount:S,trackItemSizes:g,rangeChanged:B,...E,...k,...f,sizes:d,...p}},ke(at,Kt,De,Li,Ai,It,Ut,Ni,Hi,Jo,Di));function Wi(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const Jt=typeof document<"u"?m.useLayoutEffect:m.useEffect;function cs(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),u=m.createContext({});function a(c,f){c.propsReady&&pe(c.propsReady,!1);for(const p of r){const C=c[t.required[p]];pe(C,f[p])}for(const p of o)if(p in f){const C=c[t.optional[p]];pe(C,f[p])}c.propsReady&&pe(c.propsReady,!0)}function l(c){return s.reduce((f,p)=>(f[p]=C=>{const T=c[t.methods[p]];pe(T,C)},f),{})}function d(c){return i.reduce((f,p)=>(f[p]=si(c[t.events[p]]),f),{})}const S=m.forwardRef((c,f)=>{const{children:p,...C}=c,[T]=m.useState(()=>mn(li(e),b=>{a(b,C)})),[I]=m.useState(zr(d,T));Jt(()=>{for(const b of i)b in C&&Se(I[b],C[b]);return()=>{Object.values(I).map(cr)}},[C,I,T]),Jt(()=>{a(T,C)}),m.useImperativeHandle(f,Or(l(T)));const j=n;return x.jsx(u.Provider,{value:T,children:n?x.jsx(j,{...Wi([...r,...o,...i],C),children:p}):p})}),h=c=>{const f=m.useContext(u);return m.useCallback(p=>{pe(f[c],p)},[f,c])},g=c=>{const f=m.useContext(u)[c],p=m.useCallback(C=>Se(f,C),[f]);return m.useSyncExternalStore(p,()=>Me(f),()=>Me(f))},v=c=>{const f=m.useContext(u)[c],[p,C]=m.useState(zr(Me,f));return Jt(()=>Se(f,T=>{T!==p&&C(Or(T))}),[f,p]),p},w=m.version.startsWith("18")?g:v;return{Component:S,useEmitter:(c,f)=>{const p=m.useContext(u)[c];Jt(()=>Se(p,f),[f,p])},useEmitterValue:w,usePublisher:h}}const us=m.createContext(void 0),ds=m.createContext(void 0),fs=typeof document<"u"?m.useLayoutEffect:m.useEffect;function jn(e){return"self"in e}function qi(e){return"body"in e}function ps(e,t,n,r=Ot,o,s){const i=m.useRef(null),u=m.useRef(null),a=m.useRef(null),l=m.useCallback(h=>{let g,v,w;const c=h.target;if(qi(c)||jn(c)){const p=jn(c)?c:c.defaultView;w=s?p.scrollX:p.scrollY,g=s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight,v=s?p.innerWidth:p.innerHeight}else w=s?c.scrollLeft:c.scrollTop,g=s?c.scrollWidth:c.scrollHeight,v=s?c.offsetWidth:c.offsetHeight;const f=()=>{e({scrollHeight:g,scrollTop:Math.max(w,0),viewportHeight:v})};h.suppressFlushSync?f():Gs.flushSync(f),u.current!==null&&(w===u.current||w<=0||w===g-v)&&(u.current=null,t(!0),a.current&&(clearTimeout(a.current),a.current=null))},[e,t,s]);m.useEffect(()=>{const h=o||i.current;return r(o||i.current),l({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",l,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",l)}},[i,l,n,r,o]);function d(h){const g=i.current;if(!g||(s?"offsetWidth"in g&&g.offsetWidth===0:"offsetHeight"in g&&g.offsetHeight===0))return;const v=h.behavior==="smooth";let w,c,f;jn(g)?(c=Math.max(ht(g.document.documentElement,s?"width":"height"),s?g.document.documentElement.scrollWidth:g.document.documentElement.scrollHeight),w=s?g.innerWidth:g.innerHeight,f=s?window.scrollX:window.scrollY):(c=g[s?"scrollWidth":"scrollHeight"],w=ht(g,s?"width":"height"),f=g[s?"scrollLeft":"scrollTop"]);const p=c-w;if(h.top=Math.ceil(Math.max(Math.min(p,h.top),0)),ts(w,c)||h.top===f){e({scrollHeight:c,scrollTop:f,viewportHeight:w}),v&&t(!0);return}v?(u.current=h.top,a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,u.current=null,t(!0)},1e3)):u.current=null,s&&(h={behavior:h.behavior,left:h.top}),g.scrollTo(h)}function S(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:S,scrollerRef:i,scrollToCallback:d}}const On="-webkit-sticky",qr="sticky",br=ls(()=>{if(typeof document>"u")return qr;const e=document.createElement("div");return e.style.position=On,e.style.position===On?On:qr});function xr(e){return e}const Vi=be(()=>{const e=W(u=>`Item ${u}`),t=W(u=>`Group ${u}`),n=W({}),r=W(xr),o=W("div"),s=W(Ot),i=(u,a=null)=>Ne(L(n,Y(l=>l[u]),Te()),a);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),$i=be(([e,t])=>({...e,...t}),ke(as,Vi)),Ui=({height:e})=>x.jsx("div",{style:{height:e}}),Ki={overflowAnchor:"none",position:br(),zIndex:1},gs={overflowAnchor:"none"},Xi={...gs,display:"inline-block",height:"100%"},Vr=m.memo(function({showTopList:e=!1}){const t=de("listState"),n=Ze("sizeRanges"),r=de("useWindowScroll"),o=de("customScrollParent"),s=Ze("windowScrollContainerState"),i=Ze("scrollContainerState"),u=o||r?s:i,a=de("itemContent"),l=de("context"),d=de("groupContent"),S=de("trackItemSizes"),h=de("itemSize"),g=de("log"),v=Ze("gap"),w=de("horizontalDirection"),{callbackRef:c}=ui(n,h,S,e?Ot:u,g,v,o,w,de("skipAnimationFrameInResizeObserver")),[f,p]=m.useState(0);vr("deviation",E=>{f!==E&&p(E)});const C=de("EmptyPlaceholder"),T=de("ScrollSeekPlaceholder")||Ui,I=de("ListComponent"),j=de("ItemComponent"),b=de("GroupComponent"),y=de("computeItemKey"),k=de("isSeeking"),R=de("groupIndices").length>0,_=de("alignToBottom"),z=de("initialItemFinalLocationReached"),B=e?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:f!==0?f:_?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:f!==0?f:_?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...z?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?x.jsx(C,{...Fe(C,l)}):x.jsx(I,{...Fe(I,l),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:c,style:B,children:(e?t.topItems:t.items).map(E=>{const P=E.originalIndex,F=y(P+t.firstItemIndex,E.data,l);return k?m.createElement(T,{...Fe(T,l),height:E.size,index:E.index,key:F,type:E.type||"item",...E.type==="group"?{}:{groupIndex:E.groupIndex}}):E.type==="group"?m.createElement(b,{...Fe(b,l),"data-index":P,"data-item-index":E.index,"data-known-size":E.size,key:F,style:Ki},d(E.index,l)):m.createElement(j,{...Fe(j,l),...Ji(j,E.data),"data-index":P,"data-item-group-index":E.groupIndex,"data-item-index":E.index,"data-known-size":E.size,key:F,style:w?Xi:gs},R?a(E.index,E.groupIndex,E.data,l):a(E.index,E.data,l))})})}),Qi={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Yi={outline:"none",overflowX:"auto",position:"relative"},xn=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Zi={position:br(),top:0,width:"100%",zIndex:1};function Fe(e,t){if(typeof e!="string")return{context:t}}function Ji(e,t){return{item:typeof e=="string"?void 0:t}}const el=m.memo(function(){const e=de("HeaderComponent"),t=Ze("headerHeight"),n=de("HeaderFooterTag"),r=Ct(m.useMemo(()=>s=>{t(ht(s,"height"))},[t]),!0,de("skipAnimationFrameInResizeObserver")),o=de("context");return e?x.jsx(n,{ref:r,children:x.jsx(e,{...Fe(e,o)})}):null}),tl=m.memo(function(){const e=de("FooterComponent"),t=Ze("footerHeight"),n=de("HeaderFooterTag"),r=Ct(m.useMemo(()=>s=>{t(ht(s,"height"))},[t]),!0,de("skipAnimationFrameInResizeObserver")),o=de("context");return e?x.jsx(n,{ref:r,children:x.jsx(e,{...Fe(e,o)})}):null});function hs({useEmitter:e,useEmitterValue:t,usePublisher:n}){return m.memo(function({children:r,style:o,context:s,...i}){const u=n("scrollContainerState"),a=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("scrollerRef"),S=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:g,scrollToCallback:v}=ps(u,l,a,d,void 0,S);return e("scrollTo",v),e("scrollBy",h),x.jsx(a,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:g,style:{...S?Yi:Qi,...o},tabIndex:0,...i,...Fe(a,s),children:r})})}function ms({useEmitter:e,useEmitterValue:t,usePublisher:n}){return m.memo(function({children:r,style:o,context:s,...i}){const u=n("windowScrollContainerState"),a=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("totalListHeight"),S=t("deviation"),h=t("customScrollParent"),g=m.useRef(null),v=t("scrollerRef"),{scrollByCallback:w,scrollerRef:c,scrollToCallback:f}=ps(u,l,a,v,h);return fs(()=>{var p;return c.current=h||((p=g.current)==null?void 0:p.ownerDocument.defaultView),()=>{c.current=null}},[c,h]),e("windowScrollTo",f),e("scrollBy",w),x.jsx(a,{ref:g,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+S}:{}},...i,...Fe(a,s),children:r})})}const nl=({children:e})=>{const t=m.useContext(us),n=Ze("viewportHeight"),r=Ze("fixedItemHeight"),o=de("alignToBottom"),s=de("horizontalDirection"),i=m.useMemo(()=>No(n,a=>ht(a,s?"width":"height")),[n,s]),u=Ct(i,!0,de("skipAnimationFrameInResizeObserver"));return m.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),x.jsx("div",{"data-viewport-type":"element",ref:u,style:xn(o),children:e})},rl=({children:e})=>{const t=m.useContext(us),n=Ze("windowViewportRect"),r=Ze("fixedItemHeight"),o=de("customScrollParent"),s=Wo(n,o,de("skipAnimationFrameInResizeObserver")),i=de("alignToBottom");return m.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),x.jsx("div",{"data-viewport-type":"window",ref:s,style:xn(i),children:e})},ol=({children:e})=>{const t=de("TopItemListComponent")||"div",n=de("headerHeight"),r={...Zi,marginTop:`${n}px`},o=de("context");return x.jsx(t,{style:r,...Fe(t,o),children:e})},sl=m.memo(function(e){const t=de("useWindowScroll"),n=de("topItemsIndexes").length>0,r=de("customScrollParent"),o=de("context");return x.jsxs(r||t?al:ll,{...e,context:o,children:[n&&x.jsx(ol,{children:x.jsx(Vr,{showTopList:!0})}),x.jsxs(r||t?rl:nl,{children:[x.jsx(el,{}),x.jsx(Vr,{}),x.jsx(tl,{})]})]})}),{Component:il,useEmitter:vr,useEmitterValue:de,usePublisher:Ze}=cs($i,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},sl),ll=hs({useEmitter:vr,useEmitterValue:de,usePublisher:Ze}),al=ms({useEmitter:vr,useEmitterValue:de,usePublisher:Ze}),cl=il,ul=be(()=>{const e=W(l=>x.jsxs("td",{children:["Item $",l]})),t=W(null),n=W(l=>x.jsxs("td",{colSpan:1e3,children:["Group ",l]})),r=W(null),o=W(null),s=W({}),i=W(xr),u=W(Ot),a=(l,d=null)=>Ne(L(s,Y(S=>S[l]),Te()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:a("EmptyPlaceholder"),FillerRow:a("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:a("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:a("ScrollSeekPlaceholder"),TableBodyComponent:a("TableBody","tbody"),TableComponent:a("Table","table"),TableFooterComponent:a("TableFoot","tfoot"),TableHeadComponent:a("TableHead","thead"),TableRowComponent:a("TableRow","tr"),GroupComponent:a("Group","tr")}});ke(as,ul);br();const $r={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},dl={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ur,floor:an,max:Bt,min:zn,round:Kr}=Math;function Xr(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function fl(e){return{...dl,items:e}}function en(e,t){return e&&e.width===t.width&&e.height===t.height}function pl(e,t){return e&&e.column===t.column&&e.row===t.row}const gl=be(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:u,scrollTo:a,scrollTop:l,smoothScrollTargetReached:d,viewportHeight:S},h,g,{didMount:v,propsReady:w},{customScrollParent:c,useWindowScroll:f,windowScrollContainerState:p,windowScrollTo:C,windowViewportRect:T},I])=>{const j=W(0),b=W(0),y=W($r),k=W({height:0,width:0}),R=W({height:0,width:0}),_=me(),z=me(),B=W(0),E=W(null),P=W({column:0,row:0}),F=me(),M=me(),O=W(!1),Q=W(0),re=W(!0),oe=W(!1),ie=W(!1);Se(L(v,he(Q),ae(([A,G])=>!!G)),()=>{pe(re,!1)}),Se(L(Pe(v,re,R,k,Q,oe),ae(([A,G,K,H,,te])=>A&&!G&&K.height!==0&&H.height!==0&&!te)),([,,,,A])=>{pe(oe,!0),pr(1,()=>{pe(_,A)}),tt(L(l),()=>{pe(t,[0,0]),pe(re,!0)})}),ne(L(M,ae(A=>A!=null&&A.scrollTop>0),st(0)),b),Se(L(v,he(M),ae(([,A])=>A!=null)),([,A])=>{A&&(pe(k,A.viewport),pe(R,A.item),pe(P,A.gap),A.scrollTop>0&&(pe(O,!0),tt(L(l,wt(1)),G=>{pe(O,!1)}),pe(a,{top:A.scrollTop})))}),ne(L(k,Y(({height:A})=>A)),S),ne(L(Pe(le(k,en),le(R,en),le(P,(A,G)=>A&&A.column===G.column&&A.row===G.row),le(l)),Y(([A,G,K,H])=>({gap:K,item:G,scrollTop:H,viewport:A}))),F),ne(L(Pe(le(j),r,le(P,pl),le(R,en),le(k,en),le(E),le(b),le(O),le(re),le(Q)),ae(([,,,,,,,A])=>!A),Y(([A,[G,K],H,te,$,Z,ee,,J,ce])=>{const{column:se,row:ve}=H,{height:ge,width:Ce}=te,{width:Re}=$;if(ee===0&&(A===0||Re===0))return $r;if(Ce===0){const Tt=gr(ce,A),Sn=Tt+Math.max(ee-1,0);return fl(Xr(Tt,Sn,Z))}const Ae=bs(Re,Ce,se);let je,Ge;J?G===0&&K===0&&ee>0?(je=0,Ge=ee-1):(je=Ae*an((G+ve)/(ge+ve)),Ge=Ae*Ur((K+ve)/(ge+ve))-1,Ge=zn(A-1,Bt(Ge,Ae-1)),je=zn(Ge,Bt(0,je))):(je=0,Ge=-1);const rt=Xr(je,Ge,Z),{bottom:$e,top:Oe}=Qr($,H,te,rt),et=Ur(A/Ae),Qe=et*ge+(et-1)*ve-$e;return{bottom:$e,itemHeight:ge,items:rt,itemWidth:Ce,offsetBottom:Qe,offsetTop:Oe,top:Oe}})),y),ne(L(E,ae(A=>A!==null),Y(A=>A.length)),j),ne(L(Pe(k,R,y,P),ae(([A,G,{items:K}])=>K.length>0&&G.height!==0&&A.height!==0),Y(([A,G,{items:K},H])=>{const{bottom:te,top:$}=Qr(A,H,G,K);return[$,te]}),Te(Ht)),t);const ue=W(!1);ne(L(l,he(ue),Y(([A,G])=>G||A!==0)),ue);const xe=Xe(L(Pe(y,j),ae(([{items:A}])=>A.length>0),he(ue),ae(([[A,G],K])=>{const H=A.items[A.items.length-1].index===G-1;return(K||A.bottom>0&&A.itemHeight>0&&A.offsetBottom===0&&A.items.length===G)&&H}),Y(([[,A]])=>A-1),Te())),N=Xe(L(le(y),ae(({items:A})=>A.length>0&&A[0].index===0),st(0),Te())),D=Xe(L(le(y),he(O),ae(([{items:A},G])=>A.length>0&&!G),Y(([{items:A}])=>({endIndex:A[A.length-1].index,startIndex:A[0].index})),Te(Xo),dt(0)));ne(D,g.scrollSeekRangeChanged),ne(L(_,he(k,R,j,P),Y(([A,G,K,H,te])=>{const $=es(A),{align:Z,behavior:ee,offset:J}=$;let ce=$.index;ce==="LAST"&&(ce=H-1),ce=Bt(0,ce,zn(H-1,ce));let se=or(G,te,K,ce);return Z==="end"?se=Kr(se-G.height+K.height):Z==="center"&&(se=Kr(se-G.height/2+K.height/2)),J&&(se+=J),{behavior:ee,top:se}})),a);const q=Ne(L(y,Y(A=>A.offsetBottom+A.bottom)),0);return ne(L(T,Y(A=>({height:A.visibleHeight,width:A.visibleWidth}))),k),{customScrollParent:c,data:E,deviation:B,footerHeight:o,gap:P,headerHeight:s,increaseViewportBy:e,initialItemCount:b,itemDimensions:R,overscan:n,restoreStateFrom:M,scrollBy:i,scrollContainerState:u,scrollHeight:z,scrollTo:a,scrollToIndex:_,scrollTop:l,smoothScrollTargetReached:d,totalCount:j,useWindowScroll:f,viewportDimensions:k,windowScrollContainerState:p,windowScrollTo:C,windowViewportRect:T,...g,gridState:y,horizontalDirection:ie,initialTopMostItemIndex:Q,totalListHeight:q,...h,endReached:xe,propsReady:w,rangeChanged:D,startReached:N,stateChanged:F,stateRestoreInProgress:O,...I}},ke(hr,De,Xt,is,St,mr,vt));function bs(e,t,n){return Bt(1,an((e+n)/(an(t)+n)))}function Qr(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=or(e,t,n,r[0].index);return{bottom:or(e,t,n,r[r.length-1].index)+o,top:s}}function or(e,t,n,r){const o=bs(e.width,n.width,t.column),s=an(r/o),i=s*n.height+Bt(0,s-1)*t.row;return i>0?i+t.row:i}const hl=be(()=>{const e=W(S=>`Item ${S}`),t=W({}),n=W(null),r=W("virtuoso-grid-item"),o=W("virtuoso-grid-list"),s=W(xr),i=W("div"),u=W(Ot),a=(S,h=null)=>Ne(L(t,Y(g=>g[S]),Te()),h),l=W(!1),d=W(!1);return ne(le(d),l),{components:t,computeItemKey:s,context:n,FooterComponent:a("Footer"),HeaderComponent:a("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:a("Item","div"),itemContent:e,listClassName:o,ListComponent:a("List","div"),readyStateChanged:l,reportReadyState:d,ScrollerComponent:a("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:a("ScrollSeekPlaceholder","div")}}),ml=be(([e,t])=>({...e,...t}),ke(gl,hl)),bl=m.memo(function(){const e=_e("gridState"),t=_e("listClassName"),n=_e("itemClassName"),r=_e("itemContent"),o=_e("computeItemKey"),s=_e("isSeeking"),i=Je("scrollHeight"),u=_e("ItemComponent"),a=_e("ListComponent"),l=_e("ScrollSeekPlaceholder"),d=_e("context"),S=Je("itemDimensions"),h=Je("gap"),g=_e("log"),v=_e("stateRestoreInProgress"),w=Je("reportReadyState"),c=Ct(m.useMemo(()=>f=>{const p=f.parentElement.parentElement.scrollHeight;i(p);const C=f.firstChild;if(C){const{height:T,width:I}=C.getBoundingClientRect();S({height:T,width:I})}h({column:Yr("column-gap",getComputedStyle(f).columnGap,g),row:Yr("row-gap",getComputedStyle(f).rowGap,g)})},[i,S,h,g]),!0,!1);return fs(()=>{e.itemHeight>0&&e.itemWidth>0&&w(!0)},[e]),v?null:x.jsx(a,{className:t,ref:c,...Fe(a,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(f=>{const p=o(f.index,f.data,d);return s?x.jsx(l,{...Fe(l,d),height:e.itemHeight,index:f.index,width:e.itemWidth},p):m.createElement(u,{...Fe(u,d),className:n,"data-index":f.index,key:p},r(f.index,f.data,d))})})}),xl=m.memo(function(){const e=_e("HeaderComponent"),t=Je("headerHeight"),n=_e("headerFooterTag"),r=Ct(m.useMemo(()=>s=>{t(ht(s,"height"))},[t]),!0,!1),o=_e("context");return e?x.jsx(n,{ref:r,children:x.jsx(e,{...Fe(e,o)})}):null}),vl=m.memo(function(){const e=_e("FooterComponent"),t=Je("footerHeight"),n=_e("headerFooterTag"),r=Ct(m.useMemo(()=>s=>{t(ht(s,"height"))},[t]),!0,!1),o=_e("context");return e?x.jsx(n,{ref:r,children:x.jsx(e,{...Fe(e,o)})}):null}),Sl=({children:e})=>{const t=m.useContext(ds),n=Je("itemDimensions"),r=Je("viewportDimensions"),o=Ct(m.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return m.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),x.jsx("div",{ref:o,style:xn(!1),children:e})},yl=({children:e})=>{const t=m.useContext(ds),n=Je("windowViewportRect"),r=Je("itemDimensions"),o=_e("customScrollParent"),s=Wo(n,o,!1);return m.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),x.jsx("div",{ref:s,style:xn(!1),children:e})},wl=m.memo(function({...e}){const t=_e("useWindowScroll"),n=_e("customScrollParent"),r=n||t?Il:Cl,o=n||t?yl:Sl,s=_e("context");return x.jsx(r,{...e,...Fe(r,s),children:x.jsxs(o,{children:[x.jsx(xl,{}),x.jsx(bl,{}),x.jsx(vl,{})]})})}),{useEmitter:xs,useEmitterValue:_e,usePublisher:Je}=cs(ml,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},wl),Cl=hs({useEmitter:xs,useEmitterValue:_e,usePublisher:Je}),Il=ms({useEmitter:xs,useEmitterValue:_e,usePublisher:Je});function Yr(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,qe.WARN),t==="normal"?0:parseInt(t??"0",10)}const vn=m.createContext(void 0);function we(e,t){const n=m.useContext(vn);if(!n)throw new Error("useAudioStore must be used within CRAudioProvider");return $t(n,e,t)}function cn(){const e=m.useContext(vn);if(!e)throw new Error("useAudioStoreApi must be used within CRAudioProvider");return e}let vs=!1;function Ss(){return vs}function Zr(e){vs=e}const Tl="_run_zzb61_3",kl="_runWrap_zzb61_7",Rl="_highlight_zzb61_13",_l="_highlightleft_zzb61_14",Ml="_highlightright_zzb61_15",El="_highlightcenter_zzb61_16",jl="_underline_zzb61_48",Ol="_underlineleft_zzb61_49",zl="_underlineright_zzb61_50",Al="_underlinecenter_zzb61_51",ot={run:Tl,runWrap:kl,highlight:Rl,highlightleft:_l,highlightright:Ml,highlightcenter:El,underline:jl,underlineleft:Ol,underlineright:zl,underlinecenter:Al},Jr=e=>Symbol.iterator in e,eo=e=>"entries"in e,to=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(const[o,s]of n)if(!r.has(o)||!Object.is(s,r.get(o)))return!1;return!0},Pl=(e,t)=>{const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let o=n.next(),s=r.next();for(;!o.done&&!s.done;){if(!Object.is(o.value,s.value))return!1;o=n.next(),s=r.next()}return!!o.done&&!!s.done};function Bl(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Jr(e)&&Jr(t)?eo(e)&&eo(t)?to(e,t):Pl(e,t):to({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function qt(e){const t=m.useRef(void 0);return n=>{const r=e(n);return Bl(t.current,r)?t.current:t.current=r}}function Ll(e){const t=e.replace("#",""),n=parseInt(t.length===3?t.repeat(2):t,16),r=n>>16&255,o=n>>8&255,s=n&255;return{r,g:o,b:s}}function Gl(e){const t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return t?{r:+t[1],g:+t[2],b:+t[3]}:null}const Hl=Object.freeze({showPointer:void 0,pointerStyle:void 0,pointerColor:void 0}),ys=m.memo(function({runs:t,ns:n,baseIndex:r,preGroups:o}){const s=we(_=>_.setClipIndex),i=we(_=>_.seek),u=V(_=>_.setCurrentGlobalRunIndex),a=cn(),l=V(_=>_.rangeStartGI),d=V(_=>_.rangeEndGI),S=V(_=>_.setRange),h=l!=null&&d!=null,g=m.useCallback(_=>{var Q;const z=(Q=_.target)==null?void 0:Q.closest("[data-g]");if(!z)return;const B=Number(z.dataset.g),E=B-r;if(E<0||E>=t.length)return;const P=t[E],F=P.text??"";if(!F.trim()||!/[가-힣a-zA-Z0-9]/.test(F))return;u(B,"program");const M=P.audioChunkIndex,O=P.audioTimeMs;M!=null&&O!=null&&(s(M),i(O))},[t,r,i,s,u]),v=m.useRef(null),w=m.useRef(!1),c=m.useRef({x:0,y:0}),f=m.useCallback(_=>{var P;const z=(P=_.target)==null?void 0:P.closest("[data-g]");if(!z)return;const B=Number(z.dataset.g),E=B-r;E<0||E>=t.length||(w.current=!1,c.current={x:_.clientX,y:_.clientY},v.current&&(window.clearTimeout(v.current),v.current=null),v.current=window.setTimeout(()=>{a.getState().status!=="playing"&&(S(B,B),w.current=!0,v.current=null)},800))},[t,r,S,a]),p=m.useCallback(()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]),C=m.useCallback(_=>{if(!v.current)return;const z=_.clientX-c.current.x,B=_.clientY-c.current.y;(Math.abs(z)>5||Math.abs(B)>5)&&p()},[p]),T=m.useCallback(()=>{p()},[p]),I=p,j=p,b=V(_=>_.clearRange),y=m.useCallback(_=>{var E;if(w.current){w.current=!1;return}if(Ss())return;const z=(E=_.target)==null?void 0:E.closest("[data-g]");if(!z)return;const B=Number(z.dataset.g);isNaN(B)||h&&l!=null&&d!=null&&(b(),_.stopPropagation())},[h,l,d,b]),k=o,R=r+t.length-1;return x.jsx("span",{onClick:y,onDoubleClick:g,onPointerDown:f,onPointerMove:C,onPointerUp:T,onPointerCancel:I,onPointerLeave:j,children:k.map((_,z)=>x.jsx(Nl,{ns:n,group:_,runs:t,paraLastG:R,rangeStartGI:l,rangeEndGI:d},`${n}/grp:${z}-${_.startG}`))})},(e,t)=>e.ns===t.ns&&e.baseIndex===t.baseIndex&&e.runs===t.runs&&e.sectionId===t.sectionId),Fl=m.memo(function(){const t=m.useCallback(r=>({showSplit:r.showSplit,slash:r.breakMarks.slash,breakGapPx:r.breakGapPx}),[]),n=X(qt(t));return n.showSplit?x.jsxs(x.Fragment,{children:[x.jsx("span",{style:{display:"inline-block",width:n.breakGapPx/2}}),n.slash&&x.jsx("span",{children:" / "}),x.jsx("span",{style:{display:"inline-block",width:n.breakGapPx/2}})]}):null}),Nl=m.memo(function({ns:t,group:n,runs:r,paraLastG:o,rangeStartGI:s,rangeEndGI:i}){const u=m.useCallback(c=>{const f=c.currentGlobalRunIndex;return f!=null&&f>=n.startG&&f<=n.endG},[n]),a=V(qt(u)),l=m.useCallback(c=>a?{showPointer:c.showPointer,pointerStyle:c.pointerStyle,pointerColor:c.pointerColor}:Hl,[a]),d=X(qt(l)),S=n.r0??0,h=n.len??Math.max(0,n.endG-n.startG+1),g=a&&d.showPointer&&d.pointerStyle!=="underline",v=a&&d.showPointer&&d.pointerStyle==="underline",w=g||v?{"--hl-color":d.pointerColor,"--ul-color":d.pointerColor,"--ul-thickness":"0.3em","--ul-offset":"0.35em"}:void 0;return x.jsx(x.Fragment,{children:Array.from({length:h}).map((c,f)=>{const C=r[S+f],T=n.startG+f,I=`${t}/run:${T}`,j=!!C.split&&T!==o;let b=`${ot.runWrap}`;return g&&(h===1?b+=` ${ot.highlight}`:f===0?b+=` ${ot.highlightleft}`:f+1===h?b+=` ${ot.highlightright}`:b+=` ${ot.highlightcenter}`),v&&(h===1?b+=` ${ot.underline}`:f===0?b+=` ${ot.underlineleft}`:f+1===h?b+=` ${ot.underlineright}`:b+=` ${ot.underlinecenter}`),x.jsxs(m.Fragment,{children:[x.jsx("span",{className:b,style:w,children:x.jsx(Dl,{gi:n.startG,g:T,run:C,active:a,pointerCfg:d,isInRange:s!=null&&i!=null&&T>=s&&T<=i})}),j&&x.jsx(Fl,{})]},I)})})},(e,t)=>e.group===t.group&&e.runs===t.runs&&e.ns===t.ns&&e.rangeStartGI===t.rangeStartGI&&e.rangeEndGI===t.rangeEndGI),Dl=m.memo(function({gi:t,g:n,run:r,active:o,pointerCfg:s,isInRange:i}){const u=m.useMemo(()=>{const a={whiteSpace:"pre-wrap"};if(r.bold&&(a.fontWeight=700),r.italic&&(a.fontStyle="italic"),r.underline&&(a.textDecoration="underline"),o&&s.showPointer){const l=s.pointerColor;if(s.pointerStyle!=="underline"){a.backgroundColor=l;const d=l.startsWith("#")?Ll(l):Gl(l);d&&(.299*d.r+.587*d.g+.114*d.b)/255<.6&&(a.color="#fff")}}return i&&(a.boxShadow="inset 0 0 0 100px rgba(59, 130, 246, 0.3)"),a},[r.bold,r.italic,r.underline,o,s,i]);return x.jsx("span",{className:ot.run,style:u,"data-g":n,"data-gi":t,"data-test":(r==null?void 0:r.audioChunkIndex)||-1,children:r.text||""})},(e,t)=>e.g===t.g&&e.run===t.run&&e.active===t.active&&e.pointerCfg===t.pointerCfg&&e.isInRange===t.isInRange);function Wl({block:e,computedMarker:t,ns:n,baseIndex:r,sectionId:o,preGroups:s}){var l;const i=e.list?e.list.level*24:0,u=((l=e.list)==null?void 0:l.kind)==="bullet"?e.list.glyph??"•":void 0,a=t??u;return x.jsxs("p",{style:{width:"100%",margin:"8px 0",paddingLeft:i,textAlign:e.textAlign,boxSizing:"border-box"},children:[e.list?x.jsx("span",{style:{minWidth:16,display:"inline-block",whiteSpace:"nowrap",userSelect:"none"},children:a||""}):null,x.jsx(ys,{preGroups:s,runs:e.runs,ns:n,baseIndex:r,sectionId:o})]})}const ql=m.memo(Wl,(e,t)=>e.block===t.block&&e.computedMarker===t.computedMarker&&e.baseIndex===t.baseIndex&&e.ns===t.ns);function Vl(e,t){switch((t||"decimal").toLowerCase().replace(/[\s_-]+/g,"")){case"decimal":return String(e);case"decimalleadingzero":return e<10?`0${e}`:String(e);case"loweralpha":case"lowerlatin":return ro(e,!1);case"upperalpha":case"upperlatin":return ro(e,!0);case"lowerroman":return no(e,!1);case"upperroman":return no(e,!0);case"decimalenclosedcircle":return $l(e);default:return String(e)}}function $l(e){return e>=1&&e<=20?String.fromCharCode(9312+(e-1)):`(${e})`}function no(e,t=!0){if(e<=0)return"";const n=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];let r=e,o="";for(const[s,i]of n)for(;r>=s;)o+=i,r-=s;return t?o:o.toLowerCase()}function ro(e,t=!1){let n=e,r="";for(;n>0;)n--,r=String.fromCharCode(97+n%26)+r,n=Math.floor(n/26);return t?r.toUpperCase():r}function Sr(e){const t=new Map;return{next(n,r){const o=`${n}-${r}`,s=(t.get(o)??0)+1;return t.set(o,s),s},reset(){t.clear()}}}function yr(e,t){const n=e.list;if(!n||n.kind!=="ordered")return;const r=t.next(n.numId??0,n.level),o=Vl(r,n.format),s=(n.format||"").toLowerCase();return!/enclosed|paren/.test(s)&&s!=="decimalleadingzero"?`${o}.`:o}function Ul(e){return e.map(t=>t.type==="image"?0:t.runs.length)}function Kl(e){const t=new Array(e.length+1).fill(0);for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n];return t}function Xl(e,t){const n=[];if(!e.length)return n;const r=(o,s,i)=>{n.push({splitIndex:i??o,runs:e.slice(o,s+1),startG:t+o,endG:t+s})};for(let o=0;o<e.length;o++){const s=e[o].splitIndex;if(s===void 0){r(o,o,void 0);continue}let i=o+1;for(;i<e.length&&e[i].splitIndex===s;)i++;r(o,i-1,s),o=i-1}return n}const Ql="_scroller_kqkmq_3",Yl={scroller:Ql},Zl=m.forwardRef(function({className:t,style:n,...r},o){return x.jsx("div",{ref:o,className:`${Yl.scroller}${t?" "+t:""}`,style:n,...r})}),sr=e=>/[가-힣a-zA-Z0-9]/.test(e),Jl=e=>((e==null?void 0:e.textContent)??"").trim(),un=(e,t)=>e.querySelector(`[data-g="${t}"]`);function ea(e,t=12,n=1.5,r=.5){if(!e)return-1;const o=e.getBoundingClientRect(),s=o.top+t;let i=-1,u=1/0,a=1/0,l=-1,d=1/0,S=1/0;const h=e.querySelectorAll("[data-g]");for(let g=0;g<h.length;g++){const v=h[g];if(!v||!v.isConnected)continue;const w=Jl(v);if(!w||!sr(w))continue;const c=v.getBoundingClientRect();if(c.height<=r||c.width<=r||c.bottom<=o.top||c.top>=o.bottom)continue;if(c.top<s){const C=Math.abs(c.top-s);(C<d||C===d&&(c.top<S||l!==-1&&Number(v.dataset.g)<l))&&(d=C,l=Number(v.dataset.g),S=c.top);continue}const f=Number(v.dataset.g);if(Number.isNaN(f))continue;c.top<a-n?(a=c.top,u=c.top,i=f):c.top<=a+n&&(c.top<u||c.top===u&&(i===-1||f<i))&&(u=c.top,i=f);const p=Math.abs(c.top-s);(p<d||p===d&&(c.top<S||l!==-1&&f<l))&&(d=p,l=f,S=c.top)}return i!==-1?i:l}const ws=async(e,t,{timeoutMs:n=1200,intervalMs:r=16}={})=>{const o=performance.now();let s=un(e,t);for(;!s;){if(performance.now()-o>n)return null;await new Promise(i=>setTimeout(i,r)),s=un(e,t)}return s},Cs=e=>{const t=e.getBoundingClientRect(),n=t.top+t.height*.15,r=t.top+t.height*.8,o=Array.from(e.querySelectorAll("[data-g]"));let s=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const u of o){const a=u.getBoundingClientRect();if(a.bottom<n||a.top>r||a.height<=0)continue;const l=Number(u.dataset.g);Number.isNaN(l)||(l<s&&(s=l),l>i&&(i=l))}return!Number.isFinite(s)||!Number.isFinite(i)?null:{first:s,last:i}},ta=(e,t,{topPaddingRatio:n=.15,behavior:r="auto"}={})=>{const o=un(e,t);if(!o)return!1;const s=e.getBoundingClientRect(),i=o.getBoundingClientRect(),u=s.height*n,a=i.top-(s.top+u);return e.scrollTo({top:e.scrollTop+a,behavior:r}),!0};function na(e,t=120){return new Promise(n=>{let r=null;const o=()=>{r!=null&&window.clearTimeout(r),r=window.setTimeout(()=>{e.removeEventListener("scroll",o,{capture:!0}),n()},t)};e.addEventListener("scroll",o,{passive:!0,capture:!0}),o()})}const oo=async(e,t,{topPaddingRatio:n=.15,behavior:r="smooth",quietMs:o=120}={})=>{if(!ta(e,t,{topPaddingRatio:n,behavior:r}))return!1;await na(e,o);const i=un(e,t);if(!i)return!1;const u=e.getBoundingClientRect(),a=i.getBoundingClientRect(),l=u.height*n,d=u.top+l,S=a.top-d;return Math.abs(S)<=1},gt=()=>new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>e())})}),wr=m.createContext(null);function Is(){const e=m.useContext(wr);if(!e)throw new Error("useQuizStoreApi must be used within QuizProgressProvider");return e}function Ue(e,t){const n=m.useContext(wr);if(!n)throw new Error("useQuizStore must be used within QuizProgressProvider");return $t(n,e,t)}const Ts=()=>{const e=V(l=>l.section),t=Is(),n=Ue(l=>l.retryAllowed),r=Ue(l=>l.previousResult),o=r!=null,s=e.quizzes;if(!s||!s.length)return null;const i=o?n?`퀴즈 다시 풀기 (${s.length})`:"퀴즈 결과 보기":`퀴즈 풀기 (${s.length})`,u=o&&!n?"#64748b":"#2563eb",a=o&&!n?"0 6px 16px rgba(100,116,139,0.3)":"0 6px 16px rgba(37,99,235,0.3)";return x.jsxs("button",{onClick:()=>{t.getState().openFromSection(e)},style:{width:300,background:u,color:"white",border:"none",borderRadius:"10px",padding:"14px 28px",fontSize:"16px",fontWeight:600,cursor:"pointer",boxShadow:a,transition:"all 0.15s ease"},children:[i,o&&!n&&x.jsxs("div",{style:{fontSize:"12px",fontWeight:400,marginTop:"4px",opacity:.8},children:["이미 풀었습니다 (",r.rate,"%)"]})]})},ra="_navBtn_1fciy_2",oa="_disabled_1fciy_26",sa="_label_1fciy_32",Et={navBtn:ra,disabled:oa,label:sa};var ks={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},so=m.createContext&&m.createContext(ks),ia=["attr","size","title"];function la(e,t){if(e==null)return{};var n=aa(e,t),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)r=s[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function aa(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function dn(){return dn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},dn.apply(this,arguments)}function io(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function fn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?io(Object(n),!0).forEach(function(r){ca(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):io(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function ca(e,t,n){return t=ua(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ua(e){var t=da(e,"string");return typeof t=="symbol"?t:t+""}function da(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Rs(e){return e&&e.map((t,n)=>m.createElement(t.tag,fn({key:n},t.attr),Rs(t.child)))}function Ve(e){return t=>m.createElement(fa,dn({attr:fn({},e.attr)},t),Rs(e.child))}function fa(e){var t=n=>{var{attr:r,size:o,title:s}=e,i=la(e,ia),u=o||n.size||"1em",a;return n.className&&(a=n.className),e.className&&(a=(a?a+" ":"")+e.className),m.createElement("svg",dn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,i,{className:a,style:fn(fn({color:e.color||n.color},n.style),e.style),height:u,width:u,xmlns:"http://www.w3.org/2000/svg"}),s&&m.createElement("title",null,s),e.children)};return so!==void 0?m.createElement(so.Consumer,null,n=>t(n)):t(ks)}function lo(e){return Ve({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M18.464 2.114a.998.998 0 0 0-1.033.063l-13 9a1.003 1.003 0 0 0 0 1.645l13 9A1 1 0 0 0 19 21V3a1 1 0 0 0-.536-.886zM17 19.091 6.757 12 17 4.909v14.182z"},child:[]}]})(e)}function ao(e){return Ve({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M5.536 21.886a1.004 1.004 0 0 0 1.033-.064l13-9a1 1 0 0 0 0-1.644l-13-9A.998.998 0 0 0 5 3v18a1 1 0 0 0 .536.886zM7 4.909 17.243 12 7 19.091V4.909z"},child:[]}]})(e)}const pa=({isIcon:e=!0})=>{const t=V(i=>i.isCanPrev),n=V(i=>i.onSectionNav),r=!t,o=m.useCallback(i=>{i.stopPropagation(),i.preventDefault(),t&&(n==null||n("prev"))},[t,n]),s=t?"이전 섹션으로":"이전 섹션 없음";return e?x.jsxs("button",{type:"button",className:`${Et.navBtn} ${r?Et.disabled:""}`,disabled:r,title:s,onMouseDown:o,onClick:i=>i.stopPropagation(),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},children:[x.jsx(lo,{size:18}),x.jsx("span",{className:Et.label,children:"이전"})]}):x.jsx("button",{type:"button",disabled:r,title:s,onClick:o,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},style:{width:300,background:r?"#9ca3af":"#2563eb",color:"white",border:"none",borderRadius:"10px",padding:"14px 28px",fontSize:"16px",fontWeight:600,cursor:r?"not-allowed":"pointer",boxShadow:r?"none":"0 6px 16px rgba(37,99,235,0.3)",transition:"all 0.15s ease",opacity:r?.5:1},children:r?"첫섹션입니다":x.jsxs(x.Fragment,{children:[x.jsx(lo,{size:18,style:{display:"inline",marginRight:"8px",verticalAlign:"middle"}}),"PrevSection"]})})},pn=({isIcon:e=!0})=>{const t=V(i=>i.isCanNext),n=V(i=>i.onSectionNav),r=!t,o=m.useCallback(i=>{i.stopPropagation(),i.preventDefault(),t&&(n==null||n("next"))},[t,n]),s=t?"다음 섹션으로":"다음 섹션 없음";return e?x.jsxs("button",{type:"button",className:`${Et.navBtn} ${r?Et.disabled:""}`,disabled:r,title:s,onMouseDown:o,onClick:i=>i.stopPropagation(),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},children:[x.jsx(ao,{size:18}),x.jsx("span",{className:Et.label,children:"다음"})]}):x.jsx("button",{type:"button",disabled:r,title:s,onClick:o,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},style:{width:300,background:r?"#9ca3af":"#2563eb",color:"white",border:"none",borderRadius:"10px",padding:"14px 28px",fontSize:"16px",fontWeight:600,cursor:r?"not-allowed":"pointer",boxShadow:r?"none":"0 6px 16px rgba(37,99,235,0.3)",transition:"all 0.15s ease",opacity:r?.5:1},children:r?"마지막섹션입니다":x.jsxs(x.Fragment,{children:["NextSection",x.jsx(ao,{size:18,style:{display:"inline",marginLeft:"8px",verticalAlign:"middle"}})]})})};function _s(e,t){let n=0,r=e.length-1;for(;n<r;){const o=Math.floor((n+r+1)/2);e[o]<=t?n=o:r=o-1}return n}function co(e,t,n=.2,r=.8){const o=e.querySelector(`[data-g="${t}"]`);if(!o)return!1;const s=e.getBoundingClientRect(),i=o.getBoundingClientRect();if(i.height<=0||s.height<=0)return!1;const u=(i.top+i.height/2-s.top)/s.height;return u>=n&&u<=r}const ga=e=>e==="instant"?"auto":e;function ha(e){const{sc:t,virtRef:n,prefix:r,recorderStoreApi:o,programmaticScrollRef:s,scrollToGISeqRef:i}=e,u=p=>{const C=t.scrollTop,T=t.scrollHeight-t.clientHeight,I=T>0?C/T:0;let j=0;const b=t.querySelector(`[data-g="${p}"]`);if(b){const y=t.getBoundingClientRect(),k=b.getBoundingClientRect(),R=y.height>0?y.height/t.clientHeight:1,_=(k.top-y.top)/R/t.clientHeight;j=Math.max(0,Math.min(_,1))}o.getState().emit({type:"scroll",payload:{scrollTop:C,scrollRatio:I,anchorGI:p,anchorOffsetRatio:j}})},a=async(p,C="smooth")=>{var I;const T=_s(r,p);(I=n.current)==null||I.scrollToIndex({index:T,align:"start",behavior:ga(C)}),await ws(t,p)},l=()=>new Promise(p=>requestAnimationFrame(()=>p())),d=async p=>{if(co(t,p,.1,.7))return u(p),!0;if(t.scrollTop>=t.scrollHeight-t.clientHeight-1){const y=t.querySelector(`[data-g="${p}"]`);if(y){const k=t.getBoundingClientRect(),R=y.getBoundingClientRect();if(R.bottom>k.top&&R.top<k.bottom)return u(p),!0}}s.current=!0;const T=t.querySelector(`[data-g="${p}"]`),I=t.getBoundingClientRect();let j=t.scrollTop<=1?0:.1;if(T){const y=T.getBoundingClientRect();j=((y.top+y.height/2-I.top)/I.height>.5,.15)}return!!T?(await oo(t,p,{behavior:"smooth",topPaddingRatio:j}),await l()):(await a(p,"auto"),await oo(t,p,{behavior:"auto",topPaddingRatio:.15})),s.current=!1,u(p),co(t,p,.1,.7)};return{ensureVisibleGI:d,scrollToGI:async p=>d(p),getVisibleRange:()=>Cs(t),getScrollTop:()=>t.scrollTop,setScrollTop:p=>{var C;(C=n.current)==null||C.scrollTo({top:p})},getAnchorOffsetRatio:p=>{const C=t.querySelector(`[data-g="${p}"]`);if(!C)return 0;const T=C.getBoundingClientRect(),I=t.getBoundingClientRect(),j=I.height>0?I.height/t.clientHeight:1;return(T.top-I.top)/j/t.clientHeight},scrollToGIAtOffset:async(p,C)=>{var j,b;const T=t.querySelector(`[data-g="${p}"]`);if(T){const y=T.getBoundingClientRect(),k=t.getBoundingClientRect(),R=k.height>0?k.height/t.clientHeight:1,_=(y.top-k.top)/R,z=C*t.clientHeight;if(Math.abs(_-z)<=3)return}const I=++i.current;s.current=!0;try{const y=()=>new Promise(B=>requestAnimationFrame(()=>B())),k=()=>{const B=t.querySelector(`[data-g="${p}"]`);if(!B)return null;const E=B.getBoundingClientRect(),P=t.getBoundingClientRect(),F=P.height>0?P.height/t.clientHeight:1,M=(E.top-P.top)/F,O=C*t.clientHeight;return{delta:M-O,cur:M,tgt:O}};if(I!==i.current||(await a(p,"auto"),I!==i.current)||(await y(),await y(),await y(),I!==i.current))return;const R=k(),_=t.scrollTop>=t.scrollHeight-t.clientHeight-1,z=t.scrollTop<=1;if(R&&Math.abs(R.delta)>1&&!(_&&R.delta>0)&&!(z&&R.delta<0)){const B=t.scrollTop;if((j=n.current)==null||j.scrollBy({top:R.delta}),await y(),I!==i.current)return;for(let E=0;E<3;E++){const P=k();if(!P||Math.abs(P.delta)<=2)break;const F=t.scrollTop;if((b=n.current)==null||b.scrollBy({top:P.delta}),await y(),I!==i.current)return;if(Math.abs(t.scrollTop-F)<1)break}}}finally{I===i.current&&(s.current=!1)}},getScrollRatio:()=>{const p=t.scrollHeight-t.clientHeight;return p>0?t.scrollTop/p:0}}}const ma=({scrollContainerRef:e,virtRef:t,prefix:n})=>{const r=V(M=>M.setCurrentGlobalRunIndex),o=V(M=>M.registerSectionScrollApi),s=we(M=>M.scrollLock),i=we(M=>M.syncToGI),u=bt(),a=lt(),l=Go(M=>M.isPlaybackMode),d=m.useRef(!1),S=m.useRef(null),h=m.useRef(null),g=m.useRef(0),v=m.useRef(null),w=m.useRef(-1),c=m.useCallback(()=>{if(l||s)return;S.current=null;const M=h.current;if(!M)return;const O=ea(M,5);O!==-1&&O!==w.current&&(w.current=O,i(O))},[l,s,i]),f=m.useCallback(M=>{h.current=M,S.current==null&&(S.current=requestAnimationFrame(c))},[c]),p=m.useCallback(M=>{var re;h.current=M,(re=v.current)==null||re.abort();const O=new AbortController;v.current=O,new Promise(oe=>{"onscrollend"in M?M.addEventListener("scrollend",()=>oe(),{once:!0}):setTimeout(oe,150)}).then(()=>{if(O.signal.aborted)return;v.current=null,c();const oe=w.current;oe!==-1&&r(oe,"scroll"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(O.signal.aborted)return;const ie=w.current;if(ie===-1)return;const ue=M.scrollTop,xe=M.scrollHeight-M.clientHeight,N=xe>0?ue/xe:0;let D=0;const q=M.querySelector(`[data-g="${ie}"]`);if(q){const A=M.getBoundingClientRect(),G=q.getBoundingClientRect(),K=A.height>0?A.height/M.clientHeight:1,H=(G.top-A.top)/K/M.clientHeight;D=Math.max(0,Math.min(H,1))}u.getState().emit({type:"scroll",payload:{scrollTop:ue,scrollRatio:N,anchorGI:ie,anchorOffsetRatio:D}})})})})},[c,u,r]),C=m.useRef(!1),T=m.useCallback(M=>{l||s||d.current&&(C.current||(f(M),p(M)))},[l,s,f,p]),I=m.useRef(void 0),j=m.useRef(void 0),b=m.useRef(void 0),y=m.useRef(void 0);m.useEffect(()=>{const M=e.current;if(M)return I.current=()=>{d.current=!0},j.current=()=>{d.current=!0},b.current=()=>{d.current=!0},y.current=()=>T(M),M.addEventListener("wheel",I.current,{passive:!0}),M.addEventListener("touchmove",j.current,{passive:!0}),window.addEventListener("keydown",b.current,{passive:!0}),M.addEventListener("scroll",y.current,{passive:!0}),()=>{var O;M.removeEventListener("wheel",I.current),M.removeEventListener("touchmove",j.current),window.removeEventListener("keydown",b.current),M.removeEventListener("scroll",y.current),S.current!=null&&cancelAnimationFrame(S.current),(O=v.current)==null||O.abort()}},[T,e]),m.useEffect(()=>{const M=e.current;if(!M||!s)return;const O=ie=>{ie.preventDefault(),ie.stopPropagation(),d.current=!1},Q=ie=>{ie.preventDefault(),ie.stopPropagation(),d.current=!1},re=ie=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(ie.key)&&(ie.preventDefault(),ie.stopPropagation(),d.current=!1)},oe={overscrollBehavior:M.style.overscrollBehavior,touchAction:M.style.touchAction};return M.style.overscrollBehavior="contain",M.style.touchAction="none",M.addEventListener("wheel",O,{passive:!1}),M.addEventListener("touchmove",Q,{passive:!1}),window.addEventListener("keydown",re,{passive:!1}),()=>{M.removeEventListener("wheel",O),M.removeEventListener("touchmove",Q),window.removeEventListener("keydown",re),M.style.overscrollBehavior=oe.overscrollBehavior,M.style.touchAction=oe.touchAction}},[s,e]);const k=m.useRef({first:-1,last:-1}),R=m.useRef(!1),_=m.useCallback(()=>{const M=e.current;if(!M)return;const O=Cs(M),Q=(O==null?void 0:O.first)??-1,re=(O==null?void 0:O.last)??-1;k.current={first:Q,last:re}},[e]),z=m.useRef(!1),B=m.useCallback(()=>{const M=e.current;if(!M||z.current)return;z.current=!0;const O=Math.min(M.scrollTop+Math.floor(M.clientHeight*.6),M.scrollHeight-M.clientHeight);requestAnimationFrame(()=>{M.scrollTo({top:O,behavior:"instant"})})},[e]);m.useEffect(()=>{!R.current&&s&&(z.current=!1,_()),R.current=s},[s,_]);const E=m.useRef(0),P=m.useRef(0);m.useEffect(()=>{if(!s||l)return;const M=Q=>{const re=e.current;if(!re)return;const{first:oe,last:ie}=k.current;if(oe===-1||ie===-1){B();return}const ue=re.querySelector(`[data-g="${Q}"]`);if(ue){const N=re.getBoundingClientRect(),D=ue.getBoundingClientRect();if(N.height>0){const q=(D.top-N.top)/N.height,A=(D.bottom-N.top)/N.height;if(q>=.02&&A<=.95){_();return}}}const xe=++E.current;window.clearTimeout(P.current),P.current=window.setTimeout(()=>{if(xe!==E.current)return;const N=a.getState().progress.getSectionScrollApi();N?N.ensureVisibleGI(Q).then(D=>{xe===E.current&&(D?_():B())}):B()},80)};M(a.getState().progress.currentGlobalRunIndex);const O=a.subscribe((Q,re)=>{const oe=Q.progress.currentGlobalRunIndex;oe!==re.progress.currentGlobalRunIndex&&M(oe)});return()=>{O(),E.current+=1;const Q=P.current;window.clearTimeout(Q)}},[s,l,B,_,e,a]);const F=m.useCallback(()=>{const M=e.current;if(M)return ha({sc:M,virtRef:t,prefix:n,recorderStoreApi:u,programmaticScrollRef:C,scrollToGISeqRef:g})},[e,t,n,u]);return m.useEffect(()=>(o(F()),()=>o(void 0)),[F,o]),null};function ba({section:e,blocks:t,nsPrefix:n}){const r=m.useMemo(()=>{const R=[],_=Sr();return t.forEach((z,B)=>{z.type==="paragraph"&&(R[B]=yr(z,_))}),R},[t]),o=V(R=>{var _;return((_=R.layout)==null?void 0:_.prefix)??[]}),s=V(R=>{var _;return((_=R.derivedNav)==null?void 0:_.splitGroupsPerBlock)??[]}),i=X(R=>R.marginX),u=X(R=>R.viewportHeight),a=m.useRef({start:0,end:0}),l=m.useCallback(R=>{const _=t[R],z=`${n}blk-${_.id}`;if(_.type==="image"){const{src:P,alt:F,width:M,height:O}=_,Q=M&&O?`${M} / ${O}`:"4 / 3",re=R>=a.current.start&&R<=a.current.end,oe=u>80?Math.floor((u-80)*.6):void 0;return x.jsxs("div",{style:{margin:"12px 0",textAlign:"center",width:"100%"},children:[x.jsx("div",{style:{position:"relative",width:"100%",maxHeight:oe,aspectRatio:Q},children:x.jsx("img",{src:P,alt:F||"",loading:re?"eager":"lazy",style:{pointerEvents:"none",position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"contain",display:"block"}})}),F&&x.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:F})]})}const B=r[R]??void 0,E=s[R];return x.jsx("div",{style:{maxWidth:860,display:"flex"},children:x.jsx(ql,{block:_,computedMarker:B,ns:z,baseIndex:o[R],sectionId:e.section_id,preGroups:E})})},[t,r,o,n,e,s,u]),d=m.useRef(null),S=m.useCallback(R=>{d.current=R},[]),h=m.useMemo(()=>m.memo(R=>{const{style:_,children:z,...B}=R;return x.jsx("div",{...B,style:_,children:x.jsx("div",{style:{boxSizing:"border-box",paddingRight:`${i}px`,paddingLeft:`${i}px`,maxWidth:860,margin:"0 auto",width:"100%",height:"100%"},children:z})})}),[i]),g=m.useRef(null),v=m.useMemo(()=>t.map(R=>R.id),[t]),w=Go(R=>R.isPlaybackMode),[c,f]=m.useState(!1);m.useEffect(()=>{f(w)},[t,w]);const p=m.useCallback(()=>{f(!0)},[]),C=m.useCallback(()=>{const R=Math.max(80,Math.floor(u*.5));if(!c)return x.jsx("div",{style:{height:R}});const _=e.quizzes;return _&&_.length?x.jsxs("div",{style:{display:"block"},children:[x.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:x.jsx(Ts,{})}),x.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:x.jsx(pn,{isIcon:!1})}),x.jsx("div",{style:{height:R,width:"100%"}})]}):x.jsxs("div",{children:[x.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:x.jsx(pn,{isIcon:!1})}),x.jsx("div",{style:{height:R}})]})},[c,e,u]),T=m.useMemo(()=>({Item:h,Header:()=>x.jsx("div",{style:{height:40}}),Footer:C,Scroller:Zl}),[C,h]),I=m.useCallback(R=>v[R],[v]),j=lt(),[b]=m.useState(()=>j.getState().progress.currentGlobalRunIndex??0),y=m.useMemo(()=>{if(!o.length)return 0;const R=o[o.length-1],_=Math.max(0,Math.min(b,R));return _s(o,_)},[o,b]),k=lt();return m.useEffect(()=>{let R=!1;return(async()=>{let _=d.current;if(!_){for(let P=0;P<20;P++){if(await new Promise(F=>setTimeout(F,50)),R)return;if(_=d.current,_)break}if(!_)return}const z=k.getState().progress.currentGlobalRunIndex,B=k.getState().progress.setSectionLoading,E=z!=null&&z>=0?z:0;await ws(_,E),!R&&(await gt(),await gt(),await gt(),await gt(),!R&&B(!1))})(),()=>{R=!0}},[d,k]),x.jsxs(x.Fragment,{children:[x.jsx(cl,{ref:g,style:{height:"100%",width:"100%",boxSizing:"border-box"},defaultItemHeight:99,computeItemKey:I,totalCount:t.length,itemContent:l,initialTopMostItemIndex:y,increaseViewportBy:{top:100,bottom:100},endReached:p,components:T,scrollerRef:S}),x.jsx(ma,{scrollContainerRef:d,virtRef:g,prefix:o})]})}function xa(e){var r,o;const t=e;if(!t)return!1;const n=((o=(r=t.tagName)==null?void 0:r.toLowerCase)==null?void 0:o.call(r))??"";return!!(["a","button","input","textarea","select","label"].includes(n)||t.isContentEditable)}function va(){const e=V(v=>v.section),t=X(v=>v.theme),n=X(v=>v.fontFamily),r=X(v=>v.fontSizePx),o=X(v=>v.lineHeight),s=sn[t],{blocks:i,nsPrefix:u}=m.useMemo(()=>({sectionId:e.section_id,blocks:e.ast.blocks,nsPrefix:`sec-${e.section_id??"0"}/`}),[e]),a=gn(),l=m.useCallback(()=>{const{isSettingsOpen:v,setSettingsOpen:w,toggleOverlays:c}=a.getState();v?w(!1):c()},[a]),{onClick:d,onDoubleClick:S}=Ys({onSingle:l,onDouble:()=>{},delay:250,shouldIgnoreTarget:xa}),h=m.useMemo(()=>({flex:1,fontFamily:n,background:s.bg,color:s.fg,fontSize:r,lineHeight:o,overflow:"hidden",WebkitTextSizeAdjust:"none",MozTextSizeAdjust:"none",textSizeAdjust:"none"}),[n,s.bg,s.fg,r,o]),g=m.useMemo(()=>({margin:"0 auto",width:"100%",height:"100%"}),[]);return x.jsx("div",{onClick:d,onDoubleClick:S,style:h,children:x.jsx("div",{style:g,children:x.jsx(ba,{section:e,blocks:i,nsPrefix:u})})})}function Sa(e){return Ve({attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z",clipRule:"evenodd"},child:[]}]})(e)}function ya(e){return Ve({attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0A9.972 9.972 0 0119 10a9.972 9.972 0 01-2.929 7.071 1 1 0 01-1.414-1.414A7.971 7.971 0 0017 10c0-2.21-.894-4.208-2.343-5.657a1 1 0 010-1.414zm-2.829 2.828a1 1 0 011.415 0A5.983 5.983 0 0115 10a5.984 5.984 0 01-1.757 4.243 1 1 0 01-1.415-1.415A3.984 3.984 0 0013 10a3.983 3.983 0 00-1.172-2.828 1 1 0 010-1.415z",clipRule:"evenodd"},child:[]}]})(e)}function wa(e){return Ve({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(e)}function Ca(e){return Ve({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M9.64 7.64c.23-.5.36-1.05.36-1.64 0-2.21-1.79-4-4-4S2 3.79 2 6s1.79 4 4 4c.59 0 1.14-.13 1.64-.36L10 12l-2.36 2.36C7.14 14.13 6.59 14 6 14c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.59-.13-1.14-.36-1.64L12 14l7 7h3v-1L9.64 7.64zM6 8c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm0 12c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm6-7.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM19 3l-6 6 2 2 7-7V3h-3z"},child:[]}]})(e)}function Ia(e){return Ve({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z",opacity:".87"},child:[]},{tag:"path",attr:{d:"M17.51 3.87 15.73 2.1 5.84 12l9.9 9.9 1.77-1.77L9.38 12l8.13-8.13z"},child:[]}]})(e)}function Ta(e){return Ve({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"},child:[]},{tag:"path",attr:{d:"M12 18c-.328 0 -.652 -.017 -.97 -.05c-3.172 -.332 -5.85 -2.315 -8.03 -5.95c2.4 -4 5.4 -6 9 -6c3.465 0 6.374 1.853 8.727 5.558"},child:[]},{tag:"path",attr:{d:"M18 18m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M20.2 20.2l1.8 1.8"},child:[]}]})(e)}function ka(e){return Ve({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},child:[]},{tag:"path",attr:{d:"M4 8v-2a2 2 0 0 1 2 -2h2"},child:[]},{tag:"path",attr:{d:"M4 16v2a2 2 0 0 0 2 2h2"},child:[]},{tag:"path",attr:{d:"M16 4h2a2 2 0 0 1 2 2v2"},child:[]},{tag:"path",attr:{d:"M16 20h2a2 2 0 0 0 2 -2v-2"},child:[]}]})(e)}const Ra="_wrap_1hfub_4",_a="_visible_1hfub_25",Ma="_compact_1hfub_31",Ea="_row2_1hfub_34",ja="_controls_1hfub_44",Oa="_row1_1hfub_52",za="_groupExpand_1hfub_80",Aa="_groupPlayback_1hfub_81",Pa="_groupSpeed_1hfub_82",Ba="_groupFeatures_1hfub_83",La="_groupNav_1hfub_84",Ga="_btn_1hfub_116",Ha="_btnForbidden_1hfub_141",Fa="_btnActive_1hfub_147",Na="_label_1hfub_158",Da="_compactBtn_1hfub_168",Ie={wrap:Ra,visible:_a,compact:Ma,row2:Ea,controls:ja,row1:Oa,groupExpand:za,groupPlayback:Aa,groupSpeed:Pa,groupFeatures:Ba,groupNav:La,btn:Ga,btnForbidden:Ha,btnActive:Fa,label:Na,compactBtn:Da},Wa=m.memo(function(){const t=m.useRef(null),n=m.useContext(mt),r=(n==null?void 0:n.getState().isPlaybackMode)??!1,o=we(y=>y.status),s=we(y=>y.currentTimeMs),i=we(y=>y.currentClip),u=we(y=>y.playbackKind),a=X(y=>y.muteAudio),l=X(y=>y.audioSpeed),d=we(y=>y.getClipSrc),S=we(y=>y._onTime),h=we(y=>y._onEnded),g=we(y=>y._onError),v=V(y=>y.setCurrentGlobalRunIndex),w=V(y=>y.getSectionScrollApi),c=V(y=>y.snapToReadable),f=V(y=>y.edgeReadable),p=m.useRef(null),C=m.useRef(null),T=m.useRef(!1),I=m.useRef(null);m.useEffect(()=>{u==="real"&&(T.current=!0)},[u]);const j=m.useMemo(()=>{const y=d(i);if(!y)return null;try{return new URL(y,window.location.href).href}catch{return y}},[i,d]);m.useEffect(()=>{T.current=!0},[j]),m.useEffect(()=>{const y=t.current;if(!y)return;const k=()=>{if(y.paused||y.ended)return;const z=y.currentTime*1e3;T.current&&z===0||(z>0&&(T.current=!1),S(z))},R=()=>{var B,E;h();const z=f(1);if(typeof z=="number"&&z>=0){v(z,"audio");const P=w();(B=P==null?void 0:P.ensureVisibleGI)==null||B.call(P,z),(E=P==null?void 0:P.stepPage)==null||E.call(P,1)}},_=z=>{const B=z.currentTarget;console.warn("Audio error",{networkState:B.networkState,readyState:B.readyState}),g()};return y.addEventListener("timeupdate",k),y.addEventListener("ended",R),y.addEventListener("error",_),()=>{y.removeEventListener("timeupdate",k),y.removeEventListener("ended",R),y.removeEventListener("error",_)}},[S,h,g,f,v,w]),m.useEffect(()=>{if(r)return;const y=t.current;if(!y)return;if(!j){try{y.pause()}catch(z){console.log("pause error",z)}C.current=null;return}const k=y.currentSrc||y.src||null,R=!k||k!==j;if(R){try{y.pause()}catch(z){console.log("pause error",z)}y.src=j;try{y.load()}catch(z){console.log("load error",z)}C.current=j}y.muted=!!a,y.volume=1,y.playbackRate=typeof l=="number"?l:1;const _=async()=>{R&&await new Promise(z=>{let B=!1;const E=()=>{B||(B=!0,y.removeEventListener("loadedmetadata",E),y.removeEventListener("canplay",E),z())};y.addEventListener("loadedmetadata",E),y.addEventListener("canplay",E),y.readyState>=1&&E()});try{await y.play()}catch(z){console.warn("el.play() failed",z)}};if(o==="loading"||o==="playing")_();else try{y.pause()}catch(z){console.log("pause error",z)}},[j,a,o,l,r]),m.useEffect(()=>{if(r)return;const y=t.current;if(!y||u!=="real")return;const k=s/1e3;if(Number.isFinite(k)){if(y.readyState<1){p.current=s;const R=()=>{if(p.current!=null){const _=p.current/1e3;try{y.currentTime=_}catch(z){console.log("currentTime보정 오류",z)}p.current=null}y.removeEventListener("loadedmetadata",R),y.removeEventListener("canplay",R)};y.addEventListener("loadedmetadata",R),y.addEventListener("canplay",R);return}if(Math.abs(y.currentTime-k)>.2)try{y.currentTime=k}catch(R){console.log("currentTime보정오류",R)}}},[s,u,r]);const b=we(y=>y.getGIFromCT);return m.useEffect(()=>{var R,_;if(r||u!=="real"||o!=="playing"&&o!=="loading")return;const y=b(i,s);if(y<0)return;const k=c(y);k!==I.current&&(I.current=k,v(k,"audio"),k%5===0&&((_=(R=w())==null?void 0:R.ensureVisibleGI)==null||_.call(R,k)))},[o,i,s,u,b,c,v,w,r]),x.jsx("audio",{ref:t,preload:"auto",style:{display:"none"}})});function qa(){return x.jsx(Wa,{})}const Va="_scrubberWrap_uw0cd_2",$a="_labels_uw0cd_9",Ua="_index_uw0cd_15",Ka="_controls_uw0cd_19",Xa="_percent_uw0cd_25",Qa="_range_uw0cd_46",kt={scrubberWrap:Va,labels:$a,index:Ua,controls:Ka,percent:Xa,range:Qa};function Ya(){const e=X(I=>I.isDev),t=V(I=>I.currentGlobalRunIndex),n=V(I=>I.totalRuns),r=V(I=>I.setCurrentGlobalRunIndex),o=V(I=>I.getSectionScrollApi),s=V(I=>I.giToPercentTotal),i=V(I=>I.percentToGITotal),u=V(I=>I.snapToReadable),a=we(I=>I.scrollLock),l=we(I=>I.pause),d=we(I=>I.play),S=we(I=>I.syncToGI),[h,g]=m.useState(()=>s(t||0));m.useEffect(()=>{g(s(t||0))},[t,s]);const v=m.useRef(!1),w=m.useMemo(()=>Math.max(0,Math.min(t??0,Math.max(0,(n??1)-1)))+1,[t,n]),c=m.useCallback(()=>{a&&(l(),v.current=!0)},[a,l]),f=m.useCallback(I=>{g(Number(I.currentTarget.value))},[]),p=m.useCallback(async()=>{const I=i(h),j=u(I);l(),r(j,"scrubber-commit"),S(j);const b=o();b!=null&&b.ensureVisibleGI&&await b.ensureVisibleGI(j),v.current&&(v.current=!1,d())},[h,i,u,l,r,S,o,d]),C=m.useMemo(()=>({"--pct":`${h}%`}),[h]),T=m.useMemo(()=>Math.round(h),[h]);return x.jsxs("div",{className:kt.scrubberWrap,children:[e&&x.jsx("div",{className:kt.labels,children:x.jsxs("span",{className:kt.index,children:[w," / ",n||0]})}),x.jsxs("div",{className:kt.controls,children:[x.jsx("input",{type:"range",className:kt.range,min:0,max:100,step:.5,value:h,style:C,onMouseDown:c,onTouchStart:c,onChange:f,onMouseUp:()=>{p()},onTouchEnd:()=>{p()},onKeyUp:I=>I.key==="Enter"||I.key===" "?void p():void 0,"aria-label":"진행률"}),x.jsxs("span",{className:kt.percent,children:[T,"%"]})]})]})}const Za=m.memo(Ya),Ja=m.memo(function(){const t=m.useContext(mt),n=(t==null?void 0:t.getState().isPlaybackMode)??!1,r=we(k=>k.playbackKind),o=we(k=>k.status),s=we(k=>k.fake),i=X(k=>k.audioSpeed),u=we(k=>k.pause),a=V(k=>k.totalRuns),l=V(k=>k.currentGlobalRunIndex),d=V(k=>k.setCurrentGlobalRunIndex),S=V(k=>k.getSectionScrollApi),h=V(k=>k.nextReadableFrom),g=V(k=>k.edgeReadable),v=m.useRef(null),w=m.useRef(null),c=m.useRef(0),f=m.useRef(-1),p=m.useRef(!1),C=!n&&r==="fake"&&o==="playing",T=Math.max(1,(s==null?void 0:s.totalWords)??1),I=m.useMemo(()=>{const k=200*i;return T/k*6e4},[T,i]),j=m.useMemo(()=>!a||a<=1||I<=0?0:(a-1)/I,[a,I]);m.useEffect(()=>{if(!C)return;const k=Math.max(0,Math.min(l??0,Math.max(0,(a??1)-1)));c.current=k,f.current=k,w.current=null,p.current=!1},[C,l,a]);const b=m.useRef(-1);m.useEffect(()=>{if(!a){b.current=-1;return}const k=g(1);b.current=k??-1},[g,a]);const y=m.useCallback(k=>{(async()=>{var Q,re,oe;if(!C){v.current=null;return}if(!a||a<=1||j<=0){v.current=null;return}const R=w.current;w.current=k;const _=R==null?0:Math.max(0,k-R),z=a-1;c.current=Math.min(z,c.current+j*_);const B=Math.floor(c.current),E=S(),P=b.current>=0?b.current:z,F=h(B,1);if(F==null||c.current>=z){if(f.current<P){f.current=P,d(P,"audio"),await((Q=E==null?void 0:E.ensureVisibleGI)==null?void 0:Q.call(E,P)),v.current=requestAnimationFrame(y);return}if(!p.current){p.current=!0,v.current=requestAnimationFrame(y);return}p.current=!1,u(),(re=E==null?void 0:E.stepPage)==null||re.call(E,1),v.current=null;return}const O=F;O!==f.current&&(f.current=O,d(O,"audio"),O%5===0&&await((oe=E==null?void 0:E.ensureVisibleGI)==null?void 0:oe.call(E,O))),v.current=requestAnimationFrame(y)})().catch(console.error)},[C,a,j,h,d,S,u]);return m.useEffect(()=>(C?v.current==null&&(v.current=requestAnimationFrame(y)):(v.current&&(cancelAnimationFrame(v.current),v.current=null),w.current=null),()=>{v.current&&(cancelAnimationFrame(v.current),v.current=null)}),[C,y]),null}),ec=m.memo(function(){return x.jsx(Ja,{})}),tc="data:image/svg+xml,%3csvg%20width='111'%20height='111'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20overflow='hidden'%3e%3cg%20transform='translate(-435%2011)'%3e%3cpath%20d='M532.723%2046.8125C530.242%2046.8292%20527.8%2047.4292%20525.593%2048.5642%20523.298%2049.7713%20520.952%2050.8767%20518.608%2051.8815%20517.451%2031.9953%20500.391%2016.8128%20480.505%2017.9704%20462.359%2019.0268%20447.834%2033.4215%20446.615%2051.5578L438.476%2048.1353%20438.476%2049.9344C438.473%2054.7251%20441.432%2059.0185%20445.91%2060.721%20446.509%2060.9604%20447.138%2061.1708%20447.767%2061.3801%20448.053%2061.4761%20448.339%2061.5709%20448.622%2061.6692L447.745%2066.7254C447.463%2068.2415%20447.818%2069.8071%20448.728%2071.0521%20449.635%2072.2874%20450.984%2073.1242%20452.493%2073.3877L452.768%2073.4282C453.011%2073.488%20453.259%2073.5198%20453.509%2073.523%20456.31%2073.5182%20458.699%2071.4953%20459.166%2068.7338L459.781%2064.8673C468.886%2066.8727%20478.184%2067.875%20487.508%2067.8562%20493.267%2067.8674%20499.021%2067.5125%20504.736%2066.7937%20504.893%2066.7613%20505.041%2066.7405%20505.184%2066.7231L505.562%2068.8379C505.986%2071.6231%20508.396%2073.6706%20511.213%2073.6375%20511.583%2073.648%20511.953%2073.5977%20512.307%2073.4883%20515.422%2072.958%20517.518%2070.0024%20516.988%2066.8869%20516.984%2066.8688%20516.981%2066.8509%20516.978%2066.833L516.758%2065.6767C522.066%2065.3125%20527.42%2065.3125%20532.607%2065.3125L532.723%2065.3125C537.831%2065.6255%20542.226%2061.7378%20542.539%2056.6292%20542.852%2051.5205%20538.965%2047.1255%20533.856%2046.8125%20533.479%2046.7894%20533.1%2046.7894%20532.723%2046.8125ZM516.326%2052.7256C511.914%2054.5082%20507.352%2055.8913%20502.693%2056.858L492.697%2041.007%20501.916%2026.3469C510.579%2032.4029%20515.911%2042.1631%20516.326%2052.7256ZM500.254%2057.3217C497.133%2057.8531%20493.977%2058.1542%20490.811%2058.2224L487.449%2058.2224C480.061%2058.2766%20472.682%2057.6921%20465.394%2056.4753L474.504%2042.1644%20490.692%2042.1644ZM482.602%2020.2188C488.73%2020.2155%20494.742%2021.8953%20499.981%2025.075L490.693%2039.8507%20474.491%2039.8195%20465.194%2025.0415C470.449%2021.8782%20476.468%2020.2107%20482.602%2020.2188ZM463.254%2026.2995%20472.504%2041.0023%20462.938%2056.0267C458.169%2055.1133%20453.47%2053.8672%20448.875%2052.2977%20449.378%2041.8709%20454.689%2032.2672%20463.254%2026.2995ZM456.876%2068.3719C456.595%2070.0115%20455.173%2071.2097%20453.509%2071.2094%20453.431%2071.2042%20453.354%2071.191%20453.278%2071.1701%20453.133%2071.1343%20452.984%2071.1101%20452.835%2071.0972%20451.94%2070.9264%20451.142%2070.4243%20450.601%2069.6912%20450.063%2068.9533%20449.853%2068.0254%20450.023%2067.1278L450.844%2062.3872%20457.525%2064.2962ZM514.123%2069.8103C513.566%2070.5637%20512.74%2071.0728%20511.817%2071.2313L511.657%2071.2718C511.514%2071.32%20511.363%2071.3392%20511.213%2071.3285%20509.525%2071.3698%20508.075%2070.1378%20507.844%2068.4656L507.486%2066.4688%20514.501%2065.8548%20514.701%2067.2527C514.87%2068.1485%20514.661%2069.0742%20514.123%2069.8103ZM532.723%2063%20532.607%2063C526.955%2063%20521.113%2063%20515.284%2063.4625L515.276%2063.4625%20515.276%2063.4625%20505.9%2064.2904%20504.36%2064.5078C498.77%2065.2064%20493.141%2065.5509%20487.508%2065.5391%20477.952%2065.5601%20468.425%2064.4858%20459.114%2062.3375L450.263%2059.8168%20446.738%2058.5658C443.792%2057.4525%20441.62%2054.9086%20440.982%2051.8237%20454.33%2057.5309%20470.023%2060.5383%20486.577%2060.5383%20486.868%2060.5383%20487.161%2060.5383%20487.452%2060.5383L490.828%2060.5383C500.421%2060.2575%20509.874%2058.1665%20518.689%2054.3755L518.797%2054.3304C521.437%2053.2216%20524.086%2051.9728%20526.649%2050.6235%20528.526%2049.6491%20530.608%2049.1354%20532.723%2049.125%20536.554%2048.8199%20539.908%2051.6785%20540.213%2055.5099%20540.518%2059.3414%20537.659%2062.6949%20533.828%2063%20533.46%2063.0293%20533.091%2063.0293%20532.723%2063Z'/%3e%3cpath%20d='M534.442%2053.75C534.442%2055.0272%20533.407%2056.0625%20532.13%2056.0625%20530.852%2056.0625%20529.817%2055.0272%20529.817%2053.75%20529.817%2052.4728%20530.852%2051.4375%20532.13%2051.4375%20533.407%2051.4375%20534.442%2052.4728%20534.442%2053.75Z'/%3e%3c/g%3e%3c/svg%3e",nc="data:image/svg+xml,%3csvg%20width='159'%20height='159'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20overflow='hidden'%3e%3cg%20transform='translate(-392%20-84)'%3e%3cpath%20d='M496.776%20189.601C496.122%20189.934%20495.77%20190.663%20495.916%20191.383L499.911%20210.219C500.074%20210.985%20500.75%20211.532%20501.533%20211.531L501.929%20211.531C503.729%20211.515%20505.222%20212.919%20505.319%20214.716%20505.389%20216.544%20503.964%20218.083%20502.136%20218.154%20502.093%20218.155%20502.05%20218.156%20502.006%20218.156L497.503%20218.156C495.941%20218.15%20494.594%20217.058%20494.263%20215.531L490.363%20197.147C490.174%20196.252%20489.294%20195.68%20488.4%20195.87%20488.399%20195.87%20488.399%20195.87%20488.399%20195.87%20488.174%20195.918%20487.962%20196.014%20487.776%20196.15L481.184%20200.898C479.925%20201.758%20478.809%20202.45%20477.776%20203.015%20476.998%20203.429%20476.669%20204.372%20477.022%20205.18%20477.402%20206.011%20478.385%20206.378%20479.217%20205.998%20479.253%20205.981%20479.288%20205.964%20479.322%20205.945%20480.618%20205.229%20481.877%20204.447%20483.094%20203.604L487.657%20200.313%20491.031%20216.213C491.677%20219.273%20494.376%20221.464%20497.503%20221.469L501.882%20221.469C505.577%20221.473%20508.587%20218.502%20508.631%20214.807%20508.608%20211.503%20506.158%20208.719%20502.883%20208.277L499.416%20191.93C502.051%20190.581%20506.719%20188.344%20509.619%20188.344%20515.225%20188.346%20520.812%20187.662%20526.252%20186.307%20530.081%20185.36%20533.152%20182.51%20534.381%20178.762L534.535%20178.295C535.676%20175.09%20535.323%20171.542%20533.573%20168.624L525.126%20154.2C522.254%20149.369%20517.625%20145.835%20512.207%20144.337%20512.364%20138.624%20511.516%20132.927%20509.7%20127.508%20504.714%20113.244%20488.452%20105.977%20487.761%20105.669%20487.336%20105.48%20486.851%20105.48%20486.426%20105.669%20485.959%20105.876%20484.987%20106.308%20483.1%20111.962%20482.811%20112.832%20483.281%20113.77%20484.15%20114.059%20485.019%20114.348%20485.958%20113.878%20486.247%20113.009%20486.649%20111.744%20487.129%20110.505%20487.685%20109.299%20491.474%20111.245%20502.818%20117.831%20506.566%20128.543%20508.418%20133.972%20509.183%20139.713%20508.815%20145.437%20508.734%20146.277%20509.297%20147.043%20510.122%20147.217%20515.212%20148.269%20519.626%20151.41%20522.287%20155.875L530.744%20170.299C532.007%20172.379%20532.256%20174.921%20531.42%20177.207L531.254%20177.727C530.378%20180.388%20528.194%20182.41%20525.474%20183.079%20520.288%20184.375%20514.964%20185.031%20509.619%20185.031%20505.93%20185.031%20501.061%20187.35%20496.776%20189.601Z'/%3e%3cpath%20d='M422.439%20192.966C421.946%20190.791%20421.681%20188.571%20421.649%20186.341%20421.7%20185.427%20421.001%20184.643%20420.086%20184.592%20419.171%20184.54%20418.388%20185.239%20418.336%20186.154%20418.324%20187.879%20418.47%20189.602%20418.772%20191.3%20412.577%20189.633%20408.907%20183.26%20410.574%20177.065%20411.942%20171.981%20416.559%20168.453%20421.824%20168.469%20422.661%20168.473%20423.491%20168.611%20424.284%20168.88%20425.056%20169.133%20425.898%20168.787%20426.271%20168.065%20435.26%20150.783%20455.639%20142.806%20473.971%20149.392%20474.837%20150.636%20475.5%20151.557%20475.559%20151.638%20476.094%20152.38%20477.129%20152.549%20477.872%20152.014%20478.614%20151.479%20478.782%20150.444%20478.248%20149.702%20478.216%20149.657%20475.101%20145.338%20473.444%20142.62%20467.845%20132.798%20470.283%20120.115%20471.358%20115.817%20475.617%20117.014%20487.816%20121.194%20493.442%20131.039%20496.082%20135.531%20497.921%20140.449%20498.876%20145.571%20499.017%20146.361%20499.705%20146.936%20500.508%20146.936L503.929%20146.936C504.816%20146.948%20505.561%20146.274%20505.639%20145.391%20505.7%20144.478%20505.01%20143.688%20504.097%20143.627%20504.059%20143.624%20504.021%20143.623%20503.982%20143.623L501.871%20143.623C500.778%20138.613%20498.902%20133.806%20496.312%20129.38%20488.742%20116.13%20471.271%20112.337%20470.533%20112.183%20469.704%20112.01%20468.879%20112.489%20468.618%20113.294%20468.385%20114.011%20463.013%20131.036%20470.568%20144.256%20470.579%20144.276%20470.745%20144.576%20470.978%20144.973%20470.99%20144.991%20470.978%20145.003%20470.96%20144.998%20452.498%20140.481%20433.287%20148.811%20423.966%20165.375%20423.261%20165.231%20422.543%20165.158%20421.824%20165.156%20413.582%20165.183%20406.923%20171.886%20406.95%20180.128%20406.974%20187.414%20412.256%20193.618%20419.446%20194.803L419.446%20194.803C419.532%20195.194%20419.611%20195.585%20419.706%20195.972L419.8%20196.329C422.428%20206.56%20428.796%20215.436%20437.646%20221.204%20437.917%20221.379%20438.232%20221.473%20438.554%20221.474L473.068%20221.474C476.748%20221.495%20479.756%20218.542%20479.801%20214.862%20479.847%20211.242%20476.95%20208.27%20473.329%20208.224%20473.278%20208.223%20473.227%20208.223%20473.176%20208.224L465.158%20208.224C474.765%20201.216%20476.873%20187.747%20469.866%20178.14%20465.812%20172.583%20459.348%20169.297%20452.47%20169.297%20450.573%20169.261%20448.682%20169.507%20446.858%20170.029%20445.981%20170.293%20445.484%20171.219%20445.749%20172.096%20446.013%20172.973%20446.938%20173.47%20447.816%20173.206%20449.328%20172.775%20450.897%20172.574%20452.47%20172.609%20462.532%20172.632%20470.67%20180.807%20470.648%20190.869%20470.63%20198.914%20465.337%20205.995%20457.626%20208.29%20456.784%20208.543%20456.286%20209.408%20456.491%20210.263%20456.686%20211.016%20457.369%20211.54%20458.147%20211.533L473.107%20211.533C474.951%20211.521%20476.458%20213.001%20476.48%20214.845%20476.52%20216.635%20475.102%20218.118%20473.312%20218.158%20473.264%20218.159%20473.216%20218.159%20473.168%20218.158L439.054%20218.158C431.004%20212.776%20425.251%20204.584%20422.922%20195.184%20422.853%20194.889%20422.795%20194.619%20422.733%20194.339Z'/%3e%3cpath%20d='M519.521%20163.831C519.708%20162.011%20518.383%20160.385%20516.563%20160.199%20514.743%20160.012%20513.117%20161.337%20512.931%20163.157%20512.744%20164.977%20514.069%20166.603%20515.889%20166.789%20516.113%20166.812%20516.339%20166.812%20516.563%20166.789%20518.126%20166.629%20519.361%20165.394%20519.521%20163.831Z'/%3e%3c/g%3e%3c/svg%3e",rc="_WPMSpeedButtonsWrap_r3byt_1",oc="_btnWrap_r3byt_7",sc="_label_r3byt_14",ic="_iconBtn_r3byt_22",zt={WPMSpeedButtonsWrap:rc,btnWrap:oc,label:sc,iconBtn:ic},uo=350,lc=40,ac=.85,cc=m.memo(function(){const t=X(h=>h.audioSpeed),n=X(h=>h.incAudioSpeed),r=X(h=>h.decAudioSpeed),o=m.useRef(null),s=m.useRef(uo),i=m.useRef(null),u=m.useCallback(h=>{const g=t;if(h==="inc"){if(g>=2)return!1;n()}else{if(g<=.3)return!1;r()}return!0},[t,n,r]),a=m.useCallback(()=>{i.current=null,o.current&&(clearTimeout(o.current),o.current=null)},[]),l=m.useCallback(()=>{i.current&&(s.current=Math.max(lc,Math.floor(s.current*ac)),o.current=window.setTimeout(()=>{u(i.current)?l():a()},s.current))},[u,a]),d=m.useCallback(h=>{if(i.current)return;i.current=h,s.current=uo,u(h)&&l();const v=()=>a();window.addEventListener("mouseup",v,{once:!0}),window.addEventListener("touchend",v,{once:!0})},[l,u,a]);m.useEffect(()=>a,[a]);const S=`${(t*100).toFixed(0)}%`;return x.jsx("div",{onMouseLeave:a,className:zt.WPMSpeedButtonsWrap,children:x.jsxs("div",{className:zt.btnWrap,children:[x.jsx("button",{className:zt.iconBtn,type:"button",title:"속도 느리게",onMouseDown:()=>d("dec"),onTouchStart:h=>{h.preventDefault(),d("dec")},onMouseUp:a,children:x.jsx("img",{src:tc,alt:"느리게"})}),x.jsx("div",{className:zt.label,style:{minWidth:"44px",textAlign:"center"},children:x.jsx("div",{children:S})}),x.jsx("button",{className:zt.iconBtn,type:"button",title:"속도 빠르게",onMouseDown:()=>d("inc"),onTouchStart:h=>{h.preventDefault(),d("inc")},onMouseUp:a,children:x.jsx("img",{src:nc,alt:"빠르게"})})]})})}),uc="_StepBtn_1qqzt_1",dc={StepBtn:uc};function fc(e){return Ve({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M208,48V208a8,8,0,0,1-13.66,5.66L128,147.31V208a8,8,0,0,1-13.66,5.66l-80-80a8,8,0,0,1,0-11.32l80-80A8,8,0,0,1,128,48v60.69l66.34-66.35A8,8,0,0,1,208,48Z"},child:[]}]})(e)}function pc(e){return Ve({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M221.66,133.66l-80,80A8,8,0,0,1,128,208V147.31L61.66,213.66A8,8,0,0,1,48,208V48a8,8,0,0,1,13.66-5.66L128,108.69V48a8,8,0,0,1,13.66-5.66l80,80A8,8,0,0,1,221.66,133.66Z"},child:[]}]})(e)}function fo({direction:e}){const t=V(f=>f.currentGlobalRunIndex),n=V(f=>f.totalRuns),r=V(f=>f.hasReadableInDir),o=V(f=>f.computeStepTarget),s=V(f=>f.edgeReadable),i=V(f=>f.snapToReadable),u=V(f=>f.setCurrentGlobalRunIndex),a=we(f=>f.syncToGI),l=V(f=>f.getSectionScrollApi),d=lt(),S=V(f=>f.pageIndex),h=V(f=>f.totalPages),g=h>1&&S>=h-1,v=m.useCallback(async f=>{var y,k,R,_;const{progress:p}=d.getState(),C=p.pageIndex,T=p.totalPages,I=T>1&&C>=T-1,j=Math.max(t,Math.min(0,Math.max(0,(n??1)-1)));if(f===-1&&I){p.setPageIndex(C-1);return}if(f===1){const z=i(j),B=s(1);if(B!=null&&z>=B){(k=(y=l())==null?void 0:y.stepPage)==null||k.call(y,1);return}}const b=o(j,f);u(b,"scrubber-step"),a(b),await((_=(R=l())==null?void 0:R.ensureVisibleGI)==null?void 0:_.call(R,b))},[t,n,o,i,s,u,a,l,d]),w=m.useMemo(()=>{const f=Math.max(t,Math.min(0,Math.max(0,(n??1)-1))),p=i(f),C=s(1),T=s(-1),I=h>0,j=C!=null&&p>=C,b=T!=null&&p<=T,y=g||!I&&j||!n||!r(f,1),k=b||!n||!r(f,-1);return e==="left"?k:y},[e,n,h,t,r,g,i,s]),c=m.useCallback(()=>{v(e==="left"?-1:1)},[e,v]);return x.jsx("button",{className:dc.StepBtn,type:"button",onClick:c,disabled:w,title:e==="left"?"이전":"다음",children:e==="left"?x.jsx(fc,{}):x.jsx(pc,{})})}const gc="_GCPlayBtn_16fre_1",hc="_playing_16fre_39",po={GCPlayBtn:gc,playing:hc},mc=({size:e=60,color:t="#333",bgColor:n="#fff",isPlaying:r,disabled:o=!1,onClick:s,tooltip:i="재생",title:u=""})=>x.jsx("button",{className:`${po.GCPlayBtn} ${r?po.playing:""}`,onClick:s,disabled:o,"data-tip":i,title:u,style:{"--btn-size":`${e}px`,"--icon-color":t,"--btn-bg":n}});function bc(e){return Ve({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 294.1L383 167c9.4-9.4 24.6-9.4 33.9 0s9.3 24.6 0 34L273 345c-9.1 9.1-23.7 9.3-33.1.7L95 201.1c-4.7-4.7-7-10.9-7-17s2.3-12.3 7-17c9.4-9.4 24.6-9.4 33.9 0l127.1 127z"},child:[]}]})(e)}function xc(e){return Ve({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 217.9L383 345c9.4 9.4 24.6 9.4 33.9 0 9.4-9.4 9.3-24.6 0-34L273 167c-9.1-9.1-23.7-9.3-33.1-.7L95 310.9c-4.7 4.7-7 10.9-7 17s2.3 12.3 7 17c9.4 9.4 24.6 9.4 33.9 0l127.1-127z"},child:[]}]})(e)}function vc(){var M;const e=X(O=>O.showOverlays),t=V(O=>O.section),n=!!t.ast.isAddedSplit,r=!!((M=t.audios)!=null&&M.length),o=V(O=>O.pageIndex),s=V(O=>O.totalPages),i=s>1&&o>=s-1,u=V(O=>O.currentGlobalRunIndex),a=V(O=>O.snapToReadable),l=V(O=>O.edgeReadable),d=(()=>{const O=l(1);return O==null?!1:a(u??0)>=O})(),S=i||d,h=V(O=>O.canTracking),g=V(O=>O.canToggleShowGaze),v=V(O=>O.showGaze),w=V(O=>O.onToggleShowGaze),c=X(O=>O.muteAudio),f=X(O=>O.showPointer),p=X(O=>O.showSplit),C=X(O=>O.toggleMuteAudio),T=X(O=>O.toggleShowPointer),I=X(O=>O.toggleShowSplit),j=X(O=>O.overlayCompactMode),b=X(O=>O.toggleOverlayCompactMode),y=cn(),k=lt();m.useEffect(()=>{const O=y.getState(),{syncToGI:Q,useFake:re,useReal:oe}=O,ie=O.playbackKind,ue=k.getState().progress.currentGlobalRunIndex??0;if(!r){ie!=="fake"&&re();return}c?ie!=="fake"&&re():ie!=="real"&&(Q(ue),oe())},[r,c,k,y]);const R=we(O=>O.play),_=we(O=>O.pause),z=we(O=>O.status),B=cn(),E=lt(),P=m.useCallback(O=>{var ue,xe,N;if(O.stopPropagation(),z==="playing"||z==="loading"){_();return}const{progress:Q}=E.getState(),re=Q.currentGlobalRunIndex??0,oe=Q.snapToReadable(re),ie=Q.edgeReadable(1);if(ie!=null&&oe>=ie){(N=(xe=(ue=Q.getSectionScrollApi)==null?void 0:ue.call(Q))==null?void 0:xe.stepPage)==null||N.call(xe,1);return}R()},[z,R,_,E]),F=m.useCallback(async O=>{var H,te;if(O.stopPropagation(),z==="playing"||z==="loading"){_();return}const{progress:Q}=E.getState(),{currentGlobalRunIndex:re,snapToReadable:oe,edgeReadable:ie,setCurrentGlobalRunIndex:ue,getSectionScrollApi:xe}=Q,N=B.getState(),D=N.currentClip,q=xe==null?void 0:xe(),A=typeof re=="number"?re:0,G=typeof oe=="function"?oe(A):A,K=typeof ie=="function"?ie(1):null;if(K!=null&&G>=K){ue==null||ue(K,"audio"),(H=q==null?void 0:q.stepPage)==null||H.call(q,1);return}ue==null||ue(G,"audio"),await((te=q==null?void 0:q.ensureVisibleGI)==null?void 0:te.call(q,G)),N.syncToGI(G),R(D)},[z,_,R,B,E]);return x.jsxs("div",{className:`${Ie.wrap} ${e?Ie.visible:""} ${j?Ie.compact:""}`,onClick:O=>{O.stopPropagation()},onTouchStart:O=>{O.stopPropagation()},children:[!j&&x.jsx(Za,{}),x.jsx("div",{style:j?{display:"none"}:void 0,children:r&&!c?x.jsx(qa,{}):x.jsx(ec,{})}),x.jsxs("div",{className:Ie.controls,children:[x.jsxs("div",{className:Ie.row1,children:[x.jsx("div",{className:Ie.groupExpand,children:x.jsx("button",{type:"button",onClick:O=>{O.stopPropagation(),b()},className:Ie.compactBtn,title:j?"오버레이 확대":"오버레이 축소",children:j?x.jsx(xc,{size:24}):x.jsx(bc,{size:24})})}),x.jsxs("div",{className:Ie.groupPlayback,children:[x.jsx(fo,{direction:"left"}),x.jsx(mc,{size:34,isPlaying:z==="playing",disabled:S,onClick:c?F:P,title:z==="playing"?"일시정지":"재생"}),x.jsx(fo,{direction:"right"})]}),x.jsx("div",{className:Ie.groupSpeed,children:x.jsx(cc,{})})]}),x.jsxs("div",{className:Ie.row2,children:[x.jsxs("div",{className:Ie.groupFeatures,children:[r&&x.jsxs("button",{type:"button",onClick:O=>{O.stopPropagation(),C()},className:`${Ie.btn} ${c?"":Ie.btnActive}`,title:"오디오북 음소거 전환",children:[c?x.jsx(Sa,{size:18}):x.jsx(ya,{size:18}),x.jsx("span",{className:Ie.label,children:"오디오북"})]}),x.jsxs("button",{type:"button",onClick:O=>{O.stopPropagation(),T()},className:`${Ie.btn} ${f?Ie.btnActive:""}`,title:"포인터 표시",children:[x.jsx(wa,{size:18}),x.jsx("span",{className:Ie.label,children:"포인터"})]}),n&&x.jsxs("button",{type:"button",onClick:O=>{O.stopPropagation(),I()},disabled:!n,className:`${Ie.btn} ${p?Ie.btnActive:""} ${n?"":Ie.btnForbidden}`,title:"끊어읽기 표시",children:[x.jsx(Ca,{size:18}),x.jsx("span",{className:Ie.label,children:"끊어읽기"})]}),x.jsxs("button",{type:"button",onClick:O=>{O.stopPropagation(),w==null||w()},disabled:!h||!g,className:`${Ie.btn} ${h&&v?Ie.btnActive:""} ${h?"":Ie.btnForbidden}`,title:"시선 표시",children:[x.jsx(Ta,{size:18}),x.jsx("span",{className:Ie.label,children:"시선"})]})]}),x.jsxs("div",{className:Ie.groupNav,children:[x.jsx(pa,{}),x.jsx(pn,{})]})]})]})]})}const Sc=m.memo(vc);function yc(e){return Ve({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32",d:"M262.29 192.31a64 64 0 1 0 57.4 57.4 64.13 64.13 0 0 0-57.4-57.4zM416.39 256a154.34 154.34 0 0 1-1.53 20.79l45.21 35.46a10.81 10.81 0 0 1 2.45 13.75l-42.77 74a10.81 10.81 0 0 1-13.14 4.59l-44.9-18.08a16.11 16.11 0 0 0-15.17 1.75A164.48 164.48 0 0 1 325 400.8a15.94 15.94 0 0 0-8.82 12.14l-6.73 47.89a11.08 11.08 0 0 1-10.68 9.17h-85.54a11.11 11.11 0 0 1-10.69-8.87l-6.72-47.82a16.07 16.07 0 0 0-9-12.22 155.3 155.3 0 0 1-21.46-12.57 16 16 0 0 0-15.11-1.71l-44.89 18.07a10.81 10.81 0 0 1-13.14-4.58l-42.77-74a10.8 10.8 0 0 1 2.45-13.75l38.21-30a16.05 16.05 0 0 0 6-14.08c-.36-4.17-.58-8.33-.58-12.5s.21-8.27.58-12.35a16 16 0 0 0-6.07-13.94l-38.19-30A10.81 10.81 0 0 1 49.48 186l42.77-74a10.81 10.81 0 0 1 13.14-4.59l44.9 18.08a16.11 16.11 0 0 0 15.17-1.75A164.48 164.48 0 0 1 187 111.2a15.94 15.94 0 0 0 8.82-12.14l6.73-47.89A11.08 11.08 0 0 1 213.23 42h85.54a11.11 11.11 0 0 1 10.69 8.87l6.72 47.82a16.07 16.07 0 0 0 9 12.22 155.3 155.3 0 0 1 21.46 12.57 16 16 0 0 0 15.11 1.71l44.89-18.07a10.81 10.81 0 0 1 13.14 4.58l42.77 74a10.8 10.8 0 0 1-2.45 13.75l-38.21 30a16.05 16.05 0 0 0-6.05 14.08c.33 4.14.55 8.3.55 12.47z"},child:[]}]})(e)}const wc="_host_gafql_3",Cc="_topbar_gafql_11",Ic="_visible_gafql_32",Tc="_backBtn_gafql_37",kc="_title_gafql_58",Rc="_calibrationBtn_gafql_67",_c="_disabled_gafql_87",Mc="_settingsBtn_gafql_95",pt={host:wc,topbar:Cc,visible:Ic,backBtn:Tc,title:kc,calibrationBtn:Rc,disabled:_c,settingsBtn:Mc};function Ec(){const e=X(g=>g.showOverlays),t=X(g=>g.overlayCompactMode),n=V(g=>g.onViewerClose),o=V(g=>g.section).ast.title,s=V(g=>g.canTracking),i=V(g=>g.handleAskCalibration),u=we(g=>g.status==="playing"),a=s&&!u,l=X(g=>g.setSettingsOpen),d=X(g=>g.setShowOverlays),S=m.useCallback(()=>{n==null||n()},[n]),h=m.useCallback(()=>{l(!0),d(!1)},[l,d]);return x.jsx("div",{className:pt.host,children:x.jsxs("div",{className:`${pt.topbar} ${e&&!t?pt.visible:""}`,children:[x.jsx("button",{type:"button",className:pt.backBtn,onClick:S,"aria-label":"뒤로가기",children:x.jsx(Ia,{size:28})}),x.jsx("div",{className:pt.title,children:x.jsx("span",{className:"truncate",children:o||"섹션 없음"})}),x.jsx("button",{type:"button",className:`${pt.calibrationBtn} ${a?"":pt.disabled}`,onClick:i,disabled:!a,"aria-label":"시선보정",title:"시선보정",children:x.jsx(ka,{size:24})}),x.jsx("button",{type:"button",className:pt.settingsBtn,onClick:h,"aria-label":"뷰어 설정",children:x.jsx(yc,{size:28})})]})})}const jc=m.memo(Ec),Oc="_wrap_62su0_7",zc="_wrapHidden_62su0_29",Ac="_wrapVisible_62su0_35",Pc="_scrollArea_62su0_71",Bc="_row_62su0_81",Lc="_label_62su0_89",Gc="_btn_62su0_95",Hc="_btnActive_62su0_106",Fc="_btnSmall_62su0_110",Nc="_pill_62su0_122",Dc="_themeCircle_62su0_133",Wc="_themeCircleActive_62su0_146",qc="_stepRow_62su0_151",Vc="_stepLabel_62su0_159",$c="_levelBox_62su0_172",Uc="_inlineFlex_62su0_177",Ee={wrap:Oc,wrapHidden:zc,wrapVisible:Ac,scrollArea:Pc,row:Bc,label:Lc,btn:Gc,btnActive:Hc,btnSmall:Fc,pill:Nc,themeCircle:Dc,themeCircleActive:Wc,stepRow:qc,stepLabel:Vc,levelBox:$c,inlineFlex:Uc};function Kc({visible:e}){const t=X(b=>b.mode),n=X(b=>b.setMode),r=X(b=>b.theme),o=X(b=>b.setTheme),s=X(b=>b.fontFamily),i=X(b=>b.setFontFamily),u=X(b=>b.resetToDefaults),a=X(b=>b.getFontLevel()),l=X(b=>b.getLineLevel()),d=X(b=>b.getMarginLevel()),S=X(b=>b.setFontLevel),h=X(b=>b.setLineLevel),g=X(b=>b.setMarginLevel),v=X(b=>b.pointerStyle),w=X(b=>b.setPointerStyle),c=X(b=>b.pointerColor),f=X(b=>b.setPointerColor),p=X(b=>b.breakMarks),C=X(b=>b.toggleBreakMark),T=X(b=>b.getBreakGapLevel()),I=X(b=>b.setBreakGapLevel),j=`${Ee.wrap} ${e?Ee.wrapVisible:Ee.wrapHidden}`;return x.jsxs("div",{className:j,role:"dialog","aria-modal":"true","aria-label":"뷰어 설정",children:[x.jsxs("div",{className:Ee.scrollArea,children:[x.jsx(At,{label:"열람방식",children:x.jsxs("div",{className:Ee.inlineFlex,children:[x.jsx(Rt,{active:t==="page",onClick:()=>n("page"),children:"페이지"}),x.jsx(Rt,{active:t==="scroll",onClick:()=>n("scroll"),children:"스크롤"})]})}),x.jsx(At,{label:"테마",children:x.jsx("div",{className:Ee.inlineFlex,children:Object.keys(sn).map(b=>{const y=b,k=sn[y];return x.jsx("button",{type:"button",onClick:()=>o(y),className:`${Ee.themeCircle} ${r===b?Ee.themeCircleActive:""}`,style:{background:k.bg,color:k.fg,fontFamily:s},title:String(b),"aria-label":`테마: ${String(b)}`,children:"A"},`${b}_tc_button`)})})}),x.jsx(At,{label:"글꼴",children:x.jsx("div",{className:Ee.inlineFlex,children:Ho.map(b=>x.jsx(Rt,{active:s===b.value,onClick:()=>i(b.value),title:b.value,children:b.label},b.label))})}),x.jsx(tn,{label:"글자 크기",level:a,min:1,max:12,onDec:()=>S(Math.max(1,a-1)),onInc:()=>S(Math.min(12,a+1))}),x.jsx(tn,{label:"줄 간격",level:l,min:1,max:7,onDec:()=>h(Math.max(1,l-1)),onInc:()=>h(Math.min(7,l+1))}),x.jsx(tn,{label:"여백",level:d,min:1,max:5,onDec:()=>g(Math.max(1,d-1)),onInc:()=>g(Math.min(5,d+1))}),x.jsx(At,{label:"포인터",children:x.jsxs("div",{className:Ee.inlineFlex,children:[x.jsx(Rt,{active:v==="highlight",onClick:()=>w("highlight"),children:"형광펜"}),x.jsx(Rt,{active:v==="underline",onClick:()=>w("underline"),children:"밑줄"}),x.jsx("input",{type:"color",value:c,onChange:b=>f(b.target.value),"aria-label":"포인터 색상",style:{width:36,height:28,padding:0,border:"none",background:"transparent"}})]})}),x.jsx(At,{label:"끊기표시",children:x.jsx("div",{className:Ee.inlineFlex,children:x.jsx(Rt,{active:p.slash,onClick:()=>C("slash"),children:"슬래쉬"})})}),x.jsx(tn,{label:"끊기간격",level:T,min:1,max:5,onDec:()=>I(Math.max(1,T-1)),onInc:()=>I(Math.min(5,T+1))})]}),x.jsx("div",{className:Ee.inlineFlex,style:{justifyContent:"center"},children:x.jsx("button",{type:"button",onClick:u,className:Ee.pill,children:"보기 설정 초기화"})})]})}function At({label:e,children:t}){return x.jsxs("div",{className:Ee.row,children:[x.jsx("label",{className:Ee.label,children:e}),t]})}function Rt({active:e,onClick:t,title:n,children:r}){return x.jsx("button",{type:"button",onClick:t,title:n,className:`${Ee.btn} ${e?Ee.btnActive:""}`,children:r})}function tn({label:e,level:t,min:n,max:r,onDec:o,onInc:s}){const i=t<=n,u=t>=r;return x.jsxs("div",{className:Ee.stepRow,children:[x.jsx("label",{className:Ee.stepLabel,children:e}),x.jsxs("div",{className:Ee.inlineFlex,children:[x.jsx("button",{type:"button",onClick:o,disabled:i,className:Ee.btnSmall,"aria-label":"감소",children:"−"}),x.jsx("div",{className:Ee.levelBox,children:t}),x.jsx("button",{type:"button",onClick:s,disabled:u,className:Ee.btnSmall,"aria-label":"증가",children:"+"})]})]})}const Xc=m.memo(function(){const t=X(i=>i.showOverlays),n=X(i=>i.isSettingsOpen),r=V(i=>i.rangeStartGI),o=V(i=>i.rangeEndGI);return r!=null&&o!=null?null:x.jsxs("div",{"aria-hidden":!0,style:{pointerEvents:"none",position:"absolute",inset:0,containerType:"size",containerName:"viewer"},children:[x.jsx(jc,{}),x.jsx(Sc,{}),x.jsx("div",{style:{pointerEvents:"auto"},children:x.jsx(Kc,{visible:!t&&n})})]})}),Qc=e=>(t,n,r)=>{const o=r.subscribe;return r.subscribe=((i,u,a)=>{let l=i;if(u){const d=(a==null?void 0:a.equalityFn)||Object.is;let S=i(r.getState());l=h=>{const g=i(h);if(!d(S,g)){const v=S;u(S=g,v)}},a!=null&&a.fireImmediately&&u(S,S)}return o(l)}),e(t,n,r)},Yc=Qc;function Zc(e){return e?e.kind==="saved"?e.cdnUrl:e.blobUrl:null}function Jc(e){var o,s,i;if(!e||!/\S/.test(e))return 0;const t=((o=e.match(/[A-Za-z0-9]+(?:['’-][A-Za-z0-9]+)*/g))==null?void 0:o.length)??0,n=((s=e.match(/[\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A]+/g))==null?void 0:s.length)??0,r=((i=e.match(/[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\u3040-\u30FF\u31FF\uAC00-\uD7AF\u1100-\u11FF\u3130-\u318F]/g))==null?void 0:i.length)??0;return t+n+Math.floor(r/2)}function eu(e){let t=0;for(const n of e.ast.blocks??[])if(n.type==="paragraph")for(const r of n.runs??[])t+=Jc((r==null?void 0:r.text)??"");return t}function tu(e){const t=e==null?void 0:e.recorderStore;let n=e==null?void 0:e.map,r=e==null?void 0:e.initialIndex;const o=g=>{if(!n)return null;const{g2ct:v}=n;if(!v)return null;const w=v[g];if(w)return{clip:w.clip,t:w.t};for(let c=1;c<=100&&g-c>=0;c++){const f=v[g-c];if(f)return{clip:f.clip,t:f.t}}for(let c=1;c<=100;c++){const f=v[g+c];if(f)return{clip:f.clip,t:f.t}}return null},s=(e==null?void 0:e.clips)??[];let i=0,u=0;const a=Math.max(1,eu(e.section)||150);if(typeof(e==null?void 0:e.initialIndex)=="number"&&n){const g=o(e.initialIndex);g&&(i=g.clip,u=g.t,r=void 0)}const l=s.length>0,d=l?"paused":"idle",S=l?"real":"fake",h=l?null:{totalWords:a};return Vt(Yc((g,v)=>({clips:s,currentClip:Math.max(0,Math.min(i,Math.max(0,s.length-1))),currentTimeMs:Math.max(0,u),status:d,scrollLock:!1,playbackKind:S,fake:h,useFake:()=>g(w=>({playbackKind:"fake",fake:{totalWords:a},scrollLock:w.status==="playing"})),useReal:()=>g(w=>({playbackKind:"real",fake:{totalWords:a},scrollLock:w.status==="playing"})),injectMap:w=>{if(n=w,typeof r=="number"){const c=o(r);c&&g(f=>({currentClip:Math.max(0,Math.min(c.clip,Math.max(0,f.clips.length-1))),currentTimeMs:Math.max(0,c.t)})),r=void 0}},setClipAndMs:(w,c)=>g(f=>{const p=Math.max(0,f.clips.length-1);return{currentClip:Math.max(0,Math.min(w,p)),currentTimeMs:Math.max(0,c),status:f.status,scrollLock:f.scrollLock}}),setClips:w=>g(c=>{const f=Array.isArray(w)?w:[],p=f.length>0;return{clips:f,currentClip:0,currentTimeMs:0,status:p?"paused":"idle",playbackKind:p?"real":"fake",fake:p?null:c.fake??{totalWords:a},scrollLock:!1}}),clear:()=>g(w=>({clips:[],currentClip:0,currentTimeMs:0,status:"idle",playbackKind:"fake",fake:w.fake??{totalWords:a},scrollLock:!1})),play:(w,c)=>{t==null||t.getState().emit({type:"audio_control",payload:{action:"play"}}),g(f=>{if(f.playbackKind==="fake")return{status:"playing",scrollLock:!0};const p=typeof w=="number"?w:f.currentClip,C=typeof c=="number"?c:f.currentTimeMs;return{status:"loading",currentClip:Math.max(0,Math.min(p,Math.max(0,f.clips.length-1))),currentTimeMs:C,scrollLock:!0}})},pause:()=>{t==null||t.getState().emit({type:"audio_control",payload:{action:"pause"}}),g({status:"paused",scrollLock:!1})},seek:w=>g(c=>({currentTimeMs:Math.max(0,w),status:c.status})),stop:()=>g({status:"idle",currentTimeMs:0,scrollLock:!1}),nextClip:()=>g(w=>{if(w.playbackKind==="fake")return w;const c=Math.max(0,w.clips.length-1);return{currentClip:Math.min(w.currentClip+1,c),currentTimeMs:0,status:"loading",scrollLock:!0}}),prevClip:()=>g(w=>w.playbackKind==="fake"?w:{currentClip:Math.max(0,w.currentClip-1),currentTimeMs:0,status:"loading",scrollLock:!0}),setClipIndex:w=>g(c=>c.playbackKind==="fake"||w<0||w>=c.clips.length?c:{currentClip:w,currentTimeMs:0}),getClipSrc:w=>{const c=v();if(!c.clips.length)return null;const f=typeof w=="number"?w:c.currentClip;return Zc(c.clips[f])},getGIFromCT:(w,c)=>{if(!n)return-1;const f=n.byClip[w];if(!f||f.length===0)return-1;let p=0,C=f.length-1,T=0;for(;p<=C;){const I=p+C>>1;f[I].t<=c?(T=I,p=I+1):C=I-1}return f[Math.max(0,Math.min(T,f.length-1))].g},getCTFromGI:w=>{if(!n)return null;const{g2ct:c}=n;if(!c)return null;let f=c[w];if(!f){let p=w-1;const C=Math.max(0,w-100);for(;p>=C;){if(c[p]){f=c[p];break}p--}if(!f){let T=w+1;const I=w+100;for(;c[T]==null&&T<=I;)T++;c[T]&&(f=c[T])}}return f?{clip:f.clip,timeMs:f.t}:null},getMetaByGI:w=>{const c=v().getCTFromGI(w);return c?{clipIndex:c.clip,timeMs:c.timeMs}:null},syncToGI:w=>{const c=v().getMetaByGI(w);c&&v().setClipAndMs(c.clipIndex,c.timeMs)},_onTime:w=>g({currentTimeMs:w,status:"playing",scrollLock:!0}),_onEnded:()=>g(w=>{if(w.playbackKind==="fake")return{status:"ended",scrollLock:!1};const c=Math.max(0,w.clips.length-1);return w.currentClip>=c?{status:"ended",scrollLock:!1}:{currentClip:Math.min(w.currentClip+1,c),currentTimeMs:0,status:"loading",scrollLock:!0}}),_onError:()=>g({status:"error",scrollLock:!1}),_setStatusOnly:w=>g({status:w})})))}function nu({children:e,initialState:t}){const n=m.useContext(mt)??void 0,r=m.useMemo(()=>tu({...t,recorderStore:n}),[t,n]);return x.jsx(vn.Provider,{value:r,children:e})}function ru(e){var s,i;const t={},n=[],r=((s=e==null?void 0:e.ast)==null?void 0:s.blocks)??[];let o=0;for(const u of r){if((u==null?void 0:u.type)==="image")continue;const a=(u==null?void 0:u.runs)??[];for(let l=0;l<a.length;l++){const d=a[l],S=o+l;d.audioChunkIndex!=null&&d.audioTimeMs!=null&&((t[i=d.audioChunkIndex]||(t[i]=[])).push({t:d.audioTimeMs,g:S}),n[S]={clip:d.audioChunkIndex,t:d.audioTimeMs})}o+=a.length}return Object.values(t).forEach(u=>u.sort((a,l)=>a.t-l.t)),{byClip:t,g2ct:n}}function ou(e,t,n){if(n<=0)return-1;const r=Math.max(0,Math.min(t,n-1));if(e[r]===1)return r;for(let o=1;o<n;o++){const s=r-o;if(s>=0&&e[s]===1)return s;const i=r+o;return i<n&&e[i]===1?i:-1}return-1}function su(e){const t=Ul(e),n=Kl(t),r=t.reduce((d,S)=>d+(S||0),0),o=new Int32Array(Math.max(1,r)).fill(-1),s=new Uint8Array(Math.max(1,r)).fill(0),i=[],u=[];return e.forEach((d,S)=>{var c;if(d.type!=="paragraph")return;const h=n[S]??0,g=d.runs??[];for(let f=0;f<g.length;f++){const p=((c=g[f])==null?void 0:c.text)||"";sr(p)&&(s[h+f]=1)}const w=Xl(g,h).map(f=>{var I;const p=f.startG-h,C=f.endG-f.startG+1;let T=-1;for(let j=0;j<C;j++){const b=((I=g[p+j])==null?void 0:I.text)??"";if(sr(b)){T=f.startG+j;break}}return{startG:f.startG,endG:f.endG,r0:p,len:C,firstReadableGI:T,splitIndex:f.splitIndex}});u[S]=w;for(const f of w){const p=i.length;for(let C=f.startG;C<=f.endG;C++)o[C]=p;i.push(f)}}),{nav:{groups:i,giToGroupIdx:o,readableGi:s,splitGroupsPerBlock:u},layout:{prefix:n,totalRuns:r}}}function iu(e){const{section:t,onViewerClose:n,onSectionNav:r,isCanPrev:o,isCanNext:s,canTracking:i,canToggleShowGaze:u,showGaze:a,onToggleShowGaze:l,handleAskCalibration:d,nav:S,layout:h,initialIndex:g,mountTime:v}=e,w=h.totalRuns??0,c=typeof g=="number"?g:w>0?0:-1,f=c>=0?ou(S.readableGi,c,w):-1;return{section:t,sectionId:t.section_id,onViewerClose:n,onSectionNav:r,isCanPrev:o??!1,isCanNext:s??!1,canTracking:i??!1,canToggleShowGaze:u??!1,showGaze:a??!1,onToggleShowGaze:l,handleAskCalibration:d,currentGlobalRunIndex:f,lastUpdateBy:"program",totalRuns:w,pageIndex:0,totalPages:0,sectionLoading:!0,_loadingStartTime:v,_scrollApi:void 0,derivedNav:S,layout:h,rangeStartGI:null,rangeEndGI:null,translateOpen:!1,translateLoading:!1,translateText:void 0,translatedText:void 0,translateStartGI:void 0,translateEndGI:void 0}}function lu(e){const{section:t,initialIndex:n,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i,canTracking:u,canToggleShowGaze:a,showGaze:l,onToggleShowGaze:d,handleAskCalibration:S,eventBridgeStore:h}=e,g=t.ast.blocks,{nav:v,layout:w}=su(g),c=Date.now(),f=iu({section:t,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i,canTracking:u,canToggleShowGaze:a,showGaze:l,onToggleShowGaze:d,handleAskCalibration:S,nav:v,layout:w,initialIndex:n,mountTime:c});return h&&queueMicrotask(()=>{h.getState().emit({type:"render_start",payload:{sectionId:t.section_id}},c),h.getState().emit({type:"loading_start",payload:{}},c)}),Vt((p,C)=>{const T=N=>{p(D=>D.progress._scrollApi===N?D:{progress:{...D.progress,_scrollApi:N}})},I=()=>C().progress._scrollApi,j=N=>{p(D=>{const q=D.progress;if(q.totalRuns===N)return D;const A=q.currentGlobalRunIndex<0&&N>0;return{progress:{...q,totalRuns:N,currentGlobalRunIndex:A?0:q.currentGlobalRunIndex,lastUpdateBy:A?"program":q.lastUpdateBy}}})},b=(N,D="program")=>{const q=C().progress.currentGlobalRunIndex,A=C().progress,G=A.totalRuns>0?Math.max(-1,Math.min(N,A.totalRuns-1)):N;q===G&&A.lastUpdateBy===D||(p(K=>({progress:{...K.progress,currentGlobalRunIndex:G,lastUpdateBy:D}})),q!==G&&h&&h.getState().emit({type:"global_index_change",payload:{globalIndex:G}}))},y=N=>{const{sectionLoading:D,_loadingStartTime:q}=C().progress;if(D===N)return;const A=Date.now();if(N)p(G=>({progress:{...G.progress,sectionLoading:!0,_loadingStartTime:A}})),h&&h.getState().emit({type:"loading_start",payload:{}});else{const K=(q?A-q:0)/1e3;p(H=>({progress:{...H.progress,sectionLoading:!1,_loadingStartTime:null}})),h&&h.getState().emit({type:"loading_end",payload:{duration:K}})}},k=N=>{p(D=>({progress:{...D.progress,pageIndex:N}}))},R=N=>{p(D=>({progress:{...D.progress,totalPages:N}}))},_=(N,D)=>{const A=C().progress.rangeStartGI==null;if(p(G=>({progress:{...G.progress,rangeStartGI:Math.min(N,D),rangeEndGI:Math.max(N,D)}})),h){const G=E();h.getState().emit({type:A?"range_select":"range_change",payload:{startGI:Math.min(N,D),endGI:Math.max(N,D),text:G}})}},z=()=>{p(N=>({progress:{...N.progress,rangeStartGI:null,rangeEndGI:null}})),h&&h.getState().emit({type:"range_clear",payload:{}})},B=N=>{const{rangeStartGI:D,rangeEndGI:q}=C().progress;D==null||q==null||(N<D?p(A=>({progress:{...A.progress,rangeStartGI:N}})):N>q?p(A=>({progress:{...A.progress,rangeEndGI:N}})):z())},E=()=>{var te;const{rangeStartGI:N,rangeEndGI:D,section:q,layout:A}=C().progress;if(N==null||D==null||!A)return"";const G=((te=q.ast)==null?void 0:te.blocks)??[],K=A.prefix,H=[];for(let $=0;$<G.length;$++){const Z=G[$];if(Z.type!=="paragraph")continue;const ee=Z.runs??[],J=K[$]??0;for(let ce=0;ce<ee.length;ce++){const se=J+ce;se>=N&&se<=D&&H.push(ee[ce].text??"")}}return H.join("")},P=N=>{p(D=>({progress:{...D.progress,translateOpen:N.isOpen,translateLoading:N.isLoading??!1,translateText:N.text,translatedText:N.translatedText,translateStartGI:N.startGI,translateEndGI:N.endGI}}))},F=()=>{p(N=>({progress:{...N.progress,translateOpen:!1,translateLoading:!1,translateText:void 0,translatedText:void 0,translateStartGI:void 0,translateEndGI:void 0}}))},M=N=>{const{totalRuns:D,derivedNav:q}=C().progress,A=q==null?void 0:q.readableGi;if(!A||D<=0)return N;const G=D,K=Math.max(0,Math.min(N,G-1));if(A[K])return K;let H=K-1,te=K+1;for(;H>=0||te<G;){if(te<G&&A[te])return te;if(H>=0&&A[H])return H;te+=1,H-=1}return K},O=(N,D)=>{const{totalRuns:q,derivedNav:A}=C().progress,G=A==null?void 0:A.readableGi;if(!G||q<=0)return null;if(D>0){for(let K=Math.min(Math.max(N,0),q-1);K<q;K+=1)if(G[K])return K}else for(let K=Math.min(Math.max(N,0),q-1);K>=0;K-=1)if(G[K])return K;return null},Q=N=>{const{totalRuns:D,derivedNav:q}=C().progress,A=q==null?void 0:q.readableGi;if(!A||D<=0)return null;if(N>0){for(let G=D-1;G>=0;G-=1)if(A[G])return G}else for(let G=0;G<D;G+=1)if(A[G])return G;return null};return{progress:{...f,registerSectionScrollApi:T,getSectionScrollApi:I,setTotalRuns:j,setCurrentGlobalRunIndex:b,setSectionLoading:y,setPageIndex:k,setTotalPages:R,setTranslateState:P,clearTranslate:F,setRange:_,clearRange:z,extendRange:B,getRangeText:E,snapToReadable:M,nextReadableFrom:O,edgeReadable:Q,hasReadableInDir:(N,D)=>O(N+(D>0?1:-1),D)!=null,computeStepTarget:(N,D)=>{const{totalRuns:q,derivedNav:A}=C().progress;if(!q||q<=0)return N;const G=(A==null?void 0:A.groups)??[],K=A==null?void 0:A.giToGroupIdx;if(!G.length||!K){const J=q-1;return M(Math.max(0,Math.min(N+D,J)))}let H=K[N]??-1;if(H<0||H>=G.length)for(let ee=0;ee<G.length;ee+=1){const J=G[ee];if(N>=J.startG&&N<=J.endG){H=ee;break}}if(H<0||H>=G.length)return Q(D)??M(N);const te=ee=>ee>=0&&ee<G.length&&(G[ee].firstReadableGI??-1)>=0;let $=H+D;for(;$>=0&&$<G.length&&!te($);)$+=D;if($<0||$>=G.length)return Q(D)??M(N+D);const Z=G[$].firstReadableGI;return Z>=0?Z:M(N+D)},giToPercentTotal:N=>{const D=C().progress.totalRuns;return!D||D<=1?0:Math.max(0,Math.min(N,D-1))/(D-1)*100},percentToGITotal:N=>{const D=C().progress.totalRuns;if(!D||D<=1)return 0;const q=Math.max(0,Math.min(N,100)),A=Math.round(q/100*(D-1));return Math.max(0,Math.min(A,D-1))}}}})}function au({children:e,initialState:t,gazeSync:n}){const r=m.useContext(mt),o=m.useMemo(()=>lu({...t,...n?n.getSnapshot():{},eventBridgeStore:r}),[t,r]);return m.useEffect(()=>{if(!n)return;const s=()=>{const i=n.getSnapshot(),u=o.getState().progress;u.canTracking===i.canTracking&&u.canToggleShowGaze===i.canToggleShowGaze&&u.showGaze===i.showGaze&&u.onToggleShowGaze===i.onToggleShowGaze&&u.handleAskCalibration===i.handleAskCalibration||o.setState(a=>({progress:{...a.progress,canTracking:i.canTracking,canToggleShowGaze:i.canToggleShowGaze,showGaze:i.showGaze,onToggleShowGaze:i.onToggleShowGaze,handleAskCalibration:i.handleAskCalibration}}))};return s(),n.subscribe(s)},[o,n]),x.jsx(lr.Provider,{value:o,children:e})}function cu({children:e,initialState:t}){const n=m.useContext(mt)??void 0,r=m.useRef(Js({init:t,recorderStore:n}));return x.jsx(ir.Provider,{value:r.current,children:e})}const uu=({pages:e,pageIndex:t,maxWidth:n})=>{const r=V(p=>p.section),o=m.useMemo(()=>{var p;return((p=r.ast)==null?void 0:p.blocks)??[]},[r]),s=X(p=>p.marginX),i=X(p=>p.lineHeight),u=X(p=>p.fontSizePx),a=X(p=>p.fontFamily),l=X(p=>p.viewportHeight),d=V(p=>{var C;return((C=p.layout)==null?void 0:C.prefix)??[]}),S=V(p=>{var C;return((C=p.derivedNav)==null?void 0:C.splitGroupsPerBlock)??[]}),h=e[t],g=m.useMemo(()=>{const p=[];return o.forEach((C,T)=>{(C.type==="paragraph"||C.type==="image")&&p.push(T)}),p},[o]),v=m.useMemo(()=>{if(!h)return[];const p=[];for(let C=h.startBlock;C<=h.endBlock;C++){const T=g[C];T!=null&&p.push(T)}return p},[h,g]),w=m.useMemo(()=>{const p=[];for(const C of v){const T=o[C];(T==null?void 0:T.type)==="paragraph"&&p.push({b:T,originalBlockIndex:C})}return p},[v,o]),c=m.useMemo(()=>{const p=new Map,C=Sr();return w.forEach((T,I)=>{p.set(T.originalBlockIndex,{idx:I,marker:yr(T.b,C)})}),p},[w]),f=(p,C,T)=>{if(!p||p.length===0)return[];const I=[];for(const j of p){const b=j.startG,y=j.endG;if(y<C||b>T)continue;const k=Math.max(b,C),R=Math.min(y,T),_=k-b|0,z=Math.max(0,R-k+1);if(z<=0)continue;const B=(j.r0??0)+_;I.push({...j,startG:k,endG:R,r0:B,len:z})}return I};return x.jsx("div",{style:{position:"relative",width:"100%",height:"100%",minHeight:0,display:"flex",alignItems:"stretch",justifyContent:"center",fontFamily:a,fontSize:u,lineHeight:i,boxSizing:"border-box"},children:x.jsxs("div",{style:{width:"100%",maxWidth:n,height:"100%",boxSizing:"border-box",overflow:"hidden",display:"flex",flexDirection:"column",margin:"0 auto"},children:[x.jsx("div",{style:{height:40}}),x.jsx("div",{style:{flex:1,overflow:"hidden"},children:v.map((p,C)=>{var q;const T=o[p],I=C===0,j=C===v.length-1,b={boxSizing:"border-box",paddingRight:`${s}px`,paddingLeft:`${s}px`,maxWidth:n,margin:"0 auto",display:"flex",width:"100%",height:"auto"},y=`sec-${r.section_id}/blk-${T.id??p}`;if(T.type==="image"){const{src:A,alt:G,width:K,height:H}=T,te=K&&H?`${K} / ${H}`:"4 / 3",$=l>80?Math.floor((l-80)*.6):void 0;return x.jsx("div",{style:b,children:x.jsxs("div",{style:{margin:"12px 0",textAlign:"center",width:"100%"},children:[x.jsx("div",{style:{position:"relative",width:"100%",maxHeight:$,aspectRatio:te},children:x.jsx("img",{src:A,alt:G||"",loading:"eager",style:{pointerEvents:"none",position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"contain",display:"block"}})}),G&&x.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:G})]})},y)}const k=T,R=c.get(p),_=R==null?void 0:R.marker,z=k.runs??[],B=z.length;let E=0,P=Math.max(0,B-1);I&&h.startOffsetInBlock!=null&&(E=Math.min(Math.max(0,h.startOffsetInBlock),P)),j&&h.endOffsetInBlock!=null&&(P=Math.max(E,Math.min(h.endOffsetInBlock,P)));const F=E>0,M=d[p]??0,O=S[p]??[],Q=M+E,re=M+P;let oe=f(O,Q,re);const ie=M+E;oe=oe.map(A=>{const G=Math.max(0,(A.startG??Q)-ie),K=A.len??Math.max(1,(A.endG??re)-(A.startG??Q)+1);return{...A,r0:G,len:K}});const ue=E<=P?z.slice(E,P+1):[],xe=k.list?k.list.level*24:0,N=((q=k.list)==null?void 0:q.kind)==="bullet"?k.list.glyph??"•":void 0,D=F?void 0:_??N;return x.jsx("div",{style:b,children:x.jsxs("p",{style:{width:"100%",margin:"8px 0",paddingLeft:xe,textAlign:k.textAlign,whiteSpace:"pre-wrap",boxSizing:"border-box"},children:[k.list&&D?x.jsx("span",{"aria-hidden":!0,style:{minWidth:16,display:"inline-block",whiteSpace:"nowrap",userSelect:"none"},children:D||""}):null,x.jsx(ys,{preGroups:oe,runs:ue,ns:y,baseIndex:ie,sectionId:String(r.section_id)})]})},y)})})]})})},nn=.5;function du(e,t){const n=m.useRef(null),r=m.useRef(null),o=m.useRef(!1);m.useEffect(()=>{const s=()=>{n.current==null&&(n.current=requestAnimationFrame(()=>{n.current=null,t(),o.current=!0,requestAnimationFrame(()=>{o.current=!1})}))},i=new ResizeObserver(a=>{if(o.current)return;const l=a[0],{width:d,height:S}=l.contentRect,h=r.current;if(!h){r.current={w:d,h:S};return}Math.abs(h.w-d)<nn&&Math.abs(h.h-S)<nn||(r.current={w:d,h:S},s())});e.forEach(a=>{a.current&&i.observe(a.current)});const u=()=>{var l;const a=(l=e[0])==null?void 0:l.current;if(a&&r.current){const d=a.offsetWidth,S=a.offsetHeight;if(Math.abs(r.current.w-d)<nn&&Math.abs(r.current.h-S)<nn)return;r.current={w:d,h:S}}s()};return window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u),i.disconnect(),n.current!=null&&cancelAnimationFrame(n.current),n.current=null}},[e,t])}function fu(e){const{onPrev:t,onNext:n,onSingle:r,onDouble:o,shouldIgnoreTarget:s,shouldIgnoreSwipe:i,horizontalThreshold:u=120,velocityThreshold:a=.6,singleDelayMs:l=250,doubleClickWindowMs:d=300,onDragMove:S,onDragEnd:h,pageTransitionThreshold:g}=e,v=g??u,w=10,c=We.useRef({touchId:null,startX:0,startY:0,startT:0,swiping:!1,mouseDown:!1,mouseSwiping:!1,mStartX:0,mStartY:0,mStartT:0,capturedEl:null,prevUserSelect:"",lastTapT:0,singleTimer:null,suppressClick:!1}),f=()=>{c.current.singleTimer!=null&&(clearTimeout(c.current.singleTimer),c.current.singleTimer=null)},p=We.useCallback(E=>{if(s!=null&&s(E))return;const P=performance.now();P-c.current.lastTapT<=d&&c.current.lastTapT>0?(f(),c.current.lastTapT=0,o==null||o()):(f(),r&&(c.current.singleTimer=window.setTimeout(()=>{c.current.singleTimer=null,r()},l)),c.current.lastTapT=P)},[s,d,o,r,l]),C=We.useCallback((E,P)=>{const F=Math.abs(E)/Math.max(1,P);Math.abs(E)>=v||F>=a?E<0?n():t():h==null||h()},[v,a,n,t,h]),T=We.useCallback(E=>{if(E.touches.length!==1)return;const P=i??s;if(P!=null&&P(E.target))return;const F=E.touches[0];c.current.touchId=F.identifier,c.current.startX=F.clientX,c.current.startY=F.clientY,c.current.startT=E.timeStamp,c.current.swiping=!1},[i,s]),I=We.useCallback(E=>{if(c.current.touchId==null)return;const P=Array.from(E.touches).find(Q=>Q.identifier===c.current.touchId);if(!P)return;const F=P.clientX-c.current.startX,M=Math.abs(F),O=Math.abs(P.clientY-c.current.startY);if(!c.current.swiping)if(M>=w&&M>O)c.current.swiping=!0;else return;S==null||S(F)},[S]),j=We.useCallback(E=>{if(c.current.touchId==null)return;const P=Array.from(E.changedTouches).find(Q=>Q.identifier===c.current.touchId);if(!P)return;const F=P.clientX-c.current.startX,M=P.clientY-c.current.startY,O=E.timeStamp-c.current.startT;c.current.swiping?C(F,O):Math.abs(F)<10&&Math.abs(M)<10&&p(E.target),c.current.suppressClick=!0,c.current.touchId=null,c.current.swiping=!1},[C,p]),b=We.useCallback(()=>{c.current.swiping&&(h==null||h()),c.current.touchId=null,c.current.swiping=!1},[h]),y=We.useCallback(E=>{if(E.pointerType==="touch"||c.current.mouseDown)return;const P=i??s;P!=null&&P(E.target)||(c.current.mouseDown=!0,c.current.mouseSwiping=!1,c.current.mStartX=E.clientX,c.current.mStartY=E.clientY,c.current.mStartT=E.timeStamp,c.current.suppressClick=!1,c.current.capturedEl=E.currentTarget)},[i,s]),k=We.useCallback(E=>{if(E.pointerType==="touch"||!c.current.mouseDown)return;const P=E.clientX-c.current.mStartX,F=Math.abs(P),M=Math.abs(E.clientY-c.current.mStartY);if(!c.current.mouseSwiping)if(F>=w&&F>M){c.current.mouseSwiping=!0,c.current.suppressClick=!0;const O=c.current.capturedEl;if(O!=null&&O.setPointerCapture)try{O.setPointerCapture(E.pointerId)}catch{}c.current.prevUserSelect=document.body.style.userSelect,document.body.style.userSelect="none",E.preventDefault()}else return;S==null||S(P),E.preventDefault()},[S]),R=We.useCallback(E=>{var F;if(E.pointerType==="touch"||!c.current.mouseDown)return;if(c.current.mouseSwiping){const M=E.clientX-c.current.mStartX,O=E.timeStamp-c.current.mStartT;C(M,O),document.body.style.userSelect=c.current.prevUserSelect}const P=c.current.capturedEl;if((F=P==null?void 0:P.hasPointerCapture)!=null&&F.call(P,E.pointerId))try{P.releasePointerCapture(E.pointerId)}catch{}c.current.mouseDown=!1,c.current.mouseSwiping=!1,c.current.capturedEl=null},[C]),_=We.useCallback(E=>{E.pointerType!=="touch"&&(c.current.mouseSwiping&&(h==null||h(),document.body.style.userSelect=c.current.prevUserSelect),c.current.mouseDown=!1,c.current.mouseSwiping=!1,c.current.capturedEl=null)},[h]),z=We.useCallback(()=>{c.current.mouseSwiping&&(h==null||h(),document.body.style.userSelect=c.current.prevUserSelect),c.current.mouseDown=!1,c.current.mouseSwiping=!1,c.current.capturedEl=null},[h]),B=We.useCallback(E=>{if(c.current.suppressClick){c.current.suppressClick=!1;return}p(E.target)},[p]);return We.useEffect(()=>()=>{f(),document.body.style.userSelect=""},[]),{onTouchStart:T,onTouchMove:I,onTouchEnd:j,onTouchCancel:b,onPointerDown:y,onPointerMove:k,onPointerUp:R,onPointerCancel:_,onLostPointerCapture:z,onClick:B}}var An,go;function Ms(){if(go)return An;go=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return An=e,An}var Pn,ho;function pu(){if(ho)return Pn;ho=1;var e=typeof Qt=="object"&&Qt&&Qt.Object===Object&&Qt;return Pn=e,Pn}var Bn,mo;function Es(){if(mo)return Bn;mo=1;var e=pu(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Bn=n,Bn}var Ln,bo;function gu(){if(bo)return Ln;bo=1;var e=Es(),t=function(){return e.Date.now()};return Ln=t,Ln}var Gn,xo;function hu(){if(xo)return Gn;xo=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return Gn=t,Gn}var Hn,vo;function mu(){if(vo)return Hn;vo=1;var e=hu(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Hn=n,Hn}var Fn,So;function js(){if(So)return Fn;So=1;var e=Es(),t=e.Symbol;return Fn=t,Fn}var Nn,yo;function bu(){if(yo)return Nn;yo=1;var e=js(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,o=e?e.toStringTag:void 0;function s(i){var u=n.call(i,o),a=i[o];try{i[o]=void 0;var l=!0}catch{}var d=r.call(i);return l&&(u?i[o]=a:delete i[o]),d}return Nn=s,Nn}var Dn,wo;function xu(){if(wo)return Dn;wo=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return Dn=n,Dn}var Wn,Co;function vu(){if(Co)return Wn;Co=1;var e=js(),t=bu(),n=xu(),r="[object Null]",o="[object Undefined]",s=e?e.toStringTag:void 0;function i(u){return u==null?u===void 0?o:r:s&&s in Object(u)?t(u):n(u)}return Wn=i,Wn}var qn,Io;function Su(){if(Io)return qn;Io=1;function e(t){return t!=null&&typeof t=="object"}return qn=e,qn}var Vn,To;function yu(){if(To)return Vn;To=1;var e=vu(),t=Su(),n="[object Symbol]";function r(o){return typeof o=="symbol"||t(o)&&e(o)==n}return Vn=r,Vn}var $n,ko;function wu(){if(ko)return $n;ko=1;var e=mu(),t=Ms(),n=yu(),r=NaN,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,i=/^0o[0-7]+$/i,u=parseInt;function a(l){if(typeof l=="number")return l;if(n(l))return r;if(t(l)){var d=typeof l.valueOf=="function"?l.valueOf():l;l=t(d)?d+"":d}if(typeof l!="string")return l===0?l:+l;l=e(l);var S=s.test(l);return S||i.test(l)?u(l.slice(2),S?2:8):o.test(l)?r:+l}return $n=a,$n}var Un,Ro;function Cu(){if(Ro)return Un;Ro=1;var e=Ms(),t=gu(),n=wu(),r="Expected a function",o=Math.max,s=Math.min;function i(u,a,l){var d,S,h,g,v,w,c=0,f=!1,p=!1,C=!0;if(typeof u!="function")throw new TypeError(r);a=n(a)||0,e(l)&&(f=!!l.leading,p="maxWait"in l,h=p?o(n(l.maxWait)||0,a):h,C="trailing"in l?!!l.trailing:C);function T(B){var E=d,P=S;return d=S=void 0,c=B,g=u.apply(P,E),g}function I(B){return c=B,v=setTimeout(y,a),f?T(B):g}function j(B){var E=B-w,P=B-c,F=a-E;return p?s(F,h-P):F}function b(B){var E=B-w,P=B-c;return w===void 0||E>=a||E<0||p&&P>=h}function y(){var B=t();if(b(B))return k(B);v=setTimeout(y,j(B))}function k(B){return v=void 0,C&&d?T(B):(d=S=void 0,g)}function R(){v!==void 0&&clearTimeout(v),c=0,d=w=S=v=void 0}function _(){return v===void 0?g:k(t())}function z(){var B=t(),E=b(B);if(d=arguments,S=this,w=B,E){if(v===void 0)return I(w);if(p)return clearTimeout(v),v=setTimeout(y,a),T(w)}return v===void 0&&(v=setTimeout(y,a)),g}return z.cancel=R,z.flush=_,z}return Un=i,Un}var Iu=Cu();const Tu=Po(Iu);function ku(e,t=200,n,r){const o=m.useRef(e),s=m.useRef(n);m.useEffect(()=>{o.current=e},[e]),m.useEffect(()=>{s.current=n},[n]);const i=m.useMemo(()=>{const u=Tu((...l)=>{o.current(...l)},t,r),a=((...l)=>{var d;(d=s.current)==null||d.call(s),u(...l)});return a.cancel=u.cancel.bind(u),a.flush=u.flush.bind(u),a},[t,r]);return m.useEffect(()=>()=>i.cancel(),[i]),i}const Ru="https://fonts.googleapis.com/css2?family=Nanum+Myeongjo:wght@400;700&family=Noto+Sans+KR:wght@300;400;500;700&family=Noto+Serif+KR:wght@400;700&display=swap";let Kn=!1;function _u(){if(Kn||typeof document>"u")return;if(document.querySelector('link[href*="fonts.googleapis.com"][href*="Noto"]')){Kn=!0;return}const t=document.createElement("link");t.rel="stylesheet",t.href=Ru,document.head.appendChild(t),Kn=!0}const Os=new Map,zs=e=>Os.get(e)??0,Mu=e=>{const t=zs(e)+1;return Os.set(e,t),t};class As extends Error{constructor(){super("calcPages canceled due to a newer invocation");Ir(this,"code","CALC_PAGES_CANCELED");this.name="CalcPagesCanceled"}}const Ye=(e,t)=>{if(e!==zs(t))throw new As},Xn=e=>{const t=getComputedStyle(e),n=parseFloat(t.marginTop||"0")||0,r=parseFloat(t.marginBottom||"0")||0;return{mt:n,mb:r}},_o=e=>{const t=e.getClientRects(),n=t.length?t[0].top:e.getBoundingClientRect().top,r=e.querySelectorAll("[data-runbox]"),o=[];return r.forEach((s,i)=>{const u=s.getClientRects(),a=u.length?u[u.length-1].bottom:n;o[i]=Math.max(0,a-n)}),o},Eu=(e,t,n)=>{if(n<16)return async(o=24)=>{Ye(e,t)};let r=0;return async(o=24)=>{r++,r%o===0&&(Ye(e,t),await new Promise(s=>requestAnimationFrame(()=>s())),Ye(e,t))}};async function ju({viewHost:e,measureRoot:t,contentArea:n,items:r,cfgMaxWidth:o,marginX:s,fontFamily:i,fontSizePx:u,lineHeight:a,showSplit:l,breakGapPx:d=0,showSlash:S,paragraphMarkers:h,playbackScale:g=1,viewportHeight:v=0,instanceId:w="default"}){var f,p,C;const c=Mu(w);if(Ye(c,w),i&&typeof document<"u"&&document.fonts){_u();try{const T=`${u}px ${i}`;await document.fonts.load(T),document.fonts.check(T)||await document.fonts.ready}catch{}}Ye(c,w);try{const T=Math.abs(g-1)>.001,I=1/g;T&&(t.style.transform=`scale(${I})`,t.style.transformOrigin="top left");const j=Math.max(0,e.offsetWidth||0),b=Math.max(0,Math.min(j,o));t.style.maxWidth=`${b}px`,Ye(c,w);let y=Math.round(n.offsetHeight||0);y||(y=Math.max(0,n.clientHeight|0));const k=1.5,R=(H,te)=>te+H<=y-k,_=getComputedStyle(e),z={letterSpacing:_.letterSpacing,wordSpacing:_.wordSpacing,fontKerning:_.fontKerning||"normal",fontVariantLigatures:_.fontVariantLigatures||"normal",textTransform:_.textTransform||"none",direction:_.direction||"ltr",wordBreak:_.wordBreak||"keep-all",overflowWrap:_.overflowWrap||_.wordWrap||"break-word",hyphens:_.hyphens||"manual"},B=H=>{H.style.letterSpacing=z.letterSpacing||"",H.style.wordSpacing=z.wordSpacing||"",H.style.fontKerning=z.fontKerning||"",H.style.fontVariantLigatures=z.fontVariantLigatures||"",H.style.textTransform=z.textTransform||"",H.style.direction=z.direction||"",H.style.wordBreak=z.wordBreak||"",H.style.wordWrap=z.overflowWrap||"",H.style.overflowWrap=z.overflowWrap||"",H.style.hyphens=z.hyphens||""},E=b,P=Math.max(0,E-2*(s||0));n.innerHTML="";const F=document.createElement("div");F.style.boxSizing="border-box",F.style.width=`${E}px`,F.style.maxWidth=`${E}px`,F.style.margin="0 auto",F.style.display="flex",n.appendChild(F);const M=document.createElement("div");M.style.boxSizing="border-box",M.style.paddingRight=`${s}px`,M.style.paddingLeft=`${s}px`,M.style.width=`${E}px`,M.style.maxWidth=`${E}px`,M.style.margin="0 auto",M.style.display="flex",M.style.justifyContent="center",M.style.height="auto",F.appendChild(M);const O=new Map,Q={},re=Eu(c,w,r.length),oe=(H,te)=>{const $=document.createElement("p");return $.style.margin="8px 0",$.style.paddingLeft=te?`${te}px`:"0",$.style.textAlign=H.textAlign??"start",$.style.whiteSpace="pre-wrap",$.style.lineHeight=String(a),$.style.fontSize=`${u}px`,$.style.boxSizing="border-box",$.style.fontFamily=i??"",$.style.width="100%",B($),$},ie=(H,te)=>{const $=te??[],Z=document.createDocumentFragment();for(let ee=0;ee<$.length;ee++){const J=$[ee],ce=document.createElement("span");ce.dataset.runbox=String(ee),ce.style.whiteSpace="pre-wrap";const se=document.createElement("span");if(se.dataset.run=String(ee),se.textContent=(J==null?void 0:J.text)??"",se.style.whiteSpace="pre-wrap",J!=null&&J.bold&&(se.style.fontWeight="700"),J!=null&&J.italic&&(se.style.fontStyle="italic"),J!=null&&J.underline&&(se.style.textDecoration="underline"),ce.appendChild(se),l&&(J!=null&&J.split)&&ee!==$.length-1){const ve=Math.max(0,(d??0)/2),ge=document.createElement("span");ge.style.display="inline-block",ge.style.width=`${ve}px`;const Ce=document.createElement("span");if(Ce.style.display="inline-block",Ce.style.width=`${ve}px`,ce.appendChild(ge),S){const Re=document.createElement("span");Re.textContent=" / ",ce.appendChild(Re)}ce.appendChild(Ce)}Z.appendChild(ce)}H.appendChild(Z)},ue=v>80?Math.floor((v-80)*.6):void 0,xe=H=>{const te=H!=null&&H.width&&(H!=null&&H.height)?`${H.width} / ${H.height}`:"4 / 3",$=document.createElement("div");$.style.margin="12px 0",$.style.textAlign="center",$.style.width=`${P}px`;const Z=document.createElement("div");Z.style.position="relative",Z.style.width="100%",ue&&(Z.style.maxHeight=`${ue}px`),Z.style.aspectRatio=te;const ee=document.createElement("div");if(ee.style.position="absolute",ee.style.inset="0",ee.style.width="100%",ee.style.height="100%",Z.appendChild(ee),$.appendChild(Z),H!=null&&H.alt){const J=document.createElement("div");J.style.fontSize="12px",J.style.color="#6B7280",J.style.marginTop="4px",J.textContent=String(H.alt),B(J),$.appendChild(J)}return $};for(let H=0;H<r.length;H++){Ye(c,w);const te=r[H];if(M.dataset.block=String(H),M.innerHTML="",te.kind==="image"){const Ce=te.block,Re=xe(Ce);M.appendChild(Re);const Ae=Re.getBoundingClientRect(),{mt:je,mb:Ge}=Xn(Re);Q[H]={contentH:Math.ceil(Ae.height),mt:je,mb:Ge},await re(24);continue}const $=te.block,Z=$.list?($.list.level??0)*24:0,ee=te.paraIndex??0,J=h[ee]??(((f=$.list)==null?void 0:f.kind)==="bullet"?((p=$.list)==null?void 0:p.glyph)??"•":void 0);if(!!($.list&&J)){const Ce=oe($,Z);Ce.dataset.variant="with";const Re=oe($,Z);Re.dataset.variant="no";const Ae=document.createElement("span");Ae.textContent=`${J} `,Ae.style.minWidth="16px",Ae.style.display="inline-block",Ae.style.whiteSpace="nowrap",Ae.style.userSelect="none",Ce.appendChild(Ae),ie(Ce,$.runs),ie(Re,$.runs);const je=document.createDocumentFragment();je.appendChild(Ce),je.appendChild(Re),M.appendChild(je)}else{const Ce=oe($,Z);Ce.dataset.variant="with",ie(Ce,$.runs),M.appendChild(Ce)}const se=M.querySelector('p[data-variant="with"]'),ve=M.querySelector('p[data-variant="no"]'),ge=ve??se;if(se&&ge){const Ce=_o(se),Re=_o(ge),{mt:Ae,mb:je}=Xn(se),{mt:Ge,mb:rt}=Xn(ge),$e=((C=$.runs)==null?void 0:C.length)??0,Oe=ve?Re:Ce,et=ve?Ge:Ae,Qe=ve?rt:je;O.set(H,{runsLen:$e,lastBottomWith:Ce,lastBottomNo:Oe,mtWith:Ae,mbWith:je,mtNo:et,mbNo:Qe})}await re(24)}Ye(c,w),M.innerHTML="";const N=(H,te,$,Z)=>{if(te>$)return{top:0,content:0,mb:0};const ee=Z?H.lastBottomNo:H.lastBottomWith,J=Z?H.mtNo:H.mtWith,ce=Z?H.mbNo:H.mbWith,se=Z?0:J,ve=te>0?ee[te-1]??0:0,ge=Math.max(0,(ee[$]??0)-ve);return{top:se,content:ge,mb:ce}},D=[];let q=0,A,G=null,K=null;for(;q<r.length;){Ye(c,w);const H=q;let te=0,$=0,Z=A;Z!=null&&G===q&&K!=null&&(Z=Math.max(Z,K+1));let ee=-1,J;for(;q<r.length;){if(Ye(c,w),r[q].kind==="image"){const Oe=Q[q]??{contentH:0,mt:0,mb:0},Qe=(te===0?Oe.mt:$+Oe.mt)+Oe.contentH;if(R(Qe,te)){te+=Qe,ee=q,J=void 0,$=Oe.mb,q+=1,A=void 0,G=null,K=null;continue}if(te===0){D.push({startBlock:H,endBlock:q,...Z!=null?{startOffsetInBlock:Z}:{}}),q+=1,A=void 0,G=null,K=null,$=0;break}break}const se=O.get(q),ve=se.runsLen,ge=q===H&&Z!=null?Z:0;if(ge>=ve){q+=1,A=void 0,G=null,K=null;continue}const Ce=ge>0,Re=N(se,ge,ve-1,Ce),je=(te===0?Re.top:$+Re.top)+Re.content;if(R(je,te)){te+=je,ee=q,J=ve-1,$=Re.mb,q+=1,A=void 0,G=null,K=null;continue}let Ge=ge,rt=ve-1,$e=ge-1;for(;Ge<=rt;){Ye(c,w);const Oe=Ge+rt>>1,et=N(se,ge,Oe,Ce),Qe=(te===0?et.top:$+et.top)+et.content;R(Qe,te)?($e=Oe,Ge=Oe+1):rt=Oe-1}if($e>=ge){D.push({startBlock:H,endBlock:q,...Z!=null?{startOffsetInBlock:Z}:{},endOffsetInBlock:$e}),A=$e+1,G=q,K=$e,$=0;break}if(te>0){D.push({startBlock:H,endBlock:ee>=0?ee:Math.min(q-1,r.length-1),...Z!=null?{startOffsetInBlock:Z}:{},...J!=null?{endOffsetInBlock:J}:{}}),$=0;break}else{const Oe=ge;D.push({startBlock:H,endBlock:q,...Z!=null?{startOffsetInBlock:Z}:{},endOffsetInBlock:Oe}),A=Oe+1,G=q,K=Oe,$=0;break}}(D.length===0||D[D.length-1].startBlock!==H)&&D.push({startBlock:H,endBlock:ee>=0?ee:Math.min(q-1,r.length-1),...Z!=null?{startOffsetInBlock:Z}:{},...J!=null?{endOffsetInBlock:J}:{}})}return F.remove(),T&&(t.style.transform="",t.style.transformOrigin=""),Ye(c,w),{pages:D,pageByRunIndex:null}}catch(T){throw console.error(T),T}}function Ou(e){const t=[],n=[];let r=0;return e.forEach((o,s)=>{o.type==="paragraph"?(t.push({kind:"paragraph",block:o,originalIndex:s,paraIndex:r}),n.push(s),r+=1):o.type==="image"&&t.push({kind:"image",block:o,originalIndex:s})}),{items:t,paraIndexMap:n}}function Mo(e,t,n){var r;if(!e)return null;for(let o=e.startBlock;o<=e.endBlock;o++){const s=t[o];if(!s||s.kind!=="paragraph")continue;const i=((r=s.block.runs)==null?void 0:r.length)??0;if(!i)continue;const u=o===e.startBlock&&e.startOffsetInBlock!=null?Math.min(Math.max(0,e.startOffsetInBlock),i-1):0;return(n[s.originalIndex]??0)+u}return null}function zu(e,t,n,r){var o;for(let s=0;s<t.length;s++){const i=t[s];for(let u=i.startBlock;u<=i.endBlock;u++){const a=n[u];if(!a||a.kind!=="paragraph")continue;const l=((o=a.block.runs)==null?void 0:o.length)??0;if(!l)continue;let d=0,S=l-1;u===i.startBlock&&i.startOffsetInBlock!=null&&(d=Math.max(0,Math.min(i.startOffsetInBlock,S))),u===i.endBlock&&i.endOffsetInBlock!=null&&(S=Math.max(d,Math.min(i.endOffsetInBlock,S)));const h=r[a.originalIndex]??0,g=h+d,v=h+S;if(e>=g&&e<=v)return s}}return-1}function Au(e){var r,o;const t=e;if(!t)return!1;const n=((o=(r=t.tagName)==null?void 0:r.toLowerCase)==null?void 0:o.call(r))??"";return!!(["a","button","input","textarea","select","label"].includes(n)||t.isContentEditable)}function Pu(e){var n;const t=e;return t?!!((n=t.closest)!=null&&n.call(t,"[data-range-handle]")):!1}function Bu(){var Cr;const e=m.useId(),t=V(U=>U.section),n=V(U=>U.sectionLoading),r=lt(),o=m.useRef(!1);m.useEffect(()=>r.subscribe(U=>{o.current=U.progress.rangeStartGI!=null&&U.progress.rangeEndGI!=null}),[r]);const s=o.current,i=bt(),u=X(U=>U.theme),a=sn[u],l=X(U=>U.fontFamily),d=X(U=>U.fontSizePx),S=X(U=>U.lineHeight),h=X(U=>U.marginX),g=X(U=>U.viewportHeight),v=860,w=m.useRef(null),{items:c}=m.useMemo(()=>{var U;return Ou(((U=t==null?void 0:t.ast)==null?void 0:U.blocks)??[])},[t]),f=m.useMemo(()=>{const U=[],ze=Sr();return c.forEach(Be=>{if(Be.kind==="paragraph"){const ct=Be.paraIndex;U[ct]=yr(Be.block,ze)}}),U},[c]),[p,C]=m.useState({pages:[],pageByRunIndex:null}),T=V(U=>U.pageIndex),I=V(U=>U.setPageIndex),j=m.useRef(0),b=m.useRef(null),[y,k]=m.useState(!1),[R,_]=m.useState(null),[z,B]=m.useState(!1),E=m.useMemo(()=>({flex:1,fontFamily:l,background:a.bg,color:a.fg,fontSize:d,lineHeight:S,overflow:"hidden",width:"100%",height:"100%",position:"relative",boxSizing:"border-box",WebkitTextSizeAdjust:"none",MozTextSizeAdjust:"none",textSizeAdjust:"none"}),[l,a.bg,a.fg,d,S]),{showSplit:P,breakGapPx:F,slash:M}=X(qt(U=>{var ze;return{showSplit:U.showSplit,breakGapPx:U.breakGapPx??0,slash:((ze=U.breakMarks)==null?void 0:ze.slash)??!1}})),O=lt();m.useEffect(()=>{p&&p.pages.length&&(O.getState().progress.setTotalPages(p.pages.length+1),(async()=>{const U=O.getState().progress.setSectionLoading;await gt(),await gt(),await gt(),await gt(),U(!1)})())},[p,O]);const Q=m.useCallback(()=>{const U=w.current,ze=se.current,Be=ve.current;if(!U||!ze||!Be||c.length===0){C({pages:[],pageByRunIndex:null}),I(0),O.getState().progress.setTotalPages(0);return}(async()=>{performance.now();try{const ct=i.getState().playbackScale,{pages:ft,pageByRunIndex:ut}=await ju({viewHost:U,measureRoot:ze,contentArea:Be,items:c,cfgMaxWidth:v,marginX:h,fontFamily:l,fontSizePx:d,lineHeight:S,showSplit:P,breakGapPx:F,showSlash:M,paragraphMarkers:f,playbackScale:ct,viewportHeight:g,instanceId:e}),Gd=performance.now();C({pages:ft,pageByRunIndex:ut}),I(0)}catch(ct){if(ct instanceof As)return}})()},[I,c,v,h,l,d,S,P,F,M,f,i,g,e,O]),re=V(U=>U.setCurrentGlobalRunIndex),oe=V(U=>{var ze;return((ze=U.layout)==null?void 0:ze.prefix)??[]}),ie=we(U=>U.syncToGI),ue=m.useCallback(U=>{const ze=p.pages.length+1,Be=T+U;if(Be<0||Be>=ze)return;const ct=T===p.pages.length;if(Be===p.pages.length){I(Be);const ut=O.getState().progress.edgeReadable(1);ut!=null&&(re(ut,"extra-page"),ie(ut));return}if(ct&&U===-1){const ut=Mo(p.pages[Be],c,oe);ut!=null&&(re(ut,"scrubber-step"),ie(ut)),I(Be);return}const ft=Mo(p.pages[Be],c,oe);ft!=null?(re(ft,"scrubber-step"),ie(ft)):I(Be)},[T,p.pages,c,oe,re,I,ie,O]),xe=m.useCallback(()=>{y||j.current!==0?(_("prev"),k(!1)):ue(-1)},[y,ue]),N=m.useCallback(()=>{y||j.current!==0?(_("next"),k(!1)):ue(1)},[y,ue]),D=gn(),q=m.useCallback(()=>{const{isSettingsOpen:U,setSettingsOpen:ze,toggleOverlays:Be}=D.getState();U?ze(!1):Be()},[D]),A=p.pages.length+1,G=((Cr=w.current)==null?void 0:Cr.clientWidth)||400,K=m.useCallback(U=>{var ft;const ze=b.current;if(!ze)return;const Be=((ft=w.current)==null?void 0:ft.clientWidth)||1,ct=U/Be*33.333;ze.style.transform=`translate3d(${-33.333+ct}%, 0, 0)`},[]),H=m.useCallback(U=>{T===0&&U>0||T>=A-1&&U<0||(j.current=U,K(U),y||k(!0))},[T,A,K,y]),te=m.useCallback(()=>{j.current=0,k(!1);const U=b.current;U&&(U.style.transition="transform 250ms ease-out",U.style.transform="translate3d(-33.333%, 0, 0)")},[]),$=m.useCallback(U=>{if(U.target!==U.currentTarget||U.propertyName!=="transform")return;const ze=R;B(!0),_(null),j.current=0,ze==="prev"?ue(-1):ze==="next"&&ue(1)},[R,ue]);m.useLayoutEffect(()=>{z&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{B(!1)})})},[z]);const Z=cn(),ee=m.useCallback(U=>s||Pu(U)?!0:Au(U),[s]),J=m.useCallback(U=>Z.getState().status==="playing"?!0:ee(U),[Z,ee]),ce=fu({onPrev:xe,onNext:N,onSingle:q,onDouble:()=>{},shouldIgnoreTarget:ee,shouldIgnoreSwipe:J,horizontalThreshold:120,velocityThreshold:.6,singleDelayMs:250,doubleClickWindowMs:300,onDragMove:H,onDragEnd:te,pageTransitionThreshold:G*.5}),se=m.useRef(null),ve=m.useRef(null),ge=m.useCallback(()=>{const U=O.getState().progress.setSectionLoading;U(!0)},[O]),Ce=m.useMemo(()=>({trailing:!0,leading:!1,maxWait:1e3}),[]),Re=ku(Q,200,ge,Ce),Ae=m.useRef("");m.useEffect(()=>{if(g<=0)return;const U=`${l}|${d}|${S}|${h}|${P}|${F}|${M}|${g}|${t==null?void 0:t.section_id}`;Ae.current!==U&&(Ae.current=U,Re.cancel(),ge(),Q())},[Re,Q,ge,l,d,S,h,P,F,M,g,t==null?void 0:t.section_id]),du([w],Re);const je=V(U=>U.registerSectionScrollApi);m.useEffect(()=>(je({ensureVisibleGI:()=>Promise.resolve(!0),scrollToGI:()=>Promise.resolve(!0),getVisibleRange:()=>null,getScrollTop:()=>0,setScrollTop:()=>{},getAnchorOffsetRatio:()=>0,scrollToGIAtOffset:()=>Promise.resolve(),stepPage:ue}),()=>je(void 0)),[je,ue]);const Ge=t.quizzes&&t.quizzes.length>0,rt=p.pages.length>0&&T===p.pages.length,$e=T>0?T-1:null,Oe=T<A-1?T+1:null,et=m.useMemo(()=>R==="prev"?"translate3d(0%, 0, 0)":R==="next"?"translate3d(-66.666%, 0, 0)":"translate3d(-33.333%, 0, 0)",[R]),Qe=U=>n?null:U===p.pages.length?x.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,width:"100%",height:"100%"},children:[Ge&&x.jsx(Ts,{}),x.jsx(pn,{isIcon:!1})]}):x.jsx(uu,{pages:p.pages,pageIndex:U,maxWidth:v}),Tt={width:"33.333%",height:"100%",flexShrink:0,display:"flex",alignItems:"stretch",justifyContent:"center",overflow:"hidden",boxSizing:"border-box",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},Sn=!z&&(!y||R!==null);return x.jsxs("div",{ref:w,style:{...E,touchAction:"none"},...ce,children:[x.jsxs("div",{ref:b,style:{display:"flex",width:"300%",height:"100%",transform:et,transition:Sn?"transform 250ms ease-out":"none",willChange:"transform",boxSizing:"border-box",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},onTransitionEnd:R?$:void 0,children:[x.jsx("div",{style:Tt,children:$e!==null&&Qe($e)}),x.jsx("div",{style:Tt,children:Qe(T)}),x.jsx("div",{style:Tt,children:Oe!==null&&Qe(Oe)})]}),x.jsx("div",{ref:se,"aria-hidden":!0,style:{position:"absolute",contain:"layout style paint",left:-999999,top:-999999,zIndex:-999999,opacity:0,width:"100%",maxWidth:v,height:"100%",minHeight:0,boxSizing:"border-box",overflow:"hidden",fontFamily:l,fontSize:d,lineHeight:S,pointerEvents:"none",background:"pink"},children:x.jsxs("div",{style:{width:"100%",maxWidth:v,height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",margin:"0 auto",overflow:"hidden"},children:[x.jsx("div",{style:{height:40,background:"blue"}}),x.jsx("div",{ref:ve,style:{height:"calc(100% - 110px)",overflow:"hidden",boxSizing:"border-box",width:"100%"}})]})}),x.jsx(Lu,{pages:p.pages,items:c,onGotoPage:I,currentPageIndex:T,isOnExtraPage:rt})]})}const Lu=({pages:e,items:t,onGotoPage:n,currentPageIndex:r,isOnExtraPage:o})=>{const s=V(l=>l.currentGlobalRunIndex),i=V(l=>l.lastUpdateBy),u=V(l=>{var d;return((d=l.layout)==null?void 0:d.prefix)??[]}),a=m.useRef(null);return m.useEffect(()=>{if(s==null||e.length===0||o&&!(i==="scrubber-live"||i==="scrubber-commit"||i==="scrubber-step")||a.current===s)return;a.current=s;const l=zu(s,e,t,u);l>=0&&l!==r&&n(l)},[s,e,t,u,n,r,o,i]),x.jsx(x.Fragment,{})},Gu="_wrapper_dbk3n_1",Hu="_spinner_dbk3n_10",Eo={wrapper:Gu,spinner:Hu};function Fu({size:e=28,speed:t=.8}){return x.jsx("div",{className:`${Eo.wrapper}`,children:x.jsx("div",{className:Eo.spinner,style:{width:e,height:e,borderWidth:3,animationDuration:`${t}s`}})})}function Nu(){const e=V(qt(t=>t.sectionLoading===!0));return x.jsx(x.Fragment,{children:e===!0&&x.jsx(Fu,{})})}const Du="_Overlay_ybic8_3",Wu="_Dialog_ybic8_15",qu="_Body_ybic8_25",Vu="_Header_ybic8_32",$u="_Paging_ybic8_39",Uu="_Remaining_ybic8_48",Ku="_RemainingDanger_ybic8_55",Xu="_NextBtn_ybic8_59",Qu="_CloseBtn_ybic8_96",Yu="_Question_ybic8_113",Zu="_Score_ybic8_123",Ju="_Image_ybic8_130",ed="_Options_ybic8_140",td="_OptionBtn_ybic8_145",nd="_OptionBtnActive_ybic8_165",rd="_Footer_ybic8_172",od="_OptionBtnCorrect_ybic8_195",sd="_Judge_ybic8_201",id="_Correct_ybic8_212",ld="_Incorrect_ybic8_215",ad="_ResultHeader_ybic8_220",cd="_ResultActions_ybic8_233",ud="_CloseBtnSoft_ybic8_239",dd="_SummaryGrid_ybic8_249",fd="_StatCard_ybic8_257",pd="_StatLabel_ybic8_265",gd="_StatValue_ybic8_270",hd="_StatSub_ybic8_277",fe={Overlay:Du,Dialog:Wu,Body:qu,Header:Vu,Paging:$u,Remaining:Uu,RemainingDanger:Ku,NextBtn:Xu,CloseBtn:Qu,Question:Yu,Score:Zu,Image:Ju,Options:ed,OptionBtn:td,OptionBtnActive:nd,Footer:rd,OptionBtnCorrect:od,Judge:sd,Correct:id,Incorrect:ld,ResultHeader:ad,ResultActions:cd,CloseBtnSoft:ud,SummaryGrid:dd,StatCard:fd,StatLabel:pd,StatValue:gd,StatSub:hd};function md(e){return e?e.kind==="temp"?e.image_blob_url:e.image_cdn_url:null}function Ps(e){var t;return(((t=e.answers)==null?void 0:t.length)??0)>1}function bd(e){const t=e.answers??[],n=[];return t.forEach(r=>{const o=e.options.findIndex(s=>s===r);o>=0&&n.push(o)}),n.sort((r,o)=>r-o)}const xd=m.memo(function(){const t=Ue(c=>c.phase),n=Ue(c=>c.quizzes),r=Ue(c=>c.order),o=Ue(c=>c.currentIndex),s=Ue(c=>c.answers),i=Ue(c=>c.correctCount),u=Ue(c=>c.remainingSec),a=Ue(c=>c.uiReveal),l=Ue(c=>c.startedAt),d=Ue(c=>c.finishedAt),S=Ue(c=>c.perQ),h=Is();m.useEffect(()=>{if(t==="idle"||t!=="doing"||u==null)return;const c=window.setInterval(()=>h.getState().tick(),1e3);return()=>window.clearInterval(c)},[t,u,h]);const g=t==="doing"?n[r[o]]:void 0,v=t==="doing"&&g?s[g.qid]??[]:[],w=m.useMemo(()=>{if(t==="idle"||t!=="finished")return;const c=r.map(M=>n[M]),f=c.length,p=c.reduce((M,O)=>M+(O.score??0),0),C=c.reduce((M,O)=>{const Q=S[O.qid];return M+(Q!=null&&Q.isCorrect?O.score??0:0)},0),T=c.map(M=>S[M.qid]).filter(M=>!!M),I=typeof l=="number"&&typeof d=="number"?Math.max(0,d-l):T.reduce((M,O)=>M+(O.ms??0),0),j=f>0?Math.round(I/f):0,b=[...T].sort((M,O)=>M.ms-O.ms),y=b[0],k=b[b.length-1],R=T.filter(M=>!M.multi),_=T.filter(M=>M.multi),z=R.filter(M=>M.isCorrect).length,B=_.filter(M=>M.isCorrect).length,E=T.filter(M=>M.timedOut).length,P=T.filter(M=>M.revealed).length,F=T.filter(M=>!M.isCorrect).sort((M,O)=>O.ms-M.ms).slice(0,3);return{total:f,correct:i,rate:f?Math.round(i/f*100):0,timeMsTotal:I,avgMs:j,totalScore:p,gainedScore:C,fastest:y,slowest:k,singles:{total:R.length,correct:z},multis:{total:_.length,correct:B},timedOut:E,revealed:P,wrongTop3:F}},[t,r,n,S,l,d,i]);return t==="idle"?null:x.jsx("div",{className:fe.Overlay,role:"dialog","aria-modal":"true",children:x.jsx("div",{className:fe.Dialog,children:t==="doing"&&g?x.jsx(vd,{q:g,index:o,total:r.length,selected:v,uiReveal:a,onSelect:c=>{if(a)return;const f=h.getState();Ps(g)?f.selectToggle(c):f.selectSingle(c)},onBeforeNext:()=>h.getState().setReveal(!0),onNext:()=>h.getState().afterRevealNext(),remainingSec:u,onClose:()=>h.getState().close()}):x.jsx(Sd,{total:r.length,correct:i,summary:w,retryAllowed:h.getState().retryAllowed,onClose:()=>h.getState().close(),onRetry:()=>{const f=h.getState().quizzes;if(!f.length)return;const p=f[0];h.setState({phase:"doing",currentIndex:0,answers:{},correctCount:0,startedAt:Date.now(),finishedAt:void 0,questionStartedAt:Date.now(),remainingSec:p.limit_sec||void 0,uiReveal:!1,perQ:{}})}})})})});function vd(e){const{q:t,index:n,total:r,selected:o,uiReveal:s,onSelect:i,onBeforeNext:u,onNext:a,remainingSec:l,onClose:d}=e,S=Ps(t),h=m.useMemo(()=>{const c=t.options.map((f,p)=>({opt:f,i:p}));for(let f=c.length-1;f>0;f--){const p=Math.floor(Math.random()*(f+1));[c[f],c[p]]=[c[p],c[f]]}return c},[t.options]),g=m.useMemo(()=>md(t),[t]),v=m.useMemo(()=>bd(t),[t]),w=m.useMemo(()=>{const c=[...o].sort((f,p)=>f-p);if(c.length!==v.length)return!1;for(let f=0;f<c.length;f++)if(c[f]!==v[f])return!1;return!0},[o,v]);return x.jsxs("div",{className:fe.Body,children:[x.jsxs("div",{className:fe.Header,children:[x.jsx("div",{className:fe.Paging,children:`Quiz (${n+1}/${r})`}),x.jsx("button",{type:"button",onClick:d,className:fe.CloseBtn,children:"X"})]}),x.jsx("div",{className:fe.Question,children:t.question}),x.jsx("div",{className:fe.Score,children:` (${t.score}점${S?" ,모두선택":""})`}),x.jsx("div",{className:`${fe.Judge}${s?w?` ${fe.Correct}`:` ${fe.Incorrect}`:""}`,"aria-live":"polite",children:s?w?`Correct : +${t.score} point`:"Incorrect : 0 point":"a"}),x.jsx("div",{className:fe.Image,children:g&&x.jsx("img",{src:g,alt:""})}),x.jsx("div",{className:fe.Options,children:h.map(({opt:c,i:f})=>{const p=o.includes(f),C=v.includes(f),T=[fe.OptionBtn,p?fe.OptionBtnActive:"",s&&C?fe.OptionBtnCorrect:""].filter(Boolean).join(" ");return x.jsx("button",{type:"button",onClick:()=>i(f),className:T,disabled:s,children:c},f)})}),x.jsx("div",{className:fe.Footer,children:s?x.jsx("button",{type:"button",onClick:a,className:fe.NextBtn,children:n+1>=r?"Complete":"Next Quiz"}):x.jsxs("button",{type:"button",onClick:u,className:`${fe.NextBtn}`,children:["Submit",typeof l=="number"&&x.jsx("span",{className:`${fe.Remaining} ${l<=5?fe.RemainingDanger:""}`,children:` (${l} s )`})]})})]})}function jo(e){return e==null?"-":`${Math.round(e/1e3)}s`}function Sd(e){const{total:t,correct:n,summary:r,retryAllowed:o,onClose:s,onRetry:i}=e,u=(r==null?void 0:r.rate)??(t>0?Math.round(n/t*100):0);return x.jsxs("div",{className:fe.Body,children:[x.jsx("div",{className:fe.ResultHeader,children:"결과 요약"}),x.jsxs("div",{className:fe.SummaryGrid,role:"list",children:[x.jsxs("div",{className:fe.StatCard,role:"listitem",children:[x.jsx("div",{className:fe.StatLabel,children:"정답률"}),x.jsxs("div",{className:fe.StatValue,children:[u,"%"]}),x.jsx("div",{className:fe.StatSub,children:`정답수 ${n}/문제수${t}`})]}),x.jsxs("div",{className:fe.StatCard,role:"listitem",children:[x.jsx("div",{className:fe.StatLabel,children:"총 점수"}),x.jsx("div",{className:fe.StatValue,children:r?`${r.gainedScore}/${r.totalScore}`:"-"}),x.jsx("div",{className:fe.StatSub,children:"획득점수/최대점수"})]}),x.jsxs("div",{className:fe.StatCard,role:"listitem",children:[x.jsx("div",{className:fe.StatLabel,children:"총 소요 시간"}),x.jsx("div",{className:fe.StatValue,children:jo(r==null?void 0:r.timeMsTotal)}),x.jsx("div",{className:fe.StatSub,children:`평균 ${jo(r==null?void 0:r.avgMs)}`})]}),x.jsxs("div",{className:fe.StatCard,role:"listitem",children:[x.jsx("div",{className:fe.StatLabel,children:"타입오버 퀴즈수"}),x.jsx("div",{className:fe.StatValue,children:r?`${r.timedOut}`:"-"}),x.jsx("div",{className:fe.StatSub,children:"timeout"})]})]}),x.jsxs("div",{className:fe.ResultActions,children:[o&&x.jsx("button",{type:"button",onClick:i,className:fe.CloseBtnSoft,children:"다시 풀기"}),x.jsx("button",{type:"button",onClick:s,className:fe.CloseBtnSoft,children:"닫기"})]})]})}function yd(e){return e.map((t,n)=>n)}function wd(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Qn(e){var t;return(((t=e.answers)==null?void 0:t.length)??0)>1}function Yn(e){const t=e.answers??[],n=[];return t.forEach(r=>{const o=e.options.findIndex(s=>s===r);o>=0&&n.push(o)}),n.sort((r,o)=>r-o)}function Oo(e){if(!e)return{};const t=(e.quizzes??[]).slice().sort((n,r)=>n.index-r.index);return{sectionId:e.section_id,quizzes:t,order:yd(t),currentIndex:0,answers:{},correctCount:0,startedAt:void 0,finishedAt:void 0,questionStartedAt:void 0,remainingSec:void 0,uiReveal:!1,perQ:{}}}function Cd(e,t){const n=(t==null?void 0:t.retryAllowed)??!0,r=(t==null?void 0:t.previousResult)??null,o={phase:"idle",sectionId:void 0,quizzes:[],order:[],currentIndex:0,answers:{},correctCount:0,startedAt:void 0,finishedAt:void 0,questionStartedAt:void 0,remainingSec:void 0,uiReveal:!1,perQ:{},retryAllowed:n,previousResult:r},s=Oo(e);return Vt()((u,a)=>({...o,...s,hydrateFromSection:l=>{if(!l)return;const d=Oo(l);u(d)},openFromSection:l=>{l&&a().hydrateFromSection(l);const d=a();if(!d.quizzes.length)return;if(!d.retryAllowed&&d.previousResult){const h={};for(const g of d.previousResult.perQuestion)h[g.qid]={qid:g.qid,index:g.index,question:g.question,score:g.score,multi:g.correctIdxes.length>1,selected:g.selected,correctIdxes:g.correctIdxes,isCorrect:g.isCorrect,ms:g.ms,revealed:!0,timedOut:g.timedOut};u({phase:"finished",correctCount:d.previousResult.correct,perQ:h,startedAt:void 0,finishedAt:void 0});return}const S=d.quizzes[0];u({phase:"doing",startedAt:Date.now(),finishedAt:void 0,questionStartedAt:Date.now(),remainingSec:S.limit_sec||void 0,currentIndex:0,uiReveal:!1})},close:()=>{u({phase:"idle",sectionId:void 0,quizzes:[],order:[],currentIndex:0,answers:{},correctCount:0,startedAt:void 0,finishedAt:void 0,questionStartedAt:void 0,remainingSec:void 0,uiReveal:!1,perQ:{}})},selectToggle:l=>{const d=a();if(d.phase!=="doing"||d.uiReveal)return;const h=d.quizzes[d.order[d.currentIndex]].qid,g=d.answers[h]??[],v=g.includes(l)?g.filter(w=>w!==l):[...g,l].sort((w,c)=>w-c);u({answers:{...d.answers,[h]:v}})},selectSingle:l=>{const d=a();if(d.phase!=="doing"||d.uiReveal)return;const h=d.quizzes[d.order[d.currentIndex]].qid;u({answers:{...d.answers,[h]:[l]}})},submitCurrent:()=>{const l=a();if(l.phase!=="doing")return;const d=l.order[l.currentIndex],S=l.quizzes[d],h=S.qid,g=(l.answers[h]??[]).slice().sort((C,T)=>C-T),v=Yn(S),w=wd(g,v),c=l.questionStartedAt?Date.now()-l.questionStartedAt:0,f=l.perQ[h],p={qid:h,index:S.index,question:S.question,score:S.score??0,multi:Qn(S),selected:g,correctIdxes:v,isCorrect:w,ms:c,revealed:(f==null?void 0:f.revealed)??!1,timedOut:(f==null?void 0:f.timedOut)??!1};if(u({correctCount:l.correctCount+(w?1:0),perQ:{...l.perQ,[h]:p}}),l.currentIndex+1>=l.order.length)u({uiReveal:!1,remainingSec:void 0}),a().finish();else{const C=l.currentIndex+1;u({currentIndex:C,questionStartedAt:Date.now(),remainingSec:l.quizzes[l.order[C]].limit_sec||void 0,uiReveal:!1})}},setReveal:l=>{const d=a();if(d.phase==="doing"){if(l){const S=d.quizzes[d.order[d.currentIndex]],h=S.qid,g=d.perQ[h],v={qid:h,index:S.index,question:S.question,score:S.score??0,multi:Qn(S),selected:(g==null?void 0:g.selected)??[],correctIdxes:(g==null?void 0:g.correctIdxes)??Yn(S),isCorrect:(g==null?void 0:g.isCorrect)??!1,ms:(g==null?void 0:g.ms)??0,revealed:!0,timedOut:(g==null?void 0:g.timedOut)??!1};u({perQ:{...d.perQ,[h]:v}})}u({uiReveal:l})}},afterRevealNext:()=>{a().phase==="doing"&&a().submitCurrent()},next:()=>{const l=a();if(l.phase!=="doing"||l.currentIndex+1>=l.order.length)return;const d=l.currentIndex+1;u({currentIndex:d,questionStartedAt:Date.now(),remainingSec:l.quizzes[l.order[d]].limit_sec||void 0,uiReveal:!1})},prev:()=>{const l=a();if(l.phase!=="doing"||l.currentIndex<=0)return;const d=l.currentIndex-1;u({currentIndex:d,questionStartedAt:Date.now(),remainingSec:l.quizzes[l.order[d]].limit_sec||void 0,uiReveal:!1})},finish:()=>{u({phase:"finished",remainingSec:void 0,uiReveal:!1,finishedAt:Date.now()})},tick:()=>{const l=a();if(l.phase!=="doing"||l.remainingSec==null)return;const d=l.remainingSec-1;if(d<=0){const S=l.quizzes[l.order[l.currentIndex]],h=S.qid,g=l.perQ[h],v={qid:h,index:S.index,question:S.question,score:S.score??0,multi:Qn(S),selected:(g==null?void 0:g.selected)??[],correctIdxes:(g==null?void 0:g.correctIdxes)??Yn(S),isCorrect:(g==null?void 0:g.isCorrect)??!1,ms:(g==null?void 0:g.ms)??0,revealed:!0,timedOut:!0};u({remainingSec:0,uiReveal:!0,perQ:{...l.perQ,[h]:v}})}else u({remainingSec:d})}}))}function Id({children:e,initialState:t}){const n=m.useMemo(()=>Cd(t.section,{retryAllowed:t.quizRetryAllowed??!0,previousResult:t.previousQuizResult??null}),[t]),r=m.useRef(t.onQuizStart),o=m.useRef(t.onQuizComplete);return m.useEffect(()=>{r.current=t.onQuizStart},[t.onQuizStart]),m.useEffect(()=>{o.current=t.onQuizComplete},[t.onQuizComplete]),m.useEffect(()=>{const s=n.subscribe((i,u)=>{var a;if(u.phase!=="doing"&&i.phase==="doing"&&((a=r.current)==null||a.call(r)),u.phase!=="finished"&&i.phase==="finished"){const l=o.current;if(!l||!i.retryAllowed&&i.previousResult&&!i.startedAt)return;const{sectionId:d,quizzes:S,order:h,perQ:g,startedAt:v,finishedAt:w}=i,c=h.map(y=>S[y]),f=c.length,p=c.filter(y=>{var k;return(k=g[y.qid])==null?void 0:k.isCorrect}).length,C=c.reduce((y,k)=>y+(k.score??0),0),T=c.reduce((y,k)=>{const R=g[k.qid];return y+(R!=null&&R.isCorrect?k.score??0:0)},0),I=typeof v=="number"&&typeof w=="number"?Math.max(0,w-v):0,j=c.map(y=>{const k=g[y.qid];return{qid:y.qid,index:y.index,question:y.question,score:y.score??0,isCorrect:(k==null?void 0:k.isCorrect)??!1,selected:(k==null?void 0:k.selected)??[],correctIdxes:(k==null?void 0:k.correctIdxes)??[],ms:(k==null?void 0:k.ms)??0,timedOut:(k==null?void 0:k.timedOut)??!1}}),b={sectionId:d??"",total:f,correct:p,rate:f>0?Math.round(p/f*100):0,totalScore:C,gainedScore:T,timeMsTotal:I,perQuestion:j};l(b)}});return()=>s()},[n]),x.jsx(wr.Provider,{value:n,children:e})}const zo=["mode","theme","fontFamily","fontSizePx","lineHeight","marginX","marginY","pointerStyle","pointerColor","breakMarks","breakGapPx","muteAudio","audioSpeed","showPointer","showSplit","showOverlays","overlayCompactMode","isSettingsOpen"];function Td({containerRef:e}){const t=bt(),n=gn(),r=m.useRef(null);return m.useEffect(()=>{const o=e.current;if(!o)return;let s=o.clientWidth,i=o.clientHeight;n.getState().setViewportSize(s,i);const u=new ResizeObserver(()=>{const a=o.clientWidth,l=o.clientHeight;(a!==s||l!==i)&&(s=a,i=l,n.getState().setViewportSize(a,l),t.getState().emit({type:"viewport_resize",payload:{width:a,height:l}}))});return u.observe(o),()=>u.disconnect()},[t,n,e]),m.useEffect(()=>{const o=n.getState();r.current={};for(const i of zo)r.current[i]=o[i];const s=n.subscribe(i=>{const u=r.current;if(u)for(const a of zo){const l=u[a],d=i[a];l!==d&&(a==="mode"?t.getState().emit({type:"mode_change",payload:{mode:d}}):t.getState().emit({type:"settings_change",payload:{key:a,value:d}}),u[a]=d)}});return()=>{s(),r.current=null}},[t,n]),null}function kd(){const e=bt(),t=gn(),n=lt(),r=m.useContext(Lo),o=m.useContext(vn),s=m.useCallback(a=>{const{viewerState:l}=a;if(l){l.mode&&t.getState().setMode(l.mode);const{mode:h,...g}=l,v=t.getState(),w={};for(const[c,f]of Object.entries(g))v[c]!==f&&(w[c]=f);Object.keys(w).length>0&&t.setState(w)}if(typeof a.globalIndex=="number"&&n.getState().progress.setCurrentGlobalRunIndex(a.globalIndex,"playback"),(l==null?void 0:l.mode)==="scroll"||!(l!=null&&l.mode)){const h=()=>{const g=n.getState().progress.getSectionScrollApi();if(!g)return!1;if(a.scrollY===0)g.setScrollTop(0);else if(g.scrollToGIAtOffset){const v=a.anchorGI??a.globalIndex;if(typeof v=="number"){const w=a.anchorOffsetRatio??0;g.scrollToGIAtOffset(v,w)}}return!0};if(!h()){let g=0;const v=setInterval(()=>{(h()||++g>=10)&&clearInterval(v)},50)}}a.audio&&o&&o.getState()._setStatusOnly(a.audio.status);const S=n.getState().progress;a.range?S.setRange(a.range.startGI,a.range.endGI):S.clearRange(),a.translate&&a.translate.isOpen?S.setTranslateState({isOpen:!0,isLoading:a.translate.isLoading,text:a.translate.text,translatedText:a.translate.translatedText,startGI:a.translate.startGI,endGI:a.translate.endGI}):S.clearTranslate()},[t,n,o]),i=m.useCallback(()=>{var I,j,b,y;const a=t.getState(),l=n.getState().progress,d=(I=l.getSectionScrollApi)==null?void 0:I.call(l),S=l.currentGlobalRunIndex??0,h=((j=d==null?void 0:d.getScrollTop)==null?void 0:j.call(d))??0,g=((b=d==null?void 0:d.getAnchorOffsetRatio)==null?void 0:b.call(d,S))??0,v=o==null?void 0:o.getState(),w=v?{status:v.status,currentClip:v.currentClip,currentTimeMs:v.currentTimeMs}:void 0,{rangeStartGI:c,rangeEndGI:f}=l,p=c!=null&&f!=null?{startGI:c,endGI:f,text:l.getRangeText()}:null,C=((y=d==null?void 0:d.getScrollRatio)==null?void 0:y.call(d))??0,T=l.translateOpen?{isOpen:!0,isLoading:l.translateLoading,text:l.translateText,translatedText:l.translatedText,startGI:l.translateStartGI,endGI:l.translateEndGI}:null;return{viewerState:{mode:a.mode,theme:a.theme,fontFamily:a.fontFamily,fontSizePx:a.fontSizePx,lineHeight:a.lineHeight,marginX:a.marginX,marginY:a.marginY,showOverlays:a.showOverlays,isSettingsOpen:a.isSettingsOpen,pointerStyle:a.pointerStyle,pointerColor:a.pointerColor,breakMarks:a.breakMarks,breakGapPx:a.breakGapPx,muteAudio:a.muteAudio,audioSpeed:a.audioSpeed,showPointer:a.showPointer,showSplit:a.showSplit,overlayCompactMode:a.overlayCompactMode,viewportWidth:a.viewportWidth,viewportHeight:a.viewportHeight},globalIndex:S,scrollY:h,scrollRatio:C,anchorGI:S,anchorOffsetRatio:g,currentPage:l.pageIndex??0,totalPages:l.totalPages,sectionId:l.sectionId??"",viewportWidth:a.viewportWidth,viewportHeight:a.viewportHeight,audio:w,range:p,translate:T}},[t,n,o]),u=m.useCallback(a=>{switch(a.type){case"global_index_change":{const{globalIndex:l}=a.payload;n.getState().progress.setCurrentGlobalRunIndex(l,"playback");break}case"scroll":{if(t.getState().mode==="page")break;const{scrollTop:d,anchorGI:S,anchorOffsetRatio:h}=a.payload,g=n.getState().progress.getSectionScrollApi();if(!g)break;d===0?g.setScrollTop(0):g.scrollToGIAtOffset&&typeof S=="number"&&g.scrollToGIAtOffset(S,h);break}case"settings_change":{const{key:l,value:d}=a.payload,S=t.getState();l in S&&typeof S[l]!="function"&&t.setState({[l]:d});break}case"mode_change":{const{mode:l}=a.payload;t.getState().setMode(l);break}case"audio_control":{if(!o)break;const{action:l}=a.payload;switch(l){case"play":o.getState()._setStatusOnly("playing");break;case"pause":o.getState()._setStatusOnly("paused");break;case"stop":o.getState()._setStatusOnly("idle");break}break}case"page_change":{const{pageIndex:l}=a.payload;n.getState().progress.setPageIndex(l);break}case"range_select":case"range_change":{const{startGI:l,endGI:d}=a.payload;n.getState().progress.setRange(l,d),n.getState().progress;break}case"range_clear":{n.getState().progress.clearRange();break}case"translate_request":{const{text:l,startGI:d,endGI:S}=a.payload;n.getState().progress.setTranslateState({isOpen:!0,isLoading:!0,text:l,startGI:d,endGI:S});break}case"translate_loading_start":{n.getState().progress.setTranslateState({isOpen:!0,isLoading:!0});break}case"translate_loading_end":{const{originalText:l,translatedText:d}=a.payload;n.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,text:l,translatedText:d});break}case"translate_modal_close":{n.getState().progress.clearTranslate();break}case"render_start":case"loading_start":case"loading_end":case"viewport_resize":break;default:console.log("[DirectPlaybackController] 미처리 이벤트:",a.type)}},[n,t,o]);return m.useLayoutEffect(()=>r?(r.current={dispatch:u,applySnapshot:s,getSnapshot:i,isReady:()=>!n.getState().progress.sectionLoading,waitUntilReady:()=>new Promise(l=>{if(!n.getState().progress.sectionLoading){l();return}const d=n.subscribe(S=>{S.progress.sectionLoading||(d(),l())})})},e.getState().isPlaybackMode&&(e.getState().setDispatchHandler(u),e.getState().setApplySnapshotHandler(s)),()=>{e.getState().setDispatchHandler(null),e.getState().setApplySnapshotHandler(null)}):void 0,[r,e,u,s,i,n]),m.useLayoutEffect(()=>e.subscribe((l,d)=>{l.isPlaybackMode&&!d.isPlaybackMode?(e.getState().setDispatchHandler(u),e.getState().setApplySnapshotHandler(s)):!l.isPlaybackMode&&d.isPlaybackMode&&(e.getState().setDispatchHandler(null),e.getState().setApplySnapshotHandler(null))}),[e,u,s]),null}function Rd(e){const t=e.querySelectorAll("[data-gi]");if(t.length<2)return 0;const n=[];let r=null,o=-1/0;for(let s=0;s<t.length;s++){const i=t[s].getBoundingClientRect();if(r&&Math.abs(i.top-o)<i.height*.5){const u=i.left-r.right;u>=0&&n.push(u)}r=i,o=i.top}return n.length===0?0:n.reduce((s,i)=>s+i,0)/n.length}function _d({containerRef:e}){const t=X(d=>d.fontSizePx),n=X(d=>d.fontFamily),r=X(d=>d.lineHeight),o=X(d=>d.marginX),s=X(d=>d.breakMarks),i=X(d=>d.breakGapPx),u=X(d=>d.showSplit),a=X(d=>d.viewportWidth),l=bt();return m.useEffect(()=>{const d=e.current;if(!d)return;let S;const h=requestAnimationFrame(()=>{S=requestAnimationFrame(()=>{const g=Rd(d);l.setState({wordAvgDistancePx:g})})});return()=>{cancelAnimationFrame(h),cancelAnimationFrame(S)}},[e,l,t,n,r,o,s,i,u,a]),null}const Md=({containerRef:e,onTranslate:t})=>{const n=V(h=>h.rangeStartGI),r=V(h=>h.rangeEndGI),o=V(h=>h.getRangeText),s=V(h=>h.clearRange),i=bt(),u=n!=null&&r!=null,[a,l]=m.useState(null);m.useEffect(()=>{if(!u)return;const h=e.current;if(!h)return;let g=!0;const v=new ResizeObserver(()=>{if(g){g=!1;return}s()});return v.observe(h),()=>v.disconnect()},[u,s,e]),m.useEffect(()=>{if(!u||n==null||r==null){l(null);return}const h=()=>{const c=e.current;if(!c)return;const f=c.getBoundingClientRect(),C=1/(i.getState().playbackScale||1),T=c.querySelector(`[data-g="${r}"]`);if(!T){l({x:f.width*C/2,y:80});return}const I=T.getBoundingClientRect(),j=c.querySelector(`[data-g="${n}"]`),b=j==null?void 0:j.getBoundingClientRect();let y=(I.left+I.width/2-f.left)*C;b&&(y=((b.left+I.right)/2-f.left)*C);const k=160,R=50,_=16,z=12,B=f.width*C,E=Math.max(_+k/2,Math.min(y,B-_-k/2)),P=(((b==null?void 0:b.top)??I.top)-f.top)*C-R-z;let F=P;P<_&&(F=(I.bottom-f.top)*C+z),l({x:E,y:F})};h();const g=e.current;let v=0;const w=()=>{v||(v=requestAnimationFrame(()=>{v=0,h()}))};return g&&g.addEventListener("scroll",w,!0),()=>{v&&cancelAnimationFrame(v),g&&g.removeEventListener("scroll",w,!0)}},[u,n,r,e,i]);const d=m.useCallback(()=>{const h=o();h&&navigator.clipboard.writeText(h).catch(g=>{console.error("복사 실패:",g)}),s()},[o,s]),S=m.useCallback(()=>{const h=o();h&&t&&t(h)},[o,t]);return!u||!a?null:x.jsxs("div",{"data-range-menu":!0,style:{position:"absolute",left:a.x,top:a.y,transform:"translateX(-50%)",display:"flex",gap:8,padding:"8px 12px",backgroundColor:"#fff",borderRadius:8,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.3)",zIndex:1e4},children:[x.jsx("button",{onClick:d,style:{padding:"8px 16px",backgroundColor:"#3b82f6",color:"#fff",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:"pointer",whiteSpace:"nowrap"},children:"복사"}),x.jsx("button",{onClick:S,style:{padding:"8px 16px",backgroundColor:"#10b981",color:"#fff",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:"pointer",whiteSpace:"nowrap"},children:"번역"})]})},Ed="_handleStart_1ihf3_16 _handle_1ihf3_1",jd="_handleEnd_1ihf3_21 _handle_1ihf3_1",Ao={handleStart:Ed,handleEnd:jd},Od=({containerRef:e})=>{const t=V(c=>c.rangeStartGI),n=V(c=>c.rangeEndGI),r=V(c=>c.setRange),o=bt(),s=t!=null&&n!=null,[i,u]=m.useState(null),[a,l]=m.useState(null),d=m.useRef(null),S=m.useRef({startGI:t,endGI:n});S.current={startGI:t,endGI:n};const h=m.useRef(r);h.current=r,m.useEffect(()=>{if(!s||t==null||n==null){u(null),l(null);return}const c=()=>{const p=e.current;if(!p)return;const C=p.getBoundingClientRect(),I=1/(o.getState().playbackScale||1),j=p.querySelector(`[data-g="${t}"]`),b=p.querySelector(`[data-g="${n}"]`);if(j){const y=j.getBoundingClientRect();u({x:(y.left-C.left)*I,y:(y.bottom-C.top)*I})}else u(null);if(b){const y=b.getBoundingClientRect();l({x:(y.right-C.left)*I,y:(y.bottom-C.top)*I})}else l(null)};c();const f=e.current;return f&&f.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{f&&f.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[s,t,n,e,o]);const g=m.useCallback((c,f)=>{var C;const p=document.elementsFromPoint(c,f);for(const T of p){const I=(C=T.getAttribute)==null?void 0:C.call(T,"data-g");if(I!=null)return parseInt(I,10)}return null},[]);m.useEffect(()=>{const c=p=>{if(!d.current)return;const{startGI:C,endGI:T}=S.current;if(C==null||T==null)return;const I=g(p.clientX,p.clientY);I!=null&&(d.current==="start"?I<=T?h.current(I,T):(h.current(T,I),d.current="end"):I>=C?h.current(C,I):(h.current(I,C),d.current="start"))},f=()=>{d.current=null,setTimeout(()=>{Zr(!1)},50)};return document.addEventListener("pointermove",c),document.addEventListener("pointerup",f),document.addEventListener("pointercancel",f),()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",f),document.removeEventListener("pointercancel",f)}},[g]);const v=m.useCallback(c=>f=>{f.preventDefault(),f.stopPropagation(),d.current=c,Zr(!0)},[]);return s?x.jsxs(x.Fragment,{children:[i&&x.jsx("div",{className:Ao.handleStart,"data-range-handle":"start",style:{left:i.x-26,top:i.y},onPointerDown:v("start")}),a&&x.jsx("div",{className:Ao.handleEnd,"data-range-handle":"end",style:{left:a.x,top:a.y},onPointerDown:v("end")})]}):null};function zd(){const e=V(o=>o.rangeStartGI),t=V(o=>o.rangeEndGI),n=V(o=>o.clearRange),r=e!=null&&t!=null;return m.useEffect(()=>{if(!r)return;const o=s=>{var u;if(Ss())return;const i=s.target;if(!(i.closest("[data-range-menu]")||i.closest("[data-range-handle]"))){if(i.closest("[data-g]")){const a=(u=i.closest("[data-g]"))==null?void 0:u.getAttribute("data-g");if(a){const l=parseInt(a,10),d=Math.min(e,t),S=Math.max(e,t);if(l>=d&&l<=S)return}}n()}};return document.addEventListener("click",o,!0),()=>document.removeEventListener("click",o,!0)},[r,e,t,n]),null}const Ad=({isOpen:e,isLoading:t=!1,onClose:n,text:r,translatedText:o})=>e?x.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:10001},onClick:n,children:x.jsxs("div",{style:{position:"relative",backgroundColor:"#fff",borderRadius:12,padding:"24px 32px",minWidth:280,maxWidth:"80%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.2)"},onClick:s=>s.stopPropagation(),children:[x.jsx("button",{onClick:n,style:{position:"absolute",top:12,right:12,width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"transparent",border:"none",borderRadius:"50%",cursor:"pointer",fontSize:20,color:"#666"},"aria-label":"닫기",children:"✕"}),x.jsx("h3",{style:{margin:"0 0 16px 0",fontSize:18,fontWeight:600,color:"#333"},children:"번역"}),r&&x.jsx("div",{style:{padding:12,backgroundColor:"#f5f5f5",borderRadius:8,fontSize:14,color:"#555",maxHeight:100,overflow:"auto",marginBottom:12},children:r}),t?x.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"16px 0",gap:8,color:"#888",fontSize:15},children:[x.jsx("span",{style:{display:"inline-block",width:18,height:18,border:"2px solid #ccc",borderTopColor:"#3b82f6",borderRadius:"50%",animation:"cr-translate-spin 0.8s linear infinite"}}),"번역 중...",x.jsx("style",{children:"@keyframes cr-translate-spin { to { transform: rotate(360deg); } }"})]}):o?x.jsx("div",{style:{padding:12,backgroundColor:"#eef7ff",borderRadius:8,fontSize:15,color:"#333",maxHeight:150,overflow:"auto",lineHeight:1.5},children:o}):x.jsx("p",{style:{margin:0,fontSize:16,color:"#666",textAlign:"center",padding:"16px 0"},children:"준비중입니다"})]})}):null,Pd=(e,t,n)=>Math.min(n,Math.max(t,e));function Bd({section:e,initialViewerState:t,initialProgressRunIndex:n,onViewerClose:r,onSectionNav:o,isCanPrev:s=!1,isCanNext:i=!1,onQuizStart:u,onQuizComplete:a,quizRetryAllowed:l,previousQuizResult:d,onViewerEvent:S,viewerRef:h,gazeSync:g,onRequestTranslate:v,isPlaybackMode:w=!1,playbackScale:c,isDev:f=!1}){const p=String((e==null?void 0:e.section_id)??"0"),C=m.useMemo(()=>{var k,R;const b=((k=e==null?void 0:e.ast)==null?void 0:k.blocks)??[];let y=0;for(const _ of b)(_==null?void 0:_.type)!=="image"&&(y+=((R=_==null?void 0:_.runs)==null?void 0:R.length)??0);return y},[e]),T=m.useMemo(()=>typeof n=="number"?Pd(n,C>0?0:-1,Math.max(C-1,-1)):(C>0,0),[n,C]),I=m.useMemo(()=>({section:e,initialIndex:T,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i}),[e,T,r,o,s,i]),j=m.useMemo(()=>{const b=(e==null?void 0:e.audios)??[],y=b.length>0?ru(e):void 0;return{clips:b,map:y,initialIndex:T,section:e}},[e,T]);return x.jsx(Qs,{onViewerEvent:S,isPlaybackMode:w,playbackScale:c,viewerRef:h,children:x.jsx(cu,{initialState:{...t,isDev:f},children:x.jsx(au,{initialState:I,gazeSync:g,children:x.jsx(nu,{initialState:j,children:x.jsx(Id,{initialState:{section:e,onQuizStart:u,onQuizComplete:a,quizRetryAllowed:l,previousQuizResult:d},children:x.jsx(Ld,{onRequestTranslate:v})},p)},p)},p)})})}function Ld({onRequestTranslate:e}){const t=X(v=>v.mode),n=m.useRef(null),r=bt(),o=lt();m.useEffect(()=>{if(t==="scroll"){const{progress:v}=o.getState();v.setTotalPages(0),v.setPageIndex(0)}},[t,o]);const s=V(v=>v.translateOpen),i=V(v=>v.translateLoading),u=V(v=>v.translateText),a=V(v=>v.translatedText),l=m.useRef(null),d=m.useCallback(v=>{var T;const{rangeStartGI:w,rangeEndGI:c}=o.getState().progress,f=w??0,p=c??0;if(r.getState().emit({type:"translate_request",payload:{text:v,startGI:f,endGI:p}}),!e){o.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,text:v,startGI:f,endGI:p});return}o.getState().progress.setTranslateState({isOpen:!0,isLoading:!0,text:v,startGI:f,endGI:p}),(T=l.current)==null||T.abort();const C=new AbortController;l.current=C,e(v,C.signal).then(I=>{if(!C.signal.aborted){if(I==null){o.getState().progress.clearTranslate();return}o.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,text:v,translatedText:I,startGI:f,endGI:p}),r.getState().emit({type:"translate_loading_end",payload:{originalText:v,translatedText:I}})}}).catch(I=>{if(C.signal.aborted)return;const j=I instanceof Error?I.message:"번역 실패";o.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,text:v,translatedText:`[오류] ${j}`,startGI:f,endGI:p})})},[r,o,e]),S=m.useCallback(()=>{var v;(v=l.current)==null||v.abort(),l.current=null,o.getState().progress.clearTranslate(),r.getState().emit({type:"translate_modal_close",payload:{}})},[r,o]),h=v=>{v.preventDefault()},g=v=>{v.preventDefault()};return x.jsxs("div",{ref:n,onContextMenu:h,onDragStart:g,style:{position:"relative",display:"flex",flexDirection:"column",height:"100%",width:"100%",WebkitTextSizeAdjust:"100%",textSizeAdjust:"100%",userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"none"},children:[t==="scroll"?x.jsx(va,{}):x.jsx(Bu,{}),x.jsx(Md,{containerRef:n,onTranslate:d}),x.jsx(Od,{containerRef:n}),x.jsx(Xc,{}),x.jsx(xd,{}),x.jsx(Nu,{}),x.jsx(zd,{}),x.jsx(Ad,{isOpen:s,isLoading:i,onClose:S,text:u,translatedText:a}),x.jsx(Td,{containerRef:n}),x.jsx(kd,{}),x.jsx(_d,{containerRef:n})]})}exports.CRViewer=Bd;
|