@readerseye2/cr_viewer 1.0.45 → 1.0.46

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
@@ -1,5 +1,5 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('@charset "UTF-8";._handle_1ihf3_1{position:absolute;width:26px;height:26px;background-color:#3b82f6;box-shadow:0 2px 4px #0000004d;cursor:grab;z-index:10001;touch-action:none}._handle_1ihf3_1:active{cursor:grabbing;background-color:#2563eb}._handleStart_1ihf3_16{border-radius:13px 0 13px 13px}._handleEnd_1ihf3_21{border-radius:0 13px 13px}._run_zzb61_3{cursor:pointer}._runWrap_zzb61_7{position:relative;isolation:isolate;z-index:0}._highlight_zzb61_13:before,._highlightleft_zzb61_14:before,._highlightright_zzb61_15:before,._highlightcenter_zzb61_16:before{content:"";position:absolute;z-index:-1;top:-4px;bottom:-4px;background:var(--hl-color, pink);pointer-events:none}._highlight_zzb61_13:before{left:-4px;right:-4px}._highlightleft_zzb61_14:before{left:-4px;right:0}._highlightright_zzb61_15:before{left:0;right:-4px}._highlightcenter_zzb61_16:before{left:0;right:0}._underline_zzb61_48:after,._underlineleft_zzb61_49:after,._underlineright_zzb61_50:after,._underlinecenter_zzb61_51:after{content:"";position:absolute;left:0;right:0;height:var(--ul-thickness, .2em);bottom:calc(-1 * var(--ul-offset, .35em));background:var(--ul-color, red);pointer-events:none}._underline_zzb61_48:after{left:-4px;right:-4px}._underlineleft_zzb61_49:after{left:-4px;right:0}._underlineright_zzb61_50:after{left:0;right:0}._underlinecenter_zzb61_51:after{left:0;right:0}._scroller_kqkmq_3{height:100%;overflow-y:auto;overflow-x:hidden;outline:none;scrollbar-width:none;-ms-overflow-style:none}._scroller_kqkmq_3::-webkit-scrollbar{width:0;height:0;background:transparent;pointer-events:none}._scroller_kqkmq_3::-webkit-scrollbar-track{background:transparent;pointer-events:none}._scroller_kqkmq_3::-webkit-scrollbar-thumb{background:transparent;pointer-events:none}._scroller_kqkmq_3::-webkit-scrollbar-button,._scroller_kqkmq_3::-webkit-scrollbar-corner{display:none;pointer-events:none}@media(forced-colors:active){._scroller_kqkmq_3{scrollbar-width:auto}}._navBtn_1fciy_2{-webkit-appearance:none;-moz-appearance:none;appearance:none;display:flex;flex-direction:column;align-items:center;justify-content:center;width:44px;height:44px;border:none;border-radius:8px;background:none;flex-shrink:0;color:#222;font-size:12px;font-weight:600;cursor:pointer;transition:all .15s ease}._navBtn_1fciy_2:hover:not(:disabled){background:#0000000f}._navBtn_1fciy_2:active:not(:disabled){background:#0000001a}._navBtn_1fciy_2:disabled,._navBtn_1fciy_2._disabled_1fciy_26{opacity:.4;cursor:not-allowed;transform:none}._label_1fciy_32{margin-top:2px;font-size:.55rem;font-weight:500;text-align:center}._navGroup_1fciy_40{display:flex;gap:8px}._wrap_1hfub_4{position:absolute;left:0;right:0;bottom:0;height:auto;display:flex;flex-direction:column;padding:8px 8px 10px;box-sizing:border-box;background:#fff;color:#333;border-top:1px solid #ddd;transition:opacity .15s ease;opacity:0;pointer-events:none;container-type:inline-size;container-name:bottombar}._visible_1hfub_25{opacity:1;pointer-events:auto}._compact_1hfub_31{padding:6px 8px 8px}._compact_1hfub_31 ._row2_1hfub_34{display:none}@container bottombar (min-width: 600px){._compact_1hfub_31 ._row2_1hfub_34{display:contents}}._controls_1hfub_44{display:flex;flex-wrap:wrap;align-items:center;gap:4px}._row1_1hfub_52,._row2_1hfub_34{display:flex;align-items:center;justify-content:space-between;width:100%;gap:4px}._row2_1hfub_34{margin-top:4px}@container bottombar (min-width: 500px){._row1_1hfub_52,._row2_1hfub_34{display:contents}._controls_1hfub_44{flex-wrap:nowrap;justify-content:space-between}._row2_1hfub_34{margin-top:0}}._groupExpand_1hfub_80,._groupPlayback_1hfub_81,._groupSpeed_1hfub_82,._groupFeatures_1hfub_83,._groupNav_1hfub_84{display:flex;align-items:center;flex-shrink:0}._groupExpand_1hfub_80{gap:0}._groupPlayback_1hfub_81{gap:2px}._groupSpeed_1hfub_82{gap:0}._groupFeatures_1hfub_83,._groupNav_1hfub_84{gap:2px}._btn_1hfub_116{-webkit-appearance:none;-moz-appearance:none;appearance:none;display:flex;flex-direction:column;align-items:center;justify-content:center;width:44px;height:44px;border:none;border-radius:8px;background:none;color:#222;font-size:12px;font-weight:600;cursor:pointer;transition:all .15s ease;flex-shrink:0}._btn_1hfub_116:hover{background:#0000000f}._btn_1hfub_116:active{background:#0000001f}._btnForbidden_1hfub_141{opacity:.4;cursor:not-allowed;background:#f2f2f2!important}._btnActive_1hfub_147{background:#333;color:#fff}._btnActive_1hfub_147:hover{background:#555}._btnActive_1hfub_147:active{background:#666}._label_1hfub_158{margin-top:2px;font-size:.55rem;font-weight:500;text-align:center;font-variant-numeric:tabular-nums;white-space:nowrap}._compactBtn_1hfub_168{display:flex;align-items:center;justify-content:center;width:34px;height:34px;border:none;border-radius:4px;background:none;color:#000;cursor:pointer;padding:2px;flex-shrink:0}._compactBtn_1hfub_168:hover{background:#0000000f}._compactBtn_1hfub_168:active{background:#0000001f}._scrubberWrap_uw0cd_2{display:grid;gap:8px;-webkit-user-select:none;user-select:none;margin-bottom:6px}._labels_uw0cd_9{display:flex;justify-content:space-between;font-size:12px;color:var(--text-subtle, #666)}._labels_uw0cd_9 ._index_uw0cd_15{font-variant-numeric:tabular-nums}._controls_uw0cd_19{display:grid;grid-template-columns:1fr 40px;align-items:center;gap:8px}._controls_uw0cd_19 ._percent_uw0cd_25{display:flex;justify-content:flex-end;font-size:.8rem;font-variant-numeric:tabular-nums}._stepBtn_uw0cd_32{height:28px;border:1px solid var(--line, #ddd);background:var(--bg, #fff);border-radius:8px;font-size:16px;line-height:1;cursor:pointer}._stepBtn_uw0cd_32:disabled{opacity:.5;cursor:not-allowed}._range_uw0cd_46{width:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;height:6px;border-radius:999px;background:linear-gradient(to right,currentColor var(--pct, 50%),#e5e7eb 0);outline:none}._range_uw0cd_46::-webkit-slider-thumb{-webkit-appearance:none;width:16px;height:16px;border-radius:999px;background:currentColor;cursor:pointer}._range_uw0cd_46::-moz-range-thumb{width:16px;height:16px;border-radius:999px;background:currentColor;border:none;cursor:pointer}._WPMSpeedButtonsWrap_r3byt_1{float:right;box-sizing:border-box;display:flex;flex-direction:column}._WPMSpeedButtonsWrap_r3byt_1 ._btnWrap_r3byt_7{box-sizing:border-box;padding:2px;display:flex;gap:1px;align-items:center}._WPMSpeedButtonsWrap_r3byt_1 ._btnWrap_r3byt_7 ._label_r3byt_14{font-size:.55rem;display:flex;flex-direction:column;justify-content:center;align-items:center;min-width:24px}._WPMSpeedButtonsWrap_r3byt_1 ._btnWrap_r3byt_7 ._iconBtn_r3byt_22{padding:2px;border-radius:4px;border:1px solid #888;background:none;width:34px;height:34px;flex-shrink:0;cursor:pointer;transition:all .15s ease}._WPMSpeedButtonsWrap_r3byt_1 ._btnWrap_r3byt_7 ._iconBtn_r3byt_22:hover{background:#0000000f}._WPMSpeedButtonsWrap_r3byt_1 ._btnWrap_r3byt_7 ._iconBtn_r3byt_22:active{background:#0000001f}._WPMSpeedButtonsWrap_r3byt_1 ._btnWrap_r3byt_7 ._iconBtn_r3byt_22 img{width:100%;height:100%;object-fit:contain}._StepBtn_15t0r_1{background:none;border:none;border-radius:8px;font-size:1.6rem;display:flex;justify-content:center;align-items:center;color:#000;flex-shrink:0;width:34px;height:34px;cursor:pointer;transition:all .15s ease}._StepBtn_15t0r_1:hover{background:#0000000f}._StepBtn_15t0r_1:active{background:#0000001f}._GCPlayBtn_n54mc_1{width:var(--btn-size);height:var(--btn-size);box-sizing:border-box;border:none;outline:none;position:relative;background:none;border-radius:8px;transition:all .15s ease;cursor:pointer}._GCPlayBtn_n54mc_1:hover{background:#0000000f}._GCPlayBtn_n54mc_1:active{background:#0000001f}._GCPlayBtn_n54mc_1:focus{outline:none}._GCPlayBtn_n54mc_1:before{content:"";position:absolute;top:calc(var(--btn-size) * .3);left:calc(var(--btn-size) * .34);height:0;border-style:solid;border-width:calc(var(--btn-size) * .2) 0 calc(var(--btn-size) * .2) calc(var(--btn-size) * .4);border-color:transparent transparent transparent var(--icon-color);transition:.2s ease;transform:scale(1.3)}._GCPlayBtn_n54mc_1._playing_n54mc_34:before{top:calc(var(--btn-size) * .3);left:calc(var(--btn-size) * .32);width:calc(var(--btn-size) * .12);height:calc(var(--btn-size) * .4);border:none;background-color:var(--icon-color);box-shadow:calc(var(--btn-size) * .18) 0 0 0 var(--icon-color)}._host_gafql_3{position:absolute;left:0;right:0;top:0;z-index:30}._topbar_gafql_11{position:absolute;left:0;right:0;top:0;height:48px;display:flex;align-items:center;gap:8px;padding:0 12px;background:#fff;color:#033233;-webkit-backdrop-filter:saturate(120%) blur(6px);backdrop-filter:saturate(120%) blur(6px);transition:opacity .15s ease;opacity:0;pointer-events:none;border-bottom:4px solid #033233;box-sizing:border-box}._visible_gafql_32{opacity:1;pointer-events:auto}._backBtn_gafql_37{display:flex;align-items:center;justify-content:center;width:44px;height:44px;border:none;background:transparent;color:#033233;cursor:pointer;border-radius:50%;flex-shrink:0;transition:background .15s ease}._backBtn_gafql_37:hover{background:#0000000d}._backBtn_gafql_37:active{background:#0000004d}._title_gafql_58{font-size:18px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}._calibrationBtn_gafql_67{display:flex;align-items:center;justify-content:center;width:44px;height:44px;border:none;background:transparent;color:#033233;cursor:pointer;border-radius:50%;flex-shrink:0;transition:background .15s ease}._calibrationBtn_gafql_67:hover{background:#0000000d}._calibrationBtn_gafql_67:active{background:#0000004d}._calibrationBtn_gafql_67._disabled_gafql_87{opacity:.4;cursor:not-allowed}._calibrationBtn_gafql_67._disabled_gafql_87:hover,._calibrationBtn_gafql_67._disabled_gafql_87:active{background:transparent}._settingsBtn_gafql_95{display:flex;align-items:center;justify-content:center;width:44px;height:44px;border:none;background:transparent;color:#033233;cursor:pointer;border-radius:50%;flex-shrink:0;transition:background .15s ease}._settingsBtn_gafql_95:hover{background:#0000000d}._settingsBtn_gafql_95:active{background:#0000004d}._wrap_62su0_7{position:absolute;pointer-events:auto;background:#fff;color:#111;box-shadow:0 -6px 24px #0000001f;padding:20px 0;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;gap:10px;overflow-y:auto;left:0;right:0;bottom:0;max-height:70%;border-top:1px solid rgba(0,0,0,.08);border-radius:16px 16px 0 0}._wrapHidden_62su0_29{transform:translateY(100%);visibility:hidden;transition:transform .22s ease,visibility 0s .22s}._wrapVisible_62su0_35{transform:translateY(0);visibility:visible;transition:transform .22s ease,visibility 0s 0s}@container viewer (min-aspect-ratio: 1/1){._wrap_62su0_7{left:auto;right:0;top:0;bottom:0;max-height:100%;width:400px;max-width:60%;border-top:none;border-left:1px solid rgba(0,0,0,.08);border-radius:0;box-shadow:-6px 0 24px #0000001f;padding:20px}._wrapHidden_62su0_29{transform:translate(100%);visibility:hidden;transition:transform .22s ease,visibility 0s .22s}._wrapVisible_62su0_35{transform:translate(0);visibility:visible;transition:transform .22s ease,visibility 0s 0s}}._scrollArea_62su0_71{width:100%;display:flex;flex-direction:column;max-width:400px;padding:0 20px;gap:10px;box-sizing:border-box}._row_62su0_81{display:flex;align-items:center;justify-content:space-between;gap:20px;min-height:45px}._label_62su0_89{width:78px;flex:0 0 78px;font-weight:700}._btn_62su0_95{-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;border:1px solid rgba(0,0,0,.16);background:#fff;color:#111;border-radius:8px;padding:8px 10px;font-size:13px}._btnActive_62su0_106{background:#00000014}._btnSmall_62su0_110{-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;border:1px solid rgba(0,0,0,.16);background:#fff;color:#111;border-radius:8px;padding:4px 8px;font-size:14px;line-height:1}._pill_62su0_122{-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;background:#fff;color:#111;border:1px solid rgba(0,0,0,.16);border-radius:999px;padding:8px 12px;font-size:13px}._themeCircle_62su0_133{width:40px;height:40px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-weight:600;cursor:pointer;transition:all .2s ease;border:1px solid rgba(0,0,0,.15)}._themeCircleActive_62su0_146{border:2px solid #007aff;box-shadow:0 0 0 2px #007aff40}._stepRow_62su0_151{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:40px}._stepLabel_62su0_159{width:78px;flex:0 0 78px;font-weight:700}._stepValue_62su0_165{margin-left:auto;width:72px;text-align:right;font-variant-numeric:tabular-nums}._levelBox_62su0_172{width:28px;text-align:center}._inlineFlex_62su0_177{display:flex;align-items:center;gap:6px;flex-wrap:wrap}._wrapper_dbk3n_1{display:grid;place-items:center;position:absolute;top:0;right:0;bottom:0;left:0;z-index:10000;pointer-events:none}._spinner_dbk3n_10{border-radius:50%;border:3px solid #e5e7eb;border-top-color:#3b82f6;animation:_spin_dbk3n_10 linear infinite}@keyframes _spin_dbk3n_10{to{transform:rotate(360deg)}}._Overlay_ybic8_3{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;background:#11182773;display:flex;align-items:center;justify-content:center;z-index:50}._Dialog_ybic8_15{width:min(760px,90%);max-height:80vh;overflow:auto;background:#fff;border-radius:16px;box-shadow:0 24px 48px #00000040;padding:20px}._Body_ybic8_25{margin-left:20px;margin-right:20px;display:block}._Header_ybic8_32{display:flex;align-items:center;gap:12px;margin-bottom:12px}._Paging_ybic8_39{font-weight:700;font-size:1rem;color:#333;display:flex;justify-content:center;width:100%}._Remaining_ybic8_48{margin-left:auto;font-weight:700;font-size:1rem;color:#fff}._RemainingDanger_ybic8_55{color:#dc2626}._NextBtn_ybic8_59{padding:10px 16px;border-radius:10px;border:none;background:#2563eb;color:#fff;font-size:1.2rem;font-weight:700;cursor:pointer;width:100%}@keyframes _nextbtn-blink_ybic8_1{0%,49%{transform:none;box-shadow:0 0 #dc262600;outline:0 solid rgba(220,38,38,0);filter:none}50%,to{box-shadow:0 0 0 2px #dc262659,0 6px 14px #dc262640;outline:2px solid rgba(220,38,38,.45)}}._NextBtn_ybic8_59:has(._RemainingDanger_ybic8_55){animation:_nextbtn-blink_ybic8_1 1s steps(2,start) infinite}._NextBtn_ybic8_59:has(._RemainingDanger_ybic8_55):hover,._NextBtn_ybic8_59:has(._RemainingDanger_ybic8_55):focus-visible{animation-play-state:running}._CloseBtn_ybic8_96{margin-left:8px;border:none;background:transparent;color:#6b7280;cursor:pointer;font-size:14px}._Title_ybic8_106{font-weight:700;font-size:18px;margin-bottom:8px;color:#111827}._Question_ybic8_113{font-size:1.2rem;color:#111827;font-weight:700;display:flex;justify-content:center;align-items:center}._Score_ybic8_123{display:flex;justify-content:center;align-items:center;margin-bottom:16px}._Image_ybic8_130{width:100%;display:flex;justify-content:center}._Image_ybic8_130 img{width:80%}._Options_ybic8_140{display:grid;gap:8px}._OptionBtn_ybic8_145{text-align:left;padding:12px 14px;border-radius:10px;border:1px solid #e5e7eb;background:#fff;color:#111827;cursor:pointer;font-size:1rem;transition:box-shadow .15s ease,border-color .15s ease,background .15s ease;display:flex;justify-content:center;align-items:center}._OptionBtn_ybic8_145:hover{border-color:#cbd5e1;background:#f9fafb}._OptionBtnActive_ybic8_165{border-color:#2563eb;background:#2563eb14;box-shadow:0 4px 10px #2563eb33}._Footer_ybic8_172{display:flex;justify-content:space-between;margin-top:16px;gap:8px}._PrevBtn_ybic8_179{flex:0 0 auto;padding:10px 14px;border-radius:10px;border:1px solid #e5e7eb;background:#fff;color:#111827;cursor:pointer}._PrevBtn_ybic8_179:disabled{cursor:not-allowed;opacity:.6}._OptionBtnCorrect_ybic8_195{border-color:#16a34a!important;box-shadow:0 4px 10px #16a34a33}._Judge_ybic8_201{margin:6px 0 10px;font-weight:700;font-size:1.5rem;padding:4px;width:100%;border-radius:10px;display:flex;justify-content:center;color:#fff}._Judge_ybic8_201._Correct_ybic8_212{background:#16a34a}._Judge_ybic8_201._Incorrect_ybic8_215{background:#dc2626}._ResultHeader_ybic8_220{font-weight:800;font-size:20px;margin-bottom:8px;color:#111827}._ResultText_ybic8_227{font-size:16px;margin-bottom:12px;color:#111827}._ResultActions_ybic8_233{display:flex;justify-content:flex-end;gap:8px}._CloseBtnSoft_ybic8_239{padding:10px 16px;border-radius:10px;border:1px solid #e5e7eb;background:#fff;color:#111827;cursor:pointer}._SummaryGrid_ybic8_249{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:12px;margin:12px 0 16px}._StatCard_ybic8_257{border:1px solid #e5e7eb;border-radius:12px;padding:12px 14px;background:#fff;box-shadow:0 2px 6px #1118270f}._StatLabel_ybic8_265{font-size:12px;color:#6b7280}._StatValue_ybic8_270{font-size:22px;font-weight:800;margin-top:4px;color:#111827}._StatSub_ybic8_277{font-size:12px;color:#6b7280}._SplitGrid_ybic8_282{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:8px 0 12px}._SplitBox_ybic8_289{border:1px dashed #e5e7eb;border-radius:10px;padding:10px 12px}._SplitTitle_ybic8_295{font-size:12px;color:#6b7280}._SplitText_ybic8_300{font-size:16px;font-weight:700;color:#111827;margin-top:2px}._Pairs_ybic8_307{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:8px 0 12px}._PairItem_ybic8_314{border:1px solid #f3f4f6;border-radius:10px;padding:10px 12px;background:#fafafa}._PairLabel_ybic8_321{font-size:12px;color:#6b7280}._PairValue_ybic8_326{font-size:15px;font-weight:700;margin-top:2px;color:#111827}._WrongBox_ybic8_333{margin-top:8px;border-top:1px solid #e5e7eb;padding-top:10px}._WrongTitle_ybic8_339{font-weight:700;font-size:14px;color:#111827;margin-bottom:6px}._WrongList_ybic8_346{list-style:none;padding:0;margin:0}._WrongList_ybic8_346 li{display:flex;align-items:center;gap:8px;padding:6px 0;border-bottom:1px dashed #f3f4f6}._Badge_ybic8_360{display:inline-block;font-size:12px;padding:2px 6px;border-radius:999px;background:#eef2ff;color:#3730a3;font-weight:700}._WrongName_ybic8_370{flex:1;color:#111827;font-size:14px}._WrongTime_ybic8_376{font-size:12px;color:#6b7280}._Empty_ybic8_381{color:#6b7280;font-size:13px}._Hint_ybic8_387{margin-top:8px;font-size:12px;color:#6b7280}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- "use strict";var As=Object.defineProperty;var Bs=(e,t,n)=>t in e?As(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var kr=(e,t,n)=>Bs(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react/jsx-runtime"),h=require("react"),Ls=require("react-dom");function Gs(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const $e=Gs(h),ar=h.createContext(void 0);var Yt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ao(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qt={exports:{}},yn={},Zt={exports:{}},wn={};/**
2
+ "use strict";var As=Object.defineProperty;var Bs=(e,t,n)=>t in e?As(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var kr=(e,t,n)=>Bs(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),g=require("react"),Ls=require("react-dom");function Gs(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const $e=Gs(g),ar=g.createContext(void 0);var Qt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ao(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Yt={exports:{}},yn={},Zt={exports:{}},wn={};/**
3
3
  * @license React
4
4
  * use-sync-external-store-shim.production.js
5
5
  *
@@ -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 Rr;function Hs(){if(Rr)return wn;Rr=1;var e=h;function t(m,f){return m===f&&(m!==0||1/m===1/f)||m!==m&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,i=e.useDebugValue;function u(m,f){var b=f(),S=r({inst:{value:b,getSnapshot:f}}),w=S[0].inst,c=S[1];return s(function(){w.value=b,w.getSnapshot=f,a(w)&&c({inst:w})},[m,b,f]),o(function(){return a(w)&&c({inst:w}),m(function(){a(w)&&c({inst:w})})},[m]),i(b),b}function a(m){var f=m.getSnapshot;m=m.value;try{var b=f();return!n(m,b)}catch{return!0}}function l(m,f){return f()}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={};/**
10
+ */var Rr;function Hs(){if(Rr)return wn;Rr=1;var e=g;function t(b,f){return b===f&&(b!==0||1/b===1/f)||b!==b&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,i=e.useDebugValue;function u(b,f){var m=f(),S=r({inst:{value:m,getSnapshot:f}}),w=S[0].inst,c=S[1];return s(function(){w.value=m,w.getSnapshot=f,a(w)&&c({inst:w})},[b,m,f]),o(function(){return a(w)&&c({inst:w}),b(function(){a(w)&&c({inst:w})})},[b]),i(m),m}function a(b){var f=b.getSnapshot;b=b.value;try{var m=f();return!n(b,m)}catch{return!0}}function l(b,f){return f()}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 _r;function Ns(){return _r||(_r=1,process.env.NODE_ENV!=="production"&&(function(){function e(b,S){return b===S&&(b!==0||1/b===1/S)||b!==b&&S!==S}function t(b,S){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=S();if(!m){var c=S();s(w,c)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),m=!0)}c=i({inst:{value:w,getSnapshot:S}});var p=c[0].inst,g=c[1];return a(function(){p.value=w,p.getSnapshot=S,n(p)&&g({inst:p})},[b,w,S]),u(function(){return n(p)&&g({inst:p}),b(function(){n(p)&&g({inst:p})})},[b]),l(w),w}function n(b){var S=b.getSnapshot;b=b.value;try{var w=S();return!s(b,w)}catch{return!0}}function r(b,S){return S()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=h,s=typeof Object.is=="function"?Object.is:e,i=o.useState,u=o.useEffect,a=o.useLayoutEffect,l=o.useDebugValue,d=!1,m=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:t;Cn.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Cn}var Mr;function Bo(){return Mr||(Mr=1,process.env.NODE_ENV==="production"?Zt.exports=Hs():Zt.exports=Ns()),Zt.exports}/**
18
+ */var _r;function Ns(){return _r||(_r=1,process.env.NODE_ENV!=="production"&&(function(){function e(m,S){return m===S&&(m!==0||1/m===1/S)||m!==m&&S!==S}function t(m,S){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=S();if(!b){var c=S();s(w,c)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),b=!0)}c=i({inst:{value:w,getSnapshot:S}});var p=c[0].inst,h=c[1];return a(function(){p.value=w,p.getSnapshot=S,n(p)&&h({inst:p})},[m,w,S]),u(function(){return n(p)&&h({inst:p}),m(function(){n(p)&&h({inst:p})})},[m]),l(w),w}function n(m){var S=m.getSnapshot;m=m.value;try{var w=S();return!s(m,w)}catch{return!0}}function r(m,S){return S()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=g,s=typeof Object.is=="function"?Object.is:e,i=o.useState,u=o.useEffect,a=o.useLayoutEffect,l=o.useDebugValue,d=!1,b=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:t;Cn.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Cn}var Mr;function Bo(){return Mr||(Mr=1,process.env.NODE_ENV==="production"?Zt.exports=Hs():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 Er;function Fs(){if(Er)return yn;Er=1;var e=h,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,m,f,b){var S=s(null);if(S.current===null){var w={hasValue:!1,value:null};S.current=w}else w=S.current;S=u(function(){function p(E){if(!g){if(g=!0,C=E,E=f(E),b!==void 0&&w.hasValue){var x=w.value;if(b(x,E))return k=x}return k=E}if(x=k,r(C,E))return x;var y=f(E);return b!==void 0&&b(x,y)?(C=E,x):(C=E,k=y)}var g=!1,C,k,R=m===void 0?null:m;return[function(){return p(d())},R===null?void 0:function(){return p(R())}]},[d,m,f,b]);var c=o(l,S[0],S[1]);return i(function(){w.hasValue=!0,w.value=c},[c]),a(c),c},yn}var In={};/**
26
+ */var Er;function Fs(){if(Er)return yn;Er=1;var e=g,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,b,f,m){var S=s(null);if(S.current===null){var w={hasValue:!1,value:null};S.current=w}else w=S.current;S=u(function(){function p(O){if(!h){if(h=!0,C=O,O=f(O),m!==void 0&&w.hasValue){var v=w.value;if(m(v,O))return T=v}return T=O}if(v=T,r(C,O))return v;var y=f(O);return m!==void 0&&m(v,y)?(C=O,v):(C=O,T=y)}var h=!1,C,T,_=b===void 0?null:b;return[function(){return p(d())},_===null?void 0:function(){return p(_())}]},[d,b,f,m]);var c=o(l,S[0],S[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 jr;function Ds(){return jr||(jr=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=h,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,m,f,b){var S=s(null);if(S.current===null){var w={hasValue:!1,value:null};S.current=w}else w=S.current;S=u(function(){function p(E){if(!g){if(g=!0,C=E,E=f(E),b!==void 0&&w.hasValue){var x=w.value;if(b(x,E))return k=x}return k=E}if(x=k,r(C,E))return x;var y=f(E);return b!==void 0&&b(x,y)?(C=E,x):(C=E,k=y)}var g=!1,C,k,R=m===void 0?null:m;return[function(){return p(d())},R===null?void 0:function(){return p(R())}]},[d,m,f,b]);var c=o(l,S[0],S[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 Or;function Ws(){return Or||(Or=1,process.env.NODE_ENV==="production"?Qt.exports=Fs():Qt.exports=Ds()),Qt.exports}var $s=Ws();const Vs=Ao($s),zr=e=>{let t;const n=new Set,r=(l,d)=>{const m=typeof l=="function"?l(t):l;if(!Object.is(m,t)){const f=t;t=d??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(b=>b(t,f))}},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},qt=(e=>e?zr(e):zr),{useSyncExternalStoreWithSelector:qs}=Vs,Us=e=>e;function gn(e,t=Us,n){const r=qs(e.subscribe,e.getState,e.getInitialState,t,n);return h.useDebugValue(r),r}function X(e,t){const n=h.useContext(ar);if(!n)throw new Error("useCRViewerScopedStore must be used inside <InternalCRViewerProvider>");return gn(n,e,t)}function hn(){const e=h.useContext(ar);if(!e)throw new Error("useCRViewerStoreApi must be used inside <InternalCRViewerProvider>");return e}const wt=h.createContext(void 0),Lo=h.createContext(void 0);function Ks(){return qt((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 Xs({children:e,onViewerEvent:t,isPlaybackMode:n=!1,playbackScale:r=1,viewerRef:o}){const s=h.useMemo(()=>Ks(),[]);return h.useLayoutEffect(()=>(s.getState().setEmitCallback(t??null),()=>s.getState().setEmitCallback(null)),[t,s]),h.useLayoutEffect(()=>{s.getState().setPlaybackMode(n)},[n,s]),h.useLayoutEffect(()=>{s.getState().setPlaybackScale(r)},[r,s]),h.useLayoutEffect(()=>()=>{o&&(o.current=null)},[o]),v.jsx(wt.Provider,{value:s,children:v.jsx(Lo.Provider,{value:o,children:e})})}function ht(){const e=h.useContext(wt);if(!e)throw new Error("useViewerEventBridgeStoreApi must be used inside <ViewerEventBridgeProvider>");return e}const cr=h.createContext(void 0);function pt(){const e=h.useContext(cr);if(!e)throw new Error("useProgressStoreApi must be used within InternalCRViewerProgressProvider");return e}function q(e,t){const n=h.useContext(cr);if(!n)throw new Error("useProgressStore must be used within InternalCRViewerProgressProvider");return gn(n,o=>e(o.progress),t)}function Ys({onSingle:e,onDouble:t,delay:n=250,shouldIgnoreTarget:r}){const o=h.useRef(null);h.useEffect(()=>()=>{o.current!=null&&(clearTimeout(o.current),o.current=null)},[]);const s=h.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=h.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],Jn=e=>Math.round(12+(e-1)*(16/11)),Qs=e=>{let t=1,n=1/0;for(let r=1;r<=12;r++){const o=Jn(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},Go=[{label:"고딕체",value:"'Noto Sans KR', sans-serif"},{label:"명조체",value:"'Noto Serif KR', serif"},{label:"바탕체",value:"'Nanum Myeongjo', serif"}],He={mode:"page",theme:"light",fontFamily:Go.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 Zs(e){const{init:t,recorderStore:n}=e??{};return qt((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:Jn},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:()=>Qs(o().fontSizePx),getLineLevel:()=>_n(o().lineHeight,kn),getMarginLevel:()=>_n(o().marginX,Tn),setFontLevel:s=>r({fontSizePx:Jn(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 mn=0,mt=1,jt=2,Ho=4;function Pr(e){return()=>e}function Js(e){e()}function No(e,t){return n=>e(t(n))}function Ar(e,t){return()=>e(t)}function ei(e,t){return n=>e(t,n)}function ur(e){return e!==void 0}function ti(...e){return()=>{e.map(Js)}}function Ot(){}function bn(e,t){return t(e),e}function ni(e,t){return t(e)}function Te(...e){return e}function xe(e,t){return e(mt,t)}function ce(e,t){e(mn,t)}function dr(e){e(jt)}function _e(e){return e(Ho)}function ne(e,t){return xe(e,ei(t,mn))}function nt(e,t){const n=e(mt,r=>{n(),t(r)});return n}function Br(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Fo(e,t){return e===t}function Ie(e=Fo){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function se(e){return t=>n=>{e(n)&&t(n)}}function Q(e){return t=>No(t,e)}function it(e){return t=>()=>{t(e)}}function H(e,...t){const n=ri(...t);return((r,o)=>{switch(r){case jt:dr(e);return;case mt:return xe(e,n(o))}})}function lt(e,t){return n=>r=>{n(t=e(t,r))}}function yt(e){return t=>n=>{e>0?e--:t(n)}}function ct(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function de(...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);xe(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 ri(...e){return t=>e.reduceRight(ni,t)}function oi(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case mt:return s?n===s?void 0:(r(),n=s,t=xe(e,s),t):(r(),Ot);case jt:r(),n=null;return}}}function D(e){let t=e;const n=pe();return((r,o)=>{switch(r){case mn:t=o;break;case mt:{o(t);break}case Ho:return t}return n(r,o)})}function Fe(e,t){return bn(D(t),n=>ne(e,n))}function pe(){const e=[];return((t,n)=>{switch(t){case mn:e.slice().forEach(r=>{r(n)});return;case jt:e.splice(0,e.length);return;case mt:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}})}function Xe(e){return bn(pe(),t=>ne(e,t))}function he(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:si(),singleton:n}}const si=()=>Symbol();function ii(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=pe(),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);xe(s,a=>{n[i]=a,r=r|u,r===o&&ce(t,n)})}),function(s,i){switch(s){case jt:{dr(t);return}case mt:return r===o&&i(n),xe(t,i)}}}function oe(e,t=Fo){return H(e,Ie(t))}function er(...e){return function(t,n){switch(t){case jt:return;case mt:return ti(...e.map(r=>xe(r,n)))}}}var Ve=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ve||{});const li={0:"debug",3:"error",1:"log",2:"warn"},ai=()=>typeof globalThis>"u"?window:globalThis,bt=he(()=>{const e=D(3);return{log:D((t,n,r=1)=>{var o;const s=(o=ai().VIRTUOSO_LOG_LEVEL)!=null?o:_e(e);r>=s&&console[li[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 fr(e,t,n).callbackRef}function fr(e,t,n){const r=h.useRef(null);let o=i=>{};const s=h.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 ci(e,t,n,r,o,s,i,u,a){const l=h.useCallback(d=>{const m=ui(d.children,t,u?"offsetWidth":"offsetHeight",o);let f=d.parentElement;for(;!f.dataset.virtuosoScroller;)f=f.parentElement;const b=f.lastElementChild.dataset.viewportType==="window";let S;b&&(S=f.ownerDocument.defaultView);const w=i?u?i.scrollLeft:i.scrollTop:b?u?S.scrollX||S.document.documentElement.scrollLeft:S.scrollY||S.document.documentElement.scrollTop:u?f.scrollLeft:f.scrollTop,c=i?u?i.scrollWidth:i.scrollHeight:b?u?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight:u?f.scrollWidth:f.scrollHeight,p=i?u?i.offsetWidth:i.offsetHeight:b?u?S.innerWidth:S.innerHeight:u?f.offsetWidth:f.offsetHeight;r({scrollHeight:c,scrollTop:Math.max(w,0),viewportHeight:p}),s==null||s(u?Lr("column-gap",getComputedStyle(d).columnGap,o):Lr("row-gap",getComputedStyle(d).rowGap,o)),m!==null&&e(m)},[e,t,o,s,i,r,u]);return fr(l,n,a)}function ui(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},Ve.ERROR),d===l)continue;const m=s[s.length-1];s.length===0||m.size!==d||m.endIndex!==a-1?s.push({endIndex:a,size:d,startIndex:a}):s[s.length-1].endIndex++}return s}function Lr(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ve.WARN),t==="normal"?0:parseInt(t??"0",10)}function Do(e,t,n){const r=h.useRef(null),o=h.useCallback(a=>{if(!(a!=null&&a.offsetParent))return;const l=a.getBoundingClientRect(),d=l.width;let m,f;if(t){const b=t.getBoundingClientRect(),S=l.top-b.top;f=b.height-Math.max(0,S),m=S+t.scrollTop}else{const b=i.current.ownerDocument.defaultView;f=b.innerHeight-Math.max(0,l.top),m=l.top+b.scrollY}r.current={offsetTop:m,visibleHeight:f,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=fr(o,!0,n),u=h.useCallback(()=>{o(i.current)},[o,i]);return h.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=he(()=>{const e=pe(),t=pe(),n=D(0),r=pe(),o=D(0),s=pe(),i=pe(),u=D(0),a=D(0),l=D(0),d=D(0),m=pe(),f=pe(),b=D(!1),S=D(!1),w=D(!1);return ne(H(e,Q(({scrollTop:c})=>c)),t),ne(H(e,Q(({scrollHeight:c})=>c)),i),ne(t,o),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:a,footerHeight:d,headerHeight:u,horizontalDirection:S,scrollBy:f,scrollContainerState:e,scrollHeight:i,scrollingInProgress:b,scrollTo:m,scrollTop:t,skipAnimationFrameInResizeObserver:w,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Gt={lvl:0};function Wo(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 Se(e){return e===Gt}function Ht(e,t){if(!Se(e))return t===e.k?e.v:t<e.k?Ht(e.l,t):Ht(e.r,t)}function rt(e,t,n="k"){if(Se(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=rt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return rt(e.l,t,n)}function Ke(e,t,n){return Se(e)?qo(t,n,1):t===e.k?Le(e,{k:t,v:n}):t<e.k?Gr(Le(e,{l:Ke(e.l,t,n)})):Gr(Le(e,{r:Ke(e.r,t,n)}))}function _t(){return Gt}function Mt(e,t,n){if(Se(e))return[];const r=rt(e,t)[0];return di(nr(e,r,n))}function tr(e,t){if(Se(e))return Gt;const{k:n,l:r,r:o}=e;if(t===n){if(Se(r))return o;if(Se(o))return r;{const[s,i]=Vo(r);return rn(Le(e,{k:s,l:$o(r),v:i}))}}else return t<n?rn(Le(e,{l:tr(r,t)})):rn(Le(e,{r:tr(o,t)}))}function St(e){return Se(e)?[]:[...St(e.l),{k:e.k,v:e.v},...St(e.r)]}function nr(e,t,n){if(Se(e))return[];const{k:r,l:o,r:s,v:i}=e;let u=[];return r>t&&(u=u.concat(nr(o,t,n))),r>=t&&r<=n&&u.push({k:r,v:i}),r<=n&&(u=u.concat(nr(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 Uo(Le(e,{lvl:n-1}));if(!Se(t)&&!Se(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 rr(Le(e,{lvl:n-1}));if(!Se(r)&&!Se(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:rr(Le(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Le(e,t){return qo(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 $o(e){return Se(e.r)?e.l:rn(Le(e,{r:$o(e.r)}))}function Mn(e){return Se(e)||e.lvl>e.r.lvl}function Vo(e){return Se(e.r)?[e.k,e.v]:Vo(e.r)}function qo(e,t,n,r=Gt,o=Gt){return{k:e,l:r,lvl:n,r:o,v:t}}function Gr(e){return rr(Uo(e))}function Uo(e){const{l:t}=e;return!Se(t)&&t.lvl===e.lvl?Le(t,{r:Le(e,{l:t.r})}):e}function rr(e){const{lvl:t,r:n}=e;return!Se(n)&&!Se(n.r)&&n.lvl===t&&n.r.lvl===t?Le(n,{l:Le(e,{r:n.l}),lvl:t+1}):e}function di(e){return Wo(e,({k:t,v:n})=>({index:t,value:n}))}function Ko(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Nt(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const pr=he(()=>({recalcInProgress:D(!1)}),[],{singleton:!0});function Xo(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 fi(e,t,n,r){const o=ln(e,t,r),s=ln(e,n,r,o);return e.slice(o,s+1)}function gt(e,t){return Math.round(e.getBoundingClientRect()[t])}function xn(e){return!Se(e.groupOffsetTree)}function gr({index:e},t){return t===e?0:t<e?-1:1}function pi(){return{groupIndices:[],groupOffsetTree:_t(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:_t()}}function gi(e,t){let n=Se(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Se(e)){e=Ke(e,0,s);continue}const u=Mt(e,i-1,o+1);if(u.some(yi(r)))continue;let a=!1,l=!1;for(const{end:d,start:m,value:f}of u)a?(o>=m||s===f)&&(e=tr(e,m)):(l=f!==s,a=!0),d>o&&o>=m&&f!==s&&(e=Ke(e,o+1,f));l&&(e=Ke(e,i,s))}return[e,n]}function hi(e){return typeof e.groupIndex<"u"}function mi({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}=Xo(t,e,gr),i=e-r,u=s*i+(i-1)*n+o;return u>0?u+n:u}function Yo(e,t){if(!xn(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Qo(e,t,n){if(hi(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 bi(e,t,n,r=0){return r>0&&(t=Math.max(t,Xo(e,r,gr).offset)),Wo(fi(e,t,n,mi),Si)}function xi(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ve.DEBUG);const s=e.sizeTree;let i=s,u=0;if(n.length>0&&Se(s)&&t.length===2){const f=t[0].size,b=t[1].size;i=n.reduce((S,w)=>Ke(Ke(S,w,f),w+1,b),i)}else[i,u]=gi(i,t);if(i===s)return e;const{lastIndex:a,lastOffset:l,lastSize:d,offsetTree:m}=or(e.offsetTree,u,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((f,b)=>Ke(f,b,Ft(b,m,o)),_t()),lastIndex:a,lastOffset:l,lastSize:d,offsetTree:m,sizeTree:i}}function vi(e){return St(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 Hr(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 or(e,t,n,r){let o=e,s=0,i=0,u=0,a=0;if(t!==0){a=ln(o,t-1,gr),u=o[a].offset;const l=rt(n,t-1);s=l[0],i=l[1],o.length&&o[a].size===rt(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 m=l-s,f=m*i+u+m*r;o.push({index:l,offset:f,size:d}),s=l,u=f,i=d}return{lastIndex:s,lastOffset:u,lastSize:i,offsetTree:o}}function Si(e){return{index:e.index,value:e}}function yi(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 wi={offsetHeight:"height",offsetWidth:"width"},at=he(([{log:e},{recalcInProgress:t}])=>{const n=pe(),r=pe(),o=Fe(r,0),s=pe(),i=pe(),u=D(0),a=D([]),l=D(void 0),d=D(void 0),m=D(void 0),f=D(void 0),b=D((x,y)=>gt(x,wi[y])),S=D(void 0),w=D(0),c=pi(),p=Fe(H(n,de(a,e,w),lt(xi,c),Ie()),c),g=Fe(H(a,Ie(),lt((x,y)=>({current:y,prev:x.current}),{current:[],prev:[]}),Q(({prev:x})=>x)),[]);ne(H(a,se(x=>x.length>0),de(p,w),Q(([x,y,M])=>{const T=x.reduce((O,P,I)=>Ke(O,P,Ft(P,y.offsetTree,M)||I),_t());return{...y,groupIndices:x,groupOffsetTree:T}})),p),ne(H(r,de(p),se(([x,{lastIndex:y}])=>x<y),Q(([x,{lastIndex:y,lastSize:M}])=>[{endIndex:y,size:M,startIndex:x}])),n),ne(l,d);const C=Fe(H(l,Q(x=>x===void 0)),!0);ne(H(d,se(x=>x!==void 0&&Se(_e(p).sizeTree)),Q(x=>{const y=_e(m),M=_e(a).length>0;return y?M?[{endIndex:0,size:y,startIndex:0},{endIndex:1,size:x,startIndex:1}]:[]:[{endIndex:0,size:x,startIndex:0}]})),n),ne(H(f,se(x=>x!==void 0&&x.length>0&&Se(_e(p).sizeTree)),Q(x=>{const y=[];let M=x[0],T=0;for(let O=1;O<x.length;O++){const P=x[O];P!==M&&(y.push({endIndex:O-1,size:M,startIndex:T}),M=P,T=O)}return y.push({endIndex:x.length-1,size:M,startIndex:T}),y})),n),ne(H(a,de(m,d),se(([,x,y])=>x!==void 0&&y!==void 0),Q(([x,y,M])=>{const T=[];for(let O=0;O<x.length;O++){const P=x[O],I=x[O+1];T.push({startIndex:P,endIndex:P,size:y}),I!==void 0&&T.push({startIndex:P+1,endIndex:I-1,size:M})}return T})),n);const k=Xe(H(n,de(p),lt(({sizes:x},[y,M])=>({changed:M!==x,sizes:M}),{changed:!1,sizes:c}),Q(x=>x.changed)));xe(H(u,lt((x,y)=>({diff:x.prev-y,prev:y}),{diff:0,prev:0}),Q(x=>x.diff)),x=>{const{groupIndices:y}=_e(p);if(x>0)ce(t,!0),ce(s,x+Hr(x,y));else if(x<0){const M=_e(g);M.length>0&&(x-=Hr(-x,M)),ce(i,x)}}),xe(H(u,de(e)),([x,y])=>{x<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},Ve.ERROR)});const R=Xe(s);ne(H(s,de(p),Q(([x,y])=>{const M=y.groupIndices.length>0,T=[],O=y.lastSize;if(M){const P=Ht(y.sizeTree,0);let I=0,_=0;for(;I<x;){const N=y.groupIndices[_],A=y.groupIndices.length===_+1?1/0:y.groupIndices[_+1]-N-1;T.push({endIndex:N,size:P,startIndex:N}),T.push({endIndex:N+1+A-1,size:O,startIndex:N+1}),_++,I+=A+1}const z=St(y.sizeTree);return I!==x&&z.shift(),z.reduce((N,{k:A,v:$})=>{let te=N.ranges;return N.prevSize!==0&&(te=[...N.ranges,{endIndex:A+x-1,size:N.prevSize,startIndex:N.prevIndex}]),{prevIndex:A+x,prevSize:$,ranges:te}},{prevIndex:x,prevSize:0,ranges:T}).ranges}return St(y.sizeTree).reduce((P,{k:I,v:_})=>({prevIndex:I+x,prevSize:_,ranges:[...P.ranges,{endIndex:I+x-1,size:P.prevSize,startIndex:P.prevIndex}]}),{prevIndex:0,prevSize:O,ranges:[]}).ranges})),n);const E=Xe(H(i,de(p,w),Q(([x,{offsetTree:y},M])=>{const T=-x;return Ft(T,y,M)})));return ne(H(i,de(p,w),Q(([x,y,M])=>{if(y.groupIndices.length>0){if(Se(y.sizeTree))return y;let T=_t();const O=_e(g);let P=0,I=0,_=0;for(;P<-x;){_=O[I];const z=O[I+1]-_-1;I++,P+=z+1}if(T=St(y.sizeTree).reduce((z,{k:N,v:A})=>Ke(z,Math.max(0,N+x),A),T),P!==-x){const z=Ht(y.sizeTree,_);T=Ke(T,0,z);const N=rt(y.sizeTree,-x+1)[1];T=Ke(T,1,N)}return{...y,sizeTree:T,...or(y.offsetTree,0,T,M)}}else{const T=St(y.sizeTree).reduce((O,{k:P,v:I})=>Ke(O,Math.max(0,P+x),I),_t());return{...y,sizeTree:T,...or(y.offsetTree,0,T,M)}}})),p),{beforeUnshiftWith:R,data:S,defaultItemSize:d,firstItemIndex:u,fixedItemSize:l,fixedGroupSize:m,gap:w,groupIndices:a,heightEstimates:f,itemSize:b,listRefresh:k,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:p,statefulTotalCount:o,totalCount:r,trackItemSizes:C,unshiftWith:s}},Te(bt,pr),{singleton:!0});function Ci(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Zo=he(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=pe(),i=pe(),u=Xe(H(s,Q(Ci)));return ne(H(u,Q(a=>a.totalCount)),n),ne(H(u,Q(a=>a.groupIndices)),e),ne(H(Pe(o,t,r),se(([a,l])=>xn(l)),Q(([a,l,d])=>rt(l.groupOffsetTree,Math.max(a-d,0),"v")[0]),Ie(),Q(a=>[a])),i),{groupCounts:s,topItemsIndexes:i}},Te(at,De)),xt=he(([{log:e}])=>{const t=D(!1),n=Xe(H(t,se(r=>r),Ie()));return xe(t,r=>{r&&_e(e)("props updated",{},Ve.DEBUG)}),{didMount:n,propsReady:t}},Te(bt),{singleton:!0}),Ii=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Jo(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Ii)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Ut=he(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:u,scrollingInProgress:a,scrollTo:l,smoothScrollTargetReached:d,viewportHeight:m},{log:f}])=>{const b=pe(),S=pe(),w=D(0);let c=null,p=null,g=null;function C(){c&&(c(),c=null),g&&(g(),g=null),p&&(clearTimeout(p),p=null),ce(a,!1)}return ne(H(b,de(n,m,r,w,u,i,f),de(e,s,o),Q(([[k,R,E,x,y,M,T,O],P,I,_])=>{const z=Jo(k),{align:N,behavior:A,offset:$}=z,te=x-1,fe=Qo(z,R,te);let ge=Ft(fe,R.offsetTree,P)+M;N==="end"?(ge+=I+rt(R.sizeTree,fe)[1]-E+_,fe===te&&(ge+=T)):N==="center"?ge+=(I+rt(R.sizeTree,fe)[1]-E+_)/2:ge-=y,$&&(ge+=$);const ve=me=>{C(),me?(O("retrying to scroll to",{location:k},Ve.DEBUG),ce(b,k)):(ce(S,!0),O("list did not change, scroll successful",{},Ve.DEBUG))};if(C(),A==="smooth"){let me=!1;g=xe(t,Ae=>{me=me||Ae}),c=nt(d,()=>{ve(me)})}else c=nt(H(t,Ti(150)),ve);return p=setTimeout(()=>{C()},1200),ce(a,!0),O("scrolling from index to",{behavior:A,index:fe,top:ge},Ve.DEBUG),{behavior:A,top:ge}})),l),{scrollTargetReached:S,scrollToIndex:b,topListHeight:w}},Te(at,De,bt),{singleton:!0});function Ti(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function hr(e,t){e==0?t():requestAnimationFrame(()=>{hr(e-1,t)})}function mr(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Kt=he(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const u=D(!0),a=D(0),l=D(!0);return ne(H(i,de(a),se(([d,m])=>!!m),it(!1)),u),ne(H(i,de(a),se(([d,m])=>!!m),it(!1)),l),xe(H(Pe(t,i),de(u,n,e,l),se(([[,d],m,{sizeTree:f},b,S])=>d&&(!Se(f)||ur(b))&&!m&&!S),de(a)),([,d])=>{nt(o,()=>{ce(l,!0)}),hr(4,()=>{nt(r,()=>{ce(u,!0)}),ce(s,d)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:a,scrolledToInitialItem:u}},Te(at,De,Ut,xt),{singleton:!0});function es(e,t){return Math.abs(e-t)<1.01}const Dt="up",Bt="down",ki="none",Ri={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},_i=0,Xt=he(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=D(!1),u=D(!0),a=pe(),l=pe(),d=D(4),m=D(_i),f=Fe(H(er(H(oe(o),yt(1),it(!0)),H(oe(o),yt(1),it(!1),Br(100))),Ie()),!1),b=Fe(H(er(H(n,it(!0)),H(n,it(!1),Br(200))),Ie()),!1);ne(H(Pe(oe(o),oe(m)),Q(([g,C])=>g<=C),Ie()),u),ne(H(u,ct(50)),l);const S=Xe(H(Pe(r,oe(s),oe(t),oe(e),oe(d)),lt((g,[{scrollHeight:C,scrollTop:k},R,E,x,y])=>{const M=k+R-C>-y,T={scrollHeight:C,scrollTop:k,viewportHeight:R};if(M){let P,I;return k>g.state.scrollTop?(P="SCROLLED_DOWN",I=g.state.scrollTop-k):(P="SIZE_DECREASED",I=g.state.scrollTop-k||g.scrollTopDelta),{atBottom:!0,atBottomBecause:P,scrollTopDelta:I,state:T}}let O;return T.scrollHeight>g.state.scrollHeight?O="SIZE_INCREASED":R<g.state.viewportHeight?O="VIEWPORT_HEIGHT_DECREASING":k<g.state.scrollTop?O="SCROLLING_UPWARDS":O="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:O,state:T}},Ri),Ie((g,C)=>g&&g.atBottom===C.atBottom))),w=Fe(H(r,lt((g,{scrollHeight:C,scrollTop:k,viewportHeight:R})=>{if(es(g.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:k};{const E=C-(k+R)<1;return g.scrollTop!==k&&E?{changed:!0,jump:g.scrollTop-k,scrollHeight:C,scrollTop:k}:{changed:!0,jump:0,scrollHeight:C,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),se(g=>g.changed),Q(g=>g.jump)),0);ne(H(S,Q(g=>g.atBottom)),i),ne(H(i,ct(50)),a);const c=D(Bt);ne(H(r,Q(({scrollTop:g})=>g),Ie(),lt((g,C)=>_e(b)?{direction:g.direction,prevScrollTop:C}:{direction:C<g.prevScrollTop?Dt:Bt,prevScrollTop:C},{direction:Bt,prevScrollTop:0}),Q(g=>g.direction)),c),ne(H(r,ct(50),it(ki)),c);const p=D(0);return ne(H(f,se(g=>!g),it(0)),p),ne(H(o,ct(100),de(f),se(([g,C])=>C),lt(([g,C],[k])=>[C,k],[0,0]),Q(([g,C])=>C-g)),p),{atBottomState:S,atBottomStateChange:a,atBottomThreshold:d,atTopStateChange:l,atTopThreshold:m,isAtBottom:i,isAtTop:u,isScrolling:f,lastJumpDueToItemResize:w,scrollDirection:c,scrollVelocity:p}},Te(De)),Wt="top",$t="bottom",Nr="none";function Fr(e,t,n){return typeof e=="number"?n===Dt&&t===Wt||n===Bt&&t===$t?e:0:n===Dt?t===Wt?e.main:e.reverse:t===$t?e.main:e.reverse}function Dr(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const br=he(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=pe(),i=D(0),u=D(0),a=D(0),l=Fe(H(Pe(oe(r),oe(o),oe(n),oe(s,Nt),oe(a),oe(i),oe(t),oe(e),oe(u)),Q(([d,m,f,[b,S],w,c,p,g,C])=>{const k=d-g,R=c+p,E=Math.max(f-k,0);let x=Nr;const y=Dr(C,Wt),M=Dr(C,$t);return b-=g,b+=f+p,S+=f+p,S-=g,b>d+R-y&&(x=Dt),S<d-E+m+M&&(x=Bt),x!==Nr?[Math.max(k-f-Fr(w,Wt,x)-y,0),k-E-p+m+Fr(w,$t,x)+M]:null}),se(d=>d!=null),Ie(Nt)),[0,0]);return{increaseViewportBy:u,listBoundary:s,overscan:a,topListHeight:i,visibleRange:l}},Te(De),{singleton:!0});function Mi(e,t,n){if(xn(t)){const r=Yo(e,t);return[{index:rt(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 m=n-i,f=u+m*a+(m-1)*r,b=l,S=f-d;return{bottom:d,firstItemIndex:s,items:Wr(e,o,s),offsetBottom:S,offsetTop:l,top:b,topItems:Wr(t,o,s),topListHeight:t.reduce((w,c)=>c.size+w,0),totalCount:n}}function ts(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=mr(t,u),l=Array.from({length:u}).map((d,m)=>({data:s[m+a],index:m+a,offset:0,size:0}));return on(l,[],u,o,n,r)}function Wr(e,t,n){if(e.length===0)return[];if(!xn(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 $r(e,t){var n;return e===void 0?0:typeof e=="number"?e:(n=e[t])!=null?n:0}const It=he(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:u,visibleRange:a},{initialTopMostItemIndex:l,scrolledToInitialItem:d},{topListHeight:m},f,{didMount:b},{recalcInProgress:S}])=>{const w=D([]),c=D(0),p=pe(),g=D(0);ne(s.topItemsIndexes,w);const C=Fe(H(Pe(b,S,oe(a,Nt),oe(o),oe(r),oe(l),d,oe(w),oe(t),oe(n),oe(g),e),se(([x,y,,M,,,,,,,,T])=>{const O=T&&T.length!==M;return x&&!y&&!O}),Q(([,,[x,y],M,T,O,P,I,_,z,N,A])=>{var $,te,fe,ge;const ve=T,{offsetTree:me,sizeTree:Ae}=ve,K=_e(c);if(M===0)return{...En,totalCount:M};if(x===0&&y===0)return K===0?{...En,totalCount:M}:ts(K,O,T,_,z,A||[]);if(Se(Ae))return K>0?null:on(Mi(mr(O,M),ve,A),[],M,z,ve,_);const W=[];if(I.length>0){const F=I[0],Y=I[I.length-1];let ee=0;for(const J of Mt(Ae,F,Y)){const ie=J.value,re=Math.max(J.start,F),be=Math.min(J.end,Y);for(let ue=re;ue<=be;ue++)W.push({data:A==null?void 0:A[ue],index:ue,offset:ee,size:ie}),ee+=ie}}if(!P)return on([],W,M,z,ve,_);const L=I.length>0?I[I.length-1]+1:0,j=bi(me,x,y,L);if(j.length===0)return null;const G=M-1,V=bn([],F=>{for(const Y of j){const ee=Y.value;let J=ee.offset,ie=Y.start;const re=ee.size;if(ee.offset<x){ie+=Math.floor((x-ee.offset+z)/(re+z));const ue=ie-Y.start;J+=ue*re+ue*z}ie<L&&(J+=(L-ie)*re,ie=L);const be=Math.min(Y.end,G);for(let ue=ie;ue<=be&&!(J>=y);ue++)F.push({data:A==null?void 0:A[ue],index:ue,offset:J,size:re}),J+=re+z}}),B=$r(N,Wt),Z=$r(N,$t);if(V.length>0&&(B>0||Z>0)){const F=V[0],Y=V[V.length-1];if(B>0&&F.index>L){const ee=Math.min(B,F.index-L),J=[];let ie=F.offset;for(let re=F.index-1;re>=F.index-ee;re--){const be=(te=($=Mt(Ae,re,re)[0])==null?void 0:$.value)!=null?te:F.size;ie-=be+z,J.unshift({data:A==null?void 0:A[re],index:re,offset:ie,size:be})}V.unshift(...J)}if(Z>0&&Y.index<G){const ee=Math.min(Z,G-Y.index);let J=Y.offset+Y.size+z;for(let ie=Y.index+1;ie<=Y.index+ee;ie++){const re=(ge=(fe=Mt(Ae,ie,ie)[0])==null?void 0:fe.value)!=null?ge:Y.size;V.push({data:A==null?void 0:A[ie],index:ie,offset:J,size:re}),J+=re+z}}}return on(V,W,M,z,ve,_)}),se(x=>x!==null),Ie()),En);ne(H(e,se(ur),Q(x=>x==null?void 0:x.length)),o),ne(H(C,Q(x=>x.topListHeight)),m),ne(m,u),ne(H(C,Q(x=>[x.top,x.bottom])),i),ne(H(C,Q(x=>x.items)),p);const k=Xe(H(C,se(({items:x})=>x.length>0),de(o,e),se(([{items:x},y])=>x[x.length-1].originalIndex===y-1),Q(([,x,y])=>[x-1,y]),Ie(Nt),Q(([x])=>x))),R=Xe(H(C,ct(200),se(({items:x,topItems:y})=>x.length>0&&x[0].originalIndex===y.length),Q(({items:x})=>x[0].index),Ie())),E=Xe(H(C,se(({items:x})=>x.length>0),Q(({items:x})=>{let y=0,M=x.length-1;for(;x[y].type==="group"&&y<M;)y++;for(;x[M].type==="group"&&M>y;)M--;return{endIndex:x[M].index,startIndex:x[y].index}}),Ie(Ko)));return{endReached:k,initialItemCount:c,itemsRendered:p,listState:C,minOverscanItemCount:g,rangeChanged:E,startReached:R,topItemsIndexes:w,...f}},Te(at,Zo,br,Kt,Ut,Xt,xt,pr),{singleton:!0}),ns=he(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=pe(),i=Fe(H(Pe(n,e,r,t,o),Q(([u,a,l,d,m])=>u+a+l+d+m.offsetBottom+m.bottom)),0);return ne(oe(i),s),{totalListHeight:i,totalListHeightChanged:s}},Te(De,It),{singleton:!0}),Ei=he(([{viewportHeight:e},{totalListHeight:t}])=>{const n=D(!1),r=Fe(H(Pe(n,e,t),se(([o])=>o),Q(([,o,s])=>Math.max(0,o-s)),ct(0),Ie()),0);return{alignToBottom:n,paddingTopAddition:r}},Te(De,ns),{singleton:!0}),rs=he(()=>({context:D(null)})),ji=({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,os=he(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:u,viewportHeight:a},{scrollToIndex:l}])=>{const d=pe();return ne(H(d,de(t,a,n,s,o,r,u),de(e),Q(([[m,f,b,S,w,c,p,g],C])=>{const{align:k,behavior:R,calculateViewLocation:E=ji,done:x,...y}=m,M=Qo(m,f,S-1),T=Ft(M,f.offsetTree,C)+w+c,O=T+rt(f.sizeTree,M)[1],P=g+c,I=g+b-p,_=E({itemBottom:O,itemTop:T,locationParams:{align:k,behavior:R,...y},viewportBottom:I,viewportTop:P});return _?x&&nt(H(i,se(z=>!z),yt(_e(i)?1:2)),x):x==null||x(),_}),se(m=>m!==null)),l),{scrollIntoView:d}},Te(at,De,Ut,It,bt),{singleton:!0});function Vr(e){return e?e==="smooth"?"smooth":"auto":!1}const Oi=(e,t)=>typeof e=="function"?Vr(e(t)):t&&Vr(e),zi=he(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:u},{didMount:a,propsReady:l},{log:d},{scrollingInProgress:m},{context:f},{scrollIntoView:b}])=>{const S=D(!1),w=pe();let c=null;function p(R){ce(i,{align:"end",behavior:R,index:"LAST"})}xe(H(Pe(H(oe(t),yt(1)),a),de(oe(S),s,u,m),Q(([[R,E],x,y,M,T])=>{let O=E&&M,P="auto";return O&&(P=Oi(x,y||T),O=O&&!!P),{followOutputBehavior:P,shouldFollow:O,totalCount:R}}),se(({shouldFollow:R})=>R)),({followOutputBehavior:R,totalCount:E})=>{c&&(c(),c=null),_e(n)?requestAnimationFrame(()=>{_e(d)("following output to ",{totalCount:E},Ve.DEBUG),p(R)}):c=nt(e,()=>{_e(d)("following output to ",{totalCount:E},Ve.DEBUG),p(R),c=null})});function g(R){const E=nt(o,x=>{R&&!x.atBottom&&x.notAtBottomBecause==="SIZE_INCREASED"&&!c&&(_e(d)("scrolling to bottom due to increased size",{},Ve.DEBUG),p("auto"))});setTimeout(E,100)}xe(H(Pe(oe(S),t,l),se(([R,,E])=>R&&E),lt(({value:R},[,E])=>({refreshed:R===E,value:E}),{refreshed:!1,value:0}),se(({refreshed:R})=>R),de(S,t)),([,R])=>{_e(u)&&g(R!==!1)}),xe(w,()=>{g(_e(S)!==!1)}),xe(Pe(oe(S),o),([R,E])=>{R&&!E.atBottom&&E.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&p("auto")});const C=D(null),k=pe();return ne(er(H(oe(r),Q(R=>{var E;return(E=R==null?void 0:R.length)!=null?E:0})),H(oe(t))),k),xe(H(Pe(H(k,yt(1)),a),de(oe(C),u,m,f),Q(([[R,E],x,y,M,T])=>E&&y&&(x==null?void 0:x({context:T,totalCount:R,scrollingInProgress:M}))),se(R=>!!R),ct(0)),R=>{c&&(c(),c=null),_e(n)?requestAnimationFrame(()=>{_e(d)("scrolling into view",{}),ce(b,R)}):c=nt(e,()=>{_e(d)("scrolling into view",{}),ce(b,R),c=null})}),{autoscrollToBottom:w,followOutput:S,scrollIntoViewOnChange:C}},Te(at,Xt,Ut,Kt,xt,bt,De,rs,os)),Pi=he(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:u}])=>(ne(H(u,de(s),se(([,a])=>a!==0),de(o,r,t,n,e),Q(([[,a],l,d,m,f,b=[]])=>ts(a,l,d,m,f,b))),i),{}),Te(at,Kt,It,xt),{singleton:!0}),Ai=he(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=D(0);return xe(H(e,de(r),se(([,o])=>o!==0),Q(([,o])=>({top:o}))),o=>{nt(H(n,yt(1),se(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{ce(t,o)})})}),{initialScrollTop:r}},Te(xt,De,It),{singleton:!0}),ss=he(([{scrollVelocity:e}])=>{const t=D(!1),n=pe(),r=D(!1);return ne(H(e,de(r,t,n),se(([o,s])=>!!s),Q(([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}),Ie()),t),xe(H(Pe(t,e,n),de(r)),([[o,s,i],u])=>{o&&u&&u.change&&u.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},Te(Xt),{singleton:!0}),xr=he(([{scrollContainerState:e,scrollTo:t}])=>{const n=pe(),r=pe(),o=pe(),s=D(!1),i=D(void 0);return ne(H(Pe(n,r),Q(([{scrollHeight:u,scrollTop:a,viewportHeight:l},{offsetTop:d}])=>({scrollHeight:u,scrollTop:Math.max(0,a-d),viewportHeight:l}))),e),ne(H(t,de(r),Q(([u,{offsetTop:a}])=>({...u,top:u.top+a}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},Te(De)),Bi=he(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:u,windowViewportRect:a}])=>{const l=pe(),d=D(void 0),m=D(null),f=D(null);return ne(u,m),ne(a,f),xe(H(l,de(t,r,i,m,f,n)),([b,S,w,c,p,g,C])=>{const k=vi(S.sizeTree);c&&p!==null&&g!==null&&(w=p.scrollTop-g.offsetTop),w-=C,b({ranges:k,scrollTop:w})}),ne(H(d,se(ur),Q(Li)),o),ne(H(s,de(d),se(([,b])=>b!==void 0),Ie(),Q(([,b])=>b.ranges)),e),{getState:l,restoreStateFrom:d}},Te(at,De,Kt,xt,xr));function Li(e){return{align:"start",index:0,offset:e.scrollTop}}const Gi=he(([{topItemsIndexes:e}])=>{const t=D(0);return ne(H(t,se(n=>n>=0),Q(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},Te(It));function is(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}const Hi=is(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Ni=he(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:u},{listState:a},{beforeUnshiftWith:l,gap:d,shiftWithOffset:m,sizes:f},{log:b},{recalcInProgress:S}])=>{const w=Xe(H(a,de(i),lt(([,p,g,C],[{bottom:k,items:R,offsetBottom:E,totalCount:x},y])=>{const M=k+E;let T=0;return g===x&&p.length>0&&R.length>0&&(R[0].originalIndex===0&&p[0].originalIndex===0||(T=M-C,T!==0&&(T+=y))),[T,R,x,M]},[0,[],0,0]),se(([p])=>p!==0),de(r,u,n,o,b,S),se(([,p,g,C,,,k])=>!k&&!C&&p!==0&&g===Dt),Q(([[p],,,,,g])=>(g("Upward scrolling compensation",{amount:p},Ve.DEBUG),p))));function c(p){p>0?(ce(t,{behavior:"auto",top:-p}),ce(e,0)):(ce(e,0),ce(t,{behavior:"auto",top:-p}))}return xe(H(w,de(e,s)),([p,g,C])=>{C&&Hi()?ce(e,g-p):c(-p)}),xe(H(Pe(Fe(s,!1),e,S),se(([p,g,C])=>!p&&!C&&g!==0),Q(([p,g])=>g),ct(1)),c),ne(H(m,Q(p=>({top:-p}))),t),xe(H(l,de(f,d),Q(([p,{groupIndices:g,lastSize:C,sizeTree:k},R])=>{function E(x){return x*(C+R)}if(g.length===0)return E(p);{let x=0;const y=Ht(k,0);let M=0,T=0;for(;M<p;){M++,x+=y;let O=g.length===T+1?1/0:g[T+1]-g[T]-1;M+O>p&&(x-=y,O=p-M+1),M+=O,x+=E(O),T++}return x}})),p=>{ce(e,p),requestAnimationFrame(()=>{ce(t,{top:p}),requestAnimationFrame(()=>{ce(e,0),ce(S,!1)})})}),{deviation:e}},Te(De,Xt,It,at,bt,pr)),Fi=he(([e,t,n,r,o,s,i,u,a,l,d])=>({...e,...t,...n,...r,...o,...s,...i,...u,...a,...l,...d}),Te(br,Pi,xt,ss,ns,Ai,Ei,xr,os,bt,rs)),ls=he(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:o,gap:s,groupIndices:i,heightEstimates:u,itemSize:a,sizeRanges:l,sizes:d,statefulTotalCount:m,totalCount:f,trackItemSizes:b},{initialItemFinalLocationReached:S,initialTopMostItemIndex:w,scrolledToInitialItem:c},p,g,C,k,{scrollToIndex:R},E,{topItemCount:x},{groupCounts:y},M])=>{const{listState:T,minOverscanItemCount:O,topItemsIndexes:P,rangeChanged:I,..._}=k;return ne(I,M.scrollSeekRangeChanged),ne(H(M.windowViewportRect,Q(z=>z.visibleHeight)),p.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:o,gap:s,groupCounts:y,heightEstimates:u,initialItemFinalLocationReached:S,initialTopMostItemIndex:w,scrolledToInitialItem:c,sizeRanges:l,topItemCount:x,topItemsIndexes:P,totalCount:f,...C,groupIndices:i,itemSize:a,listState:T,minOverscanItemCount:O,scrollToIndex:R,statefulTotalCount:m,trackItemSizes:b,rangeChanged:I,..._,...M,...p,sizes:d,...g}},Te(at,Kt,De,Bi,zi,It,Ut,Ni,Gi,Zo,Fi));function Di(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"?h.useLayoutEffect:h.useEffect;function as(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=h.createContext({});function a(c,p){c.propsReady&&ce(c.propsReady,!1);for(const g of r){const C=c[t.required[g]];ce(C,p[g])}for(const g of o)if(g in p){const C=c[t.optional[g]];ce(C,p[g])}c.propsReady&&ce(c.propsReady,!0)}function l(c){return s.reduce((p,g)=>(p[g]=C=>{const k=c[t.methods[g]];ce(k,C)},p),{})}function d(c){return i.reduce((p,g)=>(p[g]=oi(c[t.events[g]]),p),{})}const m=h.forwardRef((c,p)=>{const{children:g,...C}=c,[k]=h.useState(()=>bn(ii(e),x=>{a(x,C)})),[R]=h.useState(Ar(d,k));Jt(()=>{for(const x of i)x in C&&xe(R[x],C[x]);return()=>{Object.values(R).map(dr)}},[C,R,k]),Jt(()=>{a(k,C)}),h.useImperativeHandle(p,Pr(l(k)));const E=n;return v.jsx(u.Provider,{value:k,children:n?v.jsx(E,{...Di([...r,...o,...i],C),children:g}):g})}),f=c=>{const p=h.useContext(u);return h.useCallback(g=>{ce(p[c],g)},[p,c])},b=c=>{const p=h.useContext(u)[c],g=h.useCallback(C=>xe(p,C),[p]);return h.useSyncExternalStore(g,()=>_e(p),()=>_e(p))},S=c=>{const p=h.useContext(u)[c],[g,C]=h.useState(Ar(_e,p));return Jt(()=>xe(p,k=>{k!==g&&C(Pr(k))}),[p,g]),g},w=h.version.startsWith("18")?b:S;return{Component:m,useEmitter:(c,p)=>{const g=h.useContext(u)[c];Jt(()=>xe(g,p),[p,g])},useEmitterValue:w,usePublisher:f}}const cs=h.createContext(void 0),us=h.createContext(void 0),ds=typeof document<"u"?h.useLayoutEffect:h.useEffect;function jn(e){return"self"in e}function Wi(e){return"body"in e}function fs(e,t,n,r=Ot,o,s){const i=h.useRef(null),u=h.useRef(null),a=h.useRef(null),l=h.useCallback(f=>{let b,S,w;const c=f.target;if(Wi(c)||jn(c)){const g=jn(c)?c:c.defaultView;w=s?g.scrollX:g.scrollY,b=s?g.document.documentElement.scrollWidth:g.document.documentElement.scrollHeight,S=s?g.innerWidth:g.innerHeight}else w=s?c.scrollLeft:c.scrollTop,b=s?c.scrollWidth:c.scrollHeight,S=s?c.offsetWidth:c.offsetHeight;const p=()=>{e({scrollHeight:b,scrollTop:Math.max(w,0),viewportHeight:S})};f.suppressFlushSync?p():Ls.flushSync(p),u.current!==null&&(w===u.current||w<=0||w===b-S)&&(u.current=null,t(!0),a.current&&(clearTimeout(a.current),a.current=null))},[e,t,s]);h.useEffect(()=>{const f=o||i.current;return r(o||i.current),l({suppressFlushSync:!0,target:f}),f.addEventListener("scroll",l,{passive:!0}),()=>{r(null),f.removeEventListener("scroll",l)}},[i,l,n,r,o]);function d(f){const b=i.current;if(!b||(s?"offsetWidth"in b&&b.offsetWidth===0:"offsetHeight"in b&&b.offsetHeight===0))return;const S=f.behavior==="smooth";let w,c,p;jn(b)?(c=Math.max(gt(b.document.documentElement,s?"width":"height"),s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight),w=s?b.innerWidth:b.innerHeight,p=s?window.scrollX:window.scrollY):(c=b[s?"scrollWidth":"scrollHeight"],w=gt(b,s?"width":"height"),p=b[s?"scrollLeft":"scrollTop"]);const g=c-w;if(f.top=Math.ceil(Math.max(Math.min(g,f.top),0)),es(w,c)||f.top===p){e({scrollHeight:c,scrollTop:p,viewportHeight:w}),S&&t(!0);return}S?(u.current=f.top,a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,u.current=null,t(!0)},1e3)):u.current=null,s&&(f={behavior:f.behavior,left:f.top}),b.scrollTo(f)}function m(f){s&&(f={behavior:f.behavior,left:f.top}),i.current.scrollBy(f)}return{scrollByCallback:m,scrollerRef:i,scrollToCallback:d}}const On="-webkit-sticky",qr="sticky",vr=is(()=>{if(typeof document>"u")return qr;const e=document.createElement("div");return e.style.position=On,e.style.position===On?On:qr});function Sr(e){return e}const $i=he(()=>{const e=D(u=>`Item ${u}`),t=D(u=>`Group ${u}`),n=D({}),r=D(Sr),o=D("div"),s=D(Ot),i=(u,a=null)=>Fe(H(n,Q(l=>l[u]),Ie()),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")}}),Vi=he(([e,t])=>({...e,...t}),Te(ls,$i)),qi=({height:e})=>v.jsx("div",{style:{height:e}}),Ui={overflowAnchor:"none",position:vr(),zIndex:1},ps={overflowAnchor:"none"},Ki={...ps,display:"inline-block",height:"100%"},Ur=h.memo(function({showTopList:e=!1}){const t=le("listState"),n=Ze("sizeRanges"),r=le("useWindowScroll"),o=le("customScrollParent"),s=Ze("windowScrollContainerState"),i=Ze("scrollContainerState"),u=o||r?s:i,a=le("itemContent"),l=le("context"),d=le("groupContent"),m=le("trackItemSizes"),f=le("itemSize"),b=le("log"),S=Ze("gap"),w=le("horizontalDirection"),{callbackRef:c}=ci(n,f,m,e?Ot:u,b,S,o,w,le("skipAnimationFrameInResizeObserver")),[p,g]=h.useState(0);yr("deviation",_=>{p!==_&&g(_)});const C=le("EmptyPlaceholder"),k=le("ScrollSeekPlaceholder")||qi,R=le("ListComponent"),E=le("ItemComponent"),x=le("GroupComponent"),y=le("computeItemKey"),M=le("isSeeking"),T=le("groupIndices").length>0,O=le("alignToBottom"),P=le("initialItemFinalLocationReached"),I=e?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:p!==0?p:O?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:p!==0?p:O?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...P?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?v.jsx(C,{...Ne(C,l)}):v.jsx(R,{...Ne(R,l),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:c,style:I,children:(e?t.topItems:t.items).map(_=>{const z=_.originalIndex,N=y(z+t.firstItemIndex,_.data,l);return M?h.createElement(k,{...Ne(k,l),height:_.size,index:_.index,key:N,type:_.type||"item",..._.type==="group"?{}:{groupIndex:_.groupIndex}}):_.type==="group"?h.createElement(x,{...Ne(x,l),"data-index":z,"data-item-index":_.index,"data-known-size":_.size,key:N,style:Ui},d(_.index,l)):h.createElement(E,{...Ne(E,l),...Zi(E,_.data),"data-index":z,"data-item-group-index":_.groupIndex,"data-item-index":_.index,"data-known-size":_.size,key:N,style:w?Ki:ps},T?a(_.index,_.groupIndex,_.data,l):a(_.index,_.data,l))})})}),Xi={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Yi={outline:"none",overflowX:"auto",position:"relative"},vn=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Qi={position:vr(),top:0,width:"100%",zIndex:1};function Ne(e,t){if(typeof e!="string")return{context:t}}function Zi(e,t){return{item:typeof e=="string"?void 0:t}}const Ji=h.memo(function(){const e=le("HeaderComponent"),t=Ze("headerHeight"),n=le("HeaderFooterTag"),r=Ct(h.useMemo(()=>s=>{t(gt(s,"height"))},[t]),!0,le("skipAnimationFrameInResizeObserver")),o=le("context");return e?v.jsx(n,{ref:r,children:v.jsx(e,{...Ne(e,o)})}):null}),el=h.memo(function(){const e=le("FooterComponent"),t=Ze("footerHeight"),n=le("HeaderFooterTag"),r=Ct(h.useMemo(()=>s=>{t(gt(s,"height"))},[t]),!0,le("skipAnimationFrameInResizeObserver")),o=le("context");return e?v.jsx(n,{ref:r,children:v.jsx(e,{...Ne(e,o)})}):null});function gs({useEmitter:e,useEmitterValue:t,usePublisher:n}){return h.memo(function({children:r,style:o,context:s,...i}){const u=n("scrollContainerState"),a=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("scrollerRef"),m=t("horizontalDirection")||!1,{scrollByCallback:f,scrollerRef:b,scrollToCallback:S}=fs(u,l,a,d,void 0,m);return e("scrollTo",S),e("scrollBy",f),v.jsx(a,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:b,style:{...m?Yi:Xi,...o},tabIndex:0,...i,...Ne(a,s),children:r})})}function hs({useEmitter:e,useEmitterValue:t,usePublisher:n}){return h.memo(function({children:r,style:o,context:s,...i}){const u=n("windowScrollContainerState"),a=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("totalListHeight"),m=t("deviation"),f=t("customScrollParent"),b=h.useRef(null),S=t("scrollerRef"),{scrollByCallback:w,scrollerRef:c,scrollToCallback:p}=fs(u,l,a,S,f);return ds(()=>{var g;return c.current=f||((g=b.current)==null?void 0:g.ownerDocument.defaultView),()=>{c.current=null}},[c,f]),e("windowScrollTo",p),e("scrollBy",w),v.jsx(a,{ref:b,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+m}:{}},...i,...Ne(a,s),children:r})})}const tl=({children:e})=>{const t=h.useContext(cs),n=Ze("viewportHeight"),r=Ze("fixedItemHeight"),o=le("alignToBottom"),s=le("horizontalDirection"),i=h.useMemo(()=>No(n,a=>gt(a,s?"width":"height")),[n,s]),u=Ct(i,!0,le("skipAnimationFrameInResizeObserver"));return h.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),v.jsx("div",{"data-viewport-type":"element",ref:u,style:vn(o),children:e})},nl=({children:e})=>{const t=h.useContext(cs),n=Ze("windowViewportRect"),r=Ze("fixedItemHeight"),o=le("customScrollParent"),s=Do(n,o,le("skipAnimationFrameInResizeObserver")),i=le("alignToBottom");return h.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),v.jsx("div",{"data-viewport-type":"window",ref:s,style:vn(i),children:e})},rl=({children:e})=>{const t=le("TopItemListComponent")||"div",n=le("headerHeight"),r={...Qi,marginTop:`${n}px`},o=le("context");return v.jsx(t,{style:r,...Ne(t,o),children:e})},ol=h.memo(function(e){const t=le("useWindowScroll"),n=le("topItemsIndexes").length>0,r=le("customScrollParent"),o=le("context");return v.jsxs(r||t?ll:il,{...e,context:o,children:[n&&v.jsx(rl,{children:v.jsx(Ur,{showTopList:!0})}),v.jsxs(r||t?nl:tl,{children:[v.jsx(Ji,{}),v.jsx(Ur,{}),v.jsx(el,{})]})]})}),{Component:sl,useEmitter:yr,useEmitterValue:le,usePublisher:Ze}=as(Vi,{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"}},ol),il=gs({useEmitter:yr,useEmitterValue:le,usePublisher:Ze}),ll=hs({useEmitter:yr,useEmitterValue:le,usePublisher:Ze}),al=sl,cl=he(()=>{const e=D(l=>v.jsxs("td",{children:["Item $",l]})),t=D(null),n=D(l=>v.jsxs("td",{colSpan:1e3,children:["Group ",l]})),r=D(null),o=D(null),s=D({}),i=D(Sr),u=D(Ot),a=(l,d=null)=>Fe(H(s,Q(m=>m[l]),Ie()),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")}});Te(ls,cl);vr();const Kr={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},ul={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Xr,floor:an,max:Lt,min:zn,round:Yr}=Math;function Qr(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function dl(e){return{...ul,items:e}}function en(e,t){return e&&e.width===t.width&&e.height===t.height}function fl(e,t){return e&&e.column===t.column&&e.row===t.row}const pl=he(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:u,scrollTo:a,scrollTop:l,smoothScrollTargetReached:d,viewportHeight:m},f,b,{didMount:S,propsReady:w},{customScrollParent:c,useWindowScroll:p,windowScrollContainerState:g,windowScrollTo:C,windowViewportRect:k},R])=>{const E=D(0),x=D(0),y=D(Kr),M=D({height:0,width:0}),T=D({height:0,width:0}),O=pe(),P=pe(),I=D(0),_=D(null),z=D({column:0,row:0}),N=pe(),A=pe(),$=D(!1),te=D(0),fe=D(!0),ge=D(!1),ve=D(!1);xe(H(S,de(te),se(([j,G])=>!!G)),()=>{ce(fe,!1)}),xe(H(Pe(S,fe,T,M,te,ge),se(([j,G,V,B,,Z])=>j&&!G&&V.height!==0&&B.height!==0&&!Z)),([,,,,j])=>{ce(ge,!0),hr(1,()=>{ce(O,j)}),nt(H(l),()=>{ce(t,[0,0]),ce(fe,!0)})}),ne(H(A,se(j=>j!=null&&j.scrollTop>0),it(0)),x),xe(H(S,de(A),se(([,j])=>j!=null)),([,j])=>{j&&(ce(M,j.viewport),ce(T,j.item),ce(z,j.gap),j.scrollTop>0&&(ce($,!0),nt(H(l,yt(1)),G=>{ce($,!1)}),ce(a,{top:j.scrollTop})))}),ne(H(M,Q(({height:j})=>j)),m),ne(H(Pe(oe(M,en),oe(T,en),oe(z,(j,G)=>j&&j.column===G.column&&j.row===G.row),oe(l)),Q(([j,G,V,B])=>({gap:V,item:G,scrollTop:B,viewport:j}))),N),ne(H(Pe(oe(E),r,oe(z,fl),oe(T,en),oe(M,en),oe(_),oe(x),oe($),oe(fe),oe(te)),se(([,,,,,,,j])=>!j),Q(([j,[G,V],B,Z,F,Y,ee,,J,ie])=>{const{column:re,row:be}=B,{height:ue,width:ye}=Z,{width:ke}=F;if(ee===0&&(j===0||ke===0))return Kr;if(ye===0){const ut=mr(ie,j),zt=ut+Math.max(ee-1,0);return dl(Qr(ut,zt,Y))}const ze=ms(ke,ye,re);let Ee,Ge;J?G===0&&V===0&&ee>0?(Ee=0,Ge=ee-1):(Ee=ze*an((G+be)/(ue+be)),Ge=ze*Xr((V+be)/(ue+be))-1,Ge=zn(j-1,Lt(Ge,ze-1)),Ee=zn(Ge,Lt(0,Ee))):(Ee=0,Ge=-1);const ot=Qr(Ee,Ge,Y),{bottom:We,top:je}=Zr(F,B,Z,ot),et=Xr(j/ze),Ye=et*ue+(et-1)*be-We;return{bottom:We,itemHeight:ue,items:ot,itemWidth:ye,offsetBottom:Ye,offsetTop:je,top:je}})),y),ne(H(_,se(j=>j!==null),Q(j=>j.length)),E),ne(H(Pe(M,T,y,z),se(([j,G,{items:V}])=>V.length>0&&G.height!==0&&j.height!==0),Q(([j,G,{items:V},B])=>{const{bottom:Z,top:F}=Zr(j,B,G,V);return[F,Z]}),Ie(Nt)),t);const me=D(!1);ne(H(l,de(me),Q(([j,G])=>G||j!==0)),me);const Ae=Xe(H(Pe(y,E),se(([{items:j}])=>j.length>0),de(me),se(([[j,G],V])=>{const B=j.items[j.items.length-1].index===G-1;return(V||j.bottom>0&&j.itemHeight>0&&j.offsetBottom===0&&j.items.length===G)&&B}),Q(([[,j]])=>j-1),Ie())),K=Xe(H(oe(y),se(({items:j})=>j.length>0&&j[0].index===0),it(0),Ie())),W=Xe(H(oe(y),de($),se(([{items:j},G])=>j.length>0&&!G),Q(([{items:j}])=>({endIndex:j[j.length-1].index,startIndex:j[0].index})),Ie(Ko),ct(0)));ne(W,b.scrollSeekRangeChanged),ne(H(O,de(M,T,E,z),Q(([j,G,V,B,Z])=>{const F=Jo(j),{align:Y,behavior:ee,offset:J}=F;let ie=F.index;ie==="LAST"&&(ie=B-1),ie=Lt(0,ie,zn(B-1,ie));let re=sr(G,Z,V,ie);return Y==="end"?re=Yr(re-G.height+V.height):Y==="center"&&(re=Yr(re-G.height/2+V.height/2)),J&&(re+=J),{behavior:ee,top:re}})),a);const L=Fe(H(y,Q(j=>j.offsetBottom+j.bottom)),0);return ne(H(k,Q(j=>({height:j.visibleHeight,width:j.visibleWidth}))),M),{customScrollParent:c,data:_,deviation:I,footerHeight:o,gap:z,headerHeight:s,increaseViewportBy:e,initialItemCount:x,itemDimensions:T,overscan:n,restoreStateFrom:A,scrollBy:i,scrollContainerState:u,scrollHeight:P,scrollTo:a,scrollToIndex:O,scrollTop:l,smoothScrollTargetReached:d,totalCount:E,useWindowScroll:p,viewportDimensions:M,windowScrollContainerState:g,windowScrollTo:C,windowViewportRect:k,...b,gridState:y,horizontalDirection:ve,initialTopMostItemIndex:te,totalListHeight:L,...f,endReached:Ae,propsReady:w,rangeChanged:W,startReached:K,stateChanged:N,stateRestoreInProgress:$,...R}},Te(br,De,Xt,ss,xt,xr,bt));function ms(e,t,n){return Lt(1,an((e+n)/(an(t)+n)))}function Zr(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=sr(e,t,n,r[0].index);return{bottom:sr(e,t,n,r[r.length-1].index)+o,top:s}}function sr(e,t,n,r){const o=ms(e.width,n.width,t.column),s=an(r/o),i=s*n.height+Lt(0,s-1)*t.row;return i>0?i+t.row:i}const gl=he(()=>{const e=D(m=>`Item ${m}`),t=D({}),n=D(null),r=D("virtuoso-grid-item"),o=D("virtuoso-grid-list"),s=D(Sr),i=D("div"),u=D(Ot),a=(m,f=null)=>Fe(H(t,Q(b=>b[m]),Ie()),f),l=D(!1),d=D(!1);return ne(oe(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")}}),hl=he(([e,t])=>({...e,...t}),Te(pl,gl)),ml=h.memo(function(){const e=Re("gridState"),t=Re("listClassName"),n=Re("itemClassName"),r=Re("itemContent"),o=Re("computeItemKey"),s=Re("isSeeking"),i=Je("scrollHeight"),u=Re("ItemComponent"),a=Re("ListComponent"),l=Re("ScrollSeekPlaceholder"),d=Re("context"),m=Je("itemDimensions"),f=Je("gap"),b=Re("log"),S=Re("stateRestoreInProgress"),w=Je("reportReadyState"),c=Ct(h.useMemo(()=>p=>{const g=p.parentElement.parentElement.scrollHeight;i(g);const C=p.firstChild;if(C){const{height:k,width:R}=C.getBoundingClientRect();m({height:k,width:R})}f({column:Jr("column-gap",getComputedStyle(p).columnGap,b),row:Jr("row-gap",getComputedStyle(p).rowGap,b)})},[i,m,f,b]),!0,!1);return ds(()=>{e.itemHeight>0&&e.itemWidth>0&&w(!0)},[e]),S?null:v.jsx(a,{className:t,ref:c,...Ne(a,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(p=>{const g=o(p.index,p.data,d);return s?v.jsx(l,{...Ne(l,d),height:e.itemHeight,index:p.index,width:e.itemWidth},g):h.createElement(u,{...Ne(u,d),className:n,"data-index":p.index,key:g},r(p.index,p.data,d))})})}),bl=h.memo(function(){const e=Re("HeaderComponent"),t=Je("headerHeight"),n=Re("headerFooterTag"),r=Ct(h.useMemo(()=>s=>{t(gt(s,"height"))},[t]),!0,!1),o=Re("context");return e?v.jsx(n,{ref:r,children:v.jsx(e,{...Ne(e,o)})}):null}),xl=h.memo(function(){const e=Re("FooterComponent"),t=Je("footerHeight"),n=Re("headerFooterTag"),r=Ct(h.useMemo(()=>s=>{t(gt(s,"height"))},[t]),!0,!1),o=Re("context");return e?v.jsx(n,{ref:r,children:v.jsx(e,{...Ne(e,o)})}):null}),vl=({children:e})=>{const t=h.useContext(us),n=Je("itemDimensions"),r=Je("viewportDimensions"),o=Ct(h.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return h.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),v.jsx("div",{ref:o,style:vn(!1),children:e})},Sl=({children:e})=>{const t=h.useContext(us),n=Je("windowViewportRect"),r=Je("itemDimensions"),o=Re("customScrollParent"),s=Do(n,o,!1);return h.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),v.jsx("div",{ref:s,style:vn(!1),children:e})},yl=h.memo(function({...e}){const t=Re("useWindowScroll"),n=Re("customScrollParent"),r=n||t?Cl:wl,o=n||t?Sl:vl,s=Re("context");return v.jsx(r,{...e,...Ne(r,s),children:v.jsxs(o,{children:[v.jsx(bl,{}),v.jsx(ml,{}),v.jsx(xl,{})]})})}),{useEmitter:bs,useEmitterValue:Re,usePublisher:Je}=as(hl,{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"}},yl),wl=gs({useEmitter:bs,useEmitterValue:Re,usePublisher:Je}),Cl=hs({useEmitter:bs,useEmitterValue:Re,usePublisher:Je});function Jr(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ve.WARN),t==="normal"?0:parseInt(t??"0",10)}const Sn=h.createContext(void 0);function Ce(e,t){const n=h.useContext(Sn);if(!n)throw new Error("useAudioStore must be used within CRAudioProvider");return gn(n,e,t)}function cn(){const e=h.useContext(Sn);if(!e)throw new Error("useAudioStoreApi must be used within CRAudioProvider");return e}const Il="_handleStart_1ihf3_16 _handle_1ihf3_1",Tl="_handleEnd_1ihf3_21 _handle_1ihf3_1",eo={handleStart:Il,handleEnd:Tl};let ir=!1;function xs(){return ir}const kl=({containerRef:e})=>{const t=q(c=>c.rangeStartGI),n=q(c=>c.rangeEndGI),r=q(c=>c.setRange),o=ht(),s=t!=null&&n!=null,[i,u]=h.useState(null),[a,l]=h.useState(null),d=h.useRef(null),m=h.useRef({startGI:t,endGI:n});m.current={startGI:t,endGI:n};const f=h.useRef(r);f.current=r,h.useEffect(()=>{if(!s||t==null||n==null){u(null),l(null);return}const c=()=>{const g=e.current;if(!g)return;const C=g.getBoundingClientRect(),R=1/(o.getState().playbackScale||1),E=g.querySelector(`[data-g="${t}"]`),x=g.querySelector(`[data-g="${n}"]`);if(E){const y=E.getBoundingClientRect();u({x:(y.left-C.left)*R,y:(y.bottom-C.top)*R})}else u(null);if(x){const y=x.getBoundingClientRect();l({x:(y.right-C.left)*R,y:(y.bottom-C.top)*R})}else l(null)};c();const p=e.current;return p&&p.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{p&&p.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[s,t,n,e,o]);const b=h.useCallback((c,p)=>{var C;const g=document.elementsFromPoint(c,p);for(const k of g){const R=(C=k.getAttribute)==null?void 0:C.call(k,"data-g");if(R!=null)return parseInt(R,10)}return null},[]);h.useEffect(()=>{const c=g=>{if(!d.current)return;const{startGI:C,endGI:k}=m.current;if(C==null||k==null)return;const R=b(g.clientX,g.clientY);R!=null&&(d.current==="start"?R<=k?f.current(R,k):(f.current(k,R),d.current="end"):R>=C?f.current(C,R):(f.current(R,C),d.current="start"))},p=()=>{d.current=null,setTimeout(()=>{ir=!1},50)};return document.addEventListener("pointermove",c),document.addEventListener("pointerup",p),document.addEventListener("pointercancel",p),()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",p),document.removeEventListener("pointercancel",p)}},[b]);const S=h.useCallback(c=>p=>{p.preventDefault(),p.stopPropagation(),d.current=c,ir=!0},[]);return s?v.jsxs(v.Fragment,{children:[i&&v.jsx("div",{className:eo.handleStart,"data-range-handle":"start",style:{left:i.x-26,top:i.y},onPointerDown:S("start")}),a&&v.jsx("div",{className:eo.handleEnd,"data-range-handle":"end",style:{left:a.x,top:a.y},onPointerDown:S("end")})]}):null},Rl="_run_zzb61_3",_l="_runWrap_zzb61_7",Ml="_highlight_zzb61_13",El="_highlightleft_zzb61_14",jl="_highlightright_zzb61_15",Ol="_highlightcenter_zzb61_16",zl="_underline_zzb61_48",Pl="_underlineleft_zzb61_49",Al="_underlineright_zzb61_50",Bl="_underlinecenter_zzb61_51",st={run:Rl,runWrap:_l,highlight:Ml,highlightleft:El,highlightright:jl,highlightcenter:Ol,underline:zl,underlineleft:Pl,underlineright:Al,underlinecenter:Bl},to=e=>Symbol.iterator in e,no=e=>"entries"in e,ro=(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},Ll=(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 Gl(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:to(e)&&to(t)?no(e)&&no(t)?ro(e,t):Ll(e,t):ro({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function Vt(e){const t=h.useRef(void 0);return n=>{const r=e(n);return Gl(t.current,r)?t.current:t.current=r}}function Hl(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 Nl(e){const t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return t?{r:+t[1],g:+t[2],b:+t[3]}:null}const Fl=Object.freeze({showPointer:void 0,pointerStyle:void 0,pointerColor:void 0}),vs=h.memo(function({runs:t,ns:n,baseIndex:r,preGroups:o}){const s=Ce(O=>O.setClipIndex),i=Ce(O=>O.seek),u=q(O=>O.setCurrentGlobalRunIndex),a=cn(),l=q(O=>O.rangeStartGI),d=q(O=>O.rangeEndGI),m=q(O=>O.setRange),f=l!=null&&d!=null,b=h.useCallback(O=>{var te;const P=(te=O.target)==null?void 0:te.closest("[data-g]");if(!P)return;const I=Number(P.dataset.g),_=I-r;if(_<0||_>=t.length)return;const z=t[_],N=z.text??"";if(!N.trim()||!/[가-힣a-zA-Z0-9]/.test(N))return;u(I,"program");const A=z.audioChunkIndex,$=z.audioTimeMs;A!=null&&$!=null&&(s(A),i($))},[t,r,i,s,u]),S=h.useRef(null),w=h.useRef(!1),c=h.useRef({x:0,y:0}),p=h.useCallback(O=>{var z;const P=(z=O.target)==null?void 0:z.closest("[data-g]");if(!P)return;const I=Number(P.dataset.g),_=I-r;_<0||_>=t.length||(w.current=!1,c.current={x:O.clientX,y:O.clientY},S.current&&(window.clearTimeout(S.current),S.current=null),S.current=window.setTimeout(()=>{a.getState().status!=="playing"&&(m(I,I),w.current=!0,S.current=null)},800))},[t,r,m,a]),g=h.useCallback(()=>{S.current&&(window.clearTimeout(S.current),S.current=null)},[]),C=h.useCallback(O=>{if(!S.current)return;const P=O.clientX-c.current.x,I=O.clientY-c.current.y;(Math.abs(P)>5||Math.abs(I)>5)&&g()},[g]),k=h.useCallback(()=>{g()},[g]),R=g,E=g,x=q(O=>O.clearRange),y=h.useCallback(O=>{var _;if(w.current){w.current=!1;return}if(xs())return;const P=(_=O.target)==null?void 0:_.closest("[data-g]");if(!P)return;const I=Number(P.dataset.g);isNaN(I)||f&&l!=null&&d!=null&&(x(),O.stopPropagation())},[f,l,d,x]),M=o,T=r+t.length-1;return v.jsx("span",{onClick:y,onDoubleClick:b,onPointerDown:p,onPointerMove:C,onPointerUp:k,onPointerCancel:R,onPointerLeave:E,children:M.map((O,P)=>v.jsx(Wl,{ns:n,group:O,runs:t,paraLastG:T,rangeStartGI:l,rangeEndGI:d},`${n}/grp:${P}-${O.startG}`))})},(e,t)=>e.ns===t.ns&&e.baseIndex===t.baseIndex&&e.runs===t.runs&&e.sectionId===t.sectionId),Dl=h.memo(function(){const t=h.useCallback(r=>({showSplit:r.showSplit,slash:r.breakMarks.slash,breakGapPx:r.breakGapPx}),[]),n=X(Vt(t));return n.showSplit?v.jsxs(v.Fragment,{children:[v.jsx("span",{style:{display:"inline-block",width:n.breakGapPx/2}}),n.slash&&v.jsx("span",{children:" / "}),v.jsx("span",{style:{display:"inline-block",width:n.breakGapPx/2}})]}):null}),Wl=h.memo(function({ns:t,group:n,runs:r,paraLastG:o,rangeStartGI:s,rangeEndGI:i}){const u=h.useCallback(c=>{const p=c.currentGlobalRunIndex;return p!=null&&p>=n.startG&&p<=n.endG},[n]),a=q(Vt(u)),l=h.useCallback(c=>a?{showPointer:c.showPointer,pointerStyle:c.pointerStyle,pointerColor:c.pointerColor}:Fl,[a]),d=X(Vt(l)),m=n.r0??0,f=n.len??Math.max(0,n.endG-n.startG+1),b=a&&d.showPointer&&d.pointerStyle!=="underline",S=a&&d.showPointer&&d.pointerStyle==="underline",w=b||S?{"--hl-color":d.pointerColor,"--ul-color":d.pointerColor,"--ul-thickness":"0.3em","--ul-offset":"0.35em"}:void 0;return v.jsx(v.Fragment,{children:Array.from({length:f}).map((c,p)=>{const C=r[m+p],k=n.startG+p,R=`${t}/run:${k}`,E=!!C.split&&k!==o;let x=`${st.runWrap}`;return b&&(f===1?x+=` ${st.highlight}`:p===0?x+=` ${st.highlightleft}`:p+1===f?x+=` ${st.highlightright}`:x+=` ${st.highlightcenter}`),S&&(f===1?x+=` ${st.underline}`:p===0?x+=` ${st.underlineleft}`:p+1===f?x+=` ${st.underlineright}`:x+=` ${st.underlinecenter}`),v.jsxs(h.Fragment,{children:[v.jsx("span",{className:x,style:w,children:v.jsx($l,{gi:n.startG,g:k,run:C,active:a,pointerCfg:d,isInRange:s!=null&&i!=null&&k>=s&&k<=i})}),E&&v.jsx(Dl,{})]},R)})})},(e,t)=>e.group===t.group&&e.runs===t.runs&&e.ns===t.ns&&e.rangeStartGI===t.rangeStartGI&&e.rangeEndGI===t.rangeEndGI),$l=h.memo(function({gi:t,g:n,run:r,active:o,pointerCfg:s,isInRange:i}){const u=h.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("#")?Hl(l):Nl(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 v.jsx("span",{className:st.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 Vl({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 v.jsxs("p",{style:{width:"100%",margin:"8px 0",paddingLeft:i,textAlign:e.textAlign,boxSizing:"border-box"},children:[e.list?v.jsx("span",{style:{minWidth:16,display:"inline-block",whiteSpace:"nowrap",userSelect:"none"},children:a||""}):null,v.jsx(vs,{preGroups:s,runs:e.runs,ns:n,baseIndex:r,sectionId:o})]})}const ql=h.memo(Vl,(e,t)=>e.block===t.block&&e.computedMarker===t.computedMarker&&e.baseIndex===t.baseIndex&&e.ns===t.ns);function Ul(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 so(e,!1);case"upperalpha":case"upperlatin":return so(e,!0);case"lowerroman":return oo(e,!1);case"upperroman":return oo(e,!0);case"decimalenclosedcircle":return Kl(e);default:return String(e)}}function Kl(e){return e>=1&&e<=20?String.fromCharCode(9312+(e-1)):`(${e})`}function oo(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 so(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 wr(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 Cr(e,t){const n=e.list;if(!n||n.kind!=="ordered")return;const r=t.next(n.numId??0,n.level),o=Ul(r,n.format),s=(n.format||"").toLowerCase();return!/enclosed|paren/.test(s)&&s!=="decimalleadingzero"?`${o}.`:o}function Xl(e){return e.map(t=>t.type==="image"?0:t.runs.length)}function Yl(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 Ql(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 Zl="_scroller_kqkmq_3",Jl={scroller:Zl},ea=h.forwardRef(function({className:t,style:n,...r},o){return v.jsx("div",{ref:o,className:`${Jl.scroller}${t?" "+t:""}`,style:n,...r})}),lr=e=>/[가-힣a-zA-Z0-9]/.test(e),ta=e=>((e==null?void 0:e.textContent)??"").trim(),un=(e,t)=>e.querySelector(`[data-g="${t}"]`);function na(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,m=1/0;const f=e.querySelectorAll("[data-g]");for(let b=0;b<f.length;b++){const S=f[b];if(!S||!S.isConnected)continue;const w=ta(S);if(!w||!lr(w))continue;const c=S.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<m||l!==-1&&Number(S.dataset.g)<l))&&(d=C,l=Number(S.dataset.g),m=c.top);continue}const p=Number(S.dataset.g);if(Number.isNaN(p))continue;c.top<a-n?(a=c.top,u=c.top,i=p):c.top<=a+n&&(c.top<u||c.top===u&&(i===-1||p<i))&&(u=c.top,i=p);const g=Math.abs(c.top-s);(g<d||g===d&&(c.top<m||l!==-1&&p<l))&&(d=g,l=p,m=c.top)}return i!==-1?i:l}const Ss=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},io=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}},ra=(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 oa(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 Pn=async(e,t,{topPaddingRatio:n=.15,behavior:r="smooth",quietMs:o=120}={})=>{if(!ra(e,t,{topPaddingRatio:n,behavior:r}))return!1;await oa(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,m=a.top-d;return Math.abs(m)<=1},ft=()=>new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>e())})}),Ir=h.createContext(null);function ys(){const e=h.useContext(Ir);if(!e)throw new Error("useQuizStoreApi must be used within QuizProgressProvider");return e}function Ue(e,t){const n=h.useContext(Ir);if(!n)throw new Error("useQuizStore must be used within QuizProgressProvider");return gn(n,e,t)}const ws=()=>{const e=q(l=>l.section),t=ys(),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 v.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&&v.jsxs("div",{style:{fontSize:"12px",fontWeight:400,marginTop:"4px",opacity:.8},children:["이미 풀었습니다 (",r.rate,"%)"]})]})},sa="_navBtn_1fciy_2",ia="_disabled_1fciy_26",la="_label_1fciy_32",Et={navBtn:sa,disabled:ia,label:la};var Cs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},lo=h.createContext&&h.createContext(Cs),aa=["attr","size","title"];function ca(e,t){if(e==null)return{};var n=ua(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 ua(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 ao(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?ao(Object(n),!0).forEach(function(r){da(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ao(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function da(e,t,n){return t=fa(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function fa(e){var t=pa(e,"string");return typeof t=="symbol"?t:t+""}function pa(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 Is(e){return e&&e.map((t,n)=>h.createElement(t.tag,fn({key:n},t.attr),Is(t.child)))}function qe(e){return t=>h.createElement(ga,dn({attr:fn({},e.attr)},t),Is(e.child))}function ga(e){var t=n=>{var{attr:r,size:o,title:s}=e,i=ca(e,aa),u=o||n.size||"1em",a;return n.className&&(a=n.className),e.className&&(a=(a?a+" ":"")+e.className),h.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&&h.createElement("title",null,s),e.children)};return lo!==void 0?h.createElement(lo.Consumer,null,n=>t(n)):t(Cs)}function co(e){return qe({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 uo(e){return qe({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 ha=({isIcon:e=!0})=>{const t=q(i=>i.isCanPrev),n=q(i=>i.onSectionNav),r=!t,o=h.useCallback(i=>{i.stopPropagation(),i.preventDefault(),t&&(n==null||n("prev"))},[t,n]),s=t?"이전 섹션으로":"이전 섹션 없음";return e?v.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:[v.jsx(co,{size:18}),v.jsx("span",{className:Et.label,children:"이전"})]}):v.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?"첫섹션입니다":v.jsxs(v.Fragment,{children:[v.jsx(co,{size:18,style:{display:"inline",marginRight:"8px",verticalAlign:"middle"}}),"PrevSection"]})})},pn=({isIcon:e=!0})=>{const t=q(i=>i.isCanNext),n=q(i=>i.onSectionNav),r=!t,o=h.useCallback(i=>{i.stopPropagation(),i.preventDefault(),t&&(n==null||n("next"))},[t,n]),s=t?"다음 섹션으로":"다음 섹션 없음";return e?v.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:[v.jsx(uo,{size:18}),v.jsx("span",{className:Et.label,children:"다음"})]}):v.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?"마지막섹션입니다":v.jsxs(v.Fragment,{children:["NextSection",v.jsx(uo,{size:18,style:{display:"inline",marginLeft:"8px",verticalAlign:"middle"}})]})})};function Ts(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 ma({section:e,blocks:t,nsPrefix:n}){const r=h.useMemo(()=>{const M=[],T=wr();return t.forEach((O,P)=>{O.type==="paragraph"&&(M[P]=Cr(O,T))}),M},[t]),o=q(M=>{var T;return((T=M.layout)==null?void 0:T.prefix)??[]}),s=q(M=>{var T;return((T=M.derivedNav)==null?void 0:T.splitGroupsPerBlock)??[]}),i=X(M=>M.marginX),u=X(M=>M.viewportHeight),a=h.useRef({start:0,end:0}),l=h.useCallback(M=>{const T=t[M],O=`${n}blk-${T.id}`;if(T.type==="image"){const{src:_,alt:z,width:N,height:A}=T,$=N&&A?`${N} / ${A}`:"4 / 3",te=M>=a.current.start&&M<=a.current.end,fe=u>80?Math.floor((u-80)*.6):void 0;return v.jsxs("div",{style:{margin:"12px 0",textAlign:"center",width:"100%"},children:[v.jsx("div",{style:{position:"relative",width:"100%",maxHeight:fe,aspectRatio:$},children:v.jsx("img",{src:_,alt:z||"",loading:te?"eager":"lazy",style:{pointerEvents:"none",position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"contain",display:"block"}})}),z&&v.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:z})]})}const P=r[M]??void 0,I=s[M];return v.jsx("div",{style:{maxWidth:860,display:"flex"},children:v.jsx(ql,{block:T,computedMarker:P,ns:O,baseIndex:o[M],sectionId:e.section_id,preGroups:I})})},[t,r,o,n,e,s,u]),d=h.useRef(null),m=h.useCallback(M=>{d.current=M},[]),f=h.useMemo(()=>h.memo(M=>{const{style:T,children:O,...P}=M;return v.jsx("div",{...P,style:T,children:v.jsx("div",{style:{boxSizing:"border-box",paddingRight:`${i}px`,paddingLeft:`${i}px`,maxWidth:860,margin:"0 auto",width:"100%",height:"100%"},children:O})})}),[i]),b=h.useRef(null),S=h.useMemo(()=>t.map(M=>M.id),[t]),[w,c]=h.useState(!1);h.useEffect(()=>{c(!1)},[t]);const p=h.useCallback(()=>{c(!0)},[]),g=h.useCallback(()=>{if(!w)return v.jsx("div",{style:{height:40}});const M=e.quizzes,T=Math.max(80,Math.floor(u*.5));return M&&M.length?v.jsxs("div",{style:{display:"block"},children:[v.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:v.jsx(ws,{})}),v.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:v.jsx(pn,{isIcon:!1})}),v.jsx("div",{style:{height:T,width:"100%"}})]}):v.jsxs("div",{children:[v.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:v.jsx(pn,{isIcon:!1})}),v.jsx("div",{style:{height:40}})]})},[w,e,u]),C=h.useMemo(()=>({Item:f,Header:()=>v.jsx("div",{style:{height:40}}),Footer:g,Scroller:ea}),[g,f]),k=h.useCallback(M=>S[M],[S]),R=pt(),[E]=h.useState(()=>R.getState().progress.currentGlobalRunIndex??0),x=h.useMemo(()=>{if(!o.length)return 0;const M=o[o.length-1],T=Math.max(0,Math.min(E,M));return Ts(o,T)},[o,E]);console.log("SectionRenderVirtuoso확인");const y=pt();return h.useEffect(()=>{let M=!1;return(async()=>{let T=d.current;if(!T){for(let _=0;_<20;_++){if(await new Promise(z=>setTimeout(z,50)),M)return;if(T=d.current,T)break}if(!T)return}const O=y.getState().progress.currentGlobalRunIndex,P=y.getState().progress.setSectionLoading,I=O!=null&&O>=0?O:0;await Ss(T,I),!M&&(await ft(),await ft(),await ft(),await ft(),!M&&P(!1))})(),()=>{M=!0}},[d,y]),v.jsxs(v.Fragment,{children:[v.jsx(al,{ref:b,style:{height:"100%",width:"100%",boxSizing:"border-box"},defaultItemHeight:99,computeItemKey:k,totalCount:t.length,itemContent:l,initialTopMostItemIndex:x,increaseViewportBy:{top:200,bottom:200},endReached:p,components:C,scrollerRef:m}),v.jsx(ba,{scrollContainerRef:d,virtRef:b,prefix:o})]})}const ba=({scrollContainerRef:e,virtRef:t,prefix:n})=>{const r=q(I=>I.setCurrentGlobalRunIndex),o=q(I=>I.registerSectionScrollApi),s=q(I=>I.currentGlobalRunIndex),i=Ce(I=>I.scrollLock),u=Ce(I=>I.syncToGI),a=ht(),l=h.useRef(!1),d=h.useRef(null),m=h.useRef(null),f=h.useRef(null),b=h.useRef(-1),S=h.useCallback(()=>{if(i)return;d.current=null;const I=m.current;if(!I)return;const _=na(I,5);_!==-1&&_!==b.current&&(b.current=_,u(_),r(_,"scroll"))},[i,u,r]),w=h.useCallback(I=>{m.current=I,d.current==null&&(d.current=requestAnimationFrame(S))},[S]),c=h.useCallback(I=>{m.current=I,f.current!=null&&(window.clearTimeout(f.current),f.current=null),f.current=window.setTimeout(()=>{f.current=null,S();const _=b.current;if(_===-1)return;const z=I.scrollTop,N=I.scrollHeight-I.clientHeight,A=N>0?z/N:0;let $=0;const te=I.querySelector(`[data-g="${_}"]`);if(te){const fe=I.getBoundingClientRect();$=(te.getBoundingClientRect().top-fe.top)/fe.height}a.getState().emit({type:"scroll",payload:{scrollTop:z,scrollRatio:A,anchorGI:_,anchorOffsetRatio:$}})},100)},[S,a]),p=h.useRef(!1),g=h.useCallback(I=>{i||l.current&&(p.current||(w(I),c(I)))},[i,w,c]),C=h.useRef(void 0),k=h.useRef(void 0),R=h.useRef(void 0),E=h.useRef(void 0);h.useEffect(()=>{const I=e.current;if(I)return C.current=()=>{l.current=!0},k.current=()=>{l.current=!0},R.current=()=>{l.current=!0},E.current=()=>g(I),I.addEventListener("wheel",C.current,{passive:!0}),I.addEventListener("touchmove",k.current,{passive:!0}),window.addEventListener("keydown",R.current,{passive:!0}),I.addEventListener("scroll",E.current,{passive:!0}),()=>{I.removeEventListener("wheel",C.current),I.removeEventListener("touchmove",k.current),window.removeEventListener("keydown",R.current),I.removeEventListener("scroll",E.current),d.current!=null&&cancelAnimationFrame(d.current),f.current!=null&&(clearTimeout(f.current),f.current=null)}},[g,e]),h.useEffect(()=>{const I=e.current;if(!I||!i)return;const _=$=>{$.preventDefault(),$.stopPropagation(),l.current=!1},z=$=>{$.preventDefault(),$.stopPropagation(),l.current=!1},N=$=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes($.key)&&($.preventDefault(),$.stopPropagation(),l.current=!1)},A={overscrollBehavior:I.style.overscrollBehavior,touchAction:I.style.touchAction};return I.style.overscrollBehavior="contain",I.style.touchAction="none",I.addEventListener("wheel",_,{passive:!1}),I.addEventListener("touchmove",z,{passive:!1}),window.addEventListener("keydown",N,{passive:!1}),()=>{I.removeEventListener("wheel",_),I.removeEventListener("touchmove",z),window.removeEventListener("keydown",N),I.style.overscrollBehavior=A.overscrollBehavior,I.style.touchAction=A.touchAction}},[i,e]);const x=h.useRef({first:-1,last:-1}),y=h.useRef(!1),M=h.useCallback(()=>{const I=e.current;if(!I)return;const _=io(I),z=(_==null?void 0:_.first)??-1,N=(_==null?void 0:_.last)??-1;x.current={first:z,last:N}},[e]),T=h.useRef(!1),O=h.useCallback(()=>{const I=e.current;if(!I||T.current)return;T.current=!0;const _=Math.min(I.scrollTop+Math.floor(I.clientHeight*.6),I.scrollHeight-I.clientHeight);requestAnimationFrame(()=>{I.scrollTo({top:_,behavior:"instant"})})},[e]);h.useEffect(()=>{!y.current&&i&&(T.current=!1,M()),y.current=i},[i,M]),h.useEffect(()=>{if(i!==!0)return;const I=e.current;if(!I)return;const{first:_,last:z}=x.current;if(_===-1||z===-1){O();return}if(I.scrollTop<=1){(async()=>{try{p.current=!0,await Pn(I,s,{behavior:"smooth",topPaddingRatio:.2})}finally{p.current=!1}M()})();return}if(s<_||s>z){async function A(){if(!I)return;const $=I.scrollTop<=1?0:.2;return await Pn(I,s,{behavior:"smooth",topPaddingRatio:$})}A().then($=>{$?M():O()})}},[i,s,O,M,e]);const P=h.useCallback(()=>{const I=e.current;if(!I)return;function _(L,j,G=.2,V=.8){const B=L.querySelector(`[data-g="${j}"]`);if(!B)return!1;const Z=L.getBoundingClientRect(),F=B.getBoundingClientRect();if(F.height<=0||Z.height<=0)return!1;const Y=(F.top+F.height/2-Z.top)/Z.height;return Y>=G&&Y<=V}const z=L=>L==="instant"?"auto":L,N=L=>{const j=I.scrollTop,G=I.scrollHeight-I.clientHeight,V=G>0?j/G:0;let B=0;const Z=I.querySelector(`[data-g="${L}"]`);if(Z){const F=I.getBoundingClientRect();B=(Z.getBoundingClientRect().top-F.top)/F.height}a.getState().emit({type:"scroll",payload:{scrollTop:j,scrollRatio:V,anchorGI:L,anchorOffsetRatio:B}})},A=async(L,j="smooth")=>{var V;const G=Ts(n,L);(V=t.current)==null||V.scrollToIndex({index:G,align:"start",behavior:z(j)}),await Ss(I,L)},$=()=>new Promise(L=>requestAnimationFrame(()=>L())),te=async L=>{if(_(I,L,.1,.7))return N(L),!0;p.current=!0;const j=I.querySelector(`[data-g="${L}"]`),G=I.getBoundingClientRect();let V=I.scrollTop<=1?0:.1;if(j){const Z=j.getBoundingClientRect();V=((Z.top+Z.height/2-G.top)/G.height>.5,.15)}const B=!!j;return B?(await Pn(I,L,{behavior:"smooth",topPaddingRatio:V}),await $()):B||await A(L,"auto"),p.current=!1,N(L),_(I,L,.1,.7)},fe=async L=>te(L);return{ensureVisibleGI:te,scrollToGI:fe,getVisibleRange:()=>io(I),getScrollTop:()=>I.scrollTop,setScrollTop:L=>{I.scrollTop=L},getAnchorOffsetRatio:L=>{const j=I.querySelector(`[data-g="${L}"]`);if(!j)return 0;const G=j.getBoundingClientRect(),V=I.getBoundingClientRect();return(G.top-V.top)/V.height},scrollToGIAtOffset:async(L,j)=>{await fe(L),await new Promise(J=>requestAnimationFrame(()=>requestAnimationFrame(J)));const G=I.querySelector(`[data-g="${L}"]`);if(!G)return;const V=G.getBoundingClientRect(),B=I.getBoundingClientRect(),Z=B.height>0?B.height/I.clientHeight:1,F=(V.top-B.top)/Z,Y=j*I.clientHeight,ee=F-Y;I.scrollTop=I.scrollTop+ee},getScrollRatio:()=>{const L=I.scrollHeight-I.clientHeight;return L>0?I.scrollTop/L:0}}},[e,t,n,a]);return h.useEffect(()=>(console.log("@@@@@빌드스크롤api"),o(P()),()=>o(void 0)),[P,o]),null};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=q(S=>S.section),t=X(S=>S.theme),n=X(S=>S.fontFamily),r=X(S=>S.fontSizePx),o=X(S=>S.lineHeight),s=sn[t],{blocks:i,nsPrefix:u}=h.useMemo(()=>({sectionId:e.section_id,blocks:e.ast.blocks,nsPrefix:`sec-${e.section_id??"0"}/`}),[e]),a=hn(),l=h.useCallback(()=>{const{isSettingsOpen:S,setSettingsOpen:w,toggleOverlays:c}=a.getState();S?w(!1):c()},[a]),{onClick:d,onDoubleClick:m}=Ys({onSingle:l,onDouble:()=>{},delay:250,shouldIgnoreTarget:xa}),f=h.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]),b=h.useMemo(()=>({margin:"0 auto",width:"100%",height:"100%"}),[]);return console.log("ScrollSectionWrap render"),v.jsx("div",{onClick:d,onDoubleClick:m,style:f,children:v.jsx("div",{style:b,children:v.jsx(ma,{section:e,blocks:i,nsPrefix:u})})})}function Sa(e){return qe({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 qe({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 qe({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 qe({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 qe({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 qe({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 qe({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",Pa="_groupPlayback_1hfub_81",Aa="_groupSpeed_1hfub_82",Ba="_groupFeatures_1hfub_83",La="_groupNav_1hfub_84",Ga="_btn_1hfub_116",Ha="_btnForbidden_1hfub_141",Na="_btnActive_1hfub_147",Fa="_label_1hfub_158",Da="_compactBtn_1hfub_168",we={wrap:Ra,visible:_a,compact:Ma,row2:Ea,controls:ja,row1:Oa,groupExpand:za,groupPlayback:Pa,groupSpeed:Aa,groupFeatures:Ba,groupNav:La,btn:Ga,btnForbidden:Ha,btnActive:Na,label:Fa,compactBtn:Da},Wa=h.memo(function(){const t=h.useRef(null),n=h.useContext(wt),r=(n==null?void 0:n.getState().isPlaybackMode)??!1,o=Ce(y=>y.status),s=Ce(y=>y.currentTimeMs),i=Ce(y=>y.currentClip),u=Ce(y=>y.playbackKind),a=X(y=>y.muteAudio),l=X(y=>y.audioSpeed),d=Ce(y=>y.getClipSrc),m=Ce(y=>y._onTime),f=Ce(y=>y._onEnded),b=Ce(y=>y._onError),S=q(y=>y.setCurrentGlobalRunIndex),w=q(y=>y.getSectionScrollApi),c=q(y=>y.snapToReadable),p=q(y=>y.edgeReadable),g=h.useRef(null),C=h.useRef(null),k=h.useRef(!1),R=h.useRef(null);h.useEffect(()=>{u==="real"&&(k.current=!0)},[u]);const E=h.useMemo(()=>{const y=d(i);if(!y)return null;try{return new URL(y,window.location.href).href}catch{return y}},[i,d]);h.useEffect(()=>{k.current=!0},[E]),h.useEffect(()=>{const y=t.current;if(!y)return;const M=()=>{if(y.paused||y.ended)return;const P=y.currentTime*1e3;k.current&&P===0||(P>0&&(k.current=!1),m(P))},T=()=>{var I,_;f();const P=p(1);typeof P=="number"&&P>=0&&(S(P,"audio"),(_=(I=w())==null?void 0:I.ensureVisibleGI)==null||_.call(I,P))},O=P=>{const I=P.currentTarget;console.warn("Audio error",{networkState:I.networkState,readyState:I.readyState}),b()};return y.addEventListener("timeupdate",M),y.addEventListener("ended",T),y.addEventListener("error",O),()=>{y.removeEventListener("timeupdate",M),y.removeEventListener("ended",T),y.removeEventListener("error",O)}},[m,f,b,p,S,w]),h.useEffect(()=>{if(r)return;const y=t.current;if(!y)return;if(!E){try{y.pause()}catch(P){console.log("pause error",P)}C.current=null;return}const M=y.currentSrc||y.src||null,T=!M||M!==E;if(T){try{y.pause()}catch(P){console.log("pause error",P)}y.src=E;try{y.load()}catch(P){console.log("load error",P)}C.current=E}y.muted=!!a,y.volume=1,y.playbackRate=typeof l=="number"?l:1;const O=async()=>{T&&await new Promise(P=>{let I=!1;const _=()=>{I||(I=!0,y.removeEventListener("loadedmetadata",_),y.removeEventListener("canplay",_),P())};y.addEventListener("loadedmetadata",_),y.addEventListener("canplay",_),y.readyState>=1&&_()});try{await y.play()}catch(P){console.warn("el.play() failed",P)}};if(o==="loading"||o==="playing")O();else try{y.pause()}catch(P){console.log("pause error",P)}},[E,a,o,l,r]),h.useEffect(()=>{if(r)return;const y=t.current;if(!y||u!=="real")return;const M=s/1e3;if(Number.isFinite(M)){if(y.readyState<1){g.current=s;const T=()=>{if(g.current!=null){const O=g.current/1e3;try{y.currentTime=O}catch(P){console.log("currentTime보정 오류",P)}g.current=null}y.removeEventListener("loadedmetadata",T),y.removeEventListener("canplay",T)};y.addEventListener("loadedmetadata",T),y.addEventListener("canplay",T);return}if(Math.abs(y.currentTime-M)>.2)try{y.currentTime=M}catch(T){console.log("currentTime보정오류",T)}}},[s,u,r]);const x=Ce(y=>y.getGIFromCT);return h.useEffect(()=>{var T,O;if(r||u!=="real"||o!=="playing"&&o!=="loading")return;const y=x(i,s);if(y<0)return;const M=c(y);M!==R.current&&(R.current=M,S(M,"audio"),M%5===0&&((O=(T=w())==null?void 0:T.ensureVisibleGI)==null||O.call(T,M)))},[o,i,s,u,x,c,S,w,r]),v.jsx("audio",{ref:t,preload:"auto",style:{display:"none"}})});function $a(){return v.jsx(Wa,{})}const Va="_scrubberWrap_uw0cd_2",qa="_labels_uw0cd_9",Ua="_index_uw0cd_15",Ka="_controls_uw0cd_19",Xa="_percent_uw0cd_25",Ya="_range_uw0cd_46",kt={scrubberWrap:Va,labels:qa,index:Ua,controls:Ka,percent:Xa,range:Ya};function Qa(){const e=X(R=>R.isDev),t=q(R=>R.currentGlobalRunIndex),n=q(R=>R.totalRuns),r=q(R=>R.setCurrentGlobalRunIndex),o=q(R=>R.getSectionScrollApi),s=q(R=>R.giToPercentTotal),i=q(R=>R.percentToGITotal),u=q(R=>R.snapToReadable),a=Ce(R=>R.scrollLock),l=Ce(R=>R.pause),d=Ce(R=>R.play),m=Ce(R=>R.syncToGI),[f,b]=h.useState(()=>s(t||0));h.useEffect(()=>{b(s(t||0))},[t,s]);const S=h.useRef(!1),w=h.useMemo(()=>Math.max(0,Math.min(t??0,Math.max(0,(n??1)-1)))+1,[t,n]),c=h.useCallback(()=>{a&&(l(),S.current=!0)},[a,l]),p=h.useCallback(R=>{b(Number(R.currentTarget.value))},[]),g=h.useCallback(async()=>{const R=i(f),E=u(R);l(),r(E,"scrubber-commit"),m(E);const x=o();x!=null&&x.ensureVisibleGI&&await x.ensureVisibleGI(E),S.current&&(S.current=!1,d())},[f,i,u,l,r,m,o,d]),C=h.useMemo(()=>({"--pct":`${f}%`}),[f]),k=h.useMemo(()=>Math.round(f),[f]);return v.jsxs("div",{className:kt.scrubberWrap,children:[e&&v.jsx("div",{className:kt.labels,children:v.jsxs("span",{className:kt.index,children:[w," / ",n||0]})}),v.jsxs("div",{className:kt.controls,children:[v.jsx("input",{type:"range",className:kt.range,min:0,max:100,step:.5,value:f,style:C,onMouseDown:c,onTouchStart:c,onChange:p,onMouseUp:()=>{g()},onTouchEnd:()=>{g()},onKeyUp:R=>R.key==="Enter"||R.key===" "?void g():void 0,"aria-label":"진행률"}),v.jsxs("span",{className:kt.percent,children:[k,"%"]})]})]})}const Za=h.memo(Qa),Ja=h.memo(function(){const t=h.useContext(wt),n=(t==null?void 0:t.getState().isPlaybackMode)??!1,r=Ce(y=>y.playbackKind),o=Ce(y=>y.status),s=Ce(y=>y.fake),i=X(y=>y.audioSpeed),u=Ce(y=>y.pause),a=q(y=>y.totalRuns),l=q(y=>y.currentGlobalRunIndex),d=q(y=>y.setCurrentGlobalRunIndex),m=q(y=>y.getSectionScrollApi),f=q(y=>y.nextReadableFrom),b=q(y=>y.edgeReadable),S=h.useRef(null),w=h.useRef(null),c=h.useRef(0),p=h.useRef(-1),g=!n&&r==="fake"&&o==="playing",C=Math.max(1,(s==null?void 0:s.totalWords)??1),k=h.useMemo(()=>{const y=200*i;return C/y*6e4},[C,i]),R=h.useMemo(()=>!a||a<=1||k<=0?0:(a-1)/k,[a,k]);h.useEffect(()=>{if(!g)return;const y=Math.max(0,Math.min(l??0,Math.max(0,(a??1)-1)));c.current=y,p.current=y,w.current=null},[g,l,a]);const E=h.useRef(-1);h.useEffect(()=>{if(!a){E.current=-1;return}const y=b(1);E.current=y??-1},[b,a]);const x=h.useCallback(y=>{(async()=>{var N,A;if(!g){S.current=null;return}if(!a||a<=1||R<=0){S.current=null;return}const M=w.current;w.current=y;const T=M==null?0:Math.max(0,y-M),O=a-1;c.current=Math.min(O,c.current+R*T);const P=Math.floor(c.current),I=m(),_=f(P,1);if(_==null){const $=E.current>=0?E.current:P;$!==p.current&&(p.current=$,d($,"audio"),await((N=I==null?void 0:I.ensureVisibleGI)==null?void 0:N.call(I,$))),u(),S.current=null;return}const z=_;z!==p.current&&(p.current=z,d(z,"audio"),z%5===0&&await((A=I==null?void 0:I.ensureVisibleGI)==null?void 0:A.call(I,z))),S.current=requestAnimationFrame(x)})().catch(console.error)},[g,a,R,f,d,m,u]);return h.useEffect(()=>(g?S.current==null&&(S.current=requestAnimationFrame(x)):(S.current&&(cancelAnimationFrame(S.current),S.current=null),w.current=null),()=>{S.current&&(cancelAnimationFrame(S.current),S.current=null)}),[g,x]),null}),ec=h.memo(function(){return v.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",Pt={WPMSpeedButtonsWrap:rc,btnWrap:oc,label:sc,iconBtn:ic},fo=350,lc=40,ac=.85,cc=h.memo(function(){const t=X(f=>f.audioSpeed),n=X(f=>f.incAudioSpeed),r=X(f=>f.decAudioSpeed),o=h.useRef(null),s=h.useRef(fo),i=h.useRef(null),u=h.useCallback(f=>{const b=t;if(f==="inc"){if(b>=2)return!1;n()}else{if(b<=.3)return!1;r()}return!0},[t,n,r]),a=h.useCallback(()=>{i.current=null,o.current&&(clearTimeout(o.current),o.current=null)},[]),l=h.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=h.useCallback(f=>{if(i.current)return;i.current=f,s.current=fo,u(f)&&l();const S=()=>a();window.addEventListener("mouseup",S,{once:!0}),window.addEventListener("touchend",S,{once:!0})},[l,u,a]);h.useEffect(()=>a,[a]);const m=`${(t*100).toFixed(0)}%`;return v.jsx("div",{onMouseLeave:a,className:Pt.WPMSpeedButtonsWrap,children:v.jsxs("div",{className:Pt.btnWrap,children:[v.jsx("button",{className:Pt.iconBtn,type:"button",title:"속도 느리게",onMouseDown:()=>d("dec"),onTouchStart:f=>{f.preventDefault(),d("dec")},onMouseUp:a,children:v.jsx("img",{src:tc,alt:"느리게"})}),v.jsx("div",{className:Pt.label,style:{minWidth:"44px",textAlign:"center"},children:v.jsx("div",{children:m})}),v.jsx("button",{className:Pt.iconBtn,type:"button",title:"속도 빠르게",onMouseDown:()=>d("inc"),onTouchStart:f=>{f.preventDefault(),d("inc")},onMouseUp:a,children:v.jsx("img",{src:nc,alt:"빠르게"})})]})})}),uc="_StepBtn_15t0r_1",dc={StepBtn:uc};function fc(e){return qe({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 qe({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 po({direction:e}){const t=q(m=>m.currentGlobalRunIndex),n=q(m=>m.totalRuns),r=q(m=>m.hasReadableInDir),o=q(m=>m.computeStepTarget),s=q(m=>m.setCurrentGlobalRunIndex),i=Ce(m=>m.syncToGI),u=q(m=>m.getSectionScrollApi),a=h.useCallback(async m=>{var S,w;const f=Math.max(t,Math.min(0,Math.max(0,(n??1)-1))),b=o(f,m);s(b,"scrubber-step"),i(b),await((w=(S=u())==null?void 0:S.ensureVisibleGI)==null?void 0:w.call(S,b))},[t,n,o,s,i,u]),l=h.useMemo(()=>{const m=Math.max(t,Math.min(0,Math.max(0,(n??1)-1))),f=!n||!r(m,1),b=!n||!r(m,-1);return e==="left"?b:f},[e,n,t,r]),d=h.useCallback(()=>{a(e==="left"?-1:1)},[e,a]);return v.jsx("button",{className:dc.StepBtn,type:"button",onClick:d,disabled:l,title:e==="left"?"이전":"다음",children:e==="left"?v.jsx(fc,{}):v.jsx(pc,{})})}const gc="_GCPlayBtn_n54mc_1",hc="_playing_n54mc_34",go={GCPlayBtn:gc,playing:hc},mc=({size:e=60,color:t="#333",bgColor:n="#fff",isPlaying:r,onClick:o,tooltip:s="재생",title:i=""})=>v.jsx("button",{className:`${go.GCPlayBtn} ${r?go.playing:""}`,onClick:o,"data-tip":s,title:i,style:{"--btn-size":`${e}px`,"--icon-color":t,"--btn-bg":n}});function bc(e){return qe({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 qe({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(T=>T.showOverlays),t=q(T=>T.section),n=!!t.ast.isAddedSplit,r=!!((M=t.audios)!=null&&M.length),o=q(T=>T.canTracking),s=q(T=>T.canToggleShowGaze),i=q(T=>T.showGaze),u=q(T=>T.onToggleShowGaze),a=X(T=>T.muteAudio),l=X(T=>T.showPointer),d=X(T=>T.showSplit),m=X(T=>T.toggleMuteAudio),f=X(T=>T.toggleShowPointer),b=X(T=>T.toggleShowSplit),S=X(T=>T.overlayCompactMode),w=X(T=>T.toggleOverlayCompactMode),c=cn(),p=pt();h.useEffect(()=>{const T=c.getState(),{syncToGI:O,useFake:P,useReal:I}=T,_=T.playbackKind,z=p.getState().progress.currentGlobalRunIndex??0;if(!r){_!=="fake"&&P();return}a?_!=="fake"&&(console.log("이부분일까?"),P()):_!=="real"&&(O(z),I())},[r,a,p,c]);const g=Ce(T=>T.play),C=Ce(T=>T.pause),k=Ce(T=>T.status),R=h.useCallback(T=>{T.stopPropagation(),k==="playing"||k==="loading"?C():g()},[k,g,C]),E=cn(),x=pt(),y=h.useCallback(async T=>{var me,Ae;if(T.stopPropagation(),k==="playing"||k==="loading"){C();return}const{progress:O}=x.getState(),{currentGlobalRunIndex:P,snapToReadable:I,edgeReadable:_,setCurrentGlobalRunIndex:z,getSectionScrollApi:N}=O,A=E.getState(),$=A.currentClip,te=N==null?void 0:N(),fe=typeof P=="number"?P:0,ge=typeof I=="function"?I(fe):fe,ve=typeof _=="function"?_(1):null;if(ve!=null&&ge>=ve){z==null||z(ve,"audio"),await((me=te==null?void 0:te.ensureVisibleGI)==null?void 0:me.call(te,ve)),A.syncToGI(ve);return}z==null||z(ge,"audio"),await((Ae=te==null?void 0:te.ensureVisibleGI)==null?void 0:Ae.call(te,ge)),A.syncToGI(ge),g($)},[k,C,g,E,x]);return v.jsxs("div",{className:`${we.wrap} ${e?we.visible:""} ${S?we.compact:""}`,onClick:T=>{T.stopPropagation()},onTouchStart:T=>{T.stopPropagation()},children:[!S&&v.jsx(Za,{}),v.jsx("div",{style:S?{display:"none"}:void 0,children:r&&!a?v.jsx($a,{}):v.jsx(ec,{})}),v.jsxs("div",{className:we.controls,children:[v.jsxs("div",{className:we.row1,children:[v.jsx("div",{className:we.groupExpand,children:v.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),w()},className:we.compactBtn,title:S?"오버레이 확대":"오버레이 축소",children:S?v.jsx(xc,{size:24}):v.jsx(bc,{size:24})})}),v.jsxs("div",{className:we.groupPlayback,children:[v.jsx(po,{direction:"left"}),v.jsx(mc,{size:34,isPlaying:k==="playing",onClick:a?y:R,title:k==="playing"?"일시정지":"재생"}),v.jsx(po,{direction:"right"})]}),v.jsx("div",{className:we.groupSpeed,children:v.jsx(cc,{})})]}),v.jsxs("div",{className:we.row2,children:[v.jsxs("div",{className:we.groupFeatures,children:[r&&v.jsxs("button",{type:"button",onClick:T=>{T.stopPropagation(),m()},className:`${we.btn} ${a?"":we.btnActive}`,title:"오디오북 음소거 전환",children:[a?v.jsx(Sa,{size:18}):v.jsx(ya,{size:18}),v.jsx("span",{className:we.label,children:"오디오북"})]}),v.jsxs("button",{type:"button",onClick:T=>{T.stopPropagation(),f()},className:`${we.btn} ${l?we.btnActive:""}`,title:"포인터 표시",children:[v.jsx(wa,{size:18}),v.jsx("span",{className:we.label,children:"포인터"})]}),n&&v.jsxs("button",{type:"button",onClick:T=>{T.stopPropagation(),b()},disabled:!n,className:`${we.btn} ${d?we.btnActive:""} ${n?"":we.btnForbidden}`,title:"끊어읽기 표시",children:[v.jsx(Ca,{size:18}),v.jsx("span",{className:we.label,children:"끊어읽기"})]}),v.jsxs("button",{type:"button",onClick:T=>{T.stopPropagation(),u==null||u()},disabled:!o||!s,className:`${we.btn} ${o&&i?we.btnActive:""} ${o?"":we.btnForbidden}`,title:"시선 표시",children:[v.jsx(Ta,{size:18}),v.jsx("span",{className:we.label,children:"시선"})]})]}),v.jsxs("div",{className:we.groupNav,children:[v.jsx(ha,{}),v.jsx(pn,{})]})]})]})]})}const Sc=h.memo(vc);function yc(e){return qe({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",dt={host:wc,topbar:Cc,visible:Ic,backBtn:Tc,title:kc,calibrationBtn:Rc,disabled:_c,settingsBtn:Mc};function Ec(){const e=X(m=>m.showOverlays),t=X(m=>m.overlayCompactMode),n=q(m=>m.onViewerClose),o=q(m=>m.section).ast.title,s=q(m=>m.canTracking),i=q(m=>m.handleAskCalibration),u=X(m=>m.setSettingsOpen),a=X(m=>m.setShowOverlays),l=h.useCallback(()=>{n==null||n()},[n]),d=h.useCallback(()=>{u(!0),a(!1)},[u,a]);return v.jsx("div",{className:dt.host,children:v.jsxs("div",{className:`${dt.topbar} ${e&&!t?dt.visible:""}`,children:[v.jsx("button",{type:"button",className:dt.backBtn,onClick:l,"aria-label":"뒤로가기",children:v.jsx(Ia,{size:28})}),v.jsx("div",{className:dt.title,children:v.jsx("span",{className:"truncate",children:o||"섹션 없음"})}),v.jsx("button",{type:"button",className:`${dt.calibrationBtn} ${s?"":dt.disabled}`,onClick:i,disabled:!s,"aria-label":"시선보정",title:"시선보정",children:v.jsx(ka,{size:24})}),v.jsx("button",{type:"button",className:dt.settingsBtn,onClick:d,"aria-label":"뷰어 설정",children:v.jsx(yc,{size:28})})]})})}const jc=h.memo(Ec),Oc="_wrap_62su0_7",zc="_wrapHidden_62su0_29",Pc="_wrapVisible_62su0_35",Ac="_scrollArea_62su0_71",Bc="_row_62su0_81",Lc="_label_62su0_89",Gc="_btn_62su0_95",Hc="_btnActive_62su0_106",Nc="_btnSmall_62su0_110",Fc="_pill_62su0_122",Dc="_themeCircle_62su0_133",Wc="_themeCircleActive_62su0_146",$c="_stepRow_62su0_151",Vc="_stepLabel_62su0_159",qc="_levelBox_62su0_172",Uc="_inlineFlex_62su0_177",Me={wrap:Oc,wrapHidden:zc,wrapVisible:Pc,scrollArea:Ac,row:Bc,label:Lc,btn:Gc,btnActive:Hc,btnSmall:Nc,pill:Fc,themeCircle:Dc,themeCircleActive:Wc,stepRow:$c,stepLabel:Vc,levelBox:qc,inlineFlex:Uc};function Kc({visible:e}){const t=X(x=>x.mode),n=X(x=>x.setMode),r=X(x=>x.theme),o=X(x=>x.setTheme),s=X(x=>x.fontFamily),i=X(x=>x.setFontFamily),u=X(x=>x.resetToDefaults),a=X(x=>x.getFontLevel()),l=X(x=>x.getLineLevel()),d=X(x=>x.getMarginLevel()),m=X(x=>x.setFontLevel),f=X(x=>x.setLineLevel),b=X(x=>x.setMarginLevel),S=X(x=>x.pointerStyle),w=X(x=>x.setPointerStyle),c=X(x=>x.pointerColor),p=X(x=>x.setPointerColor),g=X(x=>x.breakMarks),C=X(x=>x.toggleBreakMark),k=X(x=>x.getBreakGapLevel()),R=X(x=>x.setBreakGapLevel),E=`${Me.wrap} ${e?Me.wrapVisible:Me.wrapHidden}`;return v.jsxs("div",{className:E,role:"dialog","aria-modal":"true","aria-label":"뷰어 설정",children:[v.jsxs("div",{className:Me.scrollArea,children:[v.jsx(At,{label:"열람방식",children:v.jsxs("div",{className:Me.inlineFlex,children:[v.jsx(Rt,{active:t==="page",onClick:()=>n("page"),children:"페이지"}),v.jsx(Rt,{active:t==="scroll",onClick:()=>n("scroll"),children:"스크롤"})]})}),v.jsx(At,{label:"테마",children:v.jsx("div",{className:Me.inlineFlex,children:Object.keys(sn).map(x=>{const y=x,M=sn[y];return v.jsx("button",{type:"button",onClick:()=>o(y),className:`${Me.themeCircle} ${r===x?Me.themeCircleActive:""}`,style:{background:M.bg,color:M.fg,fontFamily:s},title:String(x),"aria-label":`테마: ${String(x)}`,children:"A"},`${x}_tc_button`)})})}),v.jsx(At,{label:"글꼴",children:v.jsx("div",{className:Me.inlineFlex,children:Go.map(x=>v.jsx(Rt,{active:s===x.value,onClick:()=>i(x.value),title:x.value,children:x.label},x.label))})}),v.jsx(tn,{label:"글자 크기",level:a,min:1,max:12,onDec:()=>m(Math.max(1,a-1)),onInc:()=>m(Math.min(12,a+1))}),v.jsx(tn,{label:"줄 간격",level:l,min:1,max:7,onDec:()=>f(Math.max(1,l-1)),onInc:()=>f(Math.min(7,l+1))}),v.jsx(tn,{label:"여백",level:d,min:1,max:5,onDec:()=>b(Math.max(1,d-1)),onInc:()=>b(Math.min(5,d+1))}),v.jsx(At,{label:"포인터",children:v.jsxs("div",{className:Me.inlineFlex,children:[v.jsx(Rt,{active:S==="highlight",onClick:()=>w("highlight"),children:"형광펜"}),v.jsx(Rt,{active:S==="underline",onClick:()=>w("underline"),children:"밑줄"}),v.jsx("input",{type:"color",value:c,onChange:x=>p(x.target.value),"aria-label":"포인터 색상",style:{width:36,height:28,padding:0,border:"none",background:"transparent"}})]})}),v.jsx(At,{label:"끊기표시",children:v.jsx("div",{className:Me.inlineFlex,children:v.jsx(Rt,{active:g.slash,onClick:()=>C("slash"),children:"슬래쉬"})})}),v.jsx(tn,{label:"끊기간격",level:k,min:1,max:5,onDec:()=>R(Math.max(1,k-1)),onInc:()=>R(Math.min(5,k+1))})]}),v.jsx("div",{className:Me.inlineFlex,style:{justifyContent:"center"},children:v.jsx("button",{type:"button",onClick:u,className:Me.pill,children:"보기 설정 초기화"})})]})}function At({label:e,children:t}){return v.jsxs("div",{className:Me.row,children:[v.jsx("label",{className:Me.label,children:e}),t]})}function Rt({active:e,onClick:t,title:n,children:r}){return v.jsx("button",{type:"button",onClick:t,title:n,className:`${Me.btn} ${e?Me.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 v.jsxs("div",{className:Me.stepRow,children:[v.jsx("label",{className:Me.stepLabel,children:e}),v.jsxs("div",{className:Me.inlineFlex,children:[v.jsx("button",{type:"button",onClick:o,disabled:i,className:Me.btnSmall,"aria-label":"감소",children:"−"}),v.jsx("div",{className:Me.levelBox,children:t}),v.jsx("button",{type:"button",onClick:s,disabled:u,className:Me.btnSmall,"aria-label":"증가",children:"+"})]})]})}const Xc=h.memo(function(){const t=X(i=>i.showOverlays),n=X(i=>i.isSettingsOpen),r=q(i=>i.rangeStartGI),o=q(i=>i.rangeEndGI);return r!=null&&o!=null?null:v.jsxs("div",{"aria-hidden":!0,style:{pointerEvents:"none",position:"absolute",inset:0,containerType:"size",containerName:"viewer"},children:[v.jsx(jc,{}),v.jsx(Sc,{}),v.jsx("div",{style:{pointerEvents:"auto"},children:v.jsx(Kc,{visible:!t&&n})})]})}),Yc=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 m=i(r.getState());l=f=>{const b=i(f);if(!d(m,b)){const S=m;u(m=b,S)}},a!=null&&a.fireImmediately&&u(m,m)}return o(l)}),e(t,n,r)},Qc=Yc;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=b=>{if(!n)return null;const{g2ct:S}=n;if(!S)return null;const w=S[b];if(w)return{clip:w.clip,t:w.t};for(let c=1;c<=100&&b-c>=0;c++){const p=S[b-c];if(p)return{clip:p.clip,t:p.t}}for(let c=1;c<=100;c++){const p=S[b+c];if(p)return{clip:p.clip,t:p.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 b=o(e.initialIndex);b&&(i=b.clip,u=b.t,r=void 0)}const l=s.length>0,d=l?"paused":"idle",m=l?"real":"fake",f=l?null:{totalWords:a};return qt(Qc((b,S)=>({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:m,fake:f,useFake:()=>b(w=>({playbackKind:"fake",fake:{totalWords:a},scrollLock:w.status==="playing"})),useReal:()=>b(w=>({playbackKind:"real",fake:{totalWords:a},scrollLock:w.status==="playing"})),injectMap:w=>{if(n=w,typeof r=="number"){const c=o(r);c&&b(p=>({currentClip:Math.max(0,Math.min(c.clip,Math.max(0,p.clips.length-1))),currentTimeMs:Math.max(0,c.t)})),r=void 0}},setClipAndMs:(w,c)=>b(p=>{const g=Math.max(0,p.clips.length-1);return{currentClip:Math.max(0,Math.min(w,g)),currentTimeMs:Math.max(0,c),status:p.status,scrollLock:p.scrollLock}}),setClips:w=>b(c=>{const p=Array.isArray(w)?w:[],g=p.length>0;return{clips:p,currentClip:0,currentTimeMs:0,status:g?"paused":"idle",playbackKind:g?"real":"fake",fake:g?null:c.fake??{totalWords:a},scrollLock:!1}}),clear:()=>b(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"}}),b(p=>{if(p.playbackKind==="fake")return{status:"playing",scrollLock:!0};const g=typeof w=="number"?w:p.currentClip,C=typeof c=="number"?c:p.currentTimeMs;return{status:"loading",currentClip:Math.max(0,Math.min(g,Math.max(0,p.clips.length-1))),currentTimeMs:C,scrollLock:!0}})},pause:()=>{t==null||t.getState().emit({type:"audio_control",payload:{action:"pause"}}),b({status:"paused",scrollLock:!1})},seek:w=>b(c=>({currentTimeMs:Math.max(0,w),status:c.status})),stop:()=>b({status:"idle",currentTimeMs:0,scrollLock:!1}),nextClip:()=>b(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:()=>b(w=>w.playbackKind==="fake"?w:{currentClip:Math.max(0,w.currentClip-1),currentTimeMs:0,status:"loading",scrollLock:!0}),setClipIndex:w=>b(c=>c.playbackKind==="fake"||w<0||w>=c.clips.length?c:{currentClip:w,currentTimeMs:0}),getClipSrc:w=>{const c=S();if(!c.clips.length)return null;const p=typeof w=="number"?w:c.currentClip;return Zc(c.clips[p])},getGIFromCT:(w,c)=>{if(!n)return-1;const p=n.byClip[w];if(!p||p.length===0)return-1;let g=0,C=p.length-1,k=0;for(;g<=C;){const R=g+C>>1;p[R].t<=c?(k=R,g=R+1):C=R-1}return p[Math.max(0,Math.min(k,p.length-1))].g},getCTFromGI:w=>{if(!n)return null;const{g2ct:c}=n;if(!c)return null;let p=c[w];if(!p){let g=w-1;const C=Math.max(0,w-100);for(;g>=C;){if(c[g]){p=c[g];break}g--}if(!p){let k=w+1;const R=w+100;for(;c[k]==null&&k<=R;)k++;c[k]&&(p=c[k])}}return p?{clip:p.clip,timeMs:p.t}:null},getMetaByGI:w=>{const c=S().getCTFromGI(w);return c?{clipIndex:c.clip,timeMs:c.timeMs}:null},syncToGI:w=>{const c=S().getMetaByGI(w);c&&S().setClipAndMs(c.clipIndex,c.timeMs)},_onTime:w=>b({currentTimeMs:w,status:"playing",scrollLock:!0}),_onEnded:()=>b(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:()=>b({status:"error",scrollLock:!1}),_setStatusOnly:w=>b({status:w})})))}function nu({children:e,initialState:t}){const n=h.useContext(wt)??void 0,r=h.useMemo(()=>tu({...t,recorderStore:n}),[t,n]);return v.jsx(Sn.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],m=o+l;d.audioChunkIndex!=null&&d.audioTimeMs!=null&&((t[i=d.audioChunkIndex]||(t[i]=[])).push({t:d.audioTimeMs,g:m}),n[m]={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=Xl(e),n=Yl(t),r=t.reduce((d,m)=>d+(m||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,m)=>{var c;if(d.type!=="paragraph")return;const f=n[m]??0,b=d.runs??[];for(let p=0;p<b.length;p++){const g=((c=b[p])==null?void 0:c.text)||"";lr(g)&&(s[f+p]=1)}const w=Ql(b,f).map(p=>{var R;const g=p.startG-f,C=p.endG-p.startG+1;let k=-1;for(let E=0;E<C;E++){const x=((R=b[g+E])==null?void 0:R.text)??"";if(lr(x)){k=p.startG+E;break}}return{startG:p.startG,endG:p.endG,r0:g,len:C,firstReadableGI:k,splitIndex:p.splitIndex}});u[m]=w;for(const p of w){const g=i.length;for(let C=p.startG;C<=p.endG;C++)o[C]=g;i.push(p)}}),{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:m,layout:f,initialIndex:b,mountTime:S}=e,w=f.totalRuns??0,c=typeof b=="number"?b:w>0?0:-1,p=c>=0?ou(m.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:p,lastUpdateBy:"program",totalRuns:w,pageIndex:0,totalPages:0,sectionLoading:!0,_loadingStartTime:S,_scrollApi:void 0,derivedNav:m,layout:f,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:m,eventBridgeStore:f}=e,b=t.ast.blocks,{nav:S,layout:w}=su(b),c=Date.now(),p=iu({section:t,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i,canTracking:u,canToggleShowGaze:a,showGaze:l,onToggleShowGaze:d,handleAskCalibration:m,nav:S,layout:w,initialIndex:n,mountTime:c});return f&&queueMicrotask(()=>{f.getState().emit({type:"render_start",payload:{sectionId:t.section_id}},c),f.getState().emit({type:"loading_start",payload:{}},c)}),qt((g,C)=>{const k=K=>{g(W=>W.progress._scrollApi===K?W:{progress:{...W.progress,_scrollApi:K}})},R=()=>C().progress._scrollApi,E=K=>{g(W=>{const L=W.progress;if(L.totalRuns===K)return W;const j=L.currentGlobalRunIndex<0&&K>0;return{progress:{...L,totalRuns:K,currentGlobalRunIndex:j?0:L.currentGlobalRunIndex,lastUpdateBy:j?"program":L.lastUpdateBy}}})},x=(K,W="program")=>{const L=C().progress.currentGlobalRunIndex,j=C().progress,G=j.totalRuns>0?Math.max(-1,Math.min(K,j.totalRuns-1)):K;L===G&&j.lastUpdateBy===W||(g(V=>({progress:{...V.progress,currentGlobalRunIndex:G,lastUpdateBy:W}})),L!==G&&f&&f.getState().emit({type:"global_index_change",payload:{globalIndex:G}}))},y=K=>{const{sectionLoading:W,_loadingStartTime:L}=C().progress;if(W===K)return;const j=Date.now();if(K)g(G=>({progress:{...G.progress,sectionLoading:!0,_loadingStartTime:j}})),f&&f.getState().emit({type:"loading_start",payload:{}});else{const V=(L?j-L:0)/1e3;g(B=>({progress:{...B.progress,sectionLoading:!1,_loadingStartTime:null}})),f&&f.getState().emit({type:"loading_end",payload:{duration:V}})}},M=K=>{g(W=>({progress:{...W.progress,pageIndex:K}}))},T=K=>{g(W=>({progress:{...W.progress,totalPages:K}}))},O=(K,W)=>{const j=C().progress.rangeStartGI==null;if(g(G=>({progress:{...G.progress,rangeStartGI:Math.min(K,W),rangeEndGI:Math.max(K,W)}})),f){const G=_();f.getState().emit({type:j?"range_select":"range_change",payload:{startGI:Math.min(K,W),endGI:Math.max(K,W),text:G}})}},P=()=>{g(K=>({progress:{...K.progress,rangeStartGI:null,rangeEndGI:null}})),f&&f.getState().emit({type:"range_clear",payload:{}})},I=K=>{const{rangeStartGI:W,rangeEndGI:L}=C().progress;W==null||L==null||(K<W?g(j=>({progress:{...j.progress,rangeStartGI:K}})):K>L?g(j=>({progress:{...j.progress,rangeEndGI:K}})):P())},_=()=>{var Z;const{rangeStartGI:K,rangeEndGI:W,section:L,layout:j}=C().progress;if(K==null||W==null||!j)return"";const G=((Z=L.ast)==null?void 0:Z.blocks)??[],V=j.prefix,B=[];for(let F=0;F<G.length;F++){const Y=G[F];if(Y.type!=="paragraph")continue;const ee=Y.runs??[],J=V[F]??0;for(let ie=0;ie<ee.length;ie++){const re=J+ie;re>=K&&re<=W&&B.push(ee[ie].text??"")}}return B.join("")},z=K=>{g(W=>({progress:{...W.progress,translateOpen:K.isOpen,translateLoading:K.isLoading??!1,translateText:K.text,translatedText:K.translatedText,translateStartGI:K.startGI,translateEndGI:K.endGI}}))},N=()=>{g(K=>({progress:{...K.progress,translateOpen:!1,translateLoading:!1,translateText:void 0,translatedText:void 0,translateStartGI:void 0,translateEndGI:void 0}}))},A=K=>{const{totalRuns:W,derivedNav:L}=C().progress,j=L==null?void 0:L.readableGi;if(!j||W<=0)return K;const G=W,V=Math.max(0,Math.min(K,G-1));if(j[V])return V;let B=V-1,Z=V+1;for(;B>=0||Z<G;){if(Z<G&&j[Z])return Z;if(B>=0&&j[B])return B;Z+=1,B-=1}return V},$=(K,W)=>{const{totalRuns:L,derivedNav:j}=C().progress,G=j==null?void 0:j.readableGi;if(!G||L<=0)return null;if(W>0){for(let V=Math.min(Math.max(K,0),L-1);V<L;V+=1)if(G[V])return V}else for(let V=Math.min(Math.max(K,0),L-1);V>=0;V-=1)if(G[V])return V;return null},te=K=>{const{totalRuns:W,derivedNav:L}=C().progress,j=L==null?void 0:L.readableGi;if(!j||W<=0)return null;if(K>0){for(let G=W-1;G>=0;G-=1)if(j[G])return G}else for(let G=0;G<W;G+=1)if(j[G])return G;return null};return{progress:{...p,registerSectionScrollApi:k,getSectionScrollApi:R,setTotalRuns:E,setCurrentGlobalRunIndex:x,setSectionLoading:y,setPageIndex:M,setTotalPages:T,setTranslateState:z,clearTranslate:N,setRange:O,clearRange:P,extendRange:I,getRangeText:_,snapToReadable:A,nextReadableFrom:$,edgeReadable:te,hasReadableInDir:(K,W)=>$(K+(W>0?1:-1),W)!=null,computeStepTarget:(K,W)=>{const{totalRuns:L,derivedNav:j}=C().progress;if(!L||L<=0)return K;const G=(j==null?void 0:j.groups)??[],V=j==null?void 0:j.giToGroupIdx;if(!G.length||!V){const J=L-1;return A(Math.max(0,Math.min(K+W,J)))}let B=V[K]??-1;if(B<0||B>=G.length)for(let ee=0;ee<G.length;ee+=1){const J=G[ee];if(K>=J.startG&&K<=J.endG){B=ee;break}}if(B<0||B>=G.length)return te(W)??A(K);const Z=ee=>ee>=0&&ee<G.length&&(G[ee].firstReadableGI??-1)>=0;let F=B+W;for(;F>=0&&F<G.length&&!Z(F);)F+=W;if(F<0||F>=G.length)return te(W)??A(K+W);const Y=G[F].firstReadableGI;return Y>=0?Y:A(K+W)},giToPercentTotal:K=>{const W=C().progress.totalRuns;return!W||W<=1?0:Math.max(0,Math.min(K,W-1))/(W-1)*100},percentToGITotal:K=>{const W=C().progress.totalRuns;if(!W||W<=1)return 0;const L=Math.max(0,Math.min(K,100)),j=Math.round(L/100*(W-1));return Math.max(0,Math.min(j,W-1))}}}})}function au({children:e,initialState:t,gazeSync:n}){const r=h.useContext(wt),o=h.useMemo(()=>lu({...t,...n?n.getSnapshot():{},eventBridgeStore:r}),[t,r]);return h.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]),v.jsx(cr.Provider,{value:o,children:e})}function cu({children:e,initialState:t}){const n=h.useContext(wt)??void 0,r=h.useRef(Zs({init:t,recorderStore:n}));return v.jsx(ar.Provider,{value:r.current,children:e})}const uu=({pages:e,pageIndex:t,maxWidth:n})=>{const r=q(g=>g.section),o=h.useMemo(()=>{var g;return((g=r.ast)==null?void 0:g.blocks)??[]},[r]),s=X(g=>g.marginX),i=X(g=>g.lineHeight),u=X(g=>g.fontSizePx),a=X(g=>g.fontFamily),l=X(g=>g.viewportHeight),d=q(g=>{var C;return((C=g.layout)==null?void 0:C.prefix)??[]}),m=q(g=>{var C;return((C=g.derivedNav)==null?void 0:C.splitGroupsPerBlock)??[]}),f=e[t],b=h.useMemo(()=>{const g=[];return o.forEach((C,k)=>{(C.type==="paragraph"||C.type==="image")&&g.push(k)}),g},[o]),S=h.useMemo(()=>{if(!f)return[];const g=[];for(let C=f.startBlock;C<=f.endBlock;C++){const k=b[C];k!=null&&g.push(k)}return g},[f,b]),w=h.useMemo(()=>{const g=[];for(const C of S){const k=o[C];(k==null?void 0:k.type)==="paragraph"&&g.push({b:k,originalBlockIndex:C})}return g},[S,o]),c=h.useMemo(()=>{const g=[],C=wr();return w.forEach((k,R)=>{g[R]=Cr(k.b,C)}),g},[w]),p=(g,C,k)=>{if(!g||g.length===0)return[];const R=[];for(const E of g){const x=E.startG,y=E.endG;if(y<C||x>k)continue;const M=Math.max(x,C),T=Math.min(y,k),O=M-x|0,P=Math.max(0,T-M+1);if(P<=0)continue;const I=(E.r0??0)+O;R.push({...E,startG:M,endG:T,r0:I,len:P})}return R};return v.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:v.jsxs("div",{style:{width:"100%",maxWidth:n,height:"100%",boxSizing:"border-box",overflow:"hidden",display:"flex",flexDirection:"column",margin:"0 auto"},children:[v.jsx("div",{style:{height:40}}),v.jsx("div",{style:{flex:1,overflow:"hidden"},children:S.map((g,C)=>{var L;const k=o[g],R=C===0,E=C===S.length-1,x={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-${k.id??g}`;if(k.type==="image"){const{src:j,alt:G,width:V,height:B}=k,Z=V&&B?`${V} / ${B}`:"4 / 3",F=l>80?Math.floor((l-80)*.6):void 0;return v.jsx("div",{style:x,children:v.jsxs("div",{style:{margin:"12px 0",textAlign:"center",width:"100%"},children:[v.jsx("div",{style:{position:"relative",width:"100%",maxHeight:F,aspectRatio:Z},children:v.jsx("img",{src:j,alt:G||"",loading:"eager",style:{pointerEvents:"none",position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"contain",display:"block"}})}),G&&v.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:G})]})},y)}const M=k,T=w.findIndex(j=>j.originalBlockIndex===g),O=T>=0?c[T]:void 0,P=M.runs??[],I=P.length;let _=0,z=Math.max(0,I-1);R&&f.startOffsetInBlock!=null&&(_=Math.min(Math.max(0,f.startOffsetInBlock),z)),E&&f.endOffsetInBlock!=null&&(z=Math.max(_,Math.min(f.endOffsetInBlock,z)));const N=_>0,A=d[g]??0,$=m[g]??[],te=A+_,fe=A+z;let ge=p($,te,fe);const ve=A+_;ge=ge.map(j=>{const G=Math.max(0,(j.startG??te)-ve),V=j.len??Math.max(1,(j.endG??fe)-(j.startG??te)+1);return{...j,r0:G,len:V}});const me=_<=z?P.slice(_,z+1):[],Ae=M.list?M.list.level*24:0,K=((L=M.list)==null?void 0:L.kind)==="bullet"?M.list.glyph??"•":void 0,W=N?void 0:O??K;return v.jsx("div",{style:x,children:v.jsxs("p",{style:{width:"100%",margin:"8px 0",paddingLeft:Ae,textAlign:M.textAlign,whiteSpace:"pre-wrap",boxSizing:"border-box"},children:[M.list&&W?v.jsx("span",{"aria-hidden":!0,style:{minWidth:16,display:"inline-block",whiteSpace:"nowrap",userSelect:"none"},children:W||""}):null,v.jsx(vs,{preGroups:ge,runs:me,ns:y,baseIndex:ve,sectionId:String(r.section_id)})]})},y)})})]})})},nn=.5;function du(e,t){const n=h.useRef(null),r=h.useRef(null),o=h.useRef(!1);h.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:m}=l.contentRect,f=r.current;if(!f){r.current={w:d,h:m};return}Math.abs(f.w-d)<nn&&Math.abs(f.h-m)<nn||(r.current={w:d,h:m},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,m=a.offsetHeight;if(Math.abs(r.current.w-d)<nn&&Math.abs(r.current.h-m)<nn)return;r.current={w:d,h:m}}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:m,onDragEnd:f,pageTransitionThreshold:b}=e,S=b??u,w=10,c=$e.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}),p=()=>{c.current.singleTimer!=null&&(clearTimeout(c.current.singleTimer),c.current.singleTimer=null)},g=$e.useCallback(_=>{if(s!=null&&s(_))return;const z=performance.now();z-c.current.lastTapT<=d&&c.current.lastTapT>0?(p(),c.current.lastTapT=0,o==null||o()):(p(),r&&(c.current.singleTimer=window.setTimeout(()=>{c.current.singleTimer=null,r()},l)),c.current.lastTapT=z)},[s,d,o,r,l]),C=$e.useCallback((_,z)=>{const N=Math.abs(_)/Math.max(1,z);Math.abs(_)>=S||N>=a?_<0?n():t():f==null||f()},[S,a,n,t,f]),k=$e.useCallback(_=>{if(_.touches.length!==1)return;const z=i??s;if(z!=null&&z(_.target))return;const N=_.touches[0];c.current.touchId=N.identifier,c.current.startX=N.clientX,c.current.startY=N.clientY,c.current.startT=_.timeStamp,c.current.swiping=!1},[i,s]),R=$e.useCallback(_=>{if(c.current.touchId==null)return;const z=Array.from(_.touches).find(te=>te.identifier===c.current.touchId);if(!z)return;const N=z.clientX-c.current.startX,A=Math.abs(N),$=Math.abs(z.clientY-c.current.startY);if(!c.current.swiping)if(A>=w&&A>$)c.current.swiping=!0;else return;m==null||m(N)},[m]),E=$e.useCallback(_=>{if(c.current.touchId==null)return;const z=Array.from(_.changedTouches).find(te=>te.identifier===c.current.touchId);if(!z)return;const N=z.clientX-c.current.startX,A=z.clientY-c.current.startY,$=_.timeStamp-c.current.startT;c.current.swiping?C(N,$):Math.abs(N)<10&&Math.abs(A)<10&&g(_.target),c.current.suppressClick=!0,c.current.touchId=null,c.current.swiping=!1},[C,g]),x=$e.useCallback(()=>{c.current.swiping&&(f==null||f()),c.current.touchId=null,c.current.swiping=!1},[f]),y=$e.useCallback(_=>{if(_.pointerType==="touch"||c.current.mouseDown)return;const z=i??s;z!=null&&z(_.target)||(c.current.mouseDown=!0,c.current.mouseSwiping=!1,c.current.mStartX=_.clientX,c.current.mStartY=_.clientY,c.current.mStartT=_.timeStamp,c.current.suppressClick=!1,c.current.capturedEl=_.currentTarget)},[i,s]),M=$e.useCallback(_=>{if(_.pointerType==="touch"||!c.current.mouseDown)return;const z=_.clientX-c.current.mStartX,N=Math.abs(z),A=Math.abs(_.clientY-c.current.mStartY);if(!c.current.mouseSwiping)if(N>=w&&N>A){c.current.mouseSwiping=!0,c.current.suppressClick=!0;const $=c.current.capturedEl;if($!=null&&$.setPointerCapture)try{$.setPointerCapture(_.pointerId)}catch{}c.current.prevUserSelect=document.body.style.userSelect,document.body.style.userSelect="none",_.preventDefault()}else return;m==null||m(z),_.preventDefault()},[m]),T=$e.useCallback(_=>{var N;if(_.pointerType==="touch"||!c.current.mouseDown)return;if(c.current.mouseSwiping){const A=_.clientX-c.current.mStartX,$=_.timeStamp-c.current.mStartT;C(A,$),document.body.style.userSelect=c.current.prevUserSelect}const z=c.current.capturedEl;if((N=z==null?void 0:z.hasPointerCapture)!=null&&N.call(z,_.pointerId))try{z.releasePointerCapture(_.pointerId)}catch{}c.current.mouseDown=!1,c.current.mouseSwiping=!1,c.current.capturedEl=null},[C]),O=$e.useCallback(_=>{_.pointerType!=="touch"&&(c.current.mouseSwiping&&(f==null||f(),document.body.style.userSelect=c.current.prevUserSelect),c.current.mouseDown=!1,c.current.mouseSwiping=!1,c.current.capturedEl=null)},[f]),P=$e.useCallback(()=>{c.current.mouseSwiping&&(f==null||f(),document.body.style.userSelect=c.current.prevUserSelect),c.current.mouseDown=!1,c.current.mouseSwiping=!1,c.current.capturedEl=null},[f]),I=$e.useCallback(_=>{if(c.current.suppressClick){c.current.suppressClick=!1;return}g(_.target)},[g]);return $e.useEffect(()=>()=>{p(),document.body.style.userSelect=""},[]),{onTouchStart:k,onTouchMove:R,onTouchEnd:E,onTouchCancel:x,onPointerDown:y,onPointerMove:M,onPointerUp:T,onPointerCancel:O,onLostPointerCapture:P,onClick:I}}var An,ho;function ks(){if(ho)return An;ho=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return An=e,An}var Bn,mo;function pu(){if(mo)return Bn;mo=1;var e=typeof Yt=="object"&&Yt&&Yt.Object===Object&&Yt;return Bn=e,Bn}var Ln,bo;function Rs(){if(bo)return Ln;bo=1;var e=pu(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Ln=n,Ln}var Gn,xo;function gu(){if(xo)return Gn;xo=1;var e=Rs(),t=function(){return e.Date.now()};return Gn=t,Gn}var Hn,vo;function hu(){if(vo)return Hn;vo=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return Hn=t,Hn}var Nn,So;function mu(){if(So)return Nn;So=1;var e=hu(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Nn=n,Nn}var Fn,yo;function _s(){if(yo)return Fn;yo=1;var e=Rs(),t=e.Symbol;return Fn=t,Fn}var Dn,wo;function bu(){if(wo)return Dn;wo=1;var e=_s(),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 Dn=s,Dn}var Wn,Co;function xu(){if(Co)return Wn;Co=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return Wn=n,Wn}var $n,Io;function vu(){if(Io)return $n;Io=1;var e=_s(),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 $n=i,$n}var Vn,To;function Su(){if(To)return Vn;To=1;function e(t){return t!=null&&typeof t=="object"}return Vn=e,Vn}var qn,ko;function yu(){if(ko)return qn;ko=1;var e=vu(),t=Su(),n="[object Symbol]";function r(o){return typeof o=="symbol"||t(o)&&e(o)==n}return qn=r,qn}var Un,Ro;function wu(){if(Ro)return Un;Ro=1;var e=mu(),t=ks(),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 m=s.test(l);return m||i.test(l)?u(l.slice(2),m?2:8):o.test(l)?r:+l}return Un=a,Un}var Kn,_o;function Cu(){if(_o)return Kn;_o=1;var e=ks(),t=gu(),n=wu(),r="Expected a function",o=Math.max,s=Math.min;function i(u,a,l){var d,m,f,b,S,w,c=0,p=!1,g=!1,C=!0;if(typeof u!="function")throw new TypeError(r);a=n(a)||0,e(l)&&(p=!!l.leading,g="maxWait"in l,f=g?o(n(l.maxWait)||0,a):f,C="trailing"in l?!!l.trailing:C);function k(I){var _=d,z=m;return d=m=void 0,c=I,b=u.apply(z,_),b}function R(I){return c=I,S=setTimeout(y,a),p?k(I):b}function E(I){var _=I-w,z=I-c,N=a-_;return g?s(N,f-z):N}function x(I){var _=I-w,z=I-c;return w===void 0||_>=a||_<0||g&&z>=f}function y(){var I=t();if(x(I))return M(I);S=setTimeout(y,E(I))}function M(I){return S=void 0,C&&d?k(I):(d=m=void 0,b)}function T(){S!==void 0&&clearTimeout(S),c=0,d=w=m=S=void 0}function O(){return S===void 0?b:M(t())}function P(){var I=t(),_=x(I);if(d=arguments,m=this,w=I,_){if(S===void 0)return R(w);if(g)return clearTimeout(S),S=setTimeout(y,a),k(w)}return S===void 0&&(S=setTimeout(y,a)),b}return P.cancel=T,P.flush=O,P}return Kn=i,Kn}var Iu=Cu();const Tu=Ao(Iu);function ku(e,t=200,n,r){const o=h.useRef(e),s=h.useRef(n);h.useEffect(()=>{o.current=e},[e]),h.useEffect(()=>{s.current=n},[n]);const i=h.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 h.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 Xn=!1;function _u(){if(Xn||typeof document>"u")return;if(document.querySelector('link[href*="fonts.googleapis.com"][href*="Noto"]')){Xn=!0;return}const t=document.createElement("link");t.rel="stylesheet",t.href=Ru,document.head.appendChild(t),Xn=!0}const Ms=new Map,Es=e=>Ms.get(e)??0,Mu=e=>{const t=Es(e)+1;return Ms.set(e,t),t};class js extends Error{constructor(){super("calcPages canceled due to a newer invocation");kr(this,"code","CALC_PAGES_CANCELED");this.name="CalcPagesCanceled"}}const Qe=(e,t)=>{if(e!==Es(t))throw new js},Yn=e=>{const t=getComputedStyle(e),n=parseFloat(t.marginTop||"0")||0,r=parseFloat(t.marginBottom||"0")||0;return{mt:n,mb:r}},Mo=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)=>{Qe(e,t)};let r=0;return async(o=24)=>{r++,r%o===0&&(Qe(e,t),await new Promise(s=>requestAnimationFrame(()=>s())),Qe(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:m,paragraphMarkers:f,playbackScale:b=1,viewportHeight:S=0,instanceId:w="default"}){var p,g,C;const c=Mu(w);if(Qe(c,w),i&&typeof document<"u"&&document.fonts){_u();try{const k=`${u}px ${i}`;await document.fonts.load(k),document.fonts.check(k)||await document.fonts.ready}catch{}}Qe(c,w);try{const k=Math.abs(b-1)>.001,R=1/b;k&&(t.style.transform=`scale(${R})`,t.style.transformOrigin="top left");const E=Math.max(0,e.offsetWidth||0),x=Math.max(0,Math.min(E,o));t.style.maxWidth=`${x}px`,Qe(c,w);let y=Math.round(n.offsetHeight||0);y||(y=Math.max(0,n.clientHeight|0)),console.log("[calcPages] playbackScale:",b.toFixed(4),k?"(scaled, applying inverse)":"(no scale)"),console.log("[calcPages] viewWidth:",E),console.log("[calcPages] pageBoxWidth:",x),console.log("[calcPages] maxPageHeight:",y),console.log("[calcPages] contentArea rect:",n.getBoundingClientRect()),console.log("[calcPages] measureRoot rect:",t.getBoundingClientRect());const M=1.5,T=(B,Z)=>Z+B<=y-M,O=getComputedStyle(e),P={letterSpacing:O.letterSpacing,wordSpacing:O.wordSpacing,fontKerning:O.fontKerning||"normal",fontVariantLigatures:O.fontVariantLigatures||"normal",textTransform:O.textTransform||"none",direction:O.direction||"ltr",wordBreak:O.wordBreak||"keep-all",overflowWrap:O.overflowWrap||O.wordWrap||"break-word",hyphens:O.hyphens||"manual"},I=B=>{B.style.letterSpacing=P.letterSpacing||"",B.style.wordSpacing=P.wordSpacing||"",B.style.fontKerning=P.fontKerning||"",B.style.fontVariantLigatures=P.fontVariantLigatures||"",B.style.textTransform=P.textTransform||"",B.style.direction=P.direction||"",B.style.wordBreak=P.wordBreak||"",B.style.wordWrap=P.overflowWrap||"",B.style.overflowWrap=P.overflowWrap||"",B.style.hyphens=P.hyphens||""},_=x,z=Math.max(0,_-2*(s||0));n.innerHTML="";const N=document.createElement("div");N.style.boxSizing="border-box",N.style.width=`${_}px`,N.style.maxWidth=`${_}px`,N.style.margin="0 auto",N.style.display="flex",n.appendChild(N);const A=document.createElement("div");A.style.boxSizing="border-box",A.style.paddingRight=`${s}px`,A.style.paddingLeft=`${s}px`,A.style.width=`${_}px`,A.style.maxWidth=`${_}px`,A.style.margin="0 auto",A.style.display="flex",A.style.justifyContent="center",A.style.height="auto",N.appendChild(A);const $=new Map,te={},fe=Eu(c,w,r.length),ge=(B,Z)=>{const F=document.createElement("p");return F.style.margin="8px 0",F.style.paddingLeft=Z?`${Z}px`:"0",F.style.textAlign=B.textAlign??"start",F.style.whiteSpace="pre-wrap",F.style.lineHeight=String(a),F.style.fontSize=`${u}px`,F.style.boxSizing="border-box",F.style.fontFamily=i??"",F.style.width="100%",I(F),F},ve=(B,Z)=>{const F=Z??[],Y=document.createDocumentFragment();for(let ee=0;ee<F.length;ee++){const J=F[ee],ie=document.createElement("span");ie.dataset.runbox=String(ee),ie.style.whiteSpace="pre-wrap";const re=document.createElement("span");if(re.dataset.run=String(ee),re.textContent=(J==null?void 0:J.text)??"",re.style.whiteSpace="pre-wrap",J!=null&&J.bold&&(re.style.fontWeight="700"),J!=null&&J.italic&&(re.style.fontStyle="italic"),J!=null&&J.underline&&(re.style.textDecoration="underline"),ie.appendChild(re),l&&(J!=null&&J.split)&&ee!==F.length-1){const be=Math.max(0,(d??0)/2),ue=document.createElement("span");ue.style.display="inline-block",ue.style.width=`${be}px`;const ye=document.createElement("span");if(ye.style.display="inline-block",ye.style.width=`${be}px`,ie.appendChild(ue),m){const ke=document.createElement("span");ke.textContent=" / ",ie.appendChild(ke)}ie.appendChild(ye)}Y.appendChild(ie)}B.appendChild(Y)},me=S>80?Math.floor((S-80)*.6):void 0,Ae=B=>{const Z=B!=null&&B.width&&(B!=null&&B.height)?`${B.width} / ${B.height}`:"4 / 3",F=document.createElement("div");F.style.margin="12px 0",F.style.textAlign="center",F.style.width=`${z}px`;const Y=document.createElement("div");Y.style.position="relative",Y.style.width="100%",me&&(Y.style.maxHeight=`${me}px`),Y.style.aspectRatio=Z;const ee=document.createElement("div");if(ee.style.position="absolute",ee.style.inset="0",ee.style.width="100%",ee.style.height="100%",Y.appendChild(ee),F.appendChild(Y),B!=null&&B.alt){const J=document.createElement("div");J.style.fontSize="12px",J.style.color="#6B7280",J.style.marginTop="4px",J.textContent=String(B.alt),I(J),F.appendChild(J)}return F};for(let B=0;B<r.length;B++){Qe(c,w);const Z=r[B];if(A.dataset.block=String(B),A.innerHTML="",Z.kind==="image"){const ye=Z.block,ke=Ae(ye);A.appendChild(ke);const ze=ke.getBoundingClientRect(),{mt:Ee,mb:Ge}=Yn(ke);te[B]={contentH:Math.ceil(ze.height),mt:Ee,mb:Ge},await fe(24);continue}const F=Z.block,Y=F.list?(F.list.level??0)*24:0,ee=Z.paraIndex??0,J=f[ee]??(((p=F.list)==null?void 0:p.kind)==="bullet"?((g=F.list)==null?void 0:g.glyph)??"•":void 0);if(!!(F.list&&J)){const ye=ge(F,Y);ye.dataset.variant="with";const ke=ge(F,Y);ke.dataset.variant="no";const ze=document.createElement("span");ze.textContent=`${J} `,ze.style.minWidth="16px",ze.style.display="inline-block",ze.style.whiteSpace="nowrap",ze.style.userSelect="none",ye.appendChild(ze),ve(ye,F.runs),ve(ke,F.runs);const Ee=document.createDocumentFragment();Ee.appendChild(ye),Ee.appendChild(ke),A.appendChild(Ee)}else{const ye=ge(F,Y);ye.dataset.variant="with",ve(ye,F.runs),A.appendChild(ye)}const re=A.querySelector('p[data-variant="with"]'),be=A.querySelector('p[data-variant="no"]'),ue=be??re;if(re&&ue){const ye=Mo(re),ke=Mo(ue),{mt:ze,mb:Ee}=Yn(re),{mt:Ge,mb:ot}=Yn(ue),We=((C=F.runs)==null?void 0:C.length)??0,je=be?ke:ye,et=be?Ge:ze,Ye=be?ot:Ee;if(B<3){const ut=re.getBoundingClientRect().height;console.log(`[calcPages] para ${B}: height=${ut.toFixed(2)}, lastBottom=[${ye.slice(-3).map(zt=>zt.toFixed(1)).join(",")}], runs=${We}`)}$.set(B,{runsLen:We,lastBottomWith:ye,lastBottomNo:je,mtWith:ze,mbWith:Ee,mtNo:et,mbNo:Ye})}await fe(24)}Qe(c,w),A.innerHTML="";const K=(B,Z,F,Y)=>{if(Z>F)return{top:0,content:0,mb:0};const ee=Y?B.lastBottomNo:B.lastBottomWith,J=Y?B.mtNo:B.mtWith,ie=Y?B.mbNo:B.mbWith,re=Y?0:J,be=Z>0?ee[Z-1]??0:0,ue=Math.max(0,(ee[F]??0)-be);return{top:re,content:ue,mb:ie}},W=[];let L=0,j,G=null,V=null;for(;L<r.length;){Qe(c,w);const B=L;let Z=0,F=0,Y=j;Y!=null&&G===L&&V!=null&&(Y=Math.max(Y,V+1));let ee=-1,J;for(;L<r.length;){if(Qe(c,w),r[L].kind==="image"){const je=te[L]??{contentH:0,mt:0,mb:0},Ye=(Z===0?je.mt:F+je.mt)+je.contentH;if(T(Ye,Z)){Z+=Ye,ee=L,J=void 0,F=je.mb,L+=1,j=void 0,G=null,V=null;continue}if(Z===0){W.push({startBlock:B,endBlock:L,...Y!=null?{startOffsetInBlock:Y}:{}}),L+=1,j=void 0,G=null,V=null,F=0;break}break}const re=$.get(L),be=re.runsLen,ue=L===B&&Y!=null?Y:0;if(ue>=be){L+=1,j=void 0,G=null,V=null;continue}const ye=ue>0,ke=K(re,ue,be-1,ye),Ee=(Z===0?ke.top:F+ke.top)+ke.content;if(T(Ee,Z)){Z+=Ee,ee=L,J=be-1,F=ke.mb,L+=1,j=void 0,G=null,V=null;continue}let Ge=ue,ot=be-1,We=ue-1;for(;Ge<=ot;){Qe(c,w);const je=Ge+ot>>1,et=K(re,ue,je,ye),Ye=(Z===0?et.top:F+et.top)+et.content;T(Ye,Z)?(We=je,Ge=je+1):ot=je-1}if(We>=ue){W.push({startBlock:B,endBlock:L,...Y!=null?{startOffsetInBlock:Y}:{},endOffsetInBlock:We}),j=We+1,G=L,V=We,F=0;break}if(Z>0){W.push({startBlock:B,endBlock:ee>=0?ee:Math.min(L-1,r.length-1),...Y!=null?{startOffsetInBlock:Y}:{},...J!=null?{endOffsetInBlock:J}:{}}),F=0;break}else{const je=ue;W.push({startBlock:B,endBlock:L,...Y!=null?{startOffsetInBlock:Y}:{},endOffsetInBlock:je}),j=je+1,G=L,V=je,F=0;break}}(W.length===0||W[W.length-1].startBlock!==B)&&W.push({startBlock:B,endBlock:ee>=0?ee:Math.min(L-1,r.length-1),...Y!=null?{startOffsetInBlock:Y}:{},...J!=null?{endOffsetInBlock:J}:{}})}return N.remove(),k&&(t.style.transform="",t.style.transformOrigin=""),Qe(c,w),{pages:W,pageByRunIndex:null}}catch(k){throw console.error(k),k}}function Eo(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 Ou(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,m=l-1;u===i.startBlock&&i.startOffsetInBlock!=null&&(d=Math.max(0,Math.min(i.startOffsetInBlock,m))),u===i.endBlock&&i.endOffsetInBlock!=null&&(m=Math.max(d,Math.min(i.endOffsetInBlock,m)));const f=r[a.originalIndex]??0,b=f+d,S=f+m;if(e>=b&&e<=S)return s}}return-1}function zu(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,r;const t=e;return t?((n=t.style)==null?void 0:n.cursor)==="grab"||((r=t.closest)==null?void 0:r.call(t,"[data-range-handle]"))!=null:!1}function Au(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 Bu(){var Tr;const e=h.useId(),t=q(U=>U.section),n=q(U=>U.sectionLoading),r=pt(),o=h.useRef(!1);h.useEffect(()=>r.subscribe(U=>{o.current=U.progress.rangeStartGI!=null&&U.progress.rangeEndGI!=null}),[r]);const s=o.current,i=ht(),u=X(U=>U.theme),a=sn[u],l=X(U=>U.fontFamily),d=X(U=>U.fontSizePx),m=X(U=>U.lineHeight),f=X(U=>U.marginX),b=X(U=>U.viewportHeight),S=860,w=h.useRef(null),{items:c}=h.useMemo(()=>{var U;return Au(((U=t==null?void 0:t.ast)==null?void 0:U.blocks)??[])},[t]),p=h.useMemo(()=>{const U=[],Oe=wr();return c.forEach(Be=>{if(Be.kind==="paragraph"){const vt=Be.paraIndex;U[vt]=Cr(Be.block,Oe)}}),U},[c]),[g,C]=h.useState({pages:[],pageByRunIndex:null}),k=q(U=>U.pageIndex),R=q(U=>U.setPageIndex),E=h.useRef(0),x=h.useRef(null),[y,M]=h.useState(!1),[T,O]=h.useState(null),[P,I]=h.useState(!1),_=h.useMemo(()=>({flex:1,fontFamily:l,background:a.bg,color:a.fg,fontSize:d,lineHeight:m,overflow:"hidden",width:"100%",height:"100%",position:"relative",boxSizing:"border-box",WebkitTextSizeAdjust:"none",MozTextSizeAdjust:"none",textSizeAdjust:"none"}),[l,a.bg,a.fg,d,m]),{showSplit:z,breakGapPx:N,slash:A}=X(Vt(U=>{var Oe;return{showSplit:U.showSplit,breakGapPx:U.breakGapPx??0,slash:((Oe=U.breakMarks)==null?void 0:Oe.slash)??!1}})),$=pt();h.useEffect(()=>{g&&g.pages.length&&(console.log("그래서 총 페이지",g.pages.length),$.getState().progress.setTotalPages(g.pages.length+1),(async()=>{const U=$.getState().progress.setSectionLoading;await ft(),await ft(),await ft(),await ft(),console.log("recalc종료"),U(!1)})())},[g,$]);const te=h.useCallback(()=>{console.log("@@@@@@recalc호출");const U=w.current,Oe=re.current,Be=be.current;if(console.log("showSplit",z),!U||!Oe||!Be||c.length===0){C({pages:[],pageByRunIndex:null}),R(0),$.getState().progress.setTotalPages(0);return}(async()=>{const vt=performance.now();try{const tt=i.getState().playbackScale,{pages:Tt,pageByRunIndex:zs}=await ju({viewHost:U,measureRoot:Oe,contentArea:Be,items:c,cfgMaxWidth:S,marginX:f,fontFamily:l,fontSizePx:d,lineHeight:m,showSplit:z,breakGapPx:N,showSlash:A,paragraphMarkers:p,playbackScale:tt,viewportHeight:b,instanceId:e}),Ps=performance.now();console.log(`✅ calcPages 완료: ${(Ps-vt).toFixed(1)} ms (${Tt.length} pages)`),C({pages:Tt,pageByRunIndex:zs}),R(0)}catch(tt){if(tt instanceof js){console.log("이젠실행 취소 들어옴!");return}console.log("에러발생",tt)}})()},[R,c,S,f,l,d,m,z,N,A,p,i,b,e]),fe=q(U=>U.setCurrentGlobalRunIndex),ge=q(U=>{var Oe;return((Oe=U.layout)==null?void 0:Oe.prefix)??[]}),ve=Ce(U=>U.syncToGI),me=h.useCallback(U=>{const Oe=g.pages.length+1,Be=k+U;if(Be<0||Be>=Oe)return;const vt=k===g.pages.length;if(Be===g.pages.length){R(Be);return}if(vt&&U===-1){const Tt=Eo(g.pages[Be],c,ge);Tt!=null&&(fe(Tt,"scrubber-step"),ve(Tt)),R(Be);return}const tt=Eo(g.pages[Be],c,ge);tt!=null?(fe(tt,"scrubber-step"),ve(tt)):R(Be)},[k,g.pages,c,ge,fe,R,ve]),Ae=h.useCallback(()=>{y||E.current!==0?(O("prev"),M(!1)):me(-1)},[y,me]),K=h.useCallback(()=>{y||E.current!==0?(O("next"),M(!1)):me(1)},[y,me]),W=hn(),L=h.useCallback(()=>{const{isSettingsOpen:U,setSettingsOpen:Oe,toggleOverlays:Be}=W.getState();U?Oe(!1):Be()},[W]),j=g.pages.length+1,G=((Tr=w.current)==null?void 0:Tr.clientWidth)||400,V=h.useCallback(U=>{var tt;const Oe=x.current;if(!Oe)return;const Be=((tt=w.current)==null?void 0:tt.clientWidth)||1,vt=U/Be*33.333;Oe.style.transform=`translate3d(${-33.333+vt}%, 0, 0)`},[]),B=h.useCallback(U=>{k===0&&U>0||k>=j-1&&U<0||(E.current=U,V(U),y||M(!0))},[k,j,V,y]),Z=h.useCallback(()=>{E.current=0,M(!1);const U=x.current;U&&(U.style.transition="transform 250ms ease-out",U.style.transform="translate3d(-33.333%, 0, 0)")},[]),F=h.useCallback(U=>{if(U.target!==U.currentTarget||U.propertyName!=="transform")return;const Oe=T;I(!0),O(null),E.current=0,Oe==="prev"?me(-1):Oe==="next"&&me(1)},[T,me]);h.useLayoutEffect(()=>{P&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{I(!1)})})},[P]);const Y=cn(),ee=h.useCallback(U=>s||Pu(U)?!0:zu(U),[s]),J=h.useCallback(U=>Y.getState().status==="playing"?!0:ee(U),[Y,ee]),ie=fu({onPrev:Ae,onNext:K,onSingle:L,onDouble:()=>{},shouldIgnoreTarget:ee,shouldIgnoreSwipe:J,horizontalThreshold:120,velocityThreshold:.6,singleDelayMs:250,doubleClickWindowMs:300,onDragMove:B,onDragEnd:Z,pageTransitionThreshold:G*.5}),re=h.useRef(null),be=h.useRef(null),ue=h.useCallback(()=>{const U=$.getState().progress.setSectionLoading;U(!0)},[$]),ye=h.useMemo(()=>({trailing:!0,leading:!1,maxWait:1e3}),[]),ke=ku(te,200,ue,ye),ze=h.useRef("");h.useEffect(()=>{if(b<=0)return;const U=`${l}|${d}|${m}|${f}|${z}|${N}|${A}|${b}|${t==null?void 0:t.section_id}`;ze.current!==U&&(ze.current=U,console.log("debounceRecalc 취소"),ke.cancel(),ue(),te())},[ke,te,ue,l,d,m,f,z,N,A,b,t==null?void 0:t.section_id]),du([w],ke);const Ee=q(U=>U.registerSectionScrollApi);h.useEffect(()=>(Ee({ensureVisibleGI:()=>Promise.resolve(!0),scrollToGI:()=>Promise.resolve(!0),getVisibleRange:()=>null,getScrollTop:()=>0,setScrollTop:()=>{},getAnchorOffsetRatio:()=>0,scrollToGIAtOffset:()=>Promise.resolve(),stepPage:me}),()=>Ee(void 0)),[Ee,me]);const Ge=t.quizzes&&t.quizzes.length>0,ot=g.pages.length>0&&k===g.pages.length,We=k>0?k-1:null,je=k<j-1?k+1:null,et=h.useMemo(()=>T==="prev"?"translate3d(0%, 0, 0)":T==="next"?"translate3d(-66.666%, 0, 0)":"translate3d(-33.333%, 0, 0)",[T]),Ye=U=>n?null:U===g.pages.length?v.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,width:"100%",height:"100%"},children:[Ge&&v.jsx(ws,{}),v.jsx(pn,{isIcon:!1})]}):v.jsx(uu,{pages:g.pages,pageIndex:U,maxWidth:S}),ut={width:"33.333%",height:"100%",flexShrink:0,display:"flex",alignItems:"stretch",justifyContent:"center",overflow:"hidden",boxSizing:"border-box",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},zt=!P&&(!y||T!==null);return console.log("여기리랜더"),v.jsxs("div",{ref:w,style:{..._,touchAction:"none"},...ie,children:[v.jsxs("div",{ref:x,style:{display:"flex",width:"300%",height:"100%",transform:et,transition:zt?"transform 250ms ease-out":"none",willChange:"transform",boxSizing:"border-box",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},onTransitionEnd:T?F:void 0,children:[v.jsx("div",{style:ut,children:We!==null&&Ye(We)}),v.jsx("div",{style:ut,children:Ye(k)}),v.jsx("div",{style:ut,children:je!==null&&Ye(je)})]}),v.jsx("div",{ref:re,"aria-hidden":!0,style:{position:"absolute",contain:"layout style paint",left:-999999,top:-999999,zIndex:-999999,opacity:0,width:"100%",maxWidth:S,height:"100%",minHeight:0,boxSizing:"border-box",overflow:"hidden",fontFamily:l,fontSize:d,lineHeight:m,pointerEvents:"none",background:"pink"},children:v.jsxs("div",{style:{width:"100%",maxWidth:S,height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",margin:"0 auto",overflow:"hidden"},children:[v.jsx("div",{style:{height:40,background:"blue"}}),v.jsx("div",{ref:be,style:{height:"calc(100% - 110px)",overflow:"hidden",boxSizing:"border-box",width:"100%"}})]})}),v.jsx(Lu,{pages:g.pages,items:c,onGotoPage:R,currentPageIndex:k,isOnExtraPage:ot})]})}const Lu=({pages:e,items:t,onGotoPage:n,currentPageIndex:r,isOnExtraPage:o})=>{const s=q(l=>l.currentGlobalRunIndex),i=q(l=>l.lastUpdateBy),u=q(l=>{var d;return((d=l.layout)==null?void 0:d.prefix)??[]}),a=h.useRef(null);return h.useEffect(()=>{if(s==null||e.length===0||o&&!(i==="scrubber-live"||i==="scrubber-commit")||a.current===s)return;a.current=s;const l=Ou(s,e,t,u);l>=0&&l!==r&&n(l)},[s,e,t,u,n,r,o,i]),v.jsx(v.Fragment,{})},Gu="_wrapper_dbk3n_1",Hu="_spinner_dbk3n_10",jo={wrapper:Gu,spinner:Hu};function Nu({size:e=28,speed:t=.8}){return v.jsx("div",{className:`${jo.wrapper}`,children:v.jsx("div",{className:jo.spinner,style:{width:e,height:e,borderWidth:3,animationDuration:`${t}s`}})})}function Fu(){const e=q(Vt(t=>t.sectionLoading===!0));return v.jsx(v.Fragment,{children:e===!0&&v.jsx(Nu,{})})}const Du="_Overlay_ybic8_3",Wu="_Dialog_ybic8_15",$u="_Body_ybic8_25",Vu="_Header_ybic8_32",qu="_Paging_ybic8_39",Uu="_Remaining_ybic8_48",Ku="_RemainingDanger_ybic8_55",Xu="_NextBtn_ybic8_59",Yu="_CloseBtn_ybic8_96",Qu="_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",ae={Overlay:Du,Dialog:Wu,Body:$u,Header:Vu,Paging:qu,Remaining:Uu,RemainingDanger:Ku,NextBtn:Xu,CloseBtn:Yu,Question:Qu,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 Os(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=h.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),m=Ue(c=>c.perQ),f=ys();h.useEffect(()=>{if(t==="idle"||t!=="doing"||u==null)return;const c=window.setInterval(()=>f.getState().tick(),1e3);return()=>window.clearInterval(c)},[t,u,f]);const b=t==="doing"?n[r[o]]:void 0,S=t==="doing"&&b?s[b.qid]??[]:[],w=h.useMemo(()=>{if(t==="idle"||t!=="finished")return;const c=r.map(A=>n[A]),p=c.length,g=c.reduce((A,$)=>A+($.score??0),0),C=c.reduce((A,$)=>{const te=m[$.qid];return A+(te!=null&&te.isCorrect?$.score??0:0)},0),k=c.map(A=>m[A.qid]).filter(A=>!!A),R=typeof l=="number"&&typeof d=="number"?Math.max(0,d-l):k.reduce((A,$)=>A+($.ms??0),0),E=p>0?Math.round(R/p):0,x=[...k].sort((A,$)=>A.ms-$.ms),y=x[0],M=x[x.length-1],T=k.filter(A=>!A.multi),O=k.filter(A=>A.multi),P=T.filter(A=>A.isCorrect).length,I=O.filter(A=>A.isCorrect).length,_=k.filter(A=>A.timedOut).length,z=k.filter(A=>A.revealed).length,N=k.filter(A=>!A.isCorrect).sort((A,$)=>$.ms-A.ms).slice(0,3);return{total:p,correct:i,rate:p?Math.round(i/p*100):0,timeMsTotal:R,avgMs:E,totalScore:g,gainedScore:C,fastest:y,slowest:M,singles:{total:T.length,correct:P},multis:{total:O.length,correct:I},timedOut:_,revealed:z,wrongTop3:N}},[t,r,n,m,l,d,i]);return t==="idle"?null:v.jsx("div",{className:ae.Overlay,role:"dialog","aria-modal":"true",children:v.jsx("div",{className:ae.Dialog,children:t==="doing"&&b?v.jsx(vd,{q:b,index:o,total:r.length,selected:S,uiReveal:a,onSelect:c=>{if(a)return;const p=f.getState();Os(b)?p.selectToggle(c):p.selectSingle(c)},onBeforeNext:()=>f.getState().setReveal(!0),onNext:()=>f.getState().afterRevealNext(),remainingSec:u,onClose:()=>f.getState().close()}):v.jsx(Sd,{total:r.length,correct:i,summary:w,retryAllowed:f.getState().retryAllowed,onClose:()=>f.getState().close(),onRetry:()=>{const p=f.getState().quizzes;if(!p.length)return;const g=p[0];f.setState({phase:"doing",currentIndex:0,answers:{},correctCount:0,startedAt:Date.now(),finishedAt:void 0,questionStartedAt:Date.now(),remainingSec:g.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,m=Os(t),f=h.useMemo(()=>{const c=t.options.map((p,g)=>({opt:p,i:g}));for(let p=c.length-1;p>0;p--){const g=Math.floor(Math.random()*(p+1));[c[p],c[g]]=[c[g],c[p]]}return c},[t.options]),b=h.useMemo(()=>md(t),[t]),S=h.useMemo(()=>bd(t),[t]),w=h.useMemo(()=>{const c=[...o].sort((p,g)=>p-g);if(c.length!==S.length)return!1;for(let p=0;p<c.length;p++)if(c[p]!==S[p])return!1;return!0},[o,S]);return v.jsxs("div",{className:ae.Body,children:[v.jsxs("div",{className:ae.Header,children:[v.jsx("div",{className:ae.Paging,children:`Quiz (${n+1}/${r})`}),v.jsx("button",{type:"button",onClick:d,className:ae.CloseBtn,children:"X"})]}),v.jsx("div",{className:ae.Question,children:t.question}),v.jsx("div",{className:ae.Score,children:` (${t.score}점${m?" ,모두선택":""})`}),v.jsx("div",{className:`${ae.Judge}${s?w?` ${ae.Correct}`:` ${ae.Incorrect}`:""}`,"aria-live":"polite",children:s?w?`Correct : +${t.score} point`:"Incorrect : 0 point":"a"}),v.jsx("div",{className:ae.Image,children:b&&v.jsx("img",{src:b,alt:""})}),v.jsx("div",{className:ae.Options,children:f.map(({opt:c,i:p})=>{const g=o.includes(p),C=S.includes(p),k=[ae.OptionBtn,g?ae.OptionBtnActive:"",s&&C?ae.OptionBtnCorrect:""].filter(Boolean).join(" ");return v.jsx("button",{type:"button",onClick:()=>i(p),className:k,disabled:s,children:c},p)})}),v.jsx("div",{className:ae.Footer,children:s?v.jsx("button",{type:"button",onClick:a,className:ae.NextBtn,children:n+1>=r?"Complete":"Next Quiz"}):v.jsxs("button",{type:"button",onClick:u,className:`${ae.NextBtn}`,children:["Submit",typeof l=="number"&&v.jsx("span",{className:`${ae.Remaining} ${l<=5?ae.RemainingDanger:""}`,children:` (${l} s )`})]})})]})}function Oo(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 v.jsxs("div",{className:ae.Body,children:[v.jsx("div",{className:ae.ResultHeader,children:"결과 요약"}),v.jsxs("div",{className:ae.SummaryGrid,role:"list",children:[v.jsxs("div",{className:ae.StatCard,role:"listitem",children:[v.jsx("div",{className:ae.StatLabel,children:"정답률"}),v.jsxs("div",{className:ae.StatValue,children:[u,"%"]}),v.jsx("div",{className:ae.StatSub,children:`정답수 ${n}/문제수${t}`})]}),v.jsxs("div",{className:ae.StatCard,role:"listitem",children:[v.jsx("div",{className:ae.StatLabel,children:"총 점수"}),v.jsx("div",{className:ae.StatValue,children:r?`${r.gainedScore}/${r.totalScore}`:"-"}),v.jsx("div",{className:ae.StatSub,children:"획득점수/최대점수"})]}),v.jsxs("div",{className:ae.StatCard,role:"listitem",children:[v.jsx("div",{className:ae.StatLabel,children:"총 소요 시간"}),v.jsx("div",{className:ae.StatValue,children:Oo(r==null?void 0:r.timeMsTotal)}),v.jsx("div",{className:ae.StatSub,children:`평균 ${Oo(r==null?void 0:r.avgMs)}`})]}),v.jsxs("div",{className:ae.StatCard,role:"listitem",children:[v.jsx("div",{className:ae.StatLabel,children:"타입오버 퀴즈수"}),v.jsx("div",{className:ae.StatValue,children:r?`${r.timedOut}`:"-"}),v.jsx("div",{className:ae.StatSub,children:"timeout"})]})]}),v.jsxs("div",{className:ae.ResultActions,children:[o&&v.jsx("button",{type:"button",onClick:i,className:ae.CloseBtnSoft,children:"다시 풀기"}),v.jsx("button",{type:"button",onClick:s,className:ae.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 Zn(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 zo(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=zo(e);return qt()((u,a)=>({...o,...s,hydrateFromSection:l=>{if(!l)return;const d=zo(l);u(d)},openFromSection:l=>{l&&a().hydrateFromSection(l);const d=a();if(!d.quizzes.length)return;if(!d.retryAllowed&&d.previousResult){const f={};for(const b of d.previousResult.perQuestion)f[b.qid]={qid:b.qid,index:b.index,question:b.question,score:b.score,multi:b.correctIdxes.length>1,selected:b.selected,correctIdxes:b.correctIdxes,isCorrect:b.isCorrect,ms:b.ms,revealed:!0,timedOut:b.timedOut};u({phase:"finished",correctCount:d.previousResult.correct,perQ:f,startedAt:void 0,finishedAt:void 0});return}const m=d.quizzes[0];u({phase:"doing",startedAt:Date.now(),finishedAt:void 0,questionStartedAt:Date.now(),remainingSec:m.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 f=d.quizzes[d.order[d.currentIndex]].qid,b=d.answers[f]??[],S=b.includes(l)?b.filter(w=>w!==l):[...b,l].sort((w,c)=>w-c);u({answers:{...d.answers,[f]:S}})},selectSingle:l=>{const d=a();if(d.phase!=="doing"||d.uiReveal)return;const f=d.quizzes[d.order[d.currentIndex]].qid;u({answers:{...d.answers,[f]:[l]}})},submitCurrent:()=>{const l=a();if(l.phase!=="doing")return;const d=l.order[l.currentIndex],m=l.quizzes[d],f=m.qid,b=(l.answers[f]??[]).slice().sort((C,k)=>C-k),S=Zn(m),w=wd(b,S),c=l.questionStartedAt?Date.now()-l.questionStartedAt:0,p=l.perQ[f],g={qid:f,index:m.index,question:m.question,score:m.score??0,multi:Qn(m),selected:b,correctIdxes:S,isCorrect:w,ms:c,revealed:(p==null?void 0:p.revealed)??!1,timedOut:(p==null?void 0:p.timedOut)??!1};if(u({correctCount:l.correctCount+(w?1:0),perQ:{...l.perQ,[f]:g}}),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 m=d.quizzes[d.order[d.currentIndex]],f=m.qid,b=d.perQ[f],S={qid:f,index:m.index,question:m.question,score:m.score??0,multi:Qn(m),selected:(b==null?void 0:b.selected)??[],correctIdxes:(b==null?void 0:b.correctIdxes)??Zn(m),isCorrect:(b==null?void 0:b.isCorrect)??!1,ms:(b==null?void 0:b.ms)??0,revealed:!0,timedOut:(b==null?void 0:b.timedOut)??!1};u({perQ:{...d.perQ,[f]:S}})}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 m=l.quizzes[l.order[l.currentIndex]],f=m.qid,b=l.perQ[f],S={qid:f,index:m.index,question:m.question,score:m.score??0,multi:Qn(m),selected:(b==null?void 0:b.selected)??[],correctIdxes:(b==null?void 0:b.correctIdxes)??Zn(m),isCorrect:(b==null?void 0:b.isCorrect)??!1,ms:(b==null?void 0:b.ms)??0,revealed:!0,timedOut:!0};u({remainingSec:0,uiReveal:!0,perQ:{...l.perQ,[f]:S}})}else u({remainingSec:d})}}))}function Id({children:e,initialState:t}){const n=h.useMemo(()=>Cd(t.section,{retryAllowed:t.quizRetryAllowed??!0,previousResult:t.previousQuizResult??null}),[t]),r=h.useRef(t.onQuizComplete);return h.useEffect(()=>{r.current=t.onQuizComplete},[t.onQuizComplete]),h.useEffect(()=>{const o=n.subscribe((s,i)=>{if(i.phase!=="finished"&&s.phase==="finished"){const u=r.current;if(!u||!s.retryAllowed&&s.previousResult&&!s.startedAt)return;const{sectionId:a,quizzes:l,order:d,perQ:m,startedAt:f,finishedAt:b}=s,S=d.map(E=>l[E]),w=S.length,c=S.filter(E=>{var x;return(x=m[E.qid])==null?void 0:x.isCorrect}).length,p=S.reduce((E,x)=>E+(x.score??0),0),g=S.reduce((E,x)=>{const y=m[x.qid];return E+(y!=null&&y.isCorrect?x.score??0:0)},0),C=typeof f=="number"&&typeof b=="number"?Math.max(0,b-f):0,k=S.map(E=>{const x=m[E.qid];return{qid:E.qid,index:E.index,question:E.question,score:E.score??0,isCorrect:(x==null?void 0:x.isCorrect)??!1,selected:(x==null?void 0:x.selected)??[],correctIdxes:(x==null?void 0:x.correctIdxes)??[],ms:(x==null?void 0:x.ms)??0,timedOut:(x==null?void 0:x.timedOut)??!1}}),R={sectionId:a??"",total:w,correct:c,rate:w>0?Math.round(c/w*100):0,totalScore:p,gainedScore:g,timeMsTotal:C,perQuestion:k};u(R)}});return()=>o()},[n]),v.jsx(Ir.Provider,{value:n,children:e})}const Po=["mode","theme","fontFamily","fontSizePx","lineHeight","marginX","marginY","pointerStyle","pointerColor","breakMarks","breakGapPx","muteAudio","audioSpeed","showPointer","showSplit","showOverlays","overlayCompactMode","isSettingsOpen"];function Td({containerRef:e}){const t=ht(),n=hn(),r=h.useRef(null);return h.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]),h.useEffect(()=>{const o=n.getState();r.current={};for(const i of Po)r.current[i]=o[i];const s=n.subscribe(i=>{const u=r.current;if(u)for(const a of Po){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=ht(),t=hn(),n=pt(),r=h.useContext(Lo),o=h.useContext(Sn),s=h.useCallback(a=>{const{viewerState:l}=a;if(l){l.mode&&t.getState().setMode(l.mode);const{...f}=l;t.setState(f)}if(typeof a.globalIndex=="number"&&n.getState().progress.setCurrentGlobalRunIndex(a.globalIndex,"playback"),(l==null?void 0:l.mode)==="scroll"||!(l!=null&&l.mode)){const f=()=>{const b=n.getState().progress.getSectionScrollApi();if(!b)return!1;if(a.scrollY===0)b.setScrollTop(0);else if(b.scrollToGIAtOffset){const S=a.anchorGI??a.globalIndex;if(typeof S=="number"){const w=a.anchorOffsetRatio??0;b.scrollToGIAtOffset(S,w)}}return!0};if(!f()){let b=0;const S=setInterval(()=>{(f()||++b>=10)&&clearInterval(S)},50)}}a.audio&&o&&o.getState()._setStatusOnly(a.audio.status);const m=n.getState().progress;a.range?m.setRange(a.range.startGI,a.range.endGI):m.clearRange(),a.translate&&a.translate.isOpen?m.setTranslateState({isOpen:!0,isLoading:a.translate.isLoading,text:a.translate.text,translatedText:a.translate.translatedText,startGI:a.translate.startGI,endGI:a.translate.endGI}):m.clearTranslate()},[t,n,o]),i=h.useCallback(()=>{var R,E,x,y;const a=t.getState(),l=n.getState().progress,d=(R=l.getSectionScrollApi)==null?void 0:R.call(l),m=l.currentGlobalRunIndex??0,f=((E=d==null?void 0:d.getScrollTop)==null?void 0:E.call(d))??0,b=((x=d==null?void 0:d.getAnchorOffsetRatio)==null?void 0:x.call(d,m))??0,S=o==null?void 0:o.getState(),w=S?{status:S.status,currentClip:S.currentClip,currentTimeMs:S.currentTimeMs}:void 0,{rangeStartGI:c,rangeEndGI:p}=l,g=c!=null&&p!=null?{startGI:c,endGI:p,text:l.getRangeText()}:null,C=((y=d==null?void 0:d.getScrollRatio)==null?void 0:y.call(d))??0,k=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:m,scrollY:f,scrollRatio:C,anchorGI:m,anchorOffsetRatio:b,currentPage:l.pageIndex??0,totalPages:l.totalPages,sectionId:l.sectionId??"",viewportWidth:a.viewportWidth,viewportHeight:a.viewportHeight,audio:w,range:g,translate:k}},[t,n,o]),u=h.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:m,anchorOffsetRatio:f}=a.payload,b=n.getState().progress.getSectionScrollApi();b&&(d===0?b.setScrollTop(0):b.scrollToGIAtOffset&&typeof m=="number"&&b.scrollToGIAtOffset(m,f));break}case"settings_change":{const{key:l,value:d}=a.payload,m=t.getState();l in m&&typeof m[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;console.log(`[DirectPlayback] ${a.type}: GI ${l}~${d}`),n.getState().progress.setRange(l,d);const m=n.getState().progress;console.log(`[DirectPlayback] after setRange: rangeStartGI=${m.rangeStartGI}, rangeEndGI=${m.rangeEndGI}`);break}case"range_clear":{console.log("[DirectPlayback] range_clear"),n.getState().progress.clearRange();break}case"translate_request":{const{text:l,startGI:d,endGI:m}=a.payload;n.getState().progress.setTranslateState({isOpen:!0,isLoading:!0,text:l,startGI:d,endGI:m});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 h.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(m=>{m.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]),h.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=ht();return h.useEffect(()=>{const d=e.current;if(!d)return;let m,f;return m=requestAnimationFrame(()=>{f=requestAnimationFrame(()=>{const b=Rd(d);l.setState({wordAvgDistancePx:b})})}),()=>{cancelAnimationFrame(m),cancelAnimationFrame(f)}},[e,l,t,n,r,o,s,i,u,a]),null}const Md=({containerRef:e,onTranslate:t})=>{const n=q(f=>f.rangeStartGI),r=q(f=>f.rangeEndGI),o=q(f=>f.getRangeText),s=q(f=>f.clearRange),i=ht(),u=n!=null&&r!=null,[a,l]=h.useState(null);h.useEffect(()=>{if(!u)return;const f=e.current;if(!f)return;let b=!0;const S=new ResizeObserver(()=>{if(b){b=!1;return}s()});return S.observe(f),()=>S.disconnect()},[u,s,e]),h.useEffect(()=>{if(!u||n==null||r==null){l(null);return}const f=()=>{const S=e.current;if(!S)return;const w=S.getBoundingClientRect(),p=1/(i.getState().playbackScale||1),g=S.querySelector(`[data-g="${r}"]`);if(!g){l({x:w.width*p/2,y:80});return}const C=g.getBoundingClientRect(),k=S.querySelector(`[data-g="${n}"]`),R=k==null?void 0:k.getBoundingClientRect();let E=(C.left+C.width/2-w.left)*p;R&&(E=((R.left+C.right)/2-w.left)*p);const x=160,y=50,M=16,T=12,O=w.width*p,P=Math.max(M+x/2,Math.min(E,O-M-x/2)),I=(((R==null?void 0:R.top)??C.top)-w.top)*p-y-T;let _=I;I<M&&(_=(C.bottom-w.top)*p+T),l({x:P,y:_})};f();const b=e.current;return b&&b.addEventListener("scroll",f,!0),()=>{b&&b.removeEventListener("scroll",f,!0)}},[u,n,r,e,i]);const d=h.useCallback(()=>{const f=o();f&&navigator.clipboard.writeText(f).catch(b=>{console.error("복사 실패:",b)}),s()},[o,s]),m=h.useCallback(()=>{const f=o();f&&t&&t(f)},[o,t]);return!u||!a?null:v.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:[v.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:"복사"}),v.jsx("button",{onClick:m,style:{padding:"8px 16px",backgroundColor:"#10b981",color:"#fff",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:"pointer",whiteSpace:"nowrap"},children:"번역"})]})};function Ed(){const e=q(o=>o.rangeStartGI),t=q(o=>o.rangeEndGI),n=q(o=>o.clearRange),r=e!=null&&t!=null;return h.useEffect(()=>{if(!r)return;const o=s=>{var u;if(xs())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),m=Math.max(e,t);if(l>=d&&l<=m)return}}n()}};return document.addEventListener("click",o,!0),()=>document.removeEventListener("click",o,!0)},[r,e,t,n]),null}const jd=({isOpen:e,isLoading:t=!1,onClose:n,text:r,translatedText:o})=>e?v.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:v.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:[v.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:"✕"}),v.jsx("h3",{style:{margin:"0 0 16px 0",fontSize:18,fontWeight:600,color:"#333"},children:"번역"}),r&&v.jsx("div",{style:{padding:12,backgroundColor:"#f5f5f5",borderRadius:8,fontSize:14,color:"#555",maxHeight:100,overflow:"auto",marginBottom:12},children:r}),t?v.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"16px 0",gap:8,color:"#888",fontSize:15},children:[v.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"}}),"번역 중...",v.jsx("style",{children:"@keyframes cr-translate-spin { to { transform: rotate(360deg); } }"})]}):o?v.jsx("div",{style:{padding:12,backgroundColor:"#eef7ff",borderRadius:8,fontSize:15,color:"#333",maxHeight:150,overflow:"auto",lineHeight:1.5},children:o}):v.jsx("p",{style:{margin:0,fontSize:16,color:"#666",textAlign:"center",padding:"16px 0"},children:"준비중입니다"})]})}):null,Od=(e,t,n)=>Math.min(n,Math.max(t,e));function zd({section:e,initialViewerState:t,initialProgressRunIndex:n,onViewerClose:r,onSectionNav:o,isCanPrev:s=!1,isCanNext:i=!1,onQuizComplete:u,quizRetryAllowed:a,previousQuizResult:l,onViewerEvent:d,viewerRef:m,gazeSync:f,onRequestTranslate:b,isPlaybackMode:S=!1,playbackScale:w,isDev:c=!1}){const p=String((e==null?void 0:e.section_id)??"0"),g=h.useMemo(()=>{var y,M;const E=((y=e==null?void 0:e.ast)==null?void 0:y.blocks)??[];let x=0;for(const T of E)(T==null?void 0:T.type)!=="image"&&(x+=((M=T==null?void 0:T.runs)==null?void 0:M.length)??0);return x},[e]),C=h.useMemo(()=>typeof n=="number"?Od(n,g>0?0:-1,Math.max(g-1,-1)):(g>0,0),[n,g]),k=h.useMemo(()=>({section:e,initialIndex:C,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i}),[e,C,r,o,s,i]),R=h.useMemo(()=>{const E=(e==null?void 0:e.audios)??[],x=E.length>0?ru(e):void 0;return{clips:E,map:x,initialIndex:C,section:e}},[e,C]);return v.jsx(Xs,{onViewerEvent:d,isPlaybackMode:S,playbackScale:w,viewerRef:m,children:v.jsx(cu,{initialState:{...t,isDev:c},children:v.jsx(au,{initialState:k,gazeSync:f,children:v.jsx(nu,{initialState:R,children:v.jsx(Id,{initialState:{section:e,onQuizComplete:u,quizRetryAllowed:a,previousQuizResult:l},children:v.jsx(Pd,{onRequestTranslate:b})},p)},p)},p)})})}function Pd({onRequestTranslate:e}){const t=X(S=>S.mode),n=h.useRef(null),r=ht(),o=pt(),s=q(S=>S.translateOpen),i=q(S=>S.translateLoading),u=q(S=>S.translateText),a=q(S=>S.translatedText),l=h.useRef(null),d=h.useCallback(S=>{var k;const{rangeStartGI:w,rangeEndGI:c}=o.getState().progress,p=w??0,g=c??0;if(r.getState().emit({type:"translate_request",payload:{text:S,startGI:p,endGI:g}}),!e){o.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,text:S,startGI:p,endGI:g});return}o.getState().progress.setTranslateState({isOpen:!0,isLoading:!0,text:S,startGI:p,endGI:g}),(k=l.current)==null||k.abort();const C=new AbortController;l.current=C,e(S,C.signal).then(R=>{if(!C.signal.aborted){if(R==null){o.getState().progress.clearTranslate();return}o.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,text:S,translatedText:R,startGI:p,endGI:g}),r.getState().emit({type:"translate_loading_end",payload:{originalText:S,translatedText:R}})}}).catch(R=>{if(C.signal.aborted)return;const E=R instanceof Error?R.message:"번역 실패";o.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,text:S,translatedText:`[오류] ${E}`,startGI:p,endGI:g})})},[r,o,e]),m=h.useCallback(()=>{var S;(S=l.current)==null||S.abort(),l.current=null,o.getState().progress.clearTranslate(),r.getState().emit({type:"translate_modal_close",payload:{}})},[r,o]),f=S=>{S.preventDefault()},b=S=>{S.preventDefault()};return v.jsxs("div",{ref:n,onContextMenu:f,onDragStart:b,style:{position:"relative",display:"flex",flexDirection:"column",height:"100%",width:"100%",userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"none"},children:[t==="scroll"?v.jsx(va,{}):v.jsx(Bu,{}),v.jsx(Md,{containerRef:n,onTranslate:d}),v.jsx(kl,{containerRef:n}),v.jsx(Xc,{}),v.jsx(xd,{}),v.jsx(Fu,{}),v.jsx(Ed,{}),v.jsx(jd,{isOpen:s,isLoading:i,onClose:m,text:u,translatedText:a}),v.jsx(Td,{containerRef:n}),v.jsx(kd,{}),v.jsx(_d,{containerRef:n})]})}exports.CRViewer=zd;
34
+ */var jr;function Ds(){return jr||(jr=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=g,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,b,f,m){var S=s(null);if(S.current===null){var w={hasValue:!1,value:null};S.current=w}else w=S.current;S=u(function(){function p(O){if(!h){if(h=!0,C=O,O=f(O),m!==void 0&&w.hasValue){var v=w.value;if(m(v,O))return T=v}return T=O}if(v=T,r(C,O))return v;var y=f(O);return m!==void 0&&m(v,y)?(C=O,v):(C=O,T=y)}var h=!1,C,T,_=b===void 0?null:b;return[function(){return p(d())},_===null?void 0:function(){return p(_())}]},[d,b,f,m]);var c=o(l,S[0],S[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 Or;function Ws(){return Or||(Or=1,process.env.NODE_ENV==="production"?Yt.exports=Fs():Yt.exports=Ds()),Yt.exports}var $s=Ws();const Vs=Ao($s),zr=e=>{let t;const n=new Set,r=(l,d)=>{const b=typeof l=="function"?l(t):l;if(!Object.is(b,t)){const f=t;t=d??(typeof b!="object"||b===null)?b:Object.assign({},t,b),n.forEach(m=>m(t,f))}},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},qt=(e=>e?zr(e):zr),{useSyncExternalStoreWithSelector:qs}=Vs,Us=e=>e;function gn(e,t=Us,n){const r=qs(e.subscribe,e.getState,e.getInitialState,t,n);return g.useDebugValue(r),r}function X(e,t){const n=g.useContext(ar);if(!n)throw new Error("useCRViewerScopedStore must be used inside <InternalCRViewerProvider>");return gn(n,e,t)}function hn(){const e=g.useContext(ar);if(!e)throw new Error("useCRViewerStoreApi must be used inside <InternalCRViewerProvider>");return e}const wt=g.createContext(void 0),Lo=g.createContext(void 0);function Ks(){return qt((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 Xs({children:e,onViewerEvent:t,isPlaybackMode:n=!1,playbackScale:r=1,viewerRef:o}){const s=g.useMemo(()=>Ks(),[]);return g.useLayoutEffect(()=>(s.getState().setEmitCallback(t??null),()=>s.getState().setEmitCallback(null)),[t,s]),g.useLayoutEffect(()=>{s.getState().setPlaybackMode(n)},[n,s]),g.useLayoutEffect(()=>{s.getState().setPlaybackScale(r)},[r,s]),g.useLayoutEffect(()=>()=>{o&&(o.current=null)},[o]),x.jsx(wt.Provider,{value:s,children:x.jsx(Lo.Provider,{value:o,children:e})})}function ht(){const e=g.useContext(wt);if(!e)throw new Error("useViewerEventBridgeStoreApi must be used inside <ViewerEventBridgeProvider>");return e}const cr=g.createContext(void 0);function pt(){const e=g.useContext(cr);if(!e)throw new Error("useProgressStoreApi must be used within InternalCRViewerProgressProvider");return e}function q(e,t){const n=g.useContext(cr);if(!n)throw new Error("useProgressStore must be used within InternalCRViewerProgressProvider");return gn(n,o=>e(o.progress),t)}function Qs({onSingle:e,onDouble:t,delay:n=250,shouldIgnoreTarget:r}){const o=g.useRef(null);g.useEffect(()=>()=>{o.current!=null&&(clearTimeout(o.current),o.current=null)},[]);const s=g.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=g.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],Jn=e=>Math.round(12+(e-1)*(16/11)),Ys=e=>{let t=1,n=1/0;for(let r=1;r<=12;r++){const o=Jn(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},Go=[{label:"고딕체",value:"'Noto Sans KR', sans-serif"},{label:"명조체",value:"'Noto Serif KR', serif"},{label:"바탕체",value:"'Nanum Myeongjo', serif"}],He={mode:"page",theme:"light",fontFamily:Go.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 Zs(e){const{init:t,recorderStore:n}=e??{};return qt((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:Jn},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:()=>Ys(o().fontSizePx),getLineLevel:()=>_n(o().lineHeight,kn),getMarginLevel:()=>_n(o().marginX,Tn),setFontLevel:s=>r({fontSizePx:Jn(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 mn=0,mt=1,jt=2,Ho=4;function Pr(e){return()=>e}function Js(e){e()}function No(e,t){return n=>e(t(n))}function Ar(e,t){return()=>e(t)}function ei(e,t){return n=>e(t,n)}function ur(e){return e!==void 0}function ti(...e){return()=>{e.map(Js)}}function Ot(){}function bn(e,t){return t(e),e}function ni(e,t){return t(e)}function Te(...e){return e}function xe(e,t){return e(mt,t)}function ce(e,t){e(mn,t)}function dr(e){e(jt)}function _e(e){return e(Ho)}function ne(e,t){return xe(e,ei(t,mn))}function nt(e,t){const n=e(mt,r=>{n(),t(r)});return n}function Br(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Fo(e,t){return e===t}function Ie(e=Fo){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function se(e){return t=>n=>{e(n)&&t(n)}}function Y(e){return t=>No(t,e)}function it(e){return t=>()=>{t(e)}}function H(e,...t){const n=ri(...t);return((r,o)=>{switch(r){case jt:dr(e);return;case mt:return xe(e,n(o))}})}function lt(e,t){return n=>r=>{n(t=e(t,r))}}function yt(e){return t=>n=>{e>0?e--:t(n)}}function ct(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function de(...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);xe(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 ri(...e){return t=>e.reduceRight(ni,t)}function oi(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case mt:return s?n===s?void 0:(r(),n=s,t=xe(e,s),t):(r(),Ot);case jt:r(),n=null;return}}}function D(e){let t=e;const n=pe();return((r,o)=>{switch(r){case mn:t=o;break;case mt:{o(t);break}case Ho:return t}return n(r,o)})}function Fe(e,t){return bn(D(t),n=>ne(e,n))}function pe(){const e=[];return((t,n)=>{switch(t){case mn:e.slice().forEach(r=>{r(n)});return;case jt:e.splice(0,e.length);return;case mt:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}})}function Xe(e){return bn(pe(),t=>ne(e,t))}function he(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:si(),singleton:n}}const si=()=>Symbol();function ii(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=pe(),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);xe(s,a=>{n[i]=a,r=r|u,r===o&&ce(t,n)})}),function(s,i){switch(s){case jt:{dr(t);return}case mt:return r===o&&i(n),xe(t,i)}}}function oe(e,t=Fo){return H(e,Ie(t))}function er(...e){return function(t,n){switch(t){case jt:return;case mt:return ti(...e.map(r=>xe(r,n)))}}}var Ve=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ve||{});const li={0:"debug",3:"error",1:"log",2:"warn"},ai=()=>typeof globalThis>"u"?window:globalThis,bt=he(()=>{const e=D(3);return{log:D((t,n,r=1)=>{var o;const s=(o=ai().VIRTUOSO_LOG_LEVEL)!=null?o:_e(e);r>=s&&console[li[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 fr(e,t,n).callbackRef}function fr(e,t,n){const r=g.useRef(null);let o=i=>{};const s=g.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 ci(e,t,n,r,o,s,i,u,a){const l=g.useCallback(d=>{const b=ui(d.children,t,u?"offsetWidth":"offsetHeight",o);let f=d.parentElement;for(;!f.dataset.virtuosoScroller;)f=f.parentElement;const m=f.lastElementChild.dataset.viewportType==="window";let S;m&&(S=f.ownerDocument.defaultView);const w=i?u?i.scrollLeft:i.scrollTop:m?u?S.scrollX||S.document.documentElement.scrollLeft:S.scrollY||S.document.documentElement.scrollTop:u?f.scrollLeft:f.scrollTop,c=i?u?i.scrollWidth:i.scrollHeight:m?u?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight:u?f.scrollWidth:f.scrollHeight,p=i?u?i.offsetWidth:i.offsetHeight:m?u?S.innerWidth:S.innerHeight:u?f.offsetWidth:f.offsetHeight;r({scrollHeight:c,scrollTop:Math.max(w,0),viewportHeight:p}),s==null||s(u?Lr("column-gap",getComputedStyle(d).columnGap,o):Lr("row-gap",getComputedStyle(d).rowGap,o)),b!==null&&e(b)},[e,t,o,s,i,r,u]);return fr(l,n,a)}function ui(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},Ve.ERROR),d===l)continue;const b=s[s.length-1];s.length===0||b.size!==d||b.endIndex!==a-1?s.push({endIndex:a,size:d,startIndex:a}):s[s.length-1].endIndex++}return s}function Lr(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ve.WARN),t==="normal"?0:parseInt(t??"0",10)}function Do(e,t,n){const r=g.useRef(null),o=g.useCallback(a=>{if(!(a!=null&&a.offsetParent))return;const l=a.getBoundingClientRect(),d=l.width;let b,f;if(t){const m=t.getBoundingClientRect(),S=l.top-m.top;f=m.height-Math.max(0,S),b=S+t.scrollTop}else{const m=i.current.ownerDocument.defaultView;f=m.innerHeight-Math.max(0,l.top),b=l.top+m.scrollY}r.current={offsetTop:b,visibleHeight:f,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=fr(o,!0,n),u=g.useCallback(()=>{o(i.current)},[o,i]);return g.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=he(()=>{const e=pe(),t=pe(),n=D(0),r=pe(),o=D(0),s=pe(),i=pe(),u=D(0),a=D(0),l=D(0),d=D(0),b=pe(),f=pe(),m=D(!1),S=D(!1),w=D(!1);return ne(H(e,Y(({scrollTop:c})=>c)),t),ne(H(e,Y(({scrollHeight:c})=>c)),i),ne(t,o),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:a,footerHeight:d,headerHeight:u,horizontalDirection:S,scrollBy:f,scrollContainerState:e,scrollHeight:i,scrollingInProgress:m,scrollTo:b,scrollTop:t,skipAnimationFrameInResizeObserver:w,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Gt={lvl:0};function Wo(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 Se(e){return e===Gt}function Ht(e,t){if(!Se(e))return t===e.k?e.v:t<e.k?Ht(e.l,t):Ht(e.r,t)}function rt(e,t,n="k"){if(Se(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=rt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return rt(e.l,t,n)}function Ke(e,t,n){return Se(e)?qo(t,n,1):t===e.k?Le(e,{k:t,v:n}):t<e.k?Gr(Le(e,{l:Ke(e.l,t,n)})):Gr(Le(e,{r:Ke(e.r,t,n)}))}function _t(){return Gt}function Mt(e,t,n){if(Se(e))return[];const r=rt(e,t)[0];return di(nr(e,r,n))}function tr(e,t){if(Se(e))return Gt;const{k:n,l:r,r:o}=e;if(t===n){if(Se(r))return o;if(Se(o))return r;{const[s,i]=Vo(r);return rn(Le(e,{k:s,l:$o(r),v:i}))}}else return t<n?rn(Le(e,{l:tr(r,t)})):rn(Le(e,{r:tr(o,t)}))}function St(e){return Se(e)?[]:[...St(e.l),{k:e.k,v:e.v},...St(e.r)]}function nr(e,t,n){if(Se(e))return[];const{k:r,l:o,r:s,v:i}=e;let u=[];return r>t&&(u=u.concat(nr(o,t,n))),r>=t&&r<=n&&u.push({k:r,v:i}),r<=n&&(u=u.concat(nr(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 Uo(Le(e,{lvl:n-1}));if(!Se(t)&&!Se(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 rr(Le(e,{lvl:n-1}));if(!Se(r)&&!Se(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:rr(Le(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Le(e,t){return qo(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 $o(e){return Se(e.r)?e.l:rn(Le(e,{r:$o(e.r)}))}function Mn(e){return Se(e)||e.lvl>e.r.lvl}function Vo(e){return Se(e.r)?[e.k,e.v]:Vo(e.r)}function qo(e,t,n,r=Gt,o=Gt){return{k:e,l:r,lvl:n,r:o,v:t}}function Gr(e){return rr(Uo(e))}function Uo(e){const{l:t}=e;return!Se(t)&&t.lvl===e.lvl?Le(t,{r:Le(e,{l:t.r})}):e}function rr(e){const{lvl:t,r:n}=e;return!Se(n)&&!Se(n.r)&&n.lvl===t&&n.r.lvl===t?Le(n,{l:Le(e,{r:n.l}),lvl:t+1}):e}function di(e){return Wo(e,({k:t,v:n})=>({index:t,value:n}))}function Ko(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Nt(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const pr=he(()=>({recalcInProgress:D(!1)}),[],{singleton:!0});function Xo(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 fi(e,t,n,r){const o=ln(e,t,r),s=ln(e,n,r,o);return e.slice(o,s+1)}function gt(e,t){return Math.round(e.getBoundingClientRect()[t])}function xn(e){return!Se(e.groupOffsetTree)}function gr({index:e},t){return t===e?0:t<e?-1:1}function pi(){return{groupIndices:[],groupOffsetTree:_t(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:_t()}}function gi(e,t){let n=Se(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Se(e)){e=Ke(e,0,s);continue}const u=Mt(e,i-1,o+1);if(u.some(yi(r)))continue;let a=!1,l=!1;for(const{end:d,start:b,value:f}of u)a?(o>=b||s===f)&&(e=tr(e,b)):(l=f!==s,a=!0),d>o&&o>=b&&f!==s&&(e=Ke(e,o+1,f));l&&(e=Ke(e,i,s))}return[e,n]}function hi(e){return typeof e.groupIndex<"u"}function mi({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}=Xo(t,e,gr),i=e-r,u=s*i+(i-1)*n+o;return u>0?u+n:u}function Qo(e,t){if(!xn(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Yo(e,t,n){if(hi(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Qo(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function bi(e,t,n,r=0){return r>0&&(t=Math.max(t,Xo(e,r,gr).offset)),Wo(fi(e,t,n,mi),Si)}function xi(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ve.DEBUG);const s=e.sizeTree;let i=s,u=0;if(n.length>0&&Se(s)&&t.length===2){const f=t[0].size,m=t[1].size;i=n.reduce((S,w)=>Ke(Ke(S,w,f),w+1,m),i)}else[i,u]=gi(i,t);if(i===s)return e;const{lastIndex:a,lastOffset:l,lastSize:d,offsetTree:b}=or(e.offsetTree,u,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((f,m)=>Ke(f,m,Ft(m,b,o)),_t()),lastIndex:a,lastOffset:l,lastSize:d,offsetTree:b,sizeTree:i}}function vi(e){return St(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 Hr(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 or(e,t,n,r){let o=e,s=0,i=0,u=0,a=0;if(t!==0){a=ln(o,t-1,gr),u=o[a].offset;const l=rt(n,t-1);s=l[0],i=l[1],o.length&&o[a].size===rt(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 b=l-s,f=b*i+u+b*r;o.push({index:l,offset:f,size:d}),s=l,u=f,i=d}return{lastIndex:s,lastOffset:u,lastSize:i,offsetTree:o}}function Si(e){return{index:e.index,value:e}}function yi(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 wi={offsetHeight:"height",offsetWidth:"width"},at=he(([{log:e},{recalcInProgress:t}])=>{const n=pe(),r=pe(),o=Fe(r,0),s=pe(),i=pe(),u=D(0),a=D([]),l=D(void 0),d=D(void 0),b=D(void 0),f=D(void 0),m=D((v,y)=>gt(v,wi[y])),S=D(void 0),w=D(0),c=pi(),p=Fe(H(n,de(a,e,w),lt(xi,c),Ie()),c),h=Fe(H(a,Ie(),lt((v,y)=>({current:y,prev:v.current}),{current:[],prev:[]}),Y(({prev:v})=>v)),[]);ne(H(a,se(v=>v.length>0),de(p,w),Y(([v,y,R])=>{const k=v.reduce((E,P,I)=>Ke(E,P,Ft(P,y.offsetTree,R)||I),_t());return{...y,groupIndices:v,groupOffsetTree:k}})),p),ne(H(r,de(p),se(([v,{lastIndex:y}])=>v<y),Y(([v,{lastIndex:y,lastSize:R}])=>[{endIndex:y,size:R,startIndex:v}])),n),ne(l,d);const C=Fe(H(l,Y(v=>v===void 0)),!0);ne(H(d,se(v=>v!==void 0&&Se(_e(p).sizeTree)),Y(v=>{const y=_e(b),R=_e(a).length>0;return y?R?[{endIndex:0,size:y,startIndex:0},{endIndex:1,size:v,startIndex:1}]:[]:[{endIndex:0,size:v,startIndex:0}]})),n),ne(H(f,se(v=>v!==void 0&&v.length>0&&Se(_e(p).sizeTree)),Y(v=>{const y=[];let R=v[0],k=0;for(let E=1;E<v.length;E++){const P=v[E];P!==R&&(y.push({endIndex:E-1,size:R,startIndex:k}),R=P,k=E)}return y.push({endIndex:v.length-1,size:R,startIndex:k}),y})),n),ne(H(a,de(b,d),se(([,v,y])=>v!==void 0&&y!==void 0),Y(([v,y,R])=>{const k=[];for(let E=0;E<v.length;E++){const P=v[E],I=v[E+1];k.push({startIndex:P,endIndex:P,size:y}),I!==void 0&&k.push({startIndex:P+1,endIndex:I-1,size:R})}return k})),n);const T=Xe(H(n,de(p),lt(({sizes:v},[y,R])=>({changed:R!==v,sizes:R}),{changed:!1,sizes:c}),Y(v=>v.changed)));xe(H(u,lt((v,y)=>({diff:v.prev-y,prev:y}),{diff:0,prev:0}),Y(v=>v.diff)),v=>{const{groupIndices:y}=_e(p);if(v>0)ce(t,!0),ce(s,v+Hr(v,y));else if(v<0){const R=_e(h);R.length>0&&(v-=Hr(-v,R)),ce(i,v)}}),xe(H(u,de(e)),([v,y])=>{v<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},Ve.ERROR)});const _=Xe(s);ne(H(s,de(p),Y(([v,y])=>{const R=y.groupIndices.length>0,k=[],E=y.lastSize;if(R){const P=Ht(y.sizeTree,0);let I=0,M=0;for(;I<v;){const N=y.groupIndices[M],A=y.groupIndices.length===M+1?1/0:y.groupIndices[M+1]-N-1;k.push({endIndex:N,size:P,startIndex:N}),k.push({endIndex:N+1+A-1,size:E,startIndex:N+1}),M++,I+=A+1}const z=St(y.sizeTree);return I!==v&&z.shift(),z.reduce((N,{k:A,v:$})=>{let te=N.ranges;return N.prevSize!==0&&(te=[...N.ranges,{endIndex:A+v-1,size:N.prevSize,startIndex:N.prevIndex}]),{prevIndex:A+v,prevSize:$,ranges:te}},{prevIndex:v,prevSize:0,ranges:k}).ranges}return St(y.sizeTree).reduce((P,{k:I,v:M})=>({prevIndex:I+v,prevSize:M,ranges:[...P.ranges,{endIndex:I+v-1,size:P.prevSize,startIndex:P.prevIndex}]}),{prevIndex:0,prevSize:E,ranges:[]}).ranges})),n);const O=Xe(H(i,de(p,w),Y(([v,{offsetTree:y},R])=>{const k=-v;return Ft(k,y,R)})));return ne(H(i,de(p,w),Y(([v,y,R])=>{if(y.groupIndices.length>0){if(Se(y.sizeTree))return y;let k=_t();const E=_e(h);let P=0,I=0,M=0;for(;P<-v;){M=E[I];const z=E[I+1]-M-1;I++,P+=z+1}if(k=St(y.sizeTree).reduce((z,{k:N,v:A})=>Ke(z,Math.max(0,N+v),A),k),P!==-v){const z=Ht(y.sizeTree,M);k=Ke(k,0,z);const N=rt(y.sizeTree,-v+1)[1];k=Ke(k,1,N)}return{...y,sizeTree:k,...or(y.offsetTree,0,k,R)}}else{const k=St(y.sizeTree).reduce((E,{k:P,v:I})=>Ke(E,Math.max(0,P+v),I),_t());return{...y,sizeTree:k,...or(y.offsetTree,0,k,R)}}})),p),{beforeUnshiftWith:_,data:S,defaultItemSize:d,firstItemIndex:u,fixedItemSize:l,fixedGroupSize:b,gap:w,groupIndices:a,heightEstimates:f,itemSize:m,listRefresh:T,shiftWith:i,shiftWithOffset:O,sizeRanges:n,sizes:p,statefulTotalCount:o,totalCount:r,trackItemSizes:C,unshiftWith:s}},Te(bt,pr),{singleton:!0});function Ci(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Zo=he(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=pe(),i=pe(),u=Xe(H(s,Y(Ci)));return ne(H(u,Y(a=>a.totalCount)),n),ne(H(u,Y(a=>a.groupIndices)),e),ne(H(Pe(o,t,r),se(([a,l])=>xn(l)),Y(([a,l,d])=>rt(l.groupOffsetTree,Math.max(a-d,0),"v")[0]),Ie(),Y(a=>[a])),i),{groupCounts:s,topItemsIndexes:i}},Te(at,De)),xt=he(([{log:e}])=>{const t=D(!1),n=Xe(H(t,se(r=>r),Ie()));return xe(t,r=>{r&&_e(e)("props updated",{},Ve.DEBUG)}),{didMount:n,propsReady:t}},Te(bt),{singleton:!0}),Ii=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Jo(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Ii)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Ut=he(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:u,scrollingInProgress:a,scrollTo:l,smoothScrollTargetReached:d,viewportHeight:b},{log:f}])=>{const m=pe(),S=pe(),w=D(0);let c=null,p=null,h=null;function C(){c&&(c(),c=null),h&&(h(),h=null),p&&(clearTimeout(p),p=null),ce(a,!1)}return ne(H(m,de(n,b,r,w,u,i,f),de(e,s,o),Y(([[T,_,O,v,y,R,k,E],P,I,M])=>{const z=Jo(T),{align:N,behavior:A,offset:$}=z,te=v-1,fe=Yo(z,_,te);let ge=Ft(fe,_.offsetTree,P)+R;N==="end"?(ge+=I+rt(_.sizeTree,fe)[1]-O+M,fe===te&&(ge+=k)):N==="center"?ge+=(I+rt(_.sizeTree,fe)[1]-O+M)/2:ge-=y,$&&(ge+=$);const ve=me=>{C(),me?(E("retrying to scroll to",{location:T},Ve.DEBUG),ce(m,T)):(ce(S,!0),E("list did not change, scroll successful",{},Ve.DEBUG))};if(C(),A==="smooth"){let me=!1;h=xe(t,Ae=>{me=me||Ae}),c=nt(d,()=>{ve(me)})}else c=nt(H(t,Ti(150)),ve);return p=setTimeout(()=>{C()},1200),ce(a,!0),E("scrolling from index to",{behavior:A,index:fe,top:ge},Ve.DEBUG),{behavior:A,top:ge}})),l),{scrollTargetReached:S,scrollToIndex:m,topListHeight:w}},Te(at,De,bt),{singleton:!0});function Ti(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function hr(e,t){e==0?t():requestAnimationFrame(()=>{hr(e-1,t)})}function mr(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Kt=he(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const u=D(!0),a=D(0),l=D(!0);return ne(H(i,de(a),se(([d,b])=>!!b),it(!1)),u),ne(H(i,de(a),se(([d,b])=>!!b),it(!1)),l),xe(H(Pe(t,i),de(u,n,e,l),se(([[,d],b,{sizeTree:f},m,S])=>d&&(!Se(f)||ur(m))&&!b&&!S),de(a)),([,d])=>{nt(o,()=>{ce(l,!0)}),hr(4,()=>{nt(r,()=>{ce(u,!0)}),ce(s,d)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:a,scrolledToInitialItem:u}},Te(at,De,Ut,xt),{singleton:!0});function es(e,t){return Math.abs(e-t)<1.01}const Dt="up",Bt="down",ki="none",Ri={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},_i=0,Xt=he(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=D(!1),u=D(!0),a=pe(),l=pe(),d=D(4),b=D(_i),f=Fe(H(er(H(oe(o),yt(1),it(!0)),H(oe(o),yt(1),it(!1),Br(100))),Ie()),!1),m=Fe(H(er(H(n,it(!0)),H(n,it(!1),Br(200))),Ie()),!1);ne(H(Pe(oe(o),oe(b)),Y(([h,C])=>h<=C),Ie()),u),ne(H(u,ct(50)),l);const S=Xe(H(Pe(r,oe(s),oe(t),oe(e),oe(d)),lt((h,[{scrollHeight:C,scrollTop:T},_,O,v,y])=>{const R=T+_-C>-y,k={scrollHeight:C,scrollTop:T,viewportHeight:_};if(R){let P,I;return T>h.state.scrollTop?(P="SCROLLED_DOWN",I=h.state.scrollTop-T):(P="SIZE_DECREASED",I=h.state.scrollTop-T||h.scrollTopDelta),{atBottom:!0,atBottomBecause:P,scrollTopDelta:I,state:k}}let E;return k.scrollHeight>h.state.scrollHeight?E="SIZE_INCREASED":_<h.state.viewportHeight?E="VIEWPORT_HEIGHT_DECREASING":T<h.state.scrollTop?E="SCROLLING_UPWARDS":E="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:E,state:k}},Ri),Ie((h,C)=>h&&h.atBottom===C.atBottom))),w=Fe(H(r,lt((h,{scrollHeight:C,scrollTop:T,viewportHeight:_})=>{if(es(h.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:T};{const O=C-(T+_)<1;return h.scrollTop!==T&&O?{changed:!0,jump:h.scrollTop-T,scrollHeight:C,scrollTop:T}:{changed:!0,jump:0,scrollHeight:C,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),se(h=>h.changed),Y(h=>h.jump)),0);ne(H(S,Y(h=>h.atBottom)),i),ne(H(i,ct(50)),a);const c=D(Bt);ne(H(r,Y(({scrollTop:h})=>h),Ie(),lt((h,C)=>_e(m)?{direction:h.direction,prevScrollTop:C}:{direction:C<h.prevScrollTop?Dt:Bt,prevScrollTop:C},{direction:Bt,prevScrollTop:0}),Y(h=>h.direction)),c),ne(H(r,ct(50),it(ki)),c);const p=D(0);return ne(H(f,se(h=>!h),it(0)),p),ne(H(o,ct(100),de(f),se(([h,C])=>C),lt(([h,C],[T])=>[C,T],[0,0]),Y(([h,C])=>C-h)),p),{atBottomState:S,atBottomStateChange:a,atBottomThreshold:d,atTopStateChange:l,atTopThreshold:b,isAtBottom:i,isAtTop:u,isScrolling:f,lastJumpDueToItemResize:w,scrollDirection:c,scrollVelocity:p}},Te(De)),Wt="top",$t="bottom",Nr="none";function Fr(e,t,n){return typeof e=="number"?n===Dt&&t===Wt||n===Bt&&t===$t?e:0:n===Dt?t===Wt?e.main:e.reverse:t===$t?e.main:e.reverse}function Dr(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const br=he(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=pe(),i=D(0),u=D(0),a=D(0),l=Fe(H(Pe(oe(r),oe(o),oe(n),oe(s,Nt),oe(a),oe(i),oe(t),oe(e),oe(u)),Y(([d,b,f,[m,S],w,c,p,h,C])=>{const T=d-h,_=c+p,O=Math.max(f-T,0);let v=Nr;const y=Dr(C,Wt),R=Dr(C,$t);return m-=h,m+=f+p,S+=f+p,S-=h,m>d+_-y&&(v=Dt),S<d-O+b+R&&(v=Bt),v!==Nr?[Math.max(T-f-Fr(w,Wt,v)-y,0),T-O-p+b+Fr(w,$t,v)+R]:null}),se(d=>d!=null),Ie(Nt)),[0,0]);return{increaseViewportBy:u,listBoundary:s,overscan:a,topListHeight:i,visibleRange:l}},Te(De),{singleton:!0});function Mi(e,t,n){if(xn(t)){const r=Qo(e,t);return[{index:rt(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 b=n-i,f=u+b*a+(b-1)*r,m=l,S=f-d;return{bottom:d,firstItemIndex:s,items:Wr(e,o,s),offsetBottom:S,offsetTop:l,top:m,topItems:Wr(t,o,s),topListHeight:t.reduce((w,c)=>c.size+w,0),totalCount:n}}function ts(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=mr(t,u),l=Array.from({length:u}).map((d,b)=>({data:s[b+a],index:b+a,offset:0,size:0}));return on(l,[],u,o,n,r)}function Wr(e,t,n){if(e.length===0)return[];if(!xn(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 $r(e,t){var n;return e===void 0?0:typeof e=="number"?e:(n=e[t])!=null?n:0}const It=he(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:u,visibleRange:a},{initialTopMostItemIndex:l,scrolledToInitialItem:d},{topListHeight:b},f,{didMount:m},{recalcInProgress:S}])=>{const w=D([]),c=D(0),p=pe(),h=D(0);ne(s.topItemsIndexes,w);const C=Fe(H(Pe(m,S,oe(a,Nt),oe(o),oe(r),oe(l),d,oe(w),oe(t),oe(n),oe(h),e),se(([v,y,,R,,,,,,,,k])=>{const E=k&&k.length!==R;return v&&!y&&!E}),Y(([,,[v,y],R,k,E,P,I,M,z,N,A])=>{var $,te,fe,ge;const ve=k,{offsetTree:me,sizeTree:Ae}=ve,K=_e(c);if(R===0)return{...En,totalCount:R};if(v===0&&y===0)return K===0?{...En,totalCount:R}:ts(K,E,k,M,z,A||[]);if(Se(Ae))return K>0?null:on(Mi(mr(E,R),ve,A),[],R,z,ve,M);const W=[];if(I.length>0){const F=I[0],Q=I[I.length-1];let ee=0;for(const J of Mt(Ae,F,Q)){const ie=J.value,re=Math.max(J.start,F),be=Math.min(J.end,Q);for(let ue=re;ue<=be;ue++)W.push({data:A==null?void 0:A[ue],index:ue,offset:ee,size:ie}),ee+=ie}}if(!P)return on([],W,R,z,ve,M);const L=I.length>0?I[I.length-1]+1:0,j=bi(me,v,y,L);if(j.length===0)return null;const G=R-1,V=bn([],F=>{for(const Q of j){const ee=Q.value;let J=ee.offset,ie=Q.start;const re=ee.size;if(ee.offset<v){ie+=Math.floor((v-ee.offset+z)/(re+z));const ue=ie-Q.start;J+=ue*re+ue*z}ie<L&&(J+=(L-ie)*re,ie=L);const be=Math.min(Q.end,G);for(let ue=ie;ue<=be&&!(J>=y);ue++)F.push({data:A==null?void 0:A[ue],index:ue,offset:J,size:re}),J+=re+z}}),B=$r(N,Wt),Z=$r(N,$t);if(V.length>0&&(B>0||Z>0)){const F=V[0],Q=V[V.length-1];if(B>0&&F.index>L){const ee=Math.min(B,F.index-L),J=[];let ie=F.offset;for(let re=F.index-1;re>=F.index-ee;re--){const be=(te=($=Mt(Ae,re,re)[0])==null?void 0:$.value)!=null?te:F.size;ie-=be+z,J.unshift({data:A==null?void 0:A[re],index:re,offset:ie,size:be})}V.unshift(...J)}if(Z>0&&Q.index<G){const ee=Math.min(Z,G-Q.index);let J=Q.offset+Q.size+z;for(let ie=Q.index+1;ie<=Q.index+ee;ie++){const re=(ge=(fe=Mt(Ae,ie,ie)[0])==null?void 0:fe.value)!=null?ge:Q.size;V.push({data:A==null?void 0:A[ie],index:ie,offset:J,size:re}),J+=re+z}}}return on(V,W,R,z,ve,M)}),se(v=>v!==null),Ie()),En);ne(H(e,se(ur),Y(v=>v==null?void 0:v.length)),o),ne(H(C,Y(v=>v.topListHeight)),b),ne(b,u),ne(H(C,Y(v=>[v.top,v.bottom])),i),ne(H(C,Y(v=>v.items)),p);const T=Xe(H(C,se(({items:v})=>v.length>0),de(o,e),se(([{items:v},y])=>v[v.length-1].originalIndex===y-1),Y(([,v,y])=>[v-1,y]),Ie(Nt),Y(([v])=>v))),_=Xe(H(C,ct(200),se(({items:v,topItems:y})=>v.length>0&&v[0].originalIndex===y.length),Y(({items:v})=>v[0].index),Ie())),O=Xe(H(C,se(({items:v})=>v.length>0),Y(({items:v})=>{let y=0,R=v.length-1;for(;v[y].type==="group"&&y<R;)y++;for(;v[R].type==="group"&&R>y;)R--;return{endIndex:v[R].index,startIndex:v[y].index}}),Ie(Ko)));return{endReached:T,initialItemCount:c,itemsRendered:p,listState:C,minOverscanItemCount:h,rangeChanged:O,startReached:_,topItemsIndexes:w,...f}},Te(at,Zo,br,Kt,Ut,Xt,xt,pr),{singleton:!0}),ns=he(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=pe(),i=Fe(H(Pe(n,e,r,t,o),Y(([u,a,l,d,b])=>u+a+l+d+b.offsetBottom+b.bottom)),0);return ne(oe(i),s),{totalListHeight:i,totalListHeightChanged:s}},Te(De,It),{singleton:!0}),Ei=he(([{viewportHeight:e},{totalListHeight:t}])=>{const n=D(!1),r=Fe(H(Pe(n,e,t),se(([o])=>o),Y(([,o,s])=>Math.max(0,o-s)),ct(0),Ie()),0);return{alignToBottom:n,paddingTopAddition:r}},Te(De,ns),{singleton:!0}),rs=he(()=>({context:D(null)})),ji=({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,os=he(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:u,viewportHeight:a},{scrollToIndex:l}])=>{const d=pe();return ne(H(d,de(t,a,n,s,o,r,u),de(e),Y(([[b,f,m,S,w,c,p,h],C])=>{const{align:T,behavior:_,calculateViewLocation:O=ji,done:v,...y}=b,R=Yo(b,f,S-1),k=Ft(R,f.offsetTree,C)+w+c,E=k+rt(f.sizeTree,R)[1],P=h+c,I=h+m-p,M=O({itemBottom:E,itemTop:k,locationParams:{align:T,behavior:_,...y},viewportBottom:I,viewportTop:P});return M?v&&nt(H(i,se(z=>!z),yt(_e(i)?1:2)),v):v==null||v(),M}),se(b=>b!==null)),l),{scrollIntoView:d}},Te(at,De,Ut,It,bt),{singleton:!0});function Vr(e){return e?e==="smooth"?"smooth":"auto":!1}const Oi=(e,t)=>typeof e=="function"?Vr(e(t)):t&&Vr(e),zi=he(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:u},{didMount:a,propsReady:l},{log:d},{scrollingInProgress:b},{context:f},{scrollIntoView:m}])=>{const S=D(!1),w=pe();let c=null;function p(_){ce(i,{align:"end",behavior:_,index:"LAST"})}xe(H(Pe(H(oe(t),yt(1)),a),de(oe(S),s,u,b),Y(([[_,O],v,y,R,k])=>{let E=O&&R,P="auto";return E&&(P=Oi(v,y||k),E=E&&!!P),{followOutputBehavior:P,shouldFollow:E,totalCount:_}}),se(({shouldFollow:_})=>_)),({followOutputBehavior:_,totalCount:O})=>{c&&(c(),c=null),_e(n)?requestAnimationFrame(()=>{_e(d)("following output to ",{totalCount:O},Ve.DEBUG),p(_)}):c=nt(e,()=>{_e(d)("following output to ",{totalCount:O},Ve.DEBUG),p(_),c=null})});function h(_){const O=nt(o,v=>{_&&!v.atBottom&&v.notAtBottomBecause==="SIZE_INCREASED"&&!c&&(_e(d)("scrolling to bottom due to increased size",{},Ve.DEBUG),p("auto"))});setTimeout(O,100)}xe(H(Pe(oe(S),t,l),se(([_,,O])=>_&&O),lt(({value:_},[,O])=>({refreshed:_===O,value:O}),{refreshed:!1,value:0}),se(({refreshed:_})=>_),de(S,t)),([,_])=>{_e(u)&&h(_!==!1)}),xe(w,()=>{h(_e(S)!==!1)}),xe(Pe(oe(S),o),([_,O])=>{_&&!O.atBottom&&O.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&p("auto")});const C=D(null),T=pe();return ne(er(H(oe(r),Y(_=>{var O;return(O=_==null?void 0:_.length)!=null?O:0})),H(oe(t))),T),xe(H(Pe(H(T,yt(1)),a),de(oe(C),u,b,f),Y(([[_,O],v,y,R,k])=>O&&y&&(v==null?void 0:v({context:k,totalCount:_,scrollingInProgress:R}))),se(_=>!!_),ct(0)),_=>{c&&(c(),c=null),_e(n)?requestAnimationFrame(()=>{_e(d)("scrolling into view",{}),ce(m,_)}):c=nt(e,()=>{_e(d)("scrolling into view",{}),ce(m,_),c=null})}),{autoscrollToBottom:w,followOutput:S,scrollIntoViewOnChange:C}},Te(at,Xt,Ut,Kt,xt,bt,De,rs,os)),Pi=he(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:u}])=>(ne(H(u,de(s),se(([,a])=>a!==0),de(o,r,t,n,e),Y(([[,a],l,d,b,f,m=[]])=>ts(a,l,d,b,f,m))),i),{}),Te(at,Kt,It,xt),{singleton:!0}),Ai=he(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=D(0);return xe(H(e,de(r),se(([,o])=>o!==0),Y(([,o])=>({top:o}))),o=>{nt(H(n,yt(1),se(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{ce(t,o)})})}),{initialScrollTop:r}},Te(xt,De,It),{singleton:!0}),ss=he(([{scrollVelocity:e}])=>{const t=D(!1),n=pe(),r=D(!1);return ne(H(e,de(r,t,n),se(([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}),Ie()),t),xe(H(Pe(t,e,n),de(r)),([[o,s,i],u])=>{o&&u&&u.change&&u.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},Te(Xt),{singleton:!0}),xr=he(([{scrollContainerState:e,scrollTo:t}])=>{const n=pe(),r=pe(),o=pe(),s=D(!1),i=D(void 0);return ne(H(Pe(n,r),Y(([{scrollHeight:u,scrollTop:a,viewportHeight:l},{offsetTop:d}])=>({scrollHeight:u,scrollTop:Math.max(0,a-d),viewportHeight:l}))),e),ne(H(t,de(r),Y(([u,{offsetTop:a}])=>({...u,top:u.top+a}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},Te(De)),Bi=he(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:u,windowViewportRect:a}])=>{const l=pe(),d=D(void 0),b=D(null),f=D(null);return ne(u,b),ne(a,f),xe(H(l,de(t,r,i,b,f,n)),([m,S,w,c,p,h,C])=>{const T=vi(S.sizeTree);c&&p!==null&&h!==null&&(w=p.scrollTop-h.offsetTop),w-=C,m({ranges:T,scrollTop:w})}),ne(H(d,se(ur),Y(Li)),o),ne(H(s,de(d),se(([,m])=>m!==void 0),Ie(),Y(([,m])=>m.ranges)),e),{getState:l,restoreStateFrom:d}},Te(at,De,Kt,xt,xr));function Li(e){return{align:"start",index:0,offset:e.scrollTop}}const Gi=he(([{topItemsIndexes:e}])=>{const t=D(0);return ne(H(t,se(n=>n>=0),Y(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},Te(It));function is(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}const Hi=is(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Ni=he(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:u},{listState:a},{beforeUnshiftWith:l,gap:d,shiftWithOffset:b,sizes:f},{log:m},{recalcInProgress:S}])=>{const w=Xe(H(a,de(i),lt(([,p,h,C],[{bottom:T,items:_,offsetBottom:O,totalCount:v},y])=>{const R=T+O;let k=0;return h===v&&p.length>0&&_.length>0&&(_[0].originalIndex===0&&p[0].originalIndex===0||(k=R-C,k!==0&&(k+=y))),[k,_,v,R]},[0,[],0,0]),se(([p])=>p!==0),de(r,u,n,o,m,S),se(([,p,h,C,,,T])=>!T&&!C&&p!==0&&h===Dt),Y(([[p],,,,,h])=>(h("Upward scrolling compensation",{amount:p},Ve.DEBUG),p))));function c(p){p>0?(ce(t,{behavior:"auto",top:-p}),ce(e,0)):(ce(e,0),ce(t,{behavior:"auto",top:-p}))}return xe(H(w,de(e,s)),([p,h,C])=>{C&&Hi()?ce(e,h-p):c(-p)}),xe(H(Pe(Fe(s,!1),e,S),se(([p,h,C])=>!p&&!C&&h!==0),Y(([p,h])=>h),ct(1)),c),ne(H(b,Y(p=>({top:-p}))),t),xe(H(l,de(f,d),Y(([p,{groupIndices:h,lastSize:C,sizeTree:T},_])=>{function O(v){return v*(C+_)}if(h.length===0)return O(p);{let v=0;const y=Ht(T,0);let R=0,k=0;for(;R<p;){R++,v+=y;let E=h.length===k+1?1/0:h[k+1]-h[k]-1;R+E>p&&(v-=y,E=p-R+1),R+=E,v+=O(E),k++}return v}})),p=>{ce(e,p),requestAnimationFrame(()=>{ce(t,{top:p}),requestAnimationFrame(()=>{ce(e,0),ce(S,!1)})})}),{deviation:e}},Te(De,Xt,It,at,bt,pr)),Fi=he(([e,t,n,r,o,s,i,u,a,l,d])=>({...e,...t,...n,...r,...o,...s,...i,...u,...a,...l,...d}),Te(br,Pi,xt,ss,ns,Ai,Ei,xr,os,bt,rs)),ls=he(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:o,gap:s,groupIndices:i,heightEstimates:u,itemSize:a,sizeRanges:l,sizes:d,statefulTotalCount:b,totalCount:f,trackItemSizes:m},{initialItemFinalLocationReached:S,initialTopMostItemIndex:w,scrolledToInitialItem:c},p,h,C,T,{scrollToIndex:_},O,{topItemCount:v},{groupCounts:y},R])=>{const{listState:k,minOverscanItemCount:E,topItemsIndexes:P,rangeChanged:I,...M}=T;return ne(I,R.scrollSeekRangeChanged),ne(H(R.windowViewportRect,Y(z=>z.visibleHeight)),p.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:o,gap:s,groupCounts:y,heightEstimates:u,initialItemFinalLocationReached:S,initialTopMostItemIndex:w,scrolledToInitialItem:c,sizeRanges:l,topItemCount:v,topItemsIndexes:P,totalCount:f,...C,groupIndices:i,itemSize:a,listState:k,minOverscanItemCount:E,scrollToIndex:_,statefulTotalCount:b,trackItemSizes:m,rangeChanged:I,...M,...R,...p,sizes:d,...h}},Te(at,Kt,De,Bi,zi,It,Ut,Ni,Gi,Zo,Fi));function Di(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"?g.useLayoutEffect:g.useEffect;function as(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=g.createContext({});function a(c,p){c.propsReady&&ce(c.propsReady,!1);for(const h of r){const C=c[t.required[h]];ce(C,p[h])}for(const h of o)if(h in p){const C=c[t.optional[h]];ce(C,p[h])}c.propsReady&&ce(c.propsReady,!0)}function l(c){return s.reduce((p,h)=>(p[h]=C=>{const T=c[t.methods[h]];ce(T,C)},p),{})}function d(c){return i.reduce((p,h)=>(p[h]=oi(c[t.events[h]]),p),{})}const b=g.forwardRef((c,p)=>{const{children:h,...C}=c,[T]=g.useState(()=>bn(ii(e),v=>{a(v,C)})),[_]=g.useState(Ar(d,T));Jt(()=>{for(const v of i)v in C&&xe(_[v],C[v]);return()=>{Object.values(_).map(dr)}},[C,_,T]),Jt(()=>{a(T,C)}),g.useImperativeHandle(p,Pr(l(T)));const O=n;return x.jsx(u.Provider,{value:T,children:n?x.jsx(O,{...Di([...r,...o,...i],C),children:h}):h})}),f=c=>{const p=g.useContext(u);return g.useCallback(h=>{ce(p[c],h)},[p,c])},m=c=>{const p=g.useContext(u)[c],h=g.useCallback(C=>xe(p,C),[p]);return g.useSyncExternalStore(h,()=>_e(p),()=>_e(p))},S=c=>{const p=g.useContext(u)[c],[h,C]=g.useState(Ar(_e,p));return Jt(()=>xe(p,T=>{T!==h&&C(Pr(T))}),[p,h]),h},w=g.version.startsWith("18")?m:S;return{Component:b,useEmitter:(c,p)=>{const h=g.useContext(u)[c];Jt(()=>xe(h,p),[p,h])},useEmitterValue:w,usePublisher:f}}const cs=g.createContext(void 0),us=g.createContext(void 0),ds=typeof document<"u"?g.useLayoutEffect:g.useEffect;function jn(e){return"self"in e}function Wi(e){return"body"in e}function fs(e,t,n,r=Ot,o,s){const i=g.useRef(null),u=g.useRef(null),a=g.useRef(null),l=g.useCallback(f=>{let m,S,w;const c=f.target;if(Wi(c)||jn(c)){const h=jn(c)?c:c.defaultView;w=s?h.scrollX:h.scrollY,m=s?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight,S=s?h.innerWidth:h.innerHeight}else w=s?c.scrollLeft:c.scrollTop,m=s?c.scrollWidth:c.scrollHeight,S=s?c.offsetWidth:c.offsetHeight;const p=()=>{e({scrollHeight:m,scrollTop:Math.max(w,0),viewportHeight:S})};f.suppressFlushSync?p():Ls.flushSync(p),u.current!==null&&(w===u.current||w<=0||w===m-S)&&(u.current=null,t(!0),a.current&&(clearTimeout(a.current),a.current=null))},[e,t,s]);g.useEffect(()=>{const f=o||i.current;return r(o||i.current),l({suppressFlushSync:!0,target:f}),f.addEventListener("scroll",l,{passive:!0}),()=>{r(null),f.removeEventListener("scroll",l)}},[i,l,n,r,o]);function d(f){const m=i.current;if(!m||(s?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const S=f.behavior==="smooth";let w,c,p;jn(m)?(c=Math.max(gt(m.document.documentElement,s?"width":"height"),s?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),w=s?m.innerWidth:m.innerHeight,p=s?window.scrollX:window.scrollY):(c=m[s?"scrollWidth":"scrollHeight"],w=gt(m,s?"width":"height"),p=m[s?"scrollLeft":"scrollTop"]);const h=c-w;if(f.top=Math.ceil(Math.max(Math.min(h,f.top),0)),es(w,c)||f.top===p){e({scrollHeight:c,scrollTop:p,viewportHeight:w}),S&&t(!0);return}S?(u.current=f.top,a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,u.current=null,t(!0)},1e3)):u.current=null,s&&(f={behavior:f.behavior,left:f.top}),m.scrollTo(f)}function b(f){s&&(f={behavior:f.behavior,left:f.top}),i.current.scrollBy(f)}return{scrollByCallback:b,scrollerRef:i,scrollToCallback:d}}const On="-webkit-sticky",qr="sticky",vr=is(()=>{if(typeof document>"u")return qr;const e=document.createElement("div");return e.style.position=On,e.style.position===On?On:qr});function Sr(e){return e}const $i=he(()=>{const e=D(u=>`Item ${u}`),t=D(u=>`Group ${u}`),n=D({}),r=D(Sr),o=D("div"),s=D(Ot),i=(u,a=null)=>Fe(H(n,Y(l=>l[u]),Ie()),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")}}),Vi=he(([e,t])=>({...e,...t}),Te(ls,$i)),qi=({height:e})=>x.jsx("div",{style:{height:e}}),Ui={overflowAnchor:"none",position:vr(),zIndex:1},ps={overflowAnchor:"none"},Ki={...ps,display:"inline-block",height:"100%"},Ur=g.memo(function({showTopList:e=!1}){const t=le("listState"),n=Ze("sizeRanges"),r=le("useWindowScroll"),o=le("customScrollParent"),s=Ze("windowScrollContainerState"),i=Ze("scrollContainerState"),u=o||r?s:i,a=le("itemContent"),l=le("context"),d=le("groupContent"),b=le("trackItemSizes"),f=le("itemSize"),m=le("log"),S=Ze("gap"),w=le("horizontalDirection"),{callbackRef:c}=ci(n,f,b,e?Ot:u,m,S,o,w,le("skipAnimationFrameInResizeObserver")),[p,h]=g.useState(0);yr("deviation",M=>{p!==M&&h(M)});const C=le("EmptyPlaceholder"),T=le("ScrollSeekPlaceholder")||qi,_=le("ListComponent"),O=le("ItemComponent"),v=le("GroupComponent"),y=le("computeItemKey"),R=le("isSeeking"),k=le("groupIndices").length>0,E=le("alignToBottom"),P=le("initialItemFinalLocationReached"),I=e?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:p!==0?p:E?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:p!==0?p:E?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...P?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?x.jsx(C,{...Ne(C,l)}):x.jsx(_,{...Ne(_,l),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:c,style:I,children:(e?t.topItems:t.items).map(M=>{const z=M.originalIndex,N=y(z+t.firstItemIndex,M.data,l);return R?g.createElement(T,{...Ne(T,l),height:M.size,index:M.index,key:N,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?g.createElement(v,{...Ne(v,l),"data-index":z,"data-item-index":M.index,"data-known-size":M.size,key:N,style:Ui},d(M.index,l)):g.createElement(O,{...Ne(O,l),...Zi(O,M.data),"data-index":z,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:N,style:w?Ki:ps},k?a(M.index,M.groupIndex,M.data,l):a(M.index,M.data,l))})})}),Xi={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Qi={outline:"none",overflowX:"auto",position:"relative"},vn=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Yi={position:vr(),top:0,width:"100%",zIndex:1};function Ne(e,t){if(typeof e!="string")return{context:t}}function Zi(e,t){return{item:typeof e=="string"?void 0:t}}const Ji=g.memo(function(){const e=le("HeaderComponent"),t=Ze("headerHeight"),n=le("HeaderFooterTag"),r=Ct(g.useMemo(()=>s=>{t(gt(s,"height"))},[t]),!0,le("skipAnimationFrameInResizeObserver")),o=le("context");return e?x.jsx(n,{ref:r,children:x.jsx(e,{...Ne(e,o)})}):null}),el=g.memo(function(){const e=le("FooterComponent"),t=Ze("footerHeight"),n=le("HeaderFooterTag"),r=Ct(g.useMemo(()=>s=>{t(gt(s,"height"))},[t]),!0,le("skipAnimationFrameInResizeObserver")),o=le("context");return e?x.jsx(n,{ref:r,children:x.jsx(e,{...Ne(e,o)})}):null});function gs({useEmitter:e,useEmitterValue:t,usePublisher:n}){return g.memo(function({children:r,style:o,context:s,...i}){const u=n("scrollContainerState"),a=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("scrollerRef"),b=t("horizontalDirection")||!1,{scrollByCallback:f,scrollerRef:m,scrollToCallback:S}=fs(u,l,a,d,void 0,b);return e("scrollTo",S),e("scrollBy",f),x.jsx(a,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...b?Qi:Xi,...o},tabIndex:0,...i,...Ne(a,s),children:r})})}function hs({useEmitter:e,useEmitterValue:t,usePublisher:n}){return g.memo(function({children:r,style:o,context:s,...i}){const u=n("windowScrollContainerState"),a=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("totalListHeight"),b=t("deviation"),f=t("customScrollParent"),m=g.useRef(null),S=t("scrollerRef"),{scrollByCallback:w,scrollerRef:c,scrollToCallback:p}=fs(u,l,a,S,f);return ds(()=>{var h;return c.current=f||((h=m.current)==null?void 0:h.ownerDocument.defaultView),()=>{c.current=null}},[c,f]),e("windowScrollTo",p),e("scrollBy",w),x.jsx(a,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+b}:{}},...i,...Ne(a,s),children:r})})}const tl=({children:e})=>{const t=g.useContext(cs),n=Ze("viewportHeight"),r=Ze("fixedItemHeight"),o=le("alignToBottom"),s=le("horizontalDirection"),i=g.useMemo(()=>No(n,a=>gt(a,s?"width":"height")),[n,s]),u=Ct(i,!0,le("skipAnimationFrameInResizeObserver"));return g.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),x.jsx("div",{"data-viewport-type":"element",ref:u,style:vn(o),children:e})},nl=({children:e})=>{const t=g.useContext(cs),n=Ze("windowViewportRect"),r=Ze("fixedItemHeight"),o=le("customScrollParent"),s=Do(n,o,le("skipAnimationFrameInResizeObserver")),i=le("alignToBottom");return g.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:vn(i),children:e})},rl=({children:e})=>{const t=le("TopItemListComponent")||"div",n=le("headerHeight"),r={...Yi,marginTop:`${n}px`},o=le("context");return x.jsx(t,{style:r,...Ne(t,o),children:e})},ol=g.memo(function(e){const t=le("useWindowScroll"),n=le("topItemsIndexes").length>0,r=le("customScrollParent"),o=le("context");return x.jsxs(r||t?ll:il,{...e,context:o,children:[n&&x.jsx(rl,{children:x.jsx(Ur,{showTopList:!0})}),x.jsxs(r||t?nl:tl,{children:[x.jsx(Ji,{}),x.jsx(Ur,{}),x.jsx(el,{})]})]})}),{Component:sl,useEmitter:yr,useEmitterValue:le,usePublisher:Ze}=as(Vi,{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"}},ol),il=gs({useEmitter:yr,useEmitterValue:le,usePublisher:Ze}),ll=hs({useEmitter:yr,useEmitterValue:le,usePublisher:Ze}),al=sl,cl=he(()=>{const e=D(l=>x.jsxs("td",{children:["Item $",l]})),t=D(null),n=D(l=>x.jsxs("td",{colSpan:1e3,children:["Group ",l]})),r=D(null),o=D(null),s=D({}),i=D(Sr),u=D(Ot),a=(l,d=null)=>Fe(H(s,Y(b=>b[l]),Ie()),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")}});Te(ls,cl);vr();const Kr={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},ul={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Xr,floor:an,max:Lt,min:zn,round:Qr}=Math;function Yr(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function dl(e){return{...ul,items:e}}function en(e,t){return e&&e.width===t.width&&e.height===t.height}function fl(e,t){return e&&e.column===t.column&&e.row===t.row}const pl=he(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:u,scrollTo:a,scrollTop:l,smoothScrollTargetReached:d,viewportHeight:b},f,m,{didMount:S,propsReady:w},{customScrollParent:c,useWindowScroll:p,windowScrollContainerState:h,windowScrollTo:C,windowViewportRect:T},_])=>{const O=D(0),v=D(0),y=D(Kr),R=D({height:0,width:0}),k=D({height:0,width:0}),E=pe(),P=pe(),I=D(0),M=D(null),z=D({column:0,row:0}),N=pe(),A=pe(),$=D(!1),te=D(0),fe=D(!0),ge=D(!1),ve=D(!1);xe(H(S,de(te),se(([j,G])=>!!G)),()=>{ce(fe,!1)}),xe(H(Pe(S,fe,k,R,te,ge),se(([j,G,V,B,,Z])=>j&&!G&&V.height!==0&&B.height!==0&&!Z)),([,,,,j])=>{ce(ge,!0),hr(1,()=>{ce(E,j)}),nt(H(l),()=>{ce(t,[0,0]),ce(fe,!0)})}),ne(H(A,se(j=>j!=null&&j.scrollTop>0),it(0)),v),xe(H(S,de(A),se(([,j])=>j!=null)),([,j])=>{j&&(ce(R,j.viewport),ce(k,j.item),ce(z,j.gap),j.scrollTop>0&&(ce($,!0),nt(H(l,yt(1)),G=>{ce($,!1)}),ce(a,{top:j.scrollTop})))}),ne(H(R,Y(({height:j})=>j)),b),ne(H(Pe(oe(R,en),oe(k,en),oe(z,(j,G)=>j&&j.column===G.column&&j.row===G.row),oe(l)),Y(([j,G,V,B])=>({gap:V,item:G,scrollTop:B,viewport:j}))),N),ne(H(Pe(oe(O),r,oe(z,fl),oe(k,en),oe(R,en),oe(M),oe(v),oe($),oe(fe),oe(te)),se(([,,,,,,,j])=>!j),Y(([j,[G,V],B,Z,F,Q,ee,,J,ie])=>{const{column:re,row:be}=B,{height:ue,width:ye}=Z,{width:ke}=F;if(ee===0&&(j===0||ke===0))return Kr;if(ye===0){const ut=mr(ie,j),zt=ut+Math.max(ee-1,0);return dl(Yr(ut,zt,Q))}const ze=ms(ke,ye,re);let Ee,Ge;J?G===0&&V===0&&ee>0?(Ee=0,Ge=ee-1):(Ee=ze*an((G+be)/(ue+be)),Ge=ze*Xr((V+be)/(ue+be))-1,Ge=zn(j-1,Lt(Ge,ze-1)),Ee=zn(Ge,Lt(0,Ee))):(Ee=0,Ge=-1);const ot=Yr(Ee,Ge,Q),{bottom:We,top:je}=Zr(F,B,Z,ot),et=Xr(j/ze),Qe=et*ue+(et-1)*be-We;return{bottom:We,itemHeight:ue,items:ot,itemWidth:ye,offsetBottom:Qe,offsetTop:je,top:je}})),y),ne(H(M,se(j=>j!==null),Y(j=>j.length)),O),ne(H(Pe(R,k,y,z),se(([j,G,{items:V}])=>V.length>0&&G.height!==0&&j.height!==0),Y(([j,G,{items:V},B])=>{const{bottom:Z,top:F}=Zr(j,B,G,V);return[F,Z]}),Ie(Nt)),t);const me=D(!1);ne(H(l,de(me),Y(([j,G])=>G||j!==0)),me);const Ae=Xe(H(Pe(y,O),se(([{items:j}])=>j.length>0),de(me),se(([[j,G],V])=>{const B=j.items[j.items.length-1].index===G-1;return(V||j.bottom>0&&j.itemHeight>0&&j.offsetBottom===0&&j.items.length===G)&&B}),Y(([[,j]])=>j-1),Ie())),K=Xe(H(oe(y),se(({items:j})=>j.length>0&&j[0].index===0),it(0),Ie())),W=Xe(H(oe(y),de($),se(([{items:j},G])=>j.length>0&&!G),Y(([{items:j}])=>({endIndex:j[j.length-1].index,startIndex:j[0].index})),Ie(Ko),ct(0)));ne(W,m.scrollSeekRangeChanged),ne(H(E,de(R,k,O,z),Y(([j,G,V,B,Z])=>{const F=Jo(j),{align:Q,behavior:ee,offset:J}=F;let ie=F.index;ie==="LAST"&&(ie=B-1),ie=Lt(0,ie,zn(B-1,ie));let re=sr(G,Z,V,ie);return Q==="end"?re=Qr(re-G.height+V.height):Q==="center"&&(re=Qr(re-G.height/2+V.height/2)),J&&(re+=J),{behavior:ee,top:re}})),a);const L=Fe(H(y,Y(j=>j.offsetBottom+j.bottom)),0);return ne(H(T,Y(j=>({height:j.visibleHeight,width:j.visibleWidth}))),R),{customScrollParent:c,data:M,deviation:I,footerHeight:o,gap:z,headerHeight:s,increaseViewportBy:e,initialItemCount:v,itemDimensions:k,overscan:n,restoreStateFrom:A,scrollBy:i,scrollContainerState:u,scrollHeight:P,scrollTo:a,scrollToIndex:E,scrollTop:l,smoothScrollTargetReached:d,totalCount:O,useWindowScroll:p,viewportDimensions:R,windowScrollContainerState:h,windowScrollTo:C,windowViewportRect:T,...m,gridState:y,horizontalDirection:ve,initialTopMostItemIndex:te,totalListHeight:L,...f,endReached:Ae,propsReady:w,rangeChanged:W,startReached:K,stateChanged:N,stateRestoreInProgress:$,..._}},Te(br,De,Xt,ss,xt,xr,bt));function ms(e,t,n){return Lt(1,an((e+n)/(an(t)+n)))}function Zr(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=sr(e,t,n,r[0].index);return{bottom:sr(e,t,n,r[r.length-1].index)+o,top:s}}function sr(e,t,n,r){const o=ms(e.width,n.width,t.column),s=an(r/o),i=s*n.height+Lt(0,s-1)*t.row;return i>0?i+t.row:i}const gl=he(()=>{const e=D(b=>`Item ${b}`),t=D({}),n=D(null),r=D("virtuoso-grid-item"),o=D("virtuoso-grid-list"),s=D(Sr),i=D("div"),u=D(Ot),a=(b,f=null)=>Fe(H(t,Y(m=>m[b]),Ie()),f),l=D(!1),d=D(!1);return ne(oe(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")}}),hl=he(([e,t])=>({...e,...t}),Te(pl,gl)),ml=g.memo(function(){const e=Re("gridState"),t=Re("listClassName"),n=Re("itemClassName"),r=Re("itemContent"),o=Re("computeItemKey"),s=Re("isSeeking"),i=Je("scrollHeight"),u=Re("ItemComponent"),a=Re("ListComponent"),l=Re("ScrollSeekPlaceholder"),d=Re("context"),b=Je("itemDimensions"),f=Je("gap"),m=Re("log"),S=Re("stateRestoreInProgress"),w=Je("reportReadyState"),c=Ct(g.useMemo(()=>p=>{const h=p.parentElement.parentElement.scrollHeight;i(h);const C=p.firstChild;if(C){const{height:T,width:_}=C.getBoundingClientRect();b({height:T,width:_})}f({column:Jr("column-gap",getComputedStyle(p).columnGap,m),row:Jr("row-gap",getComputedStyle(p).rowGap,m)})},[i,b,f,m]),!0,!1);return ds(()=>{e.itemHeight>0&&e.itemWidth>0&&w(!0)},[e]),S?null:x.jsx(a,{className:t,ref:c,...Ne(a,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(p=>{const h=o(p.index,p.data,d);return s?x.jsx(l,{...Ne(l,d),height:e.itemHeight,index:p.index,width:e.itemWidth},h):g.createElement(u,{...Ne(u,d),className:n,"data-index":p.index,key:h},r(p.index,p.data,d))})})}),bl=g.memo(function(){const e=Re("HeaderComponent"),t=Je("headerHeight"),n=Re("headerFooterTag"),r=Ct(g.useMemo(()=>s=>{t(gt(s,"height"))},[t]),!0,!1),o=Re("context");return e?x.jsx(n,{ref:r,children:x.jsx(e,{...Ne(e,o)})}):null}),xl=g.memo(function(){const e=Re("FooterComponent"),t=Je("footerHeight"),n=Re("headerFooterTag"),r=Ct(g.useMemo(()=>s=>{t(gt(s,"height"))},[t]),!0,!1),o=Re("context");return e?x.jsx(n,{ref:r,children:x.jsx(e,{...Ne(e,o)})}):null}),vl=({children:e})=>{const t=g.useContext(us),n=Je("itemDimensions"),r=Je("viewportDimensions"),o=Ct(g.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return g.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:vn(!1),children:e})},Sl=({children:e})=>{const t=g.useContext(us),n=Je("windowViewportRect"),r=Je("itemDimensions"),o=Re("customScrollParent"),s=Do(n,o,!1);return g.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:vn(!1),children:e})},yl=g.memo(function({...e}){const t=Re("useWindowScroll"),n=Re("customScrollParent"),r=n||t?Cl:wl,o=n||t?Sl:vl,s=Re("context");return x.jsx(r,{...e,...Ne(r,s),children:x.jsxs(o,{children:[x.jsx(bl,{}),x.jsx(ml,{}),x.jsx(xl,{})]})})}),{useEmitter:bs,useEmitterValue:Re,usePublisher:Je}=as(hl,{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"}},yl),wl=gs({useEmitter:bs,useEmitterValue:Re,usePublisher:Je}),Cl=hs({useEmitter:bs,useEmitterValue:Re,usePublisher:Je});function Jr(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ve.WARN),t==="normal"?0:parseInt(t??"0",10)}const Sn=g.createContext(void 0);function Ce(e,t){const n=g.useContext(Sn);if(!n)throw new Error("useAudioStore must be used within CRAudioProvider");return gn(n,e,t)}function cn(){const e=g.useContext(Sn);if(!e)throw new Error("useAudioStoreApi must be used within CRAudioProvider");return e}const Il="_handleStart_1ihf3_16 _handle_1ihf3_1",Tl="_handleEnd_1ihf3_21 _handle_1ihf3_1",eo={handleStart:Il,handleEnd:Tl};let ir=!1;function xs(){return ir}const kl=({containerRef:e})=>{const t=q(c=>c.rangeStartGI),n=q(c=>c.rangeEndGI),r=q(c=>c.setRange),o=ht(),s=t!=null&&n!=null,[i,u]=g.useState(null),[a,l]=g.useState(null),d=g.useRef(null),b=g.useRef({startGI:t,endGI:n});b.current={startGI:t,endGI:n};const f=g.useRef(r);f.current=r,g.useEffect(()=>{if(!s||t==null||n==null){u(null),l(null);return}const c=()=>{const h=e.current;if(!h)return;const C=h.getBoundingClientRect(),_=1/(o.getState().playbackScale||1),O=h.querySelector(`[data-g="${t}"]`),v=h.querySelector(`[data-g="${n}"]`);if(O){const y=O.getBoundingClientRect();u({x:(y.left-C.left)*_,y:(y.bottom-C.top)*_})}else u(null);if(v){const y=v.getBoundingClientRect();l({x:(y.right-C.left)*_,y:(y.bottom-C.top)*_})}else l(null)};c();const p=e.current;return p&&p.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{p&&p.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[s,t,n,e,o]);const m=g.useCallback((c,p)=>{var C;const h=document.elementsFromPoint(c,p);for(const T of h){const _=(C=T.getAttribute)==null?void 0:C.call(T,"data-g");if(_!=null)return parseInt(_,10)}return null},[]);g.useEffect(()=>{const c=h=>{if(!d.current)return;const{startGI:C,endGI:T}=b.current;if(C==null||T==null)return;const _=m(h.clientX,h.clientY);_!=null&&(d.current==="start"?_<=T?f.current(_,T):(f.current(T,_),d.current="end"):_>=C?f.current(C,_):(f.current(_,C),d.current="start"))},p=()=>{d.current=null,setTimeout(()=>{ir=!1},50)};return document.addEventListener("pointermove",c),document.addEventListener("pointerup",p),document.addEventListener("pointercancel",p),()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",p),document.removeEventListener("pointercancel",p)}},[m]);const S=g.useCallback(c=>p=>{p.preventDefault(),p.stopPropagation(),d.current=c,ir=!0},[]);return s?x.jsxs(x.Fragment,{children:[i&&x.jsx("div",{className:eo.handleStart,"data-range-handle":"start",style:{left:i.x-26,top:i.y},onPointerDown:S("start")}),a&&x.jsx("div",{className:eo.handleEnd,"data-range-handle":"end",style:{left:a.x,top:a.y},onPointerDown:S("end")})]}):null},Rl="_run_zzb61_3",_l="_runWrap_zzb61_7",Ml="_highlight_zzb61_13",El="_highlightleft_zzb61_14",jl="_highlightright_zzb61_15",Ol="_highlightcenter_zzb61_16",zl="_underline_zzb61_48",Pl="_underlineleft_zzb61_49",Al="_underlineright_zzb61_50",Bl="_underlinecenter_zzb61_51",st={run:Rl,runWrap:_l,highlight:Ml,highlightleft:El,highlightright:jl,highlightcenter:Ol,underline:zl,underlineleft:Pl,underlineright:Al,underlinecenter:Bl},to=e=>Symbol.iterator in e,no=e=>"entries"in e,ro=(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},Ll=(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 Gl(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:to(e)&&to(t)?no(e)&&no(t)?ro(e,t):Ll(e,t):ro({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function Vt(e){const t=g.useRef(void 0);return n=>{const r=e(n);return Gl(t.current,r)?t.current:t.current=r}}function Hl(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 Nl(e){const t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return t?{r:+t[1],g:+t[2],b:+t[3]}:null}const Fl=Object.freeze({showPointer:void 0,pointerStyle:void 0,pointerColor:void 0}),vs=g.memo(function({runs:t,ns:n,baseIndex:r,preGroups:o}){const s=Ce(E=>E.setClipIndex),i=Ce(E=>E.seek),u=q(E=>E.setCurrentGlobalRunIndex),a=cn(),l=q(E=>E.rangeStartGI),d=q(E=>E.rangeEndGI),b=q(E=>E.setRange),f=l!=null&&d!=null,m=g.useCallback(E=>{var te;const P=(te=E.target)==null?void 0:te.closest("[data-g]");if(!P)return;const I=Number(P.dataset.g),M=I-r;if(M<0||M>=t.length)return;const z=t[M],N=z.text??"";if(!N.trim()||!/[가-힣a-zA-Z0-9]/.test(N))return;u(I,"program");const A=z.audioChunkIndex,$=z.audioTimeMs;A!=null&&$!=null&&(s(A),i($))},[t,r,i,s,u]),S=g.useRef(null),w=g.useRef(!1),c=g.useRef({x:0,y:0}),p=g.useCallback(E=>{var z;const P=(z=E.target)==null?void 0:z.closest("[data-g]");if(!P)return;const I=Number(P.dataset.g),M=I-r;M<0||M>=t.length||(w.current=!1,c.current={x:E.clientX,y:E.clientY},S.current&&(window.clearTimeout(S.current),S.current=null),S.current=window.setTimeout(()=>{a.getState().status!=="playing"&&(b(I,I),w.current=!0,S.current=null)},800))},[t,r,b,a]),h=g.useCallback(()=>{S.current&&(window.clearTimeout(S.current),S.current=null)},[]),C=g.useCallback(E=>{if(!S.current)return;const P=E.clientX-c.current.x,I=E.clientY-c.current.y;(Math.abs(P)>5||Math.abs(I)>5)&&h()},[h]),T=g.useCallback(()=>{h()},[h]),_=h,O=h,v=q(E=>E.clearRange),y=g.useCallback(E=>{var M;if(w.current){w.current=!1;return}if(xs())return;const P=(M=E.target)==null?void 0:M.closest("[data-g]");if(!P)return;const I=Number(P.dataset.g);isNaN(I)||f&&l!=null&&d!=null&&(v(),E.stopPropagation())},[f,l,d,v]),R=o,k=r+t.length-1;return x.jsx("span",{onClick:y,onDoubleClick:m,onPointerDown:p,onPointerMove:C,onPointerUp:T,onPointerCancel:_,onPointerLeave:O,children:R.map((E,P)=>x.jsx(Wl,{ns:n,group:E,runs:t,paraLastG:k,rangeStartGI:l,rangeEndGI:d},`${n}/grp:${P}-${E.startG}`))})},(e,t)=>e.ns===t.ns&&e.baseIndex===t.baseIndex&&e.runs===t.runs&&e.sectionId===t.sectionId),Dl=g.memo(function(){const t=g.useCallback(r=>({showSplit:r.showSplit,slash:r.breakMarks.slash,breakGapPx:r.breakGapPx}),[]),n=X(Vt(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}),Wl=g.memo(function({ns:t,group:n,runs:r,paraLastG:o,rangeStartGI:s,rangeEndGI:i}){const u=g.useCallback(c=>{const p=c.currentGlobalRunIndex;return p!=null&&p>=n.startG&&p<=n.endG},[n]),a=q(Vt(u)),l=g.useCallback(c=>a?{showPointer:c.showPointer,pointerStyle:c.pointerStyle,pointerColor:c.pointerColor}:Fl,[a]),d=X(Vt(l)),b=n.r0??0,f=n.len??Math.max(0,n.endG-n.startG+1),m=a&&d.showPointer&&d.pointerStyle!=="underline",S=a&&d.showPointer&&d.pointerStyle==="underline",w=m||S?{"--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:f}).map((c,p)=>{const C=r[b+p],T=n.startG+p,_=`${t}/run:${T}`,O=!!C.split&&T!==o;let v=`${st.runWrap}`;return m&&(f===1?v+=` ${st.highlight}`:p===0?v+=` ${st.highlightleft}`:p+1===f?v+=` ${st.highlightright}`:v+=` ${st.highlightcenter}`),S&&(f===1?v+=` ${st.underline}`:p===0?v+=` ${st.underlineleft}`:p+1===f?v+=` ${st.underlineright}`:v+=` ${st.underlinecenter}`),x.jsxs(g.Fragment,{children:[x.jsx("span",{className:v,style:w,children:x.jsx($l,{gi:n.startG,g:T,run:C,active:a,pointerCfg:d,isInRange:s!=null&&i!=null&&T>=s&&T<=i})}),O&&x.jsx(Dl,{})]},_)})})},(e,t)=>e.group===t.group&&e.runs===t.runs&&e.ns===t.ns&&e.rangeStartGI===t.rangeStartGI&&e.rangeEndGI===t.rangeEndGI),$l=g.memo(function({gi:t,g:n,run:r,active:o,pointerCfg:s,isInRange:i}){const u=g.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("#")?Hl(l):Nl(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:st.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 Vl({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(vs,{preGroups:s,runs:e.runs,ns:n,baseIndex:r,sectionId:o})]})}const ql=g.memo(Vl,(e,t)=>e.block===t.block&&e.computedMarker===t.computedMarker&&e.baseIndex===t.baseIndex&&e.ns===t.ns);function Ul(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 so(e,!1);case"upperalpha":case"upperlatin":return so(e,!0);case"lowerroman":return oo(e,!1);case"upperroman":return oo(e,!0);case"decimalenclosedcircle":return Kl(e);default:return String(e)}}function Kl(e){return e>=1&&e<=20?String.fromCharCode(9312+(e-1)):`(${e})`}function oo(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 so(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 wr(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 Cr(e,t){const n=e.list;if(!n||n.kind!=="ordered")return;const r=t.next(n.numId??0,n.level),o=Ul(r,n.format),s=(n.format||"").toLowerCase();return!/enclosed|paren/.test(s)&&s!=="decimalleadingzero"?`${o}.`:o}function Xl(e){return e.map(t=>t.type==="image"?0:t.runs.length)}function Ql(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 Yl(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 Zl="_scroller_kqkmq_3",Jl={scroller:Zl},ea=g.forwardRef(function({className:t,style:n,...r},o){return x.jsx("div",{ref:o,className:`${Jl.scroller}${t?" "+t:""}`,style:n,...r})}),lr=e=>/[가-힣a-zA-Z0-9]/.test(e),ta=e=>((e==null?void 0:e.textContent)??"").trim(),un=(e,t)=>e.querySelector(`[data-g="${t}"]`);function na(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,b=1/0;const f=e.querySelectorAll("[data-g]");for(let m=0;m<f.length;m++){const S=f[m];if(!S||!S.isConnected)continue;const w=ta(S);if(!w||!lr(w))continue;const c=S.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<b||l!==-1&&Number(S.dataset.g)<l))&&(d=C,l=Number(S.dataset.g),b=c.top);continue}const p=Number(S.dataset.g);if(Number.isNaN(p))continue;c.top<a-n?(a=c.top,u=c.top,i=p):c.top<=a+n&&(c.top<u||c.top===u&&(i===-1||p<i))&&(u=c.top,i=p);const h=Math.abs(c.top-s);(h<d||h===d&&(c.top<b||l!==-1&&p<l))&&(d=h,l=p,b=c.top)}return i!==-1?i:l}const Ss=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},io=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}},ra=(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 oa(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 Pn=async(e,t,{topPaddingRatio:n=.15,behavior:r="smooth",quietMs:o=120}={})=>{if(!ra(e,t,{topPaddingRatio:n,behavior:r}))return!1;await oa(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,b=a.top-d;return Math.abs(b)<=1},ft=()=>new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>e())})}),Ir=g.createContext(null);function ys(){const e=g.useContext(Ir);if(!e)throw new Error("useQuizStoreApi must be used within QuizProgressProvider");return e}function Ue(e,t){const n=g.useContext(Ir);if(!n)throw new Error("useQuizStore must be used within QuizProgressProvider");return gn(n,e,t)}const ws=()=>{const e=q(l=>l.section),t=ys(),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,"%)"]})]})},sa="_navBtn_1fciy_2",ia="_disabled_1fciy_26",la="_label_1fciy_32",Et={navBtn:sa,disabled:ia,label:la};var Cs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},lo=g.createContext&&g.createContext(Cs),aa=["attr","size","title"];function ca(e,t){if(e==null)return{};var n=ua(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 ua(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 ao(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?ao(Object(n),!0).forEach(function(r){da(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ao(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function da(e,t,n){return t=fa(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function fa(e){var t=pa(e,"string");return typeof t=="symbol"?t:t+""}function pa(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 Is(e){return e&&e.map((t,n)=>g.createElement(t.tag,fn({key:n},t.attr),Is(t.child)))}function qe(e){return t=>g.createElement(ga,dn({attr:fn({},e.attr)},t),Is(e.child))}function ga(e){var t=n=>{var{attr:r,size:o,title:s}=e,i=ca(e,aa),u=o||n.size||"1em",a;return n.className&&(a=n.className),e.className&&(a=(a?a+" ":"")+e.className),g.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&&g.createElement("title",null,s),e.children)};return lo!==void 0?g.createElement(lo.Consumer,null,n=>t(n)):t(Cs)}function co(e){return qe({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 uo(e){return qe({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 ha=({isIcon:e=!0})=>{const t=q(i=>i.isCanPrev),n=q(i=>i.onSectionNav),r=!t,o=g.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(co,{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(co,{size:18,style:{display:"inline",marginRight:"8px",verticalAlign:"middle"}}),"PrevSection"]})})},pn=({isIcon:e=!0})=>{const t=q(i=>i.isCanNext),n=q(i=>i.onSectionNav),r=!t,o=g.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(uo,{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(uo,{size:18,style:{display:"inline",marginLeft:"8px",verticalAlign:"middle"}})]})})};function Ts(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 ma({section:e,blocks:t,nsPrefix:n}){const r=g.useMemo(()=>{const R=[],k=wr();return t.forEach((E,P)=>{E.type==="paragraph"&&(R[P]=Cr(E,k))}),R},[t]),o=q(R=>{var k;return((k=R.layout)==null?void 0:k.prefix)??[]}),s=q(R=>{var k;return((k=R.derivedNav)==null?void 0:k.splitGroupsPerBlock)??[]}),i=X(R=>R.marginX),u=X(R=>R.viewportHeight),a=g.useRef({start:0,end:0}),l=g.useCallback(R=>{const k=t[R],E=`${n}blk-${k.id}`;if(k.type==="image"){const{src:M,alt:z,width:N,height:A}=k,$=N&&A?`${N} / ${A}`:"4 / 3",te=R>=a.current.start&&R<=a.current.end,fe=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:fe,aspectRatio:$},children:x.jsx("img",{src:M,alt:z||"",loading:te?"eager":"lazy",style:{pointerEvents:"none",position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"contain",display:"block"}})}),z&&x.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:z})]})}const P=r[R]??void 0,I=s[R];return x.jsx("div",{style:{maxWidth:860,display:"flex"},children:x.jsx(ql,{block:k,computedMarker:P,ns:E,baseIndex:o[R],sectionId:e.section_id,preGroups:I})})},[t,r,o,n,e,s,u]),d=g.useRef(null),b=g.useCallback(R=>{d.current=R},[]),f=g.useMemo(()=>g.memo(R=>{const{style:k,children:E,...P}=R;return x.jsx("div",{...P,style:k,children:x.jsx("div",{style:{boxSizing:"border-box",paddingRight:`${i}px`,paddingLeft:`${i}px`,maxWidth:860,margin:"0 auto",width:"100%",height:"100%"},children:E})})}),[i]),m=g.useRef(null),S=g.useMemo(()=>t.map(R=>R.id),[t]),[w,c]=g.useState(!1);g.useEffect(()=>{c(!1)},[t]);const p=g.useCallback(()=>{c(!0)},[]),h=g.useCallback(()=>{if(!w)return x.jsx("div",{style:{height:40}});const R=e.quizzes,k=Math.max(80,Math.floor(u*.5));return R&&R.length?x.jsxs("div",{style:{display:"block"},children:[x.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:x.jsx(ws,{})}),x.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:x.jsx(pn,{isIcon:!1})}),x.jsx("div",{style:{height:k,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:40}})]})},[w,e,u]),C=g.useMemo(()=>({Item:f,Header:()=>x.jsx("div",{style:{height:40}}),Footer:h,Scroller:ea}),[h,f]),T=g.useCallback(R=>S[R],[S]),_=pt(),[O]=g.useState(()=>_.getState().progress.currentGlobalRunIndex??0),v=g.useMemo(()=>{if(!o.length)return 0;const R=o[o.length-1],k=Math.max(0,Math.min(O,R));return Ts(o,k)},[o,O]);console.log("SectionRenderVirtuoso확인");const y=pt();return g.useEffect(()=>{let R=!1;return(async()=>{let k=d.current;if(!k){for(let M=0;M<20;M++){if(await new Promise(z=>setTimeout(z,50)),R)return;if(k=d.current,k)break}if(!k)return}const E=y.getState().progress.currentGlobalRunIndex,P=y.getState().progress.setSectionLoading,I=E!=null&&E>=0?E:0;await Ss(k,I),!R&&(await ft(),await ft(),await ft(),await ft(),!R&&P(!1))})(),()=>{R=!0}},[d,y]),x.jsxs(x.Fragment,{children:[x.jsx(al,{ref:m,style:{height:"100%",width:"100%",boxSizing:"border-box"},defaultItemHeight:99,computeItemKey:T,totalCount:t.length,itemContent:l,initialTopMostItemIndex:v,increaseViewportBy:{top:200,bottom:200},endReached:p,components:C,scrollerRef:b}),x.jsx(ba,{scrollContainerRef:d,virtRef:m,prefix:o})]})}const ba=({scrollContainerRef:e,virtRef:t,prefix:n})=>{const r=q(I=>I.setCurrentGlobalRunIndex),o=q(I=>I.registerSectionScrollApi),s=q(I=>I.currentGlobalRunIndex),i=Ce(I=>I.scrollLock),u=Ce(I=>I.syncToGI),a=ht(),l=g.useRef(!1),d=g.useRef(null),b=g.useRef(null),f=g.useRef(null),m=g.useRef(-1),S=g.useCallback(()=>{if(i)return;d.current=null;const I=b.current;if(!I)return;const M=na(I,5);M!==-1&&M!==m.current&&(m.current=M,u(M),r(M,"scroll"))},[i,u,r]),w=g.useCallback(I=>{b.current=I,d.current==null&&(d.current=requestAnimationFrame(S))},[S]),c=g.useCallback(I=>{b.current=I,f.current!=null&&(window.clearTimeout(f.current),f.current=null),f.current=window.setTimeout(()=>{f.current=null,S();const M=m.current;if(M===-1)return;const z=I.scrollTop,N=I.scrollHeight-I.clientHeight,A=N>0?z/N:0;let $=0;const te=I.querySelector(`[data-g="${M}"]`);if(te){const fe=I.getBoundingClientRect();$=(te.getBoundingClientRect().top-fe.top)/fe.height}a.getState().emit({type:"scroll",payload:{scrollTop:z,scrollRatio:A,anchorGI:M,anchorOffsetRatio:$}})},100)},[S,a]),p=g.useRef(!1),h=g.useCallback(I=>{i||l.current&&(p.current||(w(I),c(I)))},[i,w,c]),C=g.useRef(void 0),T=g.useRef(void 0),_=g.useRef(void 0),O=g.useRef(void 0);g.useEffect(()=>{const I=e.current;if(I)return C.current=()=>{l.current=!0},T.current=()=>{l.current=!0},_.current=()=>{l.current=!0},O.current=()=>h(I),I.addEventListener("wheel",C.current,{passive:!0}),I.addEventListener("touchmove",T.current,{passive:!0}),window.addEventListener("keydown",_.current,{passive:!0}),I.addEventListener("scroll",O.current,{passive:!0}),()=>{I.removeEventListener("wheel",C.current),I.removeEventListener("touchmove",T.current),window.removeEventListener("keydown",_.current),I.removeEventListener("scroll",O.current),d.current!=null&&cancelAnimationFrame(d.current),f.current!=null&&(clearTimeout(f.current),f.current=null)}},[h,e]),g.useEffect(()=>{const I=e.current;if(!I||!i)return;const M=$=>{$.preventDefault(),$.stopPropagation(),l.current=!1},z=$=>{$.preventDefault(),$.stopPropagation(),l.current=!1},N=$=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes($.key)&&($.preventDefault(),$.stopPropagation(),l.current=!1)},A={overscrollBehavior:I.style.overscrollBehavior,touchAction:I.style.touchAction};return I.style.overscrollBehavior="contain",I.style.touchAction="none",I.addEventListener("wheel",M,{passive:!1}),I.addEventListener("touchmove",z,{passive:!1}),window.addEventListener("keydown",N,{passive:!1}),()=>{I.removeEventListener("wheel",M),I.removeEventListener("touchmove",z),window.removeEventListener("keydown",N),I.style.overscrollBehavior=A.overscrollBehavior,I.style.touchAction=A.touchAction}},[i,e]);const v=g.useRef({first:-1,last:-1}),y=g.useRef(!1),R=g.useCallback(()=>{const I=e.current;if(!I)return;const M=io(I),z=(M==null?void 0:M.first)??-1,N=(M==null?void 0:M.last)??-1;v.current={first:z,last:N}},[e]),k=g.useRef(!1),E=g.useCallback(()=>{const I=e.current;if(!I||k.current)return;k.current=!0;const M=Math.min(I.scrollTop+Math.floor(I.clientHeight*.6),I.scrollHeight-I.clientHeight);requestAnimationFrame(()=>{I.scrollTo({top:M,behavior:"instant"})})},[e]);g.useEffect(()=>{!y.current&&i&&(k.current=!1,R()),y.current=i},[i,R]),g.useEffect(()=>{if(i!==!0)return;const I=e.current;if(!I)return;const{first:M,last:z}=v.current;if(M===-1||z===-1){E();return}if(I.scrollTop<=1){(async()=>{try{p.current=!0,await Pn(I,s,{behavior:"smooth",topPaddingRatio:.2})}finally{p.current=!1}R()})();return}if(s<M||s>z){async function A(){if(!I)return;const $=I.scrollTop<=1?0:.2;return await Pn(I,s,{behavior:"smooth",topPaddingRatio:$})}A().then($=>{$?R():E()})}},[i,s,E,R,e]);const P=g.useCallback(()=>{const I=e.current;if(!I)return;function M(L,j,G=.2,V=.8){const B=L.querySelector(`[data-g="${j}"]`);if(!B)return!1;const Z=L.getBoundingClientRect(),F=B.getBoundingClientRect();if(F.height<=0||Z.height<=0)return!1;const Q=(F.top+F.height/2-Z.top)/Z.height;return Q>=G&&Q<=V}const z=L=>L==="instant"?"auto":L,N=L=>{const j=I.scrollTop,G=I.scrollHeight-I.clientHeight,V=G>0?j/G:0;let B=0;const Z=I.querySelector(`[data-g="${L}"]`);if(Z){const F=I.getBoundingClientRect();B=(Z.getBoundingClientRect().top-F.top)/F.height}a.getState().emit({type:"scroll",payload:{scrollTop:j,scrollRatio:V,anchorGI:L,anchorOffsetRatio:B}})},A=async(L,j="smooth")=>{var V;const G=Ts(n,L);(V=t.current)==null||V.scrollToIndex({index:G,align:"start",behavior:z(j)}),await Ss(I,L)},$=()=>new Promise(L=>requestAnimationFrame(()=>L())),te=async L=>{if(M(I,L,.1,.7))return N(L),!0;p.current=!0;const j=I.querySelector(`[data-g="${L}"]`),G=I.getBoundingClientRect();let V=I.scrollTop<=1?0:.1;if(j){const Z=j.getBoundingClientRect();V=((Z.top+Z.height/2-G.top)/G.height>.5,.15)}const B=!!j;return B?(await Pn(I,L,{behavior:"smooth",topPaddingRatio:V}),await $()):B||await A(L,"auto"),p.current=!1,N(L),M(I,L,.1,.7)},fe=async L=>te(L);return{ensureVisibleGI:te,scrollToGI:fe,getVisibleRange:()=>io(I),getScrollTop:()=>I.scrollTop,setScrollTop:L=>{I.scrollTop=L},getAnchorOffsetRatio:L=>{const j=I.querySelector(`[data-g="${L}"]`);if(!j)return 0;const G=j.getBoundingClientRect(),V=I.getBoundingClientRect();return(G.top-V.top)/V.height},scrollToGIAtOffset:async(L,j)=>{await fe(L),await new Promise(J=>requestAnimationFrame(()=>requestAnimationFrame(J)));const G=I.querySelector(`[data-g="${L}"]`);if(!G)return;const V=G.getBoundingClientRect(),B=I.getBoundingClientRect(),Z=B.height>0?B.height/I.clientHeight:1,F=(V.top-B.top)/Z,Q=j*I.clientHeight,ee=F-Q;I.scrollTop=I.scrollTop+ee},getScrollRatio:()=>{const L=I.scrollHeight-I.clientHeight;return L>0?I.scrollTop/L:0}}},[e,t,n,a]);return g.useEffect(()=>(console.log("@@@@@빌드스크롤api"),o(P()),()=>o(void 0)),[P,o]),null};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=q(S=>S.section),t=X(S=>S.theme),n=X(S=>S.fontFamily),r=X(S=>S.fontSizePx),o=X(S=>S.lineHeight),s=sn[t],{blocks:i,nsPrefix:u}=g.useMemo(()=>({sectionId:e.section_id,blocks:e.ast.blocks,nsPrefix:`sec-${e.section_id??"0"}/`}),[e]),a=hn(),l=g.useCallback(()=>{const{isSettingsOpen:S,setSettingsOpen:w,toggleOverlays:c}=a.getState();S?w(!1):c()},[a]),{onClick:d,onDoubleClick:b}=Qs({onSingle:l,onDouble:()=>{},delay:250,shouldIgnoreTarget:xa}),f=g.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]),m=g.useMemo(()=>({margin:"0 auto",width:"100%",height:"100%"}),[]);return console.log("ScrollSectionWrap render"),x.jsx("div",{onClick:d,onDoubleClick:b,style:f,children:x.jsx("div",{style:m,children:x.jsx(ma,{section:e,blocks:i,nsPrefix:u})})})}function Sa(e){return qe({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 qe({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 qe({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 qe({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 qe({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 qe({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 qe({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",Pa="_groupPlayback_1hfub_81",Aa="_groupSpeed_1hfub_82",Ba="_groupFeatures_1hfub_83",La="_groupNav_1hfub_84",Ga="_btn_1hfub_116",Ha="_btnForbidden_1hfub_141",Na="_btnActive_1hfub_147",Fa="_label_1hfub_158",Da="_compactBtn_1hfub_168",we={wrap:Ra,visible:_a,compact:Ma,row2:Ea,controls:ja,row1:Oa,groupExpand:za,groupPlayback:Pa,groupSpeed:Aa,groupFeatures:Ba,groupNav:La,btn:Ga,btnForbidden:Ha,btnActive:Na,label:Fa,compactBtn:Da},Wa=g.memo(function(){const t=g.useRef(null),n=g.useContext(wt),r=(n==null?void 0:n.getState().isPlaybackMode)??!1,o=Ce(y=>y.status),s=Ce(y=>y.currentTimeMs),i=Ce(y=>y.currentClip),u=Ce(y=>y.playbackKind),a=X(y=>y.muteAudio),l=X(y=>y.audioSpeed),d=Ce(y=>y.getClipSrc),b=Ce(y=>y._onTime),f=Ce(y=>y._onEnded),m=Ce(y=>y._onError),S=q(y=>y.setCurrentGlobalRunIndex),w=q(y=>y.getSectionScrollApi),c=q(y=>y.snapToReadable),p=q(y=>y.edgeReadable),h=g.useRef(null),C=g.useRef(null),T=g.useRef(!1),_=g.useRef(null);g.useEffect(()=>{u==="real"&&(T.current=!0)},[u]);const O=g.useMemo(()=>{const y=d(i);if(!y)return null;try{return new URL(y,window.location.href).href}catch{return y}},[i,d]);g.useEffect(()=>{T.current=!0},[O]),g.useEffect(()=>{const y=t.current;if(!y)return;const R=()=>{if(y.paused||y.ended)return;const P=y.currentTime*1e3;T.current&&P===0||(P>0&&(T.current=!1),b(P))},k=()=>{var I,M;f();const P=p(1);typeof P=="number"&&P>=0&&(S(P,"audio"),(M=(I=w())==null?void 0:I.ensureVisibleGI)==null||M.call(I,P))},E=P=>{const I=P.currentTarget;console.warn("Audio error",{networkState:I.networkState,readyState:I.readyState}),m()};return y.addEventListener("timeupdate",R),y.addEventListener("ended",k),y.addEventListener("error",E),()=>{y.removeEventListener("timeupdate",R),y.removeEventListener("ended",k),y.removeEventListener("error",E)}},[b,f,m,p,S,w]),g.useEffect(()=>{if(r)return;const y=t.current;if(!y)return;if(!O){try{y.pause()}catch(P){console.log("pause error",P)}C.current=null;return}const R=y.currentSrc||y.src||null,k=!R||R!==O;if(k){try{y.pause()}catch(P){console.log("pause error",P)}y.src=O;try{y.load()}catch(P){console.log("load error",P)}C.current=O}y.muted=!!a,y.volume=1,y.playbackRate=typeof l=="number"?l:1;const E=async()=>{k&&await new Promise(P=>{let I=!1;const M=()=>{I||(I=!0,y.removeEventListener("loadedmetadata",M),y.removeEventListener("canplay",M),P())};y.addEventListener("loadedmetadata",M),y.addEventListener("canplay",M),y.readyState>=1&&M()});try{await y.play()}catch(P){console.warn("el.play() failed",P)}};if(o==="loading"||o==="playing")E();else try{y.pause()}catch(P){console.log("pause error",P)}},[O,a,o,l,r]),g.useEffect(()=>{if(r)return;const y=t.current;if(!y||u!=="real")return;const R=s/1e3;if(Number.isFinite(R)){if(y.readyState<1){h.current=s;const k=()=>{if(h.current!=null){const E=h.current/1e3;try{y.currentTime=E}catch(P){console.log("currentTime보정 오류",P)}h.current=null}y.removeEventListener("loadedmetadata",k),y.removeEventListener("canplay",k)};y.addEventListener("loadedmetadata",k),y.addEventListener("canplay",k);return}if(Math.abs(y.currentTime-R)>.2)try{y.currentTime=R}catch(k){console.log("currentTime보정오류",k)}}},[s,u,r]);const v=Ce(y=>y.getGIFromCT);return g.useEffect(()=>{var k,E;if(r||u!=="real"||o!=="playing"&&o!=="loading")return;const y=v(i,s);if(y<0)return;const R=c(y);R!==_.current&&(_.current=R,S(R,"audio"),R%5===0&&((E=(k=w())==null?void 0:k.ensureVisibleGI)==null||E.call(k,R)))},[o,i,s,u,v,c,S,w,r]),x.jsx("audio",{ref:t,preload:"auto",style:{display:"none"}})});function $a(){return x.jsx(Wa,{})}const Va="_scrubberWrap_uw0cd_2",qa="_labels_uw0cd_9",Ua="_index_uw0cd_15",Ka="_controls_uw0cd_19",Xa="_percent_uw0cd_25",Qa="_range_uw0cd_46",kt={scrubberWrap:Va,labels:qa,index:Ua,controls:Ka,percent:Xa,range:Qa};function Ya(){const e=X(_=>_.isDev),t=q(_=>_.currentGlobalRunIndex),n=q(_=>_.totalRuns),r=q(_=>_.setCurrentGlobalRunIndex),o=q(_=>_.getSectionScrollApi),s=q(_=>_.giToPercentTotal),i=q(_=>_.percentToGITotal),u=q(_=>_.snapToReadable),a=Ce(_=>_.scrollLock),l=Ce(_=>_.pause),d=Ce(_=>_.play),b=Ce(_=>_.syncToGI),[f,m]=g.useState(()=>s(t||0));g.useEffect(()=>{m(s(t||0))},[t,s]);const S=g.useRef(!1),w=g.useMemo(()=>Math.max(0,Math.min(t??0,Math.max(0,(n??1)-1)))+1,[t,n]),c=g.useCallback(()=>{a&&(l(),S.current=!0)},[a,l]),p=g.useCallback(_=>{m(Number(_.currentTarget.value))},[]),h=g.useCallback(async()=>{const _=i(f),O=u(_);l(),r(O,"scrubber-commit"),b(O);const v=o();v!=null&&v.ensureVisibleGI&&await v.ensureVisibleGI(O),S.current&&(S.current=!1,d())},[f,i,u,l,r,b,o,d]),C=g.useMemo(()=>({"--pct":`${f}%`}),[f]),T=g.useMemo(()=>Math.round(f),[f]);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:f,style:C,onMouseDown:c,onTouchStart:c,onChange:p,onMouseUp:()=>{h()},onTouchEnd:()=>{h()},onKeyUp:_=>_.key==="Enter"||_.key===" "?void h():void 0,"aria-label":"진행률"}),x.jsxs("span",{className:kt.percent,children:[T,"%"]})]})]})}const Za=g.memo(Ya),Ja=g.memo(function(){const t=g.useContext(wt),n=(t==null?void 0:t.getState().isPlaybackMode)??!1,r=Ce(y=>y.playbackKind),o=Ce(y=>y.status),s=Ce(y=>y.fake),i=X(y=>y.audioSpeed),u=Ce(y=>y.pause),a=q(y=>y.totalRuns),l=q(y=>y.currentGlobalRunIndex),d=q(y=>y.setCurrentGlobalRunIndex),b=q(y=>y.getSectionScrollApi),f=q(y=>y.nextReadableFrom),m=q(y=>y.edgeReadable),S=g.useRef(null),w=g.useRef(null),c=g.useRef(0),p=g.useRef(-1),h=!n&&r==="fake"&&o==="playing",C=Math.max(1,(s==null?void 0:s.totalWords)??1),T=g.useMemo(()=>{const y=200*i;return C/y*6e4},[C,i]),_=g.useMemo(()=>!a||a<=1||T<=0?0:(a-1)/T,[a,T]);g.useEffect(()=>{if(!h)return;const y=Math.max(0,Math.min(l??0,Math.max(0,(a??1)-1)));c.current=y,p.current=y,w.current=null},[h,l,a]);const O=g.useRef(-1);g.useEffect(()=>{if(!a){O.current=-1;return}const y=m(1);O.current=y??-1},[m,a]);const v=g.useCallback(y=>{(async()=>{var N,A;if(!h){S.current=null;return}if(!a||a<=1||_<=0){S.current=null;return}const R=w.current;w.current=y;const k=R==null?0:Math.max(0,y-R),E=a-1;c.current=Math.min(E,c.current+_*k);const P=Math.floor(c.current),I=b(),M=f(P,1);if(M==null){const $=O.current>=0?O.current:P;$!==p.current&&(p.current=$,d($,"audio"),await((N=I==null?void 0:I.ensureVisibleGI)==null?void 0:N.call(I,$))),u(),S.current=null;return}const z=M;z!==p.current&&(p.current=z,d(z,"audio"),z%5===0&&await((A=I==null?void 0:I.ensureVisibleGI)==null?void 0:A.call(I,z))),S.current=requestAnimationFrame(v)})().catch(console.error)},[h,a,_,f,d,b,u]);return g.useEffect(()=>(h?S.current==null&&(S.current=requestAnimationFrame(v)):(S.current&&(cancelAnimationFrame(S.current),S.current=null),w.current=null),()=>{S.current&&(cancelAnimationFrame(S.current),S.current=null)}),[h,v]),null}),ec=g.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",Pt={WPMSpeedButtonsWrap:rc,btnWrap:oc,label:sc,iconBtn:ic},fo=350,lc=40,ac=.85,cc=g.memo(function(){const t=X(f=>f.audioSpeed),n=X(f=>f.incAudioSpeed),r=X(f=>f.decAudioSpeed),o=g.useRef(null),s=g.useRef(fo),i=g.useRef(null),u=g.useCallback(f=>{const m=t;if(f==="inc"){if(m>=2)return!1;n()}else{if(m<=.3)return!1;r()}return!0},[t,n,r]),a=g.useCallback(()=>{i.current=null,o.current&&(clearTimeout(o.current),o.current=null)},[]),l=g.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=g.useCallback(f=>{if(i.current)return;i.current=f,s.current=fo,u(f)&&l();const S=()=>a();window.addEventListener("mouseup",S,{once:!0}),window.addEventListener("touchend",S,{once:!0})},[l,u,a]);g.useEffect(()=>a,[a]);const b=`${(t*100).toFixed(0)}%`;return x.jsx("div",{onMouseLeave:a,className:Pt.WPMSpeedButtonsWrap,children:x.jsxs("div",{className:Pt.btnWrap,children:[x.jsx("button",{className:Pt.iconBtn,type:"button",title:"속도 느리게",onMouseDown:()=>d("dec"),onTouchStart:f=>{f.preventDefault(),d("dec")},onMouseUp:a,children:x.jsx("img",{src:tc,alt:"느리게"})}),x.jsx("div",{className:Pt.label,style:{minWidth:"44px",textAlign:"center"},children:x.jsx("div",{children:b})}),x.jsx("button",{className:Pt.iconBtn,type:"button",title:"속도 빠르게",onMouseDown:()=>d("inc"),onTouchStart:f=>{f.preventDefault(),d("inc")},onMouseUp:a,children:x.jsx("img",{src:nc,alt:"빠르게"})})]})})}),uc="_StepBtn_15t0r_1",dc={StepBtn:uc};function fc(e){return qe({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 qe({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 po({direction:e}){const t=q(b=>b.currentGlobalRunIndex),n=q(b=>b.totalRuns),r=q(b=>b.hasReadableInDir),o=q(b=>b.computeStepTarget),s=q(b=>b.setCurrentGlobalRunIndex),i=Ce(b=>b.syncToGI),u=q(b=>b.getSectionScrollApi),a=g.useCallback(async b=>{var S,w;const f=Math.max(t,Math.min(0,Math.max(0,(n??1)-1))),m=o(f,b);s(m,"scrubber-step"),i(m),await((w=(S=u())==null?void 0:S.ensureVisibleGI)==null?void 0:w.call(S,m))},[t,n,o,s,i,u]),l=g.useMemo(()=>{const b=Math.max(t,Math.min(0,Math.max(0,(n??1)-1))),f=!n||!r(b,1),m=!n||!r(b,-1);return e==="left"?m:f},[e,n,t,r]),d=g.useCallback(()=>{a(e==="left"?-1:1)},[e,a]);return x.jsx("button",{className:dc.StepBtn,type:"button",onClick:d,disabled:l,title:e==="left"?"이전":"다음",children:e==="left"?x.jsx(fc,{}):x.jsx(pc,{})})}const gc="_GCPlayBtn_n54mc_1",hc="_playing_n54mc_34",go={GCPlayBtn:gc,playing:hc},mc=({size:e=60,color:t="#333",bgColor:n="#fff",isPlaying:r,onClick:o,tooltip:s="재생",title:i=""})=>x.jsx("button",{className:`${go.GCPlayBtn} ${r?go.playing:""}`,onClick:o,"data-tip":s,title:i,style:{"--btn-size":`${e}px`,"--icon-color":t,"--btn-bg":n}});function bc(e){return qe({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 qe({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 R;const e=X(k=>k.showOverlays),t=q(k=>k.section),n=!!t.ast.isAddedSplit,r=!!((R=t.audios)!=null&&R.length),o=q(k=>k.canTracking),s=q(k=>k.canToggleShowGaze),i=q(k=>k.showGaze),u=q(k=>k.onToggleShowGaze),a=X(k=>k.muteAudio),l=X(k=>k.showPointer),d=X(k=>k.showSplit),b=X(k=>k.toggleMuteAudio),f=X(k=>k.toggleShowPointer),m=X(k=>k.toggleShowSplit),S=X(k=>k.overlayCompactMode),w=X(k=>k.toggleOverlayCompactMode),c=cn(),p=pt();g.useEffect(()=>{const k=c.getState(),{syncToGI:E,useFake:P,useReal:I}=k,M=k.playbackKind,z=p.getState().progress.currentGlobalRunIndex??0;if(!r){M!=="fake"&&P();return}a?M!=="fake"&&(console.log("이부분일까?"),P()):M!=="real"&&(E(z),I())},[r,a,p,c]);const h=Ce(k=>k.play),C=Ce(k=>k.pause),T=Ce(k=>k.status),_=g.useCallback(k=>{k.stopPropagation(),T==="playing"||T==="loading"?C():h()},[T,h,C]),O=cn(),v=pt(),y=g.useCallback(async k=>{var me,Ae;if(k.stopPropagation(),T==="playing"||T==="loading"){C();return}const{progress:E}=v.getState(),{currentGlobalRunIndex:P,snapToReadable:I,edgeReadable:M,setCurrentGlobalRunIndex:z,getSectionScrollApi:N}=E,A=O.getState(),$=A.currentClip,te=N==null?void 0:N(),fe=typeof P=="number"?P:0,ge=typeof I=="function"?I(fe):fe,ve=typeof M=="function"?M(1):null;if(ve!=null&&ge>=ve){z==null||z(ve,"audio"),await((me=te==null?void 0:te.ensureVisibleGI)==null?void 0:me.call(te,ve)),A.syncToGI(ve);return}z==null||z(ge,"audio"),await((Ae=te==null?void 0:te.ensureVisibleGI)==null?void 0:Ae.call(te,ge)),A.syncToGI(ge),h($)},[T,C,h,O,v]);return x.jsxs("div",{className:`${we.wrap} ${e?we.visible:""} ${S?we.compact:""}`,onClick:k=>{k.stopPropagation()},onTouchStart:k=>{k.stopPropagation()},children:[!S&&x.jsx(Za,{}),x.jsx("div",{style:S?{display:"none"}:void 0,children:r&&!a?x.jsx($a,{}):x.jsx(ec,{})}),x.jsxs("div",{className:we.controls,children:[x.jsxs("div",{className:we.row1,children:[x.jsx("div",{className:we.groupExpand,children:x.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),w()},className:we.compactBtn,title:S?"오버레이 확대":"오버레이 축소",children:S?x.jsx(xc,{size:24}):x.jsx(bc,{size:24})})}),x.jsxs("div",{className:we.groupPlayback,children:[x.jsx(po,{direction:"left"}),x.jsx(mc,{size:34,isPlaying:T==="playing",onClick:a?y:_,title:T==="playing"?"일시정지":"재생"}),x.jsx(po,{direction:"right"})]}),x.jsx("div",{className:we.groupSpeed,children:x.jsx(cc,{})})]}),x.jsxs("div",{className:we.row2,children:[x.jsxs("div",{className:we.groupFeatures,children:[r&&x.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),b()},className:`${we.btn} ${a?"":we.btnActive}`,title:"오디오북 음소거 전환",children:[a?x.jsx(Sa,{size:18}):x.jsx(ya,{size:18}),x.jsx("span",{className:we.label,children:"오디오북"})]}),x.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),f()},className:`${we.btn} ${l?we.btnActive:""}`,title:"포인터 표시",children:[x.jsx(wa,{size:18}),x.jsx("span",{className:we.label,children:"포인터"})]}),n&&x.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),m()},disabled:!n,className:`${we.btn} ${d?we.btnActive:""} ${n?"":we.btnForbidden}`,title:"끊어읽기 표시",children:[x.jsx(Ca,{size:18}),x.jsx("span",{className:we.label,children:"끊어읽기"})]}),x.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),u==null||u()},disabled:!o||!s,className:`${we.btn} ${o&&i?we.btnActive:""} ${o?"":we.btnForbidden}`,title:"시선 표시",children:[x.jsx(Ta,{size:18}),x.jsx("span",{className:we.label,children:"시선"})]})]}),x.jsxs("div",{className:we.groupNav,children:[x.jsx(ha,{}),x.jsx(pn,{})]})]})]})]})}const Sc=g.memo(vc);function yc(e){return qe({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",dt={host:wc,topbar:Cc,visible:Ic,backBtn:Tc,title:kc,calibrationBtn:Rc,disabled:_c,settingsBtn:Mc};function Ec(){const e=X(b=>b.showOverlays),t=X(b=>b.overlayCompactMode),n=q(b=>b.onViewerClose),o=q(b=>b.section).ast.title,s=q(b=>b.canTracking),i=q(b=>b.handleAskCalibration),u=X(b=>b.setSettingsOpen),a=X(b=>b.setShowOverlays),l=g.useCallback(()=>{n==null||n()},[n]),d=g.useCallback(()=>{u(!0),a(!1)},[u,a]);return x.jsx("div",{className:dt.host,children:x.jsxs("div",{className:`${dt.topbar} ${e&&!t?dt.visible:""}`,children:[x.jsx("button",{type:"button",className:dt.backBtn,onClick:l,"aria-label":"뒤로가기",children:x.jsx(Ia,{size:28})}),x.jsx("div",{className:dt.title,children:x.jsx("span",{className:"truncate",children:o||"섹션 없음"})}),x.jsx("button",{type:"button",className:`${dt.calibrationBtn} ${s?"":dt.disabled}`,onClick:i,disabled:!s,"aria-label":"시선보정",title:"시선보정",children:x.jsx(ka,{size:24})}),x.jsx("button",{type:"button",className:dt.settingsBtn,onClick:d,"aria-label":"뷰어 설정",children:x.jsx(yc,{size:28})})]})})}const jc=g.memo(Ec),Oc="_wrap_62su0_7",zc="_wrapHidden_62su0_29",Pc="_wrapVisible_62su0_35",Ac="_scrollArea_62su0_71",Bc="_row_62su0_81",Lc="_label_62su0_89",Gc="_btn_62su0_95",Hc="_btnActive_62su0_106",Nc="_btnSmall_62su0_110",Fc="_pill_62su0_122",Dc="_themeCircle_62su0_133",Wc="_themeCircleActive_62su0_146",$c="_stepRow_62su0_151",Vc="_stepLabel_62su0_159",qc="_levelBox_62su0_172",Uc="_inlineFlex_62su0_177",Me={wrap:Oc,wrapHidden:zc,wrapVisible:Pc,scrollArea:Ac,row:Bc,label:Lc,btn:Gc,btnActive:Hc,btnSmall:Nc,pill:Fc,themeCircle:Dc,themeCircleActive:Wc,stepRow:$c,stepLabel:Vc,levelBox:qc,inlineFlex:Uc};function Kc({visible:e}){const t=X(v=>v.mode),n=X(v=>v.setMode),r=X(v=>v.theme),o=X(v=>v.setTheme),s=X(v=>v.fontFamily),i=X(v=>v.setFontFamily),u=X(v=>v.resetToDefaults),a=X(v=>v.getFontLevel()),l=X(v=>v.getLineLevel()),d=X(v=>v.getMarginLevel()),b=X(v=>v.setFontLevel),f=X(v=>v.setLineLevel),m=X(v=>v.setMarginLevel),S=X(v=>v.pointerStyle),w=X(v=>v.setPointerStyle),c=X(v=>v.pointerColor),p=X(v=>v.setPointerColor),h=X(v=>v.breakMarks),C=X(v=>v.toggleBreakMark),T=X(v=>v.getBreakGapLevel()),_=X(v=>v.setBreakGapLevel),O=`${Me.wrap} ${e?Me.wrapVisible:Me.wrapHidden}`;return x.jsxs("div",{className:O,role:"dialog","aria-modal":"true","aria-label":"뷰어 설정",children:[x.jsxs("div",{className:Me.scrollArea,children:[x.jsx(At,{label:"열람방식",children:x.jsxs("div",{className:Me.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:Me.inlineFlex,children:Object.keys(sn).map(v=>{const y=v,R=sn[y];return x.jsx("button",{type:"button",onClick:()=>o(y),className:`${Me.themeCircle} ${r===v?Me.themeCircleActive:""}`,style:{background:R.bg,color:R.fg,fontFamily:s},title:String(v),"aria-label":`테마: ${String(v)}`,children:"A"},`${v}_tc_button`)})})}),x.jsx(At,{label:"글꼴",children:x.jsx("div",{className:Me.inlineFlex,children:Go.map(v=>x.jsx(Rt,{active:s===v.value,onClick:()=>i(v.value),title:v.value,children:v.label},v.label))})}),x.jsx(tn,{label:"글자 크기",level:a,min:1,max:12,onDec:()=>b(Math.max(1,a-1)),onInc:()=>b(Math.min(12,a+1))}),x.jsx(tn,{label:"줄 간격",level:l,min:1,max:7,onDec:()=>f(Math.max(1,l-1)),onInc:()=>f(Math.min(7,l+1))}),x.jsx(tn,{label:"여백",level:d,min:1,max:5,onDec:()=>m(Math.max(1,d-1)),onInc:()=>m(Math.min(5,d+1))}),x.jsx(At,{label:"포인터",children:x.jsxs("div",{className:Me.inlineFlex,children:[x.jsx(Rt,{active:S==="highlight",onClick:()=>w("highlight"),children:"형광펜"}),x.jsx(Rt,{active:S==="underline",onClick:()=>w("underline"),children:"밑줄"}),x.jsx("input",{type:"color",value:c,onChange:v=>p(v.target.value),"aria-label":"포인터 색상",style:{width:36,height:28,padding:0,border:"none",background:"transparent"}})]})}),x.jsx(At,{label:"끊기표시",children:x.jsx("div",{className:Me.inlineFlex,children:x.jsx(Rt,{active:h.slash,onClick:()=>C("slash"),children:"슬래쉬"})})}),x.jsx(tn,{label:"끊기간격",level:T,min:1,max:5,onDec:()=>_(Math.max(1,T-1)),onInc:()=>_(Math.min(5,T+1))})]}),x.jsx("div",{className:Me.inlineFlex,style:{justifyContent:"center"},children:x.jsx("button",{type:"button",onClick:u,className:Me.pill,children:"보기 설정 초기화"})})]})}function At({label:e,children:t}){return x.jsxs("div",{className:Me.row,children:[x.jsx("label",{className:Me.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:`${Me.btn} ${e?Me.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:Me.stepRow,children:[x.jsx("label",{className:Me.stepLabel,children:e}),x.jsxs("div",{className:Me.inlineFlex,children:[x.jsx("button",{type:"button",onClick:o,disabled:i,className:Me.btnSmall,"aria-label":"감소",children:"−"}),x.jsx("div",{className:Me.levelBox,children:t}),x.jsx("button",{type:"button",onClick:s,disabled:u,className:Me.btnSmall,"aria-label":"증가",children:"+"})]})]})}const Xc=g.memo(function(){const t=X(i=>i.showOverlays),n=X(i=>i.isSettingsOpen),r=q(i=>i.rangeStartGI),o=q(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 b=i(r.getState());l=f=>{const m=i(f);if(!d(b,m)){const S=b;u(b=m,S)}},a!=null&&a.fireImmediately&&u(b,b)}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=m=>{if(!n)return null;const{g2ct:S}=n;if(!S)return null;const w=S[m];if(w)return{clip:w.clip,t:w.t};for(let c=1;c<=100&&m-c>=0;c++){const p=S[m-c];if(p)return{clip:p.clip,t:p.t}}for(let c=1;c<=100;c++){const p=S[m+c];if(p)return{clip:p.clip,t:p.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 m=o(e.initialIndex);m&&(i=m.clip,u=m.t,r=void 0)}const l=s.length>0,d=l?"paused":"idle",b=l?"real":"fake",f=l?null:{totalWords:a};return qt(Yc((m,S)=>({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:b,fake:f,useFake:()=>m(w=>({playbackKind:"fake",fake:{totalWords:a},scrollLock:w.status==="playing"})),useReal:()=>m(w=>({playbackKind:"real",fake:{totalWords:a},scrollLock:w.status==="playing"})),injectMap:w=>{if(n=w,typeof r=="number"){const c=o(r);c&&m(p=>({currentClip:Math.max(0,Math.min(c.clip,Math.max(0,p.clips.length-1))),currentTimeMs:Math.max(0,c.t)})),r=void 0}},setClipAndMs:(w,c)=>m(p=>{const h=Math.max(0,p.clips.length-1);return{currentClip:Math.max(0,Math.min(w,h)),currentTimeMs:Math.max(0,c),status:p.status,scrollLock:p.scrollLock}}),setClips:w=>m(c=>{const p=Array.isArray(w)?w:[],h=p.length>0;return{clips:p,currentClip:0,currentTimeMs:0,status:h?"paused":"idle",playbackKind:h?"real":"fake",fake:h?null:c.fake??{totalWords:a},scrollLock:!1}}),clear:()=>m(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"}}),m(p=>{if(p.playbackKind==="fake")return{status:"playing",scrollLock:!0};const h=typeof w=="number"?w:p.currentClip,C=typeof c=="number"?c:p.currentTimeMs;return{status:"loading",currentClip:Math.max(0,Math.min(h,Math.max(0,p.clips.length-1))),currentTimeMs:C,scrollLock:!0}})},pause:()=>{t==null||t.getState().emit({type:"audio_control",payload:{action:"pause"}}),m({status:"paused",scrollLock:!1})},seek:w=>m(c=>({currentTimeMs:Math.max(0,w),status:c.status})),stop:()=>m({status:"idle",currentTimeMs:0,scrollLock:!1}),nextClip:()=>m(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:()=>m(w=>w.playbackKind==="fake"?w:{currentClip:Math.max(0,w.currentClip-1),currentTimeMs:0,status:"loading",scrollLock:!0}),setClipIndex:w=>m(c=>c.playbackKind==="fake"||w<0||w>=c.clips.length?c:{currentClip:w,currentTimeMs:0}),getClipSrc:w=>{const c=S();if(!c.clips.length)return null;const p=typeof w=="number"?w:c.currentClip;return Zc(c.clips[p])},getGIFromCT:(w,c)=>{if(!n)return-1;const p=n.byClip[w];if(!p||p.length===0)return-1;let h=0,C=p.length-1,T=0;for(;h<=C;){const _=h+C>>1;p[_].t<=c?(T=_,h=_+1):C=_-1}return p[Math.max(0,Math.min(T,p.length-1))].g},getCTFromGI:w=>{if(!n)return null;const{g2ct:c}=n;if(!c)return null;let p=c[w];if(!p){let h=w-1;const C=Math.max(0,w-100);for(;h>=C;){if(c[h]){p=c[h];break}h--}if(!p){let T=w+1;const _=w+100;for(;c[T]==null&&T<=_;)T++;c[T]&&(p=c[T])}}return p?{clip:p.clip,timeMs:p.t}:null},getMetaByGI:w=>{const c=S().getCTFromGI(w);return c?{clipIndex:c.clip,timeMs:c.timeMs}:null},syncToGI:w=>{const c=S().getMetaByGI(w);c&&S().setClipAndMs(c.clipIndex,c.timeMs)},_onTime:w=>m({currentTimeMs:w,status:"playing",scrollLock:!0}),_onEnded:()=>m(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:()=>m({status:"error",scrollLock:!1}),_setStatusOnly:w=>m({status:w})})))}function nu({children:e,initialState:t}){const n=g.useContext(wt)??void 0,r=g.useMemo(()=>tu({...t,recorderStore:n}),[t,n]);return x.jsx(Sn.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],b=o+l;d.audioChunkIndex!=null&&d.audioTimeMs!=null&&((t[i=d.audioChunkIndex]||(t[i]=[])).push({t:d.audioTimeMs,g:b}),n[b]={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=Xl(e),n=Ql(t),r=t.reduce((d,b)=>d+(b||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,b)=>{var c;if(d.type!=="paragraph")return;const f=n[b]??0,m=d.runs??[];for(let p=0;p<m.length;p++){const h=((c=m[p])==null?void 0:c.text)||"";lr(h)&&(s[f+p]=1)}const w=Yl(m,f).map(p=>{var _;const h=p.startG-f,C=p.endG-p.startG+1;let T=-1;for(let O=0;O<C;O++){const v=((_=m[h+O])==null?void 0:_.text)??"";if(lr(v)){T=p.startG+O;break}}return{startG:p.startG,endG:p.endG,r0:h,len:C,firstReadableGI:T,splitIndex:p.splitIndex}});u[b]=w;for(const p of w){const h=i.length;for(let C=p.startG;C<=p.endG;C++)o[C]=h;i.push(p)}}),{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:b,layout:f,initialIndex:m,mountTime:S}=e,w=f.totalRuns??0,c=typeof m=="number"?m:w>0?0:-1,p=c>=0?ou(b.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:p,lastUpdateBy:"program",totalRuns:w,pageIndex:0,totalPages:0,sectionLoading:!0,_loadingStartTime:S,_scrollApi:void 0,derivedNav:b,layout:f,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:b,eventBridgeStore:f}=e,m=t.ast.blocks,{nav:S,layout:w}=su(m),c=Date.now(),p=iu({section:t,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i,canTracking:u,canToggleShowGaze:a,showGaze:l,onToggleShowGaze:d,handleAskCalibration:b,nav:S,layout:w,initialIndex:n,mountTime:c});return f&&queueMicrotask(()=>{f.getState().emit({type:"render_start",payload:{sectionId:t.section_id}},c),f.getState().emit({type:"loading_start",payload:{}},c)}),qt((h,C)=>{const T=K=>{h(W=>W.progress._scrollApi===K?W:{progress:{...W.progress,_scrollApi:K}})},_=()=>C().progress._scrollApi,O=K=>{h(W=>{const L=W.progress;if(L.totalRuns===K)return W;const j=L.currentGlobalRunIndex<0&&K>0;return{progress:{...L,totalRuns:K,currentGlobalRunIndex:j?0:L.currentGlobalRunIndex,lastUpdateBy:j?"program":L.lastUpdateBy}}})},v=(K,W="program")=>{const L=C().progress.currentGlobalRunIndex,j=C().progress,G=j.totalRuns>0?Math.max(-1,Math.min(K,j.totalRuns-1)):K;L===G&&j.lastUpdateBy===W||(h(V=>({progress:{...V.progress,currentGlobalRunIndex:G,lastUpdateBy:W}})),L!==G&&f&&f.getState().emit({type:"global_index_change",payload:{globalIndex:G}}))},y=K=>{const{sectionLoading:W,_loadingStartTime:L}=C().progress;if(W===K)return;const j=Date.now();if(K)h(G=>({progress:{...G.progress,sectionLoading:!0,_loadingStartTime:j}})),f&&f.getState().emit({type:"loading_start",payload:{}});else{const V=(L?j-L:0)/1e3;h(B=>({progress:{...B.progress,sectionLoading:!1,_loadingStartTime:null}})),f&&f.getState().emit({type:"loading_end",payload:{duration:V}})}},R=K=>{h(W=>({progress:{...W.progress,pageIndex:K}}))},k=K=>{h(W=>({progress:{...W.progress,totalPages:K}}))},E=(K,W)=>{const j=C().progress.rangeStartGI==null;if(h(G=>({progress:{...G.progress,rangeStartGI:Math.min(K,W),rangeEndGI:Math.max(K,W)}})),f){const G=M();f.getState().emit({type:j?"range_select":"range_change",payload:{startGI:Math.min(K,W),endGI:Math.max(K,W),text:G}})}},P=()=>{h(K=>({progress:{...K.progress,rangeStartGI:null,rangeEndGI:null}})),f&&f.getState().emit({type:"range_clear",payload:{}})},I=K=>{const{rangeStartGI:W,rangeEndGI:L}=C().progress;W==null||L==null||(K<W?h(j=>({progress:{...j.progress,rangeStartGI:K}})):K>L?h(j=>({progress:{...j.progress,rangeEndGI:K}})):P())},M=()=>{var Z;const{rangeStartGI:K,rangeEndGI:W,section:L,layout:j}=C().progress;if(K==null||W==null||!j)return"";const G=((Z=L.ast)==null?void 0:Z.blocks)??[],V=j.prefix,B=[];for(let F=0;F<G.length;F++){const Q=G[F];if(Q.type!=="paragraph")continue;const ee=Q.runs??[],J=V[F]??0;for(let ie=0;ie<ee.length;ie++){const re=J+ie;re>=K&&re<=W&&B.push(ee[ie].text??"")}}return B.join("")},z=K=>{h(W=>({progress:{...W.progress,translateOpen:K.isOpen,translateLoading:K.isLoading??!1,translateText:K.text,translatedText:K.translatedText,translateStartGI:K.startGI,translateEndGI:K.endGI}}))},N=()=>{h(K=>({progress:{...K.progress,translateOpen:!1,translateLoading:!1,translateText:void 0,translatedText:void 0,translateStartGI:void 0,translateEndGI:void 0}}))},A=K=>{const{totalRuns:W,derivedNav:L}=C().progress,j=L==null?void 0:L.readableGi;if(!j||W<=0)return K;const G=W,V=Math.max(0,Math.min(K,G-1));if(j[V])return V;let B=V-1,Z=V+1;for(;B>=0||Z<G;){if(Z<G&&j[Z])return Z;if(B>=0&&j[B])return B;Z+=1,B-=1}return V},$=(K,W)=>{const{totalRuns:L,derivedNav:j}=C().progress,G=j==null?void 0:j.readableGi;if(!G||L<=0)return null;if(W>0){for(let V=Math.min(Math.max(K,0),L-1);V<L;V+=1)if(G[V])return V}else for(let V=Math.min(Math.max(K,0),L-1);V>=0;V-=1)if(G[V])return V;return null},te=K=>{const{totalRuns:W,derivedNav:L}=C().progress,j=L==null?void 0:L.readableGi;if(!j||W<=0)return null;if(K>0){for(let G=W-1;G>=0;G-=1)if(j[G])return G}else for(let G=0;G<W;G+=1)if(j[G])return G;return null};return{progress:{...p,registerSectionScrollApi:T,getSectionScrollApi:_,setTotalRuns:O,setCurrentGlobalRunIndex:v,setSectionLoading:y,setPageIndex:R,setTotalPages:k,setTranslateState:z,clearTranslate:N,setRange:E,clearRange:P,extendRange:I,getRangeText:M,snapToReadable:A,nextReadableFrom:$,edgeReadable:te,hasReadableInDir:(K,W)=>$(K+(W>0?1:-1),W)!=null,computeStepTarget:(K,W)=>{const{totalRuns:L,derivedNav:j}=C().progress;if(!L||L<=0)return K;const G=(j==null?void 0:j.groups)??[],V=j==null?void 0:j.giToGroupIdx;if(!G.length||!V){const J=L-1;return A(Math.max(0,Math.min(K+W,J)))}let B=V[K]??-1;if(B<0||B>=G.length)for(let ee=0;ee<G.length;ee+=1){const J=G[ee];if(K>=J.startG&&K<=J.endG){B=ee;break}}if(B<0||B>=G.length)return te(W)??A(K);const Z=ee=>ee>=0&&ee<G.length&&(G[ee].firstReadableGI??-1)>=0;let F=B+W;for(;F>=0&&F<G.length&&!Z(F);)F+=W;if(F<0||F>=G.length)return te(W)??A(K+W);const Q=G[F].firstReadableGI;return Q>=0?Q:A(K+W)},giToPercentTotal:K=>{const W=C().progress.totalRuns;return!W||W<=1?0:Math.max(0,Math.min(K,W-1))/(W-1)*100},percentToGITotal:K=>{const W=C().progress.totalRuns;if(!W||W<=1)return 0;const L=Math.max(0,Math.min(K,100)),j=Math.round(L/100*(W-1));return Math.max(0,Math.min(j,W-1))}}}})}function au({children:e,initialState:t,gazeSync:n}){const r=g.useContext(wt),o=g.useMemo(()=>lu({...t,...n?n.getSnapshot():{},eventBridgeStore:r}),[t,r]);return g.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(cr.Provider,{value:o,children:e})}function cu({children:e,initialState:t}){const n=g.useContext(wt)??void 0,r=g.useRef(Zs({init:t,recorderStore:n}));return x.jsx(ar.Provider,{value:r.current,children:e})}const uu=({pages:e,pageIndex:t,maxWidth:n})=>{const r=q(h=>h.section),o=g.useMemo(()=>{var h;return((h=r.ast)==null?void 0:h.blocks)??[]},[r]),s=X(h=>h.marginX),i=X(h=>h.lineHeight),u=X(h=>h.fontSizePx),a=X(h=>h.fontFamily),l=X(h=>h.viewportHeight),d=q(h=>{var C;return((C=h.layout)==null?void 0:C.prefix)??[]}),b=q(h=>{var C;return((C=h.derivedNav)==null?void 0:C.splitGroupsPerBlock)??[]}),f=e[t],m=g.useMemo(()=>{const h=[];return o.forEach((C,T)=>{(C.type==="paragraph"||C.type==="image")&&h.push(T)}),h},[o]),S=g.useMemo(()=>{if(!f)return[];const h=[];for(let C=f.startBlock;C<=f.endBlock;C++){const T=m[C];T!=null&&h.push(T)}return h},[f,m]),w=g.useMemo(()=>{const h=[];for(const C of S){const T=o[C];(T==null?void 0:T.type)==="paragraph"&&h.push({b:T,originalBlockIndex:C})}return h},[S,o]),c=g.useMemo(()=>{const h=[],C=wr();return w.forEach((T,_)=>{h[_]=Cr(T.b,C)}),h},[w]),p=(h,C,T)=>{if(!h||h.length===0)return[];const _=[];for(const O of h){const v=O.startG,y=O.endG;if(y<C||v>T)continue;const R=Math.max(v,C),k=Math.min(y,T),E=R-v|0,P=Math.max(0,k-R+1);if(P<=0)continue;const I=(O.r0??0)+E;_.push({...O,startG:R,endG:k,r0:I,len:P})}return _};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:S.map((h,C)=>{var L;const T=o[h],_=C===0,O=C===S.length-1,v={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??h}`;if(T.type==="image"){const{src:j,alt:G,width:V,height:B}=T,Z=V&&B?`${V} / ${B}`:"4 / 3",F=l>80?Math.floor((l-80)*.6):void 0;return x.jsx("div",{style:v,children:x.jsxs("div",{style:{margin:"12px 0",textAlign:"center",width:"100%"},children:[x.jsx("div",{style:{position:"relative",width:"100%",maxHeight:F,aspectRatio:Z},children:x.jsx("img",{src:j,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 R=T,k=w.findIndex(j=>j.originalBlockIndex===h),E=k>=0?c[k]:void 0,P=R.runs??[],I=P.length;let M=0,z=Math.max(0,I-1);_&&f.startOffsetInBlock!=null&&(M=Math.min(Math.max(0,f.startOffsetInBlock),z)),O&&f.endOffsetInBlock!=null&&(z=Math.max(M,Math.min(f.endOffsetInBlock,z)));const N=M>0,A=d[h]??0,$=b[h]??[],te=A+M,fe=A+z;let ge=p($,te,fe);const ve=A+M;ge=ge.map(j=>{const G=Math.max(0,(j.startG??te)-ve),V=j.len??Math.max(1,(j.endG??fe)-(j.startG??te)+1);return{...j,r0:G,len:V}});const me=M<=z?P.slice(M,z+1):[],Ae=R.list?R.list.level*24:0,K=((L=R.list)==null?void 0:L.kind)==="bullet"?R.list.glyph??"•":void 0,W=N?void 0:E??K;return x.jsx("div",{style:v,children:x.jsxs("p",{style:{width:"100%",margin:"8px 0",paddingLeft:Ae,textAlign:R.textAlign,whiteSpace:"pre-wrap",boxSizing:"border-box"},children:[R.list&&W?x.jsx("span",{"aria-hidden":!0,style:{minWidth:16,display:"inline-block",whiteSpace:"nowrap",userSelect:"none"},children:W||""}):null,x.jsx(vs,{preGroups:ge,runs:me,ns:y,baseIndex:ve,sectionId:String(r.section_id)})]})},y)})})]})})},nn=.5;function du(e,t){const n=g.useRef(null),r=g.useRef(null),o=g.useRef(!1);g.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:b}=l.contentRect,f=r.current;if(!f){r.current={w:d,h:b};return}Math.abs(f.w-d)<nn&&Math.abs(f.h-b)<nn||(r.current={w:d,h:b},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,b=a.offsetHeight;if(Math.abs(r.current.w-d)<nn&&Math.abs(r.current.h-b)<nn)return;r.current={w:d,h:b}}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:b,onDragEnd:f,pageTransitionThreshold:m}=e,S=m??u,w=10,c=$e.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}),p=()=>{c.current.singleTimer!=null&&(clearTimeout(c.current.singleTimer),c.current.singleTimer=null)},h=$e.useCallback(M=>{if(s!=null&&s(M))return;const z=performance.now();z-c.current.lastTapT<=d&&c.current.lastTapT>0?(p(),c.current.lastTapT=0,o==null||o()):(p(),r&&(c.current.singleTimer=window.setTimeout(()=>{c.current.singleTimer=null,r()},l)),c.current.lastTapT=z)},[s,d,o,r,l]),C=$e.useCallback((M,z)=>{const N=Math.abs(M)/Math.max(1,z);Math.abs(M)>=S||N>=a?M<0?n():t():f==null||f()},[S,a,n,t,f]),T=$e.useCallback(M=>{if(M.touches.length!==1)return;const z=i??s;if(z!=null&&z(M.target))return;const N=M.touches[0];c.current.touchId=N.identifier,c.current.startX=N.clientX,c.current.startY=N.clientY,c.current.startT=M.timeStamp,c.current.swiping=!1},[i,s]),_=$e.useCallback(M=>{if(c.current.touchId==null)return;const z=Array.from(M.touches).find(te=>te.identifier===c.current.touchId);if(!z)return;const N=z.clientX-c.current.startX,A=Math.abs(N),$=Math.abs(z.clientY-c.current.startY);if(!c.current.swiping)if(A>=w&&A>$)c.current.swiping=!0;else return;b==null||b(N)},[b]),O=$e.useCallback(M=>{if(c.current.touchId==null)return;const z=Array.from(M.changedTouches).find(te=>te.identifier===c.current.touchId);if(!z)return;const N=z.clientX-c.current.startX,A=z.clientY-c.current.startY,$=M.timeStamp-c.current.startT;c.current.swiping?C(N,$):Math.abs(N)<10&&Math.abs(A)<10&&h(M.target),c.current.suppressClick=!0,c.current.touchId=null,c.current.swiping=!1},[C,h]),v=$e.useCallback(()=>{c.current.swiping&&(f==null||f()),c.current.touchId=null,c.current.swiping=!1},[f]),y=$e.useCallback(M=>{if(M.pointerType==="touch"||c.current.mouseDown)return;const z=i??s;z!=null&&z(M.target)||(c.current.mouseDown=!0,c.current.mouseSwiping=!1,c.current.mStartX=M.clientX,c.current.mStartY=M.clientY,c.current.mStartT=M.timeStamp,c.current.suppressClick=!1,c.current.capturedEl=M.currentTarget)},[i,s]),R=$e.useCallback(M=>{if(M.pointerType==="touch"||!c.current.mouseDown)return;const z=M.clientX-c.current.mStartX,N=Math.abs(z),A=Math.abs(M.clientY-c.current.mStartY);if(!c.current.mouseSwiping)if(N>=w&&N>A){c.current.mouseSwiping=!0,c.current.suppressClick=!0;const $=c.current.capturedEl;if($!=null&&$.setPointerCapture)try{$.setPointerCapture(M.pointerId)}catch{}c.current.prevUserSelect=document.body.style.userSelect,document.body.style.userSelect="none",M.preventDefault()}else return;b==null||b(z),M.preventDefault()},[b]),k=$e.useCallback(M=>{var N;if(M.pointerType==="touch"||!c.current.mouseDown)return;if(c.current.mouseSwiping){const A=M.clientX-c.current.mStartX,$=M.timeStamp-c.current.mStartT;C(A,$),document.body.style.userSelect=c.current.prevUserSelect}const z=c.current.capturedEl;if((N=z==null?void 0:z.hasPointerCapture)!=null&&N.call(z,M.pointerId))try{z.releasePointerCapture(M.pointerId)}catch{}c.current.mouseDown=!1,c.current.mouseSwiping=!1,c.current.capturedEl=null},[C]),E=$e.useCallback(M=>{M.pointerType!=="touch"&&(c.current.mouseSwiping&&(f==null||f(),document.body.style.userSelect=c.current.prevUserSelect),c.current.mouseDown=!1,c.current.mouseSwiping=!1,c.current.capturedEl=null)},[f]),P=$e.useCallback(()=>{c.current.mouseSwiping&&(f==null||f(),document.body.style.userSelect=c.current.prevUserSelect),c.current.mouseDown=!1,c.current.mouseSwiping=!1,c.current.capturedEl=null},[f]),I=$e.useCallback(M=>{if(c.current.suppressClick){c.current.suppressClick=!1;return}h(M.target)},[h]);return $e.useEffect(()=>()=>{p(),document.body.style.userSelect=""},[]),{onTouchStart:T,onTouchMove:_,onTouchEnd:O,onTouchCancel:v,onPointerDown:y,onPointerMove:R,onPointerUp:k,onPointerCancel:E,onLostPointerCapture:P,onClick:I}}var An,ho;function ks(){if(ho)return An;ho=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return An=e,An}var Bn,mo;function pu(){if(mo)return Bn;mo=1;var e=typeof Qt=="object"&&Qt&&Qt.Object===Object&&Qt;return Bn=e,Bn}var Ln,bo;function Rs(){if(bo)return Ln;bo=1;var e=pu(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Ln=n,Ln}var Gn,xo;function gu(){if(xo)return Gn;xo=1;var e=Rs(),t=function(){return e.Date.now()};return Gn=t,Gn}var Hn,vo;function hu(){if(vo)return Hn;vo=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return Hn=t,Hn}var Nn,So;function mu(){if(So)return Nn;So=1;var e=hu(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Nn=n,Nn}var Fn,yo;function _s(){if(yo)return Fn;yo=1;var e=Rs(),t=e.Symbol;return Fn=t,Fn}var Dn,wo;function bu(){if(wo)return Dn;wo=1;var e=_s(),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 Dn=s,Dn}var Wn,Co;function xu(){if(Co)return Wn;Co=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return Wn=n,Wn}var $n,Io;function vu(){if(Io)return $n;Io=1;var e=_s(),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 $n=i,$n}var Vn,To;function Su(){if(To)return Vn;To=1;function e(t){return t!=null&&typeof t=="object"}return Vn=e,Vn}var qn,ko;function yu(){if(ko)return qn;ko=1;var e=vu(),t=Su(),n="[object Symbol]";function r(o){return typeof o=="symbol"||t(o)&&e(o)==n}return qn=r,qn}var Un,Ro;function wu(){if(Ro)return Un;Ro=1;var e=mu(),t=ks(),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 b=s.test(l);return b||i.test(l)?u(l.slice(2),b?2:8):o.test(l)?r:+l}return Un=a,Un}var Kn,_o;function Cu(){if(_o)return Kn;_o=1;var e=ks(),t=gu(),n=wu(),r="Expected a function",o=Math.max,s=Math.min;function i(u,a,l){var d,b,f,m,S,w,c=0,p=!1,h=!1,C=!0;if(typeof u!="function")throw new TypeError(r);a=n(a)||0,e(l)&&(p=!!l.leading,h="maxWait"in l,f=h?o(n(l.maxWait)||0,a):f,C="trailing"in l?!!l.trailing:C);function T(I){var M=d,z=b;return d=b=void 0,c=I,m=u.apply(z,M),m}function _(I){return c=I,S=setTimeout(y,a),p?T(I):m}function O(I){var M=I-w,z=I-c,N=a-M;return h?s(N,f-z):N}function v(I){var M=I-w,z=I-c;return w===void 0||M>=a||M<0||h&&z>=f}function y(){var I=t();if(v(I))return R(I);S=setTimeout(y,O(I))}function R(I){return S=void 0,C&&d?T(I):(d=b=void 0,m)}function k(){S!==void 0&&clearTimeout(S),c=0,d=w=b=S=void 0}function E(){return S===void 0?m:R(t())}function P(){var I=t(),M=v(I);if(d=arguments,b=this,w=I,M){if(S===void 0)return _(w);if(h)return clearTimeout(S),S=setTimeout(y,a),T(w)}return S===void 0&&(S=setTimeout(y,a)),m}return P.cancel=k,P.flush=E,P}return Kn=i,Kn}var Iu=Cu();const Tu=Ao(Iu);function ku(e,t=200,n,r){const o=g.useRef(e),s=g.useRef(n);g.useEffect(()=>{o.current=e},[e]),g.useEffect(()=>{s.current=n},[n]);const i=g.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 g.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 Xn=!1;function _u(){if(Xn||typeof document>"u")return;if(document.querySelector('link[href*="fonts.googleapis.com"][href*="Noto"]')){Xn=!0;return}const t=document.createElement("link");t.rel="stylesheet",t.href=Ru,document.head.appendChild(t),Xn=!0}const Ms=new Map,Es=e=>Ms.get(e)??0,Mu=e=>{const t=Es(e)+1;return Ms.set(e,t),t};class js extends Error{constructor(){super("calcPages canceled due to a newer invocation");kr(this,"code","CALC_PAGES_CANCELED");this.name="CalcPagesCanceled"}}const Ye=(e,t)=>{if(e!==Es(t))throw new js},Qn=e=>{const t=getComputedStyle(e),n=parseFloat(t.marginTop||"0")||0,r=parseFloat(t.marginBottom||"0")||0;return{mt:n,mb:r}},Mo=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:b,paragraphMarkers:f,playbackScale:m=1,viewportHeight:S=0,instanceId:w="default"}){var p,h,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(m-1)>.001,_=1/m;T&&(t.style.transform=`scale(${_})`,t.style.transformOrigin="top left");const O=Math.max(0,e.offsetWidth||0),v=Math.max(0,Math.min(O,o));t.style.maxWidth=`${v}px`,Ye(c,w);let y=Math.round(n.offsetHeight||0);y||(y=Math.max(0,n.clientHeight|0)),console.log("[calcPages] playbackScale:",m.toFixed(4),T?"(scaled, applying inverse)":"(no scale)"),console.log("[calcPages] viewWidth:",O),console.log("[calcPages] pageBoxWidth:",v),console.log("[calcPages] maxPageHeight:",y),console.log("[calcPages] contentArea rect:",n.getBoundingClientRect()),console.log("[calcPages] measureRoot rect:",t.getBoundingClientRect());const R=1.5,k=(B,Z)=>Z+B<=y-R,E=getComputedStyle(e),P={letterSpacing:E.letterSpacing,wordSpacing:E.wordSpacing,fontKerning:E.fontKerning||"normal",fontVariantLigatures:E.fontVariantLigatures||"normal",textTransform:E.textTransform||"none",direction:E.direction||"ltr",wordBreak:E.wordBreak||"keep-all",overflowWrap:E.overflowWrap||E.wordWrap||"break-word",hyphens:E.hyphens||"manual"},I=B=>{B.style.letterSpacing=P.letterSpacing||"",B.style.wordSpacing=P.wordSpacing||"",B.style.fontKerning=P.fontKerning||"",B.style.fontVariantLigatures=P.fontVariantLigatures||"",B.style.textTransform=P.textTransform||"",B.style.direction=P.direction||"",B.style.wordBreak=P.wordBreak||"",B.style.wordWrap=P.overflowWrap||"",B.style.overflowWrap=P.overflowWrap||"",B.style.hyphens=P.hyphens||""},M=v,z=Math.max(0,M-2*(s||0));n.innerHTML="";const N=document.createElement("div");N.style.boxSizing="border-box",N.style.width=`${M}px`,N.style.maxWidth=`${M}px`,N.style.margin="0 auto",N.style.display="flex",n.appendChild(N);const A=document.createElement("div");A.style.boxSizing="border-box",A.style.paddingRight=`${s}px`,A.style.paddingLeft=`${s}px`,A.style.width=`${M}px`,A.style.maxWidth=`${M}px`,A.style.margin="0 auto",A.style.display="flex",A.style.justifyContent="center",A.style.height="auto",N.appendChild(A);const $=new Map,te={},fe=Eu(c,w,r.length),ge=(B,Z)=>{const F=document.createElement("p");return F.style.margin="8px 0",F.style.paddingLeft=Z?`${Z}px`:"0",F.style.textAlign=B.textAlign??"start",F.style.whiteSpace="pre-wrap",F.style.lineHeight=String(a),F.style.fontSize=`${u}px`,F.style.boxSizing="border-box",F.style.fontFamily=i??"",F.style.width="100%",I(F),F},ve=(B,Z)=>{const F=Z??[],Q=document.createDocumentFragment();for(let ee=0;ee<F.length;ee++){const J=F[ee],ie=document.createElement("span");ie.dataset.runbox=String(ee),ie.style.whiteSpace="pre-wrap";const re=document.createElement("span");if(re.dataset.run=String(ee),re.textContent=(J==null?void 0:J.text)??"",re.style.whiteSpace="pre-wrap",J!=null&&J.bold&&(re.style.fontWeight="700"),J!=null&&J.italic&&(re.style.fontStyle="italic"),J!=null&&J.underline&&(re.style.textDecoration="underline"),ie.appendChild(re),l&&(J!=null&&J.split)&&ee!==F.length-1){const be=Math.max(0,(d??0)/2),ue=document.createElement("span");ue.style.display="inline-block",ue.style.width=`${be}px`;const ye=document.createElement("span");if(ye.style.display="inline-block",ye.style.width=`${be}px`,ie.appendChild(ue),b){const ke=document.createElement("span");ke.textContent=" / ",ie.appendChild(ke)}ie.appendChild(ye)}Q.appendChild(ie)}B.appendChild(Q)},me=S>80?Math.floor((S-80)*.6):void 0,Ae=B=>{const Z=B!=null&&B.width&&(B!=null&&B.height)?`${B.width} / ${B.height}`:"4 / 3",F=document.createElement("div");F.style.margin="12px 0",F.style.textAlign="center",F.style.width=`${z}px`;const Q=document.createElement("div");Q.style.position="relative",Q.style.width="100%",me&&(Q.style.maxHeight=`${me}px`),Q.style.aspectRatio=Z;const ee=document.createElement("div");if(ee.style.position="absolute",ee.style.inset="0",ee.style.width="100%",ee.style.height="100%",Q.appendChild(ee),F.appendChild(Q),B!=null&&B.alt){const J=document.createElement("div");J.style.fontSize="12px",J.style.color="#6B7280",J.style.marginTop="4px",J.textContent=String(B.alt),I(J),F.appendChild(J)}return F};for(let B=0;B<r.length;B++){Ye(c,w);const Z=r[B];if(A.dataset.block=String(B),A.innerHTML="",Z.kind==="image"){const ye=Z.block,ke=Ae(ye);A.appendChild(ke);const ze=ke.getBoundingClientRect(),{mt:Ee,mb:Ge}=Qn(ke);te[B]={contentH:Math.ceil(ze.height),mt:Ee,mb:Ge},await fe(24);continue}const F=Z.block,Q=F.list?(F.list.level??0)*24:0,ee=Z.paraIndex??0,J=f[ee]??(((p=F.list)==null?void 0:p.kind)==="bullet"?((h=F.list)==null?void 0:h.glyph)??"•":void 0);if(!!(F.list&&J)){const ye=ge(F,Q);ye.dataset.variant="with";const ke=ge(F,Q);ke.dataset.variant="no";const ze=document.createElement("span");ze.textContent=`${J} `,ze.style.minWidth="16px",ze.style.display="inline-block",ze.style.whiteSpace="nowrap",ze.style.userSelect="none",ye.appendChild(ze),ve(ye,F.runs),ve(ke,F.runs);const Ee=document.createDocumentFragment();Ee.appendChild(ye),Ee.appendChild(ke),A.appendChild(Ee)}else{const ye=ge(F,Q);ye.dataset.variant="with",ve(ye,F.runs),A.appendChild(ye)}const re=A.querySelector('p[data-variant="with"]'),be=A.querySelector('p[data-variant="no"]'),ue=be??re;if(re&&ue){const ye=Mo(re),ke=Mo(ue),{mt:ze,mb:Ee}=Qn(re),{mt:Ge,mb:ot}=Qn(ue),We=((C=F.runs)==null?void 0:C.length)??0,je=be?ke:ye,et=be?Ge:ze,Qe=be?ot:Ee;if(B<3){const ut=re.getBoundingClientRect().height;console.log(`[calcPages] para ${B}: height=${ut.toFixed(2)}, lastBottom=[${ye.slice(-3).map(zt=>zt.toFixed(1)).join(",")}], runs=${We}`)}$.set(B,{runsLen:We,lastBottomWith:ye,lastBottomNo:je,mtWith:ze,mbWith:Ee,mtNo:et,mbNo:Qe})}await fe(24)}Ye(c,w),A.innerHTML="";const K=(B,Z,F,Q)=>{if(Z>F)return{top:0,content:0,mb:0};const ee=Q?B.lastBottomNo:B.lastBottomWith,J=Q?B.mtNo:B.mtWith,ie=Q?B.mbNo:B.mbWith,re=Q?0:J,be=Z>0?ee[Z-1]??0:0,ue=Math.max(0,(ee[F]??0)-be);return{top:re,content:ue,mb:ie}},W=[];let L=0,j,G=null,V=null;for(;L<r.length;){Ye(c,w);const B=L;let Z=0,F=0,Q=j;Q!=null&&G===L&&V!=null&&(Q=Math.max(Q,V+1));let ee=-1,J;for(;L<r.length;){if(Ye(c,w),r[L].kind==="image"){const je=te[L]??{contentH:0,mt:0,mb:0},Qe=(Z===0?je.mt:F+je.mt)+je.contentH;if(k(Qe,Z)){Z+=Qe,ee=L,J=void 0,F=je.mb,L+=1,j=void 0,G=null,V=null;continue}if(Z===0){W.push({startBlock:B,endBlock:L,...Q!=null?{startOffsetInBlock:Q}:{}}),L+=1,j=void 0,G=null,V=null,F=0;break}break}const re=$.get(L),be=re.runsLen,ue=L===B&&Q!=null?Q:0;if(ue>=be){L+=1,j=void 0,G=null,V=null;continue}const ye=ue>0,ke=K(re,ue,be-1,ye),Ee=(Z===0?ke.top:F+ke.top)+ke.content;if(k(Ee,Z)){Z+=Ee,ee=L,J=be-1,F=ke.mb,L+=1,j=void 0,G=null,V=null;continue}let Ge=ue,ot=be-1,We=ue-1;for(;Ge<=ot;){Ye(c,w);const je=Ge+ot>>1,et=K(re,ue,je,ye),Qe=(Z===0?et.top:F+et.top)+et.content;k(Qe,Z)?(We=je,Ge=je+1):ot=je-1}if(We>=ue){W.push({startBlock:B,endBlock:L,...Q!=null?{startOffsetInBlock:Q}:{},endOffsetInBlock:We}),j=We+1,G=L,V=We,F=0;break}if(Z>0){W.push({startBlock:B,endBlock:ee>=0?ee:Math.min(L-1,r.length-1),...Q!=null?{startOffsetInBlock:Q}:{},...J!=null?{endOffsetInBlock:J}:{}}),F=0;break}else{const je=ue;W.push({startBlock:B,endBlock:L,...Q!=null?{startOffsetInBlock:Q}:{},endOffsetInBlock:je}),j=je+1,G=L,V=je,F=0;break}}(W.length===0||W[W.length-1].startBlock!==B)&&W.push({startBlock:B,endBlock:ee>=0?ee:Math.min(L-1,r.length-1),...Q!=null?{startOffsetInBlock:Q}:{},...J!=null?{endOffsetInBlock:J}:{}})}return N.remove(),T&&(t.style.transform="",t.style.transformOrigin=""),Ye(c,w),{pages:W,pageByRunIndex:null}}catch(T){throw console.error(T),T}}function Eo(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 Ou(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,b=l-1;u===i.startBlock&&i.startOffsetInBlock!=null&&(d=Math.max(0,Math.min(i.startOffsetInBlock,b))),u===i.endBlock&&i.endOffsetInBlock!=null&&(b=Math.max(d,Math.min(i.endOffsetInBlock,b)));const f=r[a.originalIndex]??0,m=f+d,S=f+b;if(e>=m&&e<=S)return s}}return-1}function zu(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,r;const t=e;return t?((n=t.style)==null?void 0:n.cursor)==="grab"||((r=t.closest)==null?void 0:r.call(t,"[data-range-handle]"))!=null:!1}function Au(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 Bu(){var Tr;const e=g.useId(),t=q(U=>U.section),n=q(U=>U.sectionLoading),r=pt(),o=g.useRef(!1);g.useEffect(()=>r.subscribe(U=>{o.current=U.progress.rangeStartGI!=null&&U.progress.rangeEndGI!=null}),[r]);const s=o.current,i=ht(),u=X(U=>U.theme),a=sn[u],l=X(U=>U.fontFamily),d=X(U=>U.fontSizePx),b=X(U=>U.lineHeight),f=X(U=>U.marginX),m=X(U=>U.viewportHeight),S=860,w=g.useRef(null),{items:c}=g.useMemo(()=>{var U;return Au(((U=t==null?void 0:t.ast)==null?void 0:U.blocks)??[])},[t]),p=g.useMemo(()=>{const U=[],Oe=wr();return c.forEach(Be=>{if(Be.kind==="paragraph"){const vt=Be.paraIndex;U[vt]=Cr(Be.block,Oe)}}),U},[c]),[h,C]=g.useState({pages:[],pageByRunIndex:null}),T=q(U=>U.pageIndex),_=q(U=>U.setPageIndex),O=g.useRef(0),v=g.useRef(null),[y,R]=g.useState(!1),[k,E]=g.useState(null),[P,I]=g.useState(!1),M=g.useMemo(()=>({flex:1,fontFamily:l,background:a.bg,color:a.fg,fontSize:d,lineHeight:b,overflow:"hidden",width:"100%",height:"100%",position:"relative",boxSizing:"border-box",WebkitTextSizeAdjust:"none",MozTextSizeAdjust:"none",textSizeAdjust:"none"}),[l,a.bg,a.fg,d,b]),{showSplit:z,breakGapPx:N,slash:A}=X(Vt(U=>{var Oe;return{showSplit:U.showSplit,breakGapPx:U.breakGapPx??0,slash:((Oe=U.breakMarks)==null?void 0:Oe.slash)??!1}})),$=pt();g.useEffect(()=>{h&&h.pages.length&&(console.log("그래서 총 페이지",h.pages.length),$.getState().progress.setTotalPages(h.pages.length+1),(async()=>{const U=$.getState().progress.setSectionLoading;await ft(),await ft(),await ft(),await ft(),console.log("recalc종료"),U(!1)})())},[h,$]);const te=g.useCallback(()=>{console.log("@@@@@@recalc호출");const U=w.current,Oe=re.current,Be=be.current;if(console.log("showSplit",z),!U||!Oe||!Be||c.length===0){C({pages:[],pageByRunIndex:null}),_(0),$.getState().progress.setTotalPages(0);return}(async()=>{const vt=performance.now();try{const tt=i.getState().playbackScale,{pages:Tt,pageByRunIndex:zs}=await ju({viewHost:U,measureRoot:Oe,contentArea:Be,items:c,cfgMaxWidth:S,marginX:f,fontFamily:l,fontSizePx:d,lineHeight:b,showSplit:z,breakGapPx:N,showSlash:A,paragraphMarkers:p,playbackScale:tt,viewportHeight:m,instanceId:e}),Ps=performance.now();console.log(`✅ calcPages 완료: ${(Ps-vt).toFixed(1)} ms (${Tt.length} pages)`),C({pages:Tt,pageByRunIndex:zs}),_(0)}catch(tt){if(tt instanceof js){console.log("이젠실행 취소 들어옴!");return}console.log("에러발생",tt)}})()},[_,c,S,f,l,d,b,z,N,A,p,i,m,e]),fe=q(U=>U.setCurrentGlobalRunIndex),ge=q(U=>{var Oe;return((Oe=U.layout)==null?void 0:Oe.prefix)??[]}),ve=Ce(U=>U.syncToGI),me=g.useCallback(U=>{const Oe=h.pages.length+1,Be=T+U;if(Be<0||Be>=Oe)return;const vt=T===h.pages.length;if(Be===h.pages.length){_(Be);return}if(vt&&U===-1){const Tt=Eo(h.pages[Be],c,ge);Tt!=null&&(fe(Tt,"scrubber-step"),ve(Tt)),_(Be);return}const tt=Eo(h.pages[Be],c,ge);tt!=null?(fe(tt,"scrubber-step"),ve(tt)):_(Be)},[T,h.pages,c,ge,fe,_,ve]),Ae=g.useCallback(()=>{y||O.current!==0?(E("prev"),R(!1)):me(-1)},[y,me]),K=g.useCallback(()=>{y||O.current!==0?(E("next"),R(!1)):me(1)},[y,me]),W=hn(),L=g.useCallback(()=>{const{isSettingsOpen:U,setSettingsOpen:Oe,toggleOverlays:Be}=W.getState();U?Oe(!1):Be()},[W]),j=h.pages.length+1,G=((Tr=w.current)==null?void 0:Tr.clientWidth)||400,V=g.useCallback(U=>{var tt;const Oe=v.current;if(!Oe)return;const Be=((tt=w.current)==null?void 0:tt.clientWidth)||1,vt=U/Be*33.333;Oe.style.transform=`translate3d(${-33.333+vt}%, 0, 0)`},[]),B=g.useCallback(U=>{T===0&&U>0||T>=j-1&&U<0||(O.current=U,V(U),y||R(!0))},[T,j,V,y]),Z=g.useCallback(()=>{O.current=0,R(!1);const U=v.current;U&&(U.style.transition="transform 250ms ease-out",U.style.transform="translate3d(-33.333%, 0, 0)")},[]),F=g.useCallback(U=>{if(U.target!==U.currentTarget||U.propertyName!=="transform")return;const Oe=k;I(!0),E(null),O.current=0,Oe==="prev"?me(-1):Oe==="next"&&me(1)},[k,me]);g.useLayoutEffect(()=>{P&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{I(!1)})})},[P]);const Q=cn(),ee=g.useCallback(U=>s||Pu(U)?!0:zu(U),[s]),J=g.useCallback(U=>Q.getState().status==="playing"?!0:ee(U),[Q,ee]),ie=fu({onPrev:Ae,onNext:K,onSingle:L,onDouble:()=>{},shouldIgnoreTarget:ee,shouldIgnoreSwipe:J,horizontalThreshold:120,velocityThreshold:.6,singleDelayMs:250,doubleClickWindowMs:300,onDragMove:B,onDragEnd:Z,pageTransitionThreshold:G*.5}),re=g.useRef(null),be=g.useRef(null),ue=g.useCallback(()=>{const U=$.getState().progress.setSectionLoading;U(!0)},[$]),ye=g.useMemo(()=>({trailing:!0,leading:!1,maxWait:1e3}),[]),ke=ku(te,200,ue,ye),ze=g.useRef("");g.useEffect(()=>{if(m<=0)return;const U=`${l}|${d}|${b}|${f}|${z}|${N}|${A}|${m}|${t==null?void 0:t.section_id}`;ze.current!==U&&(ze.current=U,console.log("debounceRecalc 취소"),ke.cancel(),ue(),te())},[ke,te,ue,l,d,b,f,z,N,A,m,t==null?void 0:t.section_id]),du([w],ke);const Ee=q(U=>U.registerSectionScrollApi);g.useEffect(()=>(Ee({ensureVisibleGI:()=>Promise.resolve(!0),scrollToGI:()=>Promise.resolve(!0),getVisibleRange:()=>null,getScrollTop:()=>0,setScrollTop:()=>{},getAnchorOffsetRatio:()=>0,scrollToGIAtOffset:()=>Promise.resolve(),stepPage:me}),()=>Ee(void 0)),[Ee,me]);const Ge=t.quizzes&&t.quizzes.length>0,ot=h.pages.length>0&&T===h.pages.length,We=T>0?T-1:null,je=T<j-1?T+1:null,et=g.useMemo(()=>k==="prev"?"translate3d(0%, 0, 0)":k==="next"?"translate3d(-66.666%, 0, 0)":"translate3d(-33.333%, 0, 0)",[k]),Qe=U=>n?null:U===h.pages.length?x.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,width:"100%",height:"100%"},children:[Ge&&x.jsx(ws,{}),x.jsx(pn,{isIcon:!1})]}):x.jsx(uu,{pages:h.pages,pageIndex:U,maxWidth:S}),ut={width:"33.333%",height:"100%",flexShrink:0,display:"flex",alignItems:"stretch",justifyContent:"center",overflow:"hidden",boxSizing:"border-box",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},zt=!P&&(!y||k!==null);return console.log("여기리랜더"),x.jsxs("div",{ref:w,style:{...M,touchAction:"none"},...ie,children:[x.jsxs("div",{ref:v,style:{display:"flex",width:"300%",height:"100%",transform:et,transition:zt?"transform 250ms ease-out":"none",willChange:"transform",boxSizing:"border-box",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},onTransitionEnd:k?F:void 0,children:[x.jsx("div",{style:ut,children:We!==null&&Qe(We)}),x.jsx("div",{style:ut,children:Qe(T)}),x.jsx("div",{style:ut,children:je!==null&&Qe(je)})]}),x.jsx("div",{ref:re,"aria-hidden":!0,style:{position:"absolute",contain:"layout style paint",left:-999999,top:-999999,zIndex:-999999,opacity:0,width:"100%",maxWidth:S,height:"100%",minHeight:0,boxSizing:"border-box",overflow:"hidden",fontFamily:l,fontSize:d,lineHeight:b,pointerEvents:"none",background:"pink"},children:x.jsxs("div",{style:{width:"100%",maxWidth:S,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:be,style:{height:"calc(100% - 110px)",overflow:"hidden",boxSizing:"border-box",width:"100%"}})]})}),x.jsx(Lu,{pages:h.pages,items:c,onGotoPage:_,currentPageIndex:T,isOnExtraPage:ot})]})}const Lu=({pages:e,items:t,onGotoPage:n,currentPageIndex:r,isOnExtraPage:o})=>{const s=q(l=>l.currentGlobalRunIndex),i=q(l=>l.lastUpdateBy),u=q(l=>{var d;return((d=l.layout)==null?void 0:d.prefix)??[]}),a=g.useRef(null);return g.useEffect(()=>{if(s==null||e.length===0||o&&!(i==="scrubber-live"||i==="scrubber-commit")||a.current===s)return;a.current=s;const l=Ou(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",jo={wrapper:Gu,spinner:Hu};function Nu({size:e=28,speed:t=.8}){return x.jsx("div",{className:`${jo.wrapper}`,children:x.jsx("div",{className:jo.spinner,style:{width:e,height:e,borderWidth:3,animationDuration:`${t}s`}})})}function Fu(){const e=q(Vt(t=>t.sectionLoading===!0));return x.jsx(x.Fragment,{children:e===!0&&x.jsx(Nu,{})})}const Du="_Overlay_ybic8_3",Wu="_Dialog_ybic8_15",$u="_Body_ybic8_25",Vu="_Header_ybic8_32",qu="_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",ae={Overlay:Du,Dialog:Wu,Body:$u,Header:Vu,Paging:qu,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 Os(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=g.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),b=Ue(c=>c.perQ),f=ys();g.useEffect(()=>{if(t==="idle"||t!=="doing"||u==null)return;const c=window.setInterval(()=>f.getState().tick(),1e3);return()=>window.clearInterval(c)},[t,u,f]);const m=t==="doing"?n[r[o]]:void 0,S=t==="doing"&&m?s[m.qid]??[]:[],w=g.useMemo(()=>{if(t==="idle"||t!=="finished")return;const c=r.map(A=>n[A]),p=c.length,h=c.reduce((A,$)=>A+($.score??0),0),C=c.reduce((A,$)=>{const te=b[$.qid];return A+(te!=null&&te.isCorrect?$.score??0:0)},0),T=c.map(A=>b[A.qid]).filter(A=>!!A),_=typeof l=="number"&&typeof d=="number"?Math.max(0,d-l):T.reduce((A,$)=>A+($.ms??0),0),O=p>0?Math.round(_/p):0,v=[...T].sort((A,$)=>A.ms-$.ms),y=v[0],R=v[v.length-1],k=T.filter(A=>!A.multi),E=T.filter(A=>A.multi),P=k.filter(A=>A.isCorrect).length,I=E.filter(A=>A.isCorrect).length,M=T.filter(A=>A.timedOut).length,z=T.filter(A=>A.revealed).length,N=T.filter(A=>!A.isCorrect).sort((A,$)=>$.ms-A.ms).slice(0,3);return{total:p,correct:i,rate:p?Math.round(i/p*100):0,timeMsTotal:_,avgMs:O,totalScore:h,gainedScore:C,fastest:y,slowest:R,singles:{total:k.length,correct:P},multis:{total:E.length,correct:I},timedOut:M,revealed:z,wrongTop3:N}},[t,r,n,b,l,d,i]);return t==="idle"?null:x.jsx("div",{className:ae.Overlay,role:"dialog","aria-modal":"true",children:x.jsx("div",{className:ae.Dialog,children:t==="doing"&&m?x.jsx(vd,{q:m,index:o,total:r.length,selected:S,uiReveal:a,onSelect:c=>{if(a)return;const p=f.getState();Os(m)?p.selectToggle(c):p.selectSingle(c)},onBeforeNext:()=>f.getState().setReveal(!0),onNext:()=>f.getState().afterRevealNext(),remainingSec:u,onClose:()=>f.getState().close()}):x.jsx(Sd,{total:r.length,correct:i,summary:w,retryAllowed:f.getState().retryAllowed,onClose:()=>f.getState().close(),onRetry:()=>{const p=f.getState().quizzes;if(!p.length)return;const h=p[0];f.setState({phase:"doing",currentIndex:0,answers:{},correctCount:0,startedAt:Date.now(),finishedAt:void 0,questionStartedAt:Date.now(),remainingSec:h.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,b=Os(t),f=g.useMemo(()=>{const c=t.options.map((p,h)=>({opt:p,i:h}));for(let p=c.length-1;p>0;p--){const h=Math.floor(Math.random()*(p+1));[c[p],c[h]]=[c[h],c[p]]}return c},[t.options]),m=g.useMemo(()=>md(t),[t]),S=g.useMemo(()=>bd(t),[t]),w=g.useMemo(()=>{const c=[...o].sort((p,h)=>p-h);if(c.length!==S.length)return!1;for(let p=0;p<c.length;p++)if(c[p]!==S[p])return!1;return!0},[o,S]);return x.jsxs("div",{className:ae.Body,children:[x.jsxs("div",{className:ae.Header,children:[x.jsx("div",{className:ae.Paging,children:`Quiz (${n+1}/${r})`}),x.jsx("button",{type:"button",onClick:d,className:ae.CloseBtn,children:"X"})]}),x.jsx("div",{className:ae.Question,children:t.question}),x.jsx("div",{className:ae.Score,children:` (${t.score}점${b?" ,모두선택":""})`}),x.jsx("div",{className:`${ae.Judge}${s?w?` ${ae.Correct}`:` ${ae.Incorrect}`:""}`,"aria-live":"polite",children:s?w?`Correct : +${t.score} point`:"Incorrect : 0 point":"a"}),x.jsx("div",{className:ae.Image,children:m&&x.jsx("img",{src:m,alt:""})}),x.jsx("div",{className:ae.Options,children:f.map(({opt:c,i:p})=>{const h=o.includes(p),C=S.includes(p),T=[ae.OptionBtn,h?ae.OptionBtnActive:"",s&&C?ae.OptionBtnCorrect:""].filter(Boolean).join(" ");return x.jsx("button",{type:"button",onClick:()=>i(p),className:T,disabled:s,children:c},p)})}),x.jsx("div",{className:ae.Footer,children:s?x.jsx("button",{type:"button",onClick:a,className:ae.NextBtn,children:n+1>=r?"Complete":"Next Quiz"}):x.jsxs("button",{type:"button",onClick:u,className:`${ae.NextBtn}`,children:["Submit",typeof l=="number"&&x.jsx("span",{className:`${ae.Remaining} ${l<=5?ae.RemainingDanger:""}`,children:` (${l} s )`})]})})]})}function Oo(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:ae.Body,children:[x.jsx("div",{className:ae.ResultHeader,children:"결과 요약"}),x.jsxs("div",{className:ae.SummaryGrid,role:"list",children:[x.jsxs("div",{className:ae.StatCard,role:"listitem",children:[x.jsx("div",{className:ae.StatLabel,children:"정답률"}),x.jsxs("div",{className:ae.StatValue,children:[u,"%"]}),x.jsx("div",{className:ae.StatSub,children:`정답수 ${n}/문제수${t}`})]}),x.jsxs("div",{className:ae.StatCard,role:"listitem",children:[x.jsx("div",{className:ae.StatLabel,children:"총 점수"}),x.jsx("div",{className:ae.StatValue,children:r?`${r.gainedScore}/${r.totalScore}`:"-"}),x.jsx("div",{className:ae.StatSub,children:"획득점수/최대점수"})]}),x.jsxs("div",{className:ae.StatCard,role:"listitem",children:[x.jsx("div",{className:ae.StatLabel,children:"총 소요 시간"}),x.jsx("div",{className:ae.StatValue,children:Oo(r==null?void 0:r.timeMsTotal)}),x.jsx("div",{className:ae.StatSub,children:`평균 ${Oo(r==null?void 0:r.avgMs)}`})]}),x.jsxs("div",{className:ae.StatCard,role:"listitem",children:[x.jsx("div",{className:ae.StatLabel,children:"타입오버 퀴즈수"}),x.jsx("div",{className:ae.StatValue,children:r?`${r.timedOut}`:"-"}),x.jsx("div",{className:ae.StatSub,children:"timeout"})]})]}),x.jsxs("div",{className:ae.ResultActions,children:[o&&x.jsx("button",{type:"button",onClick:i,className:ae.CloseBtnSoft,children:"다시 풀기"}),x.jsx("button",{type:"button",onClick:s,className:ae.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 Yn(e){var t;return(((t=e.answers)==null?void 0:t.length)??0)>1}function Zn(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 zo(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=zo(e);return qt()((u,a)=>({...o,...s,hydrateFromSection:l=>{if(!l)return;const d=zo(l);u(d)},openFromSection:l=>{l&&a().hydrateFromSection(l);const d=a();if(!d.quizzes.length)return;if(!d.retryAllowed&&d.previousResult){const f={};for(const m of d.previousResult.perQuestion)f[m.qid]={qid:m.qid,index:m.index,question:m.question,score:m.score,multi:m.correctIdxes.length>1,selected:m.selected,correctIdxes:m.correctIdxes,isCorrect:m.isCorrect,ms:m.ms,revealed:!0,timedOut:m.timedOut};u({phase:"finished",correctCount:d.previousResult.correct,perQ:f,startedAt:void 0,finishedAt:void 0});return}const b=d.quizzes[0];u({phase:"doing",startedAt:Date.now(),finishedAt:void 0,questionStartedAt:Date.now(),remainingSec:b.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 f=d.quizzes[d.order[d.currentIndex]].qid,m=d.answers[f]??[],S=m.includes(l)?m.filter(w=>w!==l):[...m,l].sort((w,c)=>w-c);u({answers:{...d.answers,[f]:S}})},selectSingle:l=>{const d=a();if(d.phase!=="doing"||d.uiReveal)return;const f=d.quizzes[d.order[d.currentIndex]].qid;u({answers:{...d.answers,[f]:[l]}})},submitCurrent:()=>{const l=a();if(l.phase!=="doing")return;const d=l.order[l.currentIndex],b=l.quizzes[d],f=b.qid,m=(l.answers[f]??[]).slice().sort((C,T)=>C-T),S=Zn(b),w=wd(m,S),c=l.questionStartedAt?Date.now()-l.questionStartedAt:0,p=l.perQ[f],h={qid:f,index:b.index,question:b.question,score:b.score??0,multi:Yn(b),selected:m,correctIdxes:S,isCorrect:w,ms:c,revealed:(p==null?void 0:p.revealed)??!1,timedOut:(p==null?void 0:p.timedOut)??!1};if(u({correctCount:l.correctCount+(w?1:0),perQ:{...l.perQ,[f]:h}}),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 b=d.quizzes[d.order[d.currentIndex]],f=b.qid,m=d.perQ[f],S={qid:f,index:b.index,question:b.question,score:b.score??0,multi:Yn(b),selected:(m==null?void 0:m.selected)??[],correctIdxes:(m==null?void 0:m.correctIdxes)??Zn(b),isCorrect:(m==null?void 0:m.isCorrect)??!1,ms:(m==null?void 0:m.ms)??0,revealed:!0,timedOut:(m==null?void 0:m.timedOut)??!1};u({perQ:{...d.perQ,[f]:S}})}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 b=l.quizzes[l.order[l.currentIndex]],f=b.qid,m=l.perQ[f],S={qid:f,index:b.index,question:b.question,score:b.score??0,multi:Yn(b),selected:(m==null?void 0:m.selected)??[],correctIdxes:(m==null?void 0:m.correctIdxes)??Zn(b),isCorrect:(m==null?void 0:m.isCorrect)??!1,ms:(m==null?void 0:m.ms)??0,revealed:!0,timedOut:!0};u({remainingSec:0,uiReveal:!0,perQ:{...l.perQ,[f]:S}})}else u({remainingSec:d})}}))}function Id({children:e,initialState:t}){const n=g.useMemo(()=>Cd(t.section,{retryAllowed:t.quizRetryAllowed??!0,previousResult:t.previousQuizResult??null}),[t]),r=g.useRef(t.onQuizStart),o=g.useRef(t.onQuizComplete);return g.useEffect(()=>{r.current=t.onQuizStart},[t.onQuizStart]),g.useEffect(()=>{o.current=t.onQuizComplete},[t.onQuizComplete]),g.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:b,order:f,perQ:m,startedAt:S,finishedAt:w}=i,c=f.map(y=>b[y]),p=c.length,h=c.filter(y=>{var R;return(R=m[y.qid])==null?void 0:R.isCorrect}).length,C=c.reduce((y,R)=>y+(R.score??0),0),T=c.reduce((y,R)=>{const k=m[R.qid];return y+(k!=null&&k.isCorrect?R.score??0:0)},0),_=typeof S=="number"&&typeof w=="number"?Math.max(0,w-S):0,O=c.map(y=>{const R=m[y.qid];return{qid:y.qid,index:y.index,question:y.question,score:y.score??0,isCorrect:(R==null?void 0:R.isCorrect)??!1,selected:(R==null?void 0:R.selected)??[],correctIdxes:(R==null?void 0:R.correctIdxes)??[],ms:(R==null?void 0:R.ms)??0,timedOut:(R==null?void 0:R.timedOut)??!1}}),v={sectionId:d??"",total:p,correct:h,rate:p>0?Math.round(h/p*100):0,totalScore:C,gainedScore:T,timeMsTotal:_,perQuestion:O};l(v)}});return()=>s()},[n]),x.jsx(Ir.Provider,{value:n,children:e})}const Po=["mode","theme","fontFamily","fontSizePx","lineHeight","marginX","marginY","pointerStyle","pointerColor","breakMarks","breakGapPx","muteAudio","audioSpeed","showPointer","showSplit","showOverlays","overlayCompactMode","isSettingsOpen"];function Td({containerRef:e}){const t=ht(),n=hn(),r=g.useRef(null);return g.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]),g.useEffect(()=>{const o=n.getState();r.current={};for(const i of Po)r.current[i]=o[i];const s=n.subscribe(i=>{const u=r.current;if(u)for(const a of Po){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=ht(),t=hn(),n=pt(),r=g.useContext(Lo),o=g.useContext(Sn),s=g.useCallback(a=>{const{viewerState:l}=a;if(l){l.mode&&t.getState().setMode(l.mode);const{...f}=l;t.setState(f)}if(typeof a.globalIndex=="number"&&n.getState().progress.setCurrentGlobalRunIndex(a.globalIndex,"playback"),(l==null?void 0:l.mode)==="scroll"||!(l!=null&&l.mode)){const f=()=>{const m=n.getState().progress.getSectionScrollApi();if(!m)return!1;if(a.scrollY===0)m.setScrollTop(0);else if(m.scrollToGIAtOffset){const S=a.anchorGI??a.globalIndex;if(typeof S=="number"){const w=a.anchorOffsetRatio??0;m.scrollToGIAtOffset(S,w)}}return!0};if(!f()){let m=0;const S=setInterval(()=>{(f()||++m>=10)&&clearInterval(S)},50)}}a.audio&&o&&o.getState()._setStatusOnly(a.audio.status);const b=n.getState().progress;a.range?b.setRange(a.range.startGI,a.range.endGI):b.clearRange(),a.translate&&a.translate.isOpen?b.setTranslateState({isOpen:!0,isLoading:a.translate.isLoading,text:a.translate.text,translatedText:a.translate.translatedText,startGI:a.translate.startGI,endGI:a.translate.endGI}):b.clearTranslate()},[t,n,o]),i=g.useCallback(()=>{var _,O,v,y;const a=t.getState(),l=n.getState().progress,d=(_=l.getSectionScrollApi)==null?void 0:_.call(l),b=l.currentGlobalRunIndex??0,f=((O=d==null?void 0:d.getScrollTop)==null?void 0:O.call(d))??0,m=((v=d==null?void 0:d.getAnchorOffsetRatio)==null?void 0:v.call(d,b))??0,S=o==null?void 0:o.getState(),w=S?{status:S.status,currentClip:S.currentClip,currentTimeMs:S.currentTimeMs}:void 0,{rangeStartGI:c,rangeEndGI:p}=l,h=c!=null&&p!=null?{startGI:c,endGI:p,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:b,scrollY:f,scrollRatio:C,anchorGI:b,anchorOffsetRatio:m,currentPage:l.pageIndex??0,totalPages:l.totalPages,sectionId:l.sectionId??"",viewportWidth:a.viewportWidth,viewportHeight:a.viewportHeight,audio:w,range:h,translate:T}},[t,n,o]),u=g.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:b,anchorOffsetRatio:f}=a.payload,m=n.getState().progress.getSectionScrollApi();m&&(d===0?m.setScrollTop(0):m.scrollToGIAtOffset&&typeof b=="number"&&m.scrollToGIAtOffset(b,f));break}case"settings_change":{const{key:l,value:d}=a.payload,b=t.getState();l in b&&typeof b[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;console.log(`[DirectPlayback] ${a.type}: GI ${l}~${d}`),n.getState().progress.setRange(l,d);const b=n.getState().progress;console.log(`[DirectPlayback] after setRange: rangeStartGI=${b.rangeStartGI}, rangeEndGI=${b.rangeEndGI}`);break}case"range_clear":{console.log("[DirectPlayback] range_clear"),n.getState().progress.clearRange();break}case"translate_request":{const{text:l,startGI:d,endGI:b}=a.payload;n.getState().progress.setTranslateState({isOpen:!0,isLoading:!0,text:l,startGI:d,endGI:b});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 g.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(b=>{b.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]),g.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=ht();return g.useEffect(()=>{const d=e.current;if(!d)return;let b,f;return b=requestAnimationFrame(()=>{f=requestAnimationFrame(()=>{const m=Rd(d);l.setState({wordAvgDistancePx:m})})}),()=>{cancelAnimationFrame(b),cancelAnimationFrame(f)}},[e,l,t,n,r,o,s,i,u,a]),null}const Md=({containerRef:e,onTranslate:t})=>{const n=q(f=>f.rangeStartGI),r=q(f=>f.rangeEndGI),o=q(f=>f.getRangeText),s=q(f=>f.clearRange),i=ht(),u=n!=null&&r!=null,[a,l]=g.useState(null);g.useEffect(()=>{if(!u)return;const f=e.current;if(!f)return;let m=!0;const S=new ResizeObserver(()=>{if(m){m=!1;return}s()});return S.observe(f),()=>S.disconnect()},[u,s,e]),g.useEffect(()=>{if(!u||n==null||r==null){l(null);return}const f=()=>{const S=e.current;if(!S)return;const w=S.getBoundingClientRect(),p=1/(i.getState().playbackScale||1),h=S.querySelector(`[data-g="${r}"]`);if(!h){l({x:w.width*p/2,y:80});return}const C=h.getBoundingClientRect(),T=S.querySelector(`[data-g="${n}"]`),_=T==null?void 0:T.getBoundingClientRect();let O=(C.left+C.width/2-w.left)*p;_&&(O=((_.left+C.right)/2-w.left)*p);const v=160,y=50,R=16,k=12,E=w.width*p,P=Math.max(R+v/2,Math.min(O,E-R-v/2)),I=(((_==null?void 0:_.top)??C.top)-w.top)*p-y-k;let M=I;I<R&&(M=(C.bottom-w.top)*p+k),l({x:P,y:M})};f();const m=e.current;return m&&m.addEventListener("scroll",f,!0),()=>{m&&m.removeEventListener("scroll",f,!0)}},[u,n,r,e,i]);const d=g.useCallback(()=>{const f=o();f&&navigator.clipboard.writeText(f).catch(m=>{console.error("복사 실패:",m)}),s()},[o,s]),b=g.useCallback(()=>{const f=o();f&&t&&t(f)},[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:b,style:{padding:"8px 16px",backgroundColor:"#10b981",color:"#fff",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:"pointer",whiteSpace:"nowrap"},children:"번역"})]})};function Ed(){const e=q(o=>o.rangeStartGI),t=q(o=>o.rangeEndGI),n=q(o=>o.clearRange),r=e!=null&&t!=null;return g.useEffect(()=>{if(!r)return;const o=s=>{var u;if(xs())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),b=Math.max(e,t);if(l>=d&&l<=b)return}}n()}};return document.addEventListener("click",o,!0),()=>document.removeEventListener("click",o,!0)},[r,e,t,n]),null}const jd=({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,Od=(e,t,n)=>Math.min(n,Math.max(t,e));function zd({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:b,viewerRef:f,gazeSync:m,onRequestTranslate:S,isPlaybackMode:w=!1,playbackScale:c,isDev:p=!1}){const h=String((e==null?void 0:e.section_id)??"0"),C=g.useMemo(()=>{var R,k;const v=((R=e==null?void 0:e.ast)==null?void 0:R.blocks)??[];let y=0;for(const E of v)(E==null?void 0:E.type)!=="image"&&(y+=((k=E==null?void 0:E.runs)==null?void 0:k.length)??0);return y},[e]),T=g.useMemo(()=>typeof n=="number"?Od(n,C>0?0:-1,Math.max(C-1,-1)):(C>0,0),[n,C]),_=g.useMemo(()=>({section:e,initialIndex:T,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i}),[e,T,r,o,s,i]),O=g.useMemo(()=>{const v=(e==null?void 0:e.audios)??[],y=v.length>0?ru(e):void 0;return{clips:v,map:y,initialIndex:T,section:e}},[e,T]);return x.jsx(Xs,{onViewerEvent:b,isPlaybackMode:w,playbackScale:c,viewerRef:f,children:x.jsx(cu,{initialState:{...t,isDev:p},children:x.jsx(au,{initialState:_,gazeSync:m,children:x.jsx(nu,{initialState:O,children:x.jsx(Id,{initialState:{section:e,onQuizStart:u,onQuizComplete:a,quizRetryAllowed:l,previousQuizResult:d},children:x.jsx(Pd,{onRequestTranslate:S})},h)},h)},h)})})}function Pd({onRequestTranslate:e}){const t=X(S=>S.mode),n=g.useRef(null),r=ht(),o=pt(),s=q(S=>S.translateOpen),i=q(S=>S.translateLoading),u=q(S=>S.translateText),a=q(S=>S.translatedText),l=g.useRef(null),d=g.useCallback(S=>{var T;const{rangeStartGI:w,rangeEndGI:c}=o.getState().progress,p=w??0,h=c??0;if(r.getState().emit({type:"translate_request",payload:{text:S,startGI:p,endGI:h}}),!e){o.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,text:S,startGI:p,endGI:h});return}o.getState().progress.setTranslateState({isOpen:!0,isLoading:!0,text:S,startGI:p,endGI:h}),(T=l.current)==null||T.abort();const C=new AbortController;l.current=C,e(S,C.signal).then(_=>{if(!C.signal.aborted){if(_==null){o.getState().progress.clearTranslate();return}o.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,text:S,translatedText:_,startGI:p,endGI:h}),r.getState().emit({type:"translate_loading_end",payload:{originalText:S,translatedText:_}})}}).catch(_=>{if(C.signal.aborted)return;const O=_ instanceof Error?_.message:"번역 실패";o.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,text:S,translatedText:`[오류] ${O}`,startGI:p,endGI:h})})},[r,o,e]),b=g.useCallback(()=>{var S;(S=l.current)==null||S.abort(),l.current=null,o.getState().progress.clearTranslate(),r.getState().emit({type:"translate_modal_close",payload:{}})},[r,o]),f=S=>{S.preventDefault()},m=S=>{S.preventDefault()};return x.jsxs("div",{ref:n,onContextMenu:f,onDragStart:m,style:{position:"relative",display:"flex",flexDirection:"column",height:"100%",width:"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(kl,{containerRef:n}),x.jsx(Xc,{}),x.jsx(xd,{}),x.jsx(Fu,{}),x.jsx(Ed,{}),x.jsx(jd,{isOpen:s,isLoading:i,onClose:b,text:u,translatedText:a}),x.jsx(Td,{containerRef:n}),x.jsx(kd,{}),x.jsx(_d,{containerRef:n})]})}exports.CRViewer=zd;