@inkeep/open-knowledge 0.89.0-beta.1 → 0.89.0-beta.2
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/{cli-P9c6G0-v.mjs → cli-9xdSCTSb.mjs} +6 -6
- package/dist/cli.mjs +1 -1
- package/dist/constants-DG1EJifS.mjs +1 -0
- package/dist/index.mjs +1 -1
- package/dist/init-C5sSKM8F.mjs +1 -0
- package/dist/{init-BKy6mFjl.mjs → init-DP85bzQ5.mjs} +2 -2
- package/dist/{launch-json-removal-DKEbwqzo.mjs → launch-json-removal-BK5k3sb3.mjs} +1 -1
- package/dist/{loader-DPIGx1ya.mjs → loader-B-RuvoXR.mjs} +1 -1
- package/dist/loader-DftmKkrz.mjs +1 -0
- package/dist/{preview-C62sWCRc.mjs → preview-BHPAYimN.mjs} +1 -1
- package/dist/preview-BNkBvohW.mjs +1 -0
- package/dist/public/assets/{AccountSection-Dh99b_3y.js → AccountSection-m8CEf7-e.js} +1 -1
- package/dist/public/assets/{ActivityModeContent-CLfAAqpN.js → ActivityModeContent-DJWp7jRT.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-DYJoiTOl.js → AddPropertiesButton-BoMWGIJY.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-CITyKdMG.js → AgentDiffPane-CGjzn56w.js} +1 -1
- package/dist/public/assets/{AttachmentsSection-BxGKuNDx.js → AttachmentsSection-mWok6RVA.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-BbFqZgDv.js → CodeMirrorPropInput-DmgOqRyj.js} +1 -1
- package/dist/public/assets/{ContentRulesSection-CRJtYFP5.js → ContentRulesSection-BIfxu070.js} +1 -1
- package/dist/public/assets/{DocumentContext-yhK84CI8.js → DocumentContext-B3icnNZf.js} +3 -3
- package/dist/public/assets/{EditorModeToggle-11QOfkMf.js → EditorModeToggle-CT8PCz8M.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-BGyV616J.js → ExcalidrawDocEditor-ZYttdLyr.js} +1 -1
- package/dist/public/assets/FeedbackForm-CVGJkKqY.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-CXgMFMJi.js → ImportSkillDialog-CGyqtjC9.js} +1 -1
- package/dist/public/assets/{LinkPreviewsSection-B0FMrH2Y.js → LinkPreviewsSection-BaM9jJDF.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-DKp2163g.js → LintConfigEditor-Bl2sU0eJ.js} +1 -1
- package/dist/public/assets/{LintingSection-BnWlNb3b.js → LintingSection-DkKZo8Ml.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-BV0hsYxA.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-B3B_6MMR.js → ManagedArtifactProperties-DpeWgW_L.js} +1 -1
- package/dist/public/assets/Mermaid-Cd21uwyp.js +2 -0
- package/dist/public/assets/{MermaidDocEditor-DEHoyfnu.js → MermaidDocEditor-BdqMwpRP.js} +1 -1
- package/dist/public/assets/{NetworkAccessSection-DbyHJ9hU.js → NetworkAccessSection-DiaaB1uz.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-BwCzkS80.js → PropertyDisplayRow-f4wVzwUi.js} +1 -1
- package/dist/public/assets/{PublishToGitHubDialog-BG6U2PVl.js → PublishToGitHubDialog-CP5fRx4u.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-CkaPNVA1.js → SchemaConfigEditor-DBogrxxU.js} +1 -1
- package/dist/public/assets/{SearchSection-DtgOWb6D.js → SearchSection-VSlU_jzG.js} +1 -1
- package/dist/public/assets/{SessionsHost-CTkdUlem.js → SessionsHost-CW-oSS4M.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-BqSQgcXi.js → SettingsDialogBody-CnK91yPS.js} +2 -2
- package/dist/public/assets/{ShareReceiveMissDialog-BOavbl1H.js → ShareReceiveMissDialog-DkyVH0pF.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-CwUdOHpY.js → SkillToolbarControls-DT2pVk0T.js} +1 -1
- package/dist/public/assets/{SourceEditor-KsoNtK2L.js → SourceEditor-WqhYXfi9.js} +1 -1
- package/dist/public/assets/{SyncSection-DR3EuRpu.js → SyncSection-8Eg2YM85.js} +1 -1
- package/dist/public/assets/{SyncStatusBadge-C5gTjEQN.js → SyncStatusBadge-SFNb7FXr.js} +1 -1
- package/dist/public/assets/{TerminalSection-BYoE28HW.js → TerminalSection-Fy6h7y4y.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-CvfbGB1j.js → TerminalWindowApp-K8uM6Nln.js} +1 -1
- package/dist/public/assets/{TextDocEditor-C_q-562q.js → TextDocEditor-CxchPp0Z.js} +1 -1
- package/dist/public/assets/{ThreadView-D_JQKUzf.js → ThreadView-CRWaHK3J.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-Be66K4r4.js → TimelineDiffPane-SP3NSYEm.js} +1 -1
- package/dist/public/assets/{client-version-Cpzxcxbo.js → client-version-oNpBBa2-.js} +1 -1
- package/dist/public/assets/{comment-chips-1rhDEPpS.js → comment-chips-Bjtopm02.js} +1 -1
- package/dist/public/assets/{config-provider-DxsAQmo4.js → config-provider-Cz-fhuIV.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-DoJkueXb.js → doc-undo-manager-DZuKdi_A.js} +1 -1
- package/dist/public/assets/index-13mtfH3x.js +2209 -0
- package/dist/public/assets/{lint-plugins-n7hZE41X.js → lint-plugins-D05RHjlF.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-xyPeVIJw.js → pending-receive-nav-store-D2QP8NbX.js} +1 -1
- package/dist/public/assets/{preferred-session-events-DnHerlUY.js → preferred-session-events-DB1OQTuk.js} +1 -1
- package/dist/public/assets/{progress-LxZ6VrbK.js → progress-DmYAlc8u.js} +1 -1
- package/dist/public/assets/{selection-context-B_MHPw6m.js → selection-context-Cm0zqlLU.js} +1 -1
- package/dist/public/assets/{src-C1ewNJ-m.js → src-CHh6DJav.js} +1 -1
- package/dist/public/assets/{telemetry-impl-C0LrJOaC.js → telemetry-impl-1gAn-Ohc.js} +1 -1
- package/dist/public/assets/{telemetry-startup-CLVHyTvA.js → telemetry-startup-2XlPcBBU.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-CJ-l-YcD.js → typing-burst-detector-BTZj8ARy.js} +1 -1
- package/dist/public/assets/{use-activity-panel-B4Y5r6Db.js → use-activity-panel--8fl0sWa.js} +1 -1
- package/dist/public/assets/{use-open-skill-Bmjk1bzy.js → use-open-skill-CDxppHVl.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-GBMsws8-.js → use-terminal-enabled-B7Gcj06-.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-BtCu0OLC.js → use-timeline-entry-diff-DFDDt-0j.js} +1 -1
- package/dist/public/index.html +20 -20
- package/dist/{registry-probes-C3RVjpWq.mjs → registry-probes-vUpqMq-m.mjs} +1 -1
- package/dist/{removal-file-path-DdEiO6Fe.mjs → removal-file-path-eLkaK_F8.mjs} +1 -1
- package/dist/{repair-launch-json-cUTp_I1n.mjs → repair-launch-json-F4VqU9En.mjs} +1 -1
- package/dist/{repair-mcp-configs-C3B25E1j.mjs → repair-mcp-configs-DFV9JAFE.mjs} +1 -1
- package/dist/src-CkNl1OyQ.mjs +1 -0
- package/dist/{src-CW5scbBJ.mjs → src-DfIwcbUX.mjs} +1 -1
- package/dist/start-BXU6wYSz.mjs +1 -0
- package/dist/{start-CZtDlR7m.mjs → start-CMDTcy5c.mjs} +2 -2
- package/package.json +4 -4
- package/dist/constants-BOiMSG9R.mjs +0 -1
- package/dist/init-D-IwE-39.mjs +0 -1
- package/dist/loader-CwOmKcS2.mjs +0 -1
- package/dist/preview-Bgpivk2p.mjs +0 -1
- package/dist/public/assets/FeedbackForm-DuUw4T9Y.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-BxUMTVLN.js +0 -1
- package/dist/public/assets/Mermaid-DH1HLMlB.js +0 -2
- package/dist/public/assets/index-CMEh_Dza.js +0 -2209
- package/dist/src-B7NoNAcB.mjs +0 -1
- package/dist/start-DonGKuxP.mjs +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./prod-DmbEMjXJ.js","./chunk-CYidjpOJ.js","./preload-helper-Chd9yIcd.js","./chunk-RM4UPSZO-CjZQAhgy.js","./chunk-A66AFZZU-CKR5YIUT.js","./chunk-SRAX5OIU-BzI0JYKP.js","./chunk-7XWMRXBY-BEmTwJeS.js","./chunk-FLYJHZSQ-DkAvo7pg.js","./dist-DblniIbm.js","./mermaid.core-BxaEerew.js","./chunk-4I5QYGJK-5DqGPwMr.js","./src-D7_xh2nU.js","./src-CBDMUizI.js","./chunk-Y2CYZVJY-DmCZVwnS.js","./chunk-I66GZJ75-CvPiAcMx.js","./chunk-NSK5VX7P-BO-PX_XG.js","./dist-dnWuVjMs.js","./chunk-WRU74C26-Dg8EdA-9.js","./chunk-3NCLNEKW-Dl-JKDZ7.js","./chunk-7BUUIJ7U-OvIQx2CE.js","./chunk-7Z6QIM7H-3NnmPxCP.js","./line-CWwttAP8.js","./path-CAp-W8v3.js","./array-AMeIZ1qU.js","./chunk-QR6OTTB3-xnXkZwpW.js","./chunk-UBXNYLIW-rZJnY6Yr.js","./chunk-W5SLKNZC-Bo3xZwve.js","./rough.esm-BxdUufqV.js","./chunk-J7OUQ5F2-BR2Gk1s2.js","./chunk-ZIRB5QZD-D9EFIddH.js","./dist-BzicVdNV.js","./dist-DTFuvKje.js","./dist-CSCUSbQc.js","./react-f2sANaYj.js","./react-dom-DPxgxlDT.js","./jsx-runtime-BUgB2tll.js","./dist-d2WYntJB.js","./dist-DXjgFhPl2.js","./floating-ui.dom-BYl7JZd0.js","./dist-CRjqnzU7.js","./dist-uiDX6Nr9.js","./dist-CxbWbOvU.js","./es2015-Dtr4fzLT.js","./dist-BKgU0kag.js","./dist-C0nuYMFu.js","./dist-Cj3Bpren.js","./dist-wWBxplcG2.js","./with-selector-zVo3Fruj.js","./pdf-DO7qqKZs.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e,t}from"./chunk-CYidjpOJ.js";import{t as n}from"./preload-helper-Chd9yIcd.js";import{t as r}from"./jsx-runtime-BUgB2tll.js";import{t as i}from"./react-f2sANaYj.js";import{n as a,r as o}from"./dist-Nvb76hAm.js";import{n as s}from"./dist-PQ5KMVDh.js";import{t as c}from"./react-dom-DPxgxlDT.js";import{t as l}from"./compiler-runtime-BfE3aGVn.js";import{t as u}from"./react-error-boundary-6ac6QM6R.js";import{t as d}from"./utils-CPqDy6Hr.js";import{t as f}from"./kbd-Cg1nrB7U.js";import{i as p}from"./dist-CSCUSbQc.js";import{l as m,n as h}from"./dist-DTFuvKje.js";import{i as g,n as _,t as v}from"./tooltip-BjuCvy5N.js";import{n as y,r as b,t as x}from"./collapsible-BKbszYZV.js";import{c as S,i as C,o as w,s as T}from"./electron-drag-strip-D9GZhMg_.js";import{a as E,d as D,f as O,i as k,l as A,r as j}from"./floating-ui.dom-BYl7JZd0.js";import{i as M,n as N,o as P,s as F,t as I}from"./select-BsDvTs6I.js";import{t as L}from"./switch-BKZTXkzu.js";import{t as ee}from"./button-DzgjsZzC.js";import{_ as R,d as te,f as ne,h as re,m as ie,o as ae,p as oe,u as se}from"./constants-upload-DZP-sCdl.js";import{n as z}from"./dist-BGzUo_18.js";import{G as B,H as ce,O as V,T as H,X as U,Y as W,_t as le,at as G,bt as ue,ct as K,f as de,ft as fe,h as pe,ht as q,i as me,it as J,j as he,m as ge,n as _e,ot as ve,pt as ye,r as be,rt as xe,st as Se,ut as Ce,vt as we,x as Te,y as Ee,yt as De,z as Oe}from"./dist-Dc8tD1th.js";import{i as ke,s as Ae}from"./keyboard-shortcuts-D5fo2XHL.js";import{t as Y}from"./dist-C_FzPxEX2.js";import{p as je,u as Me,v as Ne}from"./schemas-CxFhJLAM.js";import{_ as Pe,d as Fe,f as Ie,g as Le,h as Re,o as ze,s as Be,t as Ve}from"./constants-cc1-Bt4QPTUe.js";import{b as He,i as Ue,o as We,v as Ge}from"./documents-events-C1uYbecE.js";import{a as Ke,n as qe,o as Je,r as Ye,t as Xe}from"./_envelope-DuFpUEag-Beu481Zb.js";import{D as Ze,O as Qe,S as $e,bt as et,d as tt,g as nt,i as rt,l as it,o as at,s as ot,xt as st}from"./schemas-api-CqmliOdH.js";import"./constants-editors-DmmORwNP.js";import{t as ct}from"./note-window-mode-CI3Yju9B.js";import{a as lt,i as ut,n as dt,r as ft}from"./local-menu-action-bus-Dyh2UJJF.js";import{i as pt}from"./use-apply-config-theme-CYFG76sS.js";import{t as mt}from"./parse-api-error-CeEVOj25.js";import{t as ht}from"./createLucideIcon-DdBzwsHe.js";import{n as gt,t as _t}from"./git-branch-CeTudSak.js";import{n as vt,t as yt}from"./arrow-up-BGHhPj4y.js";import{a as bt,c as xt,d as St,i as Ct,l as wt,n as Tt,r as Et,s as Dt,t as Ot,u as kt}from"./Mermaid-DH1HLMlB.js";import{t as At}from"./check-B2OLRY33.js";import{t as jt}from"./chevron-down-CEv6N8LG.js";import{t as Mt}from"./chevron-right-Bofu4lib.js";import{t as Nt}from"./circle-alert-eBm4JPxY.js";import{t as Pt}from"./circle-check-nK1yRBIw.js";import{t as Ft}from"./copy-DpWa6i2v.js";import{t as It}from"./download-BouT3__0.js";import{c as Lt,n as Rt,o as zt,t as Bt}from"./ime-composition-CNKa_WNE.js";import{n as Vt,t as Ht}from"./settings-2-DoBlNQMk.js";import{$ as Ut,$n as Wt,$t as Gt,An as Kt,B as qt,Bt as Jt,Cn as Yt,Ct as Xt,Dn as Zt,Dt as Qt,En as $t,Et as en,F as tn,Ft as nn,G as rn,Gn as an,Gt as on,H as sn,Ht as cn,It as ln,J as un,Jt as dn,K as fn,Kn as pn,Kt as mn,L as hn,Lt as gn,M as _n,Mn as vn,Mt as yn,N as bn,Nn as xn,Nt as Sn,On as Cn,Pn as wn,Pt as Tn,Q as En,Qn as Dn,Qt as On,R as kn,Rn as An,Rt as jn,S as Mn,Sn as Nn,St as Pn,Tn as Fn,Tt as In,U as Ln,Un as Rn,Ut as zn,Vn as Bn,Vt as Vn,W as Hn,Wt as Un,Xn as Wn,Xt as Gn,Y as Kn,Yn as qn,Yt as Jn,Z as Yn,Zn as Xn,Zt as Zn,_r as Qn,_t as $n,an as er,ar as tr,at as nr,bn as rr,c as ir,cn as ar,cr as or,d as sr,dn as cr,dr as lr,dt as ur,en as dr,et as fr,fn as pr,fr as mr,ft as hr,gn as gr,gr as _r,gt as vr,hn as yr,hr as br,in as xr,ir as Sr,j as Cr,jn as wr,k as Tr,kn as Er,ln as Dr,lr as Or,lt as kr,m as Ar,mn as jr,mt as Mr,n as Nr,nn as Pr,nr as Fr,nt as Ir,on as Lr,or as Rr,ot as zr,p as Br,pn as Vr,pr as Hr,pt as Ur,q as Wr,qn as Gr,qt as Kr,r as qr,rn as Jr,rr as Yr,rt as Xr,s as Zr,sn as Qr,sr as $r,t as ei,tn as ti,tr as ni,u as ri,un as ii,ur as ai,ut as oi,vn as si,vr as ci,vt as li,wn as ui,x as di,xn as fi,xt as pi,yn as mi,yr as hi,z as gi,zt as _i}from"./CodeMirrorPropInput-BbFqZgDv.js";import{t as vi}from"./folder-open-COGOeTzI.js";import{n as yi}from"./prop-types-ZtKgQMRh.js";import{t as bi}from"./hash-C4CJQURT.js";import{t as xi}from"./info-CyR0W2SK.js";import{t as Si}from"./spinner-Bx8xD6f8.js";import{t as Ci}from"./maximize-2-DjzhPUDZ.js";import{t as wi}from"./minus-DdRxss3A.js";import{t as Ti}from"./paperclip-FfP_WlTp.js";import{n as Ei,t as Di}from"./plus-CXQ-oViZ.js";import{t as Oi}from"./search-BoiwnBpA.js";import{t as ki}from"./sparkles-lfxw6YO9.js";import{t as Ai}from"./trash-2-Blf9Cydx.js";import{t as ji}from"./triangle-alert-DFWRwfH7.js";import{t as Mi}from"./x-wldAHzfP.js";import{t as Ni}from"./utils-random-uuid-CE1X6bNM.js";import{t as Pi}from"./badge-DcyFOLs8.js";import{a as Fi,c as Ii,i as Li,n as Ri,o as zi,r as Bi,s as Vi,t as Hi}from"./dialog-CAxu_6pu.js";import{a as Ui,i as Wi}from"./constants-skills-Coq7kn_k.js";import{i as Gi,r as Ki,t as qi}from"./bridge-B2_zG6bo.js";import{c as Ji,d as Yi,l as Xi,s as Zi,u as Qi}from"./structural-freshness-C6rR7cV3-VXiZX15w.js";import{n as $i,t as ea}from"./storage-scope-BDcuM4d_.js";import{t as ta}from"./use-workspace-BTtr5NT8.js";import{C as na,_ as ra,a as ia,d as aa,f as oa,i as sa,l as ca,m as la,n as ua,p as da,s as fa,u as pa,w as ma}from"./doc-hash-BT2I193z.js";import{n as X,r as ha}from"./perf-CYJlqBBt.js";import{m as ga,t as _a}from"./use-apply-config-color-theme-UYP8FtjI.js";import{a as va,i as ya,n as ba,t as xa}from"./popover-Dxc5JyiN.js";import{D as Sa,L as Ca,O as wa,T as Ta,Y as Ea,Z as Da,et as Oa,f as ka,k as Aa,n as ja,o as Ma,u as Na,v as Pa,x as Fa}from"./config-provider-DxsAQmo4.js";import{r as Ia}from"./saved-themes-client-BNonffrJ.js";import{t as La}from"./trace-api-nQInEDYS.js";import{t as Ra}from"./propagation-api-dgM6YInk.js";import{t as za}from"./context-api-CMjojwfb.js";import{i as Ba,n as Va,o as Ha}from"./css-color-to-hex-CWNe6sew.js";import{a as Ua}from"./client-version-Cpzxcxbo.js";import{n as Wa,t as Ga}from"./reveal-editor-CoucRZz8.js";import{t as Ka}from"./input-CgydZJoC.js";import{n as qa,r as Ja}from"./external-link-DxgIpECR.js";import{t as Ya}from"./skeleton-2Ewnato7.js";import{s as Xa}from"./skill-scope-DjqrCXkR.js";import{A as Za,C as Qa,M as $a,S as eo,_ as to,c as no,g as ro,h as io,j as ao,k as oo,l as so,m as co,n as lo,u as uo,v as fo,w as po,x as mo,y as ho}from"./navigation-targets-Cu84E97-.js";import{r as go}from"./doc-paths-C1iU3JM4.js";import{n as _o}from"./use-collab-url-DbvOg54A.js";import{t as vo}from"./known-skill-dirs-CErGS26P.js";import{E as yo,Ft as bo,J as xo,K as So,M as Co,Mt as wo,Nt as To,Tt as Eo,X as Do,c as Oo,f as ko,l as Ao,lt as jo,ut as Mo,wt as No}from"./dist-CoJBCixp.js";import{a as Po,c as Fo,i as Io,o as Lo,s as Ro}from"./cm-theme-DpKmjLo0.js";import{R as zo,V as Bo,a as Vo,c as Ho,g as Uo,t as Wo,v as Go,z as Ko}from"./lib-CZXZ01YL.js";import{a as qo,n as Jo,o as Yo,t as Xo}from"./lib-o_ZJ5rsY.js";import{n as Zo}from"./syntax-UjZu5532.js";import{t as Qo}from"./excalidraw-scene-Dgb0SaoB.js";import{i as $o,n as es}from"./page-list-cache-duzt_bxz.js";import{n as ts,r as ns}from"./PageListContext-NRWi1wh0.js";import{t as rs}from"./startup-marks-C403iSh4.js";import{t as is}from"./lib-DxyUjQpt.js";import{t as as}from"./lib-D3PsW6H5.js";import{D as os,_ as ss}from"./skills-api-D9_3ttAz.js";import{i as cs,n as ls,r as us,t as ds}from"./dist-W5hM-kQ3.js";import{t as fs}from"./dist-BtC2yORW.js";import{n as ps}from"./dist-OHM7P10P.js";import{n as ms}from"./dist-ldcsP3Wx.js";import{n as hs}from"./dist-CNHpRWc3.js";import{n as gs}from"./dist-OiK6QmuG.js";import{n as _s}from"./dist-DLTuJxuQ2.js";import{t as vs}from"./stex-CmWau-0j.js";import{t as ys}from"./file-tree-rename-validation-BZbYm35X.js";import{t as bs}from"./CopyButton-BT2YHECh.js";import{n as xs}from"./single-file-mode-DURp6aom.js";(function(){var e=[`user-blocking`,`user-visible`,`background`];class t{constructor(){this.t=new MessageChannel,this.i=this.t.port2,this.l={},this.o=1,this.t.port1.onmessage=e=>this.h(e)}u(e){var t=this.o++;return this.l[t]=e,this.i.postMessage(t),t}p(e){delete this.l[e]}h(e){var t=e.data;if(t in this.l){var n=this.l[t];delete this.l[t],n()}}}function n(){return n.v||=new t,n.v}class r{constructor(e,t,n){n===void 0&&(n=0),this.k=e,this.T=null,this.C=null,this.m=!1,this._(t,n)}isIdleCallback(){return this.T===0}I(){return this.T===2}cancel(){if(!this.m)switch(this.m=!0,this.T){case 0:cancelIdleCallback(this.C);break;case 1:clearTimeout(this.C);break;case 2:n().p(this.C);break;default:throw TypeError(`Unknown CallbackType`)}}_(t,r){if(r&&r>0)return this.T=1,void(this.C=setTimeout(()=>{this.P()},r));if(!e.includes(t))throw TypeError(`Invalid task priority : `+t);t===`background`&&typeof requestIdleCallback==`function`?(this.T=0,this.C=requestIdleCallback(()=>{this.P()})):typeof MessageChannel==`function`?(this.T=2,this.C=n().u(()=>{this.P()})):(this.T=1,this.C=setTimeout(()=>{this.P()}))}P(){this.m||this.k()}}var i=0;class a{constructor(){this.j=null,this.M=null}isEmpty(){return this.j==null}push(e){if(typeof e!=`object`)throw TypeError(`Task must be an Object`);e.A=i++,this.isEmpty()?(e.N=null,this.j=e):(e.N=this.M,this.M.O=e),e.O=null,this.M=e}takeNextTask(){if(this.isEmpty())return null;var e=this.j;return this.q(e),e}merge(e,t){if(typeof t!=`function`)throw TypeError(`Must provide a selector function.`);if(e==null)throw Error(`sourceQueue cannot be null`);for(var n=this.j,r=null,i=e.j;i;){var a=i;if(i=i.O,t(a)){for(e.q(a);n&&n.A<a.A;)r=n,n=n.O;this.D(a,r),r=a}}}D(e,t){if(t!=this.M){var n=t?t.O:this.j;e.O=n,n.N=e,e.N=t,t==null?this.j=e:t.O=e}else this.push(e)}q(e){if(e==null)throw Error(`Expected task to be non-null`);e===this.j&&(this.j=e.O),e===this.M&&(this.M=this.M.N),e.O&&(e.O.N=e.N),e.N&&(e.N.O=e.O)}}class o extends Event{constructor(t,n){if(!n||!e.includes(n.previousPriority))throw TypeError(`Invalid task priority: '`+n.previousPriority+`'`);super(t),this.previousPriority=n.previousPriority}}class s extends AbortController{constructor(t){if(t===void 0&&(t={}),super(),t??={},typeof t!=`object`)throw TypeError(`'init' is not an object`);var n,r,i=t.priority===void 0?`user-visible`:t.priority;if(!e.includes(i))throw TypeError(`Invalid task priority: '`+i+`'`);this.H=i,this.R=!1,r=(n=this).signal,Object.defineProperties(r,{priority:{get:function(){return n.H},enumerable:!0},onprioritychange:{value:null,writable:!0,enumerable:!0}}),r.addEventListener(`prioritychange`,e=>{r.onprioritychange&&r.onprioritychange(e)})}setPriority(t){if(!e.includes(t))throw TypeError(`Invalid task priority: `+t);if(this.R)throw new DOMException(``,`NotAllowedError`);if(this.signal.priority!==t){this.R=!0;var n=this.H;this.H=t;var r=new o(`prioritychange`,{previousPriority:n});this.signal.dispatchEvent(r),this.R=!1}}}self.scheduler===void 0?(self.scheduler=new class{constructor(){this.S={},e.forEach(e=>{this.S[e]=[new a,new a]}),this.U=null,this.W=new WeakMap}yield(){return this.B(()=>{},{priority:`user-visible`},!0)}postTask(e,t){return this.B(e,t,!1)}B(t,n,r){if((n=Object.assign({},n)).signal!==void 0){if(n.signal===null||!(`aborted`in n.signal)||typeof n.signal.addEventListener!=`function`)return Promise.reject(TypeError(`'signal' is not a valid 'AbortSignal'`));if(n.signal&&n.signal.priority&&!e.includes(n.signal.priority))return Promise.reject(TypeError(`Invalid task priority: '`+n.signal.priority+`'`))}if(n.priority!==void 0&&(n.priority===null||!e.includes(n.priority)))return Promise.reject(TypeError(`Invalid task priority: '`+n.priority+`'`));if(n.delay===void 0&&(n.delay=0),n.delay=Number(n.delay),n.delay<0)return Promise.reject(TypeError(`'delay' must be a positive number.`));var i={callback:t,options:n,resolve:null,reject:null,hostCallback:null,abortCallback:null,onTaskCompleted:function(){this.options.signal&&this.abortCallback&&(this.options.signal.removeEventListener(`abort`,this.abortCallback),this.abortCallback=null)},onTaskAborted:function(){this.hostCallback&&=(this.hostCallback.cancel(),null),this.options.signal.removeEventListener(`abort`,this.abortCallback),this.abortCallback=null,this.reject(this.options.signal.reason)},isAborted:function(){return this.options.signal&&this.options.signal.aborted},isContinuation:r},a=new Promise((e,t)=>{i.resolve=e,i.reject=t});return this._(i),a}_(e){var t=e.options.signal;if(t){if(t.aborted)return void e.reject(t.reason);e.abortCallback=()=>{e.onTaskAborted()},t.addEventListener(`abort`,e.abortCallback)}e.options.delay>0?e.hostCallback=new r(()=>{e.hostCallback=null,this.F(e)},null,e.options.delay):(this.G(e),this.J())}F(e){this.G(e),this.U&&=(this.U.cancel(),null),this.K()}L(e){var t=this.W.get(e);if(t===void 0)throw Error(`Attempting to change priority on an unregistered signal`);if(t!==e.priority){for(var n=0;n<2;n++)this.S[e.priority][n].merge(this.S[t][n],t=>t.options.signal===e);this.W.set(e,e.priority)}}K(){this.U=null,this.V(),this.J()}J(){var{priority:e}=this.X();e!=null&&(e!==`background`&&this.U&&this.U.isIdleCallback()&&(this.U.cancel(),this.U=null),this.U||=new r(()=>{this.K()},e,0))}G(t){var n;if(!e.includes(n=t.options.priority?t.options.priority:t.options.signal&&t.options.signal.priority?t.options.signal.priority:`user-visible`))throw TypeError(`Invalid task priority: `+n);if(t.options.signal&&t.options.signal.priority){var r=t.options.signal;this.W.has(r)||(r.addEventListener(`prioritychange`,()=>{this.L(r)}),this.W.set(r,r.priority))}this.S[n][+!t.isContinuation].push(t)}V(){var e=null;do{var{priority:t,type:n}=this.X();if(t==null)return;e=this.S[t][n].takeNextTask()}while(e.isAborted());try{var r=e.callback();e.resolve(r)}catch(t){e.reject(t)}finally{e.onTaskCompleted()}}X(){for(var t=0;t<e.length;t++)for(var n=e[t],r=0;r<2;r++)if(!this.S[n][r].isEmpty())return{priority:n,type:r};return{priority:null,type:0}}},self.TaskController=s,self.TaskPriorityChangeEvent=o):self.scheduler.yield||(self.scheduler.yield=function(){return self.scheduler.postTask(()=>{},{priority:`user-blocking`})})})();var Z=e(i(),1),Ss=e(c(),1),Q=l(),Cs=null,ws=!1,Ts=!1;function Es(e){return e instanceof Error&&e.message?e.message:String(e)}function Ds(e){let t=Es(e);if(t===Cs){ws=!0,Ts=!0;return}Cs=t,ws=!1,Ts=!1}function Os(){return ws}function ks(){ws=!1,Cs=null}function As(){let e=Ts;return Ts=!1,e}var $=r(),js=`open-knowledge:doc-panel-tab`,Ms=null;function Ns(){return typeof window>`u`?new EventTarget:window}function Ps(){let e=Ms;return Ms=null,e}var Fs=null,Is=null;function Ls(){Fs=null,Is?.(),Is=null}function Rs(e){let t=null,n=null,r=null,i=()=>{typeof cancelAnimationFrame==`function`&&(t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)),r!==null&&clearTimeout(r),Is===i&&(Is=null)},a=()=>{Fs===e&&(Fs=null),i()};return typeof requestAnimationFrame==`function`?(t=requestAnimationFrame(()=>{t=null,n=requestAnimationFrame(()=>{n=null,a()})}),r=setTimeout(a,250)):r=setTimeout(a,0),i}function zs(e){return typeof window>`u`||e===window}function Bs(e){if(Fs?.tab!==e)return null;let{request:t}=Fs;return Ls(),t}function Vs(e,t={},n=Ns()){if(zs(n)&&(Ms=e,Ls(),t.scope!==void 0||t.focus!==void 0)){let n={tab:e,request:t};Fs=n,Is=Rs(n)}n.dispatchEvent(new CustomEvent(js,{detail:{tab:e,...t}}))}function Hs(e,t=Ns()){let n=t=>{let n=t instanceof CustomEvent?t.detail:void 0;n?.tab&&e(n.tab,{scope:n.scope,focus:n.focus})};return t.addEventListener(js,n),()=>t.removeEventListener(js,n)}async function Us(e,t){let n=await fetch(e,{...t,headers:{"content-type":`application/json`,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok){let e=Ye.safeParse(r);throw Error(e.success?e.data.title??e.data.detail:`comments request failed (${n.status})`)}return r}function Ws(e){return Us(`/api/comment`,{method:`POST`,body:JSON.stringify(e)})}function Gs(e,t){let n=e.safeParse(t);if(!n.success)throw Error(`The server returned a response this build cannot read.`);return n.data}function Ks(e){let t=at.safeParse(e);if(!t.success)throw Error(`The server returned a comment thread this build cannot read.`);return t.data}function qs(e){let t=[];for(let n of e){let e=at.safeParse(n);e.success?t.push(e.data):console.warn(`[comments] skipped a thread this build cannot read`,e.error.issues)}return t}async function Js(e){let{threads:t}=await Us(e===void 0?`/api/comments`:`/api/comments?doc=${encodeURIComponent(e)}`);return qs(t)}function Ys(e){return Us(`/api/comments`,{method:`POST`,body:JSON.stringify(e)}).then(Ks)}function Xs(e,t){return Ws({action:`edit`,id:e,body:t}).then(Ks)}function Zs(e){return Ws({action:`reopen`,id:e}).then(Ks)}function Qs(e,t){return Ws({action:`replace`,id:e,...t}).then(Ks)}function $s(e){return Ws({action:`queue`,id:e}).then(e=>Gs(Qe,e))}function ec(e){return Ws({action:`unqueue`,id:e}).then(Ks)}function tc(e){return Us(`/api/comment?id=${encodeURIComponent(e)}`,{method:`DELETE`}).then(e=>Gs(tt,e))}function nc(e){return Ws({action:`dispatch-prepare-batch`,ids:e}).then(e=>Gs(Ze,e))}function rc(e){return Ws({action:`dispatch-complete-batch`,ids:e}).then(e=>Gs(ot,e))}var ic=`open-knowledge:comments-scope`,ac=typeof window>`u`?new EventTarget:window,oc=null;function sc(){let e=oc;return oc=null,e}function cc(e){let t=t=>{oc=null,e(t.detail)};return ac.addEventListener(ic,t),()=>ac.removeEventListener(ic,t)}function lc(e,t){t!==void 0&&typeof window<`u`&<({kind:`reveal-comments`,docName:t,scope:e===`project`?`queue`:`doc`},window)||(oc=e,Vs(`comments`),ac.dispatchEvent(new CustomEvent(ic,{detail:e})))}function uc(e){lc(`project`,e)}var dc=Object.freeze([]),fc=Object.freeze([]),pc=new Map,mc=[],hc=new Set,gc=new Set,_c=!1,vc=new Set,yc=0,bc=0;function xc(){for(let e of hc)e()}function Sc(){yc+=1,xc()}function Cc(){bc+=1,xc()}function wc(e){return{id:e.threadId,docName:e.docName,target:e.target,anchor:e.anchor===null?null:{quote:e.anchor.exact,prefix:e.anchor.prefix,suffix:e.anchor.suffix,start:e.anchor.start,end:e.anchor.end},status:e.state===`anchored`?`open`:e.state,body:e.latestComment,createdAt:e.createdAt,updatedAt:e.updatedAt??e.createdAt,queued:e.queued}}async function Tc(){return(await Js()).map(wc).sort((e,t)=>t.createdAt-e.createdAt)}async function Ec(e){e!==void 0&&gc.add(e);let t=await Tc();mc=t,_c=!0;for(let e of gc)pc.set(e,t.filter(t=>t.docName===e));Sc(),Dc(t)}function Dc(e){vl!==null&&(e.some(e=>e.id===vl&&e.status===`open`)||jl(null))}var Oc=!1;function kc(){Oc||typeof window>`u`||(Oc=!0,Ge(e=>{e.includes(`comments`)&&Ec().catch(()=>void 0)}))}function Ac(e){kc(),!gc.has(e)&&(gc.add(e),Ec(e).catch(()=>{gc.delete(e)}))}function jc(){kc(),!_c&&(_c=!0,Ec().catch(()=>{_c=!1}))}function Mc(e){return Ac(e),pc.get(e)??dc}function Nc(e){return hc.add(e),()=>{hc.delete(e)}}function Pc(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=()=>Mc(e),t[0]=e,t[1]=n),(0,Z.useSyncExternalStore)(Nc,n,Fc)}function Fc(){return dc}function Ic(){return jc(),mc}function Lc(){return(0,Z.useSyncExternalStore)(Nc,Ic,Rc)}function Rc(){return dc}function zc(e){for(let t of pc.values()){let n=t.find(t=>t.id===e);if(n)return n}return mc.find(t=>t.id===e)??null}function Bc(e){Ys({docName:e.docName,quote:e.quote,prefix:e.prefix,suffix:e.suffix,body:e.body,queue:!0}).then(t=>{if(Ec(e.docName).catch(()=>void 0),e.onCreated!==void 0){e.onCreated(t.threadId);return}lc(`doc`,e.docName),Nl()}).catch(e=>{z.error(e instanceof Error&&e.message?Y._({id:`q3W2nd`,values:{0:e.message}}):Y._({id:`SRBk2G`}))})}function Vc(e){Ys({docName:e.docName,propertyKey:e.propertyKey,propertyPath:e.propertyPath,quote:e.quote,body:e.body,queue:!0}).then(()=>{Ec(e.docName).catch(()=>void 0),lc(`doc`,e.docName),Nl()}).catch(e=>{z.error(e instanceof Error&&e.message?Y._({id:`q3W2nd`,values:{0:e.message}}):Y._({id:`SRBk2G`}))})}function Hc(e,t,n){e.then(()=>{Ec(t).catch(()=>void 0)},e=>{z.error(e instanceof Error&&e.message?`${n} ${e.message}`:n),Ec(t).catch(()=>void 0)})}function Uc(e,t){let n=zc(e)?.docName;Hc(Xs(e,t),n,Y._({id:`kzpkcn`}))}function Wc(e){let t=zc(e)?.docName;rl(e),Hc(Zs(e),t,Y._({id:`lISYEX`}))}function Gc(e){let t=zc(e)?.docName;Hc(tc(e),t,Y._({id:`IxHMdF`}))}function Kc(e,t,n){let r=zc(e)?.docName;Hc(Qs(e,{quote:t,prefix:n?.prefix,suffix:n?.suffix}),r,Y._({id:`mlvM8g`}))}var qc=fc,Jc=-1,Yc=fc,Xc=-1,Zc=-1;function Qc(){if(jc(),Jc!==yc){let e=mc.filter(e=>e.queued&&e.status!==`resolved`).sort((e,t)=>e.createdAt-t.createdAt).map(e=>e.id);qc=e.length===0?fc:e,Jc=yc}return qc}function $c(){let e=Qc();if(Xc!==yc||Zc!==bc){let t=e.filter(e=>!vc.has(e));Yc=t.length===0?fc:t,Xc=yc,Zc=bc}return Yc}function el(){return(0,Z.useSyncExternalStore)(Nc,$c,tl)}function tl(){return fc}function nl(e){return $c().filter(t=>zc(t)?.docName===e)}function rl(e){if(!vc.has(e))return;let t=new Set(vc);t.delete(e),vc=t,Cc()}function il(e){let t=zc(e)?.docName;rl(e),Hc($s(e),t,Y._({id:`S-7ej_`}))}function al(e){let t=zc(e)?.docName;Hc(ec(e),t,Y._({id:`PTUuoc`}))}function ol(e){$c().includes(e)?al(e):il(e)}function sl(e,t){let n=new Set($c()),r=e.filter(e=>n.has(e)!==t);if(r.length!==0){if(t&&vc.size>0){let e=new Set(vc);for(let t of r)e.delete(t);vc=e,Cc()}Promise.all(r.map(e=>(t?$s(e):ec(e)).then(()=>!0,()=>!1))).then(e=>{let t=e.filter(e=>!e).length;t>0&&z.error(Y._({id:`wqD3pI`,values:{0:r.length,failed:t}})),Ec().catch(()=>void 0)})}}var cl=!1;async function ll({compose:e,threadIds:t,resolve:n=!0}){let r=t??$c();if(r.length===0||cl)return[];cl=!0;try{return await ul(r,e,n)}finally{cl=!1}}async function ul(e,t,n){let r;try{r=await nc(e)}catch(e){return z.error(e instanceof Error&&e.message?Y._({id:`cVKnqL`,values:{0:e.message}}):Y._({id:`7FA2iI`})),[]}Sc();let i=r.results.flatMap(e=>e.ok?[{threadId:e.threadId,payload:e.payload}]:[]);if(i.length===0)return await Ec().catch(()=>void 0),[];let a=!1;try{a=await t(i)}catch(e){console.warn(`[comments] dispatch compose failed; leaving threads queued`,e),a=!1}let o=a?i.map(e=>e.threadId):[];return o.length>0&&n&&await rc(o).catch(()=>{z.error(Y._({id:`JyM0gO`}))}),await Ec().catch(()=>void 0),o}var dl=`open-knowledge:comment-focus-thread`,fl=`open-knowledge:comment-open-thread`,pl=`open-knowledge:comment-start`,ml=`open-knowledge:comment-posted`,hl=typeof window>`u`?new EventTarget:window;function gl(e){hl.dispatchEvent(new CustomEvent(dl,{detail:e}))}function _l(e){let t=t=>e(t.detail);return hl.addEventListener(dl,t),()=>hl.removeEventListener(dl,t)}var vl=null,yl=null,bl=null,xl=new Set;function Sl(){let e=yl??vl;if(e!==bl){bl=e;for(let e of xl)e()}}function Cl(){return bl}function wl(e){yl=e,Sl()}function Tl(e){yl===e&&(yl=null,Sl())}function El(e){return xl.add(e),()=>{xl.delete(e)}}function Dl(){return(0,Z.useSyncExternalStore)(kl,Al,Ol)}function Ol(){return null}function kl(e){return Ml(()=>e())}function Al(){return vl}function jl(e){vl=e,Sl(),e!==null&&Vs(`comments`),hl.dispatchEvent(new CustomEvent(fl,{detail:e}))}function Ml(e){let t=t=>e(t.detail);return hl.addEventListener(fl,t),()=>hl.removeEventListener(fl,t)}function Nl(){hl.dispatchEvent(new CustomEvent(ml))}function Pl(e){let t=()=>e();return hl.addEventListener(ml,t),()=>hl.removeEventListener(ml,t)}function Fl(){hl.dispatchEvent(new CustomEvent(pl))}function Il(e){let t=()=>e();return hl.addEventListener(pl,t),()=>hl.removeEventListener(pl,t)}var Ll=ht(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),Rl=ht(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),zl=ht(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),Bl=ht(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Vl=ht(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Hl=ht(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),Ul=ht(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),Wl=ht(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),Gl=ht(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Kl=ht(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),ql=ht(`copy-plus`,[[`line`,{x1:`15`,x2:`15`,y1:`12`,y2:`18`,key:`1p7wdc`}],[`line`,{x1:`12`,x2:`18`,y1:`15`,y2:`15`,key:`1nscbv`}],[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Jl=ht(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]),Yl=ht(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Xl=ht(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),Zl=ht(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),Ql=ht(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),$l=ht(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),eu=ht(`heading-1`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`m17 12 3-2v8`,key:`1hhhft`}]]),tu=ht(`heading-2`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`,key:`9jr5yi`}]]),nu=ht(`heading-3`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`,key:`68ncm8`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`,key:`1ejuhz`}]]),ru=ht(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),iu=ht(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),au=ht(`layout-panel-top`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}]]),ou=ht(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),su=ht(`link-2-off`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),cu=[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]],lu=ht(`link-2`,cu),uu=ht(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),du=ht(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),fu=ht(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),pu=ht(`message-square-warning`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 15h.01`,key:`q59x07`}],[`path`,{d:`M12 7v4`,key:`xawao1`}]]),mu=ht(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),hu=ht(`panel-top`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]),gu=ht(`pen-tool`,[[`path`,{d:`M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z`,key:`nt11vn`}],[`path`,{d:`m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18`,key:`15qc1e`}],[`path`,{d:`m2.3 2.3 7.286 7.286`,key:`1wuzzi`}],[`circle`,{cx:`11`,cy:`11`,r:`2`,key:`xmgehs`}]]),_u=ht(`quote`,[[`path`,{d:`M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`rib7q0`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`1ymkrd`}]]),vu=ht(`shapes`,[[`path`,{d:`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`,key:`1bo67w`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`3.5`,key:`w3z12y`}]]),yu=ht(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),bu=ht(`sigma`,[[`path`,{d:`M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2`,key:`wuwx1p`}]]),xu=ht(`smile`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2`,key:`1y1vjs`}],[`line`,{x1:`9`,x2:`9.01`,y1:`9`,y2:`9`,key:`yxxnd0`}],[`line`,{x1:`15`,x2:`15.01`,y1:`9`,y2:`9`,key:`1p4y9e`}]]),Su=ht(`square-play`,[[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}]]),Cu=ht(`superscript`,[[`path`,{d:`m4 19 8-8`,key:`hr47gm`}],[`path`,{d:`m12 19-8-8`,key:`1dhhmo`}],[`path`,{d:`M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06`,key:`1dfcux`}]]),wu=ht(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),Tu=ht(`text-align-center`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M17 12H7`,key:`16if0g`}],[`path`,{d:`M19 19H5`,key:`vjpgq2`}]]),Eu=ht(`text-align-end`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M21 19H7`,key:`4cu937`}]]),Du=ht(`text-align-start`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]]),Ou=ht(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),ku=ht(`workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),Au=ht(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),ju=(()=>{let e=globalThis.Intl.Segmenter;return e?new e(void 0,{granularity:`grapheme`}):null})();function Mu(e){return e>=56320&&e<=57343}function Nu(e){return e>=55296&&e<=56319}function Pu(e,t){if(ju){let n=ju.segment(e).containing(t);return n===void 0?t:n.index}return Mu(e.charCodeAt(t))&&Nu(e.charCodeAt(t-1))?t-1:t}function Fu(e,t){if(ju){let n=ju.segment(e).containing(t);return n===void 0||n.index===t?t:n.index+n.segment.length}return Mu(e.charCodeAt(t))&&Nu(e.charCodeAt(t-1))?t+1:t}function Iu(e,t){return e.length<=t?e:t<=0?``:e.slice(0,Pu(e,t))}function Lu(e,t){return e.length<=t?e:t<=0?``:e.slice(Fu(e,e.length-t))}var Ru=new Map,zu=new Set;function Bu(){for(let e of zu)e()}function Vu(e,t){Ru.set(e,t),Bu()}function Hu(e,t){Ru.get(e)===t&&(Ru.delete(e),Bu())}function Uu(e){return Ru.get(e)??null}function Wu(e){let t=Ru.get(e);if(!t||t.isDestroyed)return null;let n=br(t)?.dom;return n?.isConnected&&n.getClientRects().length>0?t:null}function Gu(e){return zu.add(e),()=>zu.delete(e)}function Ku(e,t){let n=e.attrs[t];return typeof n==`string`?n:``}function qu(e,t){let n=e.attrs.props;if(typeof n!=`object`||!n)return``;let r=n[t];return typeof r==`string`?r:``}var Ju=[`children`,`chart`,`formula`,`alt`,`name`,`alias`,`target`];function Yu(e){for(let t of Ju){let n=qu(e,t);if(n.length>0)return n}return Ku(e,`sourceRaw`)}function Xu(e){switch(e.type.name){case`wikiLink`:return Ku(e,`alias`)||Ku(e,`target`);case`wikiLinkEmbed`:return Ku(e,`target`);case`tag`:return`#${Ku(e,`value`)}`;case`mathInline`:return Ku(e,`formula`);case`image`:case`imageReference`:return Ku(e,`alt`);case`footnoteReference`:return Ku(e,`label`)||Ku(e,`identifier`);case`jsxComponent`:case`jsxInline`:return e.content.size===0?Yu(e):``;default:return``}}function Zu(e,t,n,r=`
|
|
3
|
-
`,{inlineOnly:i=!1}={}){let a=``,o=!0;return e.nodesBetween(t,n,(e,s)=>{let c=e.isText?(e.text??``).slice(Math.max(t,s)-s,n-s):i&&e.isBlock?``:Xu(e);return e.isBlock&&(e.isTextblock||c.length>0)&&r&&(o?o=!1:a+=r),a+=c,!0},0),a}function Qu(e,t){if(!t)return{kind:`absent`};if(t.getClientRects().length===0)return{kind:`unmeasurable`};let n=e.getBoundingClientRect().top;return{kind:`measured`,contentPos:t.getBoundingClientRect().top-n+e.scrollTop}}function $u(e,t,n){if(t===null)return e;switch(n.kind){case`measured`:return n.contentPos+t;case`absent`:return e;case`unmeasurable`:return null;default:return ad(n)}}var ed=`[contenteditable]`;function td(e){let t=e.getBoundingClientRect().top,{scrollTop:n}=e,r=null;for(let i of Array.from(e.querySelectorAll(ed))){if(i.parentElement?.closest(ed)||i.getClientRects().length===0)continue;let e=i.getBoundingClientRect().bottom-t+n;(r===null||e>r)&&(r=e)}return r}function nd(e,t,n){return t===null?e:Math.min(e,Math.max(0,t-n))}function rd(e,t,n){return(t??n)>e}function id(e){switch(e.kind){case`measured`:case`absent`:return!0;case`unmeasurable`:return!1;default:return ad(e)}}function ad(e){throw Error(`Unhandled AnchorMeasurement variant: ${JSON.stringify(e)}`)}function od(e,t){return Math.abs(e-t)<=1}function sd(e,t){return t-e>1}var cd=1e4;function ld(e,t,n){let r=t-n;return r<=0?0:Math.max(0,Math.min(1,e/r))}var ud=new Map;function dd(e,t){if(ud.delete(e),ud.set(e,t),ud.size>256){let e=ud.keys().next().value;e!==void 0&&ud.delete(e)}}function fd(e){return ud.get(e)}var pd=`data-ok-body-anchor`;function md(e){let t=e.anchor??e.container.querySelector(`[data-ok-body-anchor]`),n=Qu(e.container,t),r=n.kind===`measured`?n.contentPos:0;dd(e.docName,{offset:e.targetScrollTop-r,mode:e.mode,fraction:ld(e.targetScrollTop,e.container.scrollHeight,e.container.clientHeight)})}var hd=new Map,gd=0;function _d(e,t){let n=hd.get(e)??{landing:0,navigation:0};n[t]+=1,hd.set(e,n);let r=gd,i=!1;return{release(){if(i||(i=!0,r!==gd))return;let n=hd.get(e);n&&(n[t]=Math.max(0,n[t]-1),n.landing===0&&n.navigation===0&&hd.delete(e))}}}function vd(e){let t=hd.get(e);return t?t.landing>0?`landing`:t.navigation>0?`navigation`:null:null}function yd(e){return vd(e)!==null}var bd=new Map;function xd(e,t){let n=bd.get(e)??new Set;return n.add(t),bd.set(e,n),{release(){let n=bd.get(e);n&&(n.delete(t),n.size===0&&bd.delete(e))}}}var Sd=600,Cd=`ok/scroll-nav/declined`,wd=new Map;function Td(e,t){let n=wd.get(e)??new Set;if(wd.delete(e),wd.set(e,n),wd.size>32){let e=wd.keys().next().value;e!==void 0&&wd.delete(e)}return n.has(t)?!1:(n.add(t),!0)}var Ed=new Set;function Dd(e){let t=_d(e,`navigation`),n=setTimeout(()=>{Ed.delete(n),t.release()},Sd);Ed.add(n)}function Od(e,t){let n=bd.get(e),r=n?Array.from(n):[];for(let n of r)if(!n.yieldsToNavigation)return Td(e,t)&&X(Cd,{docName:e,seam:t,ownerCount:r.length}),!1;wd.delete(e),Dd(e);for(let e of r)e.supersede();return!0}function kd(e,t,n){return Od(e,t)?(n(),!0):!1}var Ad=!1;function jd(e){Ad=e}function Md(){return Ad}var Nd=new Map,Pd=null;function Fd(){return ha(`PREWARM_CORRELATION_WINDOW_MS`,5e3)}function Id(){if(Pd!==null)return;let e=Math.max(50,Math.floor(Fd()/2));Pd=setTimeout(()=>{Pd=null,Ld(Date.now()),Nd.size>0&&Id()},e)}function Ld(e){let t=Fd();for(let[n,r]of Nd)e-r.emittedAt>=t&&(Nd.delete(n),X.count(`ok/sidebar/prewarm`,{hit:!1}))}function Rd(e,t,n=Date.now()){Nd.has(e)&&X.count(`ok/sidebar/prewarm`,{hit:!1}),Nd.set(e,{poolEventId:t,emittedAt:n}),Id()}function zd(e,t,n=Date.now()){let r=Nd.get(e);return!r||r.poolEventId!==t||n-r.emittedAt>=Fd()?!1:(Nd.delete(e),X(`ok/sidebar/prewarm-clicked`,{docName:e,t:n,poolEventId:t}),X.count(`ok/sidebar/prewarm`,{hit:!0}),!0)}var Bd=6e3,Vd=6e4;function Hd(e,t){let n=e.filter(e=>t-e<Vd);return n.push(t),{times:n,escalate:n.length>=2}}function Ud(e,t){return e==null?`hidden`:e.kind===`refused`?`refused`:t?`hidden`:`switch`}var Wd=new Set,Gd=null;function Kd(){for(let e of Wd)e()}function qd(e){return Gd===e?!0:(Gd=e,Kd(),!0)}function Jd(){return Gd}function Yd(e){return Wd.add(e),()=>{Wd.delete(e)}}je({event:Me(`ok-branch-switched-clear-failed`),branch:Ne(),docName:Ne(),reason:Ne()});async function Xd(e,t){if(e.isMismatchRecycleInFlight()){console.warn(JSON.stringify({event:`ok-branch-switched-deferred-to-mismatch-recycle`,branch:t}));return}let n=[];for(let[r,i]of e.entries)i.kind===`active`&&i.persistence!==null&&n.push(i.persistence.clearData().catch(e=>{let n={event:`ok-branch-switched-clear-failed`,docName:r,branch:t,reason:e instanceof Error?e.message:String(e)};console.warn(JSON.stringify(n))}));await Promise.all(n),e.clearBufferedUpdates(),e.recycleAllEntries()}var Zd=null,Qd=null,$d=new Set;function ef(e,t){return e.runtimeVersion===t.runtimeVersion&&e.protocolVersion===t.protocolVersion}function tf(e){if(Zd===null||Qd===null){Zd=e,Qd=e;return}if(ef(Qd,e))return;Qd=e;let t={loaded:Zd,current:e,drifted:!ef(Zd,e)};for(let e of $d)try{e(t)}catch(e){console.warn(`[server-version-store] subscriber threw:`,e)}}function nf(e){return $d.add(e),()=>{$d.delete(e)}}function rf(e){let t=!1;return()=>{t?e():t=!0}}function af(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function of(e,t=``){let n;try{n=await fetch(`${t}/api/server-info`,{signal:AbortSignal.timeout(5e3)})}catch{return}if(!n.ok)return;let r;try{r=await n.json()}catch{return}let i=Ke.safeParse(r);if(!i.success){console.warn(JSON.stringify({event:`ok-server-info-schema-mismatch`,issues:i.error.issues}));return}if(e.setExpectedServerInstanceId(i.data.serverInstanceId),Ia(i.data.serverInstanceId),tf({runtimeVersion:i.data.runtimeVersion??null,protocolVersion:i.data.protocolVersion??null}),i.data.currentBranch!==void 0&&e.compareAndUpdateObservedBranch(i.data.currentBranch)&&(Xd(e,i.data.currentBranch),Ue(i.data.currentBranch)),i.data.currentDiskAckSVs!==void 0){let t={};for(let[e,n]of Object.entries(i.data.currentDiskAckSVs))try{t[e]=af(n)}catch{}e.observeDiskAckBatch(t)}}var sf=`ok-tab-session-restore-recovered`;function cf(){z(Y._({id:`HdS4Ft`}),{id:sf,description:Y._({id:`AR4s_6`}),duration:1/0})}var lf=null;function uf(e){lf=e}function df(e){let t=lf;return lf=null,t!==null&&ra(e,t)}function ff(e){return[...new Set(e)]}function pf(e){return{async reconcileLocalRename({renamed:t,renamedFolders:n=[],renamedAssets:r=[],additionalRemovedDocNames:i=[]}){e.captureRenameSnapshots(t);let a=e.getActivePoolDocName(),o=[];for(let{fromDocName:n,toDocName:r}of t)o.push(n),a!==r&&e.hasPooledDocument(r)&&o.push(r);o.push(...i),await Promise.all(ff(o).map(t=>e.closeAndClear(t))),e.remapTabs({renamed:t,renamedFolders:n,renamedAssets:r})},async reconcileLocalRemoval({tabIdsToClose:t,docNamesToClear:n}){e.closeTabs(t),await Promise.all(ff(n).map(t=>e.closeAndClear(t)))},async reconcileAuthRename({fromDocName:t,toDocName:n}){let r=e.getActivePoolDocName()===t,i=[{fromDocName:t,toDocName:n}];e.captureRenameSnapshots(i),await Promise.all([e.closeAndClear(t),e.closeAndClear(n)]),r&&e.openAndActivate(n),e.remapTabs({renamed:i,renamedFolders:[],renamedAssets:[]});let a=e.remapActiveTargetForRename(t,n);(r||a)&&e.navigateToDocument(n)},async reconcileAuthRemoval({docName:t}){let n=e.getActivePoolDocName()===t;await e.closeAndClear(t),e.removeDocumentTab(t),e.clearActiveTargetForRemoval(t),n&&e.showDocumentDeletedState?.(t)!==!0&&e.navigateHome()}}}var mf=new Map;function hf(e){return mf.get(e)}function gf(e,t){mf.set(e,t)}function _f(e){mf.delete(e)}var vf=`open-knowledge-app`,yf=new Map,bf=new Set,xf=1024,Sf=1024;function Cf(){return La.getTracer(vf)}function wf(e,t,n){if(bf.has(e))return null;let r=yf.get(e);if(r)return r;if(yf.size>=Sf){let e=yf.keys().next().value;if(e!==void 0){let t=yf.get(e);yf.delete(e);try{t?.span.end()}catch(e){console.warn(`[otel-spans] eviction span.end failed:`,e instanceof Error?e:String(e))}}}let i={span:Cf().startSpan(`ok.cold-mount`,{attributes:{"mount.id":e,...t},startTime:n}),startTimeMs:n};return yf.set(e,i),i}function Tf(e,t,n,r,i){try{let a=wf(e,n,r),o=a?La.setSpan(za.active(),a.span):za.active();Cf().startSpan(t,{attributes:{"mount.id":e,...n},startTime:r},o).end(i??Date.now())}catch(e){console.warn(`[otel-spans] emitColdMountChild failed:`,e instanceof Error?e:String(e))}}function Ef(e,t){try{let n=yf.get(e);if(n&&(yf.delete(e),n.span.end(t??Date.now())),!bf.has(e)){if(bf.size>=xf){let e=bf.values().next().value;e!==void 0&&bf.delete(e)}bf.add(e)}}catch(e){console.warn(`[otel-spans] finalizeColdMountSpan failed:`,e instanceof Error?e:String(e))}}var Df=class extends Error{docName;constructor(e){super(`Mount aborted for "${e}"`),this.name=`MountAbortError`,this.docName=e}};function Of(){return ha(`MOUNT_STALLED_THRESHOLD_MS`,1e4)}function kf(e){e.stalledHandle!==null&&(clearTimeout(e.stalledHandle),e.stalledHandle=null)}function Af(e,t,n){if(e.stalledMarkEmitted)return;e.stalledMarkEmitted=!0;let r=n-e.createdAt;X(`ok/mount/stalled`,{docName:t,mountId:e.mountId,elapsedMs:r})}var jf=new Map,Mf=new Set;function Nf(e){Mf.add(e);for(let[t,n]of jf)if(n.stalledMarkEmitted&&!n.settled)try{e(t,n.mountId)}catch{}return()=>{Mf.delete(e)}}function Pf(e,t){for(let n of Mf)try{n(e,t.mountId)}catch{}}var Ff=!1;function If(){typeof document>`u`||document.visibilityState===`visible`&&zf(Date.now())}function Lf(){Ff||typeof document>`u`||typeof document.addEventListener==`function`&&(document.addEventListener(`visibilitychange`,If),Ff=!0)}function Rf(){Ff&&(typeof document>`u`||typeof document.removeEventListener==`function`&&(document.removeEventListener(`visibilitychange`,If),Ff=!1))}function zf(e){let t=Of();for(let[n,r]of jf)r.settled||r.stalledMarkEmitted||e-r.createdAt<t||(Af(r,n,e),Pf(n,r))}function Bf(e){let{docName:t,mountId:n,construct:r,sizeStats:i}=e,a=jf.get(t);if(a)return a.promise;let o=new AbortController,s=Date.now(),{promise:c,resolve:l,reject:u}=Promise.withResolvers(),d={promise:c,rejectFn:u,controller:o,mountId:n,createdAt:s,settled:!1,resolved:!1,preMountEditor:null,stalledHandle:null,stalledMarkEmitted:!1};return d.stalledHandle=setTimeout(()=>{d.settled||(Af(d,t,Date.now()),Pf(t,d))},Of()),o.signal.addEventListener(`abort`,()=>{d.settled||(d.settled=!0,kf(d),d.preMountEditor&&=(Wf(t,d.preMountEditor,`aborted`),null),jf.delete(t),jf.size===0&&Rf(),X(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`aborted`}),u(new Df(t)),Ef(d.mountId))}),jf.set(t,d),Lf(),X(`ok/mount/create`,{docName:t,mountId:d.mountId}),Gf({docName:t,construct:r,sizeStats:i,entry:d,resolveFn:l,rejectFn:u}).catch(e=>{if(d.preMountEditor&&=(Wf(t,d.preMountEditor,`backstop`),null),d.settled){X(`ok/mount/post-settle-throw`,{docName:t,mountId:d.mountId,message:e instanceof Error?e.message:String(e)});return}d.settled=!0,kf(d);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`unhandled-body-throw`,message:n.message}),u(n),Ef(d.mountId)}),c}function Vf(e){return jf.get(e)?.resolved===!0}function Hf(e){return jf.get(e)?.controller??null}function Uf(e){let t=jf.get(e);t&&(t.settled=!0,kf(t),t.preMountEditor&&=(Wf(e,t.preMountEditor,`aborted`),null),jf.delete(e),jf.size===0&&Rf(),X(`ok/mount/invalidate`,{docName:e,mountId:t.mountId}),Ef(t.mountId),t.controller.abort())}function Wf(e,t,n){let r=Kf(t);try{t.destroy()}catch(t){X(`ok/mount/destroy-failed`,{docName:e,stage:n,message:t instanceof Error?t.message:String(t)})}r&&(r.restore=void 0)}async function Gf(e){let{docName:t,construct:n,sizeStats:r,entry:i,resolveFn:a,rejectFn:o}=e,s=document.createElement(`div`);if(Ap(t)!==void 0){let e=pp({docName:t,container:s,factory:()=>{throw Error(`mount-promise: V2 cache contract violation — factory invoked on HIT for "${t}"`)}});i.settled=!0,i.resolved=!0,kf(i),a(e);return}if(await scheduler.yield(),i.controller.signal.aborted)return;let c=null;try{c=n()}catch(e){i.settled=!0,kf(i);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`construct-failed`,message:n.message}),o(n),Ef(i.mountId);return}if(i.preMountEditor=c.editor,await scheduler.yield(),i.controller.signal.aborted){i.preMountEditor=null;return}try{c.editor.mount(s)}catch(e){Wf(t,c.editor,`mount-failed`),i.preMountEditor=null,i.settled=!0,kf(i);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`mount-failed`,message:n.message}),o(n),Ef(i.mountId);return}let l;try{l=pp({docName:t,container:s,sizeStats:r,factory:()=>c})}catch(e){Wf(t,c.editor,`v2-register-failed`),i.preMountEditor=null,i.settled=!0,kf(i);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`v2-register-failed`,message:n.message}),o(n),Ef(i.mountId);return}i.preMountEditor=null,i.settled=!0,i.resolved=!0,kf(i);let u=Date.now()-i.createdAt;X(`ok/mount/resolve`,{docName:t,mountId:i.mountId,elapsedMs:u}),X.histogram(`ok/mount/resolve-elapsed-ms`,{docName:t,mountId:i.mountId},u),a(l);let d=Date.now();Tf(i.mountId,`ok.mount-promise`,{"doc.name":t,elapsed_ms:u},i.createdAt,d),Ef(i.mountId,d)}function Kf(e){try{let t=e.state;return Dn.getState(t)?.undoManager??null}catch(e){return X(`ok/cache/undo-manager-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}var qf=ha(`MAX_CACHE`,10),Jf=ha(`VIEW_COUNT_CACHE_THRESHOLD`,50),Yf=ha(`BYTES_CACHE_THRESHOLD`,8e6);function Xf(e){return!(e.viewCount>0&&e.viewCount>=Jf||e.bytes>Yf)}var Zf=new Map,Qf=new Map,$f=new Map;function ep(e,t){if($f.size>=qf){let e=$f.keys().next().value;e!==void 0&&$f.delete(e)}$f.set(e,t),X(`ok/cache/snapshot-stored`,{toDocName:e,htmlBytes:t.html.length,hasScroll:t.scrollTop>0,hasSelection:t.selection!==null})}function tp(e){return $f.get(e)??null}function np(e){if(!$f.has(e))return;let t=$f.get(e)??null;$f.delete(e),X(`ok/cache/snapshot-consumed`,{docName:e,hit:t!==null,hasScroll:t!==null&&t.scrollTop>0,hasSelection:t!==null&&t.selection!==null})}function rp(){if(typeof document>`u`)return null;let e=document.querySelectorAll(ip);for(let t of e)if(t.getClientRects().length>0)return t;return null}var ip=`[data-testid="editor-scroll-container"]`;function ap(e){return e.closest(ip)}function op(){try{return rp()?.scrollTop??0}catch(e){return X(`ok/cache/snapshot-scroll-read-failed`,{message:e instanceof Error?e.message:String(e)}),0}}function sp(e){try{let t=e.state.selection;return t instanceof K?{type:`text`,anchor:t.anchor,head:t.head}:t instanceof xe?{type:`node`,from:t.from}:null}catch(e){return X(`ok/cache/snapshot-selection-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}function cp(e){for(let t of e)try{let e=Ap(t.fromDocName);if(e&&!e.editor.isDestroyed){if(e.ytext.length===0){X(`ok/cache/snapshot-skipped-empty`,{fromDocName:t.fromDocName});continue}if(!re(t.toDocName)){X(`ok/cache/snapshot-skipped-class-change`,{fromDocName:t.fromDocName,toDocName:t.toDocName});continue}ep(t.toDocName,{html:e.editor.getHTML(),scrollTop:op(),selection:sp(e.editor)})}else X(`ok/cache/snapshot-skipped`,{fromDocName:t.fromDocName})}catch(e){X(`ok/cache/snapshot-capture-failed`,{fromDocName:t.fromDocName,message:e instanceof Error?e.message:String(e)})}}var lp=[],up=[],dp=new Set;function fp(){if(typeof document>`u`)return null;let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-parking`,``),e.style.display=`none`,e.style.position=`absolute`,e.style.left=`-99999px`,e}function pp(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!Xf(i)){let e=r(n);return X(`ok/cache/miss`,{docName:t,mountId:hf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`}),{editor:e.editor,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=Zf.get(t);if(a){if(X(`ok/cache/reparent-start`,{docName:t,mountId:hf(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Sp(a,n),a.activeMountKey=t,wp(lp,t),vd(t)!==`landing`&&(n.scrollTop=a.scrollTop),a.hadFocus)try{a.editor.commands.focus()}catch{}return X(`ok/cache/reparent-end`,{docName:t,mountId:hf(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),X(`ok/cache/hit`,{docName:t,mountId:hf(t),kind:`tiptap`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:hf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;Zf.size>=qf;){let e=Tp(lp,t);if(!e)break;hp(e)}let o=r(n),s={editor:o.editor,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return Zf.set(t,s),wp(lp,t),X(`ok/cache/miss`,{docName:t,mountId:hf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:hf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function mp(e){let t=e.activeMountKey;if(e.__uncached){t&&Uf(t);let n=Kf(e.editor);try{e.editor.destroy()}catch(e){X(`ok/cache/park-destroy-failed`,{docName:t??``,kind:`tiptap`,stage:`editor`,message:e instanceof Error?e.message:String(e)})}n&&(n.restore=void 0),e.activeMountKey=null;return}let n=bp(e.editor);if(n){e.hadFocus=xp(n.dom),e.scrollTop=(n.scrollDOM??n.dom.parentElement??n.dom).scrollTop??0;let t=n.dom.parentElement;t&&t.removeChild(n.dom),e.parkingNode||=fp(),e.parkingNode&&e.parkingNode.appendChild(n.dom)}e.activeMountKey=null}function hp(e){Uf(e);let t=Zf.get(e);if(!t)return!1;let n=Kf(t.editor);try{t.editor.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`editor`,message:t instanceof Error?t.message:String(t)})}n&&(n.restore=void 0);try{t.provider.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}Zf.delete(e);let r=lp.indexOf(e);return r!==-1&&lp.splice(r,1),X(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function gp(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!Xf(i)){let e=r(n);return X(`ok/cache/miss`,{docName:t,mountId:hf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`,kind:`cm`}),{view:e.view,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,undoManager:e.undoManager,themeCompartment:e.themeCompartment,wordWrapCompartment:e.wordWrapCompartment,placeholderCompartment:e.placeholderCompartment,lintCompartment:e.lintCompartment,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=Qf.get(t);if(a){if(X(`ok/cache/reparent-start`,{docName:t,mountId:hf(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Cp(a,n),a.activeMountKey=t,wp(up,t),vd(t)!==`landing`&&(n.scrollTop=a.scrollTop),a.hadFocus)try{a.view.focus()}catch{}return X(`ok/cache/reparent-end`,{docName:t,mountId:hf(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),X(`ok/cache/hit`,{docName:t,mountId:hf(t),kind:`cm`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:hf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;Qf.size>=qf;){let e=Tp(up,t);if(!e)break;yp(e)}let o=r(n),s={view:o.view,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,undoManager:o.undoManager,themeCompartment:o.themeCompartment,wordWrapCompartment:o.wordWrapCompartment,placeholderCompartment:o.placeholderCompartment,lintCompartment:o.lintCompartment,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return Qf.set(t,s),wp(up,t),X(`ok/cache/miss`,{docName:t,mountId:hf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:hf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function _p(e){if(e.__uncached){try{e.view.destroy()}catch(t){X(`ok/cache/park-destroy-failed`,{docName:e.activeMountKey??``,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}vp(e,e.activeMountKey??``,`park-destroy-failed`),e.activeMountKey=null;return}let t=e.view.dom;e.hadFocus=xp(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t),e.parkingNode||=fp(),e.parkingNode&&e.parkingNode.appendChild(t),e.activeMountKey=null}function vp(e,t,n){let r=e.undoManager;if(r){e.undoManager=void 0;try{r.clear(),r.destroy()}catch(e){X(`ok/cache/${n}`,{docName:t,kind:`cm`,stage:`undo-manager`,message:e instanceof Error?e.message:String(e)})}}}function yp(e){let t=Qf.get(e);if(!t)return!1;Bn(e,t.view);try{t.view.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}vp(t,e,`evict-failed`);try{t.provider.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}Qf.delete(e);let n=up.indexOf(e);return n!==-1&&up.splice(n,1),X(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function bp(e){return e.editorView??null}function xp(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function Sp(e,t){let n=bp(e.editor);if(!n)return;let r=n.dom,i=r.parentElement;i&&i!==t&&i.removeChild(r),r.parentElement!==t&&t.appendChild(r)}function Cp(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function wp(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function Tp(e,t){for(let n of e)if(n!==t&&!dp.has(n))return n;X(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:dp.size});for(let n of e)if(n!==t)return n;return null}function Ep(e){let t=dp,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=Op(e);if(t)try{t.disconnect(),X(`ok/cache/disconnect`,{docName:e})}catch(t){X(`ok/cache/disconnect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}}for(let e of n){if(t.has(e))continue;let n=Op(e);if(!n)continue;let r=t=>{X(`ok/cache/connect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})};try{let t=n.connect();t&&typeof t.then==`function`?t.then(()=>X(`ok/cache/connect`,{docName:e}),e=>r(e)):X(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}dp=n}var Dp=null;function Op(e){let t=Zf.get(e);if(t)return t.provider;let n=Qf.get(e);if(n)return n.provider;if(Dp){let t=Dp.entries.get(e);if(t)return t.provider}return null}function kp(e){Dp=e;let t=e.onEvict(e=>{hp(e),yp(e)});return()=>{t(),Dp===e&&(Dp=null)}}function Ap(e){return Zf.get(e)}var jp=`pane-main`;function Mp(e){return Fp(e)&&!e.includes(`\0doc-tab:`)}function Np(e){return e.startsWith(`\0`)}function Pp(e){return typeof e==`string`&&!!e}function Fp(e){return typeof e==`string`&&!!e}function Ip(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function Lp(e,t=new Set){if(!Array.isArray(e))return[];let n=new Set,r=[];for(let i of e)!Mp(i)||n.has(i)||!Np(i)&&t.has(i)||(n.add(i),Np(i)||t.add(i),r.push(i));return r}function Rp(e,t){if(!Array.isArray(e))return[];let n=new Set(t),r=new Set,i=[];for(let t of e)!Fp(t)||!n.has(t)||r.has(t)||(r.add(t),i.push(t));return i}function zp(e,t){return Fp(t)&&e.includes(t)?t:null}function Bp(e,t,n){if(!t||!n.has(t))return t;let r=e.indexOf(t);for(let t=r+1;t<e.length;t++)if(!n.has(e[t]))return e[t]??null;for(let t=r-1;t>=0;t--)if(!n.has(e[t]))return e[t]??null;return null}function Vp(e,t=new Set){if(!Pp(e.id))return null;let n=Lp(e.openTabs,t),r=Array.isArray(e.newTabIds)?e.newTabIds.filter(e=>Fp(e)&&!n.includes(e)):[],i=zp(n,e.activeTabId),a=Fp(e.activeNewTabId)&&r.includes(e.activeNewTabId)?e.activeNewTabId:null,o=i??(a===null?n[0]??null:null),s=o===null?a??r[0]??null:null,c=Rp(e.pinnedTabIds,n),l=Mp(e.previewTabId)&&n.includes(e.previewTabId)&&!c.includes(e.previewTabId)?e.previewTabId:null;return{id:e.id,openTabs:n,pinnedTabIds:c,activeTabId:o,previewTabId:l,newTabIds:r,activeNewTabId:s,activeTarget:o!==null&&o===i?e.activeTarget??null:null,size:Ip(e.size)?e.size:1}}function Hp(e){if(e.length===0)return[];let t=e.reduce((e,t)=>e+(Ip(t.size)?t.size:0),0);if(t<=0){let t=100/e.length;return e.map(e=>({...e,size:t}))}return e.map(e=>({...e,size:(Ip(e.size)?e.size:0)/t*100}))}function Up(e,t=100){return{id:e,openTabs:[],pinnedTabIds:[],activeTabId:null,previewTabId:null,newTabIds:[],activeNewTabId:null,activeTarget:null,size:t}}function Wp(e=()=>jp){let t=Up(e());return{panes:[t],focusedPaneId:t.id}}function Gp(e){let t=e.panes.map(e=>({...e,previewTabId:null,newTabIds:[],activeNewTabId:null,activeTarget:null}));return{panes:t,focusedPaneId:t.some(t=>t.id===e.focusedPaneId)?e.focusedPaneId:t[0]?.id??jp}}function Kp(e){let t=Jp(e);return{panes:t.panes.map(({id:e,openTabs:t,pinnedTabIds:n,activeTabId:r,size:i})=>({id:e,openTabs:t,pinnedTabIds:n,activeTabId:r,size:i})),focusedPaneId:t.focusedPaneId}}function qp(e,t=()=>jp){let n=()=>{let e=t();return{panes:[{id:e,openTabs:[],pinnedTabIds:[],activeTabId:null,size:100}],focusedPaneId:e}};if(typeof e!=`object`||!e)return n();let r=e;if(!Array.isArray(r.panes))return n();let i=new Set,a=[];for(let[e,t]of r.panes.entries()){if(typeof t!=`object`||!t)continue;let n=t;!Pp(n.id)||i.has(n.id)||(i.add(n.id),a.push({pane:n,id:n.id,visualIndex:e}))}if(a.length===0)return n();let o=Pp(r.focusedPaneId)?r.focusedPaneId:null,s=[...a].sort((e,t)=>e.id===o?-1:t.id===o?1:e.visualIndex-t.visualIndex),c=new Set,l=new Map;for(let{pane:e,id:t}of s){let n=Lp(e.openTabs,c),r=zp(n,e.activeTabId);l.set(t,{id:t,openTabs:n,pinnedTabIds:Rp(e.pinnedTabIds,n),activeTabId:r??n[0]??null,size:Ip(e.size)?e.size:1})}let u=a.flatMap(({id:e})=>{let t=l.get(e);return t&&t.openTabs.length>0?[t]:[]});if(u.length===0)return n();let d=Hp(u);return{panes:d,focusedPaneId:o&&d.some(e=>e.id===o)?o:d[0].id}}function Jp(e){let t=new Set,n=new Set,r=e.panes.flatMap(e=>{if(!Pp(e.id)||t.has(e.id))return[];let r=Vp(e,n);return r?(t.add(r.id),[r]):[]});if(r.length===0)return Wp();let i=Hp(r);return{panes:i,focusedPaneId:i.some(t=>t.id===e.focusedPaneId)?e.focusedPaneId:i[0].id}}function Yp(e){return e.panes.find(t=>t.id===e.focusedPaneId)??e.panes[0]??Up(jp)}function Xp(e,t){return e.panes.some(e=>e.id===t)?{...e,focusedPaneId:t}:e}function Zp(e,t){let n=e.panes.find(t=>t.id===e.focusedPaneId);return n?.openTabs.includes(t)||n?.newTabIds.includes(t)?n:e.panes.find(e=>e.openTabs.includes(t)||e.newTabIds.includes(t))??null}function Qp(e,t){return Mp(t)?Zp(e,t):null}function $p(e){return e.panes.flatMap(e=>e.openTabs)}function em(e){let t=new Set($p(e));return e.panes.flatMap(e=>e.pinnedTabIds.filter(e=>t.has(e)))}function tm(e,t,n){return{...e,panes:e.panes.map(e=>e.id===t?n(e):e)}}function nm(e,t,n){let r=new Map(n.panes.map(e=>[e.id,new Set(e.openTabs)])),i=e;for(let e of t.panes){let t=e.previewTabId;if(!t)continue;let n=i.panes.find(n=>n.id===e.id&&n.openTabs.includes(t))??Qp(i,t);!n||n.pinnedTabIds.includes(t)||r.get(n.id)?.has(t)||(i=tm(i,n.id,e=>({...e,previewTabId:t})))}return i}function rm(e,t,n,r){let i=e.panes.find(e=>e.id===t);if(!i)return e;let a=new Set(i.openTabs),o=n.filter(e=>a.has(e));for(let e of i.openTabs)o.includes(e)||o.push(e);let s=new Set(i.pinnedTabIds),c=o.indexOf(r),l=c>=0&&c<i.pinnedTabIds.length,u=i.openTabs.includes(r)?o.filter(e=>e===r?l:s.has(e)):i.pinnedTabIds;return tm(e,t,e=>({...e,openTabs:o,pinnedTabIds:u,previewTabId:e.previewTabId===r?null:e.previewTabId}))}function im(e,t){let n=e.newTabIds.indexOf(t);if(n>=0){let r=e.newTabIds.filter(e=>e!==t),i=e.activeNewTabId===t,a=i?r[n]??r[n-1]??null:e.activeNewTabId,o=i&&a===null?e.openTabs[e.openTabs.length-1]??null:e.activeTabId;return{...e,newTabIds:r,activeNewTabId:a,activeTabId:o,activeTarget:a===null&&o===e.activeTabId?e.activeTarget:null}}if(e.openTabs.indexOf(t)<0)return e;let r=new Set([t]),i=Bp(e.openTabs,e.activeTabId,r),a=e.activeTabId===t&&i===null?e.activeNewTabId??e.newTabIds[e.newTabIds.length-1]??null:e.activeNewTabId;return{...e,openTabs:e.openTabs.filter(e=>e!==t),pinnedTabIds:e.pinnedTabIds.filter(e=>e!==t),activeTabId:i,activeNewTabId:a,previewTabId:e.previewTabId===t?null:e.previewTabId,activeTarget:a===null&&i===e.activeTabId?e.activeTarget:null}}function am(e){let t=e.panes.filter(e=>e.openTabs.length||e.newTabIds.length);if(t.length===0)return Wp(()=>e.focusedPaneId||jp);let n=Hp(t);return{panes:n,focusedPaneId:n.some(t=>t.id===e.focusedPaneId)?e.focusedPaneId:n[0].id}}function om(e,t){let n=e.panes.flatMap(e=>{let n=new Set([...e.openTabs,...e.newTabIds]),r=(t.get(e.id)??[]).filter((e,t,r)=>n.has(e)&&r.indexOf(e)===t);if(r.length===0)return[];let i=new Set(r),a=e.openTabs.filter(e=>i.has(e)),o=e.newTabIds.filter(e=>i.has(e)),s=(e.activeTabId&&i.has(e.activeTabId)?e.activeTabId:null)??(e.activeNewTabId&&i.has(e.activeNewTabId)?e.activeNewTabId:null)??r[0],c=a.includes(s)?s:null,l=o.includes(s)?s:null;return[{...e,openTabs:a,pinnedTabIds:e.pinnedTabIds.filter(e=>i.has(e)),activeTabId:c,previewTabId:e.previewTabId&&i.has(e.previewTabId)?e.previewTabId:null,newTabIds:o,activeNewTabId:l,activeTarget:c===e.activeTabId?e.activeTarget:null}]});if(n.length===0)return Wp(()=>e.focusedPaneId||jp);let r=Hp(n);return{panes:r,focusedPaneId:r.some(t=>t.id===e.focusedPaneId)?e.focusedPaneId:r[0].id}}function sm(e,t,n){let r=new Set(t),i=Math.max(0,Math.min(n,e.length)),a=0;for(let t=0;t<i;t+=1){let n=e[t];n&&r.has(n)&&(a+=1)}return a}function cm(e,t,n,r){let i=Zp(e,t),a=e.panes.find(e=>e.id===n);if(!i||!a)return e;let o=i.newTabIds.includes(t);if(i.id===a.id){if(o){let a=i.newTabIds.filter(e=>e!==t),o=Math.max(0,Math.min(r,a.length));return tm(e,n,e=>({...e,newTabIds:[...a.slice(0,o),t,...a.slice(o)],activeNewTabId:t,activeTabId:null,activeTarget:null}))}let a=i.openTabs.filter(e=>e!==t),s=Math.max(0,Math.min(r,a.length));return rm(e,n,[...a.slice(0,s),t,...a.slice(s)],t)}let s=i.pinnedTabIds.includes(t),c=im(i,t),l=Math.max(0,Math.min(r,o?a.newTabIds.length:a.openTabs.length)),u=o?{...a,newTabIds:[...a.newTabIds.slice(0,l),t,...a.newTabIds.slice(l)],activeNewTabId:t,activeTabId:null,activeTarget:null}:{...a,openTabs:[...a.openTabs.slice(0,l),t,...a.openTabs.slice(l)],pinnedTabIds:s?[...a.pinnedTabIds,t]:a.pinnedTabIds,activeNewTabId:null,activeTabId:t,activeTarget:null},d=e.panes.map(e=>e.id===i.id?c:e.id===a.id?u:e);return Xp(am({...e,panes:d}),a.id)}function lm(e,t,n,r,i){let a=Zp(e,t),o=e.panes.find(e=>e.id===n);if(!a||!o)return e;if(a.id===o.id&&a.openTabs.length+a.newTabIds.length===1)return Xp(e,a.id);let s=i();if(!Pp(s)||e.panes.some(e=>e.id===s))return e;let c=a.pinnedTabIds.includes(t),l=im(a,t),u=a.id===o.id?l:o,d=u.size/2,f={...u,size:d},p=a.newTabIds.includes(t),m={...Up(s,d),openTabs:p?[]:[t],pinnedTabIds:c&&!p?[t]:[],activeTabId:p?null:t,previewTabId:null,newTabIds:p?[t]:[],activeNewTabId:p?t:null},h=e.panes.map(e=>e.id===a.id?l:e),g=h.findIndex(e=>e.id===o.id);if(g<0)return e;h[g]=f;let _=r===`left`?g:g+1,v=[...h.slice(0,_),m,...h.slice(_)];return Xp(am({...e,panes:v}),s)}function um(e,t,n){let r=new Set(n),i=e.panes.find(e=>e.id===t);if(!i||r.size===0)return e;let a=Bp(i.openTabs,i.activeTabId,r);return am(tm(e,t,e=>{let t={...e,openTabs:e.openTabs.filter(e=>!r.has(e)),pinnedTabIds:e.pinnedTabIds.filter(e=>!r.has(e)),activeTabId:a,previewTabId:e.previewTabId&&r.has(e.previewTabId)?null:e.previewTabId,activeTarget:a===e.activeTabId?e.activeTarget:null};return e.newTabIds.reduce((e,t)=>r.has(t)?im(e,t):e,t)}))}function dm(e,t){let n=new Map,r=new Set;for(let i of e.panes)for(let e of i.openTabs){let a=t(e),o=Mp(a)?a:null;n.set(e,o),o&&!Np(o)&&i.pinnedTabIds.includes(e)&&r.add(o)}let i=new Set,a=e.panes.map(e=>{let t=new Map,a=new Set,o=[];for(let r of e.openTabs){let e=n.get(r);!e||a.has(e)||!Np(e)&&i.has(e)||(a.add(e),Np(e)||i.add(e),t.set(r,e),o.push(e))}let s=new Set(e.pinnedTabIds.flatMap(e=>t.get(e)??[])),c=o.filter(e=>Np(e)?s.has(e):r.has(e)),l=e.activeTabId?t.get(e.activeTabId)??null:null,u=e.previewTabId&&t.get(e.previewTabId)===e.previewTabId?e.previewTabId:null;return{...e,openTabs:o,pinnedTabIds:c,activeTabId:l,previewTabId:u&&!c.includes(u)?u:null,activeTarget:l!==null&&l===e.activeTabId?e.activeTarget:null}});return am({...e,panes:a})}function fm(e,t){return dm(e,e=>t(e)?e:null)}function pm(e){return{workspace:e,openedTabId:null,replacedPreviewTabId:null,consumedNewTabId:null}}function mm(e,t={openedTabId:null,replacedPreviewTabId:null,consumedNewTabId:null}){return{workspace:Jp(e),...t}}function hm(e,t,n){let r=e.panes.find(e=>e.id===t);return r?r.newTabIds.includes(n)?Xp(tm(e,t,e=>({...e,activeTabId:null,activeNewTabId:n,activeTarget:null})),t):r.openTabs.includes(n)?Xp(tm(e,t,e=>({...e,activeTabId:n,activeNewTabId:null,activeTarget:e.activeTabId===n?e.activeTarget:null})),t):e:e}function gm(e,t){switch(t.type){case`open-target`:{if(!Mp(t.tabId))return pm(e);let n=e.panes.find(e=>e.id===t.paneId);if(!n)return pm(e);let r=t.consumeActiveNewTab&&n.activeNewTabId?n.activeNewTabId:null,i=r===null?e:tm(e,n.id,e=>im(e,r)),a=i.panes.find(e=>e.id===t.paneId&&e.openTabs.includes(t.tabId))??Zp(i,t.tabId),o=a!==null&&a.id!==t.paneId&&t.existingTabBehavior===`open-in-pane`&&Np(t.tabId);if(a&&!o)return a.id!==t.paneId&&t.existingTabBehavior===`open-in-pane`?(i=cm(i,t.tabId,t.paneId,n.openTabs.length),i=tm(i,t.paneId,e=>({...e,activeTarget:t.target,previewTabId:t.disposition===`permanent`&&e.previewTabId===t.tabId?null:e.previewTabId})),mm(i,{openedTabId:t.tabId,replacedPreviewTabId:null,consumedNewTabId:r})):(i=tm(i,a.id,e=>({...e,activeTabId:t.tabId,activeNewTabId:null,activeTarget:t.target,previewTabId:t.disposition===`permanent`&&e.previewTabId===t.tabId?null:e.previewTabId})),i=Xp(i,a.id),i=am(i),mm(i,{openedTabId:t.tabId,replacedPreviewTabId:null,consumedNewTabId:r}));let s=i.panes.find(e=>e.id===t.paneId);if(!s)return pm(e);let c=t.disposition===`preview`?s.previewTabId:null;return i=tm(i,t.paneId,e=>{let n=c?e.openTabs.indexOf(c):-1,r=c?e.openTabs.filter(e=>e!==c):e.openTabs,i=n<0?[...r,t.tabId]:[...r.slice(0,n),t.tabId,...r.slice(n)];return{...e,openTabs:i,pinnedTabIds:e.pinnedTabIds.filter(e=>e!==c),activeTabId:t.tabId,activeNewTabId:null,activeTarget:t.target,previewTabId:t.disposition===`preview`?t.tabId:e.previewTabId}}),i=Xp(i,t.paneId),mm(i,{openedTabId:t.tabId,replacedPreviewTabId:c,consumedNewTabId:r})}case`activate-tab`:return mm(hm(e,t.paneId,t.tabId));case`promote-preview`:return mm(tm(e,t.paneId,e=>({...e,previewTabId:e.previewTabId===t.tabId?null:e.previewTabId})));case`promote-all-previews`:return mm({...e,panes:e.panes.map(e=>({...e,previewTabId:null}))});case`open-new-tab`:{if(!Fp(t.tabId))return pm(e);let n=Zp(e,t.tabId);return n?mm(hm(e,n.id,t.tabId)):e.panes.some(e=>e.id===t.paneId)?mm(Xp(tm(e,t.paneId,e=>({...e,newTabIds:[...e.newTabIds,t.tabId],activeTabId:null,activeNewTabId:t.tabId,activeTarget:null})),t.paneId)):pm(e)}case`close-tabs`:return mm(um(e,t.paneId,t.tabIds));case`pin-tab`:return mm(tm(e,t.paneId,e=>e.openTabs.includes(t.tabId)?{...e,pinnedTabIds:e.pinnedTabIds.includes(t.tabId)?e.pinnedTabIds:[...e.pinnedTabIds,t.tabId],previewTabId:e.previewTabId===t.tabId?null:e.previewTabId}:e));case`unpin-tab`:return mm(tm(e,t.paneId,e=>({...e,pinnedTabIds:e.pinnedTabIds.filter(e=>e!==t.tabId)})));case`reorder-tabs`:return mm(rm(e,t.paneId,t.tabIds,t.draggedTabId));case`move-tab`:return mm(cm(e,t.tabId,t.paneId,t.index));case`split-tab`:return mm(lm(e,t.tabId,t.paneId,t.side,()=>t.newPaneId));case`resize-panes`:return t.sizes.length!==e.panes.length||t.sizes.some(e=>!Ip(e))?pm(e):mm({...e,panes:e.panes.map((e,n)=>({...e,size:t.sizes[n]??e.size}))});case`remap-tabs`:return mm(dm(e,t.remap));case`prune-tabs`:return mm(fm(e,t.keep));default:return pm(e)}}function _m(e,t,n=25){return!Pp(t.paneId)||!Fp(t.tabId)||n<=0?[...e]:[t,...e.filter(e=>e.tabId!==t.tabId)].slice(0,n)}function vm(e){return ze.includes(e)}function ym(){return ch(qp(null),null)}var bm=new Set,xm=`ok-editor-tabs-v1:`,Sm=`\0folder:`,Cm=`\0asset:`,wm=`\0skill-file:`,Tm=`\0skill-preview:`,Em=/\.(md|mdx)$/i;function Dm(e){return Em.test(e)?e.replace(Em,``):null}function Om(e,t){let n=Dm(e);return n===null?!1:t.some(t=>t!==e&&Dm(t)===n)}function km(e,t=[]){let n=Km(e);if(n.kind===`asset`&&ie(n.assetPath))return Vm(n.assetPath);if(n.kind!==`doc`||Om(e,t))return e;let r=e,i=Dm(r);for(;i!==null&&i.length>0;)r=i,i=Dm(r);return r}function Am(e,t){return Array.isArray(e)?e.map(e=>typeof e==`string`?km(e,t):e):e}function jm(e){return e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e.openTabs;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]})}function Mm(e){let t={...e},n=Array.isArray(e.panes)?jm(e.panes):[];return Array.isArray(e.panes)&&(t.panes=e.panes.map(e=>{if(typeof e!=`object`||!e)return e;let t=e;return{...t,openTabs:Am(t.openTabs,n),pinnedTabIds:Am(t.pinnedTabIds,n),activeTabId:typeof t.activeTabId==`string`?km(t.activeTabId,n):t.activeTabId}})),t}function Nm(e){if(typeof e!=`string`||e.length===0||e.includes(`\0doc-tab:`))return!1;let t=e;return t.startsWith(Sm)?t.length>8:t.startsWith(Cm)?t.length>7:t.startsWith(wm)?Im(t)!==null:t.startsWith(Tm)?Bm(t)!==null:!0}var Pm=`:`;function Fm(e){let t=e.host===void 0?e.name:`${e.name}${Pm}${e.host}`;return`${wm}${e.scope}/${t}/${e.path}`}function Im(e){if(!e.startsWith(wm))return null;let t=e.slice(12).split(`/`);if(t.length<3)return null;let[n,r,...i]=t,a=i.join(`/`);if(!n||!r||!a||!vm(n))return null;let o=r.indexOf(Pm),s=o===-1?r:r.slice(0,o),c=o===-1?void 0:r.slice(o+1);return s?{scope:n,name:s,path:a,...c?{host:c}:{}}:null}function Lm(e){return`${Tm}${fa(e)}`}function Rm(e,t,n){return t.flavor===`explore`?[]:e.filter(e=>{if(e===n)return!1;let r=Km(e);return r.kind===`skill-preview`&&r.flavor===t.flavor&&r.name===t.name&&r.subtitle===t.subtitle&&r.level===t.level})}function zm(e,t,n,r,i){for(let a of e){let e=Km(a);if(e.kind===`skill-preview`&&e.flavor===t&&e.name===n&&e.subtitle===r&&e.level===i)return a}return null}function Bm(e){return e.startsWith(Tm)?sa(e.slice(15)):null}function Vm(e){return e}function Hm(e){return`${Sm}${e}`}function Um(e){return`${Cm}${e}`}function Wm(e,t){let n=no(e);if(n){let e=Xa(n);return{baseName:e,extension:``,label:e,prefix:``}}let r=Ie(e);if(r){let e=r.rel?r.rel.split(`/`).pop()??r.rel:Xa(r.name);return{baseName:e,extension:``,label:e,prefix:``}}let i=Pe(e);if(i)return{baseName:i.name,extension:``,label:i.name,prefix:``};let a=e.lastIndexOf(`/`),o=a<0?e:e.slice(a+1),s=Em.test(t)&&Em.test(o)?``:t,c=`${o}${s}`;return a<0?{baseName:o,extension:s,label:c,prefix:``}:{baseName:o,extension:s,label:c,prefix:`${e.slice(0,a)}/`}}function Gm(e){switch(e.kind){case`doc`:case`folder-index`:case`large-file`:return Vm(e.docName);case`folder`:return Hm(e.folderPath);case`missing`:return Vm(e.target);case`asset`:return Um(e.assetPath);case`skill-file`:return Fm(e);case`skills`:return null;case`skill-preview`:return Lm(e)}}function Km(e){let t=e;if(t.startsWith(Sm))return{kind:`folder`,folderPath:t.slice(8)};if(t.startsWith(Cm))return{kind:`asset`,assetPath:t.slice(7)};let n=Bm(t);if(n)return{kind:`skill-preview`,...n};let r=Im(t);return r?{kind:`skill-file`,...r}:{kind:`doc`,docName:t}}function qm(e){let t=Km(e);return t.kind===`doc`?t.docName:null}function Jm(e,t){return e===`suppressed`?!1:e===`applied`||t>0}function Ym(e){return Le(e)!=null||Re(e)?.kind===`skill`||Ie(e)!=null}var Xm=/(?:^|\/)\.[A-Za-z0-9_-]+\/skills\/[^/]+\/.+$/;function Zm(e){if(Xm.test(e))return!0;let t=vo();if(t.size===0)return!1;for(let n=e.lastIndexOf(`/`);n>0;n=e.lastIndexOf(`/`,n-1))if(t.has(e.slice(0,n)))return!0;return!1}function Qm(e,t){if(!Array.isArray(e)||t<=0)return[];let n=[],r=new Set;for(let i of e)if(Nm(i)&&!r.has(i)&&(r.add(i),n.push(i),n.length>=t))break;return n}function $m(e,t,n){if(t<=0)return[];let r=new Set(Qm(n,2**53-1)),i=Qm(e,2**53-1);if(r.size===0&&i.length<=t)return i;let a=[],o=0;for(let e=i.length-1;e>=0;e--){let n=i[e];if(r.has(n)){a.push(n);continue}o>=t||(o++,a.push(n))}return a.reverse()}function eh(e,t){let n=new Set(Qm(t,2**53-1));return Qm(e,2**53-1).filter(e=>!n.has(e))}function th(e,t,n){let r=Qm(t,2**53-1),i=new Set(r),a=new Set(n),o=new Set,s=[];for(let t of e)o.has(t)||!i.has(t)&&!a.has(t)||(o.add(t),s.push(t));for(let e of[...r,...n])o.has(e)||(o.add(e),s.push(e));return s}function nh(e,{pages:t,folderPaths:n,assetPaths:r,filePaths:i,keepMissingDocName:a=null,keepHashDocName:o=null,keepFolderPaths:s=bm}){return Qm(e,2**53-1).filter(e=>{let c=Km(e);if(c.kind===`folder`)return oo(n,c.folderPath)!==void 0||s.has(c.folderPath);if(c.kind===`asset`)return oo(r,c.assetPath)!==void 0||i!==void 0&&oo(i,c.assetPath)!==void 0;if(c.kind===`skill-file`||c.kind===`skill-preview`||c.kind===`doc`&&Le(c.docName)?.kind===`skill`)return!0;let l=Dm(c.docName);return t.has(c.docName)||l!==null&&t.has(l)||Fe(c.docName)||Pe(c.docName)!==null||c.docName===a||c.docName===o})}function rh(e,t,n,r=[],i=[],a=[]){if(t.length===0&&r.length===0&&a.length===0)return Qm(e,n);let o=new Map(t.map(e=>[e.fromDocName,e.toDocName])),s=new Map(a.flatMap(e=>{let t=Dm(e.fromPath);return t?[[t,e.toPath]]:[]})),c=new Map(a.flatMap(e=>{let t=Dm(e.toPath);return t?[[e.fromPath,t]]:[]})),l=e=>oh(ah(e,r),a),u=(e,t)=>{let n=o.get(e);if(n)return n;let r=s.get(e);return r?Um(r):t},d=e=>{let t=c.get(e);return t?Vm(t):Um(l(e))},f=[],p=new Set;for(let t of e){if(!Nm(t))continue;let e=Km(t),a=e.kind===`doc`?u(e.docName,t):e.kind===`folder`?Hm(ah(e.folderPath,r)):e.kind===`asset`?d(e.assetPath):t;if(!p.has(a)&&(p.add(a),f.push(a),i.length===0&&f.length>=n))break}return i.length===0?f:$m(f,n,i.flatMap(e=>{if(!Nm(e))return[];let t=Km(e);return[t.kind===`doc`?u(t.docName,e):t.kind===`folder`?Hm(ah(t.folderPath,r)):t.kind===`asset`?d(t.assetPath):e]}))}function ih(e,t,n=[],r=[]){return rh(e,t,2**53-1,n,[],r)}function ah(e,t){for(let{fromPath:n,toPath:r}of t){if(e===n)return r;if(e.startsWith(`${n}/`))return`${r}${e.slice(n.length)}`}return e}function oh(e,t){for(let{fromPath:n,toPath:r}of t)if(e===n)return r;return e}function sh(e){if(typeof e!=`object`||!e)return ym();let t=Mm(e);return Array.isArray(t.panes)?ch(qp(t),typeof t.updatedAt==`string`?t.updatedAt:null):ym()}function ch(e,t){return{updatedAt:t,panes:e.panes,focusedPaneId:e.focusedPaneId}}function lh(e,t=()=>new Date){return ch(Kp(e),t().toISOString())}function uh(e){return`${xm}${e}`}function dh(e,t){return e===`editor`||e===`note`?null:uh(t)}function fh(e,t){if(!e)return ym();try{let n=e.getItem(t);return n?sh(JSON.parse(n)):ym()}catch(e){return console.warn(`[editor-tabs] failed to read local tab session:`,e),ym()}}function ph(e,t,n){if(e)try{e.setItem(t,JSON.stringify(sh(n)))}catch(e){console.warn(`[editor-tabs] failed to write local tab session:`,e)}}var mh=null;function hh(e){return mh=e,()=>{mh===e&&(mh=null)}}function gh(e){e&&mh?.(e)}function _h(e){e&&gh(Vm(e))}function vh(e,t){let n=e=>(e.ok&&_h(t),e);return{...e,current:()=>e.current(),subscribe:t=>e.subscribe(t),dispose:()=>e.dispose(),patch:t=>n(e.patch(t)),rename:(t,r,i)=>n(e.rename(t,r,i)),reorder:t=>n(e.reorder(t)),patchPath:(t,r)=>n(e.patchPath(t,r)),deletePath:t=>n(e.deletePath(t)),renamePath:(t,r,i)=>n(e.renamePath(t,r,i)),reorderPath:(t,r)=>n(e.reorderPath(t,r)),reorderSeqPath:(t,r)=>n(e.reorderSeqPath(t,r))}}function yh(e){return e.docChanged?vn(e):!1}function bh(e){return e.docChanged?e.transactions.some(e=>e.annotation(bo.userEvent)!==void 0):!1}var xh=`epoch`,Sh=e=>Ea((t,n)=>{e.onerror=e=>n(Error(e.target.error)),e.onsuccess=e=>t(e.target.result)}),Ch=(e,t)=>Ea((n,r)=>{let i=indexedDB.open(e);i.onupgradeneeded=e=>t(e.target.result),i.onerror=e=>r(Oa(e.target.error)),i.onsuccess=e=>{let t=e.target.result;t.onversionchange=()=>{t.close()},n(t)}}),wh=e=>Sh(indexedDB.deleteDatabase(e)),Th=(e,t)=>t.forEach(t=>e.createObjectStore.apply(e,t)),Eh=(e,t,n=`readwrite`)=>{let r=e.transaction(t,n);return t.map(e=>Lh(r,e))},Dh=(e,t)=>Sh(e.count(t)),Oh=(e,t)=>Sh(e.get(t)),kh=(e,t)=>Sh(e.delete(t)),Ah=(e,t,n)=>Sh(e.put(t,n)),jh=(e,t)=>Sh(e.add(t)),Mh=(e,t,n)=>Sh(e.getAll(t,n)),Nh=(e,t,n)=>{let r=null;return Ih(e,t,e=>(r=e,!1),n).then(()=>r)},Ph=(e,t=null)=>Nh(e,t,`prev`),Fh=(e,t)=>Ea((n,r)=>{e.onerror=r,e.onsuccess=async e=>{let r=e.target.result;if(r===null||await t(r)===!1)return n();r.continue()}}),Ih=(e,t,n,r=`next`)=>Fh(e.openKeyCursor(t,r),e=>n(e.key)),Lh=(e,t)=>e.objectStore(t),Rh=(e,t)=>IDBKeyRange.upperBound(e,t),zh=(e,t)=>IDBKeyRange.lowerBound(e,t),Bh=`custom`,Vh=`updates`,Hh=(e,t=()=>{},n=()=>{})=>{let[r]=Eh(e.db,[Vh]);return Mh(r,zh(e._dbref,!1)).then(i=>{e._destroyed||(t(r),Ca(e.doc,()=>{i.forEach(t=>Pa(e.doc,t))},e,!1),n(r))}).then(()=>Ph(r).then(t=>{e._dbref=t+1})).then(()=>Dh(r).then(t=>{e._dbsize=t})).then(()=>r)},Uh=(e,t=!0)=>Hh(e).then(n=>{(t||e._dbsize>=500)&&jh(n,wa(e.doc)).then(()=>kh(n,Rh(e._dbref,!0))).then(()=>Dh(n).then(t=>{e._dbsize=t}))}),Wh=class extends Da{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=Ch(e,e=>Th(e,[[`updates`,{autoIncrement:!0}],[`custom`]])),this.whenSynced=Ea(e=>this.on(`synced`,()=>e(this))),this._db.then(e=>{this.db=e,Hh(this,async e=>{await Dh(e)>0&&jh(e,wa(t))},()=>{if(this._destroyed)return this;this.synced=!0,this.emit(`synced`,[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(e,t)=>{if(this.db&&t!==this){let[t]=Eh(this.db,[Vh]);jh(t,e).catch(e=>{globalThis.__okYdbWriteWarned||(globalThis.__okYdbWriteWarned=!0,console.warn(JSON.stringify({event:`ok-ydb-write-failed`,cause:e?.name??`unknown`,message:e?.message??String(e)})))}),++this._dbsize>=500&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{Uh(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on(`update`,this._storeUpdate),this.destroy=this.destroy.bind(this),t.on(`destroy`,this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off(`update`,this._storeUpdate),this.doc.off(`destroy`,this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{wh(this.name)})}get(e){return this._db.then(t=>{let[n]=Eh(t,[Bh],`readonly`);return Oh(n,e)})}set(e,t){return this._db.then(n=>{let[r]=Eh(n,[Bh]);return Ah(r,t,e)})}del(e){return this._db.then(t=>{let[n]=Eh(t,[Bh]);return kh(n,e)})}},Gh=`updates`,Kh=`custom`;function qh(){return!0}var Jh=class{_idb;_dbName;whenSynced;constructor({branch:e,serverInstanceId:t,docName:n,doc:r}){if(typeof t!=`string`||t.length===0)throw Error(`createClientPersistence: serverInstanceId is required and must be non-empty`);this._dbName=`ok-ydoc:${e}:${t}:${n}`;let i=qh()?0:performance.now();this._idb=new Wh(this._dbName,r),this.whenSynced=this._idb.whenSynced.then(()=>{if(!qh()){let e=performance.now();X(`ok/pool/idb-whensynced`,{docName:n,durationMs:Math.round((e-i)*1e3)/1e3},{startTime:i,duration:e-i})}return this})}get synced(){return this._idb.synced}async destroy(){let e=qh()?0:performance.now();try{await this._idb.destroy()}finally{if(!qh()){let t=performance.now();X(`ok/pool/idb-destroy`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}async flushFullState(){this._idb.db===null&&await this.whenSynced;let e=this._idb.db;if(e===null)return;let t=this._idb;await new Promise((n,r)=>{let i=e.transaction(Gh,`readwrite`),a=i.objectStore(Gh),o=a.getAll();o.onerror=()=>r(o.error??Error(`flushFullState getAll failed`)),o.onsuccess=()=>{try{Ca(t.doc,()=>{for(let e of o.result)Pa(t.doc,e)},t,!1);let e=a.add(wa(t.doc));e.onerror=()=>r(e.error??Error(`flushFullState add failed`)),e.onsuccess=()=>{a.delete(IDBKeyRange.upperBound(e.result,!0)),typeof i.commit==`function`&&i.commit()}}catch(e){r(e instanceof Error?e:Error(String(e)));try{i.abort()}catch{}}},i.oncomplete=()=>n(),i.onabort=()=>r(i.error??Error(`flushFullState transaction aborted`))})}async clearData(){let e=qh()?0:performance.now();try{await this._idb.destroy();let e=this._dbName;await new Promise((t,n)=>{let r=indexedDB.deleteDatabase(e);r.onsuccess=()=>t(),r.onerror=()=>n(r.error),r.onblocked=()=>{console.warn(JSON.stringify({event:`ok-client-persistence-clear-blocked`,dbName:e}))}})}finally{if(!qh()){let t=performance.now();X(`ok/pool/idb-cleardata`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}};function Yh(e){return new Jh(e)}async function Xh(e){if(typeof indexedDB>`u`)return null;let t=`ok-ydoc:${e.branch}:${e.serverInstanceId}:${e.docName}`;if(typeof indexedDB.databases==`function`&&!(await indexedDB.databases()).some(e=>e.name===t))return null;let n=await new Promise((e,n)=>{let r=indexedDB.open(t);r.onupgradeneeded=()=>{let e=r.result;e.objectStoreNames.contains(Gh)||e.createObjectStore(Gh,{autoIncrement:!0}),e.objectStoreNames.contains(Kh)||e.createObjectStore(Kh)},r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)});try{if(!n.objectStoreNames.contains(Gh))return null;let e=await new Promise((e,t)=>{let r=n.transaction(Gh,`readonly`).objectStore(Gh).getAll();r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)});if(e.length===0)return null;let t=new Na;try{Ca(t,()=>{for(let n of e)Pa(t,n)});let n=t.getMap(`lifecycle`).get(xh);return typeof n==`string`&&n.length>0?n:null}finally{t.destroy()}}finally{n.close()}}function Zh(e){return Aa(e)}function Qh(e,t){return t===null?wa(e):wa(e,t)}function $h(e,t){if(e===null)return t;if(t===null)return e;let n=Sa(e),r=Sa(t),i=new Map;for(let[e,t]of n)i.set(e,t);for(let[e,t]of r){let n=i.get(e);(n===void 0||t>n)&&i.set(e,t)}return Aa(i)}function eg(e){let t={};if(Ra.inject(za.active(),t),!t.traceparent)return e;let n=e.includes(`?`)?`&`:`?`,r=[`traceparent=${encodeURIComponent(t.traceparent)}`];return t.tracestate&&r.push(`tracestate=${encodeURIComponent(t.tracestate)}`),`${e}${n}${r.join(`&`)}`}var tg=({key:e,editor:t,onPaste:n,onDrop:r,allowedMimeTypes:i})=>new J({key:e||new G(`fileHandler`),props:{handleDrop(e,n){if(!r||!n.dataTransfer?.files.length)return!1;let a=e.posAtCoords({left:n.clientX,top:n.clientY}),o=Array.from(n.dataTransfer.files);return i&&(o=o.filter(e=>i.includes(e.type))),o.length===0?!1:(n.preventDefault(),n.stopPropagation(),r(t,o,a?.pos||0),!0)},handlePaste(e,r){if(!n||!r.clipboardData?.files.length)return!1;let a=Array.from(r.clipboardData.files),o=r.clipboardData.getData(`text/html`);return i&&(a=a.filter(e=>i.includes(e.type))),!(a.length===0||(r.preventDefault(),r.stopPropagation(),n(t,a,o),o.length>0))}}}),ng=_e.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[tg({key:new G(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}});function rg(e,t){let{state:n,view:r}=e;if(!n.selection.empty||!r.endOfTextblock(t))return!1;let i=n.selection.$head,a=t===`down`||t===`right`,o=null,s=-1;if(a){let e=i.after();if(e>=n.doc.content.size)return!1;o=n.doc.nodeAt(e),s=e}else{let e=i.before();if(e<=0||(o=n.doc.resolve(e).nodeBefore,!o))return!1;s=e-o.nodeSize}if(!o||o.type.name!==`jsxComponent`||o.childCount!==0||!xe.isSelectable(o))return!1;try{let t=xe.create(n.doc,s);return e.view.dispatch(n.tr.setSelection(t).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Yr(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L0`,reason:e.message.slice(0,500)})),!0}}function ig(e){let{state:t,view:n}=e;if(!(t.selection instanceof K)||!t.selection.empty||!n.endOfTextblock(`up`))return!1;let r=t.selection.$head,i=-1;for(let e=r.depth-1;e>=1;e--)if(r.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;for(let e=r.depth;e>i;e--)if(r.index(e-1)!==0)return!1;let a=r.before(i);try{let n=t.doc.resolve(a),r=ve.findFrom(n,-1,!0);return!r||!(r instanceof K)?!1:(e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return Yr(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2c`,reason:e.message.slice(0,500)})),!0}}function ag(e,t){let{state:n,view:r}=e;if(!(n.selection instanceof K)||!n.selection.empty||!r.endOfTextblock(t))return!1;let i=n.selection.$head,a=t===`down`||t===`right`,o=null,s=-1;if(a){let e=i.after();if(e>=n.doc.content.size)return!1;o=n.doc.nodeAt(e),s=e}else{let e=i.before();if(e<=0||(o=n.doc.resolve(e).nodeBefore,!o))return!1;s=e-o.nodeSize}if(!o||o.type.name!==`jsxComponent`||o.childCount===0)return!1;let c=s+o.nodeSize;try{let t=a?s+1:c-1,r=ve.findFrom(n.doc.resolve(t),a?1:-1,!0);return!r||!(r instanceof K)||r.$head.pos<=s||r.$head.pos>=c?!1:(e.view.dispatch(n.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return Yr(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L2d`,reason:e.message.slice(0,500)})),!0}}var og=_e.create({name:`keyboardNav`,priority:50,addKeyboardShortcuts(){return{Escape:({editor:e})=>{let{state:t}=e;if(t.selection instanceof xe){if(t.selection.$from.depth===0)return e.commands.blur(),!0;let n=t.selection.from+t.selection.node.nodeSize,r=t.doc.resolve(Math.min(n,t.doc.content.size)),i=K.near(r);return e.view.dispatch(t.tr.setSelection(i)),!0}return t.selection instanceof K?e.commands.selectParentNode():!1},ArrowUp:({editor:e})=>{if(rg(e,`up`)||ig(e)||ag(e,`up`))return!0;let{state:t}=e;if(!(t.selection instanceof xe))return!1;let n=t.selection.from,r=t.doc.resolve(n);if(r.index(r.depth)===0)return!1;let i=r.before(r.depth);if(i<=0)return!1;let a=t.doc.resolve(i-1).nodeBefore;if(!a||i-1-a.nodeSize+1<0)return!1;try{let n=xe.create(t.doc,i-a.nodeSize);return e.view.dispatch(t.tr.setSelection(n).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Yr(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowDown:({editor:e})=>{if(rg(e,`down`)||ag(e,`down`))return!0;let{state:t}=e;if(!(t.selection instanceof xe))return!1;let n=t.selection.from+t.selection.node.nodeSize;if(n>=t.doc.content.size)return!1;try{if(!t.doc.nodeAt(n))return!1;let r=xe.create(t.doc,n);return e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Yr(`down`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`down`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowLeft:({editor:e})=>rg(e,`left`)||ag(e,`left`),ArrowRight:({editor:e})=>rg(e,`right`)||ag(e,`right`),Enter:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof K)||!t.selection.empty)return!1;let n=t.selection.$from,r=n.parent;if(r.type.name!==`paragraph`||r.textContent!==``||n.depth<2)return!1;let i=-1;for(let e=n.depth-1;e>=1;e--)if(n.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;let a=n.node(i);if(n.index(i)!==a.childCount-1)return!1;let o=n.after(i);if(o>t.doc.content.size)return!1;let s=t.tr,c=n.before(n.depth),l=n.after(n.depth);s.delete(c,l);let u=o-(l-c),d=t.schema.nodes.paragraph.create();s.insert(u,d);let f=u+1;return s.setSelection(K.create(s.doc,f)),e.view.dispatch(s.scrollIntoView()),!0}}}}),sg={query:``,options:{caseSensitive:!1,wholeWord:!1},activeIndex:0,matches:[]},cg=/[A-Za-z0-9_]/;function lg(e){return e!==void 0&&cg.test(e)}function ug(e,t,n){return!lg(e[t-1])&&!lg(e[n])}function dg(e,t,n){if(t.length===0)return[];let r=n.caseSensitive?e:e.toLocaleLowerCase(),i=n.caseSensitive?t:t.toLocaleLowerCase(),a=[],o=0;for(;o<=r.length-i.length;){let t=r.indexOf(i,o);if(t===-1)break;let s=t+i.length;(!n.wholeWord||ug(e,t,s))&&a.push({start:t,end:s,text:e.slice(t,s)}),o=s}return a}function fg(e,t,n){if(t.length===0)return[];let r=[];return e.descendants((e,i)=>{if(!(!e.isText||typeof e.text!=`string`))for(let a of dg(e.text,t,n))r.push({from:i+a.start,to:i+a.end,text:a.text})}),r}var pg=new G(`findReplace`);function mg(e,t){return t<=0||!Number.isFinite(e)?0:Math.min(Math.max(Math.trunc(e),0),t-1)}function hg(e,t,n,r){let i=fg(e.doc,t,n);return{query:t,options:n,activeIndex:mg(r,i.length),matches:i}}function gg(e,t,n){return t<=0?0:(mg(e,t)+n+t)%t}function _g(e,t,n){if(e.length===0)return 0;let r=t+n,i=e.findIndex(e=>e.from>=r);return i===-1?0:i}function vg(e,t,n){if(t.matches.length===0)return null;let r=e.tr;for(let e of[...t.matches].reverse())r.insertText(n,e.from,e.to);let i=fg(r.doc,t.query,t.options),a=mg(0,i.length),o=i[a];return r.setMeta(pg,{type:`setActiveIndex`,activeIndex:a}),o&&r.setSelection(K.create(r.doc,o.from,o.to)),r.scrollIntoView()}function yg(e,t){let n=pg.getState(e)?.matches[t];return n?e.tr.setMeta(pg,{type:`setActiveIndex`,activeIndex:t}).setSelection(K.create(e.doc,n.from,n.to)).scrollIntoView():null}function bg(e){return pg.getState(e)??sg}function xg(){return new J({key:pg,state:{init:()=>sg,apply(e,t,n,r){let i=e.getMeta(pg);if(i?.type===`clear`)return sg;let a=t.query,o=t.options,s=t.activeIndex;if(i?.type===`setQuery`)a=i.query,o={...o,...i.options},s=i.activeIndex??0;else if(i?.type===`setOptions`)o={...o,...i.options},s=i.activeIndex??s;else if(i?.type===`setActiveIndex`)s=i.activeIndex;else if(!e.docChanged)return t;return a.length===0?{query:a,options:o,activeIndex:0,matches:[]}:hg(r,a,o,s)}},props:{decorations(e){let t=pg.getState(e);return!t||t.matches.length===0?null:U.create(e.doc,t.matches.map((e,n)=>W.inline(e.from,e.to,{class:n===t.activeIndex?`ok-find-match ok-find-match-active`:`ok-find-match`})))}}})}var Sg=_e.create({name:`findReplace`,addCommands(){return{setFindQuery:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(pg,{type:`setQuery`,query:e,options:t?.options,activeIndex:t?.activeIndex})),!0),setFindOptions:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(pg,{type:`setOptions`,options:e,activeIndex:t})),!0),setActiveFindIndex:e=>({state:t,dispatch:n})=>(n&&n(t.tr.setMeta(pg,{type:`setActiveIndex`,activeIndex:e})),!0),selectNextFindMatch:()=>({state:e,dispatch:t})=>{let n=bg(e),r=yg(e,gg(n.activeIndex,n.matches.length,1));return r?(t?.(r),!0):!1},selectPreviousFindMatch:()=>({state:e,dispatch:t})=>{let n=bg(e),r=yg(e,gg(n.activeIndex,n.matches.length,-1));return r?(t?.(r),!0):!1},replaceCurrentFindMatch:e=>({state:t,dispatch:n})=>{let r=bg(t),i=r.matches[r.activeIndex];if(!i||!n)return!1;let a=t.tr.insertText(e,i.from,i.to),o=fg(a.doc,r.query,r.options),s=_g(o,i.from,e.length),c=o[s];return a.setMeta(pg,{type:`setActiveIndex`,activeIndex:s}),c&&a.setSelection(K.create(a.doc,c.from,c.to)),a.scrollIntoView(),n(a),!0},replaceAllFindMatches:e=>({state:t,dispatch:n})=>{let r=bg(t);if(!n)return!1;let i=vg(t,r,e);return i?(n(i),!0):!1},clearFindMatches:()=>({state:e,dispatch:t})=>(t&&t(e.tr.setMeta(pg,{type:`clear`})),!0)}},addProseMirrorPlugins(){return[xg()]}}),Cg=/^(https?:\/\/|www(?=\.))((?:[-.\w]|[^\s\p{P}\p{S}\p{Cc}])+)([^ \t\r\n]*)/iu,wg=/^([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/,Tg=/[-\d_]$/,Eg=/[\p{L}\p{N}]/u,Dg=Ji.map(e=>`${e}:`);function Og(e){let t=e.toLowerCase();return Dg.some(e=>t.startsWith(e))}function kg(e,t){let n=0;for(let r of e)r===t&&n++;return n}function Ag(e){let t=e.split(`.`),n=t[t.length-1],r=t[t.length-2];return!(n&&(/_/.test(n)||!Eg.test(n))||r&&(/_/.test(r)||!Eg.test(r)))}function jg(e){return e.split(`.`).length>=2&&Ag(e)}function Mg(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,``];let n=e.slice(0,t.index),r=t[0],i=r.indexOf(`)`),a=kg(n,`(`),o=kg(n,`)`);for(;i!==-1&&a>o;)n+=r.slice(0,i+1),r=r.slice(i+1),i=r.indexOf(`)`),o++;return[n,r]}function Ng(e){let t=Cg.exec(e);if(!t)return null;let n=t[1],r=t[2],i=t[3],a=``,o=/^w/i.test(n);if(o&&(r=n+r,n=``,a=`http://`),o?!jg(r):!Ag(r))return null;let[s]=Mg(r+i);if(!s)return null;let c=n+s,l=a+n+s;return Og(l)?{href:l,text:c}:null}function Pg(e){let t=wg.exec(e);if(!t)return null;let n=t[1],r=t[2];if(Tg.test(r))return null;let i=`${n}@${r}`,a=`mailto:${i}`;return Og(a)?{href:a,text:i}:null}function Fg(e){return e?Ng(e)??Pg(e):null}function Ig(e,t){let n=Dn.getState(e.state)?.undoManager;n?.stopCapturing();try{e.dispatch(t)}finally{n?.stopCapturing()}}var Lg=`\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000`,Rg=RegExp(`[${Lg}]`),zg=RegExp(`[${Lg}]$`),Bg=`link`,Vg=`gfm-autolink`,Hg=`preventAutolink`,Ug=new G(`gfmAutolink`);function Wg(e,t,n){let r=[],i=Ee(de(e.doc,[...n]));for(let{newRange:e}of i){let n=pe(t.doc,e,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=t.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length===1){let r=t.doc.textBetween(e.from,e.to,` `,` `);if(!zg.test(r))continue;i=n[0],a=t.doc.textBetween(i.pos,e.to,void 0,` `)}if(!i||!a||In(i.node))continue;let o=a.split(Rg).filter(Boolean),s=o[o.length-1];if(!s)continue;let c=Fg(s);if(!c)continue;let l=i.pos+a.lastIndexOf(s)+1,u=l+c.text.length;r.push({from:l,to:u,href:c.href,text:c.text})}return r}function Gg(e={}){let t=e.isActiveEditor??(e=>e.hasFocus()),n=null,r=!1,i=[],a=()=>{r=!1;let e=n,a=i.splice(0,i.length);if(!e||e.isDestroyed||e.composing||!t(e))return;let o=e.state.schema.marks[Bg];if(!o)return;let s=e.state.tr,c=!1,l=e.state.doc.content.size;for(let t of a){let{from:n,to:r,href:i,text:a}=t;n<0||r>l||n>=r||e.state.doc.textBetween(n,r)===a&&(Te(n,r,e.state.doc).some(e=>e.mark.type===o)||en(e.state,n,r)||(s=s.addMark(n,r,o.create({href:i,linkStyle:Vg})),c=!0))}if(c){s=s.setMeta(Hg,!0);try{Ig(e,s)}catch(e){console.warn(`[gfm-autolink] linkify dispatch failed`,{candidates:a.map(e=>({from:e.from,to:e.to,href:e.href}))},e)}}};return new J({key:Ug,view(e){return n=e,{destroy(){n=null,i.length=0,r=!1}}},appendTransaction(e,o,s){if(!e.every(vn)||e.some(e=>e.getMeta(`preventAutolink`))||!(e.some(e=>e.docChanged)&&!o.doc.eq(s.doc))||!n||!t(n))return null;let c=Wg(o,s,e);return c.length===0?null:(i.push(...c),r||(r=!0,queueMicrotask(a)),null)}})}var Kg=_e.create({name:`gfmAutolink`,addOptions(){return{isActiveEditor:void 0}},addProseMirrorPlugins(){return[Gg({isActiveEditor:this.options.isActiveEditor})]}});function qg(){return Y._({id:`jTVuAv`})}var Jg=1e3,Yg=class extends Error{kind;constructor(e,t){super(e),this.name=`UploadFailedError`,this.kind=t}},Xg=class extends Error{constructor(e){super(e),this.name=`UploadRejectedError`}};async function Zg(e,t,n=Jg){if(t<=0)return{readable:!0,bytesRead:0};let r,i=new Promise(e=>{r=setTimeout(()=>e({readable:!1,bytesRead:0,timedOut:!0}),n)}),a=(async()=>{try{let t=await e.slice(0,1).arrayBuffer();return{readable:t.byteLength===1,bytesRead:t.byteLength}}catch(e){return{readable:!1,bytesRead:0,error:e instanceof Error?`${e.name}: ${e.message}`:String(e)}}})();try{return await Promise.race([a,i])}finally{clearTimeout(r)}}function Qg(e){return`\u2066${e}\u2069`}function $g(e){let t=Xe.safeParse(e.attachmentFolderIssue);if(!t.success)return null;let n=t.data;switch(n.kind){case`unknown-variable`:{let e=Qg(n.variables.join(`, `));return Y._({id:`FekgdG`,values:{variables:e}})}case`unclosed-braces`:{let e=Qg(`{{`),t=Qg(`}}`);return Y._({id:`uxk3-0`,values:{open:e,close:t}})}case`repeated-variable`:{let e=Qg(`{{filename}}`);return Y._({id:`ZQkkg7`,values:{filenameVariable:e}})}case`invalid-config`:{let e=Qg(`content.attachmentFolderPath`),t=Qg(`.ok/config.yml`);return Y._({id:`8uJ0VX`,values:{settingKey:e,configFile:t}})}}}function e_(e){return e.readable?`network`:`file-unreadable`}function t_(e,t){return e===`single-file-mode`?qg():e===`file-unreadable`?Y._({id:`YxZDGh`,values:{fileName:t}}):Y._({id:`H0VUMo`,values:{fileName:t}})}async function n_(e){let{file:t,sizeAtDrop:n,error:r}=e,i=await Zg(t,n),a=e_(i);return{kind:a,message:t_(a,t.name),log:{kind:a,name:t.name,type:t.type,sizeAtDrop:n,sizeAtSend:t.size,bytesRead:i.bytesRead,readError:i.error,readTimedOut:i.timedOut,error:r instanceof Error?`${r.name}: ${r.message}`:String(r)}}}var r_=new G(`imageUpload`);function i_(e){let t=document.createElement(`div`);t.className=`image-upload-skeleton w-full h-40 rounded-md bg-foreground/10 animate-pulse motion-reduce:animate-none my-2`,t.setAttribute(`data-upload-widget`,`loading`),t.setAttribute(`role`,`status`);let n=e?.name;return t.setAttribute(`aria-label`,n?Y._({id:`KDuPiY`,values:{fileName:n}}):Y._({id:`bGa3Fk`})),t}var a_=new J({key:r_,state:{init(){return{decorations:U.empty,uploads:new Map}},apply(e,t){let n=t.decorations.map(e.mapping,e.doc),r=new Map;for(let[n,i]of t.uploads)r.set(n,e.mapping.map(i));let i=e.getMeta(r_);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=W.widget(i.pos,i.widget,{id:i.id,stopEvent:()=>!0}),a=n.add(e.doc,[t]),o=new Map(r);return o.set(i.id,e.mapping.map(i.pos)),{decorations:a,uploads:o}}if(i.type===`remove`){let e=n.find(void 0,void 0,e=>e.id===i.id),t=n.remove(e),a=new Map(r);return a.delete(i.id),{decorations:t,uploads:a}}return{decorations:n,uploads:r}}},props:{decorations(e){return r_.getState(e)?.decorations??U.empty}}});function o_(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function s_(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function c_(e){return e.split(`/`).filter(e=>e!==``)}function l_(e,t){let n=o_(e),r=o_(t),i=s_(e);if(n===r)return i;let a=c_(r),o=c_(n),s=0;for(;s<a.length&&s<o.length&&a[s]===o[s];)s++;let c=a.length-s,l=o.slice(s);return c===0?`./${[...l,i].join(`/`)}`:[...Array(c).fill(`..`),...l,i].join(`/`)}function u_(e){return Xt(e)}function d_(e,t){return{type:`jsxComponent`,attrs:{componentName:e===`jsx-img`?`img`:e===`jsx-video`?`video`:`audio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:e===`jsx-img`?{src:t}:{src:t,controls:!0}}}}function f_(e){let t=Kt(e);return t===`md`||t===`mdx`?{kind:`wiki-link`,ext:t}:te.has(t)?{kind:`jsx-img`,ext:t}:ne.has(t)?{kind:`jsx-video`,ext:t}:ae.has(t)?{kind:`jsx-audio`,ext:t}:se.has(t)?{kind:`jsx-file`,ext:t}:oe.has(t)?{kind:`wikiembed`,ext:t}:{kind:`markdown-link`,ext:t}}function p_(e){return wn(e)?(z.error(qg()),!1):!0}async function m_(e,t,n){if(!p_(t))return;let r=u_(t),i=r?`${r}.md`:``;if(!i){z.error(Y._({id:`z5pqI8`}));return}let a=Ni(),o=e.size,s=i_(e);t.view.dispatch(t.state.tr.setMeta(r_,{type:`add`,id:a,pos:n,widget:s}));let c=new FormData;c.append(`file`,e),c.append(`parentDocName`,i);let l;try{l=await fetch(`/api/upload`,{method:`POST`,body:c})}catch(n){let r;try{r=await n_({file:e,sizeAtDrop:o,error:n})}catch(e){console.error(`[uploadAndInsert] upload failed, and diagnosing it failed too`,{docName:i,networkError:n,reportError:e})}r&&console.error(`[uploadAndInsert] upload failed before reaching the server`,{...r.log,docName:i}),h_(t,a,r?.message);return}let u;try{u=await l.json()}catch(e){console.error(`[uploadAndInsert] Response is not JSON:`,e),h_(t,a);return}if(!l.ok){let e=Ye.safeParse(u);if(!e.success){let n=new pi(`Upload response did not match ProblemDetails.`,{cause:e.error,status:l.status});console.error(`[uploadAndInsert] Server error (unparseable):`,n),h_(t,a);return}console.error(`[uploadAndInsert] Server error:`,e.data),h_(t,a,$g(e.data)??e.data.title);return}let d=Je.safeParse(u);if(!d.success){let e=new pi(`Upload success response did not match UploadAssetSuccess.`,{cause:d.error,status:l.status});console.error(`[uploadAndInsert] Response missing src:`,e),h_(t,a);return}let f=d.data,p=f.src,m=f.deduped===!0,h=o_(i),g=typeof f.path==`string`&&f.path.length>0?f.path:h?`${h}/${p}`:p;m&&z.info(Y._({id:`VbqhBI`,values:{assetContentPath:g}}));let _=f_(e.name),{state:v}=t,y=r_.getState(v)?.uploads.get(a)??n,b=v.tr.setMeta(r_,{type:`remove`,id:a}),x=l_(g,i),S=`/${g}`;if(_.kind===`jsx-file`){if(!v.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),h_(t,a);return}let n={type:`jsxComponent`,attrs:{componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:{src:S,target:p,alias:null,anchor:null,size:Lr(e.size)}}};t.chain().command(({tr:e})=>(e.setMeta(r_,{type:`remove`,id:a}),!0)).focus().insertContentAt(y,n).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(y);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(xe.create(e.doc,n)),!0}).run();return}if(_.kind===`jsx-img`||_.kind===`jsx-video`||_.kind===`jsx-audio`){if(!v.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),h_(t,a);return}let e=d_(_.kind,S);t.chain().command(({tr:e})=>(e.setMeta(r_,{type:`remove`,id:a}),!0)).focus().insertContentAt(y,e).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(y);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(xe.create(e.doc,n)),!0}).run();return}if(_.kind===`wikiembed`){let e=v.schema.nodes.wikiLinkEmbed;if(!e){console.error(`[uploadAndInsert] wikiLinkEmbed node missing from schema`),h_(t,a);return}b.insert(y,e.create({target:p,alias:null,anchor:null,resolvedSrc:S}))}else if(_.kind===`wiki-link`){let n=v.schema.nodes.wikiLink;if(!n){console.error(`[uploadAndInsert] wikiLink node missing from schema`),h_(t,a);return}let r=Pn(e.name.replace(/\.(md|mdx)$/i,``));r?b.insert(y,n.create(r)):b.insert(y,v.schema.text(e.name))}else{let t=v.schema.marks.link;if(t){let n=v.schema.text(e.name,[t.create({href:x})]);b.insert(y,n)}else b.insert(y,v.schema.text(e.name))}t.view.dispatch(b)}function h_(e,t,n){e.view.dispatch(e.state.tr.setMeta(r_,{type:`remove`,id:t})),z.error(n??Y._({id:`b3Thhd`}))}var g_=/\[([^\]]+)\]\(([^)\s]+)\)$/,__=`link`;function v_(e,t,n,r,i){if(e.isDestroyed||e.composing)return;let{state:a}=e,o=a.schema.marks[__];if(!o)return;let s=t+n.length;if(t<0||s>a.doc.content.size||a.doc.textBetween(t,s)!==n||a.doc.rangeHasMark(t,s,o))return;let c=a.schema.text(r,[o.create({href:i})]);try{Ig(e,a.tr.replaceRangeWith(t,s,c))}catch(e){console.warn(`[inline-link-rule] collapse dispatch failed`,{from:t,text:r,href:i},e)}}var y_=_e.create({name:`inlineLinkInputRule`,addInputRules(){let e=this.editor;return[new be({find:g_,handler:({state:t,range:n,match:r})=>{let i=r[1],a=r[2];if(!i||!a||!dn(a))return null;let o=t.schema.marks[__];if(!o||t.doc.rangeHasMark(n.from,n.to,o))return null;let s=n.from,c=r[0],l=e.view;return queueMicrotask(()=>v_(l,s,c,i,a)),null}})]}}),b_=`mathInline`,x_=/\$\$([^$\n]+)\$\$$/,S_=/(?<![\w$])\$([^\s$\n](?:[^$\n]*[^\s$\n])?)\$$/;function C_(e,t,n){let r=t.exec(e);if(!r)return null;let i=r[1];return i?{formula:i,delimiter:n,literalLength:r[0].length}:null}function w_(e,t,n){if(e.isDestroyed||e.composing)return;let{state:r}=e,i=r.schema.nodes[b_];if(!i)return;let a=t+n.literalLength;if(t<0||a>r.doc.content.size)return;let o=`${n.delimiter}${n.formula}${n.delimiter}`;if(r.doc.textBetween(t,a)!==o)return;let s=!1;if(r.doc.nodesBetween(t,a,e=>(e.isInline&&!e.isText&&(s=!0),!s)),s)return;let c=i.create({formula:n.formula,sourceDelimiter:n.delimiter});try{Ig(e,r.tr.replaceRangeWith(t,a,c))}catch(e){console.warn(`[math-input-rule] collapse dispatch failed`,{from:t,formula:n.formula,delimiter:n.delimiter},e)}}function T_(e,t,n){return new be({find:t,handler:({state:r,range:i,match:a})=>{let o=C_(a[0],t,n);if(!o||!r.schema.nodes[b_])return null;let s=i.from,c=e.view;return queueMicrotask(()=>w_(c,s,o)),null}})}var E_=_e.create({name:`mathInputRule`,addInputRules(){return[T_(this.editor,x_,`$$`),T_(this.editor,S_,`$`)]}}),D_=`ok-landing-flash`;function O_(e,t,n,r){if(r===`clamped`||r===`ordinal`)return null;let i=Math.max(0,Math.min(t,e)),a=Math.max(i,Math.min(n,e));return a<=i?null:{from:i,to:a}}var k_=new G(`okLandingFlash`),A_=new WeakMap;function j_(){return new J({key:k_,state:{init:()=>U.empty,apply(e,t){let n=e.getMeta(k_),r=t.map(e.mapping,e.doc);return n?.clear&&(r=U.empty),n?.add&&n.add.to>n.add.from&&(r=U.create(e.doc,[W.inline(n.add.from,n.add.to,{class:D_})])),r}},props:{decorations(e){return k_.getState(e)}},view(e){return{destroy(){let t=A_.get(e);t!==void 0&&(clearTimeout(t),A_.delete(e))}}}})}var M_=_e.create({name:`okLandingFlash`,addProseMirrorPlugins(){return[j_()]}}),N_=new Set;function P_(e){N_.add(e)}function F_(e){return N_.delete(e)}var I_=new G(`markIdentity`);function L_(){return{byId:new Map,counter:0}}function R_(e,t,n,r,i){let a=[];for(let e of t.byId.values()){let t=i?i.map(e.from,-1):e.from,n=i?i.map(e.to,1):e.to;n<=t||a.push({id:e.id,markType:e.markType,attrs:e.attrs,from:t,to:n})}let o=new Map,s=new Set,c=t.counter;return e.descendants((e,t)=>{if(!(!e.isInline||e.marks.length===0))for(let i of e.marks){if(!n.has(i.type.name)||r&&!r(i))continue;let l=null;for(let e of a)if(!s.has(e.id)&&e.markType===i.type.name&&z_(e.attrs,i.attrs)&&!(t<e.from||t>=e.to)){l=e.id;break}let u=l??`m${++c}`;s.add(u);let d=t,f=t+e.nodeSize,p=o.get(u);p?p.to=Math.max(p.to,f):o.set(u,{id:u,markType:i.type.name,attrs:i.attrs,from:d,to:f})}}),{byId:o,counter:c}}function z_(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(n!==i&&(typeof n!=`object`||!n||typeof i!=`object`||!i||!((Array.isArray(n)&&Array.isArray(i)||!Array.isArray(n)&&!Array.isArray(i)&&Object.getPrototypeOf(n)===Object.prototype&&Object.getPrototypeOf(i)===Object.prototype)&&z_(n,i))))return!1}return!0}function B_(e,t,n,r){let i=new Set(t.byId.keys());for(let[r,i]of t.byId)e.has(r)||n?.(i);for(let t of e)i.has(t)||r?.(t);return i}function V_(e,t,n){let r=I_.getState(e);if(!r)return null;for(let e of r.byId.values())if(e.markType===n&&e.from<=t&&t<e.to)return e.id;return null}function H_(e){let{markTypes:t,predicate:n,onRegister:r,onDeregister:i}=e,a=new Set(t);return new J({key:I_,state:{init(e,t){return R_(t.doc,L_(),a,n)},apply(e,t,r,i){return e.docChanged?R_(i.doc,t,a,n,e.mapping):t}},view(){let e=new Set;return{update(t){let n=I_.getState(t.state);n&&(e=B_(e,n,r,i))},destroy(){for(let t of e)i?.(t);e=new Set}}}})}var U_=300,W_=150,G_=500,K_=class{registry=new Map;_activeNodeId=null;listeners=new Set;_snapshot={activeNodeId:null,active:null};register(e){this.registry.set(e.nodeId,e),this._activeNodeId===e.nodeId&&this.refreshSnapshot()}deregister(e){this.registry.delete(e)&&this._activeNodeId===e&&(this._activeNodeId=null,this.refreshSnapshot())}setActiveNode(e){this._activeNodeId!==e&&(e!==null&&!this.registry.has(e)||(this._activeNodeId=e,this.refreshSnapshot()))}getActiveNode(){return this._activeNodeId}getRegistration(e){return this.registry.get(e)}hasRegistration(e){return this.registry.has(e)}clear(){this.registry.clear(),this._activeNodeId=null,this.refreshSnapshot()}getSnapshot=()=>this._snapshot;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});refreshSnapshot(){let e=this._activeNodeId==null?null:this.registry.get(this._activeNodeId)??null;this._snapshot={activeNodeId:this._activeNodeId,active:e};for(let e of this.listeners)e()}};function q_(e,t){let n=e??null;for(;n&&typeof n==`object`;){let e=n.getAttribute;if(typeof e==`function`){let r=e.call(n,`data-mark-id`);if(r&&t.hasRegistration(r))return r;let i=e.call(n,`data-node-id`);if(i&&t.hasRegistration(i))return i}n=n.parentElement??null}return null}function J_(e){return e?e.closest(`[data-ok-prop-panel]`)!==null:!1}function Y_(){return typeof document>`u`?!1:document.querySelector(`[data-ok-layer-spawned]`)!==null}var X_=e=>{let t=(0,Q.c)(18),{store:n}=e,r;t[0]===n?r=t[1]:(r=()=>n.getSnapshot(),t[0]=n,t[1]=r);let[i,a]=(0,Z.useState)(r),o,s;t[2]===n?(o=t[3],s=t[4]):(o=()=>(a(n.getSnapshot()),n.subscribe(()=>{a(n.getSnapshot())})),s=[n],t[2]=n,t[3]=o,t[4]=s),(0,Z.useEffect)(o,s);let{active:c}=i;if(!c)return null;let l;t[5]===n?l=t[6]:(l=()=>n.setActiveNode(null),t[5]=n,t[6]=l);let u,d,f;if(t[7]!==c.controls||t[8]!==c.nodeId||t[9]!==c.type||t[10]!==l){let e={nodeId:c.nodeId,type:c.type,deactivate:l};u=c.controls.propPanel?.(e),d=c.controls.toolbar?.(e),f=c.controls.breadcrumb?.(e),t[7]=c.controls,t[8]=c.nodeId,t[9]=c.type,t[10]=l,t[11]=u,t[12]=d,t[13]=f}else u=t[11],d=t[12],f=t[13];let p;return t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,$.jsxs)($.Fragment,{children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17],p};function Z_(e){return e.editorView?.dom??null}function Q_(e,t){let n=e;for(;n;){if(n.getAttribute?.(`data-mark-id`)===t||n.getAttribute?.(`data-node-id`)===t)return!0;n=n.parentElement}return!1}function $_(e){let{editor:t}=e,n=new K_,r=Z_(t),i=!1,a=null,o=null,s=null,c=null,l=null,u=()=>{a!==null&&(clearTimeout(a),a=null),s=null},d=()=>{o!==null&&(clearTimeout(o),o=null)},f=()=>{c!==null&&(clearTimeout(c),c=null)},p=e=>{if(n.getActiveNode()===e){d();return}s===e&&a!==null||(u(),d(),s=e,a=setTimeout(()=>{a=null,s=null,n.setActiveNode(e)},U_))},m=()=>{n.getActiveNode()!==null&&o===null&&(o=setTimeout(()=>{o=null,!Y_()&&n.setActiveNode(null)},W_))},h={kind:`none`},g=!1,_=e=>{try{g=!0,e.focus({preventScroll:!0})}catch{}finally{g=!1}},v=n.subscribe(()=>{let e=n.getActiveNode();if(e!==null){if(typeof document<`u`){let t=document.activeElement;h=t&&Q_(t,e)?{kind:`activator`,element:t}:{kind:`none`}}else h={kind:`none`};return}let i=h;if(h={kind:`none`},typeof document>`u`)return;if(i.kind===`none`){if(!document.activeElement?.closest(`[data-ok-prop-panel], [data-ok-layer-spawned], [data-ok-interaction-layer]`))return}else if(document.contains(i.element)&&typeof i.element.focus==`function`){_(i.element);return}let a=r??Z_(t);a&&typeof a.focus==`function`&&_(a)}),y=e=>{let t=e;if(t.button!==2){if(t.metaKey||t.ctrlKey||t.button===1){u(),t.button===1&&t.preventDefault?.();return}if(t.pointerType===`touch`){let t=q_(e.target,n);if(t===null)return;f(),c=setTimeout(()=>{c=null,l=t,n.setActiveNode(t)},G_);return}u()}},b=()=>{f()},x=e=>{e.pointerType===`touch`&&c!==null&&f()},S=e=>{let t=e;if(t.button===2||t.type===`click`&&t.button===1)return;let r=q_(e.target,n);if(r===null)return;if(l!==null){let e=l===r;if(l=null,e){t.preventDefault?.();return}}let i=t.metaKey||t.ctrlKey||t.button===1,a=n.getRegistration(r);if(a?.handlePrimary&&a.handlePrimary({nodeId:r,type:a.type,newTab:i})){t.preventDefault?.(),i||(u(),d(),n.getActiveNode()===r&&n.setActiveNode(null));return}i||(u(),d(),n.setActiveNode(r))},C=e=>{let t=e;if(t.key===`Escape`){n.getActiveNode()!==null&&(u(),d(),n.setActiveNode(null),t.preventDefault?.());return}if(t.key===`Tab`&&!t.shiftKey&&!t.altKey&&!t.metaKey&&!t.ctrlKey){let r=q_(e.target,n);if(r!==null&&n.getActiveNode()===r){let e=document.querySelector(`[data-ok-prop-panel]`);if(e){let n=e.querySelector(`button:not([disabled]), [href], input:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(n){t.preventDefault?.(),n.focus();return}}}return}let r=t.key===`Enter`,i=t.key===` `||t.key===`Spacebar`;if(!r&&!i)return;let a=q_(e.target,n);if(a===null||i&&((e.target instanceof Element?e.target:null)?.closest(`[data-mark-id], [data-node-id]`)??null)?.getAttribute(`role`)===`link`)return;let o=n.getRegistration(a);if(t.preventDefault?.(),o?.handlePrimary&&o.handlePrimary({nodeId:a,type:o.type,newTab:!1})){u(),d(),n.getActiveNode()===a&&n.setActiveNode(null);return}n.setActiveNode(a)},w=e=>{let t=e;if(t.pointerType!==`mouse`)return;let r=t.target;if(!(r instanceof Element))return;if(J_(r)){d();return}let i=q_(r,n);i!==null&&p(i)},T=e=>{let t=e;if(t.pointerType!==`mouse`)return;let r=t.target,i=t.relatedTarget;if(!(r instanceof Element))return;let a=i instanceof Element?i:null,o=q_(r,n);if(o!==null){if(a&&J_(a)){d();return}if(a&&q_(a,n)===o)return;s===o&&u(),m();return}if(J_(r)){if(a&&J_(a))return;let e=n.getActiveNode();if(e!==null&&a&&q_(a,n)===e)return;m()}},E=e=>{if(g)return;let t=e.target;if(!(t instanceof Element))return;let r=q_(t,n);r!==null&&(u(),d(),n.setActiveNode(r))},D=e=>{let t=e;if(n.getActiveNode()===null)return;let r=t.relatedTarget,i=r instanceof Element?r:null;i&&J_(i)||i&&q_(i,n)!==null||m()},O=e=>{if(n.getActiveNode()===null)return;let t=e.target;t&&(r?.contains(t)||t instanceof Element&&(t.closest(`[data-ok-interaction-layer]`)||t.closest(`[data-ok-prop-panel]`)||t.closest(`[data-ok-layer-spawned]`))||(u(),d(),n.setActiveNode(null)))},k=()=>{i||(r=Z_(t),r&&(r.addEventListener(`pointerdown`,y,!0),r.addEventListener(`pointerup`,b,!0),r.addEventListener(`pointercancel`,b,!0),r.addEventListener(`pointermove`,x,!0),r.addEventListener(`click`,S,!0),r.addEventListener(`auxclick`,S,!0),r.addEventListener(`keydown`,C,!0),typeof document<`u`&&(document.addEventListener(`pointerover`,w,!0),document.addEventListener(`pointerout`,T,!0),document.addEventListener(`focusin`,E,!0),document.addEventListener(`focusout`,D,!0),document.addEventListener(`pointerdown`,O,!0)),i=!0))},A=()=>{i&&=(r?.removeEventListener(`pointerdown`,y,!0),r?.removeEventListener(`pointerup`,b,!0),r?.removeEventListener(`pointercancel`,b,!0),r?.removeEventListener(`pointermove`,x,!0),r?.removeEventListener(`click`,S,!0),r?.removeEventListener(`auxclick`,S,!0),r?.removeEventListener(`keydown`,C,!0),typeof document<`u`&&(document.removeEventListener(`pointerover`,w,!0),document.removeEventListener(`pointerout`,T,!0),document.removeEventListener(`focusin`,E,!0),document.removeEventListener(`focusout`,D,!0),document.removeEventListener(`pointerdown`,O,!0)),!1)};return k(),{register(e){n.register(e),i||k()},deregister(e){n.deregister(e)},setActiveNode(e){n.setActiveNode(e)},getActiveNode(){return n.getActiveNode()},getRegistration(e){return n.getRegistration(e)},destroy(){A(),u(),d(),f(),v(),n.clear()},store:n}}var ev=e=>{let t=(0,Q.c)(2),{store:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{"data-ok-interaction-layer":``,className:`contents`,children:(0,$.jsx)(X_,{store:n})}),t[0]=n,t[1]=r),r},tv=new WeakMap;function nv(e){let t=tv.get(e);if(t)return t;let n=$_({editor:e});return tv.set(e,n),e.on(`destroy`,()=>{n.destroy(),tv.delete(e)}),n}var rv={AlignCenter:Tu,AppWindow:gt,ChevronRight:Mt,CopyPlus:ql,FileText:hi,Film:ci,GitBranch:_t,Image:Qn,LayoutPanelTop:au,MessageSquareWarning:pu,PanelTop:hu,Paperclip:Ti,PenTool:gu,Sigma:bu,SquarePlay:Su,Volume2:_r,Workflow:ku,ZoomIn:St};function iv(e){return e&&Object.hasOwn(rv,e)?rv[e]:Rl}var av={Info:xi,Lightbulb:ou,MessageSquareWarning:pu,AlertTriangle:ji,AlertOctagon:mu,ClipboardList:Ul,BookOpen:Ll,ListTodo:du,CircleCheck:Pt,CircleHelp:Vl,CircleX:Hl,Zap:Au,Bug:zl,FlaskConical:$l,Quote:_u,ChevronRight:Mt},ov=Object.entries(av).sort(([e],[t])=>e.localeCompare(t));function sv(e){if(!e||!e.startsWith(`lucide:`))return null;let t=e.slice(7);return Object.hasOwn(av,t)?av[t]??null:null}function cv(e){let t=(0,Q.c)(24),n;t[0]===e.icon?n=t[1]:(n=sv(e.icon),t[0]=e.icon,t[1]=n);let r=n,i=r?`custom`:void 0,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Mt,{size:14,className:`accordion-chevron`,"aria-hidden":`true`}),t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=r?(0,$.jsx)(r,{size:16,className:`accordion-icon`,"aria-hidden":`true`}):null,t[3]=r,t[4]=o);let s=e.title??`Accordion`,c;t[5]===s?c=t[6]:(c=(0,$.jsx)(`span`,{className:`accordion-title`,children:s}),t[5]=s,t[6]=c);let l;t[7]===e.description?l=t[8]:(l=e.description?(0,$.jsx)(`span`,{className:`accordion-description`,children:e.description}):null,t[7]=e.description,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,$.jsxs)(`span`,{className:`accordion-title-group`,children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==o||t[13]!==u?(d=(0,$.jsxs)(`summary`,{className:`accordion-summary`,contentEditable:!1,children:[a,o,u]}),t[12]=o,t[13]=u,t[14]=d):d=t[14];let f;t[15]===e.children?f=t[16]:(f=(0,$.jsx)(`div`,{className:`accordion-body`,children:e.children}),t[15]=e.children,t[16]=f);let p;return t[17]!==e.defaultOpen||t[18]!==e.id||t[19]!==e.name||t[20]!==i||t[21]!==d||t[22]!==f?(p=(0,$.jsxs)(`details`,{className:`accordion`,"data-accordion-icon":i,open:e.defaultOpen,id:e.id,name:e.name,children:[d,f]}),t[17]=e.defaultOpen,t[18]=e.id,t[19]=e.name,t[20]=i,t[21]=d,t[22]=f,t[23]=p):p=t[23],p}var lv={center:`text-center`,left:`text-left`,right:`text-right`,justify:`text-justify`};function uv(e){let t=(0,Q.c)(5),n=lv[e.align??``]??null,r;t[0]===n?r=t[1]:(r=d(`prose-no-margin`,n),t[0]=n,t[1]=r);let i;return t[2]!==e.children||t[3]!==r?(i=(0,$.jsx)(`div`,{"data-component-type":`align-block`,className:r,children:e.children}),t[2]=e.children,t[3]=r,t[4]=i):i=t[4],i}function dv(e){return e!==!1}function fv(e){let t=(0,Q.c)(12),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:Lo(e.src),t[0]=e.src,t[1]=n);let r=e.title,i;t[2]===e.controls?i=t[3]:(i=dv(e.controls),t[2]=e.controls,t[3]=i);let a;return t[4]!==e.autoplay||t[5]!==e.loop||t[6]!==e.muted||t[7]!==e.preload||t[8]!==e.title||t[9]!==n||t[10]!==i?(a=(0,$.jsx)(`audio`,{className:`ok-audio`,src:n,title:r,controls:i,autoPlay:e.autoplay,loop:e.loop,muted:e.muted,preload:e.preload}),t[4]=e.autoplay,t[5]=e.loop,t[6]=e.muted,t[7]=e.preload,t[8]=e.title,t[9]=n,t[10]=i,t[11]=a):a=t[11],a}var pv={note:xi,tip:ou,important:pu,warning:ji,caution:mu,abstract:Ul,info:Ll,todo:du,success:Pt,question:Vl,failure:Hl,danger:Au,bug:zl,example:$l,quote:_u};function mv(e,t){return sv(e)??pv[t]}var hv=new Set([`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`]);function gv(e){return typeof e==`string`&&hv.has(e)?e:`note`}function _v(e){let t=(0,Q.c)(29),n,r;t[0]!==e.icon||t[1]!==e.type?(r=gv(e.type),n=mv(e.icon,r),t[0]=e.icon,t[1]=e.type,t[2]=n,t[3]=r):(n=t[2],r=t[3]);let i=n,o;t[4]===e.color?o=t[5]:(o=e.color?{"--callout-type-color":e.color}:{},t[4]=e.color,t[5]=o);let s=o,c;t[6]!==i||t[7]!==e.title?(c=e.title||i?(0,$.jsxs)(`span`,{className:`callout-header`,contentEditable:!1,children:[(0,$.jsx)(i,{size:16,className:`callout-icon`,"aria-hidden":`true`}),e.title?(0,$.jsx)(`span`,{className:`callout-title`,children:e.title}):null]}):null,t[6]=i,t[7]=e.title,t[8]=c):c=t[8];let l=c;if(e.collapsible){let n=e.defaultOpen??!0,i;t[9]===l?i=t[10]:(i=l??(0,$.jsx)(`span`,{className:`callout-title`,children:(0,$.jsx)(a,{id:`URmyfc`})}),t[9]=l,t[10]=i);let o;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(jt,{size:16,className:`callout-chevron`,"aria-hidden":`true`}),t[11]=o):o=t[11];let c;t[12]===i?c=t[13]:(c=(0,$.jsxs)(`summary`,{className:`callout-summary`,contentEditable:!1,children:[i,o]}),t[12]=i,t[13]=c);let u;t[14]===e.children?u=t[15]:(u=(0,$.jsx)(`div`,{className:`callout-body`,children:e.children}),t[14]=e.children,t[15]=u);let d;return t[16]!==n||t[17]!==s||t[18]!==c||t[19]!==u||t[20]!==r?(d=(0,$.jsxs)(`details`,{className:`callout callout-collapsible`,"data-callout-type":r,open:n,style:s,children:[c,u]}),t[16]=n,t[17]=s,t[18]=c,t[19]=u,t[20]=r,t[21]=d):d=t[21],d}let u;t[22]===e.children?u=t[23]:(u=(0,$.jsx)(`div`,{className:`callout-body`,children:e.children}),t[22]=e.children,t[23]=u);let d;return t[24]!==l||t[25]!==s||t[26]!==u||t[27]!==r?(d=(0,$.jsxs)(`div`,{className:`callout callout-static`,"data-callout-type":r,style:s,children:[l,u]}),t[24]=l,t[25]=s,t[26]=u,t[27]=r,t[28]=d):d=t[28],d}function vv(e){let t;try{t=new URL(e)}catch{return null}let n=t.pathname.match(/^\/video\/(\d+)/);if(n)return n[1]??null;let r=t.pathname.match(/^\/(\d+)/);return r?r[1]??null:null}function yv(e){if(typeof e!=`string`||e.length===0)return e;let t=Yt(e);if(t){let e=t.noCookie?`www.youtube-nocookie.com`:`www.youtube.com`,n=t.startSeconds===null?``:`?start=${t.startSeconds}`;return`https://${e}/embed/${t.id}${n}`}if(ui(e)){let t=vv(e);return t?`https://player.vimeo.com/video/${t}`:e}let n=$t(e);if(n){let e=n.startRaw===null?``:`?t=${n.startRaw}`;return`https://www.loom.com/embed/${n.id}${e}`}return e}var bv=[{key:`tl`,dx:-1,dy:-1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--tl`},{key:`t`,dx:0,dy:-1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--t`},{key:`tr`,dx:1,dy:-1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--tr`},{key:`r`,dx:1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--r`},{key:`br`,dx:1,dy:1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--br`},{key:`b`,dx:0,dy:1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--b`},{key:`bl`,dx:-1,dy:1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--bl`},{key:`l`,dx:-1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--l`}];function xv(e){let t=(0,Q.c)(7),{targetRef:n,onResize:r,onResizeEnd:i,bounds:a}=e,{_:s}=o(),c=(0,Z.useRef)(null),l;t[0]!==a?.maxHeight||t[1]!==a?.maxWidth||t[2]!==a?.minHeight||t[3]!==a?.minWidth?(l=function(e,t){let n=t===`w`?a?.minWidth??64:a?.minHeight??64,r=t===`w`?a?.maxWidth??1/0:a?.maxHeight??1/0;return Math.max(n,Math.min(r,e))},t[0]=a?.maxHeight,t[1]=a?.maxWidth,t[2]=a?.minHeight,t[3]=a?.minWidth,t[4]=l):l=t[4];let u=l,f=function(e,t){let a=n.current;if(!a)return;e.preventDefault(),e.stopPropagation();let o=a.getBoundingClientRect();c.current={handle:t,startX:e.clientX,startY:e.clientY,startWidth:o.width,startHeight:o.height,latestWidth:o.width,latestHeight:o.height,hasMoved:!1};let s=e.currentTarget;try{s.setPointerCapture(e.pointerId)}catch{}document.body.style.setProperty(`cursor`,t.cursor),document.body.style.setProperty(`user-select`,`none`);let l=function(e){let t=c.current;if(!t)return;let n=(e.clientX-t.startX)*t.handle.dx,i=(e.clientY-t.startY)*t.handle.dy,a=t.handle.dx===0?t.startWidth:u(t.startWidth+n,`w`),o=t.handle.dy===0?t.startHeight:u(t.startHeight+i,`h`);t.latestWidth=a,t.latestHeight=o,t.hasMoved=!0,r({width:a,height:o})};function d(){let e=c.current;if(!e)return;let t={width:e.latestWidth,height:e.latestHeight},n=e.hasMoved;c.current=null,document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`),window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d),n&&i?.(t)}window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},p=bv.map(e=>{let t=e.key;return(0,$.jsx)(`button`,{type:`button`,className:d(e.className),"aria-label":s({id:`NxW-md`,values:{handleKey:t}}),tabIndex:-1,style:{cursor:e.cursor},onPointerDown:t=>f(t,e)},t)}),m;return t[5]===p?m=t[6]:(m=(0,$.jsx)(`div`,{className:`ok-resize-overlay`,contentEditable:!1,"aria-hidden":`true`,children:p}),t[5]=p,t[6]=m),m}var Sv=`26rem`,Cv=`Embedded content`,wv=/^https?:\/\//i;function Tv(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function Ev(e){return!(typeof e!=`string`||!wv.test(e)||!Tv(e))}function Dv(e){let t=(0,Q.c)(24),{src:n,title:r,width:i,height:a}=e,o=(0,Z.useRef)(null),s=wt(),c=i||void 0,l=a||Sv,u;t[0]!==c||t[1]!==l?(u={width:c,height:l},t[0]=c,t[1]=l,t[2]=u):u=t[2];let d=u,f,p;if(t[3]!==a||t[4]!==i?(f=()=>{let e=o.current;e&&(e.style.width=i||``,e.style.height=a||Sv)},p=[i,a],t[3]=a,t[4]=i,t[5]=f,t[6]=p):(f=t[5],p=t[6]),(0,Z.useEffect)(f,p),!Ev(n)){let e=`Embed a URL`;typeof n==`string`&&n.length>0&&(e=wv.test(n)?`Embed only supports cross-origin URLs`:`URL must start with http:// or https://`);let r;return t[7]===e?r=t[8]:(r=(0,$.jsx)(`div`,{className:`ok-embed ok-embed--placeholder`,contentEditable:!1,children:(0,$.jsx)(`span`,{children:e})}),t[7]=e,t[8]=r),r}let m;t[9]===s?m=t[10]:(m=e=>{if(!s)return;let{editor:t,getPos:n}=s,r=n();if(typeof r==`number`)try{let n=t.state.doc.nodeAt(r);if(n?.type.name!==`jsxComponent`)return;let i={...n.attrs.props??{},width:`${Math.round(e.width)}px`,height:`${Math.round(e.height)}px`};t.view.dispatch(t.state.tr.setNodeMarkup(r,null,{...n.attrs,props:i,sourceDirty:!0}))}catch(e){let t=e;if(t instanceof RangeError)return;throw t}},t[9]=s,t[10]=m);let h=m,g;t[11]===n?g=t[12]:(g=yv(n),t[11]=n,t[12]=g);let _=g,v=_===n?`no-referrer`:`strict-origin-when-cross-origin`,y=r||Cv,b;t[13]!==_||t[14]!==v||t[15]!==y?(b=(0,$.jsx)(`iframe`,{title:y,src:_,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation`,referrerPolicy:v,loading:`lazy`,className:`ok-embed-frame`}),t[13]=_,t[14]=v,t[15]=y,t[16]=b):b=t[16];let x;t[17]!==s||t[18]!==h?(x=s?(0,$.jsx)(xv,{targetRef:o,bounds:{minWidth:192,maxWidth:2e3,minHeight:128,maxHeight:Math.round(window.innerHeight*.9)},onResize:e=>{let t=o.current;t&&(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`)},onResizeEnd:h}):null,t[17]=s,t[18]=h,t[19]=x):x=t[19];let S;return t[20]!==d||t[21]!==x||t[22]!==b?(S=(0,$.jsxs)(`div`,{className:`ok-embed`,style:d,ref:o,contentEditable:!1,children:[b,x]}),t[20]=d,t[21]=x,t[22]=b,t[23]=S):S=t[23],S}function Ov(e){return e===Be}var kv=new Set(Ve);function Av(e){return kv.has(e)}var jv=new Map,Mv=1e4,Nv=(0,Z.createContext)(!0);function Pv(){return{ok:!1,reason:`refused`}}function Fv(){return(0,Z.use)(Nv)?Iv:Pv}function Iv(e,t){if(Ov(t)||Av(t))return{ok:!1,reason:`inadmissible`};let n=`${e}|${t}`,r=jv.get(n);if(r)return r.refcount+=1,{ok:!0,entry:r};if(jv.size>=30)return console.warn(`[LiveDoc] provider pool at capacity (30); refusing "${t}". Live by-reference embeds and mirrors across all visible documents share this pool.`),{ok:!1,reason:`at-capacity`};let i=new Na,a=new Ma({url:e,name:t,document:i}),o=new Set,s={provider:a,ySource:i.getText(`source`),refcount:1,synced:!1,subscribe:e=>(o.add(e),()=>{o.delete(e)})};return a.on(`synced`,()=>{s.synced=!0;for(let e of o)e.onSynced()}),s.ySource.observe(()=>{for(let e of o)e.onUpdate()}),jv.set(n,s),{ok:!0,entry:s}}function Lv(e,t){let n=`${e}|${t}`,r=jv.get(n);if(r&&(--r.refcount,r.refcount<=0)){try{r.provider.destroy()}catch(e){console.warn(`[LiveDoc] provider.destroy() failed during release`,{docName:t,err:e})}jv.delete(n)}}function Rv(e,t){return e.kind!==t.kind||e.kind===`ready`&&t.kind===`ready`&&e.text!==t.text?t:e}function zv(e,t){switch(t){case`at-capacity`:return{kind:`at-capacity`};case`inadmissible`:return{kind:`unreachable`};case`refused`:return console.warn(`[LiveDoc] live-document access is off here; refused`,{docName:e}),{kind:`loading`}}}function Bv(e,t){let n=(0,Q.c)(10),r=t===void 0?0:t,{collabUrl:i}=_o(),a=Fv(),o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={kind:`loading`},n[0]=o):o=n[0];let[s,c]=(0,Z.useState)(o),l;n[1]!==a||n[2]!==i||n[3]!==e?(l=()=>{if(!e){c({kind:`unreachable`});return}if(!i){c({kind:`loading`});return}c(Vv);let t=a(i,e);if(!t.ok){c(zv(e,t.reason));return}let{entry:n}=t,r=()=>{let e=n.ySource.toString(),t=e?{kind:`ready`,text:e}:n.synced?{kind:`empty`}:{kind:`loading`};c(e=>Rv(e,t))},o=null,s=n.subscribe({onUpdate:()=>{o&&clearTimeout(o),o=setTimeout(()=>{o=null,r()},150)},onSynced:()=>{o&&=(clearTimeout(o),null),r()}}),l=!1,u=()=>{l||(l=!0,o&&=(clearTimeout(o),null),s(),Lv(i,e))},d=setTimeout(()=>{n.synced||(c({kind:`unreachable`}),u())},Mv);return r(),()=>{clearTimeout(d),u()}},n[1]=a,n[2]=i,n[3]=e,n[4]=l):l=n[4];let u;return n[5]!==a||n[6]!==i||n[7]!==e||n[8]!==r?(u=[i,e,r,a],n[5]=a,n[6]=i,n[7]=e,n[8]=r,n[9]=u):u=n[9],(0,Z.useEffect)(l,u),s}function Vv(e){return Rv(e,{kind:`loading`})}var Hv=30,Uv=[];function Wv(e){if(typeof document>`u`)return!1;for(let t of document.images)if(t.getAttribute(`src`)===e)return!0;return!1}function Gv(e){Uv.push(e);let t=0;for(;Uv.length>Hv&&t<Uv.length;){let e=Uv.shift();if(!e)break;if(t+=1,Wv(e)){Uv.push(e);continue}URL.revokeObjectURL(e)}}function Kv(e){let t=Uv.indexOf(e);t>=0&&Uv.splice(t,1),URL.revokeObjectURL(e)}var qv=Dt(()=>n(()=>import(`./prod-DmbEMjXJ.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47]),import.meta.url)),Jv=new Set([`http:`,`https:`,`file:`]);function Yv(e,t=typeof window<`u`&&window.location?.href?window.location.href:`http://localhost/`){try{let n=new URL(t),r=new URL(e,n);if(!Jv.has(r.protocol)||!(r.protocol===`file:`?n.protocol===`file:`:r.origin===n.origin))return null;let i=r.pathname.split(`/`).filter(e=>e.length>0).map(e=>decodeURIComponent(e));if(i.length===0||i.some(e=>e===`..`||e===`.`||e.includes(`/`)||e.includes(`\\`)||/[\u0000-\u001f]/.test(e)))return null;let a=i.join(`/`);return ie(a)?a:null}catch{return null}}function Xv(e){return typeof e==`string`&&Yv(e)!==null}function Zv(e){let t=(0,Q.c)(82),{src:n,title:r,className:i,expandOpen:s,onExpandOpenChange:c}=e,l=s===void 0?!1:s,{_:u}=o(),f=bt(),[p,m]=(0,Z.useState)(0),h;t[0]===n?h=t[1]:(h=n?Yv(n):null,t[0]=n,t[1]=h);let g=h,_=Bv(g,p),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(null),w=(0,Z.useRef)(null),T=(0,Z.useRef)(!1),E,D;t[2]===g?(E=t[3],D=t[4]):(E=()=>{g&&(qv().catch(ty),Ct().catch(ey))},D=[g],t[2]=g,t[3]=E,t[4]=D),(0,Z.useEffect)(E,D);let O;t[5]!==g||t[6]!==_.kind||t[7]!==_.text||t[8]!==v?(O=()=>{if(_.kind!==`ready`||!g||v&&v.docName===g&&v.text===_.text)return;let e=!1;return(async()=>{let t=JSON.parse(_.text);if(!(typeof t==`object`&&t&&Array.isArray(t.elements)))throw Error(`not an Excalidraw scene (no elements array)`);let n;try{n=await qv()}catch(t){let n=t;if(e)return;console.warn(`[ExcalidrawEmbed] excalidraw module failed to load:`,g,n),T.current=!1,y(null),C({docName:g,kind:`module-load`});return}let r=Qo(n,t);e||(y({docName:g,text:_.text,value:r}),C(null))})().catch(t=>{e||(console.warn(`[ExcalidrawEmbed] failed to parse board:`,g,t),T.current=!1,y(null),C({docName:g,kind:`parse`}))}),()=>{e=!0}},t[5]=g,t[6]=_.kind,t[7]=_.text,t[8]=v,t[9]=O):O=t[9];let k;t[10]!==g||t[11]!==_||t[12]!==v?(k=[_,g,v],t[10]=g,t[11]=_,t[12]=v,t[13]=k):k=t[13],(0,Z.useEffect)(O,k);let A=(0,Z.useRef)(!1),j=(0,Z.useRef)(!1),[M,N]=(0,Z.useState)(0),P=(0,Z.useRef)(null),F;t[14]!==g||t[15]!==f||t[16]!==v||t[17]!==b?(F=()=>{if(!v||!g||v.docName!==g||b&&b.docName===v.docName&&b.sceneValue===v.value&&b.colorMode===f)return;if(A.current){j.current=!0;return}let e=!1;return A.current=!0,(async()=>{let t;try{t=await qv()}catch(t){let n=t;if(e)return;console.warn(`[ExcalidrawEmbed] excalidraw module failed to load:`,g,n),T.current=!1,x(null),C({docName:g,kind:`module-load`});return}let n=await t.exportToSvg({elements:v.value.elements,appState:{...v.value.appState,exportWithDarkMode:f===`dark`,exportBackground:!1},files:v.value.files});if(e)return;let r=new XMLSerializer().serializeToString(n),i=URL.createObjectURL(new Blob([r],{type:`image/svg+xml`})),a=P.current;P.current=i,Gv(i),a&&Kv(a),x({docName:v.docName,url:i,sceneValue:v.value,colorMode:f}),C(null)})().catch(t=>{e||(console.warn(`[ExcalidrawEmbed] failed to export board snapshot:`,g,t),T.current=!1,x(null),C({docName:g,kind:`export`}))}).finally(()=>{A.current=!1,j.current&&(j.current=!1,N($v))}),()=>{e=!0}},t[14]=g,t[15]=f,t[16]=v,t[17]=b,t[18]=F):F=t[18];let I;t[19]!==g||t[20]!==f||t[21]!==M||t[22]!==v||t[23]!==b?(I=[v,f,g,b,M],t[19]=g,t[20]=f,t[21]=M,t[22]=v,t[23]=b,t[24]=I):I=t[24],(0,Z.useEffect)(F,I);let L=S&&S.docName===g?S:null,R=L!==null||_.kind===`unreachable`||_.kind===`at-capacity`,te=b&&b.docName===g?b:null,ne=te!==null&&!R,re,ie;t[25]===R?(re=t[26],ie=t[27]):(ie=()=>{!R&&T.current&&(T.current=!1,w.current?.focus())},re=[R],t[25]=R,t[26]=re,t[27]=ie),(0,Z.useEffect)(ie,re);let ae=R||_.kind===`empty`,oe,se;if(t[28]!==ae||t[29]!==l||t[30]!==c?(oe=()=>{l&&ae&&c?.(!1)},se=[l,ae,c],t[28]=ae,t[29]=l,t[30]=c,t[31]=oe,t[32]=se):(oe=t[31],se=t[32]),(0,Z.useEffect)(oe,se),!n){let e;t[33]===i?e=t[34]:(e=d(`excalidraw-embed flex min-h-16 w-full items-center justify-center rounded-md border border-dashed border-border/60 bg-muted/10 px-3 py-6 text-sm text-muted-foreground`,i),t[33]=i,t[34]=e);let n;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(a,{id:`WH3roC`}),t[35]=n):n=t[35];let r;return t[36]===e?r=t[37]:(r=(0,$.jsx)(`div`,{className:e,"data-component-type":`excalidraw`,children:n}),t[36]=e,t[37]=r),r}if(_.kind===`empty`){let e;t[38]===i?e=t[39]:(e=d(`excalidraw-embed flex min-h-16 w-full items-center justify-center rounded-md border border-dashed border-border/60 bg-muted/10 px-3 py-6 text-sm text-muted-foreground`,i),t[38]=i,t[39]=e);let n;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(a,{id:`AaC-CE`}),t[40]=n):n=t[40];let r;return t[41]===e?r=t[42]:(r=(0,$.jsx)(`div`,{className:e,"data-component-type":`excalidraw`,children:n}),t[41]=e,t[42]=r),r}let z=!R&&!te,B;t[43]!==u||t[44]!==L?.kind||t[45]!==_.kind?(B=_.kind===`at-capacity`?u({id:`dT-HIQ`}):_.kind===`unreachable`?u({id:`4Vgtaz`}):L?.kind===`module-load`?u({id:`pGYklE`}):L?.kind===`parse`?u({id:`LPLWpO`}):u({id:`U4ZE26`}),t[43]=u,t[44]=L?.kind,t[45]=_.kind,t[46]=B):B=t[46];let ce=B,V=R&&_.kind!==`at-capacity`&&g!==null,H;t[47]===i?H=t[48]:(H=d(`excalidraw-embed relative w-full overflow-hidden rounded-md border border-border/60 bg-muted/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,i),t[47]=i,t[48]=H);let U=z?!0:void 0,W;t[49]!==g||t[50]!==ce||t[51]!==V||t[52]!==R||t[53]!==n?(W=R?(0,$.jsxs)(`div`,{role:`alert`,className:`m-2 flex items-start gap-2 rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive`,children:[(0,$.jsx)(ji,{className:`size-3.5 shrink-0 mt-0.5`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:(0,$.jsx)(a,{id:`eh3QBq`})}),(0,$.jsx)(`div`,{className:`mt-1`,children:ce}),(0,$.jsx)(`div`,{className:`mt-1 break-words font-mono text-[11px] opacity-90`,children:g??n})]}),V?(0,$.jsx)(ee,{type:`button`,size:`sm`,variant:`outline`,className:`shrink-0 border-destructive/40 text-destructive hover:text-destructive`,"data-testid":`excalidraw-embed-retry`,onClick:()=>{T.current=!0,C(null),y(null),x(null),m(Qv)},children:(0,$.jsx)(a,{id:`KDw4GX`})}):null]}):null,t[49]=g,t[50]=ce,t[51]=V,t[52]=R,t[53]=n,t[54]=W):W=t[54];let le;t[55]!==u||t[56]!==g||t[57]!==te||t[58]!==R||t[59]!==r?(le=te&&!R?(0,$.jsx)(`div`,{className:`flex min-h-16 w-full items-center justify-center p-3`,"data-testid":`excalidraw-embed-snapshot`,children:(0,$.jsx)(`img`,{src:te.url,alt:r||u({id:`d-RYHO`}),draggable:!1,className:`h-auto max-h-[60vh] max-w-full`,onError:()=>{console.warn(`[ExcalidrawEmbed] snapshot image failed to decode:`,g,te?.url),g&&(T.current=!1,C({docName:g,kind:`export`}))}})}):null,t[55]=u,t[56]=g,t[57]=te,t[58]=R,t[59]=r,t[60]=le):le=t[60];let G;t[61]===z?G=t[62]:(G=z?(0,$.jsx)(Ya,{className:`m-3 min-h-16`,"aria-hidden":`true`}):null,t[61]=z,t[62]=G);let ue;t[63]!==u||t[64]!==g||t[65]!==R?(ue=g&&!R?(0,$.jsx)(ee,{asChild:!0,size:`icon-sm`,variant:`secondary`,className:`absolute top-2 right-2 border-border`,title:u({id:`6M2L3X`}),"data-testid":`excalidraw-embed-open`,children:(0,$.jsx)(`a`,{href:pa(g),"aria-label":u({id:`6M2L3X`}),children:(0,$.jsx)(Yl,{className:`size-4`,"aria-hidden":`true`})})}):null,t[63]=u,t[64]=g,t[65]=R,t[66]=ue):ue=t[66];let K=l&&ne,de;t[67]===c?de=t[68]:(de=e=>c?.(e),t[67]=c,t[68]=de);let fe=te?.url??null,pe;t[69]!==K||t[70]!==de||t[71]!==fe||t[72]!==r?(pe=(0,$.jsx)(ay,{open:K,onOpenChange:de,snapshotUrl:fe,title:r}),t[69]=K,t[70]=de,t[71]=fe,t[72]=r,t[73]=pe):pe=t[73];let q;return t[74]!==H||t[75]!==U||t[76]!==W||t[77]!==le||t[78]!==G||t[79]!==ue||t[80]!==pe?(q=(0,$.jsxs)(`div`,{ref:w,tabIndex:-1,className:H,"data-component-type":`excalidraw`,"aria-busy":U,children:[W,le,G,ue,pe]}),t[74]=H,t[75]=U,t[76]=W,t[77]=le,t[78]=G,t[79]=ue,t[80]=pe,t[81]=q):q=t[81],q}function Qv(e){return e+1}function $v(e){return e+1}function ey(){}function ty(){}var ny=.5,ry=4,iy=.25;function ay(e){let t=(0,Q.c)(33),{open:n,onOpenChange:r,snapshotUrl:i,title:a}=e,{_:s}=o(),c=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(!1),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=e=>{if(!e)return;let t=!1;Ct().then(n=>{t||(c.current=n(e,{canvas:!0,cursor:`default`,maxScale:ry,minScale:ny,step:iy,noBind:!0,touchAction:`auto`}),u(!1))}).catch(e=>{console.warn(`[ExcalidrawEmbed] panzoom setup failed:`,e),t||u(!0)});let n=e=>{let t=c.current;if(!t)return;if(e.preventDefault(),e.ctrlKey||e.metaKey){t.zoomWithWheel(e);return}let n=typeof t.getScale==`function`?t.getScale():1,r=n>0?n:1;t.pan(-e.deltaX/r,-e.deltaY/r,{relative:!0})},r=e.parentElement;return r?.addEventListener(`wheel`,n,{passive:!1}),()=>{t=!0,r?.removeEventListener(`wheel`,n),c.current?.destroy(),c.current=null}},t[0]=d):d=t[0];let f=d,p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p={"--tw-enter-scale":`0.92`,"--tw-exit-scale":`0.92`},t[1]=p):p=t[1];let m;t[2]!==s||t[3]!==a?(m=a||s({id:`d-RYHO`}),t[2]=s,t[3]=a,t[4]=m):m=t[4];let h;t[5]===m?h=t[6]:(h=(0,$.jsx)(Ii,{className:`sr-only`,children:m}),t[5]=m,t[6]=h);let g;t[7]===s?g=t[8]:(g=s({id:`F8DaWi`}),t[7]=s,t[8]=g);let _;t[9]===g?_=t[10]:(_=(0,$.jsx)(`span`,{className:`absolute top-2 left-3 flex h-7 items-center text-xs text-muted-foreground`,children:g}),t[9]=g,t[10]=_);let v;t[11]!==s||t[12]!==i||t[13]!==a?(v=i?(0,$.jsx)(`img`,{ref:f,src:i,alt:a||s({id:`d-RYHO`}),draggable:!1,className:`max-h-full max-w-full`}):null,t[11]=s,t[12]=i,t[13]=a,t[14]=v):v=t[14];let y;t[15]===v?y=t[16]:(y=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,"data-testid":`excalidraw-lightbox-canvas`,children:v}),t[15]=v,t[16]=y);let b;t[17]===s?b=t[18]:(b=s({id:`iBei3o`}),t[17]=s,t[18]=b);let x;t[19]!==l||t[20]!==b?(x=(0,$.jsx)(Et,{panzoomRef:c,label:b,testId:`excalidraw-lightbox-actions`,unavailable:l}),t[19]=l,t[20]=b,t[21]=x):x=t[21];let S;t[22]!==x||t[23]!==y?(S=(0,$.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 overflow-hidden`,children:[y,x]}),t[22]=x,t[23]=y,t[24]=S):S=t[24];let C;t[25]!==S||t[26]!==h||t[27]!==_?(C=(0,$.jsxs)(Li,{className:`h-[calc(100dvh-5rem)] w-[calc(100dvw-5rem)] max-w-none gap-0 p-2 pt-10 duration-200 sm:max-w-none`,style:p,children:[h,_,S]}),t[25]=S,t[26]=h,t[27]=_,t[28]=C):C=t[28];let w;return t[29]!==r||t[30]!==n||t[31]!==C?(w=(0,$.jsx)(Hi,{open:n,onOpenChange:r,children:C}),t[29]=r,t[30]=n,t[31]=C,t[32]=w):w=t[32],w}function oy(e){if(!e)return``;let t,n=null;try{let r=new URL(e,`https://placeholder.local`);n=r.protocol,t=r.pathname}catch{t=e.split(`?`)[0]??e}if(n===`data:`||n===`blob:`)return``;let r=t.split(`/`),i=r[r.length-1]??``;try{return decodeURIComponent(i)}catch{return i}}function sy(e){let t=(0,Q.c)(18),n;t[0]!==e.name||t[1]!==e.src?(n=e.name?.trim()||oy(e.src)||`Untitled file`,t[0]=e.name,t[1]=e.src,t[2]=n):n=t[2];let r=n,i=e.size?.trim()?e.size:null,a;t[3]===e.src?a=t[4]:(a=e.src?Lo(e.src):void 0,t[3]=e.src,t[4]=a);let o=a,s;t[5]===o?s=t[6]:(s=e=>{e.stopPropagation(),e.preventDefault(),o&&window.open(o,`_blank`,`noopener,noreferrer`)},t[5]=o,t[6]=s);let c=s,l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Zl,{className:`ok-file-icon`,"aria-hidden":`true`}),t[7]=l):l=t[7];let u;t[8]===r?u=t[9]:(u=(0,$.jsx)(`span`,{className:`ok-file-name`,children:r}),t[8]=r,t[9]=u);let d;t[10]===i?d=t[11]:(d=i?(0,$.jsx)(`span`,{className:`ok-file-size`,children:i}):null,t[10]=i,t[11]=d);let f;return t[12]!==c||t[13]!==o||t[14]!==e.title||t[15]!==u||t[16]!==d?(f=(0,$.jsxs)(`a`,{href:o,title:e.title,className:`ok-file-attachment`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:cy,onClick:c,children:[l,u,d]}),t[12]=c,t[13]=o,t[14]=e.title,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function cy(e){return e.stopPropagation()}function ly(){return Z.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-unzoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Z.createElement(`path`,{d:`M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z`}))}function uy(){return Z.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-zoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Z.createElement(`path`,{d:`M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z`}))}function dy(e){return typeof Element>`u`?!1:e instanceof Element}var fy=(e,t)=>dy(t)&&t.tagName.toUpperCase()===e,py=e=>fy(`DIV`,e)||fy(`SPAN`,e),my=e=>fy(`IMG`,e),hy=e=>e.complete&&e.naturalHeight!==0,gy=e=>fy(`SVG`,e),_y=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),vy=({containerHeight:e,containerWidth:t,offset:n,targetHeight:r,targetWidth:i})=>{let a=_y({height:r,offset:n,width:i}),o=i>r?i/t:r/e;return a>1?o:a*o},yy=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:i,targetWidth:a})=>e===0||t===0?1:!n&&i!==0&&a!==0?vy({containerHeight:e,containerWidth:t,offset:r,targetHeight:i,targetWidth:a}):_y({height:e,offset:r,width:t}),by=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,xy=e=>{if(e!==null){if(my(e))return e.currentSrc===``?void 0:e.currentSrc;if(py(e)){let{backgroundImage:t}=window.getComputedStyle(e);if(t!==``)return by.exec(t)?.[1]}}},Sy=e=>{if(e!==null)return my(e)?e.alt:e.getAttribute(`aria-label`)??void 0},Cy=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s})=>{let c=yy({containerHeight:e,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s});return{top:n,left:t,width:r*c,height:e*c,transform:`translate(0,0) scale(${1/c})`}},wy=({position:e,relativeNum:t})=>{let n=parseFloat(e);return e.endsWith(`%`)?t*n/100:n},Ty=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,objectFit:a,objectPosition:o,offset:s,targetHeight:c,targetWidth:l})=>{let u=a;if(u===`scale-down`&&(u=l<=r&&c<=e?`none`:`contain`),u===`cover`||u===`contain`){let a=r/l,d=e/c,f=u===`cover`?Math.max(a,d):Math.min(a,d),[p=`50%`,m=`50%`]=o.split(` `),h=wy({position:p,relativeNum:r-l*f}),g=wy({position:m,relativeNum:e-c*f}),_=yy({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+g,left:t+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(u===`none`){let[a=`50%`,u=`50%`]=o.split(` `),d=wy({position:a,relativeNum:r-l}),f=wy({position:u,relativeNum:e-c}),p=yy({containerHeight:c,containerWidth:l,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+f,left:t+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else if(u===`fill`){let t=r/l,n=e/c,a=Math.max(t,n),o=yy({containerHeight:c*a,containerWidth:l*a,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{width:r*o,height:e*o,transform:`translate(0,0) scale(${1/o})`}}else return{}},Ey=({backgroundPosition:e,backgroundSize:t,containerHeight:n,containerLeft:r,containerTop:i,containerWidth:a,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l})=>{if(t===`cover`||t===`contain`){let u=a/l,d=n/c,f=t===`cover`?Math.max(u,d):Math.min(u,d),[p=`50%`,m=`50%`]=e.split(` `),h=wy({position:p,relativeNum:a-l*f}),g=wy({position:m,relativeNum:n-c*f}),_=yy({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+g,left:r+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(t===`auto`){let[t=`50%`,u=`50%`]=e.split(` `),d=wy({position:t,relativeNum:a-l}),f=wy({position:u,relativeNum:n-c}),p=yy({containerHeight:c,containerWidth:l,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+f,left:r+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else{let[u=`50%`,d=`50%`]=t.split(` `),f=wy({position:u,relativeNum:a}),p=wy({position:d,relativeNum:n}),m=f/l,h=p/c,g=Math.min(m,h),[_=`50%`,v=`50%`]=e.split(` `),y=wy({position:_,relativeNum:a-l*g}),b=wy({position:v,relativeNum:n-c*g}),x=yy({containerHeight:c*g,containerWidth:l*g,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+b,left:r+y,width:l*g*x,height:c*g*x,transform:`translate(0,0) scale(${1/x})`}}},Dy=/\.svg$/i,Oy=({hasZoomImg:e,imgSrc:t,isSvg:n,isZoomed:r,loadedImgEl:i,offset:a,shouldRefresh:o,targetEl:s})=>{let c=n||t?.slice(0,18)===`data:image/svg+xml`||e||t!==void 0&&Dy.test(t),l=s.getBoundingClientRect(),u=window.getComputedStyle(s),d=i!=null&&py(s),f=i!=null&&!d,p=i!=null&&i.naturalHeight!==0?i.naturalHeight:l.height,m=i!=null&&i.naturalWidth!==0?i.naturalWidth:l.width,h=Cy({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}),g=f?Ty({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,objectFit:u.objectFit,objectPosition:u.objectPosition,offset:a,targetHeight:p,targetWidth:m}):void 0,_=d?Ey({backgroundPosition:u.backgroundPosition,backgroundSize:u.backgroundSize,containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}):void 0,v={...h,...g,..._};if(r){let e=window.innerWidth/2,t=window.innerHeight/2,n=parseFloat(String(v.left??0))+parseFloat(String(v.width??0))/2,r=parseFloat(String(v.top??0))+parseFloat(String(v.height??0))/2,i=e-n,a=t-r;o&&(v.transitionDuration=`0.01ms`),v.transform=`translate(${i}px,${a}px) scale(1)`}return v},ky=e=>{if(e==null)return{};if(gy(e)){let{parentElement:t}=e,n=e.getBoundingClientRect();if(t==null)return{height:n.height,left:n.left,width:n.width,top:n.top};{let e=t.getBoundingClientRect();return{height:n.height,left:e.left-n.left,top:e.top-n.top,width:n.width}}}else return{height:e.offsetHeight,left:e.offsetLeft,width:e.offsetWidth,top:e.offsetTop}},Ay=e=>{let t=`-zoom`,n=[`clip-path`,`fill`,`mask`,`marker-start`,`marker-mid`,`marker-end`],r=new Map;if(e.hasAttribute(`id`)){let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}e.querySelectorAll(`[id]`).forEach(e=>{let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}),r.forEach((t,r)=>{let i=`url(#${r})`,a=`url(#${t})`,o=n.map(e=>`[${e}="${i}"]`).join(`, `);e.querySelectorAll(o).forEach(e=>{n.forEach(t=>{e.getAttribute(t)===i&&e.setAttribute(t,a)})})}),e.querySelectorAll(`style`).forEach(e=>{r.forEach((t,n)=>{let{textContent:r}=e;if(r!==``){let i=e;i.textContent=r.replaceAll(`#${n}`,`#${t}`)}})})},jy=[`img`,`svg`,`[role="img"]`,`[data-zoom]`].map(e=>`${e}:not([aria-hidden="true"])`).join(`,`),My={overflow:``,width:``};function Ny(){let e=document.querySelector(`[data-rmiz-portal]`);if(e!=null)return e;let t=document.createElement(`div`);return t.setAttribute(`data-rmiz-portal`,``),document.body.appendChild(t),t}function Py(e){e.preventDefault()}function Fy(e){return Z.createElement(Iy,{...e})}var Iy=class extends Z.Component{constructor(){super(...arguments),this.state={id:``,isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:`UNLOADED`,shouldRefresh:!1,styleGhost:{}},this.refContent=Z.createRef(),this.refDialog=Z.createRef(),this.refModalContent=Z.createRef(),this.refModalImg=Z.createRef(),this.refWrap=Z.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=My,this.styleModalImg={},this.handleModalStateChange=e=>{let{state:{modalState:t}}=this;e!==`LOADING`&&t===`LOADING`?(this.loadZoomImg(),window.addEventListener(`resize`,this.handleResize,{passive:!0}),window.addEventListener(`touchstart`,this.handleTouchStart,{passive:!0}),window.addEventListener(`touchmove`,this.handleTouchMove,{passive:!0}),window.addEventListener(`touchend`,this.handleTouchEnd,{passive:!0}),window.addEventListener(`touchcancel`,this.handleTouchCancel,{passive:!0}),document.addEventListener(`keydown`,this.handleKeyDown,!0)):e!==`LOADED`&&t===`LOADED`?window.addEventListener(`wheel`,this.handleWheel,{passive:!0}):e!==`UNLOADING`&&t===`UNLOADING`?(this.ensureImgTransitionEnd(),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),document.removeEventListener(`keydown`,this.handleKeyDown,!0)):e!==`UNLOADED`&&t===`UNLOADED`&&(this.bodyScrollEnable(),window.removeEventListener(`resize`,this.handleResize),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),this.refDialog.current?.close())},this.setId=()=>{let e=()=>Math.random().toString(16).slice(-4);this.setState({id:e()+e()+e()})},this.setAndTrackImg=()=>{let{refContent:{current:e}}=this;e!=null&&(this.imgEl=e.querySelector(jy),this.imgEl===null?this.contentNotFoundChangeObserver??(this.contentNotFoundChangeObserver=new MutationObserver(this.setAndTrackImg),this.contentNotFoundChangeObserver.observe(e,{childList:!0,subtree:!0})):(this.contentNotFoundChangeObserver?.disconnect(),this.imgEl.addEventListener(`load`,this.handleImgLoad),this.imgEl.addEventListener(`click`,this.handleZoom),this.state.loadedImgEl??this.handleImgLoad(),this.imgElResizeObserver=new ResizeObserver(e=>{let[t]=e;t?.target!==void 0&&(this.imgEl=t.target,this.setState({styleGhost:ky(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver??(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:ky(this.imgEl)})}),this.contentChangeObserver.observe(e,{attributes:!0,childList:!0,subtree:!0}))))},this.handleIfZoomChanged=e=>{let{props:{isZoomed:t}}=this;!e&&t?this.zoom():e&&!t&&this.unzoom()},this.handleImgLoad=()=>{let e=xy(this.imgEl);if(e==null||e===``)return;let t=new Image,{imgEl:n}=this;if(my(n)){let{sizes:e,srcset:r,crossOrigin:i}=n;t.sizes=e,t.srcset=r,t.crossOrigin=i}t.src=e;let r=()=>{this.setState({loadedImgEl:t,styleGhost:ky(this.imgEl)})};t.decode().then(r).catch(()=>{if(hy(t)){r();return}t.onload=r})},this.handleZoom=e=>{this.props.isDisabled!==!0&&this.hasImage()&&this.props.onZoomChange?.(!0,{event:e})},this.handleUnzoom=e=>{this.props.isDisabled!==!0&&this.props.onZoomChange?.(!1,{event:e})},this.handleBtnUnzoomClick=e=>{e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e)},this.handleDialogClick=e=>{(e.target===this.refModalContent.current||e.target===this.refModalImg.current)&&(e.stopPropagation(),this.handleUnzoom(e))},this.handleDialogClose=e=>{e.stopPropagation(),this.handleUnzoom(e)},this.handleKeyDown=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e))},this.handleWheel=e=>{e.ctrlKey||(e.stopPropagation(),queueMicrotask(()=>{this.handleUnzoom(e)}))},this.handleTouchStart=e=>{if(e.touches.length>1){this.isScaling=!0;return}let{changedTouches:t}=e,[n]=t;if(t.length===1&&n!==void 0){let{screenY:e}=n;this.touchYStart=e}},this.handleTouchMove=e=>{let t=window.visualViewport?.scale??1,{changedTouches:n}=e,[r]=n;if(this.props.canSwipeToUnzoom&&!this.isScaling&&t<=1&&this.touchYStart!=null&&r!==void 0){let{screenY:t}=r;this.touchYEnd=t;let n=Math.max(this.touchYStart,this.touchYEnd),i=Math.min(this.touchYStart,this.touchYEnd);Math.abs(n-i)>this.props.swipeToUnzoomThreshold&&(this.touchYStart=void 0,this.touchYEnd=void 0,this.handleUnzoom(e))}},this.handleTouchEnd=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleTouchCancel=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleResize=()=>{this.setState({shouldRefresh:!0})},this.hasImage=()=>this.imgEl!==null&&(this.state.loadedImgEl!==void 0||gy(this.imgEl))&&window.getComputedStyle(this.imgEl).display!==`none`,this.zoom=()=>{this.bodyScrollDisable(),this.refDialog.current?.showModal(),this.refModalImg.current?.addEventListener(`transitionend`,this.handleImgTransitionEnd),this.setState({modalState:`LOADING`})},this.unzoom=()=>{this.setState({modalState:`UNLOADING`})},this.handleImgTransitionEnd=()=>{clearTimeout(this.timeoutTransitionEnd),this.state.modalState===`LOADING`?this.setState({modalState:`LOADED`}):this.state.modalState===`UNLOADING`&&this.setState({shouldRefresh:!1,modalState:`UNLOADED`})},this.ensureImgTransitionEnd=()=>{if(this.refModalImg.current!==null){let{transitionDuration:e}=window.getComputedStyle(this.refModalImg.current),t=parseFloat(e);if(t!==0&&!Number.isNaN(t)){let n=t*(e.endsWith(`ms`)?1:1e3)+50;this.timeoutTransitionEnd=setTimeout(this.handleImgTransitionEnd,n)}}},this.bodyScrollDisable=()=>{this.prevBodyAttrs={overflow:document.body.style.overflow,width:document.body.style.width};let{body:{clientWidth:e}}=document;document.body.style.overflow=`hidden`,document.body.style.width=`${e}px`},this.bodyScrollEnable=()=>{let{prevBodyAttrs:{overflow:e,width:t}}=this;document.body.style.width=t,document.body.style.overflow=e,this.prevBodyAttrs=My},this.loadZoomImg=()=>{let{props:{zoomImg:e}}=this;if(e==null)return;let{src:t}=e;if(t!==void 0&&t!==``){let n=new Image;n.sizes=e.sizes??``,n.srcset=e.srcSet??``,n.crossOrigin=e.crossOrigin??void 0,n.src=t;let r=()=>{this.setState({isZoomImgLoaded:!0})};n.decode().then(r).catch(()=>{if(hy(n)){r();return}n.onload=r})}},this.UNSAFE_handleSvg=()=>{let{imgEl:e,refModalImg:t,styleModalImg:n}=this;if(gy(e)){let r=e.cloneNode(!0);Ay(r),r.style.width=`${n.width??0}px`,r.style.height=`${n.height??0}px`,r.addEventListener(`click`,this.handleUnzoom),t.current?.firstChild?.remove(),t.current?.appendChild(r)}}}render(){let{handleBtnUnzoomClick:e,handleDialogClick:t,handleDialogClose:n,handleUnzoom:r,handleZoom:i,imgEl:a,props:{a11yNameButtonUnzoom:o,a11yNameButtonZoom:s,children:c,classDialog:l,IconUnzoom:u,IconZoom:d,isZoomed:f,wrapElement:p,ZoomContent:m,zoomImg:h,zoomMargin:g},refContent:_,refDialog:v,refModalContent:y,refModalImg:b,refWrap:x,state:{id:S,isZoomImgLoaded:C,loadedImgEl:w,modalState:T,shouldRefresh:E,styleGhost:D}}=this,O=`rmiz-modal-${S}`,k=`rmiz-modal-img-${S}`,A=py(a),j=my(a),M=gy(a),N=Sy(a),P=xy(a),F=j?a.sizes:void 0,I=j?a.srcset:void 0,L=j?a.crossOrigin:void 0,ee=h?.src!==void 0&&h.src!==``,R=this.hasImage(),te=N!==void 0&&N!==``?`${s}: ${N}`:s,ne=T===`LOADING`||T===`LOADED`,re=R?`found`:`not-found`,ie=T===`UNLOADED`||T===`UNLOADING`?`hidden`:`visible`,ae={visibility:T===`UNLOADED`?`visible`:`hidden`};this.styleModalImg=R&&a!==null?Oy({hasZoomImg:ee,imgSrc:P,isSvg:M,isZoomed:f&&ne,loadedImgEl:w,offset:g,shouldRefresh:E,targetEl:a}):{};let oe=null;if(R){let t=j||A?Z.createElement(`img`,{alt:N,crossOrigin:L,sizes:F,src:P,srcSet:I,...C&&T===`LOADED`?h:{},"data-rmiz-modal-img":``,height:this.styleModalImg.height??void 0,id:k,ref:b,style:this.styleModalImg,width:this.styleModalImg.width??void 0}):M?Z.createElement(`div`,{"data-rmiz-modal-img":!0,ref:b,style:this.styleModalImg}):null,n=Z.createElement(`button`,{"aria-label":o,"data-rmiz-btn-unzoom":``,onClick:e,type:`button`},Z.createElement(u,null));oe=m==null?Z.createElement(Z.Fragment,null,t,n):Z.createElement(m,{buttonUnzoom:n,modalState:T,img:t,isZoomImgLoaded:C,onUnzoom:r})}return Z.createElement(p,{"aria-owns":R?O:void 0,"data-rmiz":``,ref:x},Z.createElement(p,{"data-rmiz-content":re,ref:_,style:ae},c),R&&Z.createElement(p,{"data-rmiz-ghost":``,style:D},Z.createElement(`button`,{"aria-label":te,"data-rmiz-btn-zoom":``,onClick:i,type:`button`},Z.createElement(d,null))),R&&Ss.createPortal(Z.createElement(`dialog`,{"aria-labelledby":k,"aria-modal":`true`,className:l,"data-rmiz-modal":``,id:O,onClick:t,onClose:n,onCancel:Py,ref:v,role:`dialog`},Z.createElement(`div`,{"data-rmiz-modal-overlay":ie}),Z.createElement(`div`,{"data-rmiz-modal-content":``,ref:y},oe)),Ny()))}componentDidMount(){this.setId(),this.setAndTrackImg(),this.handleImgLoad(),this.UNSAFE_handleSvg()}componentWillUnmount(){this.state.modalState!==`UNLOADED`&&this.bodyScrollEnable(),this.contentChangeObserver?.disconnect(),this.contentNotFoundChangeObserver?.disconnect(),this.imgElResizeObserver?.disconnect(),this.imgEl?.removeEventListener(`load`,this.handleImgLoad),this.imgEl?.removeEventListener(`click`,this.handleZoom),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),window.removeEventListener(`resize`,this.handleResize),document.removeEventListener(`keydown`,this.handleKeyDown,!0)}componentDidUpdate(e,t){this.handleModalStateChange(t.modalState),this.UNSAFE_handleSvg(),this.handleIfZoomChanged(e.isZoomed)}};Iy.defaultProps={a11yNameButtonUnzoom:`Minimize image`,a11yNameButtonZoom:`Expand image`,canSwipeToUnzoom:!0,IconUnzoom:ly,IconZoom:uy,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:`div`,zoomMargin:0};function Ly({onZoomChange:e,...t}){let[n,r]=Z.useState(!1),i=Z.useCallback((t,{event:n})=>{r(t),e?.(t,{event:n})},[e]);return Z.createElement(Fy,{...t,isZoomed:n,onZoomChange:i})}var Ry=e(t(((e,t)=>{(function(e){let n=`(0?\\d+|0x[a-f0-9]+)`,r={fourOctet:RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,`i`),threeOctet:RegExp(`^${n}\\.${n}\\.${n}$`,`i`),twoOctet:RegExp(`^${n}\\.${n}$`,`i`),longValue:RegExp(`^${n}$`,`i`)},i=RegExp(`^0[0-7]+$`,`i`),a=RegExp(`^0x[a-f0-9]+$`,`i`),o=`%[0-9a-z]{1,}`,s=`(?:[0-9a-f]+::?)+`,c={zoneIndex:new RegExp(o,`i`),native:RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,`i`),deprecatedTransitional:RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,`i`),transitional:RegExp(`^((?:${s})|(?:::)(?:${s})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,`i`)};function l(e,t){if(e.indexOf(`::`)!==e.lastIndexOf(`::`))return null;let n=0,r=-1,i=(e.match(c.zoneIndex)||[])[0],a,o;for(i&&(i=i.substring(1),e=e.replace(/%.+$/,``));(r=e.indexOf(`:`,r+1))>=0;)n++;if(e.substr(0,2)===`::`&&n--,e.substr(-2,2)===`::`&&n--,n>t)return null;for(o=t-n,a=`:`;o--;)a+=`0:`;return e=e.replace(`::`,a),e[0]===`:`&&(e=e.slice(1)),e[e.length-1]===`:`&&(e=e.slice(0,-1)),t=(function(){let t=e.split(`:`),n=[];for(let e=0;e<t.length;e++)n.push(parseInt(t[e],16));return n})(),{parts:t,zoneId:i}}function u(e,t,n,r){if(e.length!==t.length)throw Error(`ipaddr: cannot match CIDR for objects with different lengths`);let i=0,a;for(;r>0;){if(a=n-r,a<0&&(a=0),e[i]>>a!==t[i]>>a)return!1;r-=n,i+=1}return!0}function d(e){if(a.test(e))return parseInt(e,16);if(e[0]===`0`&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function f(e,t){for(;e.length<t;)e=`0${e}`;return e}let p={};p.IPv4=(function(){function e(e){if(e.length!==4)throw Error(`ipaddr: ipv4 octet count should be 4`);let t,n;for(t=0;t<e.length;t++)if(n=e[t],!(0<=n&&n<=255))throw Error(`ipaddr: ipv4 octet should fit in 8 bits`);this.octets=e}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]],as112:[[new e([192,175,48,0]),24],[new e([192,31,196,0]),24]],amt:[[new e([192,52,193,0]),24]]},e.prototype.kind=function(){return`ipv4`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv4`)throw Error(`ipaddr: cannot match ipv4 address with non-ipv4 one`);return u(this.octets,e.octets,8,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},r,i,a;for(r=3;r>=0;--r)if(i=this.octets[r],i in n){if(a=n[i],t&&a!==0)return null;a!==8&&(t=!0),e+=a}else return null;return 32-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(`.`)},e})(),p.IPv4.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<4;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch{throw Error(`ipaddr: the address does not have IPv4 CIDR format`)}},p.IPv4.isIPv4=function(e){return this.parser(e)!==null},p.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch{return!1}},p.IPv4.isValidCIDR=function(e){try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(e){return!!(p.IPv4.isValid(e)&&e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.isValidCIDRFourPartDecimal=function(e){let t=e.match(/^(.+)\/(\d+)$/);return!p.IPv4.isValidCIDR(e)||!t?!1:p.IPv4.isValidFourPartDecimal(t[1])},p.IPv4.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch{throw Error(`ipaddr: the address does not have IPv4 CIDR format`)}},p.IPv4.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv4 Address`);return new this(t)},p.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){let e=parseInt(t[2]);if(e>=0&&e<=32){let n=[this.parse(t[1]),e];return Object.defineProperty(n,`toString`,{value:function(){return this.join(`/`)}}),n}}throw Error(`ipaddr: string is not formatted like an IPv4 CIDR range`)},p.IPv4.parser=function(e){let t,n,i;if(t=e.match(r.fourOctet))return(function(){let e=t.slice(1,6),r=[];for(let t=0;t<e.length;t++)n=e[t],r.push(d(n));return r})();if(t=e.match(r.longValue)){if(i=d(t[1]),i>4294967295||i<0)throw Error(`ipaddr: address outside defined range`);return(function(){let e=[],t;for(t=0;t<=24;t+=8)e.push(i>>t&255);return e})().reverse()}else if(t=e.match(r.twoOctet))return(function(){let e=t.slice(1,4),n=[];if(i=d(e[1]),i>16777215||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(i>>16&255),n.push(i>>8&255),n.push(i&255),n})();else if(t=e.match(r.threeOctet))return(function(){let e=t.slice(1,5),n=[];if(i=d(e[2]),i>65535||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(d(e[1])),n.push(i>>8&255),n.push(i&255),n})();else return null},p.IPv4.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),e<0||e>32)throw Error(`ipaddr: invalid IPv4 prefix length`);let t=[0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<4&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.IPv6=(function(){function e(e,t){let n,r;if(e.length===16)for(this.parts=[],n=0;n<=14;n+=2)this.parts.push(e[n]<<8|e[n+1]);else if(e.length===8)this.parts=e;else throw Error(`ipaddr: ipv6 part count should be 8 or 16`);for(n=0;n<this.parts.length;n++)if(r=this.parts[n],!(0<=r&&r<=65535))throw Error(`ipaddr: ipv6 part should fit in 16 bits`);t&&(this.zoneId=t)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],deprecatedSiteLocal:[new e([65216,0,0,0,0,0,0,0]),10],discard:[new e([256,0,0,0,0,0,0,0]),64],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[[new e([100,65435,0,0,0,0,0,0]),96],[new e([100,65435,1,0,0,0,0,0]),48]],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[[new e([8193,4,274,0,0,0,0,0]),48],[new e([9760,79,32768,0,0,0,0,0]),48]],deprecatedOrchid:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new e([8193,48,0,0,0,0,0,0]),28],segmentRouting:[new e([24320,0,0,0,0,0,0,0]),16],reserved:[[new e([8193,0,0,0,0,0,0,0]),23],[new e([8193,3512,0,0,0,0,0,0]),32],[new e([16383,0,0,0,0,0,0,0]),20]]},e.prototype.isIPv4MappedAddress=function(){return this.range()===`ipv4Mapped`},e.prototype.kind=function(){return`ipv6`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv6`)throw Error(`ipaddr: cannot match ipv6 address with non-ipv6 one`);return u(this.parts,e.parts,16,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},r,i;for(let a=7;a>=0;--a)if(r=this.parts[a],r in n){if(i=n[r],t&&i!==0)return null;i!==16&&(t=!0),e+=i}else return null;return 128-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e,t=[],n=this.parts;for(let r=0;r<n.length;r++)e=n[r],t.push(e>>8),t.push(e&255);return t},e.prototype.toFixedLengthString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(f(this.parts[t].toString(16),4));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw Error(`ipaddr: trying to convert a generic ipv6 address to ipv4`);let e=this.parts.slice(-2),t=e[0],n=e[1];return new p.IPv4([t>>8,t&255,n>>8,n&255])},e.prototype.toNormalizedString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(this.parts[t].toString(16));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toRFC5952String=function(){let e=/((^|:)(0(:|$)){2,})/g,t=this.toNormalizedString(),n=0,r=-1,i;for(;i=e.exec(t);)i[0].length>r&&(n=i.index,r=i[0].length);return r<0?t:`${t.substring(0,n)}::${t.substring(n+r)}`},e.prototype.toString=function(){return this.toRFC5952String()},e})(),p.IPv6.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<16;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`)}},p.IPv6.isIPv6=function(e){return this.parser(e)!==null},p.IPv6.isValid=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{let t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch{return!1}},p.IPv6.isValidCIDR=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<16;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`)}},p.IPv6.parse=function(e){let t=this.parser(e);if(t.parts===null)throw Error(`ipaddr: string is not formatted like an IPv6 Address`);return new this(t.parts,t.zoneId)},p.IPv6.parseCIDR=function(e){let t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=128))return r=[this.parse(n[1]),t],Object.defineProperty(r,`toString`,{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv6 CIDR range`)},p.IPv6.parser=function(e){let t,n,r,i,a,o;if(r=e.match(c.deprecatedTransitional))return this.parser(`::ffff:${r[1]}`);if(c.native.test(e))return l(e,8);if((r=e.match(c.transitional))&&(o=r[6]||``,t=r[1],r[1].endsWith(`::`)||(t=t.slice(0,-1)),t=l(t+o,6),t.parts)){for(a=[parseInt(r[2]),parseInt(r[3]),parseInt(r[4]),parseInt(r[5])],n=0;n<a.length;n++)if(i=a[n],!(0<=i&&i<=255))return null;return t.parts.push(a[0]<<8|a[1]),t.parts.push(a[2]<<8|a[3]),{parts:t.parts,zoneId:t.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),e<0||e>128)throw Error(`ipaddr: invalid IPv6 prefix length`);let t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<16&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.fromByteArray=function(e){let t=e.length;if(t===4)return new p.IPv4(e);if(t===16)return new p.IPv6(e);throw Error(`ipaddr: the binary input is neither an IPv6 nor IPv4 address`)},p.isValid=function(e){return p.IPv6.isValid(e)||p.IPv4.isValid(e)},p.isValidCIDR=function(e){return p.IPv6.isValidCIDR(e)||p.IPv4.isValidCIDR(e)},p.parse=function(e){if(p.IPv6.isValid(e))return p.IPv6.parse(e);if(p.IPv4.isValid(e))return p.IPv4.parse(e);throw Error(`ipaddr: the address has neither IPv6 nor IPv4 format`)},p.parseCIDR=function(e){try{return p.IPv6.parseCIDR(e)}catch{try{return p.IPv4.parseCIDR(e)}catch{throw Error(`ipaddr: the address has neither IPv6 nor IPv4 CIDR format`)}}},p.process=function(e){let t=this.parse(e);return t.kind()===`ipv6`&&t.isIPv4MappedAddress()?t.toIPv4Address():t},p.subnetMatch=function(e,t,n){let r,i,a,o;for(i in n??=`unicast`,t)if(Object.prototype.hasOwnProperty.call(t,i)){for(a=t[i],a[0]&&!(a[0]instanceof Array)&&(a=[a]),r=0;r<a.length;r++)if(o=a[r],e.kind()===o[0].kind()&&e.match.apply(e,o))return i}return n},t!==void 0&&t.exports?t.exports=p:e.ipaddr=p})(e)}))(),1),zy=new Set([`href`,`src`,`srcset`,`poster`,`formaction`,`xlink:href`]),By=new Set([`aria-label`,`aria-description`,`title`]),Vy=/(?:[a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^\s"'<>]+|(?:javascript|vbscript|data|file|chrome-extension|moz-extension):[^\s"'<>]*)/gi,Hy=/url\s*\(\s*['"]?\s*(?:javascript|vbscript|data)\s*:/i,Uy=/\bexpression\s*\(/i,Wy=/(oklch|oklab|lab|lch)\(\s*([^)]+)\s*\)/gi,Gy=`data-clipboard-omit`;function Ky(e){let t=e.trim();return t===``||Xi.test(t)?!0:Qi(t)}function qy(e){let t=e.split(`,`);for(let e of t){let t=e.trim();if(t!==``&&!Ky(t.split(/\s+/)[0]??``))return!1}return!0}function Jy(e,t){let n=!1,r=e.replace(Vy,e=>Ky(e)?e:(n=!0,`[blocked]`));return t?.reportNoChange&&!n?null:r}function Yy(e){let t=e.toLowerCase();return t.length>=3&&t.startsWith(`on`)}function Xy(e){return e.length>1e4||Hy.test(e)||Uy.test(e)?``:e}function Zy(e){let t=e.indexOf(`/`),n=(t===-1?e:e.slice(0,t)).trim(),r=t===-1?null:e.slice(t+1).trim(),i=n.split(/[\s,]+/).filter(e=>e.length>0);if(i.length!==3)return null;let a=Qy(i[0],1),o=Qy(i[1],1),s=Qy(i[2],1);if(Number.isNaN(a)||Number.isNaN(o)||Number.isNaN(s))return null;let c=null;if(r!==null){if(c=Qy(r,1),Number.isNaN(c))return null;c=Math.max(0,Math.min(1,c))}return[a,o,s,c]}function Qy(e,t){return e===`none`?0:e.endsWith(`%`)?Number.parseFloat(e.slice(0,-1))/100*t:Number.parseFloat(e)}function $y(e,t,n){let r=n*Math.PI/180;return[e,t*Math.cos(r),t*Math.sin(r)]}function eb(e,t,n){let r=e+.3963377774*t+.2158037573*n,i=e-.1055613458*t-.0638541728*n,a=e-.0894841775*t-1.291485548*n,o=r**3,s=i**3,c=a**3;return[4.0767416621*o-3.3077115913*s+.2309699292*c,-1.2684380046*o+2.6097574011*s-.3413193965*c,-.0041960863*o-.7034186147*s+1.707614701*c]}function tb(e){return e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055}function nb(e){return Number.isFinite(e)?Math.max(0,Math.min(255,Math.round(e*255))):0}function rb(e,t,n,r){let i=e.toLowerCase(),a,o,s;i===`oklch`?[a,o,s]=$y(t,n,r):i===`oklab`?[a,o,s]=[t,n,r]:i===`lch`?[a,o,s]=$y(t/100,n/100,r):[a,o,s]=[t/100,n/100,r/100];let[c,l,u]=eb(a,o,s);return[nb(tb(c)),nb(tb(l)),nb(tb(u))]}function ib(e){if(e.length>1e4)return e;let t=e.toLowerCase();return!t.includes(`oklch`)&&!t.includes(`oklab`)&&!t.includes(`lab`)&&!t.includes(`lch`)?e:e.replace(Wy,(e,t,n)=>{let r=Zy(n);if(r===null)return e;let[i,a,o,s]=r,[c,l,u]=rb(t,i,a,o);return s===null?`rgb(${c}, ${l}, ${u})`:`rgba(${c}, ${l}, ${u}, ${s})`})}var ab=new Set([`mailto`,`tel`,`sms`,`ftp`,`ftps`]);function ob(e){let t=e.trim();if(t.startsWith(`#`))return{portable:!0};if(Qi(t))return t.startsWith(`/`)?{portable:!1,reason:`server-absolute`}:{portable:!1,reason:`relative`};let n=new URL(t),r=n.protocol.slice(0,-1).toLowerCase();if(ab.has(r))return{portable:!0};if(r!==`http`&&r!==`https`)return{portable:!1,reason:`other`};let i=n.hostname.toLowerCase();if(i===``)return{portable:!1,reason:`other`};let a=i.endsWith(`.`)?i.slice(0,-1):i;if(a===`localhost`||a.endsWith(`.localhost`))return{portable:!1,reason:`localhost`};let o=i.startsWith(`[`)&&i.endsWith(`]`)?i.slice(1,-1):i;return Ry.IPv4.isValid(o)?Ry.IPv4.parse(o).range()===`unicast`?{portable:!0}:{portable:!1,reason:`private-ip`}:Ry.IPv6.isValid(o)?Ry.IPv6.parse(o).range()===`unicast`?{portable:!0}:{portable:!1,reason:`private-ip`}:{portable:!0}}function sb(e,t){return typeof e==`number`&&typeof t==`number`&&e>0&&t>0}function cb(e,t,n){return sb(e,t)?{...n,width:`${e}px`,aspectRatio:`${e} / ${t}`}:n}function lb(e){let t=(0,Q.c)(75),n,r,i,a,s,c,l,u,f,p,m,h,g;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],s=t[5],c=t[6],l=t[7],u=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13]):({width:g,height:r,loadingTestId:f,slotTestId:p,slotClassName:c,className:n,onLoad:s,onError:a,src:l,style:u,alt:m,targetExistence:h,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=f,t[10]=p,t[11]=m,t[12]=h,t[13]=g);let _=f===void 0?`image-loading-skeleton`:f,v=p===void 0?`image-slot`:p,y=m===void 0?``:m,b=h===void 0?`unknown`:h,{_:x}=o(),S=(0,Z.useRef)(null),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(0),k;t[14]!==r||t[15]!==g?(k=sb(g,r),t[14]=r,t[15]=g,t[16]=k):k=t[16];let A=k,j;t[17]!==r||t[18]!==u||t[19]!==g?(j=cb(g,r,u),t[17]=r,t[18]=u,t[19]=g,t[20]=j):j=t[20];let M=j,N;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>{let e=S.current;if(e?.complete){if(w(!0),E(!1),typeof e.decode==`function`){let t=!1;return e.decode().then(db,()=>{t||E(!0)}),()=>{t=!0}}}else w(!1),E(!1)},t[21]=N):N=t[21];let P;t[22]!==D||t[23]!==l?(P=[l,D],t[22]=D,t[23]=l,t[24]=P):P=t[24],(0,Z.useLayoutEffect)(N,P);let F=(0,Z.useRef)(b),I,L;t[25]===b?(I=t[26],L=t[27]):(L=()=>{let e=F.current;F.current=b,e===`missing`&&b!==`missing`&&(w(!1),E(!1),O(ub))},I=[b],t[25]=b,t[26]=I,t[27]=L),(0,Z.useEffect)(L,I);let ee=b===`missing`?`not-found`:T?`undisplayable`:null,R=y&&y.length>0?y:l??``,te;t[28]!==x||t[29]!==ee?(te=x(ee===`not-found`?{id:`1pdLQw`}:{id:`XGKy1z`}),t[28]=x,t[29]=ee,t[30]=te):te=t[30];let ne=te,re;t[31]!==x||t[32]!==ee||t[33]!==R?(re=x(ee===`not-found`?{id:`kI5pWt`,values:{errorLabel:R}}:{id:`VZg6Gn`,values:{errorLabel:R}}),t[31]=x,t[32]=ee,t[33]=R,t[34]=re):re=t[34];let ie=re,ae=ee?`true`:void 0,oe=ee??void 0,se=!A&&!C&&!ee&&`aspect-[16/9] w-full max-w-full`,z;t[35]!==c||t[36]!==se?(z=d(`relative inline-block overflow-hidden`,se,c),t[35]=c,t[36]=se,t[37]=z):z=t[37];let B;t[38]!==x||t[39]!==ee||t[40]!==C||t[41]!==_?(B=!C&&!ee&&(0,$.jsx)(`span`,{"data-testid":_,role:`status`,"aria-busy":`true`,"aria-label":x({id:`N1YYa7`}),className:`absolute inset-0 animate-pulse rounded-md bg-foreground/10 motion-reduce:animate-none`}),t[38]=x,t[39]=ee,t[40]=C,t[41]=_,t[42]=B):B=t[42];let ce=ee?!0:void 0,V=C?`opacity-100`:`opacity-0`,H;t[43]!==n||t[44]!==V?(H=d(`block max-w-full transition-opacity motion-reduce:transition-none`,V,n),t[43]=n,t[44]=V,t[45]=H):H=t[45];let U;t[46]===s?U=t[47]:(U=e=>{w(!0),E(!1),s?.(e)},t[46]=s,t[47]=U);let W;t[48]===a?W=t[49]:(W=e=>{w(!0),E(!0),a?.(e)},t[48]=a,t[49]=W);let le;t[50]!==y||t[51]!==r||t[52]!==i||t[53]!==D||t[54]!==l||t[55]!==ce||t[56]!==H||t[57]!==U||t[58]!==W||t[59]!==g?(le=(0,Z.createElement)(`img`,{...i,key:D,ref:S,src:l,alt:y,width:g,height:r,hidden:ce,className:H,onLoad:U,onError:W}),t[50]=y,t[51]=r,t[52]=i,t[53]=D,t[54]=l,t[55]=ce,t[56]=H,t[57]=U,t[58]=W,t[59]=g,t[60]=le):le=t[60];let G;t[61]!==ie||t[62]!==ee||t[63]!==ne||t[64]!==l?(G=ee&&(0,$.jsxs)(`span`,{role:`img`,"aria-label":ie,"data-clipboard-omit":`true`,className:`ok-image-error-placeholder box-border inline-grid max-w-full grid-cols-[auto_minmax(0,1fr)] items-start gap-x-2 rounded-md border border-dashed px-2 py-1 text-foreground`,children:[(0,$.jsx)(ru,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`ok-image-error-message block text-xs font-medium`,children:ne}),l?(0,$.jsx)(`span`,{className:`ok-image-error-target block max-w-[24ch] truncate font-mono text-xs`,title:l,children:l}):null]})]}),t[61]=ie,t[62]=ee,t[63]=ne,t[64]=l,t[65]=G):G=t[65];let ue;return t[66]!==M||t[67]!==v||t[68]!==ae||t[69]!==oe||t[70]!==z||t[71]!==B||t[72]!==le||t[73]!==G?(ue=(0,$.jsxs)(`span`,{"data-testid":v,"data-image-error":ae,"data-image-error-kind":oe,className:z,style:M,children:[B,le,G]}),t[66]=M,t[67]=v,t[68]=ae,t[69]=oe,t[70]=z,t[71]=B,t[72]=le,t[73]=G,t[74]=ue):ue=t[74],ue}function ub(e){return e+1}function db(){}function fb(e,t,n,r){return po(e,t,{literal:!1})===null?`unknown`:ur(e,t,n,r,{literal:!1})?`exists`:`missing`}function pb(e){let t=(0,Q.c)(4),n=ts();if(e===void 0||e===``)return`missing`;if(n===null||n.loading)return`unknown`;let r;return t[0]!==n.assetPaths||t[1]!==n.filePaths||t[2]!==e?(r=fb(e,``,n.assetPaths,n.filePaths),t[0]=n.assetPaths,t[1]=n.filePaths,t[2]=e,t[3]=r):r=t[3],r}function mb(e){return e??`lazy`}function hb(e){if(typeof e!=`string`)return e;let t=Number(e);return Number.isFinite(t)&&t>0?t:e}function gb(e){let t=(0,Q.c)(22),n=pb(e.src),r;t[0]===e.src?r=t[1]:(r=e.src===void 0?void 0:Lo(e.src),t[0]=e.src,t[1]=r);let i=e.alt??``,a;t[2]===e.width?a=t[3]:(a=hb(e.width),t[2]=e.width,t[3]=a);let o;t[4]===e.height?o=t[5]:(o=hb(e.height),t[4]=e.height,t[5]=o);let s=e.title,c;t[6]===e.loading?c=t[7]:(c=mb(e.loading),t[6]=e.loading,t[7]=c);let l;return t[8]!==e.crossorigin||t[9]!==e.decoding||t[10]!==e.fetchpriority||t[11]!==e.referrerpolicy||t[12]!==e.sizes||t[13]!==e.srcset||t[14]!==e.title||t[15]!==r||t[16]!==i||t[17]!==a||t[18]!==o||t[19]!==c||t[20]!==n?(l=(0,$.jsx)(lb,{src:r,alt:i,width:a,height:o,title:s,loading:c,srcSet:e.srcset,sizes:e.sizes,decoding:e.decoding,fetchPriority:e.fetchpriority,crossOrigin:e.crossorigin,referrerPolicy:e.referrerpolicy,targetExistence:n}),t[8]=e.crossorigin,t[9]=e.decoding,t[10]=e.fetchpriority,t[11]=e.referrerpolicy,t[12]=e.sizes,t[13]=e.srcset,t[14]=e.title,t[15]=r,t[16]=i,t[17]=a,t[18]=o,t[19]=c,t[20]=n,t[21]=l):l=t[21],l}function _b(e){let t=(0,Q.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={sizes:void 0},t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,$.jsx)(Ly,{wrapElement:`span`,zoomMargin:20,zoomImg:n,children:(0,$.jsx)(gb,{...e})}),t[1]=e,t[2]=r),r}var vb=(0,Z.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-BCLP08X6.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,Q.c)(7),r;n[0]===t.formula?r=n[1]:(r=e.renderToString(t.formula,{displayMode:!0,throwOnError:!1,strict:`ignore`,trust:!1}),n[0]=t.formula,n[1]=r);let i=r,a;n[2]===i?a=n[3]:(a={__html:i},n[2]=i,n[3]=a);let o;return n[4]!==t.id||n[5]!==a?(o=(0,$.jsx)(`div`,{className:`math math-display`,"data-component-type":`math`,id:t.id,dangerouslySetInnerHTML:a}),n[4]=t.id,n[5]=a,n[6]=o):o=n[6],o}return{default:t}});function yb(e){let t=(0,Q.c)(3),n=e.formula||`\xA0`,r;return t[0]!==e.id||t[1]!==n?(r=(0,$.jsx)(`div`,{className:`math math-placeholder`,"data-component-type":`math`,id:e.id,children:n}),t[0]=e.id,t[1]=n,t[2]=r):r=t[2],r}function bb(e){let t=(0,Q.c)(6),n=e.formula??``;if(!n){let r;return t[0]!==n||t[1]!==e.id?(r=(0,$.jsx)(yb,{formula:n,id:e.id}),t[0]=n,t[1]=e.id,t[2]=r):r=t[2],r}let r;return t[3]!==n||t[4]!==e.id?(r=(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(yb,{formula:n,id:e.id}),children:(0,$.jsx)(vb,{formula:n,id:e.id})}),t[3]=n,t[4]=e.id,t[5]=r):r=t[5],r}function xb(e){return typeof e==`string`?e:typeof e==`number`?String(e):``}function Sb(e){let t=this,n={...t.data(`settings`),...e};t.compiler=r;function r(e){return as(e,n)}}var Cb=new Set([`img`,`video`,`audio`,`mark`,`u`,`ins`]),wb=new Map(Nn.flatMap(e=>e.surface===`compat`&&Cb.has(e.rendersAs)?[[e.name,e]]:[]));function Tb(e){let t={};for(let n of e.attributes){if(n.type!==`mdxJsxAttribute`)return null;let e=n.name.toLowerCase();if(!(e.length>=3&&e.startsWith(`on`)))if(n.value===null)t[n.name]=!0;else if(typeof n.value==`string`)t[n.name]=n.value;else return null}return t}function Eb(e){let t=e.name;if(!t||!Cb.has(t))return null;let n=Tb(e);return n===null?null:{type:`element`,tagName:t,properties:n,children:[]}}function Db(e){let t=e.name;if(!t)return null;let n=wb.get(t);if(!n)return null;let r=Tb(e);if(r===null)return null;let i=n.translateProps(r),a={};for(let[e,t]of Object.entries(i))(typeof t==`string`||typeof t==`boolean`)&&(a[e]=t);return{type:`element`,tagName:n.rendersAs,properties:a,children:[]}}var Ob=(e,t)=>{let n=t,{target:r,anchor:i,alias:a}=n.data,o={type:`element`,tagName:`a`,properties:{className:[`wiki-link`],dataTarget:r,dataAnchor:i??``,dataAlias:a??``,href:$a(r,i)},children:n.children.length>0?e.all(n):[{type:`text`,value:n.value}]};return e.patch(t,o),e.applyData(t,o)},kb=(e,t)=>{let n=t,{target:r,anchor:i,alias:a}=n.data,o={type:`element`,tagName:`a`,properties:{className:[`wiki-embed`],dataTarget:r,dataAnchor:i??``,dataAlias:a??``,href:$a(r,i)},children:n.children.length>0?e.all(n):[{type:`text`,value:n.value}]};return e.patch(t,o),e.applyData(t,o)},Ab=(e,t)=>{let n=t,r=Eb(n);if(r)return n.children.length>0&&(r.children=e.all(n)),e.patch(t,r),e.applyData(t,r);let i=Db(n);if(i){e.patch(t,i);let n=e.applyData(t,i);return n.tagName===`img`?{type:`element`,tagName:`p`,properties:{},children:[n]}:n}let a={type:`element`,tagName:`pre`,properties:{className:[`mdx-component`]},children:[{type:`element`,tagName:`code`,properties:{},children:[{type:`text`,value:typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:``}]}]};return e.patch(t,a),e.applyData(t,a)},jb=(e,t)=>{let n=t,r=Eb(n);if(r)return n.children.length>0&&(r.children=e.all(n)),e.patch(t,r),e.applyData(t,r);let i=Db(n);if(i)return e.patch(t,i),e.applyData(t,i);let a={type:`element`,tagName:`span`,properties:{className:[`mdx-inline`],dataJsxInline:``},children:[{type:`text`,value:typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:``}]};return e.patch(t,a),e.applyData(t,a)},Mb=(e,t)=>{let n=t,r=n.data.reason||`unknown`,i=n.value||``,a=r.replace(/--/g,`—`),o={type:`comment`,value:` Parse error: ${a} `},s={type:`element`,tagName:`pre`,properties:{className:[`mdx-fallback`],dataRawMdxFallback:``,dataReason:a},children:[{type:`element`,tagName:`code`,properties:{},children:[{type:`text`,value:i}]}]};return e.patch(t,s),[o,e.applyData(t,s)]},Nb=(e,t)=>{let n={type:`element`,tagName:`mark`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},Pb=(e,t)=>{let n=t,r={type:`element`,tagName:n.data?.sourceForm===`ins`?`ins`:`u`,properties:{},children:e.all(n)};return e.patch(t,r),e.applyData(t,r)};function Fb(e){if(typeof e!=`object`||!e)return``;let t=e;return typeof t.value==`string`?t.value:Array.isArray(t.children)?t.children.map(Fb).join(``):``}var Ib={wikiLink:Ob,wikiLinkEmbed:kb,mdxJsxFlowElement:Ab,mdxJsxTextElement:jb,rawMdxFallback:Mb,mark:Nb,underline:Pb,tag:(e,t)=>{let n=t.value,r={type:`element`,tagName:`a`,properties:{className:[`tag`],dataTag:n,href:`#tag/${n}`},children:[{type:`text`,value:`#${n}`}]};return e.patch(t,r),e.applyData(t,r)},comment:(e,t)=>{let n={type:`comment`,value:Fb(t).replace(/--/g,`—`)};return e.patch(t,n),e.applyData(t,n)},commentBlock:(e,t)=>{let n={type:`comment`,value:Fb(t).replace(/--/g,`—`)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:(e,t)=>{let n=t.identifier,r={type:`element`,tagName:`sup`,properties:{id:`fnref-${n}`,dataFootnoteRef:``,dataFootnoteId:n,className:[`footnote-ref`]},children:[{type:`element`,tagName:`a`,properties:{href:`#fn-${n}`,className:[`footnote-ref-link`]},children:[{type:`text`,value:`[${n}]`}]}]};return e.patch(t,r),e.applyData(t,r)},footnoteDefinition:(e,t)=>{let n=t.identifier,r={type:`element`,tagName:`aside`,properties:{id:`fn-${n}`,dataFootnoteDef:``,dataFootnoteId:n,className:[`footnote-def`]},children:[{type:`element`,tagName:`div`,properties:{className:[`footnote-body`]},children:e.all(t)},{type:`element`,tagName:`a`,properties:{href:`#fnref-${n}`,className:[`footnote-backref`],ariaLabel:`Back to reference`},children:[{type:`text`,value:`↩`}]}]};return e.patch(t,r),e.applyData(t,r)}},Lb=/url\s*\(\s*['"]?\s*(?:javascript|vbscript|data)\s*:/i,Rb=/\bexpression\s*\(/i,zb=1e4;function Bb(e){return!(e.length>zb||Lb.test(e)||Rb.test(e))}function Vb(e){for(let t of e.split(`,`)){let e=t.trim();if(e!==``&&!Yi(e.split(/\s+/)[0]??``))return!1}return!0}var Hb={a:[`href`,`title`],img:[`src`,`alt`,`title`],video:[`src`,`title`],audio:[`src`,`title`],code:[`className`]},Ub=new Set([`href`,`src`]),Wb=Yo(`<>`),Gb=()=>e=>{zo(e,`element`,e=>{let t=Hb[e.tagName.toLowerCase()],n=e.properties;if(!(!t||!n))for(let e of t){let t=n[e];if(Array.isArray(t)){let r=t.map(e=>typeof e==`string`?Dr(e):e);r.some((e,n)=>e!==t[n])&&(n[e]=r);continue}if(typeof t!=`string`)continue;let r;if(Ub.has(e))if(t===`<>`||t===Wb)r=``;else{let e=Dr(t);r=e===t?t:Yo(e)}else r=Dr(t);r!==t&&(n[e]=r)}})},Kb=()=>e=>{zo(e,`element`,e=>{let t=e.tagName.toLowerCase(),n=e.properties;if(!n)return;if(t===`a`||t===`area`||t===`link`||t===`base`){let e=n.href;typeof e==`string`&&!Yi(e)&&delete n.href}if(t===`img`||t===`iframe`||t===`script`||t===`embed`||t===`source`||t===`audio`||t===`video`||t===`track`){let e=n.src;typeof e==`string`&&!Yi(e)&&delete n.src}if(t===`form`){let e=n.action;typeof e==`string`&&!Yi(e)&&delete n.action}if(t===`img`||t===`source`){let e=n.srcSet;typeof e==`string`&&!Vb(e)&&delete n.srcSet;let t=n.srcset;typeof t==`string`&&!Vb(t)&&delete n.srcset}if(t===`video`){let e=n.poster;typeof e==`string`&&!Yi(e)&&delete n.poster}let r=n.style;typeof r==`string`&&!Bb(r)&&delete n.style})};function qb(e){let t=Vo().use(Xo,{handlers:Ib}).use(Gb).use(Kb).use(Sb),n=t.runSync(e);return String(t.stringify(n))}function Jb(e){let t=/\r?\n|\r/g,n=[],r=0,i=t.exec(e);for(;i!==null;)n.push(Yb(e.slice(r,i.index),r>0,!0),i[0]),r=i.index+i[0].length,i=t.exec(e);return n.push(Yb(e.slice(r),r>0,!1)),n.join(``)}function Yb(e,t,n){let r=0,i=e.length,a=e=>e===9||e===32;for(;t&&r<i&&a(e.charCodeAt(r));)r++;for(;n&&i>r&&a(e.charCodeAt(i-1));)i--;return i>r?e.slice(r,i):``}var Xb=/\r?\n|\r/,Zb=(e,t)=>{let n=Jb(String(t.value));if(!Xb.test(n)){let r={type:`text`,value:n};return e.patch(t,r),e.applyData(t,r)}let r=n.split(Xb),i=[];for(let e=0;e<r.length;e++)e>0&&i.push({type:`element`,tagName:`br`,properties:{},children:[]}),r[e].length>0&&i.push({type:`text`,value:r[e]});return i};function Qb(e){let t=Vo().use(Wo).use(Zo,[`yaml`]).use(pr).use(Ho).use(Vr).use(yr).use(gr).use(jr).use(Xo,{handlers:{...Ib,text:Zb}}).use(Gb).use(Kb).use(Sb);return String(t.processSync(cr(ii(e))))}function $b(e){let t=Nn.find(t=>t.name===e);if(!t)throw Error(`No built-in component descriptor named '${e}'`);return t.props}var ex=$b(`MirrorSource`);function tx(e){return xb(fi(ex,e).name)}function nx(e){let t={};for(let n of e.attributes??[])n.type===`mdxJsxAttribute`&&n.name!==void 0&&(t[n.name]=rr(n.value));return tx(t)}function rx(e,t){if(e.type===`mdxJsxFlowElement`){let n=e;if(n.name===`MirrorSource`&&nx(n)===t)return n}let n=e.children;if(Array.isArray(n))for(let e of n){let n=rx(e,t);if(n)return n}return null}function ix(e){return qb({type:`root`,children:e.children??[]})}function ax(e){switch(e){case`at-capacity`:return{kind:`at-capacity`};case`inadmissible`:return{kind:`source-removed`};case`refused`:return{kind:`loading`}}}function ox(e,t){let n=(0,Q.c)(9),{collabUrl:r}=_o(),i=Fv(),a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={kind:`loading`},n[0]=a):a=n[0];let[o,s]=(0,Z.useState)(a),c=(0,Z.useRef)(t),l=(0,Z.useRef)(null),u,d;n[1]!==i||n[2]!==r||n[3]!==e?(u=()=>{if(!e){s({kind:`empty-props`});return}if(!r){s({kind:`loading`});return}let t=i(r,e);if(!t.ok){console.warn(`[Mirror] live-doc pool refused subscription`,{src:e,reason:t.reason}),s(ax(t.reason));return}let{entry:n}=t,a=()=>{let t=c.current;if(!t){s({kind:`empty-props`});return}let r=n.ySource.toString();if(!r){s(n.synced?{kind:`source-removed`}:{kind:`loading`});return}let i;try{i=oi().parseToMdast(r)}catch(n){console.warn(`[Mirror] parseToMdast failed`,{src:e,name:t,err:n}),s({kind:`source-removed`});return}let a=rx(i,t);if(!a){s({kind:`name-not-found`});return}let o;try{o=ix(a)}catch(n){console.warn(`[Mirror] renderMirrorSubtree failed`,{src:e,name:t,err:n}),s({kind:`name-not-found`});return}s(e=>e.kind===`ready`&&e.html===o?e:{kind:`ready`,html:o})},o=null,u=n.subscribe({onUpdate:()=>{o&&clearTimeout(o),o=setTimeout(()=>{o=null,a()},150)},onSynced:()=>{o&&=(clearTimeout(o),null),a()}});l.current=a;let d=setTimeout(()=>{n.synced||s({kind:`source-removed`})},Mv);return a(),()=>{clearTimeout(d),o&&clearTimeout(o),u(),l.current=null,Lv(r,e)}},d=[r,e,i],n[1]=i,n[2]=r,n[3]=e,n[4]=u,n[5]=d):(u=n[4],d=n[5]),(0,Z.useEffect)(u,d);let f,p;return n[6]===t?(f=n[7],p=n[8]):(f=()=>{c.current=t,l.current?.()},p=[t],n[6]=t,n[7]=f,n[8]=p),(0,Z.useEffect)(f,p),o}function sx(e){let t=(0,Q.c)(8),n=`ok-mirror-state flex items-start gap-2 rounded-md border border-dashed px-3 py-2 text-sm ${e.tone===`error`?`border-destructive/40 text-destructive`:`border-border text-muted-foreground`}`,r;t[0]===e.tone?r=t[1]:(r=e.tone===`error`?(0,$.jsx)(su,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}):(0,$.jsx)(lu,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}),t[0]=e.tone,t[1]=r);let i;t[2]===e.children?i=t[3]:(i=(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.children}),t[2]=e.children,t[3]=i);let a;return t[4]!==n||t[5]!==r||t[6]!==i?(a=(0,$.jsxs)(`div`,{className:n,children:[r,i]}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function cx(e){let t=(0,Q.c)(39),n;t[0]===e.src?n=t[1]:(n=xb(e.src),t[0]=e.src,t[1]=n);let r=n,i;t[2]===e.name?i=t[3]:(i=xb(e.name),t[2]=e.name,t[3]=i);let o=i,s=ox(r,o);if(s.kind===`empty-props`){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(sx,{tone:`placeholder`,children:(0,$.jsx)(a,{id:`tOkGFB`,components:{0:(0,$.jsx)(`span`,{className:`font-medium`}),1:(0,$.jsx)(`code`,{}),2:(0,$.jsx)(`code`,{}),3:(0,$.jsx)(`code`,{})}})}),t[4]=e):e=t[4],e}if(s.kind===`loading`){let e=r&&o?`${r}#${o}`:``,n;t[5]===e?n=t[6]:(n={mirrorRef:e},t[5]=e,t[6]=n);let i;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(i={0:(0,$.jsx)(`code`,{})},t[7]=i):i=t[7];let s;return t[8]===n?s=t[9]:(s=(0,$.jsx)(sx,{tone:`placeholder`,children:(0,$.jsx)(a,{id:`92rbk2`,values:n,components:i})}),t[8]=n,t[9]=s),s}if(s.kind===`source-removed`){let e;t[10]===r?e=t[11]:(e={src:r},t[10]=r,t[11]=e);let n;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(n={0:(0,$.jsx)(`span`,{className:`font-medium`}),1:(0,$.jsx)(`code`,{})},t[12]=n):n=t[12];let i;return t[13]===e?i=t[14]:(i=(0,$.jsx)(sx,{tone:`error`,children:(0,$.jsx)(a,{id:`Ud0Pj9`,values:e,components:n})}),t[13]=e,t[14]=i),i}if(s.kind===`at-capacity`){let e;t[15]===r?e=t[16]:(e={src:r},t[15]=r,t[16]=e);let n;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(n={0:(0,$.jsx)(`span`,{className:`font-medium`}),1:(0,$.jsx)(`code`,{})},t[17]=n):n=t[17];let i;return t[18]===e?i=t[19]:(i=(0,$.jsx)(sx,{tone:`error`,children:(0,$.jsx)(a,{id:`SWTmnY`,values:e,components:n})}),t[18]=e,t[19]=i),i}if(s.kind===`name-not-found`){let e=`<MirrorSource name="${o}">`,n;t[20]!==e||t[21]!==r?(n={mirrorSourceTag:e,src:r},t[20]=e,t[21]=r,t[22]=n):n=t[22];let i;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(i={0:(0,$.jsx)(`span`,{className:`font-medium`}),1:(0,$.jsx)(`code`,{}),2:(0,$.jsx)(`code`,{})},t[23]=i):i=t[23];let s;return t[24]===n?s=t[25]:(s=(0,$.jsx)(sx,{tone:`error`,children:(0,$.jsx)(a,{id:`Ysv4pO`,values:n,components:i})}),t[24]=n,t[25]=s),s}let c;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Ft,{className:`size-3`,"aria-hidden":`true`}),t[26]=c):c=t[26];let l;t[27]===r?l=t[28]:(l={src:r},t[27]=r,t[28]=l);let u;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(u={0:(0,$.jsx)(`code`,{className:`font-mono`})},t[29]=u):u=t[29];let d;t[30]===l?d=t[31]:(d=(0,$.jsxs)(`div`,{className:`ok-mirror-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,"aria-hidden":`true`,children:[c,(0,$.jsx)(`span`,{children:(0,$.jsx)(a,{id:`wQp1V3`,values:l,components:u})})]}),t[30]=l,t[31]=d);let f;t[32]===s.html?f=t[33]:(f=(0,$.jsx)(`div`,{dangerouslySetInnerHTML:{__html:s.html}}),t[32]=s.html,t[33]=f);let p;return t[34]!==o||t[35]!==r||t[36]!==d||t[37]!==f?(p=(0,$.jsxs)(`div`,{className:`ok-mirror-resolved relative -mx-3 prose-no-margin rounded-md border border-dashed border-transparent px-3 py-2 transition-colors [.jsx-component-wrapper:hover_&]:border-border/40 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/40`,"data-mirror-src":r,"data-mirror-name":o,children:[d,f]}),t[34]=o,t[35]=r,t[36]=d,t[37]=f,t[38]=p):p=t[38],p}function lx(e){let t=(0,Q.c)(17),{_:n}=o(),r;t[0]===e.name?r=t[1]:(r=xb(e.name),t[0]=e.name,t[1]=r);let i=r,s;t[2]!==n||t[3]!==i?(s=i||n({id:`DWZYxR`}),t[2]=n,t[3]=i,t[4]=s):s=t[4];let c=s,l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(ql,{className:`size-3`,"aria-hidden":`true`}),t[5]=l):l=t[5];let u;t[6]===c?u=t[7]:(u={label:c},t[6]=c,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d={0:(0,$.jsx)(`code`,{className:`font-mono`})},t[8]=d):d=t[8];let f;t[9]===u?f=t[10]:(f=(0,$.jsxs)(`div`,{className:`ok-mirror-source-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,children:[l,(0,$.jsx)(`span`,{children:(0,$.jsx)(a,{id:`Zon_qG`,values:u,components:d})})]}),t[9]=u,t[10]=f);let p;t[11]===e.children?p=t[12]:(p=(0,$.jsx)(`div`,{children:e.children}),t[11]=e.children,t[12]=p);let m;return t[13]!==i||t[14]!==f||t[15]!==p?(m=(0,$.jsxs)(`div`,{className:`ok-mirror-source relative -mx-3 rounded-md border border-dashed border-transparent px-3 py-1 transition-colors [.jsx-component-wrapper:hover_&]:border-border/50 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/50`,"data-mirror-source-name":i,children:[f,p]}),t[13]=i,t[14]=f,t[15]=p,t[16]=m):m=t[16],m}function ux(e){if(!e)return{height:null,viewerFragment:``};let t=e.split(`&`).filter(e=>e.length>0),n=null,r=[];for(let e of t){let t=e.indexOf(`=`);if(t===-1){r.push(e);continue}let i=e.slice(0,t),a=e.slice(t+1);if(i===`height`){let e=Number.parseInt(a,10);!Number.isNaN(e)&&e>0&&(n=e);continue}r.push(e)}return{height:n,viewerFragment:r.join(`&`)}}var dx=24,fx=24,px=12,mx=.1;function hx(e,t,n,r){if(n<=0&&(e===`fit-width`||e===`two-odd`||e===`two-even`)||r<=0&&e===`fit-height`)return 1;switch(e){case`fit-width`:return Math.max(mx,(n-dx)/t.naturalWidth);case`fit-height`:return Math.max(mx,(r-fx)/t.naturalHeight);case`single`:return 1;case`two-odd`:case`two-even`:return Math.max(mx,((n-dx)/2-px)/t.naturalWidth)}}var gx=600,_x=.5,vx=3,yx=.25,bx=null;function xx(){return bx||(bx=(async()=>{let e=await n(()=>import(`./pdf-DO7qqKZs.js`),__vite__mapDeps([48,2]),import.meta.url);if(!e.GlobalWorkerOptions.workerSrc){let t=(await n(async()=>{let{default:e}=await import(`./pdf.worker-DG3RIHYj.js`);return{default:e}},[],import.meta.url)).default;e.GlobalWorkerOptions.workerSrc=t}return e})(),bx.catch(()=>{bx=null})),bx}function Sx(e){return e instanceof Error&&e.name===`RenderingCancelledException`}function Cx(e){let t=(0,Q.c)(96),n,r;if(t[0]!==e.anchor||t[1]!==e.fillContainer){let{height:i,viewerFragment:a}=ux(e.anchor);n=i===null?e.fillContainer?`100%`:`${gx}px`:`${i}px`,r=Ax(a),t[0]=e.anchor,t[1]=e.fillContainer,t[2]=n,t[3]=r}else n=t[2],r=t[3];let i=r,s=(0,Z.useRef)(null),c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[4]=c):c=t[4];let l=(0,Z.useRef)(c),u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[5]=u):u=t[5];let d=(0,Z.useRef)(u),f=(0,Z.useRef)(null),p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[6]=p):p=t[6];let[m,h]=(0,Z.useState)(p),[g,_]=(0,Z.useState)(!0),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(i??1),[S,C]=(0,Z.useState)(String(i??1)),[w,T]=(0,Z.useState)(1),[E,D]=(0,Z.useState)(`fit-width`),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(0),[P,F]=(0,Z.useState)(0),{_:I}=o(),L=m.length,ee,R;t[7]!==I||t[8]!==e.src?(ee=()=>{if(!e.src){_(!1);return}let t=Lo(e.src),n=!1,r=null;return _(!0),y(null),(async()=>{try{let e=(await xx()).getDocument({url:t});r=e;let i=await e.promise;if(n){await e.destroy();return}f.current=i;let a=[];for(let e=1;e<=i.numPages;e++){if(n)return;let t=(await i.getPage(e)).getViewport({scale:1});a.push({pageNumber:e,naturalWidth:t.width,naturalHeight:t.height})}if(n)return;h(a)}catch(e){let t=e;if(n)return;y(t instanceof Error?t.message:I({id:`jRHdCz`})),_(!1)}})(),()=>{n=!0,r?.destroy().catch(Ox),r=null,f.current=null}},R=[e.src,I],t[7]=I,t[8]=e.src,t[9]=ee,t[10]=R):(ee=t[9],R=t[10]),(0,Z.useEffect)(ee,R);let te,ne;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>{let e=s.current;if(!e)return;let t=()=>{N(e.clientWidth),F(e.clientHeight)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},ne=[],t[11]=te,t[12]=ne):(te=t[11],ne=t[12]),(0,Z.useEffect)(te,ne);let re,ie;t[13]!==I||t[14]!==P||t[15]!==M||t[16]!==E||t[17]!==m||t[18]!==w?(re=()=>{let e=f.current;if(!e||m.length===0||M===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of m){if(t)return;let a=l.current[i.pageNumber-1];if(!a)continue;let o=hx(E,i,M,P)*w,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let u=a.getContext(`2d`);u&&(u.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:u,viewport:c}),await n.promise,n=null)}t||_(!1)}catch(e){let n=e;if(t||Sx(n))return;console.warn(`[Pdf] page render failed:`,n),y(n instanceof Error?n.message:I({id:`_TF8ep`})),_(!1)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},ie=[m,E,w,M,P,I],t[13]=I,t[14]=P,t[15]=M,t[16]=E,t[17]=m,t[18]=w,t[19]=re,t[20]=ie):(re=t[19],ie=t[20]),(0,Z.useEffect)(re,ie);let ae,oe;t[21]!==m||t[22]!==O?(ae=()=>{if(!O)return;let e=f.current;if(!e||m.length===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of m){if(t)return;let a=d.current[i.pageNumber-1];if(!a)continue;let o=120/i.naturalWidth,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let l=a.getContext(`2d`);l&&(l.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:l,viewport:c}),await n.promise,n=null)}}catch(e){let t=e;Sx(t)||console.warn(`[Pdf] thumbnail render failed:`,t)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},oe=[O,m],t[21]=m,t[22]=O,t[23]=ae,t[24]=oe):(ae=t[23],oe=t[24]),(0,Z.useEffect)(ae,oe);let se,z;t[25]!==g||t[26]!==i?(se=()=>{if(g||!i)return;let e=s.current,t=l.current[i-1];e&&t&&(e.scrollTop=t.offsetTop-e.offsetTop)},z=[g,i],t[25]=g,t[26]=i,t[27]=se,t[28]=z):(se=t[27],z=t[28]),(0,Z.useEffect)(se,z);let B,ce;t[29]===m?(B=t[30],ce=t[31]):(B=()=>{let e=s.current;if(!e||m.length===0)return;let t=!1,n=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let n=e.scrollTop,r=1;for(let t of m){let i=l.current[t.pageNumber-1];i&&i.offsetTop-e.offsetTop<=n+40&&(r=t.pageNumber)}x(r),C(String(r))}))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},ce=[m],t[29]=m,t[30]=B,t[31]=ce),(0,Z.useEffect)(B,ce);let V,H;t[32]===A?(V=t[33],H=t[34]):(V=()=>{if(!A)return;let e=e=>{let t=e.target,n=s.current?.closest(`.ok-pdf`);if(!n||!t||!n.contains(t)){j(!1);return}let r=n.querySelector(`.ok-pdf-layout-menu`);r&&!r.contains(t)&&j(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},H=[A],t[32]=A,t[33]=V,t[34]=H),(0,Z.useEffect)(V,H);let U;t[35]===L?U=t[36]:(U=e=>{let t=Math.max(1,Math.min(L||1,e));x(t),C(String(t));let n=s.current,r=l.current[t-1];n&&r&&n.scrollTo({top:r.offsetTop-n.offsetTop,behavior:`smooth`})},t[35]=L,t[36]=U);let W=U,le;t[37]!==b||t[38]!==W||t[39]!==S?(le=()=>{let e=Number.parseInt(S,10);if(Number.isNaN(e)){C(String(b));return}W(e)},t[37]=b,t[38]=W,t[39]=S,t[40]=le):le=t[40];let G=le,ue;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>T(Dx),t[41]=ue):ue=t[41];let K=ue,de;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>T(Ex),t[42]=de):de=t[42];let fe=de,pe;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(pe=e=>{D(e),j(!1),T(1)},t[43]=pe):pe=t[43];let q=pe,me;t[44]===n?me=t[45]:(me={height:n},t[44]=n,t[45]=me);let J;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(J=()=>k(Tx),t[46]=J):J=t[46];let he;t[47]!==I||t[48]!==O?(he=I(O?{id:`JK-Ave`}:{id:`iEYxO4`}),t[47]=I,t[48]=O,t[49]=he):he=t[49];let ge;t[50]===I?ge=t[51]:(ge=I({id:`zo3Dl7`}),t[50]=I,t[51]=ge);let _e;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,$.jsx)(ut,{size:14,"aria-hidden":`true`}),t[52]=_e):_e=t[52];let ve;t[53]!==O||t[54]!==he||t[55]!==ge?(ve=(0,$.jsx)(`button`,{type:`button`,onClick:J,"aria-label":he,"aria-pressed":O,className:`ok-pdf-btn`,title:ge,children:_e}),t[53]=O,t[54]=he,t[55]=ge,t[56]=ve):ve=t[56];let ye=e.title??`PDF`,be;t[57]===ye?be=t[58]:(be=(0,$.jsx)(`span`,{className:`ok-pdf-title`,children:ye}),t[57]=ye,t[58]=be);let xe;t[59]!==I||t[60]!==A||t[61]!==E||t[62]!==S||t[63]!==G||t[64]!==L||t[65]!==w?(xe=L>0&&(0,$.jsxs)(`div`,{className:`ok-pdf-controls`,children:[(0,$.jsx)(`form`,{className:`ok-pdf-page-form`,onSubmit:e=>{e.preventDefault(),G()},children:(0,$.jsx)(`input`,{type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,className:`ok-pdf-page-input`,value:S,onChange:e=>C(e.target.value.replace(/[^0-9]/g,``)),onBlur:G,"aria-label":I({id:`xsZhu-`})})}),(0,$.jsx)(`span`,{className:`ok-pdf-page-of`,children:(0,$.jsx)(a,{id:`1GhYxC`,values:{totalPages:L}})}),(0,$.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,$.jsx)(`button`,{type:`button`,onClick:fe,disabled:w<=_x,"aria-label":I({id:`FjkaiT`}),className:`ok-pdf-btn`,title:I({id:`FjkaiT`}),children:(0,$.jsx)(kt,{size:14,"aria-hidden":`true`})}),(0,$.jsxs)(`span`,{className:`ok-pdf-zoom-display`,"aria-live":`polite`,children:[Math.round(w*100),`%`]}),(0,$.jsx)(`button`,{type:`button`,onClick:K,disabled:w>=vx,"aria-label":I({id:`AWOSPo`}),className:`ok-pdf-btn`,title:I({id:`AWOSPo`}),children:(0,$.jsx)(St,{size:14,"aria-hidden":`true`})}),(0,$.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,$.jsxs)(`div`,{className:`ok-pdf-layout-menu`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>j(wx),"aria-label":I({id:`GQDSBN`}),"aria-haspopup":`menu`,"aria-expanded":A,className:`ok-pdf-btn`,title:I({id:`rdU729`}),children:(0,$.jsx)(jt,{size:14,"aria-hidden":`true`})}),A&&(0,$.jsxs)(`div`,{role:`menu`,className:`ok-pdf-menu`,children:[(0,$.jsx)(kx,{label:I({id:`vIxrEk`}),active:E===`fit-width`,onSelect:()=>q(`fit-width`)}),(0,$.jsx)(kx,{label:I({id:`YlDuro`}),active:E===`fit-height`,onSelect:()=>q(`fit-height`)}),(0,$.jsx)(`hr`,{className:`ok-pdf-menu-divider`}),(0,$.jsx)(kx,{label:I({id:`BGHHtQ`}),active:E===`single`,onSelect:()=>q(`single`)}),(0,$.jsx)(kx,{label:I({id:`xK291b`}),active:E===`two-odd`,onSelect:()=>q(`two-odd`)}),(0,$.jsx)(kx,{label:I({id:`NSnIUP`}),active:E===`two-even`,onSelect:()=>q(`two-even`)})]})]})]}),t[59]=I,t[60]=A,t[61]=E,t[62]=S,t[63]=G,t[64]=L,t[65]=w,t[66]=xe):xe=t[66];let Se;t[67]!==ve||t[68]!==be||t[69]!==xe?(Se=(0,$.jsxs)(`div`,{className:`ok-pdf-toolbar`,contentEditable:!1,children:[ve,be,xe]}),t[67]=ve,t[68]=be,t[69]=xe,t[70]=Se):Se=t[70];let Ce;t[71]!==I||t[72]!==b||t[73]!==W||t[74]!==m||t[75]!==O?(Ce=O&&(0,$.jsx)(`aside`,{className:`ok-pdf-sidebar`,"aria-label":I({id:`nzaV6Q`}),children:m.map((e,t)=>{let{pageNumber:n}=e;return(0,$.jsxs)(`button`,{type:`button`,className:`ok-pdf-thumb`,"data-active":b===n||void 0,onClick:()=>W(n),"aria-label":I({id:`qioCwA`,values:{pageNumber:n}}),children:[(0,$.jsx)(`canvas`,{ref:e=>{d.current[t]=e},className:`ok-pdf-thumb-canvas`}),(0,$.jsx)(`span`,{className:`ok-pdf-thumb-num`,children:n})]},n)})}),t[71]=I,t[72]=b,t[73]=W,t[74]=m,t[75]=O,t[76]=Ce):Ce=t[76];let we;t[77]===g?we=t[78]:(we=g&&(0,$.jsx)(`div`,{className:`ok-pdf-loading`,children:(0,$.jsx)(a,{id:`T-654M`})}),t[77]=g,t[78]=we);let Te;t[79]===v?Te=t[80]:(Te=v&&(0,$.jsx)(`div`,{className:`ok-pdf-error`,children:(0,$.jsx)(a,{id:`WamGNs`,values:{error:v}})}),t[79]=v,t[80]=Te);let Ee;t[81]!==I||t[82]!==L?(Ee=Array.from({length:L},(e,t)=>{let n=t+1;return(0,$.jsx)(`canvas`,{ref:e=>{l.current[t]=e},className:`ok-pdf-page`,"aria-label":I({id:`XtRoxT`,values:{pageNumber:n}})},n)}),t[81]=I,t[82]=L,t[83]=Ee):Ee=t[83];let De;t[84]!==E||t[85]!==we||t[86]!==Te||t[87]!==Ee?(De=(0,$.jsxs)(`div`,{className:`ok-pdf-pages`,ref:s,"data-layout":E,children:[we,Te,Ee]}),t[84]=E,t[85]=we,t[86]=Te,t[87]=Ee,t[88]=De):De=t[88];let Oe;t[89]!==Ce||t[90]!==De?(Oe=(0,$.jsxs)(`div`,{className:`ok-pdf-body`,children:[Ce,De]}),t[89]=Ce,t[90]=De,t[91]=Oe):Oe=t[91];let ke;return t[92]!==me||t[93]!==Se||t[94]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`ok-pdf`,style:me,children:[Se,Oe]}),t[92]=me,t[93]=Se,t[94]=Oe,t[95]=ke):ke=t[95],ke}function wx(e){return!e}function Tx(e){return!e}function Ex(e){return Math.max(_x,+(e-yx).toFixed(2))}function Dx(e){return Math.min(vx,+(e+yx).toFixed(2))}function Ox(){}function kx(e){let t=(0,Q.c)(10),n=e.active||void 0,r;t[0]===e.active?r=t[1]:(r=e.active&&(0,$.jsx)(At,{size:14}),t[0]=e.active,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,$.jsx)(`span`,{className:`ok-pdf-menu-check`,"aria-hidden":`true`,children:r}),t[2]=r,t[3]=i);let a;return t[4]!==e.active||t[5]!==e.label||t[6]!==e.onSelect||t[7]!==n||t[8]!==i?(a=(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e.active,className:`ok-pdf-menu-item`,"data-active":n,onClick:e.onSelect,children:[i,e.label]}),t[4]=e.active,t[5]=e.label,t[6]=e.onSelect,t[7]=n,t[8]=i,t[9]=a):a=t[9],a}function Ax(e){if(!e)return null;for(let t of e.split(`&`)){let e=t.indexOf(`=`);if(!(e<0)&&t.slice(0,e)===`page`){let n=Number.parseInt(t.slice(e+1),10);if(!Number.isNaN(n)&&n>=1)return n}}return null}function jx(e){let t=(0,Q.c)(10),{label:n,id:r,children:i}=e,a=(0,Z.useId)(),o;t[0]!==r||t[1]!==a?(o=r||`tab-panel-${a.replace(/:/g,``)}`,t[0]=r,t[1]=a,t[2]=o):o=t[2];let s=o,c=`${s}-tab`,l;t[3]===n?l=t[4]:(l=n?.trim()||`Tab`,t[3]=n,t[4]=l);let u=l,d;return t[5]!==i||t[6]!==s||t[7]!==u||t[8]!==c?(d=(0,$.jsx)(`section`,{className:`tab-panel`,id:s,role:`tabpanel`,"aria-labelledby":c,"data-tab-label":u,"data-tab-id":s,children:i}),t[5]=i,t[6]=s,t[7]=u,t[8]=c,t[9]=d):d=t[9],d}var Mx=`:scope > .component-children > [data-node-view-content-react] > .react-renderer`;function Nx(e){return Array.from(e.querySelectorAll(Mx)).map((e,t)=>{let n=e.querySelector(`[data-tab-label]`);return{index:t,label:(n?.getAttribute(`data-tab-label`))?.trim()||`Tab ${t+1}`,panelId:n?.getAttribute(`data-tab-id`)??null}})}function Px(e,t){let n=Array.from(e.querySelectorAll(Mx))[t];return n?n.querySelector(`[data-jsx-gear]`):null}function Fx(e){let t=(0,Q.c)(31),{id:n,children:r}=e,[i,a]=(0,Z.useState)(0),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Z.useState)(s),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),f=(0,Z.useRef)(0),p=wt(),m=p?.addChild!=null,{_:h}=o(),g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=u.current;if(!e)return;let t=Nx(e);l(e=>{if(e.length!==t.length)return t;for(let n=0;n<e.length;n++)if(e[n].label!==t[n].label||e[n].panelId!==t[n].panelId)return t;return e})},t[1]=g):g=t[1],(0,Z.useLayoutEffect)(g);let _,v;t[2]===c.length?(_=t[3],v=t[4]):(_=()=>{c.length>f.current&&c.length>0&&a(c.length-1),f.current=c.length},v=[c.length],t[2]=c.length,t[3]=_,t[4]=v),(0,Z.useLayoutEffect)(_,v);let y;t[5]===n?y=t[6]:(y=()=>{let e=()=>{let e=window.location.hash.slice(1);if(!e)return;if(n&&e===n){a(0);return}let t=u.current;if(!t)return;let r=Nx(t).findIndex(t=>t.panelId===e);r<0||(a(r),queueMicrotask(()=>{t.ownerDocument.getElementById(e)?.scrollIntoView({block:`start`,behavior:`auto`})}))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},t[5]=n,t[6]=y),(0,Z.useLayoutEffect)(y);let b=c.length===0?0:Math.min(Math.max(i,0),c.length-1),x;t[7]!==c.length||t[8]!==b?(x=e=>{if(c.length===0)return;let t=null;e.key===`ArrowRight`?t=(b+1)%c.length:e.key===`ArrowLeft`?t=(b-1+c.length)%c.length:e.key===`Home`?t=0:e.key===`End`&&(t=c.length-1),t!==null&&(e.preventDefault(),a(t),(d.current?.querySelectorAll(`[role="tab"]`))?.[t]?.focus())},t[7]=c.length,t[8]=b,t[9]=x):x=t[9];let S=x,C=n?`Tabs: ${n}`:`Tabs`,w;t[10]!==c||t[11]!==b?(w=c.map(e=>(0,$.jsx)(`button`,{id:e.panelId?`${e.panelId}-tab`:void 0,type:`button`,role:`tab`,className:`tabs-strip-pill`,"data-active":e.index===b,"aria-selected":e.index===b,"aria-controls":e.panelId??void 0,tabIndex:e.index===b?0:-1,onMouseDown:Lx,onClick:()=>{if(e.index!==b){a(e.index);return}let t=u.current;t&&Px(t,e.index)?.click()},children:e.label},e.index)),t[10]=c,t[11]=b,t[12]=w):w=t[12];let T;t[13]!==S||t[14]!==C||t[15]!==w?(T=(0,$.jsx)(`div`,{ref:d,role:`tablist`,"aria-label":C,className:`tabs-tablist`,onKeyDown:S,children:w}),t[13]=S,t[14]=C,t[15]=w,t[16]=T):T=t[16];let E;t[17]!==h||t[18]!==m||t[19]!==p?(E=m&&(0,$.jsx)(`button`,{type:`button`,className:`tabs-strip-add`,"aria-label":h({id:`hjO0Mq`}),title:h({id:`hjO0Mq`}),onMouseDown:Ix,onClick:()=>p?.addChild?.(),"data-tabs-strip-add":``,children:`+`}),t[17]=h,t[18]=m,t[19]=p,t[20]=E):E=t[20];let D;t[21]!==E||t[22]!==T?(D=(0,$.jsxs)(`div`,{className:`tabs-strip`,contentEditable:!1,children:[T,E]}),t[21]=E,t[22]=T,t[23]=D):D=t[23];let O;t[24]!==r||t[25]!==b?(O=(0,$.jsx)(`div`,{ref:u,className:`tabs-content`,"data-active-index":b,children:r}),t[24]=r,t[25]=b,t[26]=O):O=t[26];let k;return t[27]!==n||t[28]!==D||t[29]!==O?(k=(0,$.jsxs)(`div`,{className:`tabs`,id:n,children:[D,O]}),t[27]=n,t[28]=D,t[29]=O,t[30]=k):k=t[30],k}function Ix(e){return e.preventDefault()}function Lx(e){return e.preventDefault()}var Rx=typeof global<`u`&&{}.toString.call(global)===`[object global]`,zx=typeof Bun<`u`,Bx=typeof Deno<`u`,Vx=typeof WebSocketPair==`function`&&caches?.default!==void 0,Hx=Rx||zx||Bx||Vx;function Ux(e,t){return e.indexOf(t.toLowerCase())===0?e:`${t.toLowerCase()}${e.substr(0,1).toUpperCase()}${e.substr(1)}`}function Wx(e){return!!(e&&e.nodeType===1&&`nodeName`in e&&e.ownerDocument&&e.ownerDocument.defaultView)}function Gx(e){return!isNaN(parseFloat(e))&&isFinite(e)&&Math.floor(e)==e}function Kx(e){return/^(https?:)?\/\/((((player|www)\.)?vimeo\.com)|((player\.)?[a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))(?=$|\/)/.test(e)}function qx(e){return/^https:\/\/player\.((vimeo\.com)|([a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))\/video\/\d+/.test(e)}function Jx(e){let t=(e||``).match(/^(?:https?:)?(?:\/\/)?([^/?]+)/),n=(t&&t[1]||``).replace(`player.`,``);for(let e of[`.videoji.hk`,`.vimeo.work`,`.videoji.cn`])if(n.endsWith(e))return n;return`vimeo.com`}function Yx(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.id,n=e.url,r=t||n;if(!r)throw Error(`An id or url must be passed, either in an options object or as a data-vimeo-id or data-vimeo-url attribute.`);if(Gx(r))return`https://vimeo.com/${r}`;if(Kx(r))return r.replace(`http:`,`https:`);throw TypeError(t?`“${t}” is not a valid video id.`:`“${r}” is not a vimeo.com url.`)}var Xx=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`addEventListener`,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:`removeEventListener`,a=typeof t==`string`?[t]:t;return a.forEach(t=>{e[r](t,n)}),{cancel:()=>a.forEach(t=>e[i](t,n))}};function Zx(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:document;if(!e||!t||typeof t.querySelectorAll!=`function`)return null;let n=t.querySelectorAll(`iframe`);for(let t=0;t<n.length;t++)if(n[t]&&n[t].contentWindow===e)return n[t];return null}var Qx=Array.prototype.indexOf!==void 0,$x=typeof window<`u`&&window.postMessage!==void 0;if(!Hx&&(!Qx||!$x))throw Error(`Sorry, the Vimeo Player API is not available in this browser.`);var eS=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function tS(e,t){return t={exports:{}},e(t,t.exports),t.exports}(function(e){if(e.WeakMap)return;var t=Object.prototype.hasOwnProperty,n=Object.defineProperty&&function(){try{return Object.defineProperty({},`x`,{value:1}).x===1}catch{}}(),r=function(e,t,r){n?Object.defineProperty(e,t,{configurable:!0,writable:!0,value:r}):e[t]=r};e.WeakMap=function(){function e(){if(this===void 0)throw TypeError(`Constructor WeakMap requires 'new'`);if(r(this,`_id`,a(`_WeakMap`)),arguments.length>0)throw TypeError(`WeakMap iterable is not supported`)}r(e.prototype,`delete`,function(e){if(n(this,`delete`),!i(e))return!1;var t=e[this._id];return t&&t[0]===e?(delete e[this._id],!0):!1}),r(e.prototype,`get`,function(e){if(n(this,`get`),i(e)){var t=e[this._id];if(t&&t[0]===e)return t[1]}}),r(e.prototype,`has`,function(e){if(n(this,`has`),!i(e))return!1;var t=e[this._id];return!!(t&&t[0]===e)}),r(e.prototype,`set`,function(e,t){if(n(this,`set`),!i(e))throw TypeError(`Invalid value used as weak map key`);var a=e[this._id];return a&&a[0]===e?(a[1]=t,this):(r(e,this._id,[e,t]),this)});function n(e,n){if(!i(e)||!t.call(e,`_id`))throw TypeError(n+` method called on incompatible receiver `+typeof e)}function a(e){return e+`_`+o()+`.`+o()}function o(){return Math.random().toString().substring(2)}return r(e,`_polyfill`,!0),e}();function i(e){return Object(e)===e}})(typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:eS);var nS=tS(function(e){(function(t,n,r){n[t]=n[t]||r(),e.exports&&=n[t]})(`Promise`,eS,function(){var e,t,n,r=Object.prototype.toString,i=typeof setImmediate<`u`?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},`x`,{}),e=function(e,t,n,r){return Object.defineProperty(e,t,{value:n,writable:!0,configurable:r!==!1})}}catch{e=function(e,t,n){return e[t]=n,e}}n=function(){var e,n,r;function i(e,t){this.fn=e,this.self=t,this.next=void 0}return{add:function(t,a){r=new i(t,a),n?n.next=r:e=r,n=r,r=void 0},drain:function(){var r=e;for(e=n=t=void 0;r;)r.fn.call(r.self),r=r.next}}}();function a(e,r){n.add(e,r),t||=i(n.drain)}function o(e){var t,n=typeof e;return e!=null&&(n==`object`||n==`function`)&&(t=e.then),typeof t==`function`?t:!1}function s(){for(var e=0;e<this.chain.length;e++)c(this,this.state===1?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function c(e,t,n){var r,i;try{t===!1?n.reject(e.msg):(r=t===!0?e.msg:t.call(void 0,e.msg),r===n.promise?n.reject(TypeError(`Promise-chain cycle`)):(i=o(r))?i.call(r,n.resolve,n.reject):n.resolve(r))}catch(e){n.reject(e)}}function l(e){var t,n=this;if(!n.triggered){n.triggered=!0,n.def&&(n=n.def);try{(t=o(e))?a(function(){var r=new f(n);try{t.call(e,function(){l.apply(r,arguments)},function(){u.apply(r,arguments)})}catch(e){u.call(r,e)}}):(n.msg=e,n.state=1,n.chain.length>0&&a(s,n))}catch(e){u.call(new f(n),e)}}}function u(e){var t=this;t.triggered||(t.triggered=!0,t.def&&(t=t.def),t.msg=e,t.state=2,t.chain.length>0&&a(s,t))}function d(e,t,n,r){for(var i=0;i<t.length;i++)(function(i){e.resolve(t[i]).then(function(e){n(i,e)},r)})(i)}function f(e){this.def=e,this.triggered=!1}function p(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function m(e){if(typeof e!=`function`)throw TypeError(`Not a function`);if(this.__NPO__!==0)throw TypeError(`Not a promise`);this.__NPO__=1;var t=new p(this);this.then=function(e,n){var r={success:typeof e==`function`?e:!0,failure:typeof n==`function`?n:!1};return r.promise=new this.constructor(function(e,t){if(typeof e!=`function`||typeof t!=`function`)throw TypeError(`Not a function`);r.resolve=e,r.reject=t}),t.chain.push(r),t.state!==0&&a(s,t),r.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,function(e){l.call(t,e)},function(e){u.call(t,e)})}catch(e){u.call(t,e)}}var h=e({},`constructor`,m,!1);return m.prototype=h,e(h,`__NPO__`,0,!1),e(m,`resolve`,function(e){var t=this;return e&&typeof e==`object`&&e.__NPO__===1?e:new t(function(t,n){if(typeof t!=`function`||typeof n!=`function`)throw TypeError(`Not a function`);t(e)})}),e(m,`reject`,function(e){return new this(function(t,n){if(typeof t!=`function`||typeof n!=`function`)throw TypeError(`Not a function`);n(e)})}),e(m,`all`,function(e){var t=this;return r.call(e)==`[object Array]`?e.length===0?t.resolve([]):new t(function(n,r){if(typeof n!=`function`||typeof r!=`function`)throw TypeError(`Not a function`);var i=e.length,a=Array(i),o=0;d(t,e,function(e,t){a[e]=t,++o===i&&n(a)},r)}):t.reject(TypeError(`Not an array`))}),e(m,`race`,function(e){var t=this;return r.call(e)==`[object Array]`?new t(function(n,r){if(typeof n!=`function`||typeof r!=`function`)throw TypeError(`Not a function`);d(t,e,function(e,t){n(t)},r)}):t.reject(TypeError(`Not an array`))}),m})}),rS=new WeakMap;function iS(e,t,n){let r=rS.get(e.element)||{};t in r||(r[t]=[]),r[t].push(n),rS.set(e.element,r)}function aS(e,t){return(rS.get(e.element)||{})[t]||[]}function oS(e,t,n){let r=rS.get(e.element)||{};if(!r[t])return!0;if(!n)return r[t]=[],rS.set(e.element,r),!0;let i=r[t].indexOf(n);return i!==-1&&r[t].splice(i,1),rS.set(e.element,r),r[t]&&r[t].length===0}function sS(e,t){let n=aS(e,t);if(n.length<1)return!1;let r=n.shift();return oS(e,t,r),r}function cS(e,t){let n=rS.get(e);rS.set(t,n),rS.delete(e)}function lS(e){if(typeof e==`string`)try{e=JSON.parse(e)}catch(e){return console.warn(e),{}}return e}function uS(e,t,n){if(!e.element.contentWindow||!e.element.contentWindow.postMessage)return;let r={method:t};n!==void 0&&(r.value=n);let i=parseFloat(navigator.userAgent.toLowerCase().replace(/^.*msie (\d+).*$/,`$1`));i>=8&&i<10&&(r=JSON.stringify(r)),e.element.contentWindow.postMessage(r,e.origin)}function dS(e,t){t=lS(t);let n=[],r;if(t.event)t.event===`error`&&aS(e,t.data.method).forEach(n=>{let r=Error(t.data.message);r.name=t.data.name,n.reject(r),oS(e,t.data.method,n)}),n=aS(e,`event:${t.event}`),r=t.data;else if(t.method){let i=sS(e,t.method);i&&(n.push(i),r=t.value)}n.forEach(t=>{try{if(typeof t==`function`){t.call(e,r);return}t.resolve(r)}catch{}})}var fS=`airplay.audio_tracks.audiotrack.autopause.autoplay.background.byline.cc.chapter_id.chapters.chromecast.color.colors.controls.disable_context_menu.dnt.end_time.fullscreen.height.id.initial_quality.interactive_params.keyboard.loop.maxheight.max_quality.maxwidth.min_quality.muted.play_button_position.playsinline.portrait.preload.progress_bar.quality.quality_selector.responsive.skipping_forward.speed.start_time.texttrack.thumbnail_id.title.transcript.transparent.unmute_button.url.vimeo_logo.volume.watch_full_video.width`.split(`.`);function pS(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return fS.reduce((t,n)=>{let r=e.getAttribute(`data-vimeo-${n}`);return(r||r===``)&&(t[n]=r===``?1:r),t},t)}function mS(e,t){let{html:n}=e;if(!t)throw TypeError(`An element must be provided`);if(t.getAttribute(`data-vimeo-initialized`)!==null)return t.querySelector(`iframe`);let r=document.createElement(`div`);return r.innerHTML=n,t.appendChild(r.firstChild),t.setAttribute(`data-vimeo-initialized`,`true`),t.querySelector(`iframe`)}function hS(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return new Promise((r,i)=>{if(!Kx(e))throw TypeError(`“${e}” is not a vimeo.com url.`);let a=`https://${Jx(e)}/api/oembed.json?url=${encodeURIComponent(e)}`;for(let e in t)t.hasOwnProperty(e)&&(a+=`&${e}=${encodeURIComponent(t[e])}`);let o=`XDomainRequest`in window?new XDomainRequest:new XMLHttpRequest;o.open(`GET`,a,!0),o.onload=function(){if(o.status===404){i(Error(`“${e}” was not found.`));return}if(o.status===403){i(Error(`“${e}” is not embeddable.`));return}try{let t=JSON.parse(o.responseText);if(t.domain_status_code===403){mS(t,n),i(Error(`“${e}” is not embeddable.`));return}r(t)}catch(e){i(e)}},o.onerror=function(){let e=o.status?` (${o.status})`:``;i(Error(`There was an error fetching the embed code from Vimeo${e}.`))},o.send()})}function gS(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document,t=[].slice.call(e.querySelectorAll(`[data-vimeo-id], [data-vimeo-url]`)),n=e=>{`console`in window&&console.error&&console.error(`There was an error creating an embed: ${e}`)};t.forEach(e=>{try{if(e.getAttribute(`data-vimeo-defer`)!==null)return;let t=pS(e);hS(Yx(t),t,e).then(t=>mS(t,e)).catch(n)}catch(e){n(e)}})}function _S(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoPlayerResizeEmbeds_||(window.VimeoPlayerResizeEmbeds_=!0,window.addEventListener(`message`,t=>{if(!Kx(t.origin)||!t.data||t.data.event!==`spacechange`)return;let n=t.source?Zx(t.source,e):null;if(n){let e=n.parentElement;e.style.paddingBottom=`${t.data.data[0].bottom}px`}}))}function vS(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoSeoMetadataAppended||(window.VimeoSeoMetadataAppended=!0,window.addEventListener(`message`,t=>{if(!Kx(t.origin))return;let n=lS(t.data);if(!n||n.event!==`ready`)return;let r=t.source?Zx(t.source,e):null;r&&qx(r.src)&&new DS(r).callMethod(`appendVideoMetadata`,window.location.href)}))}function yS(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;if(window.VimeoCheckedUrlTimeParam)return;window.VimeoCheckedUrlTimeParam=!0;let t=e=>{`console`in window&&console.error&&console.error(`There was an error getting video Id: ${e}`)};window.addEventListener(`message`,n=>{if(!Kx(n.origin))return;let r=lS(n.data);if(!r||r.event!==`ready`)return;let i=n.source?Zx(n.source,e):null;if(i&&qx(i.src)){let e=new DS(i);e.getVideoId().then(t=>{let n=RegExp(`[?&]vimeo_t_${t}=([^&#]*)`).exec(window.location.href);if(n&&n[1]){let t=decodeURI(n[1]);e.setCurrentTime(t)}}).catch(t)}})}function bS(){window.VimeoDRMEmbedsUpdated||(window.VimeoDRMEmbedsUpdated=!0,window.addEventListener(`message`,e=>{if(!Kx(e.origin))return;let t=lS(e.data);if(!t||t.event!==`drminitfailed`)return;let n=e.source?Zx(e.source):null;if(!n)return;let r=n.getAttribute(`allow`)||``;if(!r.includes(`encrypted-media`)){n.setAttribute(`allow`,`${r}; encrypted-media`);let e=new URL(n.getAttribute(`src`));e.searchParams.set(`forcereload`,`drm`),n.setAttribute(`src`,e.toString());return}}))}function xS(){let e=function(){let e,t=[[`requestFullscreen`,`exitFullscreen`,`fullscreenElement`,`fullscreenEnabled`,`fullscreenchange`,`fullscreenerror`],[`webkitRequestFullscreen`,`webkitExitFullscreen`,`webkitFullscreenElement`,`webkitFullscreenEnabled`,`webkitfullscreenchange`,`webkitfullscreenerror`],[`webkitRequestFullScreen`,`webkitCancelFullScreen`,`webkitCurrentFullScreenElement`,`webkitCancelFullScreen`,`webkitfullscreenchange`,`webkitfullscreenerror`],[`mozRequestFullScreen`,`mozCancelFullScreen`,`mozFullScreenElement`,`mozFullScreenEnabled`,`mozfullscreenchange`,`mozfullscreenerror`],[`msRequestFullscreen`,`msExitFullscreen`,`msFullscreenElement`,`msFullscreenEnabled`,`MSFullscreenChange`,`MSFullscreenError`]],n=0,r=t.length,i={};for(;n<r;n++)if(e=t[n],e&&e[1]in document){for(n=0;n<e.length;n++)i[t[0][n]]=e[n];return i}return!1}(),t={fullscreenchange:e.fullscreenchange,fullscreenerror:e.fullscreenerror},n={request(t){return new Promise((r,i)=>{let a=function(){n.off(`fullscreenchange`,a),r()};n.on(`fullscreenchange`,a),t||=document.documentElement;let o=t[e.requestFullscreen]();o instanceof Promise&&o.then(a).catch(i)})},exit(){return new Promise((t,r)=>{if(!n.isFullscreen){t();return}let i=function(){n.off(`fullscreenchange`,i),t()};n.on(`fullscreenchange`,i);let a=document[e.exitFullscreen]();a instanceof Promise&&a.then(i).catch(r)})},on(e,n){let r=t[e];r&&document.addEventListener(r,n)},off(e,n){let r=t[e];r&&document.removeEventListener(r,n)}};return Object.defineProperties(n,{isFullscreen:{get(){return!!document[e.fullscreenElement]}},element:{enumerable:!0,get(){return document[e.fullscreenElement]}},isEnabled:{enumerable:!0,get(){return!!document[e.fullscreenEnabled]}}}),n}var SS={role:`viewer`,autoPlayMuted:!0,allowedDrift:.3,maxAllowedDrift:1,minCheckInterval:.1,maxRateAdjustment:.2,maxTimeToCatchUp:1},CS=class extends EventTarget{logger;constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;super(),this.logger=r,this.init(t,e,{...SS,...n})}disconnect(){this.dispatchEvent(new Event(`disconnect`))}async init(e,t,n){if(await this.waitForTOReadyState(e,`open`),n.role===`viewer`){await this.updatePlayer(e,t,n);let r=Xx(e,`change`,()=>this.updatePlayer(e,t,n)),i=this.maintainPlaybackPosition(e,t,n);this.addEventListener(`disconnect`,()=>{i.cancel(),r.cancel()})}else{await this.updateTimingObject(e,t);let n=Xx(t,[`seeked`,`play`,`pause`,`ratechange`],()=>this.updateTimingObject(e,t),`on`,`off`);this.addEventListener(`disconnect`,()=>n.cancel())}}async updateTimingObject(e,t){let[n,r,i]=await Promise.all([t.getCurrentTime(),t.getPaused(),t.getPlaybackRate()]);e.update({position:n,velocity:r?0:i})}async updatePlayer(e,t,n){let{position:r,velocity:i}=e.query();typeof r==`number`&&t.setCurrentTime(r),typeof i==`number`&&(i===0?await t.getPaused()===!1&&t.pause():i>0&&(await t.getPaused()===!0&&(await t.play().catch(async e=>{e.name===`NotAllowedError`&&n.autoPlayMuted&&(await t.setMuted(!0),await t.play().catch(e=>console.error(`Couldn't play the video from TimingSrcConnector. Error:`,e)))}),this.updatePlayer(e,t,n)),await t.getPlaybackRate()!==i&&t.setPlaybackRate(i)))}maintainPlaybackPosition(e,t,n){let{allowedDrift:r,maxAllowedDrift:i,minCheckInterval:a,maxRateAdjustment:o,maxTimeToCatchUp:s}=n,c=Math.min(s,Math.max(a,i))*1e3,l=async()=>{if(e.query().velocity===0||await t.getPaused()===!0)return;let n=e.query().position-await t.getCurrentTime(),a=Math.abs(n);if(this.log(`Drift: ${n}`),a>i)await this.adjustSpeed(t,0),t.setCurrentTime(e.query().position),this.log(`Resync by currentTime`);else if(a>r){let e=a/s,r=o,i=e<r?(r-e)/2:r;await this.adjustSpeed(t,i*Math.sign(n)),this.log(`Resync by playbackRate`)}},u=setInterval(()=>l(),c);return{cancel:()=>clearInterval(u)}}log(e){this.logger?.(`TimingSrcConnector: ${e}`)}speedAdjustment=0;adjustSpeed=async(e,t)=>{if(this.speedAdjustment===t)return;let n=await e.getPlaybackRate()-this.speedAdjustment+t;this.log(`New playbackRate: ${n}`),await e.setPlaybackRate(n),this.speedAdjustment=t};waitForTOReadyState(e,t){return new Promise(n=>{let r=()=>{e.readyState===t?n():e.addEventListener(`readystatechange`,r,{once:!0})};r()})}},wS=new WeakMap,TS=new WeakMap,ES={},DS=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(window.jQuery&&e instanceof jQuery&&(e.length>1&&window.console&&console.warn&&console.warn(`A jQuery object with multiple elements was passed, using the first element.`),e=e[0]),typeof document<`u`&&typeof e==`string`&&(e=document.getElementById(e)),!Wx(e))throw TypeError(`You must pass either a valid element or a valid id.`);if(e.nodeName!==`IFRAME`){let t=e.querySelector(`iframe`);t&&(e=t)}if(e.nodeName===`IFRAME`&&!Kx(e.getAttribute(`src`)||``))throw Error(`The player element passed isn’t a Vimeo embed.`);if(wS.has(e))return wS.get(e);this._window=e.ownerDocument.defaultView,this.element=e,this.origin=`*`;let n=new nS((n,r)=>{if(this._onMessage=e=>{if(!Kx(e.origin)||this.element.contentWindow!==e.source)return;this.origin===`*`&&(this.origin=e.origin);let t=lS(e.data);if(t&&t.event===`error`&&t.data&&t.data.method===`ready`){let e=Error(t.data.message);e.name=t.data.name,r(e);return}let i=t&&t.event===`ready`,a=t&&t.method===`ping`;if(i||a){this.element.setAttribute(`data-ready`,`true`),n();return}dS(this,t)},this._window.addEventListener(`message`,this._onMessage),this.element.nodeName!==`IFRAME`){let n=pS(e,t);hS(Yx(n),n,e).then(t=>{let n=mS(t,e);return this.element=n,this._originalElement=e,cS(e,n),wS.set(this.element,this),t}).catch(r)}});if(TS.set(this,n),wS.set(this.element,this),this.element.nodeName===`IFRAME`&&uS(this,`ping`),ES.isEnabled){let e=()=>ES.exit();this.fullscreenchangeHandler=()=>{ES.isFullscreen?iS(this,`event:exitFullscreen`,e):oS(this,`event:exitFullscreen`,e),this.ready().then(()=>{uS(this,`fullscreenchange`,ES.isFullscreen)})},ES.on(`fullscreenchange`,this.fullscreenchangeHandler)}return this}static isVimeoUrl(e){return Kx(e)}callMethod(e){var t=[...arguments].slice(1);if(e==null)throw TypeError(`You must pass a method name.`);return new nS((n,r)=>this.ready().then(()=>{iS(this,e,{resolve:n,reject:r}),t.length===0?t={}:t.length===1&&(t=t[0]),uS(this,e,t)}).catch(r))}get(e){return new nS((t,n)=>(e=Ux(e,`get`),this.ready().then(()=>{iS(this,e,{resolve:t,reject:n}),uS(this,e)}).catch(n)))}set(e,t){return new nS((n,r)=>{if(e=Ux(e,`set`),t==null)throw TypeError(`There must be a value to set.`);return this.ready().then(()=>{iS(this,e,{resolve:n,reject:r}),uS(this,e,t)}).catch(r)})}on(e,t){if(!e)throw TypeError(`You must pass an event name.`);if(!t)throw TypeError(`You must pass a callback function.`);if(typeof t!=`function`)throw TypeError(`The callback must be a function.`);aS(this,`event:${e}`).length===0&&this.callMethod(`addEventListener`,e).catch(()=>{}),iS(this,`event:${e}`,t)}off(e,t){if(!e)throw TypeError(`You must pass an event name.`);if(t&&typeof t!=`function`)throw TypeError(`The callback must be a function.`);oS(this,`event:${e}`,t)&&this.callMethod(`removeEventListener`,e).catch(e=>{})}loadVideo(e){return this.callMethod(`loadVideo`,e)}ready(){let e=TS.get(this)||new nS((e,t)=>{t(Error(`Unknown player. Probably unloaded.`))});return nS.resolve(e)}addCuePoint(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.callMethod(`addCuePoint`,{time:e,data:t})}removeCuePoint(e){return this.callMethod(`removeCuePoint`,e)}enableTextTrack(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e)throw TypeError(`You must pass a language.`);return this.callMethod(`enableTextTrack`,{language:e,kind:t,showing:n})}disableTextTrack(){return this.callMethod(`disableTextTrack`)}selectAudioTrack(e,t){if(!e)throw TypeError(`You must pass a language.`);return this.callMethod(`selectAudioTrack`,{language:e,kind:t})}selectDefaultAudioTrack(){return this.callMethod(`selectDefaultAudioTrack`)}pause(){return this.callMethod(`pause`)}play(){return this.callMethod(`play`)}requestFullscreen(){return ES.isEnabled?ES.request(this.element):this.callMethod(`requestFullscreen`)}exitFullscreen(){return ES.isEnabled?ES.exit():this.callMethod(`exitFullscreen`)}getFullscreen(){return ES.isEnabled?nS.resolve(ES.isFullscreen):this.get(`fullscreen`)}requestPictureInPicture(){return this.callMethod(`requestPictureInPicture`)}exitPictureInPicture(){return this.callMethod(`exitPictureInPicture`)}getPictureInPicture(){return this.get(`pictureInPicture`)}remotePlaybackPrompt(){return this.callMethod(`remotePlaybackPrompt`)}unload(){return this.callMethod(`unload`)}destroy(){return new nS(e=>{if(TS.delete(this),wS.delete(this.element),this._originalElement&&(wS.delete(this._originalElement),this._originalElement.removeAttribute(`data-vimeo-initialized`)),this.element&&this.element.nodeName===`IFRAME`&&this.element.parentNode&&(this.element.parentNode.parentNode&&this._originalElement&&this._originalElement!==this.element.parentNode?this.element.parentNode.parentNode.removeChild(this.element.parentNode):this.element.parentNode.removeChild(this.element)),this.element&&this.element.nodeName===`DIV`&&this.element.parentNode){this.element.removeAttribute(`data-vimeo-initialized`);let e=this.element.querySelector(`iframe`);e&&e.parentNode&&(e.parentNode.parentNode&&this._originalElement&&this._originalElement!==e.parentNode?e.parentNode.parentNode.removeChild(e.parentNode):e.parentNode.removeChild(e))}this._window.removeEventListener(`message`,this._onMessage),ES.isEnabled&&ES.off(`fullscreenchange`,this.fullscreenchangeHandler),e()})}getAutopause(){return this.get(`autopause`)}setAutopause(e){return this.set(`autopause`,e)}getBuffered(){return this.get(`buffered`)}getCameraProps(){return this.get(`cameraProps`)}setCameraProps(e){return this.set(`cameraProps`,e)}getChapters(){return this.get(`chapters`)}getCurrentChapter(){return this.get(`currentChapter`)}getColor(){return this.get(`color`)}getColors(){return nS.all([this.get(`colorOne`),this.get(`colorTwo`),this.get(`colorThree`),this.get(`colorFour`)])}setColor(e){return this.set(`color`,e)}setColors(e){if(!Array.isArray(e))return new nS((e,t)=>t(TypeError(`Argument must be an array.`)));let t=new nS(e=>e(null)),n=[e[0]?this.set(`colorOne`,e[0]):t,e[1]?this.set(`colorTwo`,e[1]):t,e[2]?this.set(`colorThree`,e[2]):t,e[3]?this.set(`colorFour`,e[3]):t];return nS.all(n)}getCuePoints(){return this.get(`cuePoints`)}getCurrentTime(){return this.get(`currentTime`)}setCurrentTime(e){return this.set(`currentTime`,e)}getDuration(){return this.get(`duration`)}getEnded(){return this.get(`ended`)}getLoop(){return this.get(`loop`)}setLoop(e){return this.set(`loop`,e)}setMuted(e){return this.set(`muted`,e)}getMuted(){return this.get(`muted`)}getPaused(){return this.get(`paused`)}getPlaybackRate(){return this.get(`playbackRate`)}setPlaybackRate(e){return this.set(`playbackRate`,e)}getPlayed(){return this.get(`played`)}getQualities(){return this.get(`qualities`)}getQuality(){return this.get(`quality`)}setQuality(e){return this.set(`quality`,e)}getRemotePlaybackAvailability(){return this.get(`remotePlaybackAvailability`)}getRemotePlaybackState(){return this.get(`remotePlaybackState`)}getSeekable(){return this.get(`seekable`)}getSeeking(){return this.get(`seeking`)}getTextTracks(){return this.get(`textTracks`)}getAudioTracks(){return this.get(`audioTracks`)}getEnabledAudioTrack(){return this.get(`enabledAudioTrack`)}getDefaultAudioTrack(){return this.get(`defaultAudioTrack`)}getVideoEmbedCode(){return this.get(`videoEmbedCode`)}getVideoId(){return this.get(`videoId`)}getVideoTitle(){return this.get(`videoTitle`)}getVideoWidth(){return this.get(`videoWidth`)}getVideoHeight(){return this.get(`videoHeight`)}getVideoUrl(){return this.get(`videoUrl`)}getVolume(){return this.get(`volume`)}setVolume(e){return this.set(`volume`,e)}async setTimingSrc(e,t){if(!e)throw TypeError(`A Timing Object must be provided.`);await this.ready();let n=new CS(this,e,t);return uS(this,`notifyTimingObjectConnect`),n.addEventListener(`disconnect`,()=>uS(this,`notifyTimingObjectDisconnect`)),n}};Hx||(ES=xS(),gS(),_S(),vS(),yS(),bS());function OS(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,kS(e,t)}function kS(e,t){return kS=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},kS(e,t)}var AS={play:`onPlay`,playing:`onPlaying`,pause:`onPause`,ended:`onEnd`,timeupdate:`onTimeUpdate`,progress:`onProgress`,seeked:`onSeeked`,texttrackchange:`onTextTrackChange`,cuechange:`onCueChange`,cuepoint:`onCuePoint`,volumechange:`onVolumeChange`,playbackratechange:`onPlaybackRateChange`,error:`onError`,loaded:`onLoaded`},jS=function(e){function t(t){var n=e.call(this,t)||this;return n.refContainer=n.refContainer.bind(n),n}OS(t,e);var n=t.prototype;return n.componentDidMount=function(){this.createPlayer()},n.componentDidUpdate=function(e){var t=this,n=Object.keys(this.props).filter(function(n){return t.props[n]!==e[n]});this.updateProps(n)},n.componentWillUnmount=function(){this.player.destroy()},n.getInitialOptions=function(){var e,t=this.props.video,n=/^https?:/i.test(t)?`url`:`id`;return e={},e[n]=t,e.width=this.props.width,e.height=this.props.height,e.autopause=this.props.autopause,e.autoplay=this.props.autoplay,e.byline=this.props.showByline,e.color=this.props.color,e.controls=this.props.controls,e.loop=this.props.loop,e.portrait=this.props.showPortrait,e.title=this.props.showTitle,e.muted=this.props.muted,e.background=this.props.background,e.responsive=this.props.responsive,e.dnt=this.props.dnt,e.speed=this.props.speed,e.keyboard=this.props.keyboard,e.pip=this.props.pip,e.playsinline=this.props.playsInline,e.quality=this.props.quality,e.texttrack=this.props.textTrack,e.transparent=this.props.transparent,e},n.updateProps=function(e){var t=this,n=this.player;e.forEach(function(e){var r=t.props[e];switch(e){case`autopause`:n.setAutopause(r);break;case`color`:n.setColor(r);break;case`loop`:n.setLoop(r);break;case`volume`:n.setVolume(r);break;case`paused`:n.getPaused().then(function(e){return r&&!e?n.pause():!r&&e?n.play():null});break;case`width`:case`height`:n.element[e]=r;break;case`video`:if(r){var i=t.props.start,a=n.loadVideo(r);typeof i==`number`&&a.then(function(){n.setCurrentTime(i)})}else n.unload();break;case`playbackRate`:n.setPlaybackRate(r);break;case`quality`:n.setQuality(r);break}})},n.createPlayer=function(){var e=this,t=this.props,n=t.start,r=t.volume,i=t.playbackRate;this.player=new DS(this.container,this.getInitialOptions()),Object.keys(AS).forEach(function(t){var n=AS[t];e.player.on(t,function(t){var r=e.props[n];r&&r(t)})});var a=this.props,o=a.onError,s=a.onReady;this.player.ready().then(function(){s&&s(e.player)},function(e){if(o)o(e);else throw e}),typeof n==`number`&&this.player.setCurrentTime(n),typeof r==`number`&&this.updateProps([`volume`]),typeof i==`number`&&this.updateProps([`playbackRate`])},n.refContainer=function(e){this.container=e},n.render=function(){var e=this.props,t=e.id,n=e.className,r=e.style;return Z.createElement(`div`,{id:t,className:n,style:r,ref:this.refContainer})},t}(Z.Component);jS.defaultProps={autopause:!0,autoplay:!1,showByline:!0,controls:!0,loop:!1,showPortrait:!0,showTitle:!0,muted:!1,background:!1,responsive:!1,dnt:!1,speed:!1,keyboard:!0,pip:!1,playsInline:!0,transparent:!0};var MS={default:120,mqdefault:320,hqdefault:480,sddefault:640,maxresdefault:1280},NS=(e,t,n,r=`maxresdefault`)=>{let[i,a]=(0,Z.useState)(``);return(0,Z.useEffect)(()=>{let i=`https://img.youtube.com/${t}/${e}/${r}.${n}`,o=`https://img.youtube.com/${t}/${e}/hqdefault.${n}`,s=MS[r],c=new Image;c.onload=()=>{c.width<s?a(o):a(i)},c.onerror=()=>a(o),c.src=i},[e,t,n,r]),i};function PS(e,t,n,r,i){let a={"@context":`https://schema.org`,"@type":`VideoObject`,name:i?.name||t,thumbnailUrl:[i?.thumbnailUrl||n],embedUrl:i?.embedUrl||`${r}/embed/${e}`,contentUrl:i?.contentUrl||`https://www.youtube.com/watch?v=${e}`,...i?.description&&{description:i.description},...i?.uploadDate&&{uploadDate:i.uploadDate},...i?.duration&&{duration:i.duration}};return JSON.stringify(a)}function FS(e,t){let[n,r]=Z.useState(!1),[i,a]=Z.useState(e.alwaysLoadIframe||!1),o=encodeURIComponent(e.id),s=typeof e.playlistCoverId==`string`?encodeURIComponent(e.playlistCoverId):null,c=e.title,l=e.poster||`hqdefault`,u=e.announce||`Watch`,d=e.alwaysLoadIframe?e.autoplay&&e.muted:!0,f=Z.useMemo(()=>{let t=new URLSearchParams({...e.muted?{mute:`1`}:{},...d?{autoplay:`1`}:{},...e.enableJsApi?{enablejsapi:`1`}:{},...e.enableJsApi&&typeof window<`u`?{origin:window.location.origin}:{},...e.playlist?{list:o}:{}});return e.params&&new URLSearchParams(e.params.startsWith(`&`)?e.params.slice(1):e.params).forEach((e,n)=>{t.append(n,e)}),t},[e.muted,d,e.enableJsApi,e.playlist,o,e.params]),p=Z.useMemo(()=>e.cookie?`https://www.youtube.com`:`https://www.youtube-nocookie.com`,[e.cookie]),m=Z.useMemo(()=>e.playlist?`${p}/embed/videoseries?${f.toString()}`:`${p}/embed/${o}?${f.toString()}`,[e.playlist,p,o,f]),h=!e.thumbnail&&!e.playlist&&l===`maxresdefault`,g=e.webp?`webp`:`jpg`,_=e.webp?`vi_webp`:`vi`,v=h?NS(e.id,_,g,l):null,y=Z.useMemo(()=>e.thumbnail||v||`https://i.ytimg.com/${_}/${e.playlist?s:o}/${l}.${g}`,[e.thumbnail,v,_,e.playlist,s,o,l,g]),b=e.activatedClass||`lyt-activated`,x=e.adNetwork||!1,S=e.aspectHeight||9,C=e.aspectWidth||16,w=e.iframeClass||``,T=e.playerClass||`lty-playbtn`,E=e.wrapperClass||`yt-lite`,D=Z.useCallback(e.onIframeAdded||function(){},[e.onIframeAdded]),O=e.rel?`prefetch`:`preload`,k=e.containerElement||`article`,A=e.noscriptFallback!==!1,j=()=>{n||r(!0)},M=()=>{i||a(!0)};return Z.useEffect(()=>{i&&(D(),e.focusOnLoad&&typeof t==`object`&&t?.current&&t.current.focus())},[i,D,e.focusOnLoad,t]),Z.useEffect(()=>{if(!i||!e.enableJsApi||!(e.onReady||e.onStateChange||e.onError||e.onPlay||e.onPause||e.onEnd||e.onBuffering||e.onPlaybackRateChange||e.onPlaybackQualityChange))return;let n=!1,r=!1,a=r=>{if(r.origin!==`https://www.youtube.com`&&r.origin!==`https://www.youtube-nocookie.com`)return;let i;try{i=typeof r.data==`string`?JSON.parse(r.data):r.data}catch{return}switch(i.event){case`onReady`:n||(n=!0,e.onReady&&e.onReady({videoId:e.id,title:c}));break;case`infoDelivery`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate),i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break;case`onStateChange`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}break;case`onError`:if(i.info&&`errorCode`in i.info){let t=i.info.errorCode;e.onError&&e.onError(t)}break;case`onPlaybackRateChange`:i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate);break;case`onPlaybackQualityChange`:i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break}};window.addEventListener(`message`,a);let s=[],l=()=>{typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"listening","id":"`+o+`"}`,`*`)},u=()=>{r||(r=!0,l(),[100,300,600,1200,2400].forEach(e=>{s.push(setTimeout(l,e))}))};return typeof t==`object`&&t?.current?(t.current.addEventListener(`load`,u),t.current.contentDocument?.readyState===`complete`&&u()):[200,500,1e3,2e3,3e3].forEach(e=>{s.push(setTimeout(l,e))}),()=>{window.removeEventListener(`message`,a),s.forEach(clearTimeout),typeof t==`object`&&t?.current&&t.current.removeEventListener(`load`,u)}},[i,e.enableJsApi,e.onReady,e.onStateChange,e.onError,e.onPlay,e.onPause,e.onEnd,e.onBuffering,e.onPlaybackRateChange,e.onPlaybackQualityChange,e.stopOnEnd,e.id,o,c,t]),(0,$.jsxs)($.Fragment,{children:[!e.lazyLoad&&(0,$.jsx)(`link`,{rel:O,href:y,as:`image`}),(0,$.jsx)($.Fragment,{children:n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`link`,{rel:`preconnect`,href:p}),(0,$.jsx)(`link`,{rel:`preconnect`,href:`https://www.google.com`}),x&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`link`,{rel:`preconnect`,href:`https://static.doubleclick.net`}),(0,$.jsx)(`link`,{rel:`preconnect`,href:`https://googleads.g.doubleclick.net`})]})]})}),e.seo&&!e.playlist&&(0,$.jsx)(`script`,{type:`application/ld+json`,dangerouslySetInnerHTML:{__html:PS(e.id,c,y,p,e.seo)}}),A&&!e.playlist&&(0,$.jsx)(`noscript`,{children:(0,$.jsxs)(`a`,{href:`https://www.youtube.com/watch?v=${e.id}`,"aria-label":`Watch ${c} on YouTube`,children:[`Watch "`,c,`" on YouTube`]})}),(0,$.jsxs)(k,{onPointerOver:j,onClick:M,className:`${E} ${i?b:``}`,"data-title":c,role:!i&&!e.lazyLoad?`img`:void 0,"aria-label":i?void 0:`${c} - YouTube video preview`,style:{...!e.lazyLoad&&{backgroundImage:`url(${y})`},"--aspect-ratio":`${S/C*100}%`,...e.style||{}},children:[e.lazyLoad&&!i&&(0,$.jsx)(`img`,{src:y,alt:`${c} - YouTube thumbnail`,className:`lty-thumbnail`,loading:`lazy`}),e.playlist&&!i&&(0,$.jsx)(`div`,{className:`lty-playlist-icon`,"aria-hidden":`true`}),!(e.hideButtonOnActivate&&i)&&(0,$.jsx)(`button`,{type:`button`,className:T,"aria-label":`${u} ${c}`,"aria-hidden":i||void 0,tabIndex:i?-1:0,onClick:M,children:(0,$.jsx)(`span`,{className:`lty-visually-hidden`,children:u})}),i&&(0,$.jsx)(`iframe`,{ref:t,className:w,title:c,width:`560`,height:`315`,allow:`accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,src:m,referrerPolicy:e.referrerPolicy||`strict-origin-when-cross-origin`})]})]})}var IS=Z.forwardRef(FS);function LS(e){return e!==!1}function RS(e,t){let n=[];return t.startSeconds!==null&&n.push(`start=${t.startSeconds}`),e.controls===!1&&n.push(`controls=0`),e.loop===!0&&n.push(`loop=1`,`playlist=${t.id}`),e.playsinline===!0&&n.push(`playsinline=1`),n.length>0?n.join(`&`):void 0}function zS(e){if(e.width!==void 0)return{width:e.width}}function BS(e){if(!(e.width===void 0||e.height===void 0))return{aspectRatio:`${e.width} / ${e.height}`}}function VS(e){let t=(0,Q.c)(23),n=(0,Z.useRef)(null),r=e.title??`Vimeo video player`,i;t[0]===r?i=t[1]:(i=e=>{let t=e;n.current=t,t.element&&(t.element.title=r)},t[0]=r,t[1]=i);let a=i,o,s;t[2]===r?(o=t[3],s=t[4]):(o=()=>{let e=n.current;e?.element&&(e.element.title=r)},s=[r],t[2]=r,t[3]=o,t[4]=s),(0,Z.useEffect)(o,s);let c;t[5]===e?c=t[6]:(c=zS(e),t[5]=e,t[6]=c);let l=e.width===void 0,u=e.autoplay===!0,d=e.muted===!0,f=e.muted===!0?0:1,p=e.loop===!0,m=e.controls!==!1,h=e.playsinline!==!1,g;t[7]!==a||t[8]!==e.height||t[9]!==e.src||t[10]!==e.width||t[11]!==h||t[12]!==l||t[13]!==u||t[14]!==d||t[15]!==f||t[16]!==p||t[17]!==m?(g=(0,$.jsx)(jS,{video:e.src,responsive:l,width:e.width,height:e.height,autoplay:u,muted:d,volume:f,loop:p,controls:m,playsInline:h,onReady:a}),t[7]=a,t[8]=e.height,t[9]=e.src,t[10]=e.width,t[11]=h,t[12]=l,t[13]=u,t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=g):g=t[18];let _;return t[19]!==e.title||t[20]!==g||t[21]!==c?(_=(0,$.jsx)(`div`,{className:`ok-video ok-video-vimeo`,style:c,title:e.title,children:g}),t[19]=e.title,t[20]=g,t[21]=c,t[22]=_):_=t[22],_}function HS(e){let t=(0,Q.c)(17),n;t[0]===e.src?n=t[1]:(n=$t(e.src),t[0]=e.src,t[1]=n);let r=n;if(!r)return null;let i;t[2]!==r.startRaw||t[3]!==e.autoplay||t[4]!==e.muted?(i=[],r.startRaw!==null&&i.push(`t=${r.startRaw}`),e.autoplay===!0&&i.push(`autoplay=true`),e.muted===!0&&i.push(`muted=true`),t[2]=r.startRaw,t[3]=e.autoplay,t[4]=e.muted,t[5]=i):i=t[5];let a=i.length>0?`https://www.loom.com/embed/${r.id}?${i.join(`&`)}`:`https://www.loom.com/embed/${r.id}`,o;t[6]===e?o=t[7]:(o=zS(e),t[6]=e,t[7]=o);let s=e.title??`Loom video player`,c;t[8]!==a||t[9]!==e.height||t[10]!==e.width||t[11]!==s?(c=(0,$.jsx)(`iframe`,{className:`ok-video-loom-iframe`,src:a,title:s,width:e.width,height:e.height,allow:`autoplay; fullscreen`,referrerPolicy:`strict-origin-when-cross-origin`,allowFullScreen:!0}),t[8]=a,t[9]=e.height,t[10]=e.width,t[11]=s,t[12]=c):c=t[12];let l;return t[13]!==e.title||t[14]!==o||t[15]!==c?(l=(0,$.jsx)(`div`,{className:`ok-video ok-video-loom`,style:o,title:e.title,children:c}),t[13]=e.title,t[14]=o,t[15]=c,t[16]=l):l=t[16],l}function US(e){let t=(0,Q.c)(29);if(e.src!==void 0&&Fn(e.src)){let n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(HS,{...e,src:e.src}),t[0]=e,t[1]=n),n}if(e.src!==void 0&&ui(e.src)){let n;return t[2]===e?n=t[3]:(n=(0,$.jsx)(VS,{...e,src:e.src}),t[2]=e,t[3]=n),n}let n;if(t[4]!==e){n=Symbol.for(`react.early_return_sentinel`);bb0:{let r=e.src===void 0?null:Yt(e.src);if(r!==null){let i=e.autoplay===!0&&e.muted===!0,a=e.width!==void 0&&e.height!==void 0,o=zS(e),s;t[6]===e.poster?s=t[7]:(s=e.poster===void 0?void 0:Lo(e.poster),t[6]=e.poster,t[7]=s);let c=(0,$.jsx)(IS,{id:r.id,title:e.title??`YouTube video player`,cookie:!r.noCookie,params:RS(e,r),muted:e.muted===!0,autoplay:e.autoplay===!0,alwaysLoadIframe:i,thumbnail:s,aspectWidth:a?Number(e.width):void 0,aspectHeight:a?Number(e.height):void 0,style:BS(e)}),l;t[8]!==o||t[9]!==c?(l=(0,$.jsx)(`div`,{className:`ok-video ok-video-youtube`,style:o,children:c}),t[8]=o,t[9]=c,t[10]=l):l=t[10],n=l;break bb0}}t[4]=e,t[5]=n}else n=t[5];if(n!==Symbol.for(`react.early_return_sentinel`))return n;let r;t[11]===e.src?r=t[12]:(r=e.src===void 0?void 0:Lo(e.src),t[11]=e.src,t[12]=r);let i=e.title,a;t[13]===e.controls?a=t[14]:(a=LS(e.controls),t[13]=e.controls,t[14]=a);let o;t[15]===e.poster?o=t[16]:(o=e.poster===void 0?void 0:Lo(e.poster),t[15]=e.poster,t[16]=o);let s;return t[17]!==e.autoplay||t[18]!==e.height||t[19]!==e.loop||t[20]!==e.muted||t[21]!==e.playsinline||t[22]!==e.preload||t[23]!==e.title||t[24]!==e.width||t[25]!==r||t[26]!==a||t[27]!==o?(s=(0,$.jsx)(`video`,{className:`ok-video`,src:r,title:i,controls:a,autoPlay:e.autoplay,muted:e.muted,loop:e.loop,playsInline:e.playsinline,poster:o,preload:e.preload,width:e.width,height:e.height}),t[17]=e.autoplay,t[18]=e.height,t[19]=e.loop,t[20]=e.muted,t[21]=e.playsinline,t[22]=e.preload,t[23]=e.title,t[24]=e.width,t[25]=r,t[26]=a,t[27]=o,t[28]=s):s=t[28],s}function WS(e){let t=(0,Q.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,$.jsx)(`div`,{className:`prose-no-margin`,children:e.children}),t[0]=e.children,t[1]=n),n}var GS={Callout:_v,img:_b,video:US,audio:fv,Pdf:Cx,File:sy,Embed:Dv,Excalidraw:Zv,Accordion:cv,Toggle:e=>(0,$.jsx)(cv,{...e,title:e.title??`Toggle`}),HtmlAlignBlock:uv,Tabs:Fx,Tab:jx,Math:bb,MermaidFence:Tt,Mirror:cx,MirrorSource:lx,"*":WS};function KS(e){let t=new Set;for(let n of e)n.type===`reactnode`&&t.add(n.name);return t}var qS=mi(),JS=new Map;function YS(e){if(e.surface===`compat`){let t=GS[e.rendersAs];if(!t)throw Error(`Compat descriptor '${e.name}' declares rendersAs: '${e.rendersAs}', but no React component is registered under that name in componentMap. Add the canonical component before registering the compat descriptor.`);return{Component:t,reactNodePropNames:KS(e.props)}}let t=GS[e.name];return t?{Component:t,reactNodePropNames:KS(e.props)}:null}for(let[e,t]of qS.entries()){let n=YS(t);n&&JS.set(e,n)}function XS(e,t){return{...e,Component:t.Component,reactNodePropNames:t.reactNodePropNames}}function ZS(e){let t=qS.getOrWildcard(e),n=JS.get(t.name)??JS.get(`*`);if(!n)throw Error(`No React component registered for ${t.name} (and no '*' wildcard)`);return XS(t,n)}function QS(){let e=[];for(let[t,n]of qS.entries()){if(t===`*`)continue;let r=JS.get(t);r&&e.push(XS(n,r))}return e}var $S=`source`,eC=40;function tC(e,t){let n=``;return e.nodesBetween(0,t,(e,r)=>{e.type.name===`heading`&&r+e.nodeSize<=t&&(n=e.textContent)}),n}function nC(e){if(e.length<=eC)return e;let t=Iu(e,eC),n=t.lastIndexOf(`-`);return n>0?t.slice(0,n):t}function rC(e){let t=new Set;return e.descendants(e=>{if(e.type.name!==`jsxComponent`||e.attrs.componentName!==`MirrorSource`)return;let n=tx(e.attrs.props??{});n!==``&&t.add(n)}),t}function iC(e,t){let n=nC(ao(tC(e,t)))||$S,r=rC(e);if(!r.has(n))return n;let i=1;for(;r.has(`${n}-${i}`);)i+=1;return`${n}-${i}`}var aC=``+new URL(`image-preview-BJSGEOo4.png`,import.meta.url).href,oC=``+new URL(`video-preview-vLovc_Vy.png`,import.meta.url).href,sC={Callout:{description:{id:`322lyb`},props:()=>({type:`note`,title:Y._({id:`6s7LXO`})}),children:()=>Y._({id:`64sesb`})},Accordion:{description:{id:`mWVJRX`},props:()=>({title:Y._({id:`z9NwEu`}),defaultOpen:!0}),children:()=>Y._({id:`8uGMP8`})},Toggle:{description:{id:`D0_8qa`},props:()=>({title:Y._({id:`z9NwEu`}),defaultOpen:!0}),children:()=>Y._({id:`8uGMP8`})},img:{description:{id:`VUijjF`},props:()=>({src:aC,alt:Y._({id:`R9dK63`})})},video:{description:{id:`e1hptq`},props:()=>({controls:!0,poster:oC})},audio:{description:{id:`9jnjV0`},props:()=>({controls:!0})},Math:{description:{id:`Y-Urt2`},props:()=>({formula:`c = \\pm\\sqrt{a^2 + b^2}`})},Excalidraw:{description:{id:`qi17kj`},render:()=>(0,$.jsx)(`div`,{className:`flex h-full w-full items-center justify-center rounded-md border border-border bg-background p-3`,children:(0,$.jsxs)(`svg`,{viewBox:`0 0 120 60`,className:`h-full w-auto`,"aria-hidden":`true`,children:[(0,$.jsx)(`rect`,{x:`6`,y:`10`,width:`46`,height:`26`,rx:`6`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`text-muted-foreground`}),(0,$.jsx)(`ellipse`,{cx:`92`,cy:`38`,rx:`20`,ry:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`text-muted-foreground/70`}),(0,$.jsx)(`path`,{d:`M52 23 C 66 23, 70 34, 72 36`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`text-muted-foreground/50`})]})})},Embed:{description:{id:`jTLWxh`},render:()=>(0,$.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border bg-muted/40 px-2 py-1.5`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,$.jsx)(`span`,{className:`ml-1.5 flex-1 truncate rounded-sm bg-background px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:`https://example.com/embed`})]}),(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col justify-center gap-1.5 px-3 py-2`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`h-1.5 w-full rounded-sm bg-muted-foreground/20`}),(0,$.jsx)(`span`,{className:`h-1.5 w-5/6 rounded-sm bg-muted-foreground/20`}),(0,$.jsx)(`span`,{className:`h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]})]})},Pdf:{description:{id:`Fqr8BP`},render:()=>(0,$.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border bg-muted/40 px-1.5 py-1`,children:[(0,$.jsxs)(`svg`,{viewBox:`0 0 12 12`,className:`size-3 text-muted-foreground`,"aria-hidden":`true`,children:[(0,$.jsx)(`title`,{children:`Thumbnails`}),(0,$.jsx)(`rect`,{x:`1`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,$.jsx)(`rect`,{x:`7`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,$.jsx)(`rect`,{x:`1`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,$.jsx)(`rect`,{x:`7`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`})]}),(0,$.jsxs)(`span`,{className:`ml-1 flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5 font-mono`,children:`2`}),(0,$.jsx)(`span`,{children:`/ 12`})]}),(0,$.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] font-mono text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`−`}),(0,$.jsx)(`span`,{children:`100%`}),(0,$.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`+`})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-1 gap-1 p-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex w-6 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`}),(0,$.jsx)(`span`,{className:`h-3 rounded-sm border border-foreground/60 bg-background`}),(0,$.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`})]}),(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1 rounded-sm bg-background p-1.5`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1/2 rounded-sm bg-foreground/50`}),(0,$.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`h-1 w-5/6 rounded-sm bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`h-1 w-2/3 rounded-sm bg-muted-foreground/30`})]})]})]})},MermaidFence:{description:{id:`z0a2EA`},render:()=>(0,$.jsxs)(`svg`,{viewBox:`0 0 200 120`,className:`h-full w-full text-foreground`,"aria-hidden":`true`,preserveAspectRatio:`xMidYMid meet`,children:[(0,$.jsx)(`title`,{children:`Mermaid flowchart preview`}),(0,$.jsx)(`defs`,{children:(0,$.jsx)(`marker`,{id:`mermaid-preview-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto-start-reverse`,children:(0,$.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`currentColor`})})}),(0,$.jsx)(`rect`,{x:`14`,y:`20`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,$.jsx)(`text`,{x:`42`,y:`38`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Start`}),(0,$.jsx)(`polygon`,{points:`100,18 140,50 100,82 60,50`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,$.jsx)(`text`,{x:`100`,y:`54`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Ready?`}),(0,$.jsx)(`rect`,{x:`130`,y:`84`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,$.jsx)(`text`,{x:`158`,y:`102`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`End`}),(0,$.jsx)(`line`,{x1:`70`,y1:`34`,x2:`80`,y2:`40`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,$.jsx)(`line`,{x1:`124`,y1:`62`,x2:`138`,y2:`82`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,$.jsx)(`text`,{x:`138`,y:`74`,fontSize:`8`,fill:`currentColor`,opacity:`0.6`,children:`yes`})]})},Tabs:{description:{id:`75Y1dk`},render:()=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex gap-1 border-b border-border pb-1`,children:[(0,$.jsx)(`span`,{className:`rounded-md bg-foreground/10 px-2 py-0.5 text-xs font-medium text-foreground`,children:`Tab 1`}),(0,$.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs text-muted-foreground`,children:`Tab 2`})]}),(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:(0,$.jsx)(a,{id:`m6YGpY`})})]})},Mirror:{description:{id:`_WPP7e`},render:()=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/40 px-2 py-1.5`,children:[(0,$.jsxs)(`span`,{className:`absolute -top-2 right-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(Yl,{className:`size-2.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:(0,$.jsx)(a,{id:`EL_YRd`,components:{0:(0,$.jsx)(`code`,{className:`font-mono`})}})})]}),(0,$.jsx)(`span`,{className:`block h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`mt-1 block h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]}),(0,$.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,$.jsx)(a,{id:`qNOgUu`})})]})},MirrorSource:{description:{id:`epuNYK`},render:()=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/50 px-2 py-1.5`,children:[(0,$.jsxs)(`span`,{className:`absolute -top-2 left-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(ql,{className:`size-2.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:(0,$.jsx)(a,{id:`maDWIB`,components:{0:(0,$.jsx)(`code`,{className:`font-mono`})}})})]}),(0,$.jsx)(`span`,{className:`block h-1.5 w-4/5 rounded-sm bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`mt-1 block h-1.5 w-3/5 rounded-sm bg-muted-foreground/20`})]}),(0,$.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,$.jsx)(a,{id:`emgiet`})})]})}};function cC(e){let t={};for(let n of e.props)n.type!==`reactnode`&&`defaultValue`in n&&n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);return t}function lC(e){let t=ZS(e),n=cC(t);return{type:`jsxComponent`,attrs:{componentName:t.name,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:n},content:t.hasChildren?[{type:`paragraph`}]:void 0}}var uC=new Set;function dC(e){uC.add(e)}function fC(e){if(typeof e==`number`)return uC.delete(e);let t=uC.values().next();return t.done?!1:(uC.delete(t.value),!0)}function pC(e,t,n){n.props.some(e=>!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`)?(dC(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)})):n.hasChildren?e.commands.setTextSelection(t+2):(dC(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)}))}function mC(e){return({chain:t,state:n,editor:r,afterCommit:i})=>{let a=new WeakSet;n.doc.descendants(t=>{t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&a.add(t)});let o=lC(e.name);if(e.name===`Tabs`){let e=lC(`Tab`),t=lC(`Tab`),n=e.attrs,r=t.attrs;n.props={...n.props,label:`Tab 1`},r.props={...r.props,label:`Tab 2`},o.content=[e,t]}if(e.name===`MirrorSource`){let e=o.attrs;e.props={...e.props,name:iC(n.doc,n.selection.from)}}t().insertContent(o).run(),i(()=>{let t=-1;r.state.doc.descendants((n,r)=>{if(t>=0)return!1;n.type.name===`jsxComponent`&&n.attrs.componentName===e.name&&!a.has(n)&&(t=r)}),!(t<0)&&pC(r,t,e)})}}var hC=new Set([`File`,`Tab`]);function gC(){return[{name:`component-File`,label:Y._({id:`J2eKUI`}),icon:Zl,category:`media`,aliases:[`file`,`attachment`,`download`,`upload`,`document`,`doc`,`docx`,`zip`],description:"Attach a downloadable file (`.pdf` / `.docx` / `.zip` / …)",insertsBlockComponent:!0,command:vC,preview:{description:Y._({id:`wtcU6y`}),render:()=>(0,$.jsxs)(`div`,{className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1.5`,children:[(0,$.jsx)(Zl,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:`quarterly-report.pdf`}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`1.4 MB`})]})}}]}function _C(){return[...QS().filter(e=>e.surface===`canonical`&&!hC.has(e.name)).map(e=>{let t=sC[e.name],n=e.Component,r=t?{description:Y._(t.description),render:t.render??(()=>(0,$.jsx)(n,{...t.props?.(),children:t.children?.()}))}:void 0;return{name:`component-${e.name}`,label:e.displayName??e.name,icon:iv(e.icon),category:e.category??`content`,command:mC(e),aliases:e.searchTerms,description:e.description,insertsBlockComponent:!0,preview:r}}),...gC()]}function vC({editor:e}){if(!p_(e))return;let t=document.createElement(`input`);t.type=`file`,t.accept=`*/*`,t.style.display=`none`,t.addEventListener(`change`,()=>{let n=t.files?.[0];if(n){let t=e.state.selection.from;m_(n,e,t)}t.remove()},{once:!0}),t.addEventListener(`cancel`,()=>t.remove(),{once:!0}),document.body.appendChild(t),t.click()}function yC(){return[{name:`link`,label:Y._({id:`yzF66j`}),icon:lu,category:`insert`,aliases:[`url`,`href`,`external`,`web`,`hyperlink`,`wiki`,`wikilink`,`[[`,`internal`,`page`,`backlink`,`cross-link`],description:`Link to a page or external URL`,preview:{description:Y._({id:`5WDhAk`}),render:()=>(0,$.jsx)(`p`,{className:`leading-7 text-sm`,children:(0,$.jsx)(a,{id:`u-9fWA`,components:{0:(0,$.jsx)(`span`,{className:`font-medium text-azure-blue underline underline-offset-2 dark:text-sky-blue`})}})})},command:({chain:e,state:t,editor:n,afterCommit:r})=>{let i=t.selection.from;e().insertContent({type:`text`,text:`link`,marks:[{type:`link`,attrs:{href:``}}]}).run(),r(()=>{let e=V_(n.state,i,`link`);e&&(P_(e),requestAnimationFrame(()=>{nv(n).setActiveNode(e)}))})}},{name:`component-Tag`,label:Y._({id:`UL8A9w`}),icon:bi,category:`content`,aliases:[`#`,`hashtag`,`label`],description:"Inline tag (`#tagname`) for cross-doc linking",preview:{description:Y._({id:`5ClEAu`}),render:()=>(0,$.jsx)(`p`,{className:`text-sm leading-7`,children:(0,$.jsx)(a,{id:`KZLdgR`,components:{0:(0,$.jsx)(`a`,{className:`tag pointer-events-none`})}})})},command:({chain:e})=>{e().insertTag(``).run()}}]}var bC=[{id:`chart`,title:`Chart`,description:`A bar chart whose series colors track the OK chart palette.`,html:`<div style="font-family:system-ui,sans-serif;padding:20px;color:var(--foreground)">
|
|
2
|
+
import{o as e,t}from"./chunk-CYidjpOJ.js";import{t as n}from"./preload-helper-Chd9yIcd.js";import{t as r}from"./jsx-runtime-BUgB2tll.js";import{t as i}from"./react-f2sANaYj.js";import{n as a,r as o}from"./dist-Nvb76hAm.js";import{n as s}from"./dist-PQ5KMVDh.js";import{t as c}from"./react-dom-DPxgxlDT.js";import{t as l}from"./compiler-runtime-BfE3aGVn.js";import{t as u}from"./react-error-boundary-6ac6QM6R.js";import{t as d}from"./utils-CPqDy6Hr.js";import{t as f}from"./kbd-Cg1nrB7U.js";import{i as p}from"./dist-CSCUSbQc.js";import{l as m,n as h}from"./dist-DTFuvKje.js";import{i as g,n as _,t as v}from"./tooltip-BjuCvy5N.js";import{n as y,r as b,t as x}from"./collapsible-BKbszYZV.js";import{c as S,i as C,o as w,s as T}from"./electron-drag-strip-D9GZhMg_.js";import{a as E,d as D,f as O,i as k,l as A,r as j}from"./floating-ui.dom-BYl7JZd0.js";import{i as M,n as N,o as P,s as F,t as I}from"./select-BsDvTs6I.js";import{t as L}from"./switch-BKZTXkzu.js";import{t as ee}from"./button-DzgjsZzC.js";import{_ as R,d as te,f as ne,h as re,m as ie,o as ae,p as oe,u as se}from"./constants-upload-DZP-sCdl.js";import{n as z}from"./dist-BGzUo_18.js";import{G as B,H as ce,O as V,T as H,X as U,Y as W,_t as le,at as G,bt as ue,ct as K,f as de,ft as fe,h as pe,ht as q,i as me,it as J,j as he,m as ge,n as _e,ot as ve,pt as ye,r as be,rt as xe,st as Se,ut as Ce,vt as we,x as Te,y as Ee,yt as De,z as Oe}from"./dist-Dc8tD1th.js";import{i as ke,s as Ae}from"./keyboard-shortcuts-D5fo2XHL.js";import{t as Y}from"./dist-C_FzPxEX2.js";import{p as je,u as Me,v as Ne}from"./schemas-CxFhJLAM.js";import{_ as Pe,d as Fe,f as Ie,g as Le,h as Re,o as ze,s as Be,t as Ve}from"./constants-cc1-Bt4QPTUe.js";import{b as He,i as Ue,o as We,v as Ge}from"./documents-events-C1uYbecE.js";import{a as Ke,n as qe,o as Je,r as Ye,t as Xe}from"./_envelope-DuFpUEag-Beu481Zb.js";import{D as Ze,O as Qe,S as $e,bt as et,d as tt,g as nt,i as rt,l as it,o as at,s as ot,xt as st}from"./schemas-api-CqmliOdH.js";import"./constants-editors-DmmORwNP.js";import{t as ct}from"./note-window-mode-CI3Yju9B.js";import{a as lt,i as ut,n as dt,r as ft}from"./local-menu-action-bus-Dyh2UJJF.js";import{i as pt}from"./use-apply-config-theme-CYFG76sS.js";import{t as mt}from"./parse-api-error-CeEVOj25.js";import{t as ht}from"./createLucideIcon-DdBzwsHe.js";import{n as gt,t as _t}from"./git-branch-CeTudSak.js";import{n as vt,t as yt}from"./arrow-up-BGHhPj4y.js";import{a as bt,c as xt,d as St,f as Ct,i as wt,l as Tt,n as Et,r as Dt,t as Ot,u as kt}from"./Mermaid-Cd21uwyp.js";import{t as At}from"./check-B2OLRY33.js";import{t as jt}from"./chevron-down-CEv6N8LG.js";import{t as Mt}from"./chevron-right-Bofu4lib.js";import{t as Nt}from"./circle-alert-eBm4JPxY.js";import{t as Pt}from"./circle-check-nK1yRBIw.js";import{t as Ft}from"./copy-DpWa6i2v.js";import{t as It}from"./download-BouT3__0.js";import{c as Lt,n as Rt,o as zt,t as Bt}from"./ime-composition-CNKa_WNE.js";import{n as Vt,t as Ht}from"./settings-2-DoBlNQMk.js";import{$ as Ut,$n as Wt,$t as Gt,An as Kt,B as qt,Bt as Jt,Cn as Yt,Ct as Xt,Dn as Zt,Dt as Qt,En as $t,Et as en,F as tn,Ft as nn,G as rn,Gn as an,Gt as on,H as sn,Ht as cn,It as ln,J as un,Jt as dn,K as fn,Kn as pn,Kt as mn,L as hn,Lt as gn,M as _n,Mn as vn,Mt as yn,N as bn,Nn as xn,Nt as Sn,On as Cn,Pn as wn,Pt as Tn,Q as En,Qn as Dn,Qt as On,R as kn,Rn as An,Rt as jn,S as Mn,Sn as Nn,St as Pn,Tn as Fn,Tt as In,U as Ln,Un as Rn,Ut as zn,Vn as Bn,Vt as Vn,W as Hn,Wt as Un,Xn as Wn,Xt as Gn,Y as Kn,Yn as qn,Yt as Jn,Z as Yn,Zn as Xn,Zt as Zn,_r as Qn,_t as $n,an as er,ar as tr,at as nr,bn as rr,c as ir,cn as ar,cr as or,d as sr,dn as cr,dr as lr,dt as ur,en as dr,et as fr,fn as pr,fr as mr,ft as hr,gn as gr,gr as _r,gt as vr,hn as yr,hr as br,in as xr,ir as Sr,j as Cr,jn as wr,k as Tr,kn as Er,ln as Dr,lr as Or,lt as kr,m as Ar,mn as jr,mt as Mr,n as Nr,nn as Pr,nr as Fr,nt as Ir,on as Lr,or as Rr,ot as zr,p as Br,pn as Vr,pr as Hr,pt as Ur,q as Wr,qn as Gr,qt as Kr,r as qr,rn as Jr,rr as Yr,rt as Xr,s as Zr,sn as Qr,sr as $r,t as ei,tn as ti,tr as ni,u as ri,un as ii,ur as ai,ut as oi,vn as si,vr as ci,vt as li,wn as ui,x as di,xn as fi,xt as pi,yn as mi,yr as hi,z as gi,zt as _i}from"./CodeMirrorPropInput-DmgOqRyj.js";import{t as vi}from"./folder-open-COGOeTzI.js";import{n as yi}from"./prop-types-ZtKgQMRh.js";import{t as bi}from"./hash-C4CJQURT.js";import{t as xi}from"./info-CyR0W2SK.js";import{t as Si}from"./spinner-Bx8xD6f8.js";import{t as Ci}from"./maximize-2-DjzhPUDZ.js";import{t as wi}from"./minus-DdRxss3A.js";import{t as Ti}from"./paperclip-FfP_WlTp.js";import{n as Ei,t as Di}from"./plus-CXQ-oViZ.js";import{t as Oi}from"./search-BoiwnBpA.js";import{t as ki}from"./sparkles-lfxw6YO9.js";import{t as Ai}from"./trash-2-Blf9Cydx.js";import{t as ji}from"./triangle-alert-DFWRwfH7.js";import{t as Mi}from"./x-wldAHzfP.js";import{t as Ni}from"./utils-random-uuid-CE1X6bNM.js";import{t as Pi}from"./badge-DcyFOLs8.js";import{a as Fi,c as Ii,i as Li,n as Ri,o as zi,r as Bi,s as Vi,t as Hi}from"./dialog-CAxu_6pu.js";import{a as Ui,i as Wi}from"./constants-skills-Coq7kn_k.js";import{i as Gi,r as Ki,t as qi}from"./bridge-B2_zG6bo.js";import{c as Ji,d as Yi,l as Xi,s as Zi,u as Qi}from"./structural-freshness-C6rR7cV3-VXiZX15w.js";import{n as $i,t as ea}from"./storage-scope-BDcuM4d_.js";import{t as ta}from"./use-workspace-BTtr5NT8.js";import{C as na,_ as ra,a as ia,d as aa,f as oa,i as sa,l as ca,m as la,n as ua,p as da,s as fa,u as pa,w as ma}from"./doc-hash-BT2I193z.js";import{n as X,r as ha}from"./perf-CYJlqBBt.js";import{m as ga,t as _a}from"./use-apply-config-color-theme-UYP8FtjI.js";import{a as va,i as ya,n as ba,t as xa}from"./popover-Dxc5JyiN.js";import{D as Sa,L as Ca,O as wa,T as Ta,Y as Ea,Z as Da,et as Oa,f as ka,k as Aa,n as ja,o as Ma,u as Na,v as Pa,x as Fa}from"./config-provider-Cz-fhuIV.js";import{r as Ia}from"./saved-themes-client-BNonffrJ.js";import{t as La}from"./trace-api-nQInEDYS.js";import{t as Ra}from"./propagation-api-dgM6YInk.js";import{t as za}from"./context-api-CMjojwfb.js";import{i as Ba,n as Va,o as Ha}from"./css-color-to-hex-CWNe6sew.js";import{a as Ua}from"./client-version-oNpBBa2-.js";import{n as Wa,t as Ga}from"./reveal-editor-CoucRZz8.js";import{t as Ka}from"./input-CgydZJoC.js";import{n as qa,r as Ja}from"./external-link-DxgIpECR.js";import{t as Ya}from"./skeleton-2Ewnato7.js";import{s as Xa}from"./skill-scope-DjqrCXkR.js";import{A as Za,C as Qa,M as $a,S as eo,_ as to,c as no,g as ro,h as io,j as ao,k as oo,l as so,m as co,n as lo,u as uo,v as fo,w as po,x as mo,y as ho}from"./navigation-targets-Cu84E97-.js";import{r as go}from"./doc-paths-C1iU3JM4.js";import{n as _o}from"./use-collab-url-DbvOg54A.js";import{t as vo}from"./known-skill-dirs-CErGS26P.js";import{E as yo,Ft as bo,J as xo,K as So,M as Co,Mt as wo,Nt as To,Tt as Eo,X as Do,c as Oo,f as ko,l as Ao,lt as jo,ut as Mo,wt as No}from"./dist-CoJBCixp.js";import{a as Po,c as Fo,i as Io,o as Lo,s as Ro}from"./cm-theme-DpKmjLo0.js";import{R as zo,V as Bo,a as Vo,c as Ho,g as Uo,t as Wo,v as Go,z as Ko}from"./lib-CZXZ01YL.js";import{a as qo,n as Jo,o as Yo,t as Xo}from"./lib-o_ZJ5rsY.js";import{n as Zo}from"./syntax-UjZu5532.js";import{t as Qo}from"./excalidraw-scene-Dgb0SaoB.js";import{i as $o,n as es}from"./page-list-cache-duzt_bxz.js";import{n as ts,r as ns}from"./PageListContext-NRWi1wh0.js";import{t as rs}from"./startup-marks-C403iSh4.js";import{t as is}from"./lib-DxyUjQpt.js";import{t as as}from"./lib-D3PsW6H5.js";import{D as os,_ as ss}from"./skills-api-D9_3ttAz.js";import{i as cs,n as ls,r as us,t as ds}from"./dist-W5hM-kQ3.js";import{t as fs}from"./dist-BtC2yORW.js";import{n as ps}from"./dist-OHM7P10P.js";import{n as ms}from"./dist-ldcsP3Wx.js";import{n as hs}from"./dist-CNHpRWc3.js";import{n as gs}from"./dist-OiK6QmuG.js";import{n as _s}from"./dist-DLTuJxuQ2.js";import{t as vs}from"./stex-CmWau-0j.js";import{t as ys}from"./file-tree-rename-validation-BZbYm35X.js";import{t as bs}from"./CopyButton-BT2YHECh.js";import{n as xs}from"./single-file-mode-DURp6aom.js";(function(){var e=[`user-blocking`,`user-visible`,`background`];class t{constructor(){this.t=new MessageChannel,this.i=this.t.port2,this.l={},this.o=1,this.t.port1.onmessage=e=>this.h(e)}u(e){var t=this.o++;return this.l[t]=e,this.i.postMessage(t),t}p(e){delete this.l[e]}h(e){var t=e.data;if(t in this.l){var n=this.l[t];delete this.l[t],n()}}}function n(){return n.v||=new t,n.v}class r{constructor(e,t,n){n===void 0&&(n=0),this.k=e,this.T=null,this.C=null,this.m=!1,this._(t,n)}isIdleCallback(){return this.T===0}I(){return this.T===2}cancel(){if(!this.m)switch(this.m=!0,this.T){case 0:cancelIdleCallback(this.C);break;case 1:clearTimeout(this.C);break;case 2:n().p(this.C);break;default:throw TypeError(`Unknown CallbackType`)}}_(t,r){if(r&&r>0)return this.T=1,void(this.C=setTimeout(()=>{this.P()},r));if(!e.includes(t))throw TypeError(`Invalid task priority : `+t);t===`background`&&typeof requestIdleCallback==`function`?(this.T=0,this.C=requestIdleCallback(()=>{this.P()})):typeof MessageChannel==`function`?(this.T=2,this.C=n().u(()=>{this.P()})):(this.T=1,this.C=setTimeout(()=>{this.P()}))}P(){this.m||this.k()}}var i=0;class a{constructor(){this.j=null,this.M=null}isEmpty(){return this.j==null}push(e){if(typeof e!=`object`)throw TypeError(`Task must be an Object`);e.A=i++,this.isEmpty()?(e.N=null,this.j=e):(e.N=this.M,this.M.O=e),e.O=null,this.M=e}takeNextTask(){if(this.isEmpty())return null;var e=this.j;return this.q(e),e}merge(e,t){if(typeof t!=`function`)throw TypeError(`Must provide a selector function.`);if(e==null)throw Error(`sourceQueue cannot be null`);for(var n=this.j,r=null,i=e.j;i;){var a=i;if(i=i.O,t(a)){for(e.q(a);n&&n.A<a.A;)r=n,n=n.O;this.D(a,r),r=a}}}D(e,t){if(t!=this.M){var n=t?t.O:this.j;e.O=n,n.N=e,e.N=t,t==null?this.j=e:t.O=e}else this.push(e)}q(e){if(e==null)throw Error(`Expected task to be non-null`);e===this.j&&(this.j=e.O),e===this.M&&(this.M=this.M.N),e.O&&(e.O.N=e.N),e.N&&(e.N.O=e.O)}}class o extends Event{constructor(t,n){if(!n||!e.includes(n.previousPriority))throw TypeError(`Invalid task priority: '`+n.previousPriority+`'`);super(t),this.previousPriority=n.previousPriority}}class s extends AbortController{constructor(t){if(t===void 0&&(t={}),super(),t??={},typeof t!=`object`)throw TypeError(`'init' is not an object`);var n,r,i=t.priority===void 0?`user-visible`:t.priority;if(!e.includes(i))throw TypeError(`Invalid task priority: '`+i+`'`);this.H=i,this.R=!1,r=(n=this).signal,Object.defineProperties(r,{priority:{get:function(){return n.H},enumerable:!0},onprioritychange:{value:null,writable:!0,enumerable:!0}}),r.addEventListener(`prioritychange`,e=>{r.onprioritychange&&r.onprioritychange(e)})}setPriority(t){if(!e.includes(t))throw TypeError(`Invalid task priority: `+t);if(this.R)throw new DOMException(``,`NotAllowedError`);if(this.signal.priority!==t){this.R=!0;var n=this.H;this.H=t;var r=new o(`prioritychange`,{previousPriority:n});this.signal.dispatchEvent(r),this.R=!1}}}self.scheduler===void 0?(self.scheduler=new class{constructor(){this.S={},e.forEach(e=>{this.S[e]=[new a,new a]}),this.U=null,this.W=new WeakMap}yield(){return this.B(()=>{},{priority:`user-visible`},!0)}postTask(e,t){return this.B(e,t,!1)}B(t,n,r){if((n=Object.assign({},n)).signal!==void 0){if(n.signal===null||!(`aborted`in n.signal)||typeof n.signal.addEventListener!=`function`)return Promise.reject(TypeError(`'signal' is not a valid 'AbortSignal'`));if(n.signal&&n.signal.priority&&!e.includes(n.signal.priority))return Promise.reject(TypeError(`Invalid task priority: '`+n.signal.priority+`'`))}if(n.priority!==void 0&&(n.priority===null||!e.includes(n.priority)))return Promise.reject(TypeError(`Invalid task priority: '`+n.priority+`'`));if(n.delay===void 0&&(n.delay=0),n.delay=Number(n.delay),n.delay<0)return Promise.reject(TypeError(`'delay' must be a positive number.`));var i={callback:t,options:n,resolve:null,reject:null,hostCallback:null,abortCallback:null,onTaskCompleted:function(){this.options.signal&&this.abortCallback&&(this.options.signal.removeEventListener(`abort`,this.abortCallback),this.abortCallback=null)},onTaskAborted:function(){this.hostCallback&&=(this.hostCallback.cancel(),null),this.options.signal.removeEventListener(`abort`,this.abortCallback),this.abortCallback=null,this.reject(this.options.signal.reason)},isAborted:function(){return this.options.signal&&this.options.signal.aborted},isContinuation:r},a=new Promise((e,t)=>{i.resolve=e,i.reject=t});return this._(i),a}_(e){var t=e.options.signal;if(t){if(t.aborted)return void e.reject(t.reason);e.abortCallback=()=>{e.onTaskAborted()},t.addEventListener(`abort`,e.abortCallback)}e.options.delay>0?e.hostCallback=new r(()=>{e.hostCallback=null,this.F(e)},null,e.options.delay):(this.G(e),this.J())}F(e){this.G(e),this.U&&=(this.U.cancel(),null),this.K()}L(e){var t=this.W.get(e);if(t===void 0)throw Error(`Attempting to change priority on an unregistered signal`);if(t!==e.priority){for(var n=0;n<2;n++)this.S[e.priority][n].merge(this.S[t][n],t=>t.options.signal===e);this.W.set(e,e.priority)}}K(){this.U=null,this.V(),this.J()}J(){var{priority:e}=this.X();e!=null&&(e!==`background`&&this.U&&this.U.isIdleCallback()&&(this.U.cancel(),this.U=null),this.U||=new r(()=>{this.K()},e,0))}G(t){var n;if(!e.includes(n=t.options.priority?t.options.priority:t.options.signal&&t.options.signal.priority?t.options.signal.priority:`user-visible`))throw TypeError(`Invalid task priority: `+n);if(t.options.signal&&t.options.signal.priority){var r=t.options.signal;this.W.has(r)||(r.addEventListener(`prioritychange`,()=>{this.L(r)}),this.W.set(r,r.priority))}this.S[n][+!t.isContinuation].push(t)}V(){var e=null;do{var{priority:t,type:n}=this.X();if(t==null)return;e=this.S[t][n].takeNextTask()}while(e.isAborted());try{var r=e.callback();e.resolve(r)}catch(t){e.reject(t)}finally{e.onTaskCompleted()}}X(){for(var t=0;t<e.length;t++)for(var n=e[t],r=0;r<2;r++)if(!this.S[n][r].isEmpty())return{priority:n,type:r};return{priority:null,type:0}}},self.TaskController=s,self.TaskPriorityChangeEvent=o):self.scheduler.yield||(self.scheduler.yield=function(){return self.scheduler.postTask(()=>{},{priority:`user-blocking`})})})();var Z=e(i(),1),Ss=e(c(),1),Q=l(),Cs=null,ws=!1,Ts=!1;function Es(e){return e instanceof Error&&e.message?e.message:String(e)}function Ds(e){let t=Es(e);if(t===Cs){ws=!0,Ts=!0;return}Cs=t,ws=!1,Ts=!1}function Os(){return ws}function ks(){ws=!1,Cs=null}function As(){let e=Ts;return Ts=!1,e}var $=r(),js=`open-knowledge:doc-panel-tab`,Ms=null;function Ns(){return typeof window>`u`?new EventTarget:window}function Ps(){let e=Ms;return Ms=null,e}var Fs=null,Is=null;function Ls(){Fs=null,Is?.(),Is=null}function Rs(e){let t=null,n=null,r=null,i=()=>{typeof cancelAnimationFrame==`function`&&(t!==null&&cancelAnimationFrame(t),n!==null&&cancelAnimationFrame(n)),r!==null&&clearTimeout(r),Is===i&&(Is=null)},a=()=>{Fs===e&&(Fs=null),i()};return typeof requestAnimationFrame==`function`?(t=requestAnimationFrame(()=>{t=null,n=requestAnimationFrame(()=>{n=null,a()})}),r=setTimeout(a,250)):r=setTimeout(a,0),i}function zs(e){return typeof window>`u`||e===window}function Bs(e){if(Fs?.tab!==e)return null;let{request:t}=Fs;return Ls(),t}function Vs(e,t={},n=Ns()){if(zs(n)&&(Ms=e,Ls(),t.scope!==void 0||t.focus!==void 0)){let n={tab:e,request:t};Fs=n,Is=Rs(n)}n.dispatchEvent(new CustomEvent(js,{detail:{tab:e,...t}}))}function Hs(e,t=Ns()){let n=t=>{let n=t instanceof CustomEvent?t.detail:void 0;n?.tab&&e(n.tab,{scope:n.scope,focus:n.focus})};return t.addEventListener(js,n),()=>t.removeEventListener(js,n)}async function Us(e,t){let n=await fetch(e,{...t,headers:{"content-type":`application/json`,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok){let e=Ye.safeParse(r);throw Error(e.success?e.data.title??e.data.detail:`comments request failed (${n.status})`)}return r}function Ws(e){return Us(`/api/comment`,{method:`POST`,body:JSON.stringify(e)})}function Gs(e,t){let n=e.safeParse(t);if(!n.success)throw Error(`The server returned a response this build cannot read.`);return n.data}function Ks(e){let t=at.safeParse(e);if(!t.success)throw Error(`The server returned a comment thread this build cannot read.`);return t.data}function qs(e){let t=[];for(let n of e){let e=at.safeParse(n);e.success?t.push(e.data):console.warn(`[comments] skipped a thread this build cannot read`,e.error.issues)}return t}async function Js(e){let{threads:t}=await Us(e===void 0?`/api/comments`:`/api/comments?doc=${encodeURIComponent(e)}`);return qs(t)}function Ys(e){return Us(`/api/comments`,{method:`POST`,body:JSON.stringify(e)}).then(Ks)}function Xs(e,t){return Ws({action:`edit`,id:e,body:t}).then(Ks)}function Zs(e){return Ws({action:`reopen`,id:e}).then(Ks)}function Qs(e,t){return Ws({action:`replace`,id:e,...t}).then(Ks)}function $s(e){return Ws({action:`queue`,id:e}).then(e=>Gs(Qe,e))}function ec(e){return Ws({action:`unqueue`,id:e}).then(Ks)}function tc(e){return Us(`/api/comment?id=${encodeURIComponent(e)}`,{method:`DELETE`}).then(e=>Gs(tt,e))}function nc(e){return Ws({action:`dispatch-prepare-batch`,ids:e}).then(e=>Gs(Ze,e))}function rc(e){return Ws({action:`dispatch-complete-batch`,ids:e}).then(e=>Gs(ot,e))}var ic=`open-knowledge:comments-scope`,ac=typeof window>`u`?new EventTarget:window,oc=null;function sc(){let e=oc;return oc=null,e}function cc(e){let t=t=>{oc=null,e(t.detail)};return ac.addEventListener(ic,t),()=>ac.removeEventListener(ic,t)}function lc(e,t){t!==void 0&&typeof window<`u`&<({kind:`reveal-comments`,docName:t,scope:e===`project`?`queue`:`doc`},window)||(oc=e,Vs(`comments`),ac.dispatchEvent(new CustomEvent(ic,{detail:e})))}function uc(e){lc(`project`,e)}var dc=Object.freeze([]),fc=Object.freeze([]),pc=new Map,mc=[],hc=new Set,gc=new Set,_c=!1,vc=new Set,yc=0,bc=0;function xc(){for(let e of hc)e()}function Sc(){yc+=1,xc()}function Cc(){bc+=1,xc()}function wc(e){return{id:e.threadId,docName:e.docName,target:e.target,anchor:e.anchor===null?null:{quote:e.anchor.exact,prefix:e.anchor.prefix,suffix:e.anchor.suffix,start:e.anchor.start,end:e.anchor.end},status:e.state===`anchored`?`open`:e.state,body:e.latestComment,createdAt:e.createdAt,updatedAt:e.updatedAt??e.createdAt,queued:e.queued}}async function Tc(){return(await Js()).map(wc).sort((e,t)=>t.createdAt-e.createdAt)}async function Ec(e){e!==void 0&&gc.add(e);let t=await Tc();mc=t,_c=!0;for(let e of gc)pc.set(e,t.filter(t=>t.docName===e));Sc(),Dc(t)}function Dc(e){vl!==null&&(e.some(e=>e.id===vl&&e.status===`open`)||jl(null))}var Oc=!1;function kc(){Oc||typeof window>`u`||(Oc=!0,Ge(e=>{e.includes(`comments`)&&Ec().catch(()=>void 0)}))}function Ac(e){kc(),!gc.has(e)&&(gc.add(e),Ec(e).catch(()=>{gc.delete(e)}))}function jc(){kc(),!_c&&(_c=!0,Ec().catch(()=>{_c=!1}))}function Mc(e){return Ac(e),pc.get(e)??dc}function Nc(e){return hc.add(e),()=>{hc.delete(e)}}function Pc(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=()=>Mc(e),t[0]=e,t[1]=n),(0,Z.useSyncExternalStore)(Nc,n,Fc)}function Fc(){return dc}function Ic(){return jc(),mc}function Lc(){return(0,Z.useSyncExternalStore)(Nc,Ic,Rc)}function Rc(){return dc}function zc(e){for(let t of pc.values()){let n=t.find(t=>t.id===e);if(n)return n}return mc.find(t=>t.id===e)??null}function Bc(e){Ys({docName:e.docName,quote:e.quote,prefix:e.prefix,suffix:e.suffix,body:e.body,queue:!0}).then(t=>{if(Ec(e.docName).catch(()=>void 0),e.onCreated!==void 0){e.onCreated(t.threadId);return}lc(`doc`,e.docName),Nl()}).catch(e=>{z.error(e instanceof Error&&e.message?Y._({id:`q3W2nd`,values:{0:e.message}}):Y._({id:`SRBk2G`}))})}function Vc(e){Ys({docName:e.docName,propertyKey:e.propertyKey,propertyPath:e.propertyPath,quote:e.quote,body:e.body,queue:!0}).then(()=>{Ec(e.docName).catch(()=>void 0),lc(`doc`,e.docName),Nl()}).catch(e=>{z.error(e instanceof Error&&e.message?Y._({id:`q3W2nd`,values:{0:e.message}}):Y._({id:`SRBk2G`}))})}function Hc(e,t,n){e.then(()=>{Ec(t).catch(()=>void 0)},e=>{z.error(e instanceof Error&&e.message?`${n} ${e.message}`:n),Ec(t).catch(()=>void 0)})}function Uc(e,t){let n=zc(e)?.docName;Hc(Xs(e,t),n,Y._({id:`kzpkcn`}))}function Wc(e){let t=zc(e)?.docName;rl(e),Hc(Zs(e),t,Y._({id:`lISYEX`}))}function Gc(e){let t=zc(e)?.docName;Hc(tc(e),t,Y._({id:`IxHMdF`}))}function Kc(e,t,n){let r=zc(e)?.docName;Hc(Qs(e,{quote:t,prefix:n?.prefix,suffix:n?.suffix}),r,Y._({id:`mlvM8g`}))}var qc=fc,Jc=-1,Yc=fc,Xc=-1,Zc=-1;function Qc(){if(jc(),Jc!==yc){let e=mc.filter(e=>e.queued&&e.status!==`resolved`).sort((e,t)=>e.createdAt-t.createdAt).map(e=>e.id);qc=e.length===0?fc:e,Jc=yc}return qc}function $c(){let e=Qc();if(Xc!==yc||Zc!==bc){let t=e.filter(e=>!vc.has(e));Yc=t.length===0?fc:t,Xc=yc,Zc=bc}return Yc}function el(){return(0,Z.useSyncExternalStore)(Nc,$c,tl)}function tl(){return fc}function nl(e){return $c().filter(t=>zc(t)?.docName===e)}function rl(e){if(!vc.has(e))return;let t=new Set(vc);t.delete(e),vc=t,Cc()}function il(e){let t=zc(e)?.docName;rl(e),Hc($s(e),t,Y._({id:`S-7ej_`}))}function al(e){let t=zc(e)?.docName;Hc(ec(e),t,Y._({id:`PTUuoc`}))}function ol(e){$c().includes(e)?al(e):il(e)}function sl(e,t){let n=new Set($c()),r=e.filter(e=>n.has(e)!==t);if(r.length!==0){if(t&&vc.size>0){let e=new Set(vc);for(let t of r)e.delete(t);vc=e,Cc()}Promise.all(r.map(e=>(t?$s(e):ec(e)).then(()=>!0,()=>!1))).then(e=>{let t=e.filter(e=>!e).length;t>0&&z.error(Y._({id:`wqD3pI`,values:{0:r.length,failed:t}})),Ec().catch(()=>void 0)})}}var cl=!1;async function ll({compose:e,threadIds:t,resolve:n=!0}){let r=t??$c();if(r.length===0||cl)return[];cl=!0;try{return await ul(r,e,n)}finally{cl=!1}}async function ul(e,t,n){let r;try{r=await nc(e)}catch(e){return z.error(e instanceof Error&&e.message?Y._({id:`cVKnqL`,values:{0:e.message}}):Y._({id:`7FA2iI`})),[]}Sc();let i=r.results.flatMap(e=>e.ok?[{threadId:e.threadId,payload:e.payload}]:[]);if(i.length===0)return await Ec().catch(()=>void 0),[];let a=!1;try{a=await t(i)}catch(e){console.warn(`[comments] dispatch compose failed; leaving threads queued`,e),a=!1}let o=a?i.map(e=>e.threadId):[];return o.length>0&&n&&await rc(o).catch(()=>{z.error(Y._({id:`JyM0gO`}))}),await Ec().catch(()=>void 0),o}var dl=`open-knowledge:comment-focus-thread`,fl=`open-knowledge:comment-open-thread`,pl=`open-knowledge:comment-start`,ml=`open-knowledge:comment-posted`,hl=typeof window>`u`?new EventTarget:window;function gl(e){hl.dispatchEvent(new CustomEvent(dl,{detail:e}))}function _l(e){let t=t=>e(t.detail);return hl.addEventListener(dl,t),()=>hl.removeEventListener(dl,t)}var vl=null,yl=null,bl=null,xl=new Set;function Sl(){let e=yl??vl;if(e!==bl){bl=e;for(let e of xl)e()}}function Cl(){return bl}function wl(e){yl=e,Sl()}function Tl(e){yl===e&&(yl=null,Sl())}function El(e){return xl.add(e),()=>{xl.delete(e)}}function Dl(){return(0,Z.useSyncExternalStore)(kl,Al,Ol)}function Ol(){return null}function kl(e){return Ml(()=>e())}function Al(){return vl}function jl(e){vl=e,Sl(),e!==null&&Vs(`comments`),hl.dispatchEvent(new CustomEvent(fl,{detail:e}))}function Ml(e){let t=t=>e(t.detail);return hl.addEventListener(fl,t),()=>hl.removeEventListener(fl,t)}function Nl(){hl.dispatchEvent(new CustomEvent(ml))}function Pl(e){let t=()=>e();return hl.addEventListener(ml,t),()=>hl.removeEventListener(ml,t)}function Fl(){hl.dispatchEvent(new CustomEvent(pl))}function Il(e){let t=()=>e();return hl.addEventListener(pl,t),()=>hl.removeEventListener(pl,t)}var Ll=ht(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),Rl=ht(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),zl=ht(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),Bl=ht(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Vl=ht(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Hl=ht(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),Ul=ht(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),Wl=ht(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),Gl=ht(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Kl=ht(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),ql=ht(`copy-plus`,[[`line`,{x1:`15`,x2:`15`,y1:`12`,y2:`18`,key:`1p7wdc`}],[`line`,{x1:`12`,x2:`18`,y1:`15`,y2:`15`,key:`1nscbv`}],[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Jl=ht(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]),Yl=ht(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Xl=ht(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),Zl=ht(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),Ql=ht(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),$l=ht(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),eu=ht(`heading-1`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`m17 12 3-2v8`,key:`1hhhft`}]]),tu=ht(`heading-2`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`,key:`9jr5yi`}]]),nu=ht(`heading-3`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`,key:`68ncm8`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`,key:`1ejuhz`}]]),ru=ht(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),iu=ht(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),au=ht(`layout-panel-top`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}]]),ou=ht(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),su=ht(`link-2-off`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),cu=[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]],lu=ht(`link-2`,cu),uu=ht(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),du=ht(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),fu=ht(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),pu=ht(`message-square-warning`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 15h.01`,key:`q59x07`}],[`path`,{d:`M12 7v4`,key:`xawao1`}]]),mu=ht(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),hu=ht(`panel-top`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]),gu=ht(`pen-tool`,[[`path`,{d:`M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z`,key:`nt11vn`}],[`path`,{d:`m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18`,key:`15qc1e`}],[`path`,{d:`m2.3 2.3 7.286 7.286`,key:`1wuzzi`}],[`circle`,{cx:`11`,cy:`11`,r:`2`,key:`xmgehs`}]]),_u=ht(`quote`,[[`path`,{d:`M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`rib7q0`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`1ymkrd`}]]),vu=ht(`shapes`,[[`path`,{d:`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`,key:`1bo67w`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`3.5`,key:`w3z12y`}]]),yu=ht(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),bu=ht(`sigma`,[[`path`,{d:`M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2`,key:`wuwx1p`}]]),xu=ht(`smile`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2`,key:`1y1vjs`}],[`line`,{x1:`9`,x2:`9.01`,y1:`9`,y2:`9`,key:`yxxnd0`}],[`line`,{x1:`15`,x2:`15.01`,y1:`9`,y2:`9`,key:`1p4y9e`}]]),Su=ht(`square-play`,[[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}]]),Cu=ht(`superscript`,[[`path`,{d:`m4 19 8-8`,key:`hr47gm`}],[`path`,{d:`m12 19-8-8`,key:`1dhhmo`}],[`path`,{d:`M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06`,key:`1dfcux`}]]),wu=ht(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),Tu=ht(`text-align-center`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M17 12H7`,key:`16if0g`}],[`path`,{d:`M19 19H5`,key:`vjpgq2`}]]),Eu=ht(`text-align-end`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M21 19H7`,key:`4cu937`}]]),Du=ht(`text-align-start`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]]),Ou=ht(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),ku=ht(`workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),Au=ht(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),ju=(()=>{let e=globalThis.Intl.Segmenter;return e?new e(void 0,{granularity:`grapheme`}):null})();function Mu(e){return e>=56320&&e<=57343}function Nu(e){return e>=55296&&e<=56319}function Pu(e,t){if(ju){let n=ju.segment(e).containing(t);return n===void 0?t:n.index}return Mu(e.charCodeAt(t))&&Nu(e.charCodeAt(t-1))?t-1:t}function Fu(e,t){if(ju){let n=ju.segment(e).containing(t);return n===void 0||n.index===t?t:n.index+n.segment.length}return Mu(e.charCodeAt(t))&&Nu(e.charCodeAt(t-1))?t+1:t}function Iu(e,t){return e.length<=t?e:t<=0?``:e.slice(0,Pu(e,t))}function Lu(e,t){return e.length<=t?e:t<=0?``:e.slice(Fu(e,e.length-t))}var Ru=new Map,zu=new Set;function Bu(){for(let e of zu)e()}function Vu(e,t){Ru.set(e,t),Bu()}function Hu(e,t){Ru.get(e)===t&&(Ru.delete(e),Bu())}function Uu(e){return Ru.get(e)??null}function Wu(e){let t=Ru.get(e);if(!t||t.isDestroyed)return null;let n=br(t)?.dom;return n?.isConnected&&n.getClientRects().length>0?t:null}function Gu(e){return zu.add(e),()=>zu.delete(e)}function Ku(e,t){let n=e.attrs[t];return typeof n==`string`?n:``}function qu(e,t){let n=e.attrs.props;if(typeof n!=`object`||!n)return``;let r=n[t];return typeof r==`string`?r:``}var Ju=[`children`,`chart`,`formula`,`alt`,`name`,`alias`,`target`];function Yu(e){for(let t of Ju){let n=qu(e,t);if(n.length>0)return n}return Ku(e,`sourceRaw`)}function Xu(e){switch(e.type.name){case`wikiLink`:return Ku(e,`alias`)||Ku(e,`target`);case`wikiLinkEmbed`:return Ku(e,`target`);case`tag`:return`#${Ku(e,`value`)}`;case`mathInline`:return Ku(e,`formula`);case`image`:case`imageReference`:return Ku(e,`alt`);case`footnoteReference`:return Ku(e,`label`)||Ku(e,`identifier`);case`jsxComponent`:case`jsxInline`:return e.content.size===0?Yu(e):``;default:return``}}function Zu(e,t,n,r=`
|
|
3
|
+
`,{inlineOnly:i=!1}={}){let a=``,o=!0;return e.nodesBetween(t,n,(e,s)=>{let c=e.isText?(e.text??``).slice(Math.max(t,s)-s,n-s):i&&e.isBlock?``:Xu(e);return e.isBlock&&(e.isTextblock||c.length>0)&&r&&(o?o=!1:a+=r),a+=c,!0},0),a}function Qu(e,t){if(!t)return{kind:`absent`};if(t.getClientRects().length===0)return{kind:`unmeasurable`};let n=e.getBoundingClientRect().top;return{kind:`measured`,contentPos:t.getBoundingClientRect().top-n+e.scrollTop}}function $u(e,t,n){if(t===null)return e;switch(n.kind){case`measured`:return n.contentPos+t;case`absent`:return e;case`unmeasurable`:return null;default:return ad(n)}}var ed=`[contenteditable]`;function td(e){let t=e.getBoundingClientRect().top,{scrollTop:n}=e,r=null;for(let i of Array.from(e.querySelectorAll(ed))){if(i.parentElement?.closest(ed)||i.getClientRects().length===0)continue;let e=i.getBoundingClientRect().bottom-t+n;(r===null||e>r)&&(r=e)}return r}function nd(e,t,n){return t===null?e:Math.min(e,Math.max(0,t-n))}function rd(e,t,n){return(t??n)>e}function id(e){switch(e.kind){case`measured`:case`absent`:return!0;case`unmeasurable`:return!1;default:return ad(e)}}function ad(e){throw Error(`Unhandled AnchorMeasurement variant: ${JSON.stringify(e)}`)}function od(e,t){return Math.abs(e-t)<=1}function sd(e,t){return t-e>1}var cd=1e4;function ld(e,t,n){let r=t-n;return r<=0?0:Math.max(0,Math.min(1,e/r))}var ud=new Map;function dd(e,t){if(ud.delete(e),ud.set(e,t),ud.size>256){let e=ud.keys().next().value;e!==void 0&&ud.delete(e)}}function fd(e){return ud.get(e)}var pd=`data-ok-body-anchor`;function md(e){let t=e.anchor??e.container.querySelector(`[data-ok-body-anchor]`),n=Qu(e.container,t),r=n.kind===`measured`?n.contentPos:0;dd(e.docName,{offset:e.targetScrollTop-r,mode:e.mode,fraction:ld(e.targetScrollTop,e.container.scrollHeight,e.container.clientHeight)})}var hd=new Map,gd=0;function _d(e,t){let n=hd.get(e)??{landing:0,navigation:0};n[t]+=1,hd.set(e,n);let r=gd,i=!1;return{release(){if(i||(i=!0,r!==gd))return;let n=hd.get(e);n&&(n[t]=Math.max(0,n[t]-1),n.landing===0&&n.navigation===0&&hd.delete(e))}}}function vd(e){let t=hd.get(e);return t?t.landing>0?`landing`:t.navigation>0?`navigation`:null:null}function yd(e){return vd(e)!==null}var bd=new Map;function xd(e,t){let n=bd.get(e)??new Set;return n.add(t),bd.set(e,n),{release(){let n=bd.get(e);n&&(n.delete(t),n.size===0&&bd.delete(e))}}}var Sd=600,Cd=`ok/scroll-nav/declined`,wd=new Map;function Td(e,t){let n=wd.get(e)??new Set;if(wd.delete(e),wd.set(e,n),wd.size>32){let e=wd.keys().next().value;e!==void 0&&wd.delete(e)}return n.has(t)?!1:(n.add(t),!0)}var Ed=new Set;function Dd(e){let t=_d(e,`navigation`),n=setTimeout(()=>{Ed.delete(n),t.release()},Sd);Ed.add(n)}function Od(e,t){let n=bd.get(e),r=n?Array.from(n):[];for(let n of r)if(!n.yieldsToNavigation)return Td(e,t)&&X(Cd,{docName:e,seam:t,ownerCount:r.length}),!1;wd.delete(e),Dd(e);for(let e of r)e.supersede();return!0}function kd(e,t,n){return Od(e,t)?(n(),!0):!1}var Ad=!1;function jd(e){Ad=e}function Md(){return Ad}var Nd=new Map,Pd=null;function Fd(){return ha(`PREWARM_CORRELATION_WINDOW_MS`,5e3)}function Id(){if(Pd!==null)return;let e=Math.max(50,Math.floor(Fd()/2));Pd=setTimeout(()=>{Pd=null,Ld(Date.now()),Nd.size>0&&Id()},e)}function Ld(e){let t=Fd();for(let[n,r]of Nd)e-r.emittedAt>=t&&(Nd.delete(n),X.count(`ok/sidebar/prewarm`,{hit:!1}))}function Rd(e,t,n=Date.now()){Nd.has(e)&&X.count(`ok/sidebar/prewarm`,{hit:!1}),Nd.set(e,{poolEventId:t,emittedAt:n}),Id()}function zd(e,t,n=Date.now()){let r=Nd.get(e);return!r||r.poolEventId!==t||n-r.emittedAt>=Fd()?!1:(Nd.delete(e),X(`ok/sidebar/prewarm-clicked`,{docName:e,t:n,poolEventId:t}),X.count(`ok/sidebar/prewarm`,{hit:!0}),!0)}var Bd=6e3,Vd=6e4;function Hd(e,t){let n=e.filter(e=>t-e<Vd);return n.push(t),{times:n,escalate:n.length>=2}}function Ud(e,t){return e==null?`hidden`:e.kind===`refused`?`refused`:t?`hidden`:`switch`}var Wd=new Set,Gd=null;function Kd(){for(let e of Wd)e()}function qd(e){return Gd===e?!0:(Gd=e,Kd(),!0)}function Jd(){return Gd}function Yd(e){return Wd.add(e),()=>{Wd.delete(e)}}je({event:Me(`ok-branch-switched-clear-failed`),branch:Ne(),docName:Ne(),reason:Ne()});async function Xd(e,t){if(e.isMismatchRecycleInFlight()){console.warn(JSON.stringify({event:`ok-branch-switched-deferred-to-mismatch-recycle`,branch:t}));return}let n=[];for(let[r,i]of e.entries)i.kind===`active`&&i.persistence!==null&&n.push(i.persistence.clearData().catch(e=>{let n={event:`ok-branch-switched-clear-failed`,docName:r,branch:t,reason:e instanceof Error?e.message:String(e)};console.warn(JSON.stringify(n))}));await Promise.all(n),e.clearBufferedUpdates(),e.recycleAllEntries()}var Zd=null,Qd=null,$d=new Set;function ef(e,t){return e.runtimeVersion===t.runtimeVersion&&e.protocolVersion===t.protocolVersion}function tf(e){if(Zd===null||Qd===null){Zd=e,Qd=e;return}if(ef(Qd,e))return;Qd=e;let t={loaded:Zd,current:e,drifted:!ef(Zd,e)};for(let e of $d)try{e(t)}catch(e){console.warn(`[server-version-store] subscriber threw:`,e)}}function nf(e){return $d.add(e),()=>{$d.delete(e)}}function rf(e){let t=!1;return()=>{t?e():t=!0}}function af(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function of(e,t=``){let n;try{n=await fetch(`${t}/api/server-info`,{signal:AbortSignal.timeout(5e3)})}catch{return}if(!n.ok)return;let r;try{r=await n.json()}catch{return}let i=Ke.safeParse(r);if(!i.success){console.warn(JSON.stringify({event:`ok-server-info-schema-mismatch`,issues:i.error.issues}));return}if(e.setExpectedServerInstanceId(i.data.serverInstanceId),Ia(i.data.serverInstanceId),tf({runtimeVersion:i.data.runtimeVersion??null,protocolVersion:i.data.protocolVersion??null}),i.data.currentBranch!==void 0&&e.compareAndUpdateObservedBranch(i.data.currentBranch)&&(Xd(e,i.data.currentBranch),Ue(i.data.currentBranch)),i.data.currentDiskAckSVs!==void 0){let t={};for(let[e,n]of Object.entries(i.data.currentDiskAckSVs))try{t[e]=af(n)}catch{}e.observeDiskAckBatch(t)}}var sf=`ok-tab-session-restore-recovered`;function cf(){z(Y._({id:`HdS4Ft`}),{id:sf,description:Y._({id:`AR4s_6`}),duration:1/0})}var lf=null;function uf(e){lf=e}function df(e){let t=lf;return lf=null,t!==null&&ra(e,t)}function ff(e){return[...new Set(e)]}function pf(e){return{async reconcileLocalRename({renamed:t,renamedFolders:n=[],renamedAssets:r=[],additionalRemovedDocNames:i=[]}){e.captureRenameSnapshots(t);let a=e.getActivePoolDocName(),o=[];for(let{fromDocName:n,toDocName:r}of t)o.push(n),a!==r&&e.hasPooledDocument(r)&&o.push(r);o.push(...i),await Promise.all(ff(o).map(t=>e.closeAndClear(t))),e.remapTabs({renamed:t,renamedFolders:n,renamedAssets:r})},async reconcileLocalRemoval({tabIdsToClose:t,docNamesToClear:n}){e.closeTabs(t),await Promise.all(ff(n).map(t=>e.closeAndClear(t)))},async reconcileAuthRename({fromDocName:t,toDocName:n}){let r=e.getActivePoolDocName()===t,i=[{fromDocName:t,toDocName:n}];e.captureRenameSnapshots(i),await Promise.all([e.closeAndClear(t),e.closeAndClear(n)]),r&&e.openAndActivate(n),e.remapTabs({renamed:i,renamedFolders:[],renamedAssets:[]});let a=e.remapActiveTargetForRename(t,n);(r||a)&&e.navigateToDocument(n)},async reconcileAuthRemoval({docName:t}){let n=e.getActivePoolDocName()===t;await e.closeAndClear(t),e.removeDocumentTab(t),e.clearActiveTargetForRemoval(t),n&&e.showDocumentDeletedState?.(t)!==!0&&e.navigateHome()}}}var mf=new Map;function hf(e){return mf.get(e)}function gf(e,t){mf.set(e,t)}function _f(e){mf.delete(e)}var vf=`open-knowledge-app`,yf=new Map,bf=new Set,xf=1024,Sf=1024;function Cf(){return La.getTracer(vf)}function wf(e,t,n){if(bf.has(e))return null;let r=yf.get(e);if(r)return r;if(yf.size>=Sf){let e=yf.keys().next().value;if(e!==void 0){let t=yf.get(e);yf.delete(e);try{t?.span.end()}catch(e){console.warn(`[otel-spans] eviction span.end failed:`,e instanceof Error?e:String(e))}}}let i={span:Cf().startSpan(`ok.cold-mount`,{attributes:{"mount.id":e,...t},startTime:n}),startTimeMs:n};return yf.set(e,i),i}function Tf(e,t,n,r,i){try{let a=wf(e,n,r),o=a?La.setSpan(za.active(),a.span):za.active();Cf().startSpan(t,{attributes:{"mount.id":e,...n},startTime:r},o).end(i??Date.now())}catch(e){console.warn(`[otel-spans] emitColdMountChild failed:`,e instanceof Error?e:String(e))}}function Ef(e,t){try{let n=yf.get(e);if(n&&(yf.delete(e),n.span.end(t??Date.now())),!bf.has(e)){if(bf.size>=xf){let e=bf.values().next().value;e!==void 0&&bf.delete(e)}bf.add(e)}}catch(e){console.warn(`[otel-spans] finalizeColdMountSpan failed:`,e instanceof Error?e:String(e))}}var Df=class extends Error{docName;constructor(e){super(`Mount aborted for "${e}"`),this.name=`MountAbortError`,this.docName=e}};function Of(){return ha(`MOUNT_STALLED_THRESHOLD_MS`,1e4)}function kf(e){e.stalledHandle!==null&&(clearTimeout(e.stalledHandle),e.stalledHandle=null)}function Af(e,t,n){if(e.stalledMarkEmitted)return;e.stalledMarkEmitted=!0;let r=n-e.createdAt;X(`ok/mount/stalled`,{docName:t,mountId:e.mountId,elapsedMs:r})}var jf=new Map,Mf=new Set;function Nf(e){Mf.add(e);for(let[t,n]of jf)if(n.stalledMarkEmitted&&!n.settled)try{e(t,n.mountId)}catch{}return()=>{Mf.delete(e)}}function Pf(e,t){for(let n of Mf)try{n(e,t.mountId)}catch{}}var Ff=!1;function If(){typeof document>`u`||document.visibilityState===`visible`&&zf(Date.now())}function Lf(){Ff||typeof document>`u`||typeof document.addEventListener==`function`&&(document.addEventListener(`visibilitychange`,If),Ff=!0)}function Rf(){Ff&&(typeof document>`u`||typeof document.removeEventListener==`function`&&(document.removeEventListener(`visibilitychange`,If),Ff=!1))}function zf(e){let t=Of();for(let[n,r]of jf)r.settled||r.stalledMarkEmitted||e-r.createdAt<t||(Af(r,n,e),Pf(n,r))}function Bf(e){let{docName:t,mountId:n,construct:r,sizeStats:i}=e,a=jf.get(t);if(a)return a.promise;let o=new AbortController,s=Date.now(),{promise:c,resolve:l,reject:u}=Promise.withResolvers(),d={promise:c,rejectFn:u,controller:o,mountId:n,createdAt:s,settled:!1,resolved:!1,preMountEditor:null,stalledHandle:null,stalledMarkEmitted:!1};return d.stalledHandle=setTimeout(()=>{d.settled||(Af(d,t,Date.now()),Pf(t,d))},Of()),o.signal.addEventListener(`abort`,()=>{d.settled||(d.settled=!0,kf(d),d.preMountEditor&&=(Wf(t,d.preMountEditor,`aborted`),null),jf.delete(t),jf.size===0&&Rf(),X(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`aborted`}),u(new Df(t)),Ef(d.mountId))}),jf.set(t,d),Lf(),X(`ok/mount/create`,{docName:t,mountId:d.mountId}),Gf({docName:t,construct:r,sizeStats:i,entry:d,resolveFn:l,rejectFn:u}).catch(e=>{if(d.preMountEditor&&=(Wf(t,d.preMountEditor,`backstop`),null),d.settled){X(`ok/mount/post-settle-throw`,{docName:t,mountId:d.mountId,message:e instanceof Error?e.message:String(e)});return}d.settled=!0,kf(d);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`unhandled-body-throw`,message:n.message}),u(n),Ef(d.mountId)}),c}function Vf(e){return jf.get(e)?.resolved===!0}function Hf(e){return jf.get(e)?.controller??null}function Uf(e){let t=jf.get(e);t&&(t.settled=!0,kf(t),t.preMountEditor&&=(Wf(e,t.preMountEditor,`aborted`),null),jf.delete(e),jf.size===0&&Rf(),X(`ok/mount/invalidate`,{docName:e,mountId:t.mountId}),Ef(t.mountId),t.controller.abort())}function Wf(e,t,n){let r=Kf(t);try{t.destroy()}catch(t){X(`ok/mount/destroy-failed`,{docName:e,stage:n,message:t instanceof Error?t.message:String(t)})}r&&(r.restore=void 0)}async function Gf(e){let{docName:t,construct:n,sizeStats:r,entry:i,resolveFn:a,rejectFn:o}=e,s=document.createElement(`div`);if(Ap(t)!==void 0){let e=pp({docName:t,container:s,factory:()=>{throw Error(`mount-promise: V2 cache contract violation — factory invoked on HIT for "${t}"`)}});i.settled=!0,i.resolved=!0,kf(i),a(e);return}if(await scheduler.yield(),i.controller.signal.aborted)return;let c=null;try{c=n()}catch(e){i.settled=!0,kf(i);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`construct-failed`,message:n.message}),o(n),Ef(i.mountId);return}if(i.preMountEditor=c.editor,await scheduler.yield(),i.controller.signal.aborted){i.preMountEditor=null;return}try{c.editor.mount(s)}catch(e){Wf(t,c.editor,`mount-failed`),i.preMountEditor=null,i.settled=!0,kf(i);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`mount-failed`,message:n.message}),o(n),Ef(i.mountId);return}let l;try{l=pp({docName:t,container:s,sizeStats:r,factory:()=>c})}catch(e){Wf(t,c.editor,`v2-register-failed`),i.preMountEditor=null,i.settled=!0,kf(i);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`v2-register-failed`,message:n.message}),o(n),Ef(i.mountId);return}i.preMountEditor=null,i.settled=!0,i.resolved=!0,kf(i);let u=Date.now()-i.createdAt;X(`ok/mount/resolve`,{docName:t,mountId:i.mountId,elapsedMs:u}),X.histogram(`ok/mount/resolve-elapsed-ms`,{docName:t,mountId:i.mountId},u),a(l);let d=Date.now();Tf(i.mountId,`ok.mount-promise`,{"doc.name":t,elapsed_ms:u},i.createdAt,d),Ef(i.mountId,d)}function Kf(e){try{let t=e.state;return Dn.getState(t)?.undoManager??null}catch(e){return X(`ok/cache/undo-manager-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}var qf=ha(`MAX_CACHE`,10),Jf=ha(`VIEW_COUNT_CACHE_THRESHOLD`,50),Yf=ha(`BYTES_CACHE_THRESHOLD`,8e6);function Xf(e){return!(e.viewCount>0&&e.viewCount>=Jf||e.bytes>Yf)}var Zf=new Map,Qf=new Map,$f=new Map;function ep(e,t){if($f.size>=qf){let e=$f.keys().next().value;e!==void 0&&$f.delete(e)}$f.set(e,t),X(`ok/cache/snapshot-stored`,{toDocName:e,htmlBytes:t.html.length,hasScroll:t.scrollTop>0,hasSelection:t.selection!==null})}function tp(e){return $f.get(e)??null}function np(e){if(!$f.has(e))return;let t=$f.get(e)??null;$f.delete(e),X(`ok/cache/snapshot-consumed`,{docName:e,hit:t!==null,hasScroll:t!==null&&t.scrollTop>0,hasSelection:t!==null&&t.selection!==null})}function rp(){if(typeof document>`u`)return null;let e=document.querySelectorAll(ip);for(let t of e)if(t.getClientRects().length>0)return t;return null}var ip=`[data-testid="editor-scroll-container"]`;function ap(e){return e.closest(ip)}function op(){try{return rp()?.scrollTop??0}catch(e){return X(`ok/cache/snapshot-scroll-read-failed`,{message:e instanceof Error?e.message:String(e)}),0}}function sp(e){try{let t=e.state.selection;return t instanceof K?{type:`text`,anchor:t.anchor,head:t.head}:t instanceof xe?{type:`node`,from:t.from}:null}catch(e){return X(`ok/cache/snapshot-selection-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}function cp(e){for(let t of e)try{let e=Ap(t.fromDocName);if(e&&!e.editor.isDestroyed){if(e.ytext.length===0){X(`ok/cache/snapshot-skipped-empty`,{fromDocName:t.fromDocName});continue}if(!re(t.toDocName)){X(`ok/cache/snapshot-skipped-class-change`,{fromDocName:t.fromDocName,toDocName:t.toDocName});continue}ep(t.toDocName,{html:e.editor.getHTML(),scrollTop:op(),selection:sp(e.editor)})}else X(`ok/cache/snapshot-skipped`,{fromDocName:t.fromDocName})}catch(e){X(`ok/cache/snapshot-capture-failed`,{fromDocName:t.fromDocName,message:e instanceof Error?e.message:String(e)})}}var lp=[],up=[],dp=new Set;function fp(){if(typeof document>`u`)return null;let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-parking`,``),e.style.display=`none`,e.style.position=`absolute`,e.style.left=`-99999px`,e}function pp(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!Xf(i)){let e=r(n);return X(`ok/cache/miss`,{docName:t,mountId:hf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`}),{editor:e.editor,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=Zf.get(t);if(a){if(X(`ok/cache/reparent-start`,{docName:t,mountId:hf(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Sp(a,n),a.activeMountKey=t,wp(lp,t),vd(t)!==`landing`&&(n.scrollTop=a.scrollTop),a.hadFocus)try{a.editor.commands.focus()}catch{}return X(`ok/cache/reparent-end`,{docName:t,mountId:hf(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),X(`ok/cache/hit`,{docName:t,mountId:hf(t),kind:`tiptap`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:hf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;Zf.size>=qf;){let e=Tp(lp,t);if(!e)break;hp(e)}let o=r(n),s={editor:o.editor,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return Zf.set(t,s),wp(lp,t),X(`ok/cache/miss`,{docName:t,mountId:hf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:hf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function mp(e){let t=e.activeMountKey;if(e.__uncached){t&&Uf(t);let n=Kf(e.editor);try{e.editor.destroy()}catch(e){X(`ok/cache/park-destroy-failed`,{docName:t??``,kind:`tiptap`,stage:`editor`,message:e instanceof Error?e.message:String(e)})}n&&(n.restore=void 0),e.activeMountKey=null;return}let n=bp(e.editor);if(n){e.hadFocus=xp(n.dom),e.scrollTop=(n.scrollDOM??n.dom.parentElement??n.dom).scrollTop??0;let t=n.dom.parentElement;t&&t.removeChild(n.dom),e.parkingNode||=fp(),e.parkingNode&&e.parkingNode.appendChild(n.dom)}e.activeMountKey=null}function hp(e){Uf(e);let t=Zf.get(e);if(!t)return!1;let n=Kf(t.editor);try{t.editor.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`editor`,message:t instanceof Error?t.message:String(t)})}n&&(n.restore=void 0);try{t.provider.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}Zf.delete(e);let r=lp.indexOf(e);return r!==-1&&lp.splice(r,1),X(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function gp(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!Xf(i)){let e=r(n);return X(`ok/cache/miss`,{docName:t,mountId:hf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`,kind:`cm`}),{view:e.view,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,undoManager:e.undoManager,themeCompartment:e.themeCompartment,wordWrapCompartment:e.wordWrapCompartment,placeholderCompartment:e.placeholderCompartment,lintCompartment:e.lintCompartment,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=Qf.get(t);if(a){if(X(`ok/cache/reparent-start`,{docName:t,mountId:hf(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Cp(a,n),a.activeMountKey=t,wp(up,t),vd(t)!==`landing`&&(n.scrollTop=a.scrollTop),a.hadFocus)try{a.view.focus()}catch{}return X(`ok/cache/reparent-end`,{docName:t,mountId:hf(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),X(`ok/cache/hit`,{docName:t,mountId:hf(t),kind:`cm`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:hf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;Qf.size>=qf;){let e=Tp(up,t);if(!e)break;yp(e)}let o=r(n),s={view:o.view,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,undoManager:o.undoManager,themeCompartment:o.themeCompartment,wordWrapCompartment:o.wordWrapCompartment,placeholderCompartment:o.placeholderCompartment,lintCompartment:o.lintCompartment,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return Qf.set(t,s),wp(up,t),X(`ok/cache/miss`,{docName:t,mountId:hf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:hf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function _p(e){if(e.__uncached){try{e.view.destroy()}catch(t){X(`ok/cache/park-destroy-failed`,{docName:e.activeMountKey??``,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}vp(e,e.activeMountKey??``,`park-destroy-failed`),e.activeMountKey=null;return}let t=e.view.dom;e.hadFocus=xp(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t),e.parkingNode||=fp(),e.parkingNode&&e.parkingNode.appendChild(t),e.activeMountKey=null}function vp(e,t,n){let r=e.undoManager;if(r){e.undoManager=void 0;try{r.clear(),r.destroy()}catch(e){X(`ok/cache/${n}`,{docName:t,kind:`cm`,stage:`undo-manager`,message:e instanceof Error?e.message:String(e)})}}}function yp(e){let t=Qf.get(e);if(!t)return!1;Bn(e,t.view);try{t.view.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}vp(t,e,`evict-failed`);try{t.provider.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}Qf.delete(e);let n=up.indexOf(e);return n!==-1&&up.splice(n,1),X(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function bp(e){return e.editorView??null}function xp(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function Sp(e,t){let n=bp(e.editor);if(!n)return;let r=n.dom,i=r.parentElement;i&&i!==t&&i.removeChild(r),r.parentElement!==t&&t.appendChild(r)}function Cp(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function wp(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function Tp(e,t){for(let n of e)if(n!==t&&!dp.has(n))return n;X(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:dp.size});for(let n of e)if(n!==t)return n;return null}function Ep(e){let t=dp,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=Op(e);if(t)try{t.disconnect(),X(`ok/cache/disconnect`,{docName:e})}catch(t){X(`ok/cache/disconnect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}}for(let e of n){if(t.has(e))continue;let n=Op(e);if(!n)continue;let r=t=>{X(`ok/cache/connect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})};try{let t=n.connect();t&&typeof t.then==`function`?t.then(()=>X(`ok/cache/connect`,{docName:e}),e=>r(e)):X(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}dp=n}var Dp=null;function Op(e){let t=Zf.get(e);if(t)return t.provider;let n=Qf.get(e);if(n)return n.provider;if(Dp){let t=Dp.entries.get(e);if(t)return t.provider}return null}function kp(e){Dp=e;let t=e.onEvict(e=>{hp(e),yp(e)});return()=>{t(),Dp===e&&(Dp=null)}}function Ap(e){return Zf.get(e)}var jp=`pane-main`;function Mp(e){return Fp(e)&&!e.includes(`\0doc-tab:`)}function Np(e){return e.startsWith(`\0`)}function Pp(e){return typeof e==`string`&&!!e}function Fp(e){return typeof e==`string`&&!!e}function Ip(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function Lp(e,t=new Set){if(!Array.isArray(e))return[];let n=new Set,r=[];for(let i of e)!Mp(i)||n.has(i)||!Np(i)&&t.has(i)||(n.add(i),Np(i)||t.add(i),r.push(i));return r}function Rp(e,t){if(!Array.isArray(e))return[];let n=new Set(t),r=new Set,i=[];for(let t of e)!Fp(t)||!n.has(t)||r.has(t)||(r.add(t),i.push(t));return i}function zp(e,t){return Fp(t)&&e.includes(t)?t:null}function Bp(e,t,n){if(!t||!n.has(t))return t;let r=e.indexOf(t);for(let t=r+1;t<e.length;t++)if(!n.has(e[t]))return e[t]??null;for(let t=r-1;t>=0;t--)if(!n.has(e[t]))return e[t]??null;return null}function Vp(e,t=new Set){if(!Pp(e.id))return null;let n=Lp(e.openTabs,t),r=Array.isArray(e.newTabIds)?e.newTabIds.filter(e=>Fp(e)&&!n.includes(e)):[],i=zp(n,e.activeTabId),a=Fp(e.activeNewTabId)&&r.includes(e.activeNewTabId)?e.activeNewTabId:null,o=i??(a===null?n[0]??null:null),s=o===null?a??r[0]??null:null,c=Rp(e.pinnedTabIds,n),l=Mp(e.previewTabId)&&n.includes(e.previewTabId)&&!c.includes(e.previewTabId)?e.previewTabId:null;return{id:e.id,openTabs:n,pinnedTabIds:c,activeTabId:o,previewTabId:l,newTabIds:r,activeNewTabId:s,activeTarget:o!==null&&o===i?e.activeTarget??null:null,size:Ip(e.size)?e.size:1}}function Hp(e){if(e.length===0)return[];let t=e.reduce((e,t)=>e+(Ip(t.size)?t.size:0),0);if(t<=0){let t=100/e.length;return e.map(e=>({...e,size:t}))}return e.map(e=>({...e,size:(Ip(e.size)?e.size:0)/t*100}))}function Up(e,t=100){return{id:e,openTabs:[],pinnedTabIds:[],activeTabId:null,previewTabId:null,newTabIds:[],activeNewTabId:null,activeTarget:null,size:t}}function Wp(e=()=>jp){let t=Up(e());return{panes:[t],focusedPaneId:t.id}}function Gp(e){let t=e.panes.map(e=>({...e,previewTabId:null,newTabIds:[],activeNewTabId:null,activeTarget:null}));return{panes:t,focusedPaneId:t.some(t=>t.id===e.focusedPaneId)?e.focusedPaneId:t[0]?.id??jp}}function Kp(e){let t=Jp(e);return{panes:t.panes.map(({id:e,openTabs:t,pinnedTabIds:n,activeTabId:r,size:i})=>({id:e,openTabs:t,pinnedTabIds:n,activeTabId:r,size:i})),focusedPaneId:t.focusedPaneId}}function qp(e,t=()=>jp){let n=()=>{let e=t();return{panes:[{id:e,openTabs:[],pinnedTabIds:[],activeTabId:null,size:100}],focusedPaneId:e}};if(typeof e!=`object`||!e)return n();let r=e;if(!Array.isArray(r.panes))return n();let i=new Set,a=[];for(let[e,t]of r.panes.entries()){if(typeof t!=`object`||!t)continue;let n=t;!Pp(n.id)||i.has(n.id)||(i.add(n.id),a.push({pane:n,id:n.id,visualIndex:e}))}if(a.length===0)return n();let o=Pp(r.focusedPaneId)?r.focusedPaneId:null,s=[...a].sort((e,t)=>e.id===o?-1:t.id===o?1:e.visualIndex-t.visualIndex),c=new Set,l=new Map;for(let{pane:e,id:t}of s){let n=Lp(e.openTabs,c),r=zp(n,e.activeTabId);l.set(t,{id:t,openTabs:n,pinnedTabIds:Rp(e.pinnedTabIds,n),activeTabId:r??n[0]??null,size:Ip(e.size)?e.size:1})}let u=a.flatMap(({id:e})=>{let t=l.get(e);return t&&t.openTabs.length>0?[t]:[]});if(u.length===0)return n();let d=Hp(u);return{panes:d,focusedPaneId:o&&d.some(e=>e.id===o)?o:d[0].id}}function Jp(e){let t=new Set,n=new Set,r=e.panes.flatMap(e=>{if(!Pp(e.id)||t.has(e.id))return[];let r=Vp(e,n);return r?(t.add(r.id),[r]):[]});if(r.length===0)return Wp();let i=Hp(r);return{panes:i,focusedPaneId:i.some(t=>t.id===e.focusedPaneId)?e.focusedPaneId:i[0].id}}function Yp(e){return e.panes.find(t=>t.id===e.focusedPaneId)??e.panes[0]??Up(jp)}function Xp(e,t){return e.panes.some(e=>e.id===t)?{...e,focusedPaneId:t}:e}function Zp(e,t){let n=e.panes.find(t=>t.id===e.focusedPaneId);return n?.openTabs.includes(t)||n?.newTabIds.includes(t)?n:e.panes.find(e=>e.openTabs.includes(t)||e.newTabIds.includes(t))??null}function Qp(e,t){return Mp(t)?Zp(e,t):null}function $p(e){return e.panes.flatMap(e=>e.openTabs)}function em(e){let t=new Set($p(e));return e.panes.flatMap(e=>e.pinnedTabIds.filter(e=>t.has(e)))}function tm(e,t,n){return{...e,panes:e.panes.map(e=>e.id===t?n(e):e)}}function nm(e,t,n){let r=new Map(n.panes.map(e=>[e.id,new Set(e.openTabs)])),i=e;for(let e of t.panes){let t=e.previewTabId;if(!t)continue;let n=i.panes.find(n=>n.id===e.id&&n.openTabs.includes(t))??Qp(i,t);!n||n.pinnedTabIds.includes(t)||r.get(n.id)?.has(t)||(i=tm(i,n.id,e=>({...e,previewTabId:t})))}return i}function rm(e,t,n,r){let i=e.panes.find(e=>e.id===t);if(!i)return e;let a=new Set(i.openTabs),o=n.filter(e=>a.has(e));for(let e of i.openTabs)o.includes(e)||o.push(e);let s=new Set(i.pinnedTabIds),c=o.indexOf(r),l=c>=0&&c<i.pinnedTabIds.length,u=i.openTabs.includes(r)?o.filter(e=>e===r?l:s.has(e)):i.pinnedTabIds;return tm(e,t,e=>({...e,openTabs:o,pinnedTabIds:u,previewTabId:e.previewTabId===r?null:e.previewTabId}))}function im(e,t){let n=e.newTabIds.indexOf(t);if(n>=0){let r=e.newTabIds.filter(e=>e!==t),i=e.activeNewTabId===t,a=i?r[n]??r[n-1]??null:e.activeNewTabId,o=i&&a===null?e.openTabs[e.openTabs.length-1]??null:e.activeTabId;return{...e,newTabIds:r,activeNewTabId:a,activeTabId:o,activeTarget:a===null&&o===e.activeTabId?e.activeTarget:null}}if(e.openTabs.indexOf(t)<0)return e;let r=new Set([t]),i=Bp(e.openTabs,e.activeTabId,r),a=e.activeTabId===t&&i===null?e.activeNewTabId??e.newTabIds[e.newTabIds.length-1]??null:e.activeNewTabId;return{...e,openTabs:e.openTabs.filter(e=>e!==t),pinnedTabIds:e.pinnedTabIds.filter(e=>e!==t),activeTabId:i,activeNewTabId:a,previewTabId:e.previewTabId===t?null:e.previewTabId,activeTarget:a===null&&i===e.activeTabId?e.activeTarget:null}}function am(e){let t=e.panes.filter(e=>e.openTabs.length||e.newTabIds.length);if(t.length===0)return Wp(()=>e.focusedPaneId||jp);let n=Hp(t);return{panes:n,focusedPaneId:n.some(t=>t.id===e.focusedPaneId)?e.focusedPaneId:n[0].id}}function om(e,t){let n=e.panes.flatMap(e=>{let n=new Set([...e.openTabs,...e.newTabIds]),r=(t.get(e.id)??[]).filter((e,t,r)=>n.has(e)&&r.indexOf(e)===t);if(r.length===0)return[];let i=new Set(r),a=e.openTabs.filter(e=>i.has(e)),o=e.newTabIds.filter(e=>i.has(e)),s=(e.activeTabId&&i.has(e.activeTabId)?e.activeTabId:null)??(e.activeNewTabId&&i.has(e.activeNewTabId)?e.activeNewTabId:null)??r[0],c=a.includes(s)?s:null,l=o.includes(s)?s:null;return[{...e,openTabs:a,pinnedTabIds:e.pinnedTabIds.filter(e=>i.has(e)),activeTabId:c,previewTabId:e.previewTabId&&i.has(e.previewTabId)?e.previewTabId:null,newTabIds:o,activeNewTabId:l,activeTarget:c===e.activeTabId?e.activeTarget:null}]});if(n.length===0)return Wp(()=>e.focusedPaneId||jp);let r=Hp(n);return{panes:r,focusedPaneId:r.some(t=>t.id===e.focusedPaneId)?e.focusedPaneId:r[0].id}}function sm(e,t,n){let r=new Set(t),i=Math.max(0,Math.min(n,e.length)),a=0;for(let t=0;t<i;t+=1){let n=e[t];n&&r.has(n)&&(a+=1)}return a}function cm(e,t,n,r){let i=Zp(e,t),a=e.panes.find(e=>e.id===n);if(!i||!a)return e;let o=i.newTabIds.includes(t);if(i.id===a.id){if(o){let a=i.newTabIds.filter(e=>e!==t),o=Math.max(0,Math.min(r,a.length));return tm(e,n,e=>({...e,newTabIds:[...a.slice(0,o),t,...a.slice(o)],activeNewTabId:t,activeTabId:null,activeTarget:null}))}let a=i.openTabs.filter(e=>e!==t),s=Math.max(0,Math.min(r,a.length));return rm(e,n,[...a.slice(0,s),t,...a.slice(s)],t)}let s=i.pinnedTabIds.includes(t),c=im(i,t),l=Math.max(0,Math.min(r,o?a.newTabIds.length:a.openTabs.length)),u=o?{...a,newTabIds:[...a.newTabIds.slice(0,l),t,...a.newTabIds.slice(l)],activeNewTabId:t,activeTabId:null,activeTarget:null}:{...a,openTabs:[...a.openTabs.slice(0,l),t,...a.openTabs.slice(l)],pinnedTabIds:s?[...a.pinnedTabIds,t]:a.pinnedTabIds,activeNewTabId:null,activeTabId:t,activeTarget:null},d=e.panes.map(e=>e.id===i.id?c:e.id===a.id?u:e);return Xp(am({...e,panes:d}),a.id)}function lm(e,t,n,r,i){let a=Zp(e,t),o=e.panes.find(e=>e.id===n);if(!a||!o)return e;if(a.id===o.id&&a.openTabs.length+a.newTabIds.length===1)return Xp(e,a.id);let s=i();if(!Pp(s)||e.panes.some(e=>e.id===s))return e;let c=a.pinnedTabIds.includes(t),l=im(a,t),u=a.id===o.id?l:o,d=u.size/2,f={...u,size:d},p=a.newTabIds.includes(t),m={...Up(s,d),openTabs:p?[]:[t],pinnedTabIds:c&&!p?[t]:[],activeTabId:p?null:t,previewTabId:null,newTabIds:p?[t]:[],activeNewTabId:p?t:null},h=e.panes.map(e=>e.id===a.id?l:e),g=h.findIndex(e=>e.id===o.id);if(g<0)return e;h[g]=f;let _=r===`left`?g:g+1,v=[...h.slice(0,_),m,...h.slice(_)];return Xp(am({...e,panes:v}),s)}function um(e,t,n){let r=new Set(n),i=e.panes.find(e=>e.id===t);if(!i||r.size===0)return e;let a=Bp(i.openTabs,i.activeTabId,r);return am(tm(e,t,e=>{let t={...e,openTabs:e.openTabs.filter(e=>!r.has(e)),pinnedTabIds:e.pinnedTabIds.filter(e=>!r.has(e)),activeTabId:a,previewTabId:e.previewTabId&&r.has(e.previewTabId)?null:e.previewTabId,activeTarget:a===e.activeTabId?e.activeTarget:null};return e.newTabIds.reduce((e,t)=>r.has(t)?im(e,t):e,t)}))}function dm(e,t){let n=new Map,r=new Set;for(let i of e.panes)for(let e of i.openTabs){let a=t(e),o=Mp(a)?a:null;n.set(e,o),o&&!Np(o)&&i.pinnedTabIds.includes(e)&&r.add(o)}let i=new Set,a=e.panes.map(e=>{let t=new Map,a=new Set,o=[];for(let r of e.openTabs){let e=n.get(r);!e||a.has(e)||!Np(e)&&i.has(e)||(a.add(e),Np(e)||i.add(e),t.set(r,e),o.push(e))}let s=new Set(e.pinnedTabIds.flatMap(e=>t.get(e)??[])),c=o.filter(e=>Np(e)?s.has(e):r.has(e)),l=e.activeTabId?t.get(e.activeTabId)??null:null,u=e.previewTabId&&t.get(e.previewTabId)===e.previewTabId?e.previewTabId:null;return{...e,openTabs:o,pinnedTabIds:c,activeTabId:l,previewTabId:u&&!c.includes(u)?u:null,activeTarget:l!==null&&l===e.activeTabId?e.activeTarget:null}});return am({...e,panes:a})}function fm(e,t){return dm(e,e=>t(e)?e:null)}function pm(e){return{workspace:e,openedTabId:null,replacedPreviewTabId:null,consumedNewTabId:null}}function mm(e,t={openedTabId:null,replacedPreviewTabId:null,consumedNewTabId:null}){return{workspace:Jp(e),...t}}function hm(e,t,n){let r=e.panes.find(e=>e.id===t);return r?r.newTabIds.includes(n)?Xp(tm(e,t,e=>({...e,activeTabId:null,activeNewTabId:n,activeTarget:null})),t):r.openTabs.includes(n)?Xp(tm(e,t,e=>({...e,activeTabId:n,activeNewTabId:null,activeTarget:e.activeTabId===n?e.activeTarget:null})),t):e:e}function gm(e,t){switch(t.type){case`open-target`:{if(!Mp(t.tabId))return pm(e);let n=e.panes.find(e=>e.id===t.paneId);if(!n)return pm(e);let r=t.consumeActiveNewTab&&n.activeNewTabId?n.activeNewTabId:null,i=r===null?e:tm(e,n.id,e=>im(e,r)),a=i.panes.find(e=>e.id===t.paneId&&e.openTabs.includes(t.tabId))??Zp(i,t.tabId),o=a!==null&&a.id!==t.paneId&&t.existingTabBehavior===`open-in-pane`&&Np(t.tabId);if(a&&!o)return a.id!==t.paneId&&t.existingTabBehavior===`open-in-pane`?(i=cm(i,t.tabId,t.paneId,n.openTabs.length),i=tm(i,t.paneId,e=>({...e,activeTarget:t.target,previewTabId:t.disposition===`permanent`&&e.previewTabId===t.tabId?null:e.previewTabId})),mm(i,{openedTabId:t.tabId,replacedPreviewTabId:null,consumedNewTabId:r})):(i=tm(i,a.id,e=>({...e,activeTabId:t.tabId,activeNewTabId:null,activeTarget:t.target,previewTabId:t.disposition===`permanent`&&e.previewTabId===t.tabId?null:e.previewTabId})),i=Xp(i,a.id),i=am(i),mm(i,{openedTabId:t.tabId,replacedPreviewTabId:null,consumedNewTabId:r}));let s=i.panes.find(e=>e.id===t.paneId);if(!s)return pm(e);let c=t.disposition===`preview`?s.previewTabId:null;return i=tm(i,t.paneId,e=>{let n=c?e.openTabs.indexOf(c):-1,r=c?e.openTabs.filter(e=>e!==c):e.openTabs,i=n<0?[...r,t.tabId]:[...r.slice(0,n),t.tabId,...r.slice(n)];return{...e,openTabs:i,pinnedTabIds:e.pinnedTabIds.filter(e=>e!==c),activeTabId:t.tabId,activeNewTabId:null,activeTarget:t.target,previewTabId:t.disposition===`preview`?t.tabId:e.previewTabId}}),i=Xp(i,t.paneId),mm(i,{openedTabId:t.tabId,replacedPreviewTabId:c,consumedNewTabId:r})}case`activate-tab`:return mm(hm(e,t.paneId,t.tabId));case`promote-preview`:return mm(tm(e,t.paneId,e=>({...e,previewTabId:e.previewTabId===t.tabId?null:e.previewTabId})));case`promote-all-previews`:return mm({...e,panes:e.panes.map(e=>({...e,previewTabId:null}))});case`open-new-tab`:{if(!Fp(t.tabId))return pm(e);let n=Zp(e,t.tabId);return n?mm(hm(e,n.id,t.tabId)):e.panes.some(e=>e.id===t.paneId)?mm(Xp(tm(e,t.paneId,e=>({...e,newTabIds:[...e.newTabIds,t.tabId],activeTabId:null,activeNewTabId:t.tabId,activeTarget:null})),t.paneId)):pm(e)}case`close-tabs`:return mm(um(e,t.paneId,t.tabIds));case`pin-tab`:return mm(tm(e,t.paneId,e=>e.openTabs.includes(t.tabId)?{...e,pinnedTabIds:e.pinnedTabIds.includes(t.tabId)?e.pinnedTabIds:[...e.pinnedTabIds,t.tabId],previewTabId:e.previewTabId===t.tabId?null:e.previewTabId}:e));case`unpin-tab`:return mm(tm(e,t.paneId,e=>({...e,pinnedTabIds:e.pinnedTabIds.filter(e=>e!==t.tabId)})));case`reorder-tabs`:return mm(rm(e,t.paneId,t.tabIds,t.draggedTabId));case`move-tab`:return mm(cm(e,t.tabId,t.paneId,t.index));case`split-tab`:return mm(lm(e,t.tabId,t.paneId,t.side,()=>t.newPaneId));case`resize-panes`:return t.sizes.length!==e.panes.length||t.sizes.some(e=>!Ip(e))?pm(e):mm({...e,panes:e.panes.map((e,n)=>({...e,size:t.sizes[n]??e.size}))});case`remap-tabs`:return mm(dm(e,t.remap));case`prune-tabs`:return mm(fm(e,t.keep));default:return pm(e)}}function _m(e,t,n=25){return!Pp(t.paneId)||!Fp(t.tabId)||n<=0?[...e]:[t,...e.filter(e=>e.tabId!==t.tabId)].slice(0,n)}function vm(e){return ze.includes(e)}function ym(){return ch(qp(null),null)}var bm=new Set,xm=`ok-editor-tabs-v1:`,Sm=`\0folder:`,Cm=`\0asset:`,wm=`\0skill-file:`,Tm=`\0skill-preview:`,Em=/\.(md|mdx)$/i;function Dm(e){return Em.test(e)?e.replace(Em,``):null}function Om(e,t){let n=Dm(e);return n===null?!1:t.some(t=>t!==e&&Dm(t)===n)}function km(e,t=[]){let n=Km(e);if(n.kind===`asset`&&ie(n.assetPath))return Vm(n.assetPath);if(n.kind!==`doc`||Om(e,t))return e;let r=e,i=Dm(r);for(;i!==null&&i.length>0;)r=i,i=Dm(r);return r}function Am(e,t){return Array.isArray(e)?e.map(e=>typeof e==`string`?km(e,t):e):e}function jm(e){return e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e.openTabs;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]})}function Mm(e){let t={...e},n=Array.isArray(e.panes)?jm(e.panes):[];return Array.isArray(e.panes)&&(t.panes=e.panes.map(e=>{if(typeof e!=`object`||!e)return e;let t=e;return{...t,openTabs:Am(t.openTabs,n),pinnedTabIds:Am(t.pinnedTabIds,n),activeTabId:typeof t.activeTabId==`string`?km(t.activeTabId,n):t.activeTabId}})),t}function Nm(e){if(typeof e!=`string`||e.length===0||e.includes(`\0doc-tab:`))return!1;let t=e;return t.startsWith(Sm)?t.length>8:t.startsWith(Cm)?t.length>7:t.startsWith(wm)?Im(t)!==null:t.startsWith(Tm)?Bm(t)!==null:!0}var Pm=`:`;function Fm(e){let t=e.host===void 0?e.name:`${e.name}${Pm}${e.host}`;return`${wm}${e.scope}/${t}/${e.path}`}function Im(e){if(!e.startsWith(wm))return null;let t=e.slice(12).split(`/`);if(t.length<3)return null;let[n,r,...i]=t,a=i.join(`/`);if(!n||!r||!a||!vm(n))return null;let o=r.indexOf(Pm),s=o===-1?r:r.slice(0,o),c=o===-1?void 0:r.slice(o+1);return s?{scope:n,name:s,path:a,...c?{host:c}:{}}:null}function Lm(e){return`${Tm}${fa(e)}`}function Rm(e,t,n){return t.flavor===`explore`?[]:e.filter(e=>{if(e===n)return!1;let r=Km(e);return r.kind===`skill-preview`&&r.flavor===t.flavor&&r.name===t.name&&r.subtitle===t.subtitle&&r.level===t.level})}function zm(e,t,n,r,i){for(let a of e){let e=Km(a);if(e.kind===`skill-preview`&&e.flavor===t&&e.name===n&&e.subtitle===r&&e.level===i)return a}return null}function Bm(e){return e.startsWith(Tm)?sa(e.slice(15)):null}function Vm(e){return e}function Hm(e){return`${Sm}${e}`}function Um(e){return`${Cm}${e}`}function Wm(e,t){let n=no(e);if(n){let e=Xa(n);return{baseName:e,extension:``,label:e,prefix:``}}let r=Ie(e);if(r){let e=r.rel?r.rel.split(`/`).pop()??r.rel:Xa(r.name);return{baseName:e,extension:``,label:e,prefix:``}}let i=Pe(e);if(i)return{baseName:i.name,extension:``,label:i.name,prefix:``};let a=e.lastIndexOf(`/`),o=a<0?e:e.slice(a+1),s=Em.test(t)&&Em.test(o)?``:t,c=`${o}${s}`;return a<0?{baseName:o,extension:s,label:c,prefix:``}:{baseName:o,extension:s,label:c,prefix:`${e.slice(0,a)}/`}}function Gm(e){switch(e.kind){case`doc`:case`folder-index`:case`large-file`:return Vm(e.docName);case`folder`:return Hm(e.folderPath);case`missing`:return Vm(e.target);case`asset`:return Um(e.assetPath);case`skill-file`:return Fm(e);case`skills`:return null;case`skill-preview`:return Lm(e)}}function Km(e){let t=e;if(t.startsWith(Sm))return{kind:`folder`,folderPath:t.slice(8)};if(t.startsWith(Cm))return{kind:`asset`,assetPath:t.slice(7)};let n=Bm(t);if(n)return{kind:`skill-preview`,...n};let r=Im(t);return r?{kind:`skill-file`,...r}:{kind:`doc`,docName:t}}function qm(e){let t=Km(e);return t.kind===`doc`?t.docName:null}function Jm(e,t){return e===`suppressed`?!1:e===`applied`||t>0}function Ym(e){return Le(e)!=null||Re(e)?.kind===`skill`||Ie(e)!=null}var Xm=/(?:^|\/)\.[A-Za-z0-9_-]+\/skills\/[^/]+\/.+$/;function Zm(e){if(Xm.test(e))return!0;let t=vo();if(t.size===0)return!1;for(let n=e.lastIndexOf(`/`);n>0;n=e.lastIndexOf(`/`,n-1))if(t.has(e.slice(0,n)))return!0;return!1}function Qm(e,t){if(!Array.isArray(e)||t<=0)return[];let n=[],r=new Set;for(let i of e)if(Nm(i)&&!r.has(i)&&(r.add(i),n.push(i),n.length>=t))break;return n}function $m(e,t,n){if(t<=0)return[];let r=new Set(Qm(n,2**53-1)),i=Qm(e,2**53-1);if(r.size===0&&i.length<=t)return i;let a=[],o=0;for(let e=i.length-1;e>=0;e--){let n=i[e];if(r.has(n)){a.push(n);continue}o>=t||(o++,a.push(n))}return a.reverse()}function eh(e,t){let n=new Set(Qm(t,2**53-1));return Qm(e,2**53-1).filter(e=>!n.has(e))}function th(e,t,n){let r=Qm(t,2**53-1),i=new Set(r),a=new Set(n),o=new Set,s=[];for(let t of e)o.has(t)||!i.has(t)&&!a.has(t)||(o.add(t),s.push(t));for(let e of[...r,...n])o.has(e)||(o.add(e),s.push(e));return s}function nh(e,{pages:t,folderPaths:n,assetPaths:r,filePaths:i,keepMissingDocName:a=null,keepHashDocName:o=null,keepFolderPaths:s=bm}){return Qm(e,2**53-1).filter(e=>{let c=Km(e);if(c.kind===`folder`)return oo(n,c.folderPath)!==void 0||s.has(c.folderPath);if(c.kind===`asset`)return oo(r,c.assetPath)!==void 0||i!==void 0&&oo(i,c.assetPath)!==void 0;if(c.kind===`skill-file`||c.kind===`skill-preview`||c.kind===`doc`&&Le(c.docName)?.kind===`skill`)return!0;let l=Dm(c.docName);return t.has(c.docName)||l!==null&&t.has(l)||Fe(c.docName)||Pe(c.docName)!==null||c.docName===a||c.docName===o})}function rh(e,t,n,r=[],i=[],a=[]){if(t.length===0&&r.length===0&&a.length===0)return Qm(e,n);let o=new Map(t.map(e=>[e.fromDocName,e.toDocName])),s=new Map(a.flatMap(e=>{let t=Dm(e.fromPath);return t?[[t,e.toPath]]:[]})),c=new Map(a.flatMap(e=>{let t=Dm(e.toPath);return t?[[e.fromPath,t]]:[]})),l=e=>oh(ah(e,r),a),u=(e,t)=>{let n=o.get(e);if(n)return n;let r=s.get(e);return r?Um(r):t},d=e=>{let t=c.get(e);return t?Vm(t):Um(l(e))},f=[],p=new Set;for(let t of e){if(!Nm(t))continue;let e=Km(t),a=e.kind===`doc`?u(e.docName,t):e.kind===`folder`?Hm(ah(e.folderPath,r)):e.kind===`asset`?d(e.assetPath):t;if(!p.has(a)&&(p.add(a),f.push(a),i.length===0&&f.length>=n))break}return i.length===0?f:$m(f,n,i.flatMap(e=>{if(!Nm(e))return[];let t=Km(e);return[t.kind===`doc`?u(t.docName,e):t.kind===`folder`?Hm(ah(t.folderPath,r)):t.kind===`asset`?d(t.assetPath):e]}))}function ih(e,t,n=[],r=[]){return rh(e,t,2**53-1,n,[],r)}function ah(e,t){for(let{fromPath:n,toPath:r}of t){if(e===n)return r;if(e.startsWith(`${n}/`))return`${r}${e.slice(n.length)}`}return e}function oh(e,t){for(let{fromPath:n,toPath:r}of t)if(e===n)return r;return e}function sh(e){if(typeof e!=`object`||!e)return ym();let t=Mm(e);return Array.isArray(t.panes)?ch(qp(t),typeof t.updatedAt==`string`?t.updatedAt:null):ym()}function ch(e,t){return{updatedAt:t,panes:e.panes,focusedPaneId:e.focusedPaneId}}function lh(e,t=()=>new Date){return ch(Kp(e),t().toISOString())}function uh(e){return`${xm}${e}`}function dh(e,t){return e===`editor`||e===`note`?null:uh(t)}function fh(e,t){if(!e)return ym();try{let n=e.getItem(t);return n?sh(JSON.parse(n)):ym()}catch(e){return console.warn(`[editor-tabs] failed to read local tab session:`,e),ym()}}function ph(e,t,n){if(e)try{e.setItem(t,JSON.stringify(sh(n)))}catch(e){console.warn(`[editor-tabs] failed to write local tab session:`,e)}}var mh=null;function hh(e){return mh=e,()=>{mh===e&&(mh=null)}}function gh(e){e&&mh?.(e)}function _h(e){e&&gh(Vm(e))}function vh(e,t){let n=e=>(e.ok&&_h(t),e);return{...e,current:()=>e.current(),subscribe:t=>e.subscribe(t),dispose:()=>e.dispose(),patch:t=>n(e.patch(t)),rename:(t,r,i)=>n(e.rename(t,r,i)),reorder:t=>n(e.reorder(t)),patchPath:(t,r)=>n(e.patchPath(t,r)),deletePath:t=>n(e.deletePath(t)),renamePath:(t,r,i)=>n(e.renamePath(t,r,i)),reorderPath:(t,r)=>n(e.reorderPath(t,r)),reorderSeqPath:(t,r)=>n(e.reorderSeqPath(t,r))}}function yh(e){return e.docChanged?vn(e):!1}function bh(e){return e.docChanged?e.transactions.some(e=>e.annotation(bo.userEvent)!==void 0):!1}var xh=`epoch`,Sh=e=>Ea((t,n)=>{e.onerror=e=>n(Error(e.target.error)),e.onsuccess=e=>t(e.target.result)}),Ch=(e,t)=>Ea((n,r)=>{let i=indexedDB.open(e);i.onupgradeneeded=e=>t(e.target.result),i.onerror=e=>r(Oa(e.target.error)),i.onsuccess=e=>{let t=e.target.result;t.onversionchange=()=>{t.close()},n(t)}}),wh=e=>Sh(indexedDB.deleteDatabase(e)),Th=(e,t)=>t.forEach(t=>e.createObjectStore.apply(e,t)),Eh=(e,t,n=`readwrite`)=>{let r=e.transaction(t,n);return t.map(e=>Lh(r,e))},Dh=(e,t)=>Sh(e.count(t)),Oh=(e,t)=>Sh(e.get(t)),kh=(e,t)=>Sh(e.delete(t)),Ah=(e,t,n)=>Sh(e.put(t,n)),jh=(e,t)=>Sh(e.add(t)),Mh=(e,t,n)=>Sh(e.getAll(t,n)),Nh=(e,t,n)=>{let r=null;return Ih(e,t,e=>(r=e,!1),n).then(()=>r)},Ph=(e,t=null)=>Nh(e,t,`prev`),Fh=(e,t)=>Ea((n,r)=>{e.onerror=r,e.onsuccess=async e=>{let r=e.target.result;if(r===null||await t(r)===!1)return n();r.continue()}}),Ih=(e,t,n,r=`next`)=>Fh(e.openKeyCursor(t,r),e=>n(e.key)),Lh=(e,t)=>e.objectStore(t),Rh=(e,t)=>IDBKeyRange.upperBound(e,t),zh=(e,t)=>IDBKeyRange.lowerBound(e,t),Bh=`custom`,Vh=`updates`,Hh=(e,t=()=>{},n=()=>{})=>{let[r]=Eh(e.db,[Vh]);return Mh(r,zh(e._dbref,!1)).then(i=>{e._destroyed||(t(r),Ca(e.doc,()=>{i.forEach(t=>Pa(e.doc,t))},e,!1),n(r))}).then(()=>Ph(r).then(t=>{e._dbref=t+1})).then(()=>Dh(r).then(t=>{e._dbsize=t})).then(()=>r)},Uh=(e,t=!0)=>Hh(e).then(n=>{(t||e._dbsize>=500)&&jh(n,wa(e.doc)).then(()=>kh(n,Rh(e._dbref,!0))).then(()=>Dh(n).then(t=>{e._dbsize=t}))}),Wh=class extends Da{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=Ch(e,e=>Th(e,[[`updates`,{autoIncrement:!0}],[`custom`]])),this.whenSynced=Ea(e=>this.on(`synced`,()=>e(this))),this._db.then(e=>{this.db=e,Hh(this,async e=>{await Dh(e)>0&&jh(e,wa(t))},()=>{if(this._destroyed)return this;this.synced=!0,this.emit(`synced`,[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(e,t)=>{if(this.db&&t!==this){let[t]=Eh(this.db,[Vh]);jh(t,e).catch(e=>{globalThis.__okYdbWriteWarned||(globalThis.__okYdbWriteWarned=!0,console.warn(JSON.stringify({event:`ok-ydb-write-failed`,cause:e?.name??`unknown`,message:e?.message??String(e)})))}),++this._dbsize>=500&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{Uh(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on(`update`,this._storeUpdate),this.destroy=this.destroy.bind(this),t.on(`destroy`,this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off(`update`,this._storeUpdate),this.doc.off(`destroy`,this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{wh(this.name)})}get(e){return this._db.then(t=>{let[n]=Eh(t,[Bh],`readonly`);return Oh(n,e)})}set(e,t){return this._db.then(n=>{let[r]=Eh(n,[Bh]);return Ah(r,t,e)})}del(e){return this._db.then(t=>{let[n]=Eh(t,[Bh]);return kh(n,e)})}},Gh=`updates`,Kh=`custom`;function qh(){return!0}var Jh=class{_idb;_dbName;whenSynced;constructor({branch:e,serverInstanceId:t,docName:n,doc:r}){if(typeof t!=`string`||t.length===0)throw Error(`createClientPersistence: serverInstanceId is required and must be non-empty`);this._dbName=`ok-ydoc:${e}:${t}:${n}`;let i=qh()?0:performance.now();this._idb=new Wh(this._dbName,r),this.whenSynced=this._idb.whenSynced.then(()=>{if(!qh()){let e=performance.now();X(`ok/pool/idb-whensynced`,{docName:n,durationMs:Math.round((e-i)*1e3)/1e3},{startTime:i,duration:e-i})}return this})}get synced(){return this._idb.synced}async destroy(){let e=qh()?0:performance.now();try{await this._idb.destroy()}finally{if(!qh()){let t=performance.now();X(`ok/pool/idb-destroy`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}async flushFullState(){this._idb.db===null&&await this.whenSynced;let e=this._idb.db;if(e===null)return;let t=this._idb;await new Promise((n,r)=>{let i=e.transaction(Gh,`readwrite`),a=i.objectStore(Gh),o=a.getAll();o.onerror=()=>r(o.error??Error(`flushFullState getAll failed`)),o.onsuccess=()=>{try{Ca(t.doc,()=>{for(let e of o.result)Pa(t.doc,e)},t,!1);let e=a.add(wa(t.doc));e.onerror=()=>r(e.error??Error(`flushFullState add failed`)),e.onsuccess=()=>{a.delete(IDBKeyRange.upperBound(e.result,!0)),typeof i.commit==`function`&&i.commit()}}catch(e){r(e instanceof Error?e:Error(String(e)));try{i.abort()}catch{}}},i.oncomplete=()=>n(),i.onabort=()=>r(i.error??Error(`flushFullState transaction aborted`))})}async clearData(){let e=qh()?0:performance.now();try{await this._idb.destroy();let e=this._dbName;await new Promise((t,n)=>{let r=indexedDB.deleteDatabase(e);r.onsuccess=()=>t(),r.onerror=()=>n(r.error),r.onblocked=()=>{console.warn(JSON.stringify({event:`ok-client-persistence-clear-blocked`,dbName:e}))}})}finally{if(!qh()){let t=performance.now();X(`ok/pool/idb-cleardata`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}};function Yh(e){return new Jh(e)}async function Xh(e){if(typeof indexedDB>`u`)return null;let t=`ok-ydoc:${e.branch}:${e.serverInstanceId}:${e.docName}`;if(typeof indexedDB.databases==`function`&&!(await indexedDB.databases()).some(e=>e.name===t))return null;let n=await new Promise((e,n)=>{let r=indexedDB.open(t);r.onupgradeneeded=()=>{let e=r.result;e.objectStoreNames.contains(Gh)||e.createObjectStore(Gh,{autoIncrement:!0}),e.objectStoreNames.contains(Kh)||e.createObjectStore(Kh)},r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)});try{if(!n.objectStoreNames.contains(Gh))return null;let e=await new Promise((e,t)=>{let r=n.transaction(Gh,`readonly`).objectStore(Gh).getAll();r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)});if(e.length===0)return null;let t=new Na;try{Ca(t,()=>{for(let n of e)Pa(t,n)});let n=t.getMap(`lifecycle`).get(xh);return typeof n==`string`&&n.length>0?n:null}finally{t.destroy()}}finally{n.close()}}function Zh(e){return Aa(e)}function Qh(e,t){return t===null?wa(e):wa(e,t)}function $h(e,t){if(e===null)return t;if(t===null)return e;let n=Sa(e),r=Sa(t),i=new Map;for(let[e,t]of n)i.set(e,t);for(let[e,t]of r){let n=i.get(e);(n===void 0||t>n)&&i.set(e,t)}return Aa(i)}function eg(e){let t={};if(Ra.inject(za.active(),t),!t.traceparent)return e;let n=e.includes(`?`)?`&`:`?`,r=[`traceparent=${encodeURIComponent(t.traceparent)}`];return t.tracestate&&r.push(`tracestate=${encodeURIComponent(t.tracestate)}`),`${e}${n}${r.join(`&`)}`}var tg=({key:e,editor:t,onPaste:n,onDrop:r,allowedMimeTypes:i})=>new J({key:e||new G(`fileHandler`),props:{handleDrop(e,n){if(!r||!n.dataTransfer?.files.length)return!1;let a=e.posAtCoords({left:n.clientX,top:n.clientY}),o=Array.from(n.dataTransfer.files);return i&&(o=o.filter(e=>i.includes(e.type))),o.length===0?!1:(n.preventDefault(),n.stopPropagation(),r(t,o,a?.pos||0),!0)},handlePaste(e,r){if(!n||!r.clipboardData?.files.length)return!1;let a=Array.from(r.clipboardData.files),o=r.clipboardData.getData(`text/html`);return i&&(a=a.filter(e=>i.includes(e.type))),!(a.length===0||(r.preventDefault(),r.stopPropagation(),n(t,a,o),o.length>0))}}}),ng=_e.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[tg({key:new G(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}});function rg(e,t){let{state:n,view:r}=e;if(!n.selection.empty||!r.endOfTextblock(t))return!1;let i=n.selection.$head,a=t===`down`||t===`right`,o=null,s=-1;if(a){let e=i.after();if(e>=n.doc.content.size)return!1;o=n.doc.nodeAt(e),s=e}else{let e=i.before();if(e<=0||(o=n.doc.resolve(e).nodeBefore,!o))return!1;s=e-o.nodeSize}if(!o||o.type.name!==`jsxComponent`||o.childCount!==0||!xe.isSelectable(o))return!1;try{let t=xe.create(n.doc,s);return e.view.dispatch(n.tr.setSelection(t).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Yr(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L0`,reason:e.message.slice(0,500)})),!0}}function ig(e){let{state:t,view:n}=e;if(!(t.selection instanceof K)||!t.selection.empty||!n.endOfTextblock(`up`))return!1;let r=t.selection.$head,i=-1;for(let e=r.depth-1;e>=1;e--)if(r.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;for(let e=r.depth;e>i;e--)if(r.index(e-1)!==0)return!1;let a=r.before(i);try{let n=t.doc.resolve(a),r=ve.findFrom(n,-1,!0);return!r||!(r instanceof K)?!1:(e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return Yr(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2c`,reason:e.message.slice(0,500)})),!0}}function ag(e,t){let{state:n,view:r}=e;if(!(n.selection instanceof K)||!n.selection.empty||!r.endOfTextblock(t))return!1;let i=n.selection.$head,a=t===`down`||t===`right`,o=null,s=-1;if(a){let e=i.after();if(e>=n.doc.content.size)return!1;o=n.doc.nodeAt(e),s=e}else{let e=i.before();if(e<=0||(o=n.doc.resolve(e).nodeBefore,!o))return!1;s=e-o.nodeSize}if(!o||o.type.name!==`jsxComponent`||o.childCount===0)return!1;let c=s+o.nodeSize;try{let t=a?s+1:c-1,r=ve.findFrom(n.doc.resolve(t),a?1:-1,!0);return!r||!(r instanceof K)||r.$head.pos<=s||r.$head.pos>=c?!1:(e.view.dispatch(n.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return Yr(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L2d`,reason:e.message.slice(0,500)})),!0}}var og=_e.create({name:`keyboardNav`,priority:50,addKeyboardShortcuts(){return{Escape:({editor:e})=>{let{state:t}=e;if(t.selection instanceof xe){if(t.selection.$from.depth===0)return e.commands.blur(),!0;let n=t.selection.from+t.selection.node.nodeSize,r=t.doc.resolve(Math.min(n,t.doc.content.size)),i=K.near(r);return e.view.dispatch(t.tr.setSelection(i)),!0}return t.selection instanceof K?e.commands.selectParentNode():!1},ArrowUp:({editor:e})=>{if(rg(e,`up`)||ig(e)||ag(e,`up`))return!0;let{state:t}=e;if(!(t.selection instanceof xe))return!1;let n=t.selection.from,r=t.doc.resolve(n);if(r.index(r.depth)===0)return!1;let i=r.before(r.depth);if(i<=0)return!1;let a=t.doc.resolve(i-1).nodeBefore;if(!a||i-1-a.nodeSize+1<0)return!1;try{let n=xe.create(t.doc,i-a.nodeSize);return e.view.dispatch(t.tr.setSelection(n).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Yr(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowDown:({editor:e})=>{if(rg(e,`down`)||ag(e,`down`))return!0;let{state:t}=e;if(!(t.selection instanceof xe))return!1;let n=t.selection.from+t.selection.node.nodeSize;if(n>=t.doc.content.size)return!1;try{if(!t.doc.nodeAt(n))return!1;let r=xe.create(t.doc,n);return e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Yr(`down`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`down`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowLeft:({editor:e})=>rg(e,`left`)||ag(e,`left`),ArrowRight:({editor:e})=>rg(e,`right`)||ag(e,`right`),Enter:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof K)||!t.selection.empty)return!1;let n=t.selection.$from,r=n.parent;if(r.type.name!==`paragraph`||r.textContent!==``||n.depth<2)return!1;let i=-1;for(let e=n.depth-1;e>=1;e--)if(n.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;let a=n.node(i);if(n.index(i)!==a.childCount-1)return!1;let o=n.after(i);if(o>t.doc.content.size)return!1;let s=t.tr,c=n.before(n.depth),l=n.after(n.depth);s.delete(c,l);let u=o-(l-c),d=t.schema.nodes.paragraph.create();s.insert(u,d);let f=u+1;return s.setSelection(K.create(s.doc,f)),e.view.dispatch(s.scrollIntoView()),!0}}}}),sg={query:``,options:{caseSensitive:!1,wholeWord:!1},activeIndex:0,matches:[]},cg=/[A-Za-z0-9_]/;function lg(e){return e!==void 0&&cg.test(e)}function ug(e,t,n){return!lg(e[t-1])&&!lg(e[n])}function dg(e,t,n){if(t.length===0)return[];let r=n.caseSensitive?e:e.toLocaleLowerCase(),i=n.caseSensitive?t:t.toLocaleLowerCase(),a=[],o=0;for(;o<=r.length-i.length;){let t=r.indexOf(i,o);if(t===-1)break;let s=t+i.length;(!n.wholeWord||ug(e,t,s))&&a.push({start:t,end:s,text:e.slice(t,s)}),o=s}return a}function fg(e,t,n){if(t.length===0)return[];let r=[];return e.descendants((e,i)=>{if(!(!e.isText||typeof e.text!=`string`))for(let a of dg(e.text,t,n))r.push({from:i+a.start,to:i+a.end,text:a.text})}),r}var pg=new G(`findReplace`);function mg(e,t){return t<=0||!Number.isFinite(e)?0:Math.min(Math.max(Math.trunc(e),0),t-1)}function hg(e,t,n,r){let i=fg(e.doc,t,n);return{query:t,options:n,activeIndex:mg(r,i.length),matches:i}}function gg(e,t,n){return t<=0?0:(mg(e,t)+n+t)%t}function _g(e,t,n){if(e.length===0)return 0;let r=t+n,i=e.findIndex(e=>e.from>=r);return i===-1?0:i}function vg(e,t,n){if(t.matches.length===0)return null;let r=e.tr;for(let e of[...t.matches].reverse())r.insertText(n,e.from,e.to);let i=fg(r.doc,t.query,t.options),a=mg(0,i.length),o=i[a];return r.setMeta(pg,{type:`setActiveIndex`,activeIndex:a}),o&&r.setSelection(K.create(r.doc,o.from,o.to)),r.scrollIntoView()}function yg(e,t){let n=pg.getState(e)?.matches[t];return n?e.tr.setMeta(pg,{type:`setActiveIndex`,activeIndex:t}).setSelection(K.create(e.doc,n.from,n.to)).scrollIntoView():null}function bg(e){return pg.getState(e)??sg}function xg(){return new J({key:pg,state:{init:()=>sg,apply(e,t,n,r){let i=e.getMeta(pg);if(i?.type===`clear`)return sg;let a=t.query,o=t.options,s=t.activeIndex;if(i?.type===`setQuery`)a=i.query,o={...o,...i.options},s=i.activeIndex??0;else if(i?.type===`setOptions`)o={...o,...i.options},s=i.activeIndex??s;else if(i?.type===`setActiveIndex`)s=i.activeIndex;else if(!e.docChanged)return t;return a.length===0?{query:a,options:o,activeIndex:0,matches:[]}:hg(r,a,o,s)}},props:{decorations(e){let t=pg.getState(e);return!t||t.matches.length===0?null:U.create(e.doc,t.matches.map((e,n)=>W.inline(e.from,e.to,{class:n===t.activeIndex?`ok-find-match ok-find-match-active`:`ok-find-match`})))}}})}var Sg=_e.create({name:`findReplace`,addCommands(){return{setFindQuery:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(pg,{type:`setQuery`,query:e,options:t?.options,activeIndex:t?.activeIndex})),!0),setFindOptions:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(pg,{type:`setOptions`,options:e,activeIndex:t})),!0),setActiveFindIndex:e=>({state:t,dispatch:n})=>(n&&n(t.tr.setMeta(pg,{type:`setActiveIndex`,activeIndex:e})),!0),selectNextFindMatch:()=>({state:e,dispatch:t})=>{let n=bg(e),r=yg(e,gg(n.activeIndex,n.matches.length,1));return r?(t?.(r),!0):!1},selectPreviousFindMatch:()=>({state:e,dispatch:t})=>{let n=bg(e),r=yg(e,gg(n.activeIndex,n.matches.length,-1));return r?(t?.(r),!0):!1},replaceCurrentFindMatch:e=>({state:t,dispatch:n})=>{let r=bg(t),i=r.matches[r.activeIndex];if(!i||!n)return!1;let a=t.tr.insertText(e,i.from,i.to),o=fg(a.doc,r.query,r.options),s=_g(o,i.from,e.length),c=o[s];return a.setMeta(pg,{type:`setActiveIndex`,activeIndex:s}),c&&a.setSelection(K.create(a.doc,c.from,c.to)),a.scrollIntoView(),n(a),!0},replaceAllFindMatches:e=>({state:t,dispatch:n})=>{let r=bg(t);if(!n)return!1;let i=vg(t,r,e);return i?(n(i),!0):!1},clearFindMatches:()=>({state:e,dispatch:t})=>(t&&t(e.tr.setMeta(pg,{type:`clear`})),!0)}},addProseMirrorPlugins(){return[xg()]}}),Cg=/^(https?:\/\/|www(?=\.))((?:[-.\w]|[^\s\p{P}\p{S}\p{Cc}])+)([^ \t\r\n]*)/iu,wg=/^([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/,Tg=/[-\d_]$/,Eg=/[\p{L}\p{N}]/u,Dg=Ji.map(e=>`${e}:`);function Og(e){let t=e.toLowerCase();return Dg.some(e=>t.startsWith(e))}function kg(e,t){let n=0;for(let r of e)r===t&&n++;return n}function Ag(e){let t=e.split(`.`),n=t[t.length-1],r=t[t.length-2];return!(n&&(/_/.test(n)||!Eg.test(n))||r&&(/_/.test(r)||!Eg.test(r)))}function jg(e){return e.split(`.`).length>=2&&Ag(e)}function Mg(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,``];let n=e.slice(0,t.index),r=t[0],i=r.indexOf(`)`),a=kg(n,`(`),o=kg(n,`)`);for(;i!==-1&&a>o;)n+=r.slice(0,i+1),r=r.slice(i+1),i=r.indexOf(`)`),o++;return[n,r]}function Ng(e){let t=Cg.exec(e);if(!t)return null;let n=t[1],r=t[2],i=t[3],a=``,o=/^w/i.test(n);if(o&&(r=n+r,n=``,a=`http://`),o?!jg(r):!Ag(r))return null;let[s]=Mg(r+i);if(!s)return null;let c=n+s,l=a+n+s;return Og(l)?{href:l,text:c}:null}function Pg(e){let t=wg.exec(e);if(!t)return null;let n=t[1],r=t[2];if(Tg.test(r))return null;let i=`${n}@${r}`,a=`mailto:${i}`;return Og(a)?{href:a,text:i}:null}function Fg(e){return e?Ng(e)??Pg(e):null}function Ig(e,t){let n=Dn.getState(e.state)?.undoManager;n?.stopCapturing();try{e.dispatch(t)}finally{n?.stopCapturing()}}var Lg=`\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000`,Rg=RegExp(`[${Lg}]`),zg=RegExp(`[${Lg}]$`),Bg=`link`,Vg=`gfm-autolink`,Hg=`preventAutolink`,Ug=new G(`gfmAutolink`);function Wg(e,t,n){let r=[],i=Ee(de(e.doc,[...n]));for(let{newRange:e}of i){let n=pe(t.doc,e,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=t.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length===1){let r=t.doc.textBetween(e.from,e.to,` `,` `);if(!zg.test(r))continue;i=n[0],a=t.doc.textBetween(i.pos,e.to,void 0,` `)}if(!i||!a||In(i.node))continue;let o=a.split(Rg).filter(Boolean),s=o[o.length-1];if(!s)continue;let c=Fg(s);if(!c)continue;let l=i.pos+a.lastIndexOf(s)+1,u=l+c.text.length;r.push({from:l,to:u,href:c.href,text:c.text})}return r}function Gg(e={}){let t=e.isActiveEditor??(e=>e.hasFocus()),n=null,r=!1,i=[],a=()=>{r=!1;let e=n,a=i.splice(0,i.length);if(!e||e.isDestroyed||e.composing||!t(e))return;let o=e.state.schema.marks[Bg];if(!o)return;let s=e.state.tr,c=!1,l=e.state.doc.content.size;for(let t of a){let{from:n,to:r,href:i,text:a}=t;n<0||r>l||n>=r||e.state.doc.textBetween(n,r)===a&&(Te(n,r,e.state.doc).some(e=>e.mark.type===o)||en(e.state,n,r)||(s=s.addMark(n,r,o.create({href:i,linkStyle:Vg})),c=!0))}if(c){s=s.setMeta(Hg,!0);try{Ig(e,s)}catch(e){console.warn(`[gfm-autolink] linkify dispatch failed`,{candidates:a.map(e=>({from:e.from,to:e.to,href:e.href}))},e)}}};return new J({key:Ug,view(e){return n=e,{destroy(){n=null,i.length=0,r=!1}}},appendTransaction(e,o,s){if(!e.every(vn)||e.some(e=>e.getMeta(`preventAutolink`))||!(e.some(e=>e.docChanged)&&!o.doc.eq(s.doc))||!n||!t(n))return null;let c=Wg(o,s,e);return c.length===0?null:(i.push(...c),r||(r=!0,queueMicrotask(a)),null)}})}var Kg=_e.create({name:`gfmAutolink`,addOptions(){return{isActiveEditor:void 0}},addProseMirrorPlugins(){return[Gg({isActiveEditor:this.options.isActiveEditor})]}});function qg(){return Y._({id:`jTVuAv`})}var Jg=1e3,Yg=class extends Error{kind;constructor(e,t){super(e),this.name=`UploadFailedError`,this.kind=t}},Xg=class extends Error{constructor(e){super(e),this.name=`UploadRejectedError`}};async function Zg(e,t,n=Jg){if(t<=0)return{readable:!0,bytesRead:0};let r,i=new Promise(e=>{r=setTimeout(()=>e({readable:!1,bytesRead:0,timedOut:!0}),n)}),a=(async()=>{try{let t=await e.slice(0,1).arrayBuffer();return{readable:t.byteLength===1,bytesRead:t.byteLength}}catch(e){return{readable:!1,bytesRead:0,error:e instanceof Error?`${e.name}: ${e.message}`:String(e)}}})();try{return await Promise.race([a,i])}finally{clearTimeout(r)}}function Qg(e){return`\u2066${e}\u2069`}function $g(e){let t=Xe.safeParse(e.attachmentFolderIssue);if(!t.success)return null;let n=t.data;switch(n.kind){case`unknown-variable`:{let e=Qg(n.variables.join(`, `));return Y._({id:`FekgdG`,values:{variables:e}})}case`unclosed-braces`:{let e=Qg(`{{`),t=Qg(`}}`);return Y._({id:`uxk3-0`,values:{open:e,close:t}})}case`repeated-variable`:{let e=Qg(`{{filename}}`);return Y._({id:`ZQkkg7`,values:{filenameVariable:e}})}case`invalid-config`:{let e=Qg(`content.attachmentFolderPath`),t=Qg(`.ok/config.yml`);return Y._({id:`8uJ0VX`,values:{settingKey:e,configFile:t}})}}}function e_(e){return e.readable?`network`:`file-unreadable`}function t_(e,t){return e===`single-file-mode`?qg():e===`file-unreadable`?Y._({id:`YxZDGh`,values:{fileName:t}}):Y._({id:`H0VUMo`,values:{fileName:t}})}async function n_(e){let{file:t,sizeAtDrop:n,error:r}=e,i=await Zg(t,n),a=e_(i);return{kind:a,message:t_(a,t.name),log:{kind:a,name:t.name,type:t.type,sizeAtDrop:n,sizeAtSend:t.size,bytesRead:i.bytesRead,readError:i.error,readTimedOut:i.timedOut,error:r instanceof Error?`${r.name}: ${r.message}`:String(r)}}}var r_=new G(`imageUpload`);function i_(e){let t=document.createElement(`div`);t.className=`image-upload-skeleton w-full h-40 rounded-md bg-foreground/10 animate-pulse motion-reduce:animate-none my-2`,t.setAttribute(`data-upload-widget`,`loading`),t.setAttribute(`role`,`status`);let n=e?.name;return t.setAttribute(`aria-label`,n?Y._({id:`KDuPiY`,values:{fileName:n}}):Y._({id:`bGa3Fk`})),t}var a_=new J({key:r_,state:{init(){return{decorations:U.empty,uploads:new Map}},apply(e,t){let n=t.decorations.map(e.mapping,e.doc),r=new Map;for(let[n,i]of t.uploads)r.set(n,e.mapping.map(i));let i=e.getMeta(r_);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=W.widget(i.pos,i.widget,{id:i.id,stopEvent:()=>!0}),a=n.add(e.doc,[t]),o=new Map(r);return o.set(i.id,e.mapping.map(i.pos)),{decorations:a,uploads:o}}if(i.type===`remove`){let e=n.find(void 0,void 0,e=>e.id===i.id),t=n.remove(e),a=new Map(r);return a.delete(i.id),{decorations:t,uploads:a}}return{decorations:n,uploads:r}}},props:{decorations(e){return r_.getState(e)?.decorations??U.empty}}});function o_(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function s_(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function c_(e){return e.split(`/`).filter(e=>e!==``)}function l_(e,t){let n=o_(e),r=o_(t),i=s_(e);if(n===r)return i;let a=c_(r),o=c_(n),s=0;for(;s<a.length&&s<o.length&&a[s]===o[s];)s++;let c=a.length-s,l=o.slice(s);return c===0?`./${[...l,i].join(`/`)}`:[...Array(c).fill(`..`),...l,i].join(`/`)}function u_(e){return Xt(e)}function d_(e,t){return{type:`jsxComponent`,attrs:{componentName:e===`jsx-img`?`img`:e===`jsx-video`?`video`:`audio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:e===`jsx-img`?{src:t}:{src:t,controls:!0}}}}function f_(e){let t=Kt(e);return t===`md`||t===`mdx`?{kind:`wiki-link`,ext:t}:te.has(t)?{kind:`jsx-img`,ext:t}:ne.has(t)?{kind:`jsx-video`,ext:t}:ae.has(t)?{kind:`jsx-audio`,ext:t}:se.has(t)?{kind:`jsx-file`,ext:t}:oe.has(t)?{kind:`wikiembed`,ext:t}:{kind:`markdown-link`,ext:t}}function p_(e){return wn(e)?(z.error(qg()),!1):!0}async function m_(e,t,n){if(!p_(t))return;let r=u_(t),i=r?`${r}.md`:``;if(!i){z.error(Y._({id:`z5pqI8`}));return}let a=Ni(),o=e.size,s=i_(e);t.view.dispatch(t.state.tr.setMeta(r_,{type:`add`,id:a,pos:n,widget:s}));let c=new FormData;c.append(`file`,e),c.append(`parentDocName`,i);let l;try{l=await fetch(`/api/upload`,{method:`POST`,body:c})}catch(n){let r;try{r=await n_({file:e,sizeAtDrop:o,error:n})}catch(e){console.error(`[uploadAndInsert] upload failed, and diagnosing it failed too`,{docName:i,networkError:n,reportError:e})}r&&console.error(`[uploadAndInsert] upload failed before reaching the server`,{...r.log,docName:i}),h_(t,a,r?.message);return}let u;try{u=await l.json()}catch(e){console.error(`[uploadAndInsert] Response is not JSON:`,e),h_(t,a);return}if(!l.ok){let e=Ye.safeParse(u);if(!e.success){let n=new pi(`Upload response did not match ProblemDetails.`,{cause:e.error,status:l.status});console.error(`[uploadAndInsert] Server error (unparseable):`,n),h_(t,a);return}console.error(`[uploadAndInsert] Server error:`,e.data),h_(t,a,$g(e.data)??e.data.title);return}let d=Je.safeParse(u);if(!d.success){let e=new pi(`Upload success response did not match UploadAssetSuccess.`,{cause:d.error,status:l.status});console.error(`[uploadAndInsert] Response missing src:`,e),h_(t,a);return}let f=d.data,p=f.src,m=f.deduped===!0,h=o_(i),g=typeof f.path==`string`&&f.path.length>0?f.path:h?`${h}/${p}`:p;m&&z.info(Y._({id:`VbqhBI`,values:{assetContentPath:g}}));let _=f_(e.name),{state:v}=t,y=r_.getState(v)?.uploads.get(a)??n,b=v.tr.setMeta(r_,{type:`remove`,id:a}),x=l_(g,i),S=`/${g}`;if(_.kind===`jsx-file`){if(!v.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),h_(t,a);return}let n={type:`jsxComponent`,attrs:{componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:{src:S,target:p,alias:null,anchor:null,size:Lr(e.size)}}};t.chain().command(({tr:e})=>(e.setMeta(r_,{type:`remove`,id:a}),!0)).focus().insertContentAt(y,n).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(y);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(xe.create(e.doc,n)),!0}).run();return}if(_.kind===`jsx-img`||_.kind===`jsx-video`||_.kind===`jsx-audio`){if(!v.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),h_(t,a);return}let e=d_(_.kind,S);t.chain().command(({tr:e})=>(e.setMeta(r_,{type:`remove`,id:a}),!0)).focus().insertContentAt(y,e).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(y);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(xe.create(e.doc,n)),!0}).run();return}if(_.kind===`wikiembed`){let e=v.schema.nodes.wikiLinkEmbed;if(!e){console.error(`[uploadAndInsert] wikiLinkEmbed node missing from schema`),h_(t,a);return}b.insert(y,e.create({target:p,alias:null,anchor:null,resolvedSrc:S}))}else if(_.kind===`wiki-link`){let n=v.schema.nodes.wikiLink;if(!n){console.error(`[uploadAndInsert] wikiLink node missing from schema`),h_(t,a);return}let r=Pn(e.name.replace(/\.(md|mdx)$/i,``));r?b.insert(y,n.create(r)):b.insert(y,v.schema.text(e.name))}else{let t=v.schema.marks.link;if(t){let n=v.schema.text(e.name,[t.create({href:x})]);b.insert(y,n)}else b.insert(y,v.schema.text(e.name))}t.view.dispatch(b)}function h_(e,t,n){e.view.dispatch(e.state.tr.setMeta(r_,{type:`remove`,id:t})),z.error(n??Y._({id:`b3Thhd`}))}var g_=/\[([^\]]+)\]\(([^)\s]+)\)$/,__=`link`;function v_(e,t,n,r,i){if(e.isDestroyed||e.composing)return;let{state:a}=e,o=a.schema.marks[__];if(!o)return;let s=t+n.length;if(t<0||s>a.doc.content.size||a.doc.textBetween(t,s)!==n||a.doc.rangeHasMark(t,s,o))return;let c=a.schema.text(r,[o.create({href:i})]);try{Ig(e,a.tr.replaceRangeWith(t,s,c))}catch(e){console.warn(`[inline-link-rule] collapse dispatch failed`,{from:t,text:r,href:i},e)}}var y_=_e.create({name:`inlineLinkInputRule`,addInputRules(){let e=this.editor;return[new be({find:g_,handler:({state:t,range:n,match:r})=>{let i=r[1],a=r[2];if(!i||!a||!dn(a))return null;let o=t.schema.marks[__];if(!o||t.doc.rangeHasMark(n.from,n.to,o))return null;let s=n.from,c=r[0],l=e.view;return queueMicrotask(()=>v_(l,s,c,i,a)),null}})]}}),b_=`mathInline`,x_=/\$\$([^$\n]+)\$\$$/,S_=/(?<![\w$])\$([^\s$\n](?:[^$\n]*[^\s$\n])?)\$$/;function C_(e,t,n){let r=t.exec(e);if(!r)return null;let i=r[1];return i?{formula:i,delimiter:n,literalLength:r[0].length}:null}function w_(e,t,n){if(e.isDestroyed||e.composing)return;let{state:r}=e,i=r.schema.nodes[b_];if(!i)return;let a=t+n.literalLength;if(t<0||a>r.doc.content.size)return;let o=`${n.delimiter}${n.formula}${n.delimiter}`;if(r.doc.textBetween(t,a)!==o)return;let s=!1;if(r.doc.nodesBetween(t,a,e=>(e.isInline&&!e.isText&&(s=!0),!s)),s)return;let c=i.create({formula:n.formula,sourceDelimiter:n.delimiter});try{Ig(e,r.tr.replaceRangeWith(t,a,c))}catch(e){console.warn(`[math-input-rule] collapse dispatch failed`,{from:t,formula:n.formula,delimiter:n.delimiter},e)}}function T_(e,t,n){return new be({find:t,handler:({state:r,range:i,match:a})=>{let o=C_(a[0],t,n);if(!o||!r.schema.nodes[b_])return null;let s=i.from,c=e.view;return queueMicrotask(()=>w_(c,s,o)),null}})}var E_=_e.create({name:`mathInputRule`,addInputRules(){return[T_(this.editor,x_,`$$`),T_(this.editor,S_,`$`)]}}),D_=`ok-landing-flash`;function O_(e,t,n,r){if(r===`clamped`||r===`ordinal`)return null;let i=Math.max(0,Math.min(t,e)),a=Math.max(i,Math.min(n,e));return a<=i?null:{from:i,to:a}}var k_=new G(`okLandingFlash`),A_=new WeakMap;function j_(){return new J({key:k_,state:{init:()=>U.empty,apply(e,t){let n=e.getMeta(k_),r=t.map(e.mapping,e.doc);return n?.clear&&(r=U.empty),n?.add&&n.add.to>n.add.from&&(r=U.create(e.doc,[W.inline(n.add.from,n.add.to,{class:D_})])),r}},props:{decorations(e){return k_.getState(e)}},view(e){return{destroy(){let t=A_.get(e);t!==void 0&&(clearTimeout(t),A_.delete(e))}}}})}var M_=_e.create({name:`okLandingFlash`,addProseMirrorPlugins(){return[j_()]}}),N_=new Set;function P_(e){N_.add(e)}function F_(e){return N_.delete(e)}var I_=new G(`markIdentity`);function L_(){return{byId:new Map,counter:0}}function R_(e,t,n,r,i){let a=[];for(let e of t.byId.values()){let t=i?i.map(e.from,-1):e.from,n=i?i.map(e.to,1):e.to;n<=t||a.push({id:e.id,markType:e.markType,attrs:e.attrs,from:t,to:n})}let o=new Map,s=new Set,c=t.counter;return e.descendants((e,t)=>{if(!(!e.isInline||e.marks.length===0))for(let i of e.marks){if(!n.has(i.type.name)||r&&!r(i))continue;let l=null;for(let e of a)if(!s.has(e.id)&&e.markType===i.type.name&&z_(e.attrs,i.attrs)&&!(t<e.from||t>=e.to)){l=e.id;break}let u=l??`m${++c}`;s.add(u);let d=t,f=t+e.nodeSize,p=o.get(u);p?p.to=Math.max(p.to,f):o.set(u,{id:u,markType:i.type.name,attrs:i.attrs,from:d,to:f})}}),{byId:o,counter:c}}function z_(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(n!==i&&(typeof n!=`object`||!n||typeof i!=`object`||!i||!((Array.isArray(n)&&Array.isArray(i)||!Array.isArray(n)&&!Array.isArray(i)&&Object.getPrototypeOf(n)===Object.prototype&&Object.getPrototypeOf(i)===Object.prototype)&&z_(n,i))))return!1}return!0}function B_(e,t,n,r){let i=new Set(t.byId.keys());for(let[r,i]of t.byId)e.has(r)||n?.(i);for(let t of e)i.has(t)||r?.(t);return i}function V_(e,t,n){let r=I_.getState(e);if(!r)return null;for(let e of r.byId.values())if(e.markType===n&&e.from<=t&&t<e.to)return e.id;return null}function H_(e){let{markTypes:t,predicate:n,onRegister:r,onDeregister:i}=e,a=new Set(t);return new J({key:I_,state:{init(e,t){return R_(t.doc,L_(),a,n)},apply(e,t,r,i){return e.docChanged?R_(i.doc,t,a,n,e.mapping):t}},view(){let e=new Set;return{update(t){let n=I_.getState(t.state);n&&(e=B_(e,n,r,i))},destroy(){for(let t of e)i?.(t);e=new Set}}}})}var U_=300,W_=150,G_=500,K_=class{registry=new Map;_activeNodeId=null;listeners=new Set;_snapshot={activeNodeId:null,active:null};register(e){this.registry.set(e.nodeId,e),this._activeNodeId===e.nodeId&&this.refreshSnapshot()}deregister(e){this.registry.delete(e)&&this._activeNodeId===e&&(this._activeNodeId=null,this.refreshSnapshot())}setActiveNode(e){this._activeNodeId!==e&&(e!==null&&!this.registry.has(e)||(this._activeNodeId=e,this.refreshSnapshot()))}getActiveNode(){return this._activeNodeId}getRegistration(e){return this.registry.get(e)}hasRegistration(e){return this.registry.has(e)}clear(){this.registry.clear(),this._activeNodeId=null,this.refreshSnapshot()}getSnapshot=()=>this._snapshot;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});refreshSnapshot(){let e=this._activeNodeId==null?null:this.registry.get(this._activeNodeId)??null;this._snapshot={activeNodeId:this._activeNodeId,active:e};for(let e of this.listeners)e()}};function q_(e,t){let n=e??null;for(;n&&typeof n==`object`;){let e=n.getAttribute;if(typeof e==`function`){let r=e.call(n,`data-mark-id`);if(r&&t.hasRegistration(r))return r;let i=e.call(n,`data-node-id`);if(i&&t.hasRegistration(i))return i}n=n.parentElement??null}return null}function J_(e){return e?e.closest(`[data-ok-prop-panel]`)!==null:!1}function Y_(){return typeof document>`u`?!1:document.querySelector(`[data-ok-layer-spawned]`)!==null}var X_=e=>{let t=(0,Q.c)(18),{store:n}=e,r;t[0]===n?r=t[1]:(r=()=>n.getSnapshot(),t[0]=n,t[1]=r);let[i,a]=(0,Z.useState)(r),o,s;t[2]===n?(o=t[3],s=t[4]):(o=()=>(a(n.getSnapshot()),n.subscribe(()=>{a(n.getSnapshot())})),s=[n],t[2]=n,t[3]=o,t[4]=s),(0,Z.useEffect)(o,s);let{active:c}=i;if(!c)return null;let l;t[5]===n?l=t[6]:(l=()=>n.setActiveNode(null),t[5]=n,t[6]=l);let u,d,f;if(t[7]!==c.controls||t[8]!==c.nodeId||t[9]!==c.type||t[10]!==l){let e={nodeId:c.nodeId,type:c.type,deactivate:l};u=c.controls.propPanel?.(e),d=c.controls.toolbar?.(e),f=c.controls.breadcrumb?.(e),t[7]=c.controls,t[8]=c.nodeId,t[9]=c.type,t[10]=l,t[11]=u,t[12]=d,t[13]=f}else u=t[11],d=t[12],f=t[13];let p;return t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,$.jsxs)($.Fragment,{children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17],p};function Z_(e){return e.editorView?.dom??null}function Q_(e,t){let n=e;for(;n;){if(n.getAttribute?.(`data-mark-id`)===t||n.getAttribute?.(`data-node-id`)===t)return!0;n=n.parentElement}return!1}function $_(e){let{editor:t}=e,n=new K_,r=Z_(t),i=!1,a=null,o=null,s=null,c=null,l=null,u=()=>{a!==null&&(clearTimeout(a),a=null),s=null},d=()=>{o!==null&&(clearTimeout(o),o=null)},f=()=>{c!==null&&(clearTimeout(c),c=null)},p=e=>{if(n.getActiveNode()===e){d();return}s===e&&a!==null||(u(),d(),s=e,a=setTimeout(()=>{a=null,s=null,n.setActiveNode(e)},U_))},m=()=>{n.getActiveNode()!==null&&o===null&&(o=setTimeout(()=>{o=null,!Y_()&&n.setActiveNode(null)},W_))},h={kind:`none`},g=!1,_=e=>{try{g=!0,e.focus({preventScroll:!0})}catch{}finally{g=!1}},v=n.subscribe(()=>{let e=n.getActiveNode();if(e!==null){if(typeof document<`u`){let t=document.activeElement;h=t&&Q_(t,e)?{kind:`activator`,element:t}:{kind:`none`}}else h={kind:`none`};return}let i=h;if(h={kind:`none`},typeof document>`u`)return;if(i.kind===`none`){if(!document.activeElement?.closest(`[data-ok-prop-panel], [data-ok-layer-spawned], [data-ok-interaction-layer]`))return}else if(document.contains(i.element)&&typeof i.element.focus==`function`){_(i.element);return}let a=r??Z_(t);a&&typeof a.focus==`function`&&_(a)}),y=e=>{let t=e;if(t.button!==2){if(t.metaKey||t.ctrlKey||t.button===1){u(),t.button===1&&t.preventDefault?.();return}if(t.pointerType===`touch`){let t=q_(e.target,n);if(t===null)return;f(),c=setTimeout(()=>{c=null,l=t,n.setActiveNode(t)},G_);return}u()}},b=()=>{f()},x=e=>{e.pointerType===`touch`&&c!==null&&f()},S=e=>{let t=e;if(t.button===2||t.type===`click`&&t.button===1)return;let r=q_(e.target,n);if(r===null)return;if(l!==null){let e=l===r;if(l=null,e){t.preventDefault?.();return}}let i=t.metaKey||t.ctrlKey||t.button===1,a=n.getRegistration(r);if(a?.handlePrimary&&a.handlePrimary({nodeId:r,type:a.type,newTab:i})){t.preventDefault?.(),i||(u(),d(),n.getActiveNode()===r&&n.setActiveNode(null));return}i||(u(),d(),n.setActiveNode(r))},C=e=>{let t=e;if(t.key===`Escape`){n.getActiveNode()!==null&&(u(),d(),n.setActiveNode(null),t.preventDefault?.());return}if(t.key===`Tab`&&!t.shiftKey&&!t.altKey&&!t.metaKey&&!t.ctrlKey){let r=q_(e.target,n);if(r!==null&&n.getActiveNode()===r){let e=document.querySelector(`[data-ok-prop-panel]`);if(e){let n=e.querySelector(`button:not([disabled]), [href], input:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(n){t.preventDefault?.(),n.focus();return}}}return}let r=t.key===`Enter`,i=t.key===` `||t.key===`Spacebar`;if(!r&&!i)return;let a=q_(e.target,n);if(a===null||i&&((e.target instanceof Element?e.target:null)?.closest(`[data-mark-id], [data-node-id]`)??null)?.getAttribute(`role`)===`link`)return;let o=n.getRegistration(a);if(t.preventDefault?.(),o?.handlePrimary&&o.handlePrimary({nodeId:a,type:o.type,newTab:!1})){u(),d(),n.getActiveNode()===a&&n.setActiveNode(null);return}n.setActiveNode(a)},w=e=>{let t=e;if(t.pointerType!==`mouse`)return;let r=t.target;if(!(r instanceof Element))return;if(J_(r)){d();return}let i=q_(r,n);i!==null&&p(i)},T=e=>{let t=e;if(t.pointerType!==`mouse`)return;let r=t.target,i=t.relatedTarget;if(!(r instanceof Element))return;let a=i instanceof Element?i:null,o=q_(r,n);if(o!==null){if(a&&J_(a)){d();return}if(a&&q_(a,n)===o)return;s===o&&u(),m();return}if(J_(r)){if(a&&J_(a))return;let e=n.getActiveNode();if(e!==null&&a&&q_(a,n)===e)return;m()}},E=e=>{if(g)return;let t=e.target;if(!(t instanceof Element))return;let r=q_(t,n);r!==null&&(u(),d(),n.setActiveNode(r))},D=e=>{let t=e;if(n.getActiveNode()===null)return;let r=t.relatedTarget,i=r instanceof Element?r:null;i&&J_(i)||i&&q_(i,n)!==null||m()},O=e=>{if(n.getActiveNode()===null)return;let t=e.target;t&&(r?.contains(t)||t instanceof Element&&(t.closest(`[data-ok-interaction-layer]`)||t.closest(`[data-ok-prop-panel]`)||t.closest(`[data-ok-layer-spawned]`))||(u(),d(),n.setActiveNode(null)))},k=()=>{i||(r=Z_(t),r&&(r.addEventListener(`pointerdown`,y,!0),r.addEventListener(`pointerup`,b,!0),r.addEventListener(`pointercancel`,b,!0),r.addEventListener(`pointermove`,x,!0),r.addEventListener(`click`,S,!0),r.addEventListener(`auxclick`,S,!0),r.addEventListener(`keydown`,C,!0),typeof document<`u`&&(document.addEventListener(`pointerover`,w,!0),document.addEventListener(`pointerout`,T,!0),document.addEventListener(`focusin`,E,!0),document.addEventListener(`focusout`,D,!0),document.addEventListener(`pointerdown`,O,!0)),i=!0))},A=()=>{i&&=(r?.removeEventListener(`pointerdown`,y,!0),r?.removeEventListener(`pointerup`,b,!0),r?.removeEventListener(`pointercancel`,b,!0),r?.removeEventListener(`pointermove`,x,!0),r?.removeEventListener(`click`,S,!0),r?.removeEventListener(`auxclick`,S,!0),r?.removeEventListener(`keydown`,C,!0),typeof document<`u`&&(document.removeEventListener(`pointerover`,w,!0),document.removeEventListener(`pointerout`,T,!0),document.removeEventListener(`focusin`,E,!0),document.removeEventListener(`focusout`,D,!0),document.removeEventListener(`pointerdown`,O,!0)),!1)};return k(),{register(e){n.register(e),i||k()},deregister(e){n.deregister(e)},setActiveNode(e){n.setActiveNode(e)},getActiveNode(){return n.getActiveNode()},getRegistration(e){return n.getRegistration(e)},destroy(){A(),u(),d(),f(),v(),n.clear()},store:n}}var ev=e=>{let t=(0,Q.c)(2),{store:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{"data-ok-interaction-layer":``,className:`contents`,children:(0,$.jsx)(X_,{store:n})}),t[0]=n,t[1]=r),r},tv=new WeakMap;function nv(e){let t=tv.get(e);if(t)return t;let n=$_({editor:e});return tv.set(e,n),e.on(`destroy`,()=>{n.destroy(),tv.delete(e)}),n}var rv={AlignCenter:Tu,AppWindow:gt,ChevronRight:Mt,CopyPlus:ql,FileText:hi,Film:ci,GitBranch:_t,Image:Qn,LayoutPanelTop:au,MessageSquareWarning:pu,PanelTop:hu,Paperclip:Ti,PenTool:gu,Sigma:bu,SquarePlay:Su,Volume2:_r,Workflow:ku,ZoomIn:Ct};function iv(e){return e&&Object.hasOwn(rv,e)?rv[e]:Rl}var av={Info:xi,Lightbulb:ou,MessageSquareWarning:pu,AlertTriangle:ji,AlertOctagon:mu,ClipboardList:Ul,BookOpen:Ll,ListTodo:du,CircleCheck:Pt,CircleHelp:Vl,CircleX:Hl,Zap:Au,Bug:zl,FlaskConical:$l,Quote:_u,ChevronRight:Mt},ov=Object.entries(av).sort(([e],[t])=>e.localeCompare(t));function sv(e){if(!e||!e.startsWith(`lucide:`))return null;let t=e.slice(7);return Object.hasOwn(av,t)?av[t]??null:null}function cv(e){let t=(0,Q.c)(24),n;t[0]===e.icon?n=t[1]:(n=sv(e.icon),t[0]=e.icon,t[1]=n);let r=n,i=r?`custom`:void 0,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Mt,{size:14,className:`accordion-chevron`,"aria-hidden":`true`}),t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=r?(0,$.jsx)(r,{size:16,className:`accordion-icon`,"aria-hidden":`true`}):null,t[3]=r,t[4]=o);let s=e.title??`Accordion`,c;t[5]===s?c=t[6]:(c=(0,$.jsx)(`span`,{className:`accordion-title`,children:s}),t[5]=s,t[6]=c);let l;t[7]===e.description?l=t[8]:(l=e.description?(0,$.jsx)(`span`,{className:`accordion-description`,children:e.description}):null,t[7]=e.description,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,$.jsxs)(`span`,{className:`accordion-title-group`,children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==o||t[13]!==u?(d=(0,$.jsxs)(`summary`,{className:`accordion-summary`,contentEditable:!1,children:[a,o,u]}),t[12]=o,t[13]=u,t[14]=d):d=t[14];let f;t[15]===e.children?f=t[16]:(f=(0,$.jsx)(`div`,{className:`accordion-body`,children:e.children}),t[15]=e.children,t[16]=f);let p;return t[17]!==e.defaultOpen||t[18]!==e.id||t[19]!==e.name||t[20]!==i||t[21]!==d||t[22]!==f?(p=(0,$.jsxs)(`details`,{className:`accordion`,"data-accordion-icon":i,open:e.defaultOpen,id:e.id,name:e.name,children:[d,f]}),t[17]=e.defaultOpen,t[18]=e.id,t[19]=e.name,t[20]=i,t[21]=d,t[22]=f,t[23]=p):p=t[23],p}var lv={center:`text-center`,left:`text-left`,right:`text-right`,justify:`text-justify`};function uv(e){let t=(0,Q.c)(5),n=lv[e.align??``]??null,r;t[0]===n?r=t[1]:(r=d(`prose-no-margin`,n),t[0]=n,t[1]=r);let i;return t[2]!==e.children||t[3]!==r?(i=(0,$.jsx)(`div`,{"data-component-type":`align-block`,className:r,children:e.children}),t[2]=e.children,t[3]=r,t[4]=i):i=t[4],i}function dv(e){return e!==!1}function fv(e){let t=(0,Q.c)(12),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:Lo(e.src),t[0]=e.src,t[1]=n);let r=e.title,i;t[2]===e.controls?i=t[3]:(i=dv(e.controls),t[2]=e.controls,t[3]=i);let a;return t[4]!==e.autoplay||t[5]!==e.loop||t[6]!==e.muted||t[7]!==e.preload||t[8]!==e.title||t[9]!==n||t[10]!==i?(a=(0,$.jsx)(`audio`,{className:`ok-audio`,src:n,title:r,controls:i,autoPlay:e.autoplay,loop:e.loop,muted:e.muted,preload:e.preload}),t[4]=e.autoplay,t[5]=e.loop,t[6]=e.muted,t[7]=e.preload,t[8]=e.title,t[9]=n,t[10]=i,t[11]=a):a=t[11],a}var pv={note:xi,tip:ou,important:pu,warning:ji,caution:mu,abstract:Ul,info:Ll,todo:du,success:Pt,question:Vl,failure:Hl,danger:Au,bug:zl,example:$l,quote:_u};function mv(e,t){return sv(e)??pv[t]}var hv=new Set([`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`]);function gv(e){return typeof e==`string`&&hv.has(e)?e:`note`}function _v(e){let t=(0,Q.c)(29),n,r;t[0]!==e.icon||t[1]!==e.type?(r=gv(e.type),n=mv(e.icon,r),t[0]=e.icon,t[1]=e.type,t[2]=n,t[3]=r):(n=t[2],r=t[3]);let i=n,o;t[4]===e.color?o=t[5]:(o=e.color?{"--callout-type-color":e.color}:{},t[4]=e.color,t[5]=o);let s=o,c;t[6]!==i||t[7]!==e.title?(c=e.title||i?(0,$.jsxs)(`span`,{className:`callout-header`,contentEditable:!1,children:[(0,$.jsx)(i,{size:16,className:`callout-icon`,"aria-hidden":`true`}),e.title?(0,$.jsx)(`span`,{className:`callout-title`,children:e.title}):null]}):null,t[6]=i,t[7]=e.title,t[8]=c):c=t[8];let l=c;if(e.collapsible){let n=e.defaultOpen??!0,i;t[9]===l?i=t[10]:(i=l??(0,$.jsx)(`span`,{className:`callout-title`,children:(0,$.jsx)(a,{id:`URmyfc`})}),t[9]=l,t[10]=i);let o;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(jt,{size:16,className:`callout-chevron`,"aria-hidden":`true`}),t[11]=o):o=t[11];let c;t[12]===i?c=t[13]:(c=(0,$.jsxs)(`summary`,{className:`callout-summary`,contentEditable:!1,children:[i,o]}),t[12]=i,t[13]=c);let u;t[14]===e.children?u=t[15]:(u=(0,$.jsx)(`div`,{className:`callout-body`,children:e.children}),t[14]=e.children,t[15]=u);let d;return t[16]!==n||t[17]!==s||t[18]!==c||t[19]!==u||t[20]!==r?(d=(0,$.jsxs)(`details`,{className:`callout callout-collapsible`,"data-callout-type":r,open:n,style:s,children:[c,u]}),t[16]=n,t[17]=s,t[18]=c,t[19]=u,t[20]=r,t[21]=d):d=t[21],d}let u;t[22]===e.children?u=t[23]:(u=(0,$.jsx)(`div`,{className:`callout-body`,children:e.children}),t[22]=e.children,t[23]=u);let d;return t[24]!==l||t[25]!==s||t[26]!==u||t[27]!==r?(d=(0,$.jsxs)(`div`,{className:`callout callout-static`,"data-callout-type":r,style:s,children:[l,u]}),t[24]=l,t[25]=s,t[26]=u,t[27]=r,t[28]=d):d=t[28],d}function vv(e){let t;try{t=new URL(e)}catch{return null}let n=t.pathname.match(/^\/video\/(\d+)/);if(n)return n[1]??null;let r=t.pathname.match(/^\/(\d+)/);return r?r[1]??null:null}function yv(e){if(typeof e!=`string`||e.length===0)return e;let t=Yt(e);if(t){let e=t.noCookie?`www.youtube-nocookie.com`:`www.youtube.com`,n=t.startSeconds===null?``:`?start=${t.startSeconds}`;return`https://${e}/embed/${t.id}${n}`}if(ui(e)){let t=vv(e);return t?`https://player.vimeo.com/video/${t}`:e}let n=$t(e);if(n){let e=n.startRaw===null?``:`?t=${n.startRaw}`;return`https://www.loom.com/embed/${n.id}${e}`}return e}var bv=[{key:`tl`,dx:-1,dy:-1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--tl`},{key:`t`,dx:0,dy:-1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--t`},{key:`tr`,dx:1,dy:-1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--tr`},{key:`r`,dx:1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--r`},{key:`br`,dx:1,dy:1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--br`},{key:`b`,dx:0,dy:1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--b`},{key:`bl`,dx:-1,dy:1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--bl`},{key:`l`,dx:-1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--l`}];function xv(e){let t=(0,Q.c)(7),{targetRef:n,onResize:r,onResizeEnd:i,bounds:a}=e,{_:s}=o(),c=(0,Z.useRef)(null),l;t[0]!==a?.maxHeight||t[1]!==a?.maxWidth||t[2]!==a?.minHeight||t[3]!==a?.minWidth?(l=function(e,t){let n=t===`w`?a?.minWidth??64:a?.minHeight??64,r=t===`w`?a?.maxWidth??1/0:a?.maxHeight??1/0;return Math.max(n,Math.min(r,e))},t[0]=a?.maxHeight,t[1]=a?.maxWidth,t[2]=a?.minHeight,t[3]=a?.minWidth,t[4]=l):l=t[4];let u=l,f=function(e,t){let a=n.current;if(!a)return;e.preventDefault(),e.stopPropagation();let o=a.getBoundingClientRect();c.current={handle:t,startX:e.clientX,startY:e.clientY,startWidth:o.width,startHeight:o.height,latestWidth:o.width,latestHeight:o.height,hasMoved:!1};let s=e.currentTarget;try{s.setPointerCapture(e.pointerId)}catch{}document.body.style.setProperty(`cursor`,t.cursor),document.body.style.setProperty(`user-select`,`none`);let l=function(e){let t=c.current;if(!t)return;let n=(e.clientX-t.startX)*t.handle.dx,i=(e.clientY-t.startY)*t.handle.dy,a=t.handle.dx===0?t.startWidth:u(t.startWidth+n,`w`),o=t.handle.dy===0?t.startHeight:u(t.startHeight+i,`h`);t.latestWidth=a,t.latestHeight=o,t.hasMoved=!0,r({width:a,height:o})};function d(){let e=c.current;if(!e)return;let t={width:e.latestWidth,height:e.latestHeight},n=e.hasMoved;c.current=null,document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`),window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d),n&&i?.(t)}window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},p=bv.map(e=>{let t=e.key;return(0,$.jsx)(`button`,{type:`button`,className:d(e.className),"aria-label":s({id:`NxW-md`,values:{handleKey:t}}),tabIndex:-1,style:{cursor:e.cursor},onPointerDown:t=>f(t,e)},t)}),m;return t[5]===p?m=t[6]:(m=(0,$.jsx)(`div`,{className:`ok-resize-overlay`,contentEditable:!1,"aria-hidden":`true`,children:p}),t[5]=p,t[6]=m),m}var Sv=`26rem`,Cv=`Embedded content`,wv=/^https?:\/\//i;function Tv(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function Ev(e){return!(typeof e!=`string`||!wv.test(e)||!Tv(e))}function Dv(e){let t=(0,Q.c)(24),{src:n,title:r,width:i,height:a}=e,o=(0,Z.useRef)(null),s=kt(),c=i||void 0,l=a||Sv,u;t[0]!==c||t[1]!==l?(u={width:c,height:l},t[0]=c,t[1]=l,t[2]=u):u=t[2];let d=u,f,p;if(t[3]!==a||t[4]!==i?(f=()=>{let e=o.current;e&&(e.style.width=i||``,e.style.height=a||Sv)},p=[i,a],t[3]=a,t[4]=i,t[5]=f,t[6]=p):(f=t[5],p=t[6]),(0,Z.useEffect)(f,p),!Ev(n)){let e=`Embed a URL`;typeof n==`string`&&n.length>0&&(e=wv.test(n)?`Embed only supports cross-origin URLs`:`URL must start with http:// or https://`);let r;return t[7]===e?r=t[8]:(r=(0,$.jsx)(`div`,{className:`ok-embed ok-embed--placeholder`,contentEditable:!1,children:(0,$.jsx)(`span`,{children:e})}),t[7]=e,t[8]=r),r}let m;t[9]===s?m=t[10]:(m=e=>{if(!s)return;let{editor:t,getPos:n}=s,r=n();if(typeof r==`number`)try{let n=t.state.doc.nodeAt(r);if(n?.type.name!==`jsxComponent`)return;let i={...n.attrs.props??{},width:`${Math.round(e.width)}px`,height:`${Math.round(e.height)}px`};t.view.dispatch(t.state.tr.setNodeMarkup(r,null,{...n.attrs,props:i,sourceDirty:!0}))}catch(e){let t=e;if(t instanceof RangeError)return;throw t}},t[9]=s,t[10]=m);let h=m,g;t[11]===n?g=t[12]:(g=yv(n),t[11]=n,t[12]=g);let _=g,v=_===n?`no-referrer`:`strict-origin-when-cross-origin`,y=r||Cv,b;t[13]!==_||t[14]!==v||t[15]!==y?(b=(0,$.jsx)(`iframe`,{title:y,src:_,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation`,referrerPolicy:v,loading:`lazy`,className:`ok-embed-frame`}),t[13]=_,t[14]=v,t[15]=y,t[16]=b):b=t[16];let x;t[17]!==s||t[18]!==h?(x=s?(0,$.jsx)(xv,{targetRef:o,bounds:{minWidth:192,maxWidth:2e3,minHeight:128,maxHeight:Math.round(window.innerHeight*.9)},onResize:e=>{let t=o.current;t&&(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`)},onResizeEnd:h}):null,t[17]=s,t[18]=h,t[19]=x):x=t[19];let S;return t[20]!==d||t[21]!==x||t[22]!==b?(S=(0,$.jsxs)(`div`,{className:`ok-embed`,style:d,ref:o,contentEditable:!1,children:[b,x]}),t[20]=d,t[21]=x,t[22]=b,t[23]=S):S=t[23],S}function Ov(e){return e===Be}var kv=new Set(Ve);function Av(e){return kv.has(e)}var jv=new Map,Mv=1e4,Nv=(0,Z.createContext)(!0);function Pv(){return{ok:!1,reason:`refused`}}function Fv(){return(0,Z.use)(Nv)?Iv:Pv}function Iv(e,t){if(Ov(t)||Av(t))return{ok:!1,reason:`inadmissible`};let n=`${e}|${t}`,r=jv.get(n);if(r)return r.refcount+=1,{ok:!0,entry:r};if(jv.size>=30)return console.warn(`[LiveDoc] provider pool at capacity (30); refusing "${t}". Live by-reference embeds and mirrors across all visible documents share this pool.`),{ok:!1,reason:`at-capacity`};let i=new Na,a=new Ma({url:e,name:t,document:i}),o=new Set,s={provider:a,ySource:i.getText(`source`),refcount:1,synced:!1,subscribe:e=>(o.add(e),()=>{o.delete(e)})};return a.on(`synced`,()=>{s.synced=!0;for(let e of o)e.onSynced()}),s.ySource.observe(()=>{for(let e of o)e.onUpdate()}),jv.set(n,s),{ok:!0,entry:s}}function Lv(e,t){let n=`${e}|${t}`,r=jv.get(n);if(r&&(--r.refcount,r.refcount<=0)){try{r.provider.destroy()}catch(e){console.warn(`[LiveDoc] provider.destroy() failed during release`,{docName:t,err:e})}jv.delete(n)}}function Rv(e,t){return e.kind!==t.kind||e.kind===`ready`&&t.kind===`ready`&&e.text!==t.text?t:e}function zv(e,t){switch(t){case`at-capacity`:return{kind:`at-capacity`};case`inadmissible`:return{kind:`unreachable`};case`refused`:return console.warn(`[LiveDoc] live-document access is off here; refused`,{docName:e}),{kind:`loading`}}}function Bv(e,t){let n=(0,Q.c)(10),r=t===void 0?0:t,{collabUrl:i}=_o(),a=Fv(),o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={kind:`loading`},n[0]=o):o=n[0];let[s,c]=(0,Z.useState)(o),l;n[1]!==a||n[2]!==i||n[3]!==e?(l=()=>{if(!e){c({kind:`unreachable`});return}if(!i){c({kind:`loading`});return}c(Vv);let t=a(i,e);if(!t.ok){c(zv(e,t.reason));return}let{entry:n}=t,r=()=>{let e=n.ySource.toString(),t=e?{kind:`ready`,text:e}:n.synced?{kind:`empty`}:{kind:`loading`};c(e=>Rv(e,t))},o=null,s=n.subscribe({onUpdate:()=>{o&&clearTimeout(o),o=setTimeout(()=>{o=null,r()},150)},onSynced:()=>{o&&=(clearTimeout(o),null),r()}}),l=!1,u=()=>{l||(l=!0,o&&=(clearTimeout(o),null),s(),Lv(i,e))},d=setTimeout(()=>{n.synced||(c({kind:`unreachable`}),u())},Mv);return r(),()=>{clearTimeout(d),u()}},n[1]=a,n[2]=i,n[3]=e,n[4]=l):l=n[4];let u;return n[5]!==a||n[6]!==i||n[7]!==e||n[8]!==r?(u=[i,e,r,a],n[5]=a,n[6]=i,n[7]=e,n[8]=r,n[9]=u):u=n[9],(0,Z.useEffect)(l,u),s}function Vv(e){return Rv(e,{kind:`loading`})}var Hv=30,Uv=[];function Wv(e){if(typeof document>`u`)return!1;for(let t of document.images)if(t.getAttribute(`src`)===e)return!0;return!1}function Gv(e){Uv.push(e);let t=0;for(;Uv.length>Hv&&t<Uv.length;){let e=Uv.shift();if(!e)break;if(t+=1,Wv(e)){Uv.push(e);continue}URL.revokeObjectURL(e)}}function Kv(e){let t=Uv.indexOf(e);t>=0&&Uv.splice(t,1),URL.revokeObjectURL(e)}var qv=xt(()=>n(()=>import(`./prod-DmbEMjXJ.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47]),import.meta.url)),Jv=new Set([`http:`,`https:`,`file:`]);function Yv(e,t=typeof window<`u`&&window.location?.href?window.location.href:`http://localhost/`){try{let n=new URL(t),r=new URL(e,n);if(!Jv.has(r.protocol)||!(r.protocol===`file:`?n.protocol===`file:`:r.origin===n.origin))return null;let i=r.pathname.split(`/`).filter(e=>e.length>0).map(e=>decodeURIComponent(e));if(i.length===0||i.some(e=>e===`..`||e===`.`||e.includes(`/`)||e.includes(`\\`)||/[\u0000-\u001f]/.test(e)))return null;let a=i.join(`/`);return ie(a)?a:null}catch{return null}}function Xv(e){return typeof e==`string`&&Yv(e)!==null}function Zv(e){let t=(0,Q.c)(82),{src:n,title:r,className:i,expandOpen:s,onExpandOpenChange:c}=e,l=s===void 0?!1:s,{_:u}=o(),f=bt(),[p,m]=(0,Z.useState)(0),h;t[0]===n?h=t[1]:(h=n?Yv(n):null,t[0]=n,t[1]=h);let g=h,_=Bv(g,p),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(null),w=(0,Z.useRef)(null),T=(0,Z.useRef)(!1),E,D;t[2]===g?(E=t[3],D=t[4]):(E=()=>{g&&(qv().catch(ty),wt().catch(ey))},D=[g],t[2]=g,t[3]=E,t[4]=D),(0,Z.useEffect)(E,D);let O;t[5]!==g||t[6]!==_.kind||t[7]!==_.text||t[8]!==v?(O=()=>{if(_.kind!==`ready`||!g||v&&v.docName===g&&v.text===_.text)return;let e=!1;return(async()=>{let t=JSON.parse(_.text);if(!(typeof t==`object`&&t&&Array.isArray(t.elements)))throw Error(`not an Excalidraw scene (no elements array)`);let n;try{n=await qv()}catch(t){let n=t;if(e)return;console.warn(`[ExcalidrawEmbed] excalidraw module failed to load:`,g,n),T.current=!1,y(null),C({docName:g,kind:`module-load`});return}let r=Qo(n,t);e||(y({docName:g,text:_.text,value:r}),C(null))})().catch(t=>{e||(console.warn(`[ExcalidrawEmbed] failed to parse board:`,g,t),T.current=!1,y(null),C({docName:g,kind:`parse`}))}),()=>{e=!0}},t[5]=g,t[6]=_.kind,t[7]=_.text,t[8]=v,t[9]=O):O=t[9];let k;t[10]!==g||t[11]!==_||t[12]!==v?(k=[_,g,v],t[10]=g,t[11]=_,t[12]=v,t[13]=k):k=t[13],(0,Z.useEffect)(O,k);let A=(0,Z.useRef)(!1),j=(0,Z.useRef)(!1),[M,N]=(0,Z.useState)(0),P=(0,Z.useRef)(null),F;t[14]!==g||t[15]!==f||t[16]!==v||t[17]!==b?(F=()=>{if(!v||!g||v.docName!==g||b&&b.docName===v.docName&&b.sceneValue===v.value&&b.colorMode===f)return;if(A.current){j.current=!0;return}let e=!1;return A.current=!0,(async()=>{let t;try{t=await qv()}catch(t){let n=t;if(e)return;console.warn(`[ExcalidrawEmbed] excalidraw module failed to load:`,g,n),T.current=!1,x(null),C({docName:g,kind:`module-load`});return}let n=await t.exportToSvg({elements:v.value.elements,appState:{...v.value.appState,exportWithDarkMode:f===`dark`,exportBackground:!1},files:v.value.files});if(e)return;let r=new XMLSerializer().serializeToString(n),i=URL.createObjectURL(new Blob([r],{type:`image/svg+xml`})),a=P.current;P.current=i,Gv(i),a&&Kv(a),x({docName:v.docName,url:i,sceneValue:v.value,colorMode:f}),C(null)})().catch(t=>{e||(console.warn(`[ExcalidrawEmbed] failed to export board snapshot:`,g,t),T.current=!1,x(null),C({docName:g,kind:`export`}))}).finally(()=>{A.current=!1,j.current&&(j.current=!1,N($v))}),()=>{e=!0}},t[14]=g,t[15]=f,t[16]=v,t[17]=b,t[18]=F):F=t[18];let I;t[19]!==g||t[20]!==f||t[21]!==M||t[22]!==v||t[23]!==b?(I=[v,f,g,b,M],t[19]=g,t[20]=f,t[21]=M,t[22]=v,t[23]=b,t[24]=I):I=t[24],(0,Z.useEffect)(F,I);let L=S&&S.docName===g?S:null,R=L!==null||_.kind===`unreachable`||_.kind===`at-capacity`,te=b&&b.docName===g?b:null,ne=te!==null&&!R,re,ie;t[25]===R?(re=t[26],ie=t[27]):(ie=()=>{!R&&T.current&&(T.current=!1,w.current?.focus())},re=[R],t[25]=R,t[26]=re,t[27]=ie),(0,Z.useEffect)(ie,re);let ae=R||_.kind===`empty`,oe,se;if(t[28]!==ae||t[29]!==l||t[30]!==c?(oe=()=>{l&&ae&&c?.(!1)},se=[l,ae,c],t[28]=ae,t[29]=l,t[30]=c,t[31]=oe,t[32]=se):(oe=t[31],se=t[32]),(0,Z.useEffect)(oe,se),!n){let e;t[33]===i?e=t[34]:(e=d(`excalidraw-embed flex min-h-16 w-full items-center justify-center rounded-md border border-dashed border-border/60 bg-muted/10 px-3 py-6 text-sm text-muted-foreground`,i),t[33]=i,t[34]=e);let n;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(a,{id:`WH3roC`}),t[35]=n):n=t[35];let r;return t[36]===e?r=t[37]:(r=(0,$.jsx)(`div`,{className:e,"data-component-type":`excalidraw`,children:n}),t[36]=e,t[37]=r),r}if(_.kind===`empty`){let e;t[38]===i?e=t[39]:(e=d(`excalidraw-embed flex min-h-16 w-full items-center justify-center rounded-md border border-dashed border-border/60 bg-muted/10 px-3 py-6 text-sm text-muted-foreground`,i),t[38]=i,t[39]=e);let n;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(a,{id:`AaC-CE`}),t[40]=n):n=t[40];let r;return t[41]===e?r=t[42]:(r=(0,$.jsx)(`div`,{className:e,"data-component-type":`excalidraw`,children:n}),t[41]=e,t[42]=r),r}let z=!R&&!te,B;t[43]!==u||t[44]!==L?.kind||t[45]!==_.kind?(B=_.kind===`at-capacity`?u({id:`dT-HIQ`}):_.kind===`unreachable`?u({id:`4Vgtaz`}):L?.kind===`module-load`?u({id:`pGYklE`}):L?.kind===`parse`?u({id:`LPLWpO`}):u({id:`U4ZE26`}),t[43]=u,t[44]=L?.kind,t[45]=_.kind,t[46]=B):B=t[46];let ce=B,V=R&&_.kind!==`at-capacity`&&g!==null,H;t[47]===i?H=t[48]:(H=d(`excalidraw-embed relative w-full overflow-hidden rounded-md border border-border/60 bg-muted/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,i),t[47]=i,t[48]=H);let U=z?!0:void 0,W;t[49]!==g||t[50]!==ce||t[51]!==V||t[52]!==R||t[53]!==n?(W=R?(0,$.jsxs)(`div`,{role:`alert`,className:`m-2 flex items-start gap-2 rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive`,children:[(0,$.jsx)(ji,{className:`size-3.5 shrink-0 mt-0.5`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:(0,$.jsx)(a,{id:`eh3QBq`})}),(0,$.jsx)(`div`,{className:`mt-1`,children:ce}),(0,$.jsx)(`div`,{className:`mt-1 break-words font-mono text-[11px] opacity-90`,children:g??n})]}),V?(0,$.jsx)(ee,{type:`button`,size:`sm`,variant:`outline`,className:`shrink-0 border-destructive/40 text-destructive hover:text-destructive`,"data-testid":`excalidraw-embed-retry`,onClick:()=>{T.current=!0,C(null),y(null),x(null),m(Qv)},children:(0,$.jsx)(a,{id:`KDw4GX`})}):null]}):null,t[49]=g,t[50]=ce,t[51]=V,t[52]=R,t[53]=n,t[54]=W):W=t[54];let le;t[55]!==u||t[56]!==g||t[57]!==te||t[58]!==R||t[59]!==r?(le=te&&!R?(0,$.jsx)(`div`,{className:`flex min-h-16 w-full items-center justify-center p-3`,"data-testid":`excalidraw-embed-snapshot`,children:(0,$.jsx)(`img`,{src:te.url,alt:r||u({id:`d-RYHO`}),draggable:!1,className:`h-auto max-h-[60vh] max-w-full`,onError:()=>{console.warn(`[ExcalidrawEmbed] snapshot image failed to decode:`,g,te?.url),g&&(T.current=!1,C({docName:g,kind:`export`}))}})}):null,t[55]=u,t[56]=g,t[57]=te,t[58]=R,t[59]=r,t[60]=le):le=t[60];let G;t[61]===z?G=t[62]:(G=z?(0,$.jsx)(Ya,{className:`m-3 min-h-16`,"aria-hidden":`true`}):null,t[61]=z,t[62]=G);let ue;t[63]!==u||t[64]!==g||t[65]!==R?(ue=g&&!R?(0,$.jsx)(ee,{asChild:!0,size:`icon-sm`,variant:`secondary`,className:`absolute top-2 right-2 border-border`,title:u({id:`6M2L3X`}),"data-testid":`excalidraw-embed-open`,children:(0,$.jsx)(`a`,{href:pa(g),"aria-label":u({id:`6M2L3X`}),children:(0,$.jsx)(Yl,{className:`size-4`,"aria-hidden":`true`})})}):null,t[63]=u,t[64]=g,t[65]=R,t[66]=ue):ue=t[66];let K=l&&ne,de;t[67]===c?de=t[68]:(de=e=>c?.(e),t[67]=c,t[68]=de);let fe=te?.url??null,pe;t[69]!==K||t[70]!==de||t[71]!==fe||t[72]!==r?(pe=(0,$.jsx)(ay,{open:K,onOpenChange:de,snapshotUrl:fe,title:r}),t[69]=K,t[70]=de,t[71]=fe,t[72]=r,t[73]=pe):pe=t[73];let q;return t[74]!==H||t[75]!==U||t[76]!==W||t[77]!==le||t[78]!==G||t[79]!==ue||t[80]!==pe?(q=(0,$.jsxs)(`div`,{ref:w,tabIndex:-1,className:H,"data-component-type":`excalidraw`,"aria-busy":U,children:[W,le,G,ue,pe]}),t[74]=H,t[75]=U,t[76]=W,t[77]=le,t[78]=G,t[79]=ue,t[80]=pe,t[81]=q):q=t[81],q}function Qv(e){return e+1}function $v(e){return e+1}function ey(){}function ty(){}var ny=.5,ry=4,iy=.25;function ay(e){let t=(0,Q.c)(33),{open:n,onOpenChange:r,snapshotUrl:i,title:a}=e,{_:s}=o(),c=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(!1),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=e=>{if(!e)return;let t=!1;wt().then(n=>{t||(c.current=n(e,{canvas:!0,cursor:`default`,maxScale:ry,minScale:ny,step:iy,noBind:!0,touchAction:`auto`}),u(!1))}).catch(e=>{console.warn(`[ExcalidrawEmbed] panzoom setup failed:`,e),t||u(!0)});let n=e=>{let t=c.current;if(!t)return;if(e.preventDefault(),e.ctrlKey||e.metaKey){t.zoomWithWheel(e);return}let n=typeof t.getScale==`function`?t.getScale():1,r=n>0?n:1;t.pan(-e.deltaX/r,-e.deltaY/r,{relative:!0})},r=e.parentElement;return r?.addEventListener(`wheel`,n,{passive:!1}),()=>{t=!0,r?.removeEventListener(`wheel`,n),c.current?.destroy(),c.current=null}},t[0]=d):d=t[0];let f=d,p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p={"--tw-enter-scale":`0.92`,"--tw-exit-scale":`0.92`},t[1]=p):p=t[1];let m;t[2]!==s||t[3]!==a?(m=a||s({id:`d-RYHO`}),t[2]=s,t[3]=a,t[4]=m):m=t[4];let h;t[5]===m?h=t[6]:(h=(0,$.jsx)(Ii,{className:`sr-only`,children:m}),t[5]=m,t[6]=h);let g;t[7]===s?g=t[8]:(g=s({id:`F8DaWi`}),t[7]=s,t[8]=g);let _;t[9]===g?_=t[10]:(_=(0,$.jsx)(`span`,{className:`absolute top-2 left-3 flex h-7 items-center text-xs text-muted-foreground`,children:g}),t[9]=g,t[10]=_);let v;t[11]!==s||t[12]!==i||t[13]!==a?(v=i?(0,$.jsx)(`img`,{ref:f,src:i,alt:a||s({id:`d-RYHO`}),draggable:!1,className:`max-h-full max-w-full`}):null,t[11]=s,t[12]=i,t[13]=a,t[14]=v):v=t[14];let y;t[15]===v?y=t[16]:(y=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,"data-testid":`excalidraw-lightbox-canvas`,children:v}),t[15]=v,t[16]=y);let b;t[17]===s?b=t[18]:(b=s({id:`iBei3o`}),t[17]=s,t[18]=b);let x;t[19]!==l||t[20]!==b?(x=(0,$.jsx)(Dt,{panzoomRef:c,label:b,testId:`excalidraw-lightbox-actions`,unavailable:l}),t[19]=l,t[20]=b,t[21]=x):x=t[21];let S;t[22]!==x||t[23]!==y?(S=(0,$.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 overflow-hidden`,children:[y,x]}),t[22]=x,t[23]=y,t[24]=S):S=t[24];let C;t[25]!==S||t[26]!==h||t[27]!==_?(C=(0,$.jsxs)(Li,{className:`h-[calc(100dvh-5rem)] w-[calc(100dvw-5rem)] max-w-none gap-0 p-2 pt-10 duration-200 sm:max-w-none`,style:p,children:[h,_,S]}),t[25]=S,t[26]=h,t[27]=_,t[28]=C):C=t[28];let w;return t[29]!==r||t[30]!==n||t[31]!==C?(w=(0,$.jsx)(Hi,{open:n,onOpenChange:r,children:C}),t[29]=r,t[30]=n,t[31]=C,t[32]=w):w=t[32],w}function oy(e){if(!e)return``;let t,n=null;try{let r=new URL(e,`https://placeholder.local`);n=r.protocol,t=r.pathname}catch{t=e.split(`?`)[0]??e}if(n===`data:`||n===`blob:`)return``;let r=t.split(`/`),i=r[r.length-1]??``;try{return decodeURIComponent(i)}catch{return i}}function sy(e){let t=(0,Q.c)(18),n;t[0]!==e.name||t[1]!==e.src?(n=e.name?.trim()||oy(e.src)||`Untitled file`,t[0]=e.name,t[1]=e.src,t[2]=n):n=t[2];let r=n,i=e.size?.trim()?e.size:null,a;t[3]===e.src?a=t[4]:(a=e.src?Lo(e.src):void 0,t[3]=e.src,t[4]=a);let o=a,s;t[5]===o?s=t[6]:(s=e=>{e.stopPropagation(),e.preventDefault(),o&&window.open(o,`_blank`,`noopener,noreferrer`)},t[5]=o,t[6]=s);let c=s,l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Zl,{className:`ok-file-icon`,"aria-hidden":`true`}),t[7]=l):l=t[7];let u;t[8]===r?u=t[9]:(u=(0,$.jsx)(`span`,{className:`ok-file-name`,children:r}),t[8]=r,t[9]=u);let d;t[10]===i?d=t[11]:(d=i?(0,$.jsx)(`span`,{className:`ok-file-size`,children:i}):null,t[10]=i,t[11]=d);let f;return t[12]!==c||t[13]!==o||t[14]!==e.title||t[15]!==u||t[16]!==d?(f=(0,$.jsxs)(`a`,{href:o,title:e.title,className:`ok-file-attachment`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:cy,onClick:c,children:[l,u,d]}),t[12]=c,t[13]=o,t[14]=e.title,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function cy(e){return e.stopPropagation()}function ly(){return Z.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-unzoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Z.createElement(`path`,{d:`M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z`}))}function uy(){return Z.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-zoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Z.createElement(`path`,{d:`M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z`}))}function dy(e){return typeof Element>`u`?!1:e instanceof Element}var fy=(e,t)=>dy(t)&&t.tagName.toUpperCase()===e,py=e=>fy(`DIV`,e)||fy(`SPAN`,e),my=e=>fy(`IMG`,e),hy=e=>e.complete&&e.naturalHeight!==0,gy=e=>fy(`SVG`,e),_y=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),vy=({containerHeight:e,containerWidth:t,offset:n,targetHeight:r,targetWidth:i})=>{let a=_y({height:r,offset:n,width:i}),o=i>r?i/t:r/e;return a>1?o:a*o},yy=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:i,targetWidth:a})=>e===0||t===0?1:!n&&i!==0&&a!==0?vy({containerHeight:e,containerWidth:t,offset:r,targetHeight:i,targetWidth:a}):_y({height:e,offset:r,width:t}),by=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,xy=e=>{if(e!==null){if(my(e))return e.currentSrc===``?void 0:e.currentSrc;if(py(e)){let{backgroundImage:t}=window.getComputedStyle(e);if(t!==``)return by.exec(t)?.[1]}}},Sy=e=>{if(e!==null)return my(e)?e.alt:e.getAttribute(`aria-label`)??void 0},Cy=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s})=>{let c=yy({containerHeight:e,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s});return{top:n,left:t,width:r*c,height:e*c,transform:`translate(0,0) scale(${1/c})`}},wy=({position:e,relativeNum:t})=>{let n=parseFloat(e);return e.endsWith(`%`)?t*n/100:n},Ty=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,objectFit:a,objectPosition:o,offset:s,targetHeight:c,targetWidth:l})=>{let u=a;if(u===`scale-down`&&(u=l<=r&&c<=e?`none`:`contain`),u===`cover`||u===`contain`){let a=r/l,d=e/c,f=u===`cover`?Math.max(a,d):Math.min(a,d),[p=`50%`,m=`50%`]=o.split(` `),h=wy({position:p,relativeNum:r-l*f}),g=wy({position:m,relativeNum:e-c*f}),_=yy({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+g,left:t+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(u===`none`){let[a=`50%`,u=`50%`]=o.split(` `),d=wy({position:a,relativeNum:r-l}),f=wy({position:u,relativeNum:e-c}),p=yy({containerHeight:c,containerWidth:l,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+f,left:t+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else if(u===`fill`){let t=r/l,n=e/c,a=Math.max(t,n),o=yy({containerHeight:c*a,containerWidth:l*a,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{width:r*o,height:e*o,transform:`translate(0,0) scale(${1/o})`}}else return{}},Ey=({backgroundPosition:e,backgroundSize:t,containerHeight:n,containerLeft:r,containerTop:i,containerWidth:a,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l})=>{if(t===`cover`||t===`contain`){let u=a/l,d=n/c,f=t===`cover`?Math.max(u,d):Math.min(u,d),[p=`50%`,m=`50%`]=e.split(` `),h=wy({position:p,relativeNum:a-l*f}),g=wy({position:m,relativeNum:n-c*f}),_=yy({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+g,left:r+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(t===`auto`){let[t=`50%`,u=`50%`]=e.split(` `),d=wy({position:t,relativeNum:a-l}),f=wy({position:u,relativeNum:n-c}),p=yy({containerHeight:c,containerWidth:l,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+f,left:r+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else{let[u=`50%`,d=`50%`]=t.split(` `),f=wy({position:u,relativeNum:a}),p=wy({position:d,relativeNum:n}),m=f/l,h=p/c,g=Math.min(m,h),[_=`50%`,v=`50%`]=e.split(` `),y=wy({position:_,relativeNum:a-l*g}),b=wy({position:v,relativeNum:n-c*g}),x=yy({containerHeight:c*g,containerWidth:l*g,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+b,left:r+y,width:l*g*x,height:c*g*x,transform:`translate(0,0) scale(${1/x})`}}},Dy=/\.svg$/i,Oy=({hasZoomImg:e,imgSrc:t,isSvg:n,isZoomed:r,loadedImgEl:i,offset:a,shouldRefresh:o,targetEl:s})=>{let c=n||t?.slice(0,18)===`data:image/svg+xml`||e||t!==void 0&&Dy.test(t),l=s.getBoundingClientRect(),u=window.getComputedStyle(s),d=i!=null&&py(s),f=i!=null&&!d,p=i!=null&&i.naturalHeight!==0?i.naturalHeight:l.height,m=i!=null&&i.naturalWidth!==0?i.naturalWidth:l.width,h=Cy({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}),g=f?Ty({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,objectFit:u.objectFit,objectPosition:u.objectPosition,offset:a,targetHeight:p,targetWidth:m}):void 0,_=d?Ey({backgroundPosition:u.backgroundPosition,backgroundSize:u.backgroundSize,containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}):void 0,v={...h,...g,..._};if(r){let e=window.innerWidth/2,t=window.innerHeight/2,n=parseFloat(String(v.left??0))+parseFloat(String(v.width??0))/2,r=parseFloat(String(v.top??0))+parseFloat(String(v.height??0))/2,i=e-n,a=t-r;o&&(v.transitionDuration=`0.01ms`),v.transform=`translate(${i}px,${a}px) scale(1)`}return v},ky=e=>{if(e==null)return{};if(gy(e)){let{parentElement:t}=e,n=e.getBoundingClientRect();if(t==null)return{height:n.height,left:n.left,width:n.width,top:n.top};{let e=t.getBoundingClientRect();return{height:n.height,left:e.left-n.left,top:e.top-n.top,width:n.width}}}else return{height:e.offsetHeight,left:e.offsetLeft,width:e.offsetWidth,top:e.offsetTop}},Ay=e=>{let t=`-zoom`,n=[`clip-path`,`fill`,`mask`,`marker-start`,`marker-mid`,`marker-end`],r=new Map;if(e.hasAttribute(`id`)){let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}e.querySelectorAll(`[id]`).forEach(e=>{let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}),r.forEach((t,r)=>{let i=`url(#${r})`,a=`url(#${t})`,o=n.map(e=>`[${e}="${i}"]`).join(`, `);e.querySelectorAll(o).forEach(e=>{n.forEach(t=>{e.getAttribute(t)===i&&e.setAttribute(t,a)})})}),e.querySelectorAll(`style`).forEach(e=>{r.forEach((t,n)=>{let{textContent:r}=e;if(r!==``){let i=e;i.textContent=r.replaceAll(`#${n}`,`#${t}`)}})})},jy=[`img`,`svg`,`[role="img"]`,`[data-zoom]`].map(e=>`${e}:not([aria-hidden="true"])`).join(`,`),My={overflow:``,width:``};function Ny(){let e=document.querySelector(`[data-rmiz-portal]`);if(e!=null)return e;let t=document.createElement(`div`);return t.setAttribute(`data-rmiz-portal`,``),document.body.appendChild(t),t}function Py(e){e.preventDefault()}function Fy(e){return Z.createElement(Iy,{...e})}var Iy=class extends Z.Component{constructor(){super(...arguments),this.state={id:``,isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:`UNLOADED`,shouldRefresh:!1,styleGhost:{}},this.refContent=Z.createRef(),this.refDialog=Z.createRef(),this.refModalContent=Z.createRef(),this.refModalImg=Z.createRef(),this.refWrap=Z.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=My,this.styleModalImg={},this.handleModalStateChange=e=>{let{state:{modalState:t}}=this;e!==`LOADING`&&t===`LOADING`?(this.loadZoomImg(),window.addEventListener(`resize`,this.handleResize,{passive:!0}),window.addEventListener(`touchstart`,this.handleTouchStart,{passive:!0}),window.addEventListener(`touchmove`,this.handleTouchMove,{passive:!0}),window.addEventListener(`touchend`,this.handleTouchEnd,{passive:!0}),window.addEventListener(`touchcancel`,this.handleTouchCancel,{passive:!0}),document.addEventListener(`keydown`,this.handleKeyDown,!0)):e!==`LOADED`&&t===`LOADED`?window.addEventListener(`wheel`,this.handleWheel,{passive:!0}):e!==`UNLOADING`&&t===`UNLOADING`?(this.ensureImgTransitionEnd(),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),document.removeEventListener(`keydown`,this.handleKeyDown,!0)):e!==`UNLOADED`&&t===`UNLOADED`&&(this.bodyScrollEnable(),window.removeEventListener(`resize`,this.handleResize),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),this.refDialog.current?.close())},this.setId=()=>{let e=()=>Math.random().toString(16).slice(-4);this.setState({id:e()+e()+e()})},this.setAndTrackImg=()=>{let{refContent:{current:e}}=this;e!=null&&(this.imgEl=e.querySelector(jy),this.imgEl===null?this.contentNotFoundChangeObserver??(this.contentNotFoundChangeObserver=new MutationObserver(this.setAndTrackImg),this.contentNotFoundChangeObserver.observe(e,{childList:!0,subtree:!0})):(this.contentNotFoundChangeObserver?.disconnect(),this.imgEl.addEventListener(`load`,this.handleImgLoad),this.imgEl.addEventListener(`click`,this.handleZoom),this.state.loadedImgEl??this.handleImgLoad(),this.imgElResizeObserver=new ResizeObserver(e=>{let[t]=e;t?.target!==void 0&&(this.imgEl=t.target,this.setState({styleGhost:ky(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver??(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:ky(this.imgEl)})}),this.contentChangeObserver.observe(e,{attributes:!0,childList:!0,subtree:!0}))))},this.handleIfZoomChanged=e=>{let{props:{isZoomed:t}}=this;!e&&t?this.zoom():e&&!t&&this.unzoom()},this.handleImgLoad=()=>{let e=xy(this.imgEl);if(e==null||e===``)return;let t=new Image,{imgEl:n}=this;if(my(n)){let{sizes:e,srcset:r,crossOrigin:i}=n;t.sizes=e,t.srcset=r,t.crossOrigin=i}t.src=e;let r=()=>{this.setState({loadedImgEl:t,styleGhost:ky(this.imgEl)})};t.decode().then(r).catch(()=>{if(hy(t)){r();return}t.onload=r})},this.handleZoom=e=>{this.props.isDisabled!==!0&&this.hasImage()&&this.props.onZoomChange?.(!0,{event:e})},this.handleUnzoom=e=>{this.props.isDisabled!==!0&&this.props.onZoomChange?.(!1,{event:e})},this.handleBtnUnzoomClick=e=>{e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e)},this.handleDialogClick=e=>{(e.target===this.refModalContent.current||e.target===this.refModalImg.current)&&(e.stopPropagation(),this.handleUnzoom(e))},this.handleDialogClose=e=>{e.stopPropagation(),this.handleUnzoom(e)},this.handleKeyDown=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e))},this.handleWheel=e=>{e.ctrlKey||(e.stopPropagation(),queueMicrotask(()=>{this.handleUnzoom(e)}))},this.handleTouchStart=e=>{if(e.touches.length>1){this.isScaling=!0;return}let{changedTouches:t}=e,[n]=t;if(t.length===1&&n!==void 0){let{screenY:e}=n;this.touchYStart=e}},this.handleTouchMove=e=>{let t=window.visualViewport?.scale??1,{changedTouches:n}=e,[r]=n;if(this.props.canSwipeToUnzoom&&!this.isScaling&&t<=1&&this.touchYStart!=null&&r!==void 0){let{screenY:t}=r;this.touchYEnd=t;let n=Math.max(this.touchYStart,this.touchYEnd),i=Math.min(this.touchYStart,this.touchYEnd);Math.abs(n-i)>this.props.swipeToUnzoomThreshold&&(this.touchYStart=void 0,this.touchYEnd=void 0,this.handleUnzoom(e))}},this.handleTouchEnd=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleTouchCancel=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleResize=()=>{this.setState({shouldRefresh:!0})},this.hasImage=()=>this.imgEl!==null&&(this.state.loadedImgEl!==void 0||gy(this.imgEl))&&window.getComputedStyle(this.imgEl).display!==`none`,this.zoom=()=>{this.bodyScrollDisable(),this.refDialog.current?.showModal(),this.refModalImg.current?.addEventListener(`transitionend`,this.handleImgTransitionEnd),this.setState({modalState:`LOADING`})},this.unzoom=()=>{this.setState({modalState:`UNLOADING`})},this.handleImgTransitionEnd=()=>{clearTimeout(this.timeoutTransitionEnd),this.state.modalState===`LOADING`?this.setState({modalState:`LOADED`}):this.state.modalState===`UNLOADING`&&this.setState({shouldRefresh:!1,modalState:`UNLOADED`})},this.ensureImgTransitionEnd=()=>{if(this.refModalImg.current!==null){let{transitionDuration:e}=window.getComputedStyle(this.refModalImg.current),t=parseFloat(e);if(t!==0&&!Number.isNaN(t)){let n=t*(e.endsWith(`ms`)?1:1e3)+50;this.timeoutTransitionEnd=setTimeout(this.handleImgTransitionEnd,n)}}},this.bodyScrollDisable=()=>{this.prevBodyAttrs={overflow:document.body.style.overflow,width:document.body.style.width};let{body:{clientWidth:e}}=document;document.body.style.overflow=`hidden`,document.body.style.width=`${e}px`},this.bodyScrollEnable=()=>{let{prevBodyAttrs:{overflow:e,width:t}}=this;document.body.style.width=t,document.body.style.overflow=e,this.prevBodyAttrs=My},this.loadZoomImg=()=>{let{props:{zoomImg:e}}=this;if(e==null)return;let{src:t}=e;if(t!==void 0&&t!==``){let n=new Image;n.sizes=e.sizes??``,n.srcset=e.srcSet??``,n.crossOrigin=e.crossOrigin??void 0,n.src=t;let r=()=>{this.setState({isZoomImgLoaded:!0})};n.decode().then(r).catch(()=>{if(hy(n)){r();return}n.onload=r})}},this.UNSAFE_handleSvg=()=>{let{imgEl:e,refModalImg:t,styleModalImg:n}=this;if(gy(e)){let r=e.cloneNode(!0);Ay(r),r.style.width=`${n.width??0}px`,r.style.height=`${n.height??0}px`,r.addEventListener(`click`,this.handleUnzoom),t.current?.firstChild?.remove(),t.current?.appendChild(r)}}}render(){let{handleBtnUnzoomClick:e,handleDialogClick:t,handleDialogClose:n,handleUnzoom:r,handleZoom:i,imgEl:a,props:{a11yNameButtonUnzoom:o,a11yNameButtonZoom:s,children:c,classDialog:l,IconUnzoom:u,IconZoom:d,isZoomed:f,wrapElement:p,ZoomContent:m,zoomImg:h,zoomMargin:g},refContent:_,refDialog:v,refModalContent:y,refModalImg:b,refWrap:x,state:{id:S,isZoomImgLoaded:C,loadedImgEl:w,modalState:T,shouldRefresh:E,styleGhost:D}}=this,O=`rmiz-modal-${S}`,k=`rmiz-modal-img-${S}`,A=py(a),j=my(a),M=gy(a),N=Sy(a),P=xy(a),F=j?a.sizes:void 0,I=j?a.srcset:void 0,L=j?a.crossOrigin:void 0,ee=h?.src!==void 0&&h.src!==``,R=this.hasImage(),te=N!==void 0&&N!==``?`${s}: ${N}`:s,ne=T===`LOADING`||T===`LOADED`,re=R?`found`:`not-found`,ie=T===`UNLOADED`||T===`UNLOADING`?`hidden`:`visible`,ae={visibility:T===`UNLOADED`?`visible`:`hidden`};this.styleModalImg=R&&a!==null?Oy({hasZoomImg:ee,imgSrc:P,isSvg:M,isZoomed:f&&ne,loadedImgEl:w,offset:g,shouldRefresh:E,targetEl:a}):{};let oe=null;if(R){let t=j||A?Z.createElement(`img`,{alt:N,crossOrigin:L,sizes:F,src:P,srcSet:I,...C&&T===`LOADED`?h:{},"data-rmiz-modal-img":``,height:this.styleModalImg.height??void 0,id:k,ref:b,style:this.styleModalImg,width:this.styleModalImg.width??void 0}):M?Z.createElement(`div`,{"data-rmiz-modal-img":!0,ref:b,style:this.styleModalImg}):null,n=Z.createElement(`button`,{"aria-label":o,"data-rmiz-btn-unzoom":``,onClick:e,type:`button`},Z.createElement(u,null));oe=m==null?Z.createElement(Z.Fragment,null,t,n):Z.createElement(m,{buttonUnzoom:n,modalState:T,img:t,isZoomImgLoaded:C,onUnzoom:r})}return Z.createElement(p,{"aria-owns":R?O:void 0,"data-rmiz":``,ref:x},Z.createElement(p,{"data-rmiz-content":re,ref:_,style:ae},c),R&&Z.createElement(p,{"data-rmiz-ghost":``,style:D},Z.createElement(`button`,{"aria-label":te,"data-rmiz-btn-zoom":``,onClick:i,type:`button`},Z.createElement(d,null))),R&&Ss.createPortal(Z.createElement(`dialog`,{"aria-labelledby":k,"aria-modal":`true`,className:l,"data-rmiz-modal":``,id:O,onClick:t,onClose:n,onCancel:Py,ref:v,role:`dialog`},Z.createElement(`div`,{"data-rmiz-modal-overlay":ie}),Z.createElement(`div`,{"data-rmiz-modal-content":``,ref:y},oe)),Ny()))}componentDidMount(){this.setId(),this.setAndTrackImg(),this.handleImgLoad(),this.UNSAFE_handleSvg()}componentWillUnmount(){this.state.modalState!==`UNLOADED`&&this.bodyScrollEnable(),this.contentChangeObserver?.disconnect(),this.contentNotFoundChangeObserver?.disconnect(),this.imgElResizeObserver?.disconnect(),this.imgEl?.removeEventListener(`load`,this.handleImgLoad),this.imgEl?.removeEventListener(`click`,this.handleZoom),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),window.removeEventListener(`resize`,this.handleResize),document.removeEventListener(`keydown`,this.handleKeyDown,!0)}componentDidUpdate(e,t){this.handleModalStateChange(t.modalState),this.UNSAFE_handleSvg(),this.handleIfZoomChanged(e.isZoomed)}};Iy.defaultProps={a11yNameButtonUnzoom:`Minimize image`,a11yNameButtonZoom:`Expand image`,canSwipeToUnzoom:!0,IconUnzoom:ly,IconZoom:uy,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:`div`,zoomMargin:0};function Ly({onZoomChange:e,...t}){let[n,r]=Z.useState(!1),i=Z.useCallback((t,{event:n})=>{r(t),e?.(t,{event:n})},[e]);return Z.createElement(Fy,{...t,isZoomed:n,onZoomChange:i})}var Ry=e(t(((e,t)=>{(function(e){let n=`(0?\\d+|0x[a-f0-9]+)`,r={fourOctet:RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,`i`),threeOctet:RegExp(`^${n}\\.${n}\\.${n}$`,`i`),twoOctet:RegExp(`^${n}\\.${n}$`,`i`),longValue:RegExp(`^${n}$`,`i`)},i=RegExp(`^0[0-7]+$`,`i`),a=RegExp(`^0x[a-f0-9]+$`,`i`),o=`%[0-9a-z]{1,}`,s=`(?:[0-9a-f]+::?)+`,c={zoneIndex:new RegExp(o,`i`),native:RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,`i`),deprecatedTransitional:RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,`i`),transitional:RegExp(`^((?:${s})|(?:::)(?:${s})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,`i`)};function l(e,t){if(e.indexOf(`::`)!==e.lastIndexOf(`::`))return null;let n=0,r=-1,i=(e.match(c.zoneIndex)||[])[0],a,o;for(i&&(i=i.substring(1),e=e.replace(/%.+$/,``));(r=e.indexOf(`:`,r+1))>=0;)n++;if(e.substr(0,2)===`::`&&n--,e.substr(-2,2)===`::`&&n--,n>t)return null;for(o=t-n,a=`:`;o--;)a+=`0:`;return e=e.replace(`::`,a),e[0]===`:`&&(e=e.slice(1)),e[e.length-1]===`:`&&(e=e.slice(0,-1)),t=(function(){let t=e.split(`:`),n=[];for(let e=0;e<t.length;e++)n.push(parseInt(t[e],16));return n})(),{parts:t,zoneId:i}}function u(e,t,n,r){if(e.length!==t.length)throw Error(`ipaddr: cannot match CIDR for objects with different lengths`);let i=0,a;for(;r>0;){if(a=n-r,a<0&&(a=0),e[i]>>a!==t[i]>>a)return!1;r-=n,i+=1}return!0}function d(e){if(a.test(e))return parseInt(e,16);if(e[0]===`0`&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function f(e,t){for(;e.length<t;)e=`0${e}`;return e}let p={};p.IPv4=(function(){function e(e){if(e.length!==4)throw Error(`ipaddr: ipv4 octet count should be 4`);let t,n;for(t=0;t<e.length;t++)if(n=e[t],!(0<=n&&n<=255))throw Error(`ipaddr: ipv4 octet should fit in 8 bits`);this.octets=e}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]],as112:[[new e([192,175,48,0]),24],[new e([192,31,196,0]),24]],amt:[[new e([192,52,193,0]),24]]},e.prototype.kind=function(){return`ipv4`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv4`)throw Error(`ipaddr: cannot match ipv4 address with non-ipv4 one`);return u(this.octets,e.octets,8,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},r,i,a;for(r=3;r>=0;--r)if(i=this.octets[r],i in n){if(a=n[i],t&&a!==0)return null;a!==8&&(t=!0),e+=a}else return null;return 32-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(`.`)},e})(),p.IPv4.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<4;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch{throw Error(`ipaddr: the address does not have IPv4 CIDR format`)}},p.IPv4.isIPv4=function(e){return this.parser(e)!==null},p.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch{return!1}},p.IPv4.isValidCIDR=function(e){try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(e){return!!(p.IPv4.isValid(e)&&e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.isValidCIDRFourPartDecimal=function(e){let t=e.match(/^(.+)\/(\d+)$/);return!p.IPv4.isValidCIDR(e)||!t?!1:p.IPv4.isValidFourPartDecimal(t[1])},p.IPv4.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch{throw Error(`ipaddr: the address does not have IPv4 CIDR format`)}},p.IPv4.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv4 Address`);return new this(t)},p.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){let e=parseInt(t[2]);if(e>=0&&e<=32){let n=[this.parse(t[1]),e];return Object.defineProperty(n,`toString`,{value:function(){return this.join(`/`)}}),n}}throw Error(`ipaddr: string is not formatted like an IPv4 CIDR range`)},p.IPv4.parser=function(e){let t,n,i;if(t=e.match(r.fourOctet))return(function(){let e=t.slice(1,6),r=[];for(let t=0;t<e.length;t++)n=e[t],r.push(d(n));return r})();if(t=e.match(r.longValue)){if(i=d(t[1]),i>4294967295||i<0)throw Error(`ipaddr: address outside defined range`);return(function(){let e=[],t;for(t=0;t<=24;t+=8)e.push(i>>t&255);return e})().reverse()}else if(t=e.match(r.twoOctet))return(function(){let e=t.slice(1,4),n=[];if(i=d(e[1]),i>16777215||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(i>>16&255),n.push(i>>8&255),n.push(i&255),n})();else if(t=e.match(r.threeOctet))return(function(){let e=t.slice(1,5),n=[];if(i=d(e[2]),i>65535||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(d(e[1])),n.push(i>>8&255),n.push(i&255),n})();else return null},p.IPv4.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),e<0||e>32)throw Error(`ipaddr: invalid IPv4 prefix length`);let t=[0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<4&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.IPv6=(function(){function e(e,t){let n,r;if(e.length===16)for(this.parts=[],n=0;n<=14;n+=2)this.parts.push(e[n]<<8|e[n+1]);else if(e.length===8)this.parts=e;else throw Error(`ipaddr: ipv6 part count should be 8 or 16`);for(n=0;n<this.parts.length;n++)if(r=this.parts[n],!(0<=r&&r<=65535))throw Error(`ipaddr: ipv6 part should fit in 16 bits`);t&&(this.zoneId=t)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],deprecatedSiteLocal:[new e([65216,0,0,0,0,0,0,0]),10],discard:[new e([256,0,0,0,0,0,0,0]),64],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[[new e([100,65435,0,0,0,0,0,0]),96],[new e([100,65435,1,0,0,0,0,0]),48]],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[[new e([8193,4,274,0,0,0,0,0]),48],[new e([9760,79,32768,0,0,0,0,0]),48]],deprecatedOrchid:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new e([8193,48,0,0,0,0,0,0]),28],segmentRouting:[new e([24320,0,0,0,0,0,0,0]),16],reserved:[[new e([8193,0,0,0,0,0,0,0]),23],[new e([8193,3512,0,0,0,0,0,0]),32],[new e([16383,0,0,0,0,0,0,0]),20]]},e.prototype.isIPv4MappedAddress=function(){return this.range()===`ipv4Mapped`},e.prototype.kind=function(){return`ipv6`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv6`)throw Error(`ipaddr: cannot match ipv6 address with non-ipv6 one`);return u(this.parts,e.parts,16,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},r,i;for(let a=7;a>=0;--a)if(r=this.parts[a],r in n){if(i=n[r],t&&i!==0)return null;i!==16&&(t=!0),e+=i}else return null;return 128-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e,t=[],n=this.parts;for(let r=0;r<n.length;r++)e=n[r],t.push(e>>8),t.push(e&255);return t},e.prototype.toFixedLengthString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(f(this.parts[t].toString(16),4));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw Error(`ipaddr: trying to convert a generic ipv6 address to ipv4`);let e=this.parts.slice(-2),t=e[0],n=e[1];return new p.IPv4([t>>8,t&255,n>>8,n&255])},e.prototype.toNormalizedString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(this.parts[t].toString(16));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toRFC5952String=function(){let e=/((^|:)(0(:|$)){2,})/g,t=this.toNormalizedString(),n=0,r=-1,i;for(;i=e.exec(t);)i[0].length>r&&(n=i.index,r=i[0].length);return r<0?t:`${t.substring(0,n)}::${t.substring(n+r)}`},e.prototype.toString=function(){return this.toRFC5952String()},e})(),p.IPv6.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<16;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`)}},p.IPv6.isIPv6=function(e){return this.parser(e)!==null},p.IPv6.isValid=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{let t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch{return!1}},p.IPv6.isValidCIDR=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<16;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`)}},p.IPv6.parse=function(e){let t=this.parser(e);if(t.parts===null)throw Error(`ipaddr: string is not formatted like an IPv6 Address`);return new this(t.parts,t.zoneId)},p.IPv6.parseCIDR=function(e){let t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=128))return r=[this.parse(n[1]),t],Object.defineProperty(r,`toString`,{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv6 CIDR range`)},p.IPv6.parser=function(e){let t,n,r,i,a,o;if(r=e.match(c.deprecatedTransitional))return this.parser(`::ffff:${r[1]}`);if(c.native.test(e))return l(e,8);if((r=e.match(c.transitional))&&(o=r[6]||``,t=r[1],r[1].endsWith(`::`)||(t=t.slice(0,-1)),t=l(t+o,6),t.parts)){for(a=[parseInt(r[2]),parseInt(r[3]),parseInt(r[4]),parseInt(r[5])],n=0;n<a.length;n++)if(i=a[n],!(0<=i&&i<=255))return null;return t.parts.push(a[0]<<8|a[1]),t.parts.push(a[2]<<8|a[3]),{parts:t.parts,zoneId:t.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),e<0||e>128)throw Error(`ipaddr: invalid IPv6 prefix length`);let t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<16&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.fromByteArray=function(e){let t=e.length;if(t===4)return new p.IPv4(e);if(t===16)return new p.IPv6(e);throw Error(`ipaddr: the binary input is neither an IPv6 nor IPv4 address`)},p.isValid=function(e){return p.IPv6.isValid(e)||p.IPv4.isValid(e)},p.isValidCIDR=function(e){return p.IPv6.isValidCIDR(e)||p.IPv4.isValidCIDR(e)},p.parse=function(e){if(p.IPv6.isValid(e))return p.IPv6.parse(e);if(p.IPv4.isValid(e))return p.IPv4.parse(e);throw Error(`ipaddr: the address has neither IPv6 nor IPv4 format`)},p.parseCIDR=function(e){try{return p.IPv6.parseCIDR(e)}catch{try{return p.IPv4.parseCIDR(e)}catch{throw Error(`ipaddr: the address has neither IPv6 nor IPv4 CIDR format`)}}},p.process=function(e){let t=this.parse(e);return t.kind()===`ipv6`&&t.isIPv4MappedAddress()?t.toIPv4Address():t},p.subnetMatch=function(e,t,n){let r,i,a,o;for(i in n??=`unicast`,t)if(Object.prototype.hasOwnProperty.call(t,i)){for(a=t[i],a[0]&&!(a[0]instanceof Array)&&(a=[a]),r=0;r<a.length;r++)if(o=a[r],e.kind()===o[0].kind()&&e.match.apply(e,o))return i}return n},t!==void 0&&t.exports?t.exports=p:e.ipaddr=p})(e)}))(),1),zy=new Set([`href`,`src`,`srcset`,`poster`,`formaction`,`xlink:href`]),By=new Set([`aria-label`,`aria-description`,`title`]),Vy=/(?:[a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^\s"'<>]+|(?:javascript|vbscript|data|file|chrome-extension|moz-extension):[^\s"'<>]*)/gi,Hy=/url\s*\(\s*['"]?\s*(?:javascript|vbscript|data)\s*:/i,Uy=/\bexpression\s*\(/i,Wy=/(oklch|oklab|lab|lch)\(\s*([^)]+)\s*\)/gi,Gy=`data-clipboard-omit`;function Ky(e){let t=e.trim();return t===``||Xi.test(t)?!0:Qi(t)}function qy(e){let t=e.split(`,`);for(let e of t){let t=e.trim();if(t!==``&&!Ky(t.split(/\s+/)[0]??``))return!1}return!0}function Jy(e,t){let n=!1,r=e.replace(Vy,e=>Ky(e)?e:(n=!0,`[blocked]`));return t?.reportNoChange&&!n?null:r}function Yy(e){let t=e.toLowerCase();return t.length>=3&&t.startsWith(`on`)}function Xy(e){return e.length>1e4||Hy.test(e)||Uy.test(e)?``:e}function Zy(e){let t=e.indexOf(`/`),n=(t===-1?e:e.slice(0,t)).trim(),r=t===-1?null:e.slice(t+1).trim(),i=n.split(/[\s,]+/).filter(e=>e.length>0);if(i.length!==3)return null;let a=Qy(i[0],1),o=Qy(i[1],1),s=Qy(i[2],1);if(Number.isNaN(a)||Number.isNaN(o)||Number.isNaN(s))return null;let c=null;if(r!==null){if(c=Qy(r,1),Number.isNaN(c))return null;c=Math.max(0,Math.min(1,c))}return[a,o,s,c]}function Qy(e,t){return e===`none`?0:e.endsWith(`%`)?Number.parseFloat(e.slice(0,-1))/100*t:Number.parseFloat(e)}function $y(e,t,n){let r=n*Math.PI/180;return[e,t*Math.cos(r),t*Math.sin(r)]}function eb(e,t,n){let r=e+.3963377774*t+.2158037573*n,i=e-.1055613458*t-.0638541728*n,a=e-.0894841775*t-1.291485548*n,o=r**3,s=i**3,c=a**3;return[4.0767416621*o-3.3077115913*s+.2309699292*c,-1.2684380046*o+2.6097574011*s-.3413193965*c,-.0041960863*o-.7034186147*s+1.707614701*c]}function tb(e){return e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055}function nb(e){return Number.isFinite(e)?Math.max(0,Math.min(255,Math.round(e*255))):0}function rb(e,t,n,r){let i=e.toLowerCase(),a,o,s;i===`oklch`?[a,o,s]=$y(t,n,r):i===`oklab`?[a,o,s]=[t,n,r]:i===`lch`?[a,o,s]=$y(t/100,n/100,r):[a,o,s]=[t/100,n/100,r/100];let[c,l,u]=eb(a,o,s);return[nb(tb(c)),nb(tb(l)),nb(tb(u))]}function ib(e){if(e.length>1e4)return e;let t=e.toLowerCase();return!t.includes(`oklch`)&&!t.includes(`oklab`)&&!t.includes(`lab`)&&!t.includes(`lch`)?e:e.replace(Wy,(e,t,n)=>{let r=Zy(n);if(r===null)return e;let[i,a,o,s]=r,[c,l,u]=rb(t,i,a,o);return s===null?`rgb(${c}, ${l}, ${u})`:`rgba(${c}, ${l}, ${u}, ${s})`})}var ab=new Set([`mailto`,`tel`,`sms`,`ftp`,`ftps`]);function ob(e){let t=e.trim();if(t.startsWith(`#`))return{portable:!0};if(Qi(t))return t.startsWith(`/`)?{portable:!1,reason:`server-absolute`}:{portable:!1,reason:`relative`};let n=new URL(t),r=n.protocol.slice(0,-1).toLowerCase();if(ab.has(r))return{portable:!0};if(r!==`http`&&r!==`https`)return{portable:!1,reason:`other`};let i=n.hostname.toLowerCase();if(i===``)return{portable:!1,reason:`other`};let a=i.endsWith(`.`)?i.slice(0,-1):i;if(a===`localhost`||a.endsWith(`.localhost`))return{portable:!1,reason:`localhost`};let o=i.startsWith(`[`)&&i.endsWith(`]`)?i.slice(1,-1):i;return Ry.IPv4.isValid(o)?Ry.IPv4.parse(o).range()===`unicast`?{portable:!0}:{portable:!1,reason:`private-ip`}:Ry.IPv6.isValid(o)?Ry.IPv6.parse(o).range()===`unicast`?{portable:!0}:{portable:!1,reason:`private-ip`}:{portable:!0}}function sb(e,t){return typeof e==`number`&&typeof t==`number`&&e>0&&t>0}function cb(e,t,n){return sb(e,t)?{...n,width:`${e}px`,aspectRatio:`${e} / ${t}`}:n}function lb(e){let t=(0,Q.c)(75),n,r,i,a,s,c,l,u,f,p,m,h,g;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],s=t[5],c=t[6],l=t[7],u=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13]):({width:g,height:r,loadingTestId:f,slotTestId:p,slotClassName:c,className:n,onLoad:s,onError:a,src:l,style:u,alt:m,targetExistence:h,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=f,t[10]=p,t[11]=m,t[12]=h,t[13]=g);let _=f===void 0?`image-loading-skeleton`:f,v=p===void 0?`image-slot`:p,y=m===void 0?``:m,b=h===void 0?`unknown`:h,{_:x}=o(),S=(0,Z.useRef)(null),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(0),k;t[14]!==r||t[15]!==g?(k=sb(g,r),t[14]=r,t[15]=g,t[16]=k):k=t[16];let A=k,j;t[17]!==r||t[18]!==u||t[19]!==g?(j=cb(g,r,u),t[17]=r,t[18]=u,t[19]=g,t[20]=j):j=t[20];let M=j,N;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>{let e=S.current;if(e?.complete){if(w(!0),E(!1),typeof e.decode==`function`){let t=!1;return e.decode().then(db,()=>{t||E(!0)}),()=>{t=!0}}}else w(!1),E(!1)},t[21]=N):N=t[21];let P;t[22]!==D||t[23]!==l?(P=[l,D],t[22]=D,t[23]=l,t[24]=P):P=t[24],(0,Z.useLayoutEffect)(N,P);let F=(0,Z.useRef)(b),I,L;t[25]===b?(I=t[26],L=t[27]):(L=()=>{let e=F.current;F.current=b,e===`missing`&&b!==`missing`&&(w(!1),E(!1),O(ub))},I=[b],t[25]=b,t[26]=I,t[27]=L),(0,Z.useEffect)(L,I);let ee=b===`missing`?`not-found`:T?`undisplayable`:null,R=y&&y.length>0?y:l??``,te;t[28]!==x||t[29]!==ee?(te=x(ee===`not-found`?{id:`1pdLQw`}:{id:`XGKy1z`}),t[28]=x,t[29]=ee,t[30]=te):te=t[30];let ne=te,re;t[31]!==x||t[32]!==ee||t[33]!==R?(re=x(ee===`not-found`?{id:`kI5pWt`,values:{errorLabel:R}}:{id:`VZg6Gn`,values:{errorLabel:R}}),t[31]=x,t[32]=ee,t[33]=R,t[34]=re):re=t[34];let ie=re,ae=ee?`true`:void 0,oe=ee??void 0,se=!A&&!C&&!ee&&`aspect-[16/9] w-full max-w-full`,z;t[35]!==c||t[36]!==se?(z=d(`relative inline-block overflow-hidden`,se,c),t[35]=c,t[36]=se,t[37]=z):z=t[37];let B;t[38]!==x||t[39]!==ee||t[40]!==C||t[41]!==_?(B=!C&&!ee&&(0,$.jsx)(`span`,{"data-testid":_,role:`status`,"aria-busy":`true`,"aria-label":x({id:`N1YYa7`}),className:`absolute inset-0 animate-pulse rounded-md bg-foreground/10 motion-reduce:animate-none`}),t[38]=x,t[39]=ee,t[40]=C,t[41]=_,t[42]=B):B=t[42];let ce=ee?!0:void 0,V=C?`opacity-100`:`opacity-0`,H;t[43]!==n||t[44]!==V?(H=d(`block max-w-full transition-opacity motion-reduce:transition-none`,V,n),t[43]=n,t[44]=V,t[45]=H):H=t[45];let U;t[46]===s?U=t[47]:(U=e=>{w(!0),E(!1),s?.(e)},t[46]=s,t[47]=U);let W;t[48]===a?W=t[49]:(W=e=>{w(!0),E(!0),a?.(e)},t[48]=a,t[49]=W);let le;t[50]!==y||t[51]!==r||t[52]!==i||t[53]!==D||t[54]!==l||t[55]!==ce||t[56]!==H||t[57]!==U||t[58]!==W||t[59]!==g?(le=(0,Z.createElement)(`img`,{...i,key:D,ref:S,src:l,alt:y,width:g,height:r,hidden:ce,className:H,onLoad:U,onError:W}),t[50]=y,t[51]=r,t[52]=i,t[53]=D,t[54]=l,t[55]=ce,t[56]=H,t[57]=U,t[58]=W,t[59]=g,t[60]=le):le=t[60];let G;t[61]!==ie||t[62]!==ee||t[63]!==ne||t[64]!==l?(G=ee&&(0,$.jsxs)(`span`,{role:`img`,"aria-label":ie,"data-clipboard-omit":`true`,className:`ok-image-error-placeholder box-border inline-grid max-w-full grid-cols-[auto_minmax(0,1fr)] items-start gap-x-2 rounded-md border border-dashed px-2 py-1 text-foreground`,children:[(0,$.jsx)(ru,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`ok-image-error-message block text-xs font-medium`,children:ne}),l?(0,$.jsx)(`span`,{className:`ok-image-error-target block max-w-[24ch] truncate font-mono text-xs`,title:l,children:l}):null]})]}),t[61]=ie,t[62]=ee,t[63]=ne,t[64]=l,t[65]=G):G=t[65];let ue;return t[66]!==M||t[67]!==v||t[68]!==ae||t[69]!==oe||t[70]!==z||t[71]!==B||t[72]!==le||t[73]!==G?(ue=(0,$.jsxs)(`span`,{"data-testid":v,"data-image-error":ae,"data-image-error-kind":oe,className:z,style:M,children:[B,le,G]}),t[66]=M,t[67]=v,t[68]=ae,t[69]=oe,t[70]=z,t[71]=B,t[72]=le,t[73]=G,t[74]=ue):ue=t[74],ue}function ub(e){return e+1}function db(){}function fb(e,t,n,r){return po(e,t,{literal:!1})===null?`unknown`:ur(e,t,n,r,{literal:!1})?`exists`:`missing`}function pb(e){let t=(0,Q.c)(4),n=ts();if(e===void 0||e===``)return`missing`;if(n===null||n.loading)return`unknown`;let r;return t[0]!==n.assetPaths||t[1]!==n.filePaths||t[2]!==e?(r=fb(e,``,n.assetPaths,n.filePaths),t[0]=n.assetPaths,t[1]=n.filePaths,t[2]=e,t[3]=r):r=t[3],r}function mb(e){return e??`lazy`}function hb(e){if(typeof e!=`string`)return e;let t=Number(e);return Number.isFinite(t)&&t>0?t:e}function gb(e){let t=(0,Q.c)(22),n=pb(e.src),r;t[0]===e.src?r=t[1]:(r=e.src===void 0?void 0:Lo(e.src),t[0]=e.src,t[1]=r);let i=e.alt??``,a;t[2]===e.width?a=t[3]:(a=hb(e.width),t[2]=e.width,t[3]=a);let o;t[4]===e.height?o=t[5]:(o=hb(e.height),t[4]=e.height,t[5]=o);let s=e.title,c;t[6]===e.loading?c=t[7]:(c=mb(e.loading),t[6]=e.loading,t[7]=c);let l;return t[8]!==e.crossorigin||t[9]!==e.decoding||t[10]!==e.fetchpriority||t[11]!==e.referrerpolicy||t[12]!==e.sizes||t[13]!==e.srcset||t[14]!==e.title||t[15]!==r||t[16]!==i||t[17]!==a||t[18]!==o||t[19]!==c||t[20]!==n?(l=(0,$.jsx)(lb,{src:r,alt:i,width:a,height:o,title:s,loading:c,srcSet:e.srcset,sizes:e.sizes,decoding:e.decoding,fetchPriority:e.fetchpriority,crossOrigin:e.crossorigin,referrerPolicy:e.referrerpolicy,targetExistence:n}),t[8]=e.crossorigin,t[9]=e.decoding,t[10]=e.fetchpriority,t[11]=e.referrerpolicy,t[12]=e.sizes,t[13]=e.srcset,t[14]=e.title,t[15]=r,t[16]=i,t[17]=a,t[18]=o,t[19]=c,t[20]=n,t[21]=l):l=t[21],l}function _b(e){let t=(0,Q.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={sizes:void 0},t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,$.jsx)(Ly,{wrapElement:`span`,zoomMargin:20,zoomImg:n,children:(0,$.jsx)(gb,{...e})}),t[1]=e,t[2]=r),r}var vb=(0,Z.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-BCLP08X6.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,Q.c)(7),r;n[0]===t.formula?r=n[1]:(r=e.renderToString(t.formula,{displayMode:!0,throwOnError:!1,strict:`ignore`,trust:!1}),n[0]=t.formula,n[1]=r);let i=r,a;n[2]===i?a=n[3]:(a={__html:i},n[2]=i,n[3]=a);let o;return n[4]!==t.id||n[5]!==a?(o=(0,$.jsx)(`div`,{className:`math math-display`,"data-component-type":`math`,id:t.id,dangerouslySetInnerHTML:a}),n[4]=t.id,n[5]=a,n[6]=o):o=n[6],o}return{default:t}});function yb(e){let t=(0,Q.c)(3),n=e.formula||`\xA0`,r;return t[0]!==e.id||t[1]!==n?(r=(0,$.jsx)(`div`,{className:`math math-placeholder`,"data-component-type":`math`,id:e.id,children:n}),t[0]=e.id,t[1]=n,t[2]=r):r=t[2],r}function bb(e){let t=(0,Q.c)(6),n=e.formula??``;if(!n){let r;return t[0]!==n||t[1]!==e.id?(r=(0,$.jsx)(yb,{formula:n,id:e.id}),t[0]=n,t[1]=e.id,t[2]=r):r=t[2],r}let r;return t[3]!==n||t[4]!==e.id?(r=(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(yb,{formula:n,id:e.id}),children:(0,$.jsx)(vb,{formula:n,id:e.id})}),t[3]=n,t[4]=e.id,t[5]=r):r=t[5],r}function xb(e){return typeof e==`string`?e:typeof e==`number`?String(e):``}function Sb(e){let t=this,n={...t.data(`settings`),...e};t.compiler=r;function r(e){return as(e,n)}}var Cb=new Set([`img`,`video`,`audio`,`mark`,`u`,`ins`]),wb=new Map(Nn.flatMap(e=>e.surface===`compat`&&Cb.has(e.rendersAs)?[[e.name,e]]:[]));function Tb(e){let t={};for(let n of e.attributes){if(n.type!==`mdxJsxAttribute`)return null;let e=n.name.toLowerCase();if(!(e.length>=3&&e.startsWith(`on`)))if(n.value===null)t[n.name]=!0;else if(typeof n.value==`string`)t[n.name]=n.value;else return null}return t}function Eb(e){let t=e.name;if(!t||!Cb.has(t))return null;let n=Tb(e);return n===null?null:{type:`element`,tagName:t,properties:n,children:[]}}function Db(e){let t=e.name;if(!t)return null;let n=wb.get(t);if(!n)return null;let r=Tb(e);if(r===null)return null;let i=n.translateProps(r),a={};for(let[e,t]of Object.entries(i))(typeof t==`string`||typeof t==`boolean`)&&(a[e]=t);return{type:`element`,tagName:n.rendersAs,properties:a,children:[]}}var Ob=(e,t)=>{let n=t,{target:r,anchor:i,alias:a}=n.data,o={type:`element`,tagName:`a`,properties:{className:[`wiki-link`],dataTarget:r,dataAnchor:i??``,dataAlias:a??``,href:$a(r,i)},children:n.children.length>0?e.all(n):[{type:`text`,value:n.value}]};return e.patch(t,o),e.applyData(t,o)},kb=(e,t)=>{let n=t,{target:r,anchor:i,alias:a}=n.data,o={type:`element`,tagName:`a`,properties:{className:[`wiki-embed`],dataTarget:r,dataAnchor:i??``,dataAlias:a??``,href:$a(r,i)},children:n.children.length>0?e.all(n):[{type:`text`,value:n.value}]};return e.patch(t,o),e.applyData(t,o)},Ab=(e,t)=>{let n=t,r=Eb(n);if(r)return n.children.length>0&&(r.children=e.all(n)),e.patch(t,r),e.applyData(t,r);let i=Db(n);if(i){e.patch(t,i);let n=e.applyData(t,i);return n.tagName===`img`?{type:`element`,tagName:`p`,properties:{},children:[n]}:n}let a={type:`element`,tagName:`pre`,properties:{className:[`mdx-component`]},children:[{type:`element`,tagName:`code`,properties:{},children:[{type:`text`,value:typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:``}]}]};return e.patch(t,a),e.applyData(t,a)},jb=(e,t)=>{let n=t,r=Eb(n);if(r)return n.children.length>0&&(r.children=e.all(n)),e.patch(t,r),e.applyData(t,r);let i=Db(n);if(i)return e.patch(t,i),e.applyData(t,i);let a={type:`element`,tagName:`span`,properties:{className:[`mdx-inline`],dataJsxInline:``},children:[{type:`text`,value:typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:``}]};return e.patch(t,a),e.applyData(t,a)},Mb=(e,t)=>{let n=t,r=n.data.reason||`unknown`,i=n.value||``,a=r.replace(/--/g,`—`),o={type:`comment`,value:` Parse error: ${a} `},s={type:`element`,tagName:`pre`,properties:{className:[`mdx-fallback`],dataRawMdxFallback:``,dataReason:a},children:[{type:`element`,tagName:`code`,properties:{},children:[{type:`text`,value:i}]}]};return e.patch(t,s),[o,e.applyData(t,s)]},Nb=(e,t)=>{let n={type:`element`,tagName:`mark`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},Pb=(e,t)=>{let n=t,r={type:`element`,tagName:n.data?.sourceForm===`ins`?`ins`:`u`,properties:{},children:e.all(n)};return e.patch(t,r),e.applyData(t,r)};function Fb(e){if(typeof e!=`object`||!e)return``;let t=e;return typeof t.value==`string`?t.value:Array.isArray(t.children)?t.children.map(Fb).join(``):``}var Ib={wikiLink:Ob,wikiLinkEmbed:kb,mdxJsxFlowElement:Ab,mdxJsxTextElement:jb,rawMdxFallback:Mb,mark:Nb,underline:Pb,tag:(e,t)=>{let n=t.value,r={type:`element`,tagName:`a`,properties:{className:[`tag`],dataTag:n,href:`#tag/${n}`},children:[{type:`text`,value:`#${n}`}]};return e.patch(t,r),e.applyData(t,r)},comment:(e,t)=>{let n={type:`comment`,value:Fb(t).replace(/--/g,`—`)};return e.patch(t,n),e.applyData(t,n)},commentBlock:(e,t)=>{let n={type:`comment`,value:Fb(t).replace(/--/g,`—`)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:(e,t)=>{let n=t.identifier,r={type:`element`,tagName:`sup`,properties:{id:`fnref-${n}`,dataFootnoteRef:``,dataFootnoteId:n,className:[`footnote-ref`]},children:[{type:`element`,tagName:`a`,properties:{href:`#fn-${n}`,className:[`footnote-ref-link`]},children:[{type:`text`,value:`[${n}]`}]}]};return e.patch(t,r),e.applyData(t,r)},footnoteDefinition:(e,t)=>{let n=t.identifier,r={type:`element`,tagName:`aside`,properties:{id:`fn-${n}`,dataFootnoteDef:``,dataFootnoteId:n,className:[`footnote-def`]},children:[{type:`element`,tagName:`div`,properties:{className:[`footnote-body`]},children:e.all(t)},{type:`element`,tagName:`a`,properties:{href:`#fnref-${n}`,className:[`footnote-backref`],ariaLabel:`Back to reference`},children:[{type:`text`,value:`↩`}]}]};return e.patch(t,r),e.applyData(t,r)}},Lb=/url\s*\(\s*['"]?\s*(?:javascript|vbscript|data)\s*:/i,Rb=/\bexpression\s*\(/i,zb=1e4;function Bb(e){return!(e.length>zb||Lb.test(e)||Rb.test(e))}function Vb(e){for(let t of e.split(`,`)){let e=t.trim();if(e!==``&&!Yi(e.split(/\s+/)[0]??``))return!1}return!0}var Hb={a:[`href`,`title`],img:[`src`,`alt`,`title`],video:[`src`,`title`],audio:[`src`,`title`],code:[`className`]},Ub=new Set([`href`,`src`]),Wb=Yo(`<>`),Gb=()=>e=>{zo(e,`element`,e=>{let t=Hb[e.tagName.toLowerCase()],n=e.properties;if(!(!t||!n))for(let e of t){let t=n[e];if(Array.isArray(t)){let r=t.map(e=>typeof e==`string`?Dr(e):e);r.some((e,n)=>e!==t[n])&&(n[e]=r);continue}if(typeof t!=`string`)continue;let r;if(Ub.has(e))if(t===`<>`||t===Wb)r=``;else{let e=Dr(t);r=e===t?t:Yo(e)}else r=Dr(t);r!==t&&(n[e]=r)}})},Kb=()=>e=>{zo(e,`element`,e=>{let t=e.tagName.toLowerCase(),n=e.properties;if(!n)return;if(t===`a`||t===`area`||t===`link`||t===`base`){let e=n.href;typeof e==`string`&&!Yi(e)&&delete n.href}if(t===`img`||t===`iframe`||t===`script`||t===`embed`||t===`source`||t===`audio`||t===`video`||t===`track`){let e=n.src;typeof e==`string`&&!Yi(e)&&delete n.src}if(t===`form`){let e=n.action;typeof e==`string`&&!Yi(e)&&delete n.action}if(t===`img`||t===`source`){let e=n.srcSet;typeof e==`string`&&!Vb(e)&&delete n.srcSet;let t=n.srcset;typeof t==`string`&&!Vb(t)&&delete n.srcset}if(t===`video`){let e=n.poster;typeof e==`string`&&!Yi(e)&&delete n.poster}let r=n.style;typeof r==`string`&&!Bb(r)&&delete n.style})};function qb(e){let t=Vo().use(Xo,{handlers:Ib}).use(Gb).use(Kb).use(Sb),n=t.runSync(e);return String(t.stringify(n))}function Jb(e){let t=/\r?\n|\r/g,n=[],r=0,i=t.exec(e);for(;i!==null;)n.push(Yb(e.slice(r,i.index),r>0,!0),i[0]),r=i.index+i[0].length,i=t.exec(e);return n.push(Yb(e.slice(r),r>0,!1)),n.join(``)}function Yb(e,t,n){let r=0,i=e.length,a=e=>e===9||e===32;for(;t&&r<i&&a(e.charCodeAt(r));)r++;for(;n&&i>r&&a(e.charCodeAt(i-1));)i--;return i>r?e.slice(r,i):``}var Xb=/\r?\n|\r/,Zb=(e,t)=>{let n=Jb(String(t.value));if(!Xb.test(n)){let r={type:`text`,value:n};return e.patch(t,r),e.applyData(t,r)}let r=n.split(Xb),i=[];for(let e=0;e<r.length;e++)e>0&&i.push({type:`element`,tagName:`br`,properties:{},children:[]}),r[e].length>0&&i.push({type:`text`,value:r[e]});return i};function Qb(e){let t=Vo().use(Wo).use(Zo,[`yaml`]).use(pr).use(Ho).use(Vr).use(yr).use(gr).use(jr).use(Xo,{handlers:{...Ib,text:Zb}}).use(Gb).use(Kb).use(Sb);return String(t.processSync(cr(ii(e))))}function $b(e){let t=Nn.find(t=>t.name===e);if(!t)throw Error(`No built-in component descriptor named '${e}'`);return t.props}var ex=$b(`MirrorSource`);function tx(e){return xb(fi(ex,e).name)}function nx(e){let t={};for(let n of e.attributes??[])n.type===`mdxJsxAttribute`&&n.name!==void 0&&(t[n.name]=rr(n.value));return tx(t)}function rx(e,t){if(e.type===`mdxJsxFlowElement`){let n=e;if(n.name===`MirrorSource`&&nx(n)===t)return n}let n=e.children;if(Array.isArray(n))for(let e of n){let n=rx(e,t);if(n)return n}return null}function ix(e){return qb({type:`root`,children:e.children??[]})}function ax(e){switch(e){case`at-capacity`:return{kind:`at-capacity`};case`inadmissible`:return{kind:`source-removed`};case`refused`:return{kind:`loading`}}}function ox(e,t){let n=(0,Q.c)(9),{collabUrl:r}=_o(),i=Fv(),a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={kind:`loading`},n[0]=a):a=n[0];let[o,s]=(0,Z.useState)(a),c=(0,Z.useRef)(t),l=(0,Z.useRef)(null),u,d;n[1]!==i||n[2]!==r||n[3]!==e?(u=()=>{if(!e){s({kind:`empty-props`});return}if(!r){s({kind:`loading`});return}let t=i(r,e);if(!t.ok){console.warn(`[Mirror] live-doc pool refused subscription`,{src:e,reason:t.reason}),s(ax(t.reason));return}let{entry:n}=t,a=()=>{let t=c.current;if(!t){s({kind:`empty-props`});return}let r=n.ySource.toString();if(!r){s(n.synced?{kind:`source-removed`}:{kind:`loading`});return}let i;try{i=oi().parseToMdast(r)}catch(n){console.warn(`[Mirror] parseToMdast failed`,{src:e,name:t,err:n}),s({kind:`source-removed`});return}let a=rx(i,t);if(!a){s({kind:`name-not-found`});return}let o;try{o=ix(a)}catch(n){console.warn(`[Mirror] renderMirrorSubtree failed`,{src:e,name:t,err:n}),s({kind:`name-not-found`});return}s(e=>e.kind===`ready`&&e.html===o?e:{kind:`ready`,html:o})},o=null,u=n.subscribe({onUpdate:()=>{o&&clearTimeout(o),o=setTimeout(()=>{o=null,a()},150)},onSynced:()=>{o&&=(clearTimeout(o),null),a()}});l.current=a;let d=setTimeout(()=>{n.synced||s({kind:`source-removed`})},Mv);return a(),()=>{clearTimeout(d),o&&clearTimeout(o),u(),l.current=null,Lv(r,e)}},d=[r,e,i],n[1]=i,n[2]=r,n[3]=e,n[4]=u,n[5]=d):(u=n[4],d=n[5]),(0,Z.useEffect)(u,d);let f,p;return n[6]===t?(f=n[7],p=n[8]):(f=()=>{c.current=t,l.current?.()},p=[t],n[6]=t,n[7]=f,n[8]=p),(0,Z.useEffect)(f,p),o}function sx(e){let t=(0,Q.c)(8),n=`ok-mirror-state flex items-start gap-2 rounded-md border border-dashed px-3 py-2 text-sm ${e.tone===`error`?`border-destructive/40 text-destructive`:`border-border text-muted-foreground`}`,r;t[0]===e.tone?r=t[1]:(r=e.tone===`error`?(0,$.jsx)(su,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}):(0,$.jsx)(lu,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}),t[0]=e.tone,t[1]=r);let i;t[2]===e.children?i=t[3]:(i=(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.children}),t[2]=e.children,t[3]=i);let a;return t[4]!==n||t[5]!==r||t[6]!==i?(a=(0,$.jsxs)(`div`,{className:n,children:[r,i]}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function cx(e){let t=(0,Q.c)(39),n;t[0]===e.src?n=t[1]:(n=xb(e.src),t[0]=e.src,t[1]=n);let r=n,i;t[2]===e.name?i=t[3]:(i=xb(e.name),t[2]=e.name,t[3]=i);let o=i,s=ox(r,o);if(s.kind===`empty-props`){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(sx,{tone:`placeholder`,children:(0,$.jsx)(a,{id:`tOkGFB`,components:{0:(0,$.jsx)(`span`,{className:`font-medium`}),1:(0,$.jsx)(`code`,{}),2:(0,$.jsx)(`code`,{}),3:(0,$.jsx)(`code`,{})}})}),t[4]=e):e=t[4],e}if(s.kind===`loading`){let e=r&&o?`${r}#${o}`:``,n;t[5]===e?n=t[6]:(n={mirrorRef:e},t[5]=e,t[6]=n);let i;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(i={0:(0,$.jsx)(`code`,{})},t[7]=i):i=t[7];let s;return t[8]===n?s=t[9]:(s=(0,$.jsx)(sx,{tone:`placeholder`,children:(0,$.jsx)(a,{id:`92rbk2`,values:n,components:i})}),t[8]=n,t[9]=s),s}if(s.kind===`source-removed`){let e;t[10]===r?e=t[11]:(e={src:r},t[10]=r,t[11]=e);let n;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(n={0:(0,$.jsx)(`span`,{className:`font-medium`}),1:(0,$.jsx)(`code`,{})},t[12]=n):n=t[12];let i;return t[13]===e?i=t[14]:(i=(0,$.jsx)(sx,{tone:`error`,children:(0,$.jsx)(a,{id:`Ud0Pj9`,values:e,components:n})}),t[13]=e,t[14]=i),i}if(s.kind===`at-capacity`){let e;t[15]===r?e=t[16]:(e={src:r},t[15]=r,t[16]=e);let n;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(n={0:(0,$.jsx)(`span`,{className:`font-medium`}),1:(0,$.jsx)(`code`,{})},t[17]=n):n=t[17];let i;return t[18]===e?i=t[19]:(i=(0,$.jsx)(sx,{tone:`error`,children:(0,$.jsx)(a,{id:`SWTmnY`,values:e,components:n})}),t[18]=e,t[19]=i),i}if(s.kind===`name-not-found`){let e=`<MirrorSource name="${o}">`,n;t[20]!==e||t[21]!==r?(n={mirrorSourceTag:e,src:r},t[20]=e,t[21]=r,t[22]=n):n=t[22];let i;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(i={0:(0,$.jsx)(`span`,{className:`font-medium`}),1:(0,$.jsx)(`code`,{}),2:(0,$.jsx)(`code`,{})},t[23]=i):i=t[23];let s;return t[24]===n?s=t[25]:(s=(0,$.jsx)(sx,{tone:`error`,children:(0,$.jsx)(a,{id:`Ysv4pO`,values:n,components:i})}),t[24]=n,t[25]=s),s}let c;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Ft,{className:`size-3`,"aria-hidden":`true`}),t[26]=c):c=t[26];let l;t[27]===r?l=t[28]:(l={src:r},t[27]=r,t[28]=l);let u;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(u={0:(0,$.jsx)(`code`,{className:`font-mono`})},t[29]=u):u=t[29];let d;t[30]===l?d=t[31]:(d=(0,$.jsxs)(`div`,{className:`ok-mirror-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,"aria-hidden":`true`,children:[c,(0,$.jsx)(`span`,{children:(0,$.jsx)(a,{id:`wQp1V3`,values:l,components:u})})]}),t[30]=l,t[31]=d);let f;t[32]===s.html?f=t[33]:(f=(0,$.jsx)(`div`,{dangerouslySetInnerHTML:{__html:s.html}}),t[32]=s.html,t[33]=f);let p;return t[34]!==o||t[35]!==r||t[36]!==d||t[37]!==f?(p=(0,$.jsxs)(`div`,{className:`ok-mirror-resolved relative -mx-3 prose-no-margin rounded-md border border-dashed border-transparent px-3 py-2 transition-colors [.jsx-component-wrapper:hover_&]:border-border/40 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/40`,"data-mirror-src":r,"data-mirror-name":o,children:[d,f]}),t[34]=o,t[35]=r,t[36]=d,t[37]=f,t[38]=p):p=t[38],p}function lx(e){let t=(0,Q.c)(17),{_:n}=o(),r;t[0]===e.name?r=t[1]:(r=xb(e.name),t[0]=e.name,t[1]=r);let i=r,s;t[2]!==n||t[3]!==i?(s=i||n({id:`DWZYxR`}),t[2]=n,t[3]=i,t[4]=s):s=t[4];let c=s,l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(ql,{className:`size-3`,"aria-hidden":`true`}),t[5]=l):l=t[5];let u;t[6]===c?u=t[7]:(u={label:c},t[6]=c,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d={0:(0,$.jsx)(`code`,{className:`font-mono`})},t[8]=d):d=t[8];let f;t[9]===u?f=t[10]:(f=(0,$.jsxs)(`div`,{className:`ok-mirror-source-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,children:[l,(0,$.jsx)(`span`,{children:(0,$.jsx)(a,{id:`Zon_qG`,values:u,components:d})})]}),t[9]=u,t[10]=f);let p;t[11]===e.children?p=t[12]:(p=(0,$.jsx)(`div`,{children:e.children}),t[11]=e.children,t[12]=p);let m;return t[13]!==i||t[14]!==f||t[15]!==p?(m=(0,$.jsxs)(`div`,{className:`ok-mirror-source relative -mx-3 rounded-md border border-dashed border-transparent px-3 py-1 transition-colors [.jsx-component-wrapper:hover_&]:border-border/50 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/50`,"data-mirror-source-name":i,children:[f,p]}),t[13]=i,t[14]=f,t[15]=p,t[16]=m):m=t[16],m}function ux(e){if(!e)return{height:null,viewerFragment:``};let t=e.split(`&`).filter(e=>e.length>0),n=null,r=[];for(let e of t){let t=e.indexOf(`=`);if(t===-1){r.push(e);continue}let i=e.slice(0,t),a=e.slice(t+1);if(i===`height`){let e=Number.parseInt(a,10);!Number.isNaN(e)&&e>0&&(n=e);continue}r.push(e)}return{height:n,viewerFragment:r.join(`&`)}}var dx=24,fx=24,px=12,mx=.1;function hx(e,t,n,r){if(n<=0&&(e===`fit-width`||e===`two-odd`||e===`two-even`)||r<=0&&e===`fit-height`)return 1;switch(e){case`fit-width`:return Math.max(mx,(n-dx)/t.naturalWidth);case`fit-height`:return Math.max(mx,(r-fx)/t.naturalHeight);case`single`:return 1;case`two-odd`:case`two-even`:return Math.max(mx,((n-dx)/2-px)/t.naturalWidth)}}var gx=600,_x=.5,vx=3,yx=.25,bx=null;function xx(){return bx||(bx=(async()=>{let e=await n(()=>import(`./pdf-DO7qqKZs.js`),__vite__mapDeps([48,2]),import.meta.url);if(!e.GlobalWorkerOptions.workerSrc){let t=(await n(async()=>{let{default:e}=await import(`./pdf.worker-DG3RIHYj.js`);return{default:e}},[],import.meta.url)).default;e.GlobalWorkerOptions.workerSrc=t}return e})(),bx.catch(()=>{bx=null})),bx}function Sx(e){return e instanceof Error&&e.name===`RenderingCancelledException`}function Cx(e){let t=(0,Q.c)(96),n,r;if(t[0]!==e.anchor||t[1]!==e.fillContainer){let{height:i,viewerFragment:a}=ux(e.anchor);n=i===null?e.fillContainer?`100%`:`${gx}px`:`${i}px`,r=Ax(a),t[0]=e.anchor,t[1]=e.fillContainer,t[2]=n,t[3]=r}else n=t[2],r=t[3];let i=r,s=(0,Z.useRef)(null),c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[4]=c):c=t[4];let l=(0,Z.useRef)(c),u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[5]=u):u=t[5];let d=(0,Z.useRef)(u),f=(0,Z.useRef)(null),p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[6]=p):p=t[6];let[m,h]=(0,Z.useState)(p),[g,_]=(0,Z.useState)(!0),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(i??1),[S,C]=(0,Z.useState)(String(i??1)),[w,T]=(0,Z.useState)(1),[E,D]=(0,Z.useState)(`fit-width`),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(0),[P,F]=(0,Z.useState)(0),{_:I}=o(),L=m.length,ee,R;t[7]!==I||t[8]!==e.src?(ee=()=>{if(!e.src){_(!1);return}let t=Lo(e.src),n=!1,r=null;return _(!0),y(null),(async()=>{try{let e=(await xx()).getDocument({url:t});r=e;let i=await e.promise;if(n){await e.destroy();return}f.current=i;let a=[];for(let e=1;e<=i.numPages;e++){if(n)return;let t=(await i.getPage(e)).getViewport({scale:1});a.push({pageNumber:e,naturalWidth:t.width,naturalHeight:t.height})}if(n)return;h(a)}catch(e){let t=e;if(n)return;y(t instanceof Error?t.message:I({id:`jRHdCz`})),_(!1)}})(),()=>{n=!0,r?.destroy().catch(Ox),r=null,f.current=null}},R=[e.src,I],t[7]=I,t[8]=e.src,t[9]=ee,t[10]=R):(ee=t[9],R=t[10]),(0,Z.useEffect)(ee,R);let te,ne;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>{let e=s.current;if(!e)return;let t=()=>{N(e.clientWidth),F(e.clientHeight)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},ne=[],t[11]=te,t[12]=ne):(te=t[11],ne=t[12]),(0,Z.useEffect)(te,ne);let re,ie;t[13]!==I||t[14]!==P||t[15]!==M||t[16]!==E||t[17]!==m||t[18]!==w?(re=()=>{let e=f.current;if(!e||m.length===0||M===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of m){if(t)return;let a=l.current[i.pageNumber-1];if(!a)continue;let o=hx(E,i,M,P)*w,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let u=a.getContext(`2d`);u&&(u.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:u,viewport:c}),await n.promise,n=null)}t||_(!1)}catch(e){let n=e;if(t||Sx(n))return;console.warn(`[Pdf] page render failed:`,n),y(n instanceof Error?n.message:I({id:`_TF8ep`})),_(!1)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},ie=[m,E,w,M,P,I],t[13]=I,t[14]=P,t[15]=M,t[16]=E,t[17]=m,t[18]=w,t[19]=re,t[20]=ie):(re=t[19],ie=t[20]),(0,Z.useEffect)(re,ie);let ae,oe;t[21]!==m||t[22]!==O?(ae=()=>{if(!O)return;let e=f.current;if(!e||m.length===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of m){if(t)return;let a=d.current[i.pageNumber-1];if(!a)continue;let o=120/i.naturalWidth,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let l=a.getContext(`2d`);l&&(l.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:l,viewport:c}),await n.promise,n=null)}}catch(e){let t=e;Sx(t)||console.warn(`[Pdf] thumbnail render failed:`,t)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},oe=[O,m],t[21]=m,t[22]=O,t[23]=ae,t[24]=oe):(ae=t[23],oe=t[24]),(0,Z.useEffect)(ae,oe);let se,z;t[25]!==g||t[26]!==i?(se=()=>{if(g||!i)return;let e=s.current,t=l.current[i-1];e&&t&&(e.scrollTop=t.offsetTop-e.offsetTop)},z=[g,i],t[25]=g,t[26]=i,t[27]=se,t[28]=z):(se=t[27],z=t[28]),(0,Z.useEffect)(se,z);let B,ce;t[29]===m?(B=t[30],ce=t[31]):(B=()=>{let e=s.current;if(!e||m.length===0)return;let t=!1,n=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let n=e.scrollTop,r=1;for(let t of m){let i=l.current[t.pageNumber-1];i&&i.offsetTop-e.offsetTop<=n+40&&(r=t.pageNumber)}x(r),C(String(r))}))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},ce=[m],t[29]=m,t[30]=B,t[31]=ce),(0,Z.useEffect)(B,ce);let V,H;t[32]===A?(V=t[33],H=t[34]):(V=()=>{if(!A)return;let e=e=>{let t=e.target,n=s.current?.closest(`.ok-pdf`);if(!n||!t||!n.contains(t)){j(!1);return}let r=n.querySelector(`.ok-pdf-layout-menu`);r&&!r.contains(t)&&j(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},H=[A],t[32]=A,t[33]=V,t[34]=H),(0,Z.useEffect)(V,H);let U;t[35]===L?U=t[36]:(U=e=>{let t=Math.max(1,Math.min(L||1,e));x(t),C(String(t));let n=s.current,r=l.current[t-1];n&&r&&n.scrollTo({top:r.offsetTop-n.offsetTop,behavior:`smooth`})},t[35]=L,t[36]=U);let W=U,le;t[37]!==b||t[38]!==W||t[39]!==S?(le=()=>{let e=Number.parseInt(S,10);if(Number.isNaN(e)){C(String(b));return}W(e)},t[37]=b,t[38]=W,t[39]=S,t[40]=le):le=t[40];let G=le,ue;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>T(Dx),t[41]=ue):ue=t[41];let K=ue,de;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>T(Ex),t[42]=de):de=t[42];let fe=de,pe;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(pe=e=>{D(e),j(!1),T(1)},t[43]=pe):pe=t[43];let q=pe,me;t[44]===n?me=t[45]:(me={height:n},t[44]=n,t[45]=me);let J;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(J=()=>k(Tx),t[46]=J):J=t[46];let he;t[47]!==I||t[48]!==O?(he=I(O?{id:`JK-Ave`}:{id:`iEYxO4`}),t[47]=I,t[48]=O,t[49]=he):he=t[49];let ge;t[50]===I?ge=t[51]:(ge=I({id:`zo3Dl7`}),t[50]=I,t[51]=ge);let _e;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,$.jsx)(ut,{size:14,"aria-hidden":`true`}),t[52]=_e):_e=t[52];let ve;t[53]!==O||t[54]!==he||t[55]!==ge?(ve=(0,$.jsx)(`button`,{type:`button`,onClick:J,"aria-label":he,"aria-pressed":O,className:`ok-pdf-btn`,title:ge,children:_e}),t[53]=O,t[54]=he,t[55]=ge,t[56]=ve):ve=t[56];let ye=e.title??`PDF`,be;t[57]===ye?be=t[58]:(be=(0,$.jsx)(`span`,{className:`ok-pdf-title`,children:ye}),t[57]=ye,t[58]=be);let xe;t[59]!==I||t[60]!==A||t[61]!==E||t[62]!==S||t[63]!==G||t[64]!==L||t[65]!==w?(xe=L>0&&(0,$.jsxs)(`div`,{className:`ok-pdf-controls`,children:[(0,$.jsx)(`form`,{className:`ok-pdf-page-form`,onSubmit:e=>{e.preventDefault(),G()},children:(0,$.jsx)(`input`,{type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,className:`ok-pdf-page-input`,value:S,onChange:e=>C(e.target.value.replace(/[^0-9]/g,``)),onBlur:G,"aria-label":I({id:`xsZhu-`})})}),(0,$.jsx)(`span`,{className:`ok-pdf-page-of`,children:(0,$.jsx)(a,{id:`1GhYxC`,values:{totalPages:L}})}),(0,$.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,$.jsx)(`button`,{type:`button`,onClick:fe,disabled:w<=_x,"aria-label":I({id:`FjkaiT`}),className:`ok-pdf-btn`,title:I({id:`FjkaiT`}),children:(0,$.jsx)(St,{size:14,"aria-hidden":`true`})}),(0,$.jsxs)(`span`,{className:`ok-pdf-zoom-display`,"aria-live":`polite`,children:[Math.round(w*100),`%`]}),(0,$.jsx)(`button`,{type:`button`,onClick:K,disabled:w>=vx,"aria-label":I({id:`AWOSPo`}),className:`ok-pdf-btn`,title:I({id:`AWOSPo`}),children:(0,$.jsx)(Ct,{size:14,"aria-hidden":`true`})}),(0,$.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,$.jsxs)(`div`,{className:`ok-pdf-layout-menu`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>j(wx),"aria-label":I({id:`GQDSBN`}),"aria-haspopup":`menu`,"aria-expanded":A,className:`ok-pdf-btn`,title:I({id:`rdU729`}),children:(0,$.jsx)(jt,{size:14,"aria-hidden":`true`})}),A&&(0,$.jsxs)(`div`,{role:`menu`,className:`ok-pdf-menu`,children:[(0,$.jsx)(kx,{label:I({id:`vIxrEk`}),active:E===`fit-width`,onSelect:()=>q(`fit-width`)}),(0,$.jsx)(kx,{label:I({id:`YlDuro`}),active:E===`fit-height`,onSelect:()=>q(`fit-height`)}),(0,$.jsx)(`hr`,{className:`ok-pdf-menu-divider`}),(0,$.jsx)(kx,{label:I({id:`BGHHtQ`}),active:E===`single`,onSelect:()=>q(`single`)}),(0,$.jsx)(kx,{label:I({id:`xK291b`}),active:E===`two-odd`,onSelect:()=>q(`two-odd`)}),(0,$.jsx)(kx,{label:I({id:`NSnIUP`}),active:E===`two-even`,onSelect:()=>q(`two-even`)})]})]})]}),t[59]=I,t[60]=A,t[61]=E,t[62]=S,t[63]=G,t[64]=L,t[65]=w,t[66]=xe):xe=t[66];let Se;t[67]!==ve||t[68]!==be||t[69]!==xe?(Se=(0,$.jsxs)(`div`,{className:`ok-pdf-toolbar`,contentEditable:!1,children:[ve,be,xe]}),t[67]=ve,t[68]=be,t[69]=xe,t[70]=Se):Se=t[70];let Ce;t[71]!==I||t[72]!==b||t[73]!==W||t[74]!==m||t[75]!==O?(Ce=O&&(0,$.jsx)(`aside`,{className:`ok-pdf-sidebar`,"aria-label":I({id:`nzaV6Q`}),children:m.map((e,t)=>{let{pageNumber:n}=e;return(0,$.jsxs)(`button`,{type:`button`,className:`ok-pdf-thumb`,"data-active":b===n||void 0,onClick:()=>W(n),"aria-label":I({id:`qioCwA`,values:{pageNumber:n}}),children:[(0,$.jsx)(`canvas`,{ref:e=>{d.current[t]=e},className:`ok-pdf-thumb-canvas`}),(0,$.jsx)(`span`,{className:`ok-pdf-thumb-num`,children:n})]},n)})}),t[71]=I,t[72]=b,t[73]=W,t[74]=m,t[75]=O,t[76]=Ce):Ce=t[76];let we;t[77]===g?we=t[78]:(we=g&&(0,$.jsx)(`div`,{className:`ok-pdf-loading`,children:(0,$.jsx)(a,{id:`T-654M`})}),t[77]=g,t[78]=we);let Te;t[79]===v?Te=t[80]:(Te=v&&(0,$.jsx)(`div`,{className:`ok-pdf-error`,children:(0,$.jsx)(a,{id:`WamGNs`,values:{error:v}})}),t[79]=v,t[80]=Te);let Ee;t[81]!==I||t[82]!==L?(Ee=Array.from({length:L},(e,t)=>{let n=t+1;return(0,$.jsx)(`canvas`,{ref:e=>{l.current[t]=e},className:`ok-pdf-page`,"aria-label":I({id:`XtRoxT`,values:{pageNumber:n}})},n)}),t[81]=I,t[82]=L,t[83]=Ee):Ee=t[83];let De;t[84]!==E||t[85]!==we||t[86]!==Te||t[87]!==Ee?(De=(0,$.jsxs)(`div`,{className:`ok-pdf-pages`,ref:s,"data-layout":E,children:[we,Te,Ee]}),t[84]=E,t[85]=we,t[86]=Te,t[87]=Ee,t[88]=De):De=t[88];let Oe;t[89]!==Ce||t[90]!==De?(Oe=(0,$.jsxs)(`div`,{className:`ok-pdf-body`,children:[Ce,De]}),t[89]=Ce,t[90]=De,t[91]=Oe):Oe=t[91];let ke;return t[92]!==me||t[93]!==Se||t[94]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`ok-pdf`,style:me,children:[Se,Oe]}),t[92]=me,t[93]=Se,t[94]=Oe,t[95]=ke):ke=t[95],ke}function wx(e){return!e}function Tx(e){return!e}function Ex(e){return Math.max(_x,+(e-yx).toFixed(2))}function Dx(e){return Math.min(vx,+(e+yx).toFixed(2))}function Ox(){}function kx(e){let t=(0,Q.c)(10),n=e.active||void 0,r;t[0]===e.active?r=t[1]:(r=e.active&&(0,$.jsx)(At,{size:14}),t[0]=e.active,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,$.jsx)(`span`,{className:`ok-pdf-menu-check`,"aria-hidden":`true`,children:r}),t[2]=r,t[3]=i);let a;return t[4]!==e.active||t[5]!==e.label||t[6]!==e.onSelect||t[7]!==n||t[8]!==i?(a=(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e.active,className:`ok-pdf-menu-item`,"data-active":n,onClick:e.onSelect,children:[i,e.label]}),t[4]=e.active,t[5]=e.label,t[6]=e.onSelect,t[7]=n,t[8]=i,t[9]=a):a=t[9],a}function Ax(e){if(!e)return null;for(let t of e.split(`&`)){let e=t.indexOf(`=`);if(!(e<0)&&t.slice(0,e)===`page`){let n=Number.parseInt(t.slice(e+1),10);if(!Number.isNaN(n)&&n>=1)return n}}return null}function jx(e){let t=(0,Q.c)(10),{label:n,id:r,children:i}=e,a=(0,Z.useId)(),o;t[0]!==r||t[1]!==a?(o=r||`tab-panel-${a.replace(/:/g,``)}`,t[0]=r,t[1]=a,t[2]=o):o=t[2];let s=o,c=`${s}-tab`,l;t[3]===n?l=t[4]:(l=n?.trim()||`Tab`,t[3]=n,t[4]=l);let u=l,d;return t[5]!==i||t[6]!==s||t[7]!==u||t[8]!==c?(d=(0,$.jsx)(`section`,{className:`tab-panel`,id:s,role:`tabpanel`,"aria-labelledby":c,"data-tab-label":u,"data-tab-id":s,children:i}),t[5]=i,t[6]=s,t[7]=u,t[8]=c,t[9]=d):d=t[9],d}var Mx=`:scope > .component-children > [data-node-view-content-react] > .react-renderer`;function Nx(e){return Array.from(e.querySelectorAll(Mx)).map((e,t)=>{let n=e.querySelector(`[data-tab-label]`);return{index:t,label:(n?.getAttribute(`data-tab-label`))?.trim()||`Tab ${t+1}`,panelId:n?.getAttribute(`data-tab-id`)??null}})}function Px(e,t){let n=Array.from(e.querySelectorAll(Mx))[t];return n?n.querySelector(`[data-jsx-gear]`):null}function Fx(e){let t=(0,Q.c)(31),{id:n,children:r}=e,[i,a]=(0,Z.useState)(0),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Z.useState)(s),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),f=(0,Z.useRef)(0),p=kt(),m=p?.addChild!=null,{_:h}=o(),g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=u.current;if(!e)return;let t=Nx(e);l(e=>{if(e.length!==t.length)return t;for(let n=0;n<e.length;n++)if(e[n].label!==t[n].label||e[n].panelId!==t[n].panelId)return t;return e})},t[1]=g):g=t[1],(0,Z.useLayoutEffect)(g);let _,v;t[2]===c.length?(_=t[3],v=t[4]):(_=()=>{c.length>f.current&&c.length>0&&a(c.length-1),f.current=c.length},v=[c.length],t[2]=c.length,t[3]=_,t[4]=v),(0,Z.useLayoutEffect)(_,v);let y;t[5]===n?y=t[6]:(y=()=>{let e=()=>{let e=window.location.hash.slice(1);if(!e)return;if(n&&e===n){a(0);return}let t=u.current;if(!t)return;let r=Nx(t).findIndex(t=>t.panelId===e);r<0||(a(r),queueMicrotask(()=>{t.ownerDocument.getElementById(e)?.scrollIntoView({block:`start`,behavior:`auto`})}))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},t[5]=n,t[6]=y),(0,Z.useLayoutEffect)(y);let b=c.length===0?0:Math.min(Math.max(i,0),c.length-1),x;t[7]!==c.length||t[8]!==b?(x=e=>{if(c.length===0)return;let t=null;e.key===`ArrowRight`?t=(b+1)%c.length:e.key===`ArrowLeft`?t=(b-1+c.length)%c.length:e.key===`Home`?t=0:e.key===`End`&&(t=c.length-1),t!==null&&(e.preventDefault(),a(t),(d.current?.querySelectorAll(`[role="tab"]`))?.[t]?.focus())},t[7]=c.length,t[8]=b,t[9]=x):x=t[9];let S=x,C=n?`Tabs: ${n}`:`Tabs`,w;t[10]!==c||t[11]!==b?(w=c.map(e=>(0,$.jsx)(`button`,{id:e.panelId?`${e.panelId}-tab`:void 0,type:`button`,role:`tab`,className:`tabs-strip-pill`,"data-active":e.index===b,"aria-selected":e.index===b,"aria-controls":e.panelId??void 0,tabIndex:e.index===b?0:-1,onMouseDown:Lx,onClick:()=>{if(e.index!==b){a(e.index);return}let t=u.current;t&&Px(t,e.index)?.click()},children:e.label},e.index)),t[10]=c,t[11]=b,t[12]=w):w=t[12];let T;t[13]!==S||t[14]!==C||t[15]!==w?(T=(0,$.jsx)(`div`,{ref:d,role:`tablist`,"aria-label":C,className:`tabs-tablist`,onKeyDown:S,children:w}),t[13]=S,t[14]=C,t[15]=w,t[16]=T):T=t[16];let E;t[17]!==h||t[18]!==m||t[19]!==p?(E=m&&(0,$.jsx)(`button`,{type:`button`,className:`tabs-strip-add`,"aria-label":h({id:`hjO0Mq`}),title:h({id:`hjO0Mq`}),onMouseDown:Ix,onClick:()=>p?.addChild?.(),"data-tabs-strip-add":``,children:`+`}),t[17]=h,t[18]=m,t[19]=p,t[20]=E):E=t[20];let D;t[21]!==E||t[22]!==T?(D=(0,$.jsxs)(`div`,{className:`tabs-strip`,contentEditable:!1,children:[T,E]}),t[21]=E,t[22]=T,t[23]=D):D=t[23];let O;t[24]!==r||t[25]!==b?(O=(0,$.jsx)(`div`,{ref:u,className:`tabs-content`,"data-active-index":b,children:r}),t[24]=r,t[25]=b,t[26]=O):O=t[26];let k;return t[27]!==n||t[28]!==D||t[29]!==O?(k=(0,$.jsxs)(`div`,{className:`tabs`,id:n,children:[D,O]}),t[27]=n,t[28]=D,t[29]=O,t[30]=k):k=t[30],k}function Ix(e){return e.preventDefault()}function Lx(e){return e.preventDefault()}var Rx=typeof global<`u`&&{}.toString.call(global)===`[object global]`,zx=typeof Bun<`u`,Bx=typeof Deno<`u`,Vx=typeof WebSocketPair==`function`&&caches?.default!==void 0,Hx=Rx||zx||Bx||Vx;function Ux(e,t){return e.indexOf(t.toLowerCase())===0?e:`${t.toLowerCase()}${e.substr(0,1).toUpperCase()}${e.substr(1)}`}function Wx(e){return!!(e&&e.nodeType===1&&`nodeName`in e&&e.ownerDocument&&e.ownerDocument.defaultView)}function Gx(e){return!isNaN(parseFloat(e))&&isFinite(e)&&Math.floor(e)==e}function Kx(e){return/^(https?:)?\/\/((((player|www)\.)?vimeo\.com)|((player\.)?[a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))(?=$|\/)/.test(e)}function qx(e){return/^https:\/\/player\.((vimeo\.com)|([a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))\/video\/\d+/.test(e)}function Jx(e){let t=(e||``).match(/^(?:https?:)?(?:\/\/)?([^/?]+)/),n=(t&&t[1]||``).replace(`player.`,``);for(let e of[`.videoji.hk`,`.vimeo.work`,`.videoji.cn`])if(n.endsWith(e))return n;return`vimeo.com`}function Yx(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.id,n=e.url,r=t||n;if(!r)throw Error(`An id or url must be passed, either in an options object or as a data-vimeo-id or data-vimeo-url attribute.`);if(Gx(r))return`https://vimeo.com/${r}`;if(Kx(r))return r.replace(`http:`,`https:`);throw TypeError(t?`“${t}” is not a valid video id.`:`“${r}” is not a vimeo.com url.`)}var Xx=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`addEventListener`,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:`removeEventListener`,a=typeof t==`string`?[t]:t;return a.forEach(t=>{e[r](t,n)}),{cancel:()=>a.forEach(t=>e[i](t,n))}};function Zx(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:document;if(!e||!t||typeof t.querySelectorAll!=`function`)return null;let n=t.querySelectorAll(`iframe`);for(let t=0;t<n.length;t++)if(n[t]&&n[t].contentWindow===e)return n[t];return null}var Qx=Array.prototype.indexOf!==void 0,$x=typeof window<`u`&&window.postMessage!==void 0;if(!Hx&&(!Qx||!$x))throw Error(`Sorry, the Vimeo Player API is not available in this browser.`);var eS=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function tS(e,t){return t={exports:{}},e(t,t.exports),t.exports}(function(e){if(e.WeakMap)return;var t=Object.prototype.hasOwnProperty,n=Object.defineProperty&&function(){try{return Object.defineProperty({},`x`,{value:1}).x===1}catch{}}(),r=function(e,t,r){n?Object.defineProperty(e,t,{configurable:!0,writable:!0,value:r}):e[t]=r};e.WeakMap=function(){function e(){if(this===void 0)throw TypeError(`Constructor WeakMap requires 'new'`);if(r(this,`_id`,a(`_WeakMap`)),arguments.length>0)throw TypeError(`WeakMap iterable is not supported`)}r(e.prototype,`delete`,function(e){if(n(this,`delete`),!i(e))return!1;var t=e[this._id];return t&&t[0]===e?(delete e[this._id],!0):!1}),r(e.prototype,`get`,function(e){if(n(this,`get`),i(e)){var t=e[this._id];if(t&&t[0]===e)return t[1]}}),r(e.prototype,`has`,function(e){if(n(this,`has`),!i(e))return!1;var t=e[this._id];return!!(t&&t[0]===e)}),r(e.prototype,`set`,function(e,t){if(n(this,`set`),!i(e))throw TypeError(`Invalid value used as weak map key`);var a=e[this._id];return a&&a[0]===e?(a[1]=t,this):(r(e,this._id,[e,t]),this)});function n(e,n){if(!i(e)||!t.call(e,`_id`))throw TypeError(n+` method called on incompatible receiver `+typeof e)}function a(e){return e+`_`+o()+`.`+o()}function o(){return Math.random().toString().substring(2)}return r(e,`_polyfill`,!0),e}();function i(e){return Object(e)===e}})(typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:eS);var nS=tS(function(e){(function(t,n,r){n[t]=n[t]||r(),e.exports&&=n[t]})(`Promise`,eS,function(){var e,t,n,r=Object.prototype.toString,i=typeof setImmediate<`u`?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},`x`,{}),e=function(e,t,n,r){return Object.defineProperty(e,t,{value:n,writable:!0,configurable:r!==!1})}}catch{e=function(e,t,n){return e[t]=n,e}}n=function(){var e,n,r;function i(e,t){this.fn=e,this.self=t,this.next=void 0}return{add:function(t,a){r=new i(t,a),n?n.next=r:e=r,n=r,r=void 0},drain:function(){var r=e;for(e=n=t=void 0;r;)r.fn.call(r.self),r=r.next}}}();function a(e,r){n.add(e,r),t||=i(n.drain)}function o(e){var t,n=typeof e;return e!=null&&(n==`object`||n==`function`)&&(t=e.then),typeof t==`function`?t:!1}function s(){for(var e=0;e<this.chain.length;e++)c(this,this.state===1?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function c(e,t,n){var r,i;try{t===!1?n.reject(e.msg):(r=t===!0?e.msg:t.call(void 0,e.msg),r===n.promise?n.reject(TypeError(`Promise-chain cycle`)):(i=o(r))?i.call(r,n.resolve,n.reject):n.resolve(r))}catch(e){n.reject(e)}}function l(e){var t,n=this;if(!n.triggered){n.triggered=!0,n.def&&(n=n.def);try{(t=o(e))?a(function(){var r=new f(n);try{t.call(e,function(){l.apply(r,arguments)},function(){u.apply(r,arguments)})}catch(e){u.call(r,e)}}):(n.msg=e,n.state=1,n.chain.length>0&&a(s,n))}catch(e){u.call(new f(n),e)}}}function u(e){var t=this;t.triggered||(t.triggered=!0,t.def&&(t=t.def),t.msg=e,t.state=2,t.chain.length>0&&a(s,t))}function d(e,t,n,r){for(var i=0;i<t.length;i++)(function(i){e.resolve(t[i]).then(function(e){n(i,e)},r)})(i)}function f(e){this.def=e,this.triggered=!1}function p(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function m(e){if(typeof e!=`function`)throw TypeError(`Not a function`);if(this.__NPO__!==0)throw TypeError(`Not a promise`);this.__NPO__=1;var t=new p(this);this.then=function(e,n){var r={success:typeof e==`function`?e:!0,failure:typeof n==`function`?n:!1};return r.promise=new this.constructor(function(e,t){if(typeof e!=`function`||typeof t!=`function`)throw TypeError(`Not a function`);r.resolve=e,r.reject=t}),t.chain.push(r),t.state!==0&&a(s,t),r.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,function(e){l.call(t,e)},function(e){u.call(t,e)})}catch(e){u.call(t,e)}}var h=e({},`constructor`,m,!1);return m.prototype=h,e(h,`__NPO__`,0,!1),e(m,`resolve`,function(e){var t=this;return e&&typeof e==`object`&&e.__NPO__===1?e:new t(function(t,n){if(typeof t!=`function`||typeof n!=`function`)throw TypeError(`Not a function`);t(e)})}),e(m,`reject`,function(e){return new this(function(t,n){if(typeof t!=`function`||typeof n!=`function`)throw TypeError(`Not a function`);n(e)})}),e(m,`all`,function(e){var t=this;return r.call(e)==`[object Array]`?e.length===0?t.resolve([]):new t(function(n,r){if(typeof n!=`function`||typeof r!=`function`)throw TypeError(`Not a function`);var i=e.length,a=Array(i),o=0;d(t,e,function(e,t){a[e]=t,++o===i&&n(a)},r)}):t.reject(TypeError(`Not an array`))}),e(m,`race`,function(e){var t=this;return r.call(e)==`[object Array]`?new t(function(n,r){if(typeof n!=`function`||typeof r!=`function`)throw TypeError(`Not a function`);d(t,e,function(e,t){n(t)},r)}):t.reject(TypeError(`Not an array`))}),m})}),rS=new WeakMap;function iS(e,t,n){let r=rS.get(e.element)||{};t in r||(r[t]=[]),r[t].push(n),rS.set(e.element,r)}function aS(e,t){return(rS.get(e.element)||{})[t]||[]}function oS(e,t,n){let r=rS.get(e.element)||{};if(!r[t])return!0;if(!n)return r[t]=[],rS.set(e.element,r),!0;let i=r[t].indexOf(n);return i!==-1&&r[t].splice(i,1),rS.set(e.element,r),r[t]&&r[t].length===0}function sS(e,t){let n=aS(e,t);if(n.length<1)return!1;let r=n.shift();return oS(e,t,r),r}function cS(e,t){let n=rS.get(e);rS.set(t,n),rS.delete(e)}function lS(e){if(typeof e==`string`)try{e=JSON.parse(e)}catch(e){return console.warn(e),{}}return e}function uS(e,t,n){if(!e.element.contentWindow||!e.element.contentWindow.postMessage)return;let r={method:t};n!==void 0&&(r.value=n);let i=parseFloat(navigator.userAgent.toLowerCase().replace(/^.*msie (\d+).*$/,`$1`));i>=8&&i<10&&(r=JSON.stringify(r)),e.element.contentWindow.postMessage(r,e.origin)}function dS(e,t){t=lS(t);let n=[],r;if(t.event)t.event===`error`&&aS(e,t.data.method).forEach(n=>{let r=Error(t.data.message);r.name=t.data.name,n.reject(r),oS(e,t.data.method,n)}),n=aS(e,`event:${t.event}`),r=t.data;else if(t.method){let i=sS(e,t.method);i&&(n.push(i),r=t.value)}n.forEach(t=>{try{if(typeof t==`function`){t.call(e,r);return}t.resolve(r)}catch{}})}var fS=`airplay.audio_tracks.audiotrack.autopause.autoplay.background.byline.cc.chapter_id.chapters.chromecast.color.colors.controls.disable_context_menu.dnt.end_time.fullscreen.height.id.initial_quality.interactive_params.keyboard.loop.maxheight.max_quality.maxwidth.min_quality.muted.play_button_position.playsinline.portrait.preload.progress_bar.quality.quality_selector.responsive.skipping_forward.speed.start_time.texttrack.thumbnail_id.title.transcript.transparent.unmute_button.url.vimeo_logo.volume.watch_full_video.width`.split(`.`);function pS(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return fS.reduce((t,n)=>{let r=e.getAttribute(`data-vimeo-${n}`);return(r||r===``)&&(t[n]=r===``?1:r),t},t)}function mS(e,t){let{html:n}=e;if(!t)throw TypeError(`An element must be provided`);if(t.getAttribute(`data-vimeo-initialized`)!==null)return t.querySelector(`iframe`);let r=document.createElement(`div`);return r.innerHTML=n,t.appendChild(r.firstChild),t.setAttribute(`data-vimeo-initialized`,`true`),t.querySelector(`iframe`)}function hS(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return new Promise((r,i)=>{if(!Kx(e))throw TypeError(`“${e}” is not a vimeo.com url.`);let a=`https://${Jx(e)}/api/oembed.json?url=${encodeURIComponent(e)}`;for(let e in t)t.hasOwnProperty(e)&&(a+=`&${e}=${encodeURIComponent(t[e])}`);let o=`XDomainRequest`in window?new XDomainRequest:new XMLHttpRequest;o.open(`GET`,a,!0),o.onload=function(){if(o.status===404){i(Error(`“${e}” was not found.`));return}if(o.status===403){i(Error(`“${e}” is not embeddable.`));return}try{let t=JSON.parse(o.responseText);if(t.domain_status_code===403){mS(t,n),i(Error(`“${e}” is not embeddable.`));return}r(t)}catch(e){i(e)}},o.onerror=function(){let e=o.status?` (${o.status})`:``;i(Error(`There was an error fetching the embed code from Vimeo${e}.`))},o.send()})}function gS(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document,t=[].slice.call(e.querySelectorAll(`[data-vimeo-id], [data-vimeo-url]`)),n=e=>{`console`in window&&console.error&&console.error(`There was an error creating an embed: ${e}`)};t.forEach(e=>{try{if(e.getAttribute(`data-vimeo-defer`)!==null)return;let t=pS(e);hS(Yx(t),t,e).then(t=>mS(t,e)).catch(n)}catch(e){n(e)}})}function _S(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoPlayerResizeEmbeds_||(window.VimeoPlayerResizeEmbeds_=!0,window.addEventListener(`message`,t=>{if(!Kx(t.origin)||!t.data||t.data.event!==`spacechange`)return;let n=t.source?Zx(t.source,e):null;if(n){let e=n.parentElement;e.style.paddingBottom=`${t.data.data[0].bottom}px`}}))}function vS(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoSeoMetadataAppended||(window.VimeoSeoMetadataAppended=!0,window.addEventListener(`message`,t=>{if(!Kx(t.origin))return;let n=lS(t.data);if(!n||n.event!==`ready`)return;let r=t.source?Zx(t.source,e):null;r&&qx(r.src)&&new DS(r).callMethod(`appendVideoMetadata`,window.location.href)}))}function yS(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;if(window.VimeoCheckedUrlTimeParam)return;window.VimeoCheckedUrlTimeParam=!0;let t=e=>{`console`in window&&console.error&&console.error(`There was an error getting video Id: ${e}`)};window.addEventListener(`message`,n=>{if(!Kx(n.origin))return;let r=lS(n.data);if(!r||r.event!==`ready`)return;let i=n.source?Zx(n.source,e):null;if(i&&qx(i.src)){let e=new DS(i);e.getVideoId().then(t=>{let n=RegExp(`[?&]vimeo_t_${t}=([^&#]*)`).exec(window.location.href);if(n&&n[1]){let t=decodeURI(n[1]);e.setCurrentTime(t)}}).catch(t)}})}function bS(){window.VimeoDRMEmbedsUpdated||(window.VimeoDRMEmbedsUpdated=!0,window.addEventListener(`message`,e=>{if(!Kx(e.origin))return;let t=lS(e.data);if(!t||t.event!==`drminitfailed`)return;let n=e.source?Zx(e.source):null;if(!n)return;let r=n.getAttribute(`allow`)||``;if(!r.includes(`encrypted-media`)){n.setAttribute(`allow`,`${r}; encrypted-media`);let e=new URL(n.getAttribute(`src`));e.searchParams.set(`forcereload`,`drm`),n.setAttribute(`src`,e.toString());return}}))}function xS(){let e=function(){let e,t=[[`requestFullscreen`,`exitFullscreen`,`fullscreenElement`,`fullscreenEnabled`,`fullscreenchange`,`fullscreenerror`],[`webkitRequestFullscreen`,`webkitExitFullscreen`,`webkitFullscreenElement`,`webkitFullscreenEnabled`,`webkitfullscreenchange`,`webkitfullscreenerror`],[`webkitRequestFullScreen`,`webkitCancelFullScreen`,`webkitCurrentFullScreenElement`,`webkitCancelFullScreen`,`webkitfullscreenchange`,`webkitfullscreenerror`],[`mozRequestFullScreen`,`mozCancelFullScreen`,`mozFullScreenElement`,`mozFullScreenEnabled`,`mozfullscreenchange`,`mozfullscreenerror`],[`msRequestFullscreen`,`msExitFullscreen`,`msFullscreenElement`,`msFullscreenEnabled`,`MSFullscreenChange`,`MSFullscreenError`]],n=0,r=t.length,i={};for(;n<r;n++)if(e=t[n],e&&e[1]in document){for(n=0;n<e.length;n++)i[t[0][n]]=e[n];return i}return!1}(),t={fullscreenchange:e.fullscreenchange,fullscreenerror:e.fullscreenerror},n={request(t){return new Promise((r,i)=>{let a=function(){n.off(`fullscreenchange`,a),r()};n.on(`fullscreenchange`,a),t||=document.documentElement;let o=t[e.requestFullscreen]();o instanceof Promise&&o.then(a).catch(i)})},exit(){return new Promise((t,r)=>{if(!n.isFullscreen){t();return}let i=function(){n.off(`fullscreenchange`,i),t()};n.on(`fullscreenchange`,i);let a=document[e.exitFullscreen]();a instanceof Promise&&a.then(i).catch(r)})},on(e,n){let r=t[e];r&&document.addEventListener(r,n)},off(e,n){let r=t[e];r&&document.removeEventListener(r,n)}};return Object.defineProperties(n,{isFullscreen:{get(){return!!document[e.fullscreenElement]}},element:{enumerable:!0,get(){return document[e.fullscreenElement]}},isEnabled:{enumerable:!0,get(){return!!document[e.fullscreenEnabled]}}}),n}var SS={role:`viewer`,autoPlayMuted:!0,allowedDrift:.3,maxAllowedDrift:1,minCheckInterval:.1,maxRateAdjustment:.2,maxTimeToCatchUp:1},CS=class extends EventTarget{logger;constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;super(),this.logger=r,this.init(t,e,{...SS,...n})}disconnect(){this.dispatchEvent(new Event(`disconnect`))}async init(e,t,n){if(await this.waitForTOReadyState(e,`open`),n.role===`viewer`){await this.updatePlayer(e,t,n);let r=Xx(e,`change`,()=>this.updatePlayer(e,t,n)),i=this.maintainPlaybackPosition(e,t,n);this.addEventListener(`disconnect`,()=>{i.cancel(),r.cancel()})}else{await this.updateTimingObject(e,t);let n=Xx(t,[`seeked`,`play`,`pause`,`ratechange`],()=>this.updateTimingObject(e,t),`on`,`off`);this.addEventListener(`disconnect`,()=>n.cancel())}}async updateTimingObject(e,t){let[n,r,i]=await Promise.all([t.getCurrentTime(),t.getPaused(),t.getPlaybackRate()]);e.update({position:n,velocity:r?0:i})}async updatePlayer(e,t,n){let{position:r,velocity:i}=e.query();typeof r==`number`&&t.setCurrentTime(r),typeof i==`number`&&(i===0?await t.getPaused()===!1&&t.pause():i>0&&(await t.getPaused()===!0&&(await t.play().catch(async e=>{e.name===`NotAllowedError`&&n.autoPlayMuted&&(await t.setMuted(!0),await t.play().catch(e=>console.error(`Couldn't play the video from TimingSrcConnector. Error:`,e)))}),this.updatePlayer(e,t,n)),await t.getPlaybackRate()!==i&&t.setPlaybackRate(i)))}maintainPlaybackPosition(e,t,n){let{allowedDrift:r,maxAllowedDrift:i,minCheckInterval:a,maxRateAdjustment:o,maxTimeToCatchUp:s}=n,c=Math.min(s,Math.max(a,i))*1e3,l=async()=>{if(e.query().velocity===0||await t.getPaused()===!0)return;let n=e.query().position-await t.getCurrentTime(),a=Math.abs(n);if(this.log(`Drift: ${n}`),a>i)await this.adjustSpeed(t,0),t.setCurrentTime(e.query().position),this.log(`Resync by currentTime`);else if(a>r){let e=a/s,r=o,i=e<r?(r-e)/2:r;await this.adjustSpeed(t,i*Math.sign(n)),this.log(`Resync by playbackRate`)}},u=setInterval(()=>l(),c);return{cancel:()=>clearInterval(u)}}log(e){this.logger?.(`TimingSrcConnector: ${e}`)}speedAdjustment=0;adjustSpeed=async(e,t)=>{if(this.speedAdjustment===t)return;let n=await e.getPlaybackRate()-this.speedAdjustment+t;this.log(`New playbackRate: ${n}`),await e.setPlaybackRate(n),this.speedAdjustment=t};waitForTOReadyState(e,t){return new Promise(n=>{let r=()=>{e.readyState===t?n():e.addEventListener(`readystatechange`,r,{once:!0})};r()})}},wS=new WeakMap,TS=new WeakMap,ES={},DS=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(window.jQuery&&e instanceof jQuery&&(e.length>1&&window.console&&console.warn&&console.warn(`A jQuery object with multiple elements was passed, using the first element.`),e=e[0]),typeof document<`u`&&typeof e==`string`&&(e=document.getElementById(e)),!Wx(e))throw TypeError(`You must pass either a valid element or a valid id.`);if(e.nodeName!==`IFRAME`){let t=e.querySelector(`iframe`);t&&(e=t)}if(e.nodeName===`IFRAME`&&!Kx(e.getAttribute(`src`)||``))throw Error(`The player element passed isn’t a Vimeo embed.`);if(wS.has(e))return wS.get(e);this._window=e.ownerDocument.defaultView,this.element=e,this.origin=`*`;let n=new nS((n,r)=>{if(this._onMessage=e=>{if(!Kx(e.origin)||this.element.contentWindow!==e.source)return;this.origin===`*`&&(this.origin=e.origin);let t=lS(e.data);if(t&&t.event===`error`&&t.data&&t.data.method===`ready`){let e=Error(t.data.message);e.name=t.data.name,r(e);return}let i=t&&t.event===`ready`,a=t&&t.method===`ping`;if(i||a){this.element.setAttribute(`data-ready`,`true`),n();return}dS(this,t)},this._window.addEventListener(`message`,this._onMessage),this.element.nodeName!==`IFRAME`){let n=pS(e,t);hS(Yx(n),n,e).then(t=>{let n=mS(t,e);return this.element=n,this._originalElement=e,cS(e,n),wS.set(this.element,this),t}).catch(r)}});if(TS.set(this,n),wS.set(this.element,this),this.element.nodeName===`IFRAME`&&uS(this,`ping`),ES.isEnabled){let e=()=>ES.exit();this.fullscreenchangeHandler=()=>{ES.isFullscreen?iS(this,`event:exitFullscreen`,e):oS(this,`event:exitFullscreen`,e),this.ready().then(()=>{uS(this,`fullscreenchange`,ES.isFullscreen)})},ES.on(`fullscreenchange`,this.fullscreenchangeHandler)}return this}static isVimeoUrl(e){return Kx(e)}callMethod(e){var t=[...arguments].slice(1);if(e==null)throw TypeError(`You must pass a method name.`);return new nS((n,r)=>this.ready().then(()=>{iS(this,e,{resolve:n,reject:r}),t.length===0?t={}:t.length===1&&(t=t[0]),uS(this,e,t)}).catch(r))}get(e){return new nS((t,n)=>(e=Ux(e,`get`),this.ready().then(()=>{iS(this,e,{resolve:t,reject:n}),uS(this,e)}).catch(n)))}set(e,t){return new nS((n,r)=>{if(e=Ux(e,`set`),t==null)throw TypeError(`There must be a value to set.`);return this.ready().then(()=>{iS(this,e,{resolve:n,reject:r}),uS(this,e,t)}).catch(r)})}on(e,t){if(!e)throw TypeError(`You must pass an event name.`);if(!t)throw TypeError(`You must pass a callback function.`);if(typeof t!=`function`)throw TypeError(`The callback must be a function.`);aS(this,`event:${e}`).length===0&&this.callMethod(`addEventListener`,e).catch(()=>{}),iS(this,`event:${e}`,t)}off(e,t){if(!e)throw TypeError(`You must pass an event name.`);if(t&&typeof t!=`function`)throw TypeError(`The callback must be a function.`);oS(this,`event:${e}`,t)&&this.callMethod(`removeEventListener`,e).catch(e=>{})}loadVideo(e){return this.callMethod(`loadVideo`,e)}ready(){let e=TS.get(this)||new nS((e,t)=>{t(Error(`Unknown player. Probably unloaded.`))});return nS.resolve(e)}addCuePoint(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.callMethod(`addCuePoint`,{time:e,data:t})}removeCuePoint(e){return this.callMethod(`removeCuePoint`,e)}enableTextTrack(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e)throw TypeError(`You must pass a language.`);return this.callMethod(`enableTextTrack`,{language:e,kind:t,showing:n})}disableTextTrack(){return this.callMethod(`disableTextTrack`)}selectAudioTrack(e,t){if(!e)throw TypeError(`You must pass a language.`);return this.callMethod(`selectAudioTrack`,{language:e,kind:t})}selectDefaultAudioTrack(){return this.callMethod(`selectDefaultAudioTrack`)}pause(){return this.callMethod(`pause`)}play(){return this.callMethod(`play`)}requestFullscreen(){return ES.isEnabled?ES.request(this.element):this.callMethod(`requestFullscreen`)}exitFullscreen(){return ES.isEnabled?ES.exit():this.callMethod(`exitFullscreen`)}getFullscreen(){return ES.isEnabled?nS.resolve(ES.isFullscreen):this.get(`fullscreen`)}requestPictureInPicture(){return this.callMethod(`requestPictureInPicture`)}exitPictureInPicture(){return this.callMethod(`exitPictureInPicture`)}getPictureInPicture(){return this.get(`pictureInPicture`)}remotePlaybackPrompt(){return this.callMethod(`remotePlaybackPrompt`)}unload(){return this.callMethod(`unload`)}destroy(){return new nS(e=>{if(TS.delete(this),wS.delete(this.element),this._originalElement&&(wS.delete(this._originalElement),this._originalElement.removeAttribute(`data-vimeo-initialized`)),this.element&&this.element.nodeName===`IFRAME`&&this.element.parentNode&&(this.element.parentNode.parentNode&&this._originalElement&&this._originalElement!==this.element.parentNode?this.element.parentNode.parentNode.removeChild(this.element.parentNode):this.element.parentNode.removeChild(this.element)),this.element&&this.element.nodeName===`DIV`&&this.element.parentNode){this.element.removeAttribute(`data-vimeo-initialized`);let e=this.element.querySelector(`iframe`);e&&e.parentNode&&(e.parentNode.parentNode&&this._originalElement&&this._originalElement!==e.parentNode?e.parentNode.parentNode.removeChild(e.parentNode):e.parentNode.removeChild(e))}this._window.removeEventListener(`message`,this._onMessage),ES.isEnabled&&ES.off(`fullscreenchange`,this.fullscreenchangeHandler),e()})}getAutopause(){return this.get(`autopause`)}setAutopause(e){return this.set(`autopause`,e)}getBuffered(){return this.get(`buffered`)}getCameraProps(){return this.get(`cameraProps`)}setCameraProps(e){return this.set(`cameraProps`,e)}getChapters(){return this.get(`chapters`)}getCurrentChapter(){return this.get(`currentChapter`)}getColor(){return this.get(`color`)}getColors(){return nS.all([this.get(`colorOne`),this.get(`colorTwo`),this.get(`colorThree`),this.get(`colorFour`)])}setColor(e){return this.set(`color`,e)}setColors(e){if(!Array.isArray(e))return new nS((e,t)=>t(TypeError(`Argument must be an array.`)));let t=new nS(e=>e(null)),n=[e[0]?this.set(`colorOne`,e[0]):t,e[1]?this.set(`colorTwo`,e[1]):t,e[2]?this.set(`colorThree`,e[2]):t,e[3]?this.set(`colorFour`,e[3]):t];return nS.all(n)}getCuePoints(){return this.get(`cuePoints`)}getCurrentTime(){return this.get(`currentTime`)}setCurrentTime(e){return this.set(`currentTime`,e)}getDuration(){return this.get(`duration`)}getEnded(){return this.get(`ended`)}getLoop(){return this.get(`loop`)}setLoop(e){return this.set(`loop`,e)}setMuted(e){return this.set(`muted`,e)}getMuted(){return this.get(`muted`)}getPaused(){return this.get(`paused`)}getPlaybackRate(){return this.get(`playbackRate`)}setPlaybackRate(e){return this.set(`playbackRate`,e)}getPlayed(){return this.get(`played`)}getQualities(){return this.get(`qualities`)}getQuality(){return this.get(`quality`)}setQuality(e){return this.set(`quality`,e)}getRemotePlaybackAvailability(){return this.get(`remotePlaybackAvailability`)}getRemotePlaybackState(){return this.get(`remotePlaybackState`)}getSeekable(){return this.get(`seekable`)}getSeeking(){return this.get(`seeking`)}getTextTracks(){return this.get(`textTracks`)}getAudioTracks(){return this.get(`audioTracks`)}getEnabledAudioTrack(){return this.get(`enabledAudioTrack`)}getDefaultAudioTrack(){return this.get(`defaultAudioTrack`)}getVideoEmbedCode(){return this.get(`videoEmbedCode`)}getVideoId(){return this.get(`videoId`)}getVideoTitle(){return this.get(`videoTitle`)}getVideoWidth(){return this.get(`videoWidth`)}getVideoHeight(){return this.get(`videoHeight`)}getVideoUrl(){return this.get(`videoUrl`)}getVolume(){return this.get(`volume`)}setVolume(e){return this.set(`volume`,e)}async setTimingSrc(e,t){if(!e)throw TypeError(`A Timing Object must be provided.`);await this.ready();let n=new CS(this,e,t);return uS(this,`notifyTimingObjectConnect`),n.addEventListener(`disconnect`,()=>uS(this,`notifyTimingObjectDisconnect`)),n}};Hx||(ES=xS(),gS(),_S(),vS(),yS(),bS());function OS(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,kS(e,t)}function kS(e,t){return kS=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},kS(e,t)}var AS={play:`onPlay`,playing:`onPlaying`,pause:`onPause`,ended:`onEnd`,timeupdate:`onTimeUpdate`,progress:`onProgress`,seeked:`onSeeked`,texttrackchange:`onTextTrackChange`,cuechange:`onCueChange`,cuepoint:`onCuePoint`,volumechange:`onVolumeChange`,playbackratechange:`onPlaybackRateChange`,error:`onError`,loaded:`onLoaded`},jS=function(e){function t(t){var n=e.call(this,t)||this;return n.refContainer=n.refContainer.bind(n),n}OS(t,e);var n=t.prototype;return n.componentDidMount=function(){this.createPlayer()},n.componentDidUpdate=function(e){var t=this,n=Object.keys(this.props).filter(function(n){return t.props[n]!==e[n]});this.updateProps(n)},n.componentWillUnmount=function(){this.player.destroy()},n.getInitialOptions=function(){var e,t=this.props.video,n=/^https?:/i.test(t)?`url`:`id`;return e={},e[n]=t,e.width=this.props.width,e.height=this.props.height,e.autopause=this.props.autopause,e.autoplay=this.props.autoplay,e.byline=this.props.showByline,e.color=this.props.color,e.controls=this.props.controls,e.loop=this.props.loop,e.portrait=this.props.showPortrait,e.title=this.props.showTitle,e.muted=this.props.muted,e.background=this.props.background,e.responsive=this.props.responsive,e.dnt=this.props.dnt,e.speed=this.props.speed,e.keyboard=this.props.keyboard,e.pip=this.props.pip,e.playsinline=this.props.playsInline,e.quality=this.props.quality,e.texttrack=this.props.textTrack,e.transparent=this.props.transparent,e},n.updateProps=function(e){var t=this,n=this.player;e.forEach(function(e){var r=t.props[e];switch(e){case`autopause`:n.setAutopause(r);break;case`color`:n.setColor(r);break;case`loop`:n.setLoop(r);break;case`volume`:n.setVolume(r);break;case`paused`:n.getPaused().then(function(e){return r&&!e?n.pause():!r&&e?n.play():null});break;case`width`:case`height`:n.element[e]=r;break;case`video`:if(r){var i=t.props.start,a=n.loadVideo(r);typeof i==`number`&&a.then(function(){n.setCurrentTime(i)})}else n.unload();break;case`playbackRate`:n.setPlaybackRate(r);break;case`quality`:n.setQuality(r);break}})},n.createPlayer=function(){var e=this,t=this.props,n=t.start,r=t.volume,i=t.playbackRate;this.player=new DS(this.container,this.getInitialOptions()),Object.keys(AS).forEach(function(t){var n=AS[t];e.player.on(t,function(t){var r=e.props[n];r&&r(t)})});var a=this.props,o=a.onError,s=a.onReady;this.player.ready().then(function(){s&&s(e.player)},function(e){if(o)o(e);else throw e}),typeof n==`number`&&this.player.setCurrentTime(n),typeof r==`number`&&this.updateProps([`volume`]),typeof i==`number`&&this.updateProps([`playbackRate`])},n.refContainer=function(e){this.container=e},n.render=function(){var e=this.props,t=e.id,n=e.className,r=e.style;return Z.createElement(`div`,{id:t,className:n,style:r,ref:this.refContainer})},t}(Z.Component);jS.defaultProps={autopause:!0,autoplay:!1,showByline:!0,controls:!0,loop:!1,showPortrait:!0,showTitle:!0,muted:!1,background:!1,responsive:!1,dnt:!1,speed:!1,keyboard:!0,pip:!1,playsInline:!0,transparent:!0};var MS={default:120,mqdefault:320,hqdefault:480,sddefault:640,maxresdefault:1280},NS=(e,t,n,r=`maxresdefault`)=>{let[i,a]=(0,Z.useState)(``);return(0,Z.useEffect)(()=>{let i=`https://img.youtube.com/${t}/${e}/${r}.${n}`,o=`https://img.youtube.com/${t}/${e}/hqdefault.${n}`,s=MS[r],c=new Image;c.onload=()=>{c.width<s?a(o):a(i)},c.onerror=()=>a(o),c.src=i},[e,t,n,r]),i};function PS(e,t,n,r,i){let a={"@context":`https://schema.org`,"@type":`VideoObject`,name:i?.name||t,thumbnailUrl:[i?.thumbnailUrl||n],embedUrl:i?.embedUrl||`${r}/embed/${e}`,contentUrl:i?.contentUrl||`https://www.youtube.com/watch?v=${e}`,...i?.description&&{description:i.description},...i?.uploadDate&&{uploadDate:i.uploadDate},...i?.duration&&{duration:i.duration}};return JSON.stringify(a)}function FS(e,t){let[n,r]=Z.useState(!1),[i,a]=Z.useState(e.alwaysLoadIframe||!1),o=encodeURIComponent(e.id),s=typeof e.playlistCoverId==`string`?encodeURIComponent(e.playlistCoverId):null,c=e.title,l=e.poster||`hqdefault`,u=e.announce||`Watch`,d=e.alwaysLoadIframe?e.autoplay&&e.muted:!0,f=Z.useMemo(()=>{let t=new URLSearchParams({...e.muted?{mute:`1`}:{},...d?{autoplay:`1`}:{},...e.enableJsApi?{enablejsapi:`1`}:{},...e.enableJsApi&&typeof window<`u`?{origin:window.location.origin}:{},...e.playlist?{list:o}:{}});return e.params&&new URLSearchParams(e.params.startsWith(`&`)?e.params.slice(1):e.params).forEach((e,n)=>{t.append(n,e)}),t},[e.muted,d,e.enableJsApi,e.playlist,o,e.params]),p=Z.useMemo(()=>e.cookie?`https://www.youtube.com`:`https://www.youtube-nocookie.com`,[e.cookie]),m=Z.useMemo(()=>e.playlist?`${p}/embed/videoseries?${f.toString()}`:`${p}/embed/${o}?${f.toString()}`,[e.playlist,p,o,f]),h=!e.thumbnail&&!e.playlist&&l===`maxresdefault`,g=e.webp?`webp`:`jpg`,_=e.webp?`vi_webp`:`vi`,v=h?NS(e.id,_,g,l):null,y=Z.useMemo(()=>e.thumbnail||v||`https://i.ytimg.com/${_}/${e.playlist?s:o}/${l}.${g}`,[e.thumbnail,v,_,e.playlist,s,o,l,g]),b=e.activatedClass||`lyt-activated`,x=e.adNetwork||!1,S=e.aspectHeight||9,C=e.aspectWidth||16,w=e.iframeClass||``,T=e.playerClass||`lty-playbtn`,E=e.wrapperClass||`yt-lite`,D=Z.useCallback(e.onIframeAdded||function(){},[e.onIframeAdded]),O=e.rel?`prefetch`:`preload`,k=e.containerElement||`article`,A=e.noscriptFallback!==!1,j=()=>{n||r(!0)},M=()=>{i||a(!0)};return Z.useEffect(()=>{i&&(D(),e.focusOnLoad&&typeof t==`object`&&t?.current&&t.current.focus())},[i,D,e.focusOnLoad,t]),Z.useEffect(()=>{if(!i||!e.enableJsApi||!(e.onReady||e.onStateChange||e.onError||e.onPlay||e.onPause||e.onEnd||e.onBuffering||e.onPlaybackRateChange||e.onPlaybackQualityChange))return;let n=!1,r=!1,a=r=>{if(r.origin!==`https://www.youtube.com`&&r.origin!==`https://www.youtube-nocookie.com`)return;let i;try{i=typeof r.data==`string`?JSON.parse(r.data):r.data}catch{return}switch(i.event){case`onReady`:n||(n=!0,e.onReady&&e.onReady({videoId:e.id,title:c}));break;case`infoDelivery`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate),i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break;case`onStateChange`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}break;case`onError`:if(i.info&&`errorCode`in i.info){let t=i.info.errorCode;e.onError&&e.onError(t)}break;case`onPlaybackRateChange`:i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate);break;case`onPlaybackQualityChange`:i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break}};window.addEventListener(`message`,a);let s=[],l=()=>{typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"listening","id":"`+o+`"}`,`*`)},u=()=>{r||(r=!0,l(),[100,300,600,1200,2400].forEach(e=>{s.push(setTimeout(l,e))}))};return typeof t==`object`&&t?.current?(t.current.addEventListener(`load`,u),t.current.contentDocument?.readyState===`complete`&&u()):[200,500,1e3,2e3,3e3].forEach(e=>{s.push(setTimeout(l,e))}),()=>{window.removeEventListener(`message`,a),s.forEach(clearTimeout),typeof t==`object`&&t?.current&&t.current.removeEventListener(`load`,u)}},[i,e.enableJsApi,e.onReady,e.onStateChange,e.onError,e.onPlay,e.onPause,e.onEnd,e.onBuffering,e.onPlaybackRateChange,e.onPlaybackQualityChange,e.stopOnEnd,e.id,o,c,t]),(0,$.jsxs)($.Fragment,{children:[!e.lazyLoad&&(0,$.jsx)(`link`,{rel:O,href:y,as:`image`}),(0,$.jsx)($.Fragment,{children:n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`link`,{rel:`preconnect`,href:p}),(0,$.jsx)(`link`,{rel:`preconnect`,href:`https://www.google.com`}),x&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`link`,{rel:`preconnect`,href:`https://static.doubleclick.net`}),(0,$.jsx)(`link`,{rel:`preconnect`,href:`https://googleads.g.doubleclick.net`})]})]})}),e.seo&&!e.playlist&&(0,$.jsx)(`script`,{type:`application/ld+json`,dangerouslySetInnerHTML:{__html:PS(e.id,c,y,p,e.seo)}}),A&&!e.playlist&&(0,$.jsx)(`noscript`,{children:(0,$.jsxs)(`a`,{href:`https://www.youtube.com/watch?v=${e.id}`,"aria-label":`Watch ${c} on YouTube`,children:[`Watch "`,c,`" on YouTube`]})}),(0,$.jsxs)(k,{onPointerOver:j,onClick:M,className:`${E} ${i?b:``}`,"data-title":c,role:!i&&!e.lazyLoad?`img`:void 0,"aria-label":i?void 0:`${c} - YouTube video preview`,style:{...!e.lazyLoad&&{backgroundImage:`url(${y})`},"--aspect-ratio":`${S/C*100}%`,...e.style||{}},children:[e.lazyLoad&&!i&&(0,$.jsx)(`img`,{src:y,alt:`${c} - YouTube thumbnail`,className:`lty-thumbnail`,loading:`lazy`}),e.playlist&&!i&&(0,$.jsx)(`div`,{className:`lty-playlist-icon`,"aria-hidden":`true`}),!(e.hideButtonOnActivate&&i)&&(0,$.jsx)(`button`,{type:`button`,className:T,"aria-label":`${u} ${c}`,"aria-hidden":i||void 0,tabIndex:i?-1:0,onClick:M,children:(0,$.jsx)(`span`,{className:`lty-visually-hidden`,children:u})}),i&&(0,$.jsx)(`iframe`,{ref:t,className:w,title:c,width:`560`,height:`315`,allow:`accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,src:m,referrerPolicy:e.referrerPolicy||`strict-origin-when-cross-origin`})]})]})}var IS=Z.forwardRef(FS);function LS(e){return e!==!1}function RS(e,t){let n=[];return t.startSeconds!==null&&n.push(`start=${t.startSeconds}`),e.controls===!1&&n.push(`controls=0`),e.loop===!0&&n.push(`loop=1`,`playlist=${t.id}`),e.playsinline===!0&&n.push(`playsinline=1`),n.length>0?n.join(`&`):void 0}function zS(e){if(e.width!==void 0)return{width:e.width}}function BS(e){if(!(e.width===void 0||e.height===void 0))return{aspectRatio:`${e.width} / ${e.height}`}}function VS(e){let t=(0,Q.c)(23),n=(0,Z.useRef)(null),r=e.title??`Vimeo video player`,i;t[0]===r?i=t[1]:(i=e=>{let t=e;n.current=t,t.element&&(t.element.title=r)},t[0]=r,t[1]=i);let a=i,o,s;t[2]===r?(o=t[3],s=t[4]):(o=()=>{let e=n.current;e?.element&&(e.element.title=r)},s=[r],t[2]=r,t[3]=o,t[4]=s),(0,Z.useEffect)(o,s);let c;t[5]===e?c=t[6]:(c=zS(e),t[5]=e,t[6]=c);let l=e.width===void 0,u=e.autoplay===!0,d=e.muted===!0,f=e.muted===!0?0:1,p=e.loop===!0,m=e.controls!==!1,h=e.playsinline!==!1,g;t[7]!==a||t[8]!==e.height||t[9]!==e.src||t[10]!==e.width||t[11]!==h||t[12]!==l||t[13]!==u||t[14]!==d||t[15]!==f||t[16]!==p||t[17]!==m?(g=(0,$.jsx)(jS,{video:e.src,responsive:l,width:e.width,height:e.height,autoplay:u,muted:d,volume:f,loop:p,controls:m,playsInline:h,onReady:a}),t[7]=a,t[8]=e.height,t[9]=e.src,t[10]=e.width,t[11]=h,t[12]=l,t[13]=u,t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=g):g=t[18];let _;return t[19]!==e.title||t[20]!==g||t[21]!==c?(_=(0,$.jsx)(`div`,{className:`ok-video ok-video-vimeo`,style:c,title:e.title,children:g}),t[19]=e.title,t[20]=g,t[21]=c,t[22]=_):_=t[22],_}function HS(e){let t=(0,Q.c)(17),n;t[0]===e.src?n=t[1]:(n=$t(e.src),t[0]=e.src,t[1]=n);let r=n;if(!r)return null;let i;t[2]!==r.startRaw||t[3]!==e.autoplay||t[4]!==e.muted?(i=[],r.startRaw!==null&&i.push(`t=${r.startRaw}`),e.autoplay===!0&&i.push(`autoplay=true`),e.muted===!0&&i.push(`muted=true`),t[2]=r.startRaw,t[3]=e.autoplay,t[4]=e.muted,t[5]=i):i=t[5];let a=i.length>0?`https://www.loom.com/embed/${r.id}?${i.join(`&`)}`:`https://www.loom.com/embed/${r.id}`,o;t[6]===e?o=t[7]:(o=zS(e),t[6]=e,t[7]=o);let s=e.title??`Loom video player`,c;t[8]!==a||t[9]!==e.height||t[10]!==e.width||t[11]!==s?(c=(0,$.jsx)(`iframe`,{className:`ok-video-loom-iframe`,src:a,title:s,width:e.width,height:e.height,allow:`autoplay; fullscreen`,referrerPolicy:`strict-origin-when-cross-origin`,allowFullScreen:!0}),t[8]=a,t[9]=e.height,t[10]=e.width,t[11]=s,t[12]=c):c=t[12];let l;return t[13]!==e.title||t[14]!==o||t[15]!==c?(l=(0,$.jsx)(`div`,{className:`ok-video ok-video-loom`,style:o,title:e.title,children:c}),t[13]=e.title,t[14]=o,t[15]=c,t[16]=l):l=t[16],l}function US(e){let t=(0,Q.c)(29);if(e.src!==void 0&&Fn(e.src)){let n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(HS,{...e,src:e.src}),t[0]=e,t[1]=n),n}if(e.src!==void 0&&ui(e.src)){let n;return t[2]===e?n=t[3]:(n=(0,$.jsx)(VS,{...e,src:e.src}),t[2]=e,t[3]=n),n}let n;if(t[4]!==e){n=Symbol.for(`react.early_return_sentinel`);bb0:{let r=e.src===void 0?null:Yt(e.src);if(r!==null){let i=e.autoplay===!0&&e.muted===!0,a=e.width!==void 0&&e.height!==void 0,o=zS(e),s;t[6]===e.poster?s=t[7]:(s=e.poster===void 0?void 0:Lo(e.poster),t[6]=e.poster,t[7]=s);let c=(0,$.jsx)(IS,{id:r.id,title:e.title??`YouTube video player`,cookie:!r.noCookie,params:RS(e,r),muted:e.muted===!0,autoplay:e.autoplay===!0,alwaysLoadIframe:i,thumbnail:s,aspectWidth:a?Number(e.width):void 0,aspectHeight:a?Number(e.height):void 0,style:BS(e)}),l;t[8]!==o||t[9]!==c?(l=(0,$.jsx)(`div`,{className:`ok-video ok-video-youtube`,style:o,children:c}),t[8]=o,t[9]=c,t[10]=l):l=t[10],n=l;break bb0}}t[4]=e,t[5]=n}else n=t[5];if(n!==Symbol.for(`react.early_return_sentinel`))return n;let r;t[11]===e.src?r=t[12]:(r=e.src===void 0?void 0:Lo(e.src),t[11]=e.src,t[12]=r);let i=e.title,a;t[13]===e.controls?a=t[14]:(a=LS(e.controls),t[13]=e.controls,t[14]=a);let o;t[15]===e.poster?o=t[16]:(o=e.poster===void 0?void 0:Lo(e.poster),t[15]=e.poster,t[16]=o);let s;return t[17]!==e.autoplay||t[18]!==e.height||t[19]!==e.loop||t[20]!==e.muted||t[21]!==e.playsinline||t[22]!==e.preload||t[23]!==e.title||t[24]!==e.width||t[25]!==r||t[26]!==a||t[27]!==o?(s=(0,$.jsx)(`video`,{className:`ok-video`,src:r,title:i,controls:a,autoPlay:e.autoplay,muted:e.muted,loop:e.loop,playsInline:e.playsinline,poster:o,preload:e.preload,width:e.width,height:e.height}),t[17]=e.autoplay,t[18]=e.height,t[19]=e.loop,t[20]=e.muted,t[21]=e.playsinline,t[22]=e.preload,t[23]=e.title,t[24]=e.width,t[25]=r,t[26]=a,t[27]=o,t[28]=s):s=t[28],s}function WS(e){let t=(0,Q.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,$.jsx)(`div`,{className:`prose-no-margin`,children:e.children}),t[0]=e.children,t[1]=n),n}var GS={Callout:_v,img:_b,video:US,audio:fv,Pdf:Cx,File:sy,Embed:Dv,Excalidraw:Zv,Accordion:cv,Toggle:e=>(0,$.jsx)(cv,{...e,title:e.title??`Toggle`}),HtmlAlignBlock:uv,Tabs:Fx,Tab:jx,Math:bb,MermaidFence:Et,Mirror:cx,MirrorSource:lx,"*":WS};function KS(e){let t=new Set;for(let n of e)n.type===`reactnode`&&t.add(n.name);return t}var qS=mi(),JS=new Map;function YS(e){if(e.surface===`compat`){let t=GS[e.rendersAs];if(!t)throw Error(`Compat descriptor '${e.name}' declares rendersAs: '${e.rendersAs}', but no React component is registered under that name in componentMap. Add the canonical component before registering the compat descriptor.`);return{Component:t,reactNodePropNames:KS(e.props)}}let t=GS[e.name];return t?{Component:t,reactNodePropNames:KS(e.props)}:null}for(let[e,t]of qS.entries()){let n=YS(t);n&&JS.set(e,n)}function XS(e,t){return{...e,Component:t.Component,reactNodePropNames:t.reactNodePropNames}}function ZS(e){let t=qS.getOrWildcard(e),n=JS.get(t.name)??JS.get(`*`);if(!n)throw Error(`No React component registered for ${t.name} (and no '*' wildcard)`);return XS(t,n)}function QS(){let e=[];for(let[t,n]of qS.entries()){if(t===`*`)continue;let r=JS.get(t);r&&e.push(XS(n,r))}return e}var $S=`source`,eC=40;function tC(e,t){let n=``;return e.nodesBetween(0,t,(e,r)=>{e.type.name===`heading`&&r+e.nodeSize<=t&&(n=e.textContent)}),n}function nC(e){if(e.length<=eC)return e;let t=Iu(e,eC),n=t.lastIndexOf(`-`);return n>0?t.slice(0,n):t}function rC(e){let t=new Set;return e.descendants(e=>{if(e.type.name!==`jsxComponent`||e.attrs.componentName!==`MirrorSource`)return;let n=tx(e.attrs.props??{});n!==``&&t.add(n)}),t}function iC(e,t){let n=nC(ao(tC(e,t)))||$S,r=rC(e);if(!r.has(n))return n;let i=1;for(;r.has(`${n}-${i}`);)i+=1;return`${n}-${i}`}var aC=``+new URL(`image-preview-BJSGEOo4.png`,import.meta.url).href,oC=``+new URL(`video-preview-vLovc_Vy.png`,import.meta.url).href,sC={Callout:{description:{id:`322lyb`},props:()=>({type:`note`,title:Y._({id:`6s7LXO`})}),children:()=>Y._({id:`64sesb`})},Accordion:{description:{id:`mWVJRX`},props:()=>({title:Y._({id:`z9NwEu`}),defaultOpen:!0}),children:()=>Y._({id:`8uGMP8`})},Toggle:{description:{id:`D0_8qa`},props:()=>({title:Y._({id:`z9NwEu`}),defaultOpen:!0}),children:()=>Y._({id:`8uGMP8`})},img:{description:{id:`VUijjF`},props:()=>({src:aC,alt:Y._({id:`R9dK63`})})},video:{description:{id:`e1hptq`},props:()=>({controls:!0,poster:oC})},audio:{description:{id:`9jnjV0`},props:()=>({controls:!0})},Math:{description:{id:`Y-Urt2`},props:()=>({formula:`c = \\pm\\sqrt{a^2 + b^2}`})},Excalidraw:{description:{id:`qi17kj`},render:()=>(0,$.jsx)(`div`,{className:`flex h-full w-full items-center justify-center rounded-md border border-border bg-background p-3`,children:(0,$.jsxs)(`svg`,{viewBox:`0 0 120 60`,className:`h-full w-auto`,"aria-hidden":`true`,children:[(0,$.jsx)(`rect`,{x:`6`,y:`10`,width:`46`,height:`26`,rx:`6`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`text-muted-foreground`}),(0,$.jsx)(`ellipse`,{cx:`92`,cy:`38`,rx:`20`,ry:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`text-muted-foreground/70`}),(0,$.jsx)(`path`,{d:`M52 23 C 66 23, 70 34, 72 36`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`text-muted-foreground/50`})]})})},Embed:{description:{id:`jTLWxh`},render:()=>(0,$.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border bg-muted/40 px-2 py-1.5`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,$.jsx)(`span`,{className:`ml-1.5 flex-1 truncate rounded-sm bg-background px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:`https://example.com/embed`})]}),(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col justify-center gap-1.5 px-3 py-2`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`h-1.5 w-full rounded-sm bg-muted-foreground/20`}),(0,$.jsx)(`span`,{className:`h-1.5 w-5/6 rounded-sm bg-muted-foreground/20`}),(0,$.jsx)(`span`,{className:`h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]})]})},Pdf:{description:{id:`Fqr8BP`},render:()=>(0,$.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border bg-muted/40 px-1.5 py-1`,children:[(0,$.jsxs)(`svg`,{viewBox:`0 0 12 12`,className:`size-3 text-muted-foreground`,"aria-hidden":`true`,children:[(0,$.jsx)(`title`,{children:`Thumbnails`}),(0,$.jsx)(`rect`,{x:`1`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,$.jsx)(`rect`,{x:`7`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,$.jsx)(`rect`,{x:`1`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,$.jsx)(`rect`,{x:`7`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`})]}),(0,$.jsxs)(`span`,{className:`ml-1 flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5 font-mono`,children:`2`}),(0,$.jsx)(`span`,{children:`/ 12`})]}),(0,$.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] font-mono text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`−`}),(0,$.jsx)(`span`,{children:`100%`}),(0,$.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`+`})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-1 gap-1 p-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex w-6 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`}),(0,$.jsx)(`span`,{className:`h-3 rounded-sm border border-foreground/60 bg-background`}),(0,$.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`})]}),(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1 rounded-sm bg-background p-1.5`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1/2 rounded-sm bg-foreground/50`}),(0,$.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`h-1 w-5/6 rounded-sm bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`h-1 w-2/3 rounded-sm bg-muted-foreground/30`})]})]})]})},MermaidFence:{description:{id:`z0a2EA`},render:()=>(0,$.jsxs)(`svg`,{viewBox:`0 0 200 120`,className:`h-full w-full text-foreground`,"aria-hidden":`true`,preserveAspectRatio:`xMidYMid meet`,children:[(0,$.jsx)(`title`,{children:`Mermaid flowchart preview`}),(0,$.jsx)(`defs`,{children:(0,$.jsx)(`marker`,{id:`mermaid-preview-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto-start-reverse`,children:(0,$.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`currentColor`})})}),(0,$.jsx)(`rect`,{x:`14`,y:`20`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,$.jsx)(`text`,{x:`42`,y:`38`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Start`}),(0,$.jsx)(`polygon`,{points:`100,18 140,50 100,82 60,50`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,$.jsx)(`text`,{x:`100`,y:`54`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Ready?`}),(0,$.jsx)(`rect`,{x:`130`,y:`84`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,$.jsx)(`text`,{x:`158`,y:`102`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`End`}),(0,$.jsx)(`line`,{x1:`70`,y1:`34`,x2:`80`,y2:`40`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,$.jsx)(`line`,{x1:`124`,y1:`62`,x2:`138`,y2:`82`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,$.jsx)(`text`,{x:`138`,y:`74`,fontSize:`8`,fill:`currentColor`,opacity:`0.6`,children:`yes`})]})},Tabs:{description:{id:`75Y1dk`},render:()=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex gap-1 border-b border-border pb-1`,children:[(0,$.jsx)(`span`,{className:`rounded-md bg-foreground/10 px-2 py-0.5 text-xs font-medium text-foreground`,children:`Tab 1`}),(0,$.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs text-muted-foreground`,children:`Tab 2`})]}),(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:(0,$.jsx)(a,{id:`m6YGpY`})})]})},Mirror:{description:{id:`_WPP7e`},render:()=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/40 px-2 py-1.5`,children:[(0,$.jsxs)(`span`,{className:`absolute -top-2 right-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(Yl,{className:`size-2.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:(0,$.jsx)(a,{id:`EL_YRd`,components:{0:(0,$.jsx)(`code`,{className:`font-mono`})}})})]}),(0,$.jsx)(`span`,{className:`block h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`mt-1 block h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]}),(0,$.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,$.jsx)(a,{id:`qNOgUu`})})]})},MirrorSource:{description:{id:`epuNYK`},render:()=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/50 px-2 py-1.5`,children:[(0,$.jsxs)(`span`,{className:`absolute -top-2 left-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(ql,{className:`size-2.5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:(0,$.jsx)(a,{id:`maDWIB`,components:{0:(0,$.jsx)(`code`,{className:`font-mono`})}})})]}),(0,$.jsx)(`span`,{className:`block h-1.5 w-4/5 rounded-sm bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`mt-1 block h-1.5 w-3/5 rounded-sm bg-muted-foreground/20`})]}),(0,$.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,$.jsx)(a,{id:`emgiet`})})]})}};function cC(e){let t={};for(let n of e.props)n.type!==`reactnode`&&`defaultValue`in n&&n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);return t}function lC(e){let t=ZS(e),n=cC(t);return{type:`jsxComponent`,attrs:{componentName:t.name,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:n},content:t.hasChildren?[{type:`paragraph`}]:void 0}}var uC=new Set;function dC(e){uC.add(e)}function fC(e){if(typeof e==`number`)return uC.delete(e);let t=uC.values().next();return t.done?!1:(uC.delete(t.value),!0)}function pC(e,t,n){n.props.some(e=>!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`)?(dC(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)})):n.hasChildren?e.commands.setTextSelection(t+2):(dC(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)}))}function mC(e){return({chain:t,state:n,editor:r,afterCommit:i})=>{let a=new WeakSet;n.doc.descendants(t=>{t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&a.add(t)});let o=lC(e.name);if(e.name===`Tabs`){let e=lC(`Tab`),t=lC(`Tab`),n=e.attrs,r=t.attrs;n.props={...n.props,label:`Tab 1`},r.props={...r.props,label:`Tab 2`},o.content=[e,t]}if(e.name===`MirrorSource`){let e=o.attrs;e.props={...e.props,name:iC(n.doc,n.selection.from)}}t().insertContent(o).run(),i(()=>{let t=-1;r.state.doc.descendants((n,r)=>{if(t>=0)return!1;n.type.name===`jsxComponent`&&n.attrs.componentName===e.name&&!a.has(n)&&(t=r)}),!(t<0)&&pC(r,t,e)})}}var hC=new Set([`File`,`Tab`]);function gC(){return[{name:`component-File`,label:Y._({id:`J2eKUI`}),icon:Zl,category:`media`,aliases:[`file`,`attachment`,`download`,`upload`,`document`,`doc`,`docx`,`zip`],description:"Attach a downloadable file (`.pdf` / `.docx` / `.zip` / …)",insertsBlockComponent:!0,command:vC,preview:{description:Y._({id:`wtcU6y`}),render:()=>(0,$.jsxs)(`div`,{className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1.5`,children:[(0,$.jsx)(Zl,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:`quarterly-report.pdf`}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`1.4 MB`})]})}}]}function _C(){return[...QS().filter(e=>e.surface===`canonical`&&!hC.has(e.name)).map(e=>{let t=sC[e.name],n=e.Component,r=t?{description:Y._(t.description),render:t.render??(()=>(0,$.jsx)(n,{...t.props?.(),children:t.children?.()}))}:void 0;return{name:`component-${e.name}`,label:e.displayName??e.name,icon:iv(e.icon),category:e.category??`content`,command:mC(e),aliases:e.searchTerms,description:e.description,insertsBlockComponent:!0,preview:r}}),...gC()]}function vC({editor:e}){if(!p_(e))return;let t=document.createElement(`input`);t.type=`file`,t.accept=`*/*`,t.style.display=`none`,t.addEventListener(`change`,()=>{let n=t.files?.[0];if(n){let t=e.state.selection.from;m_(n,e,t)}t.remove()},{once:!0}),t.addEventListener(`cancel`,()=>t.remove(),{once:!0}),document.body.appendChild(t),t.click()}function yC(){return[{name:`link`,label:Y._({id:`yzF66j`}),icon:lu,category:`insert`,aliases:[`url`,`href`,`external`,`web`,`hyperlink`,`wiki`,`wikilink`,`[[`,`internal`,`page`,`backlink`,`cross-link`],description:`Link to a page or external URL`,preview:{description:Y._({id:`5WDhAk`}),render:()=>(0,$.jsx)(`p`,{className:`leading-7 text-sm`,children:(0,$.jsx)(a,{id:`u-9fWA`,components:{0:(0,$.jsx)(`span`,{className:`font-medium text-azure-blue underline underline-offset-2 dark:text-sky-blue`})}})})},command:({chain:e,state:t,editor:n,afterCommit:r})=>{let i=t.selection.from;e().insertContent({type:`text`,text:`link`,marks:[{type:`link`,attrs:{href:``}}]}).run(),r(()=>{let e=V_(n.state,i,`link`);e&&(P_(e),requestAnimationFrame(()=>{nv(n).setActiveNode(e)}))})}},{name:`component-Tag`,label:Y._({id:`UL8A9w`}),icon:bi,category:`content`,aliases:[`#`,`hashtag`,`label`],description:"Inline tag (`#tagname`) for cross-doc linking",preview:{description:Y._({id:`5ClEAu`}),render:()=>(0,$.jsx)(`p`,{className:`text-sm leading-7`,children:(0,$.jsx)(a,{id:`KZLdgR`,components:{0:(0,$.jsx)(`a`,{className:`tag pointer-events-none`})}})})},command:({chain:e})=>{e().insertTag(``).run()}}]}var bC=[{id:`chart`,title:`Chart`,description:`A bar chart whose series colors track the OK chart palette.`,html:`<div style="font-family:system-ui,sans-serif;padding:20px;color:var(--foreground)">
|
|
4
4
|
<h3 style="margin:0 0 14px;font-size:15px;font-weight:600">Revenue by region</h3>
|
|
5
5
|
<div id="bars" style="display:flex;align-items:flex-end;gap:14px;height:170px"></div>
|
|
6
6
|
<script>
|
|
@@ -107,4 +107,4 @@ ${kF(e)}`}function MF(e){let t=(0,Q.c)(9),{html:n,title:r,className:i,frameRef:a
|
|
|
107
107
|
`)),i.dataTransfer.effectAllowed=`move`,n=m.createElement(`div`),n.appendChild(h.serializeFragment(p.content,{document:m})),n.setAttribute(`inert`,``),n.setAttribute(`aria-hidden`,`true`);let v=a.nodeDOM(u.listPos??u.from),y=v instanceof Element?v:null;_L(n,a,y),m.body.appendChild(n);let b=y?.getBoundingClientRect(),x=a.nodeDOM(u.from),S=x instanceof Element?x.getBoundingClientRect():b,C=n.getBoundingClientRect(),w=b?Math.min(i.clientX-b.left,C.width):0,T=S?Math.min(Math.max(i.clientY-S.top,0),C.height):0;i.dataTransfer.setDragImage(n,w,T);let E=o.nodeAt(u.from)?.nodeSize===u.to-u.from?xe.create(o,u.from):a.state.selection;return a.dragging={slice:l,move:!0},t=a,a.dispatch(a.state.tr.setSelection(E).setMeta(e,{status:`active`,range:u,relative:hL(a.state,u)})),r=m,r.addEventListener(`dragend`,s),r.addEventListener(`drop`,s),d=!0,!0}finally{d||o(a)}}return{plugin:c,start:l,destroy:a}}var yL=20,bL=44,xL=28,SL=new G(`blockDragHover`);function CL(e){return Y._({id:`7Voget`,values:{name:e}})}function wL(e){if(!e)return Y._({id:`CbxTfe`});if(e.type.name===`listItem`)return Y._({id:`_CWM2I`});if(e.type.name===`jsxComponent`){let t=e.attrs.componentName??``;if(t){let e=ZS(t),n=e.name===`*`?t:e.displayName??e.name;if(n)return CL(n)}}return CL(e.type.name)}function TL(){let e=document.createElement(`div`);e.className=`ok-block-controls`,e.setAttribute(Gy,`true`),e.style.visibility=`hidden`;let t=document.createElement(`button`);t.className=`ok-add-block-btn`,t.setAttribute(`aria-label`,Y._({id:`46YgRZ`})),t.setAttribute(`type`,`button`),t.innerHTML=sL,t.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation()});let n=document.createElement(`button`);return n.className=`ok-drag-grip`,n.setAttribute(`type`,`button`),n.setAttribute(`aria-label`,Y._({id:`CbxTfe`})),n.setAttribute(`tabindex`,`-1`),n.innerHTML=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-grip-vertical-icon lucide-grip-vertical"><circle cx="9" cy="12" r="1"/><circle cx="9" cy="5" r="1"/><circle cx="9" cy="19" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="15" cy="5" r="1"/><circle cx="15" cy="19" r="1"/></svg>`,e.appendChild(t),e.appendChild(n),{container:e,addBtn:t,grip:n}}function EL(e,t,n){let{state:r,view:i}=e;if(n.type.name===`listItem`){let n=r.doc.resolve(t);EL(e,n.before(1),n.node(1));return}if(n.type.name===`jsxComponent`){let i=n.attrs.componentName??``;if(i){let a=ZS(i);if(a.emptyChildName){let i=t+1+n.content.size;if(i>r.doc.content.size)return;let o=a.emptyChildName;e.chain().focus().insertContentAt(i,lC(o)).run(),pC(e,i,ZS(o));return}}}let a=t+n.nodeSize;if(a>r.doc.content.size)return;let{tr:o}=r,s=r.schema.nodes.paragraph?.create();if(!s)return;o.insert(a,s);let c=K.near(o.doc.resolve(a+1));o.setSelection(c).scrollIntoView(),i.dispatch(o),i.focus(),e.commands.insertContent(`/`)}var DL=_e.create({name:`blockDragHandle`,addProseMirrorPlugins(){let e=this.editor,t=null,n=-1,{container:r,addBtn:i,grip:a}=TL(),o=vL(),s=oL(e);e.on(`destroy`,o.destroy),e.on(`destroy`,s.destroy),r.addEventListener(`dragstart`,r=>{r.dataTransfer&&e.view.editable&&s.start(e.view),o.start(r,e.view,t,n)&&r.stopImmediatePropagation()},{capture:!0}),i.addEventListener(`click`,()=>{t&&n>=0&&EL(e,n,t)}),a.addEventListener(`click`,()=>{if(n<0)return;let r=t,i=r?.type.name??`unknown`;try{e.chain().focus().setNodeSelection(n).run()||(ni(i),console.warn(JSON.stringify({event:`block-grip-click-select-failed`,nodeType:i,componentName:String(r?.attrs.componentName??``).slice(0,200),reason:`chain-dispatch-returned-false`})))}catch(e){if(!(e instanceof RangeError))throw e;ni(i),console.warn(JSON.stringify({event:`block-grip-click-select-failed`,nodeType:i,componentName:String(r?.attrs.componentName??``).slice(0,200),reason:e.message.slice(0,500)}))}});function c(i){if(t?.type.name!==`listItem`||n<0||r.style.visibility===`hidden`)return null;let a=e.view.nodeDOM(n);if(!(a instanceof HTMLElement))return null;let o=a.getBoundingClientRect(),s=r.getBoundingClientRect(),c=Math.min(o.height,xL);return i.clientX<s.left||i.clientX>o.left||i.clientY<o.top||i.clientY>o.top+c?null:{x:o.left+Math.min(2,o.width/2),y:i.clientY}}let l=MI({element:r,editor:e,onElementDragEnd(){let{view:t}=e;t.dispatch(t.state.tr.setMeta(`hideDragHandle`,!0))},onNodeChange({node:e,pos:r}){t=e,n=r??-1,a.setAttribute(`aria-label`,wL(e)),i.setAttribute(`aria-label`,Y._({id:`46YgRZ`}))},getReferencedVirtualElement(){if(t?.type.name!==`listItem`||n<0)return null;let r=e.view.nodeDOM(n);if(!(r instanceof HTMLElement))return null;let i=r.parentElement;return i?.matches(`ul, ol`)?{contextElement:r,getBoundingClientRect(){let e=r.getBoundingClientRect(),t=i.getBoundingClientRect();return new DOMRect(t.left,e.top,t.width,e.height)}}:null},computePositionConfig:{placement:`left-start`,strategy:`absolute`,middleware:[A(({rects:e})=>({mainAxis:10,crossAxis:((e.reference.height<=bL?e.reference.height:xL)-yL)/2}))]},nestedOptions:NI({edgeDetection:`none`,defaultRules:!1,rules:[{id:`list-items-and-top-level-blocks`,evaluate:({node:e,depth:t})=>e.type.name===`listItem`||t===1&&e.type.name!==`list`?0:1e3}]})}).plugin;return[o.plugin,new J({key:SL,appendTransaction(e,n,r){return t&&e.some(e=>e.docChanged)?r.tr.setMeta(`hideDragHandle`,!0):null},props:{handleDOMEvents:{mousemove(e,t){let n=c(t);return n?(l.props.handleDOMEvents?.mousemove?.call(l,e,new MouseEvent(`mousemove`,{bubbles:t.bubbles,cancelable:t.cancelable,clientX:n.x,clientY:n.y,buttons:t.buttons,button:t.button,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey})),!0):!1},mouseleave(e,t){return c(t)!==null}}}}),l]}}),OL=/^#fn(?:ref)?-/,kL=_e.create({name:`footnoteAnchorScroll`,addProseMirrorPlugins(){return[new J({props:{handleDOMEvents:{click(e,t){let n=t.target;if(!(n instanceof Element))return!1;let r=n.closest(`a[href^="#fn"]`);if(!(r instanceof HTMLAnchorElement))return!1;let i=r.getAttribute(`href`)??``;if(!OL.test(i))return!1;let a=i.slice(1);t.preventDefault();let o=e.dom.ownerDocument.getElementById(a);return o&&o.scrollIntoView({behavior:`smooth`,block:`start`}),!0}}}})]}}),AL=_e.create({name:`formattingShortcuts`,addKeyboardShortcuts(){return{"Mod-Shift-x":()=>this.editor.commands.toggleStrike()}}}),jL=_e.create({name:`headingAnchors`,addProseMirrorPlugins(){return[new J({props:{decorations(e){let t=[],n=new Map;return e.doc.descendants((e,r)=>{if(e.type.name===`heading`){let i=Za(e.textContent,n);if(!i)return;t.push(W.node(r,r+e.nodeSize,{id:i}))}}),U.create(e.doc,t)}}})]}});function ML(e){let t=(0,Q.c)(8),{node:n,editor:r}=e,i=n.attrs.src,a=n.attrs.alt,o=n.attrs.title,s;if(t[0]!==r||t[1]!==i){let e=r?Xt(r)??void 0:void 0;s=typeof i==`string`?Zi(i,e):void 0,t[0]=r,t[1]=i,t[2]=s}else s=t[2];let c=s,l=typeof a==`string`?a:``,u=typeof o==`string`?o:void 0,d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d={sizes:void 0},t[3]=d):d=t[3];let f;return t[4]!==l||t[5]!==c||t[6]!==u?(f=(0,$.jsx)(Xr,{as:`span`,"data-image-inline-zoom":!0,"data-clipboard-inline-leaf":`image`,children:(0,$.jsx)(Ly,{wrapElement:`span`,zoomMargin:20,zoomImg:d,children:(0,$.jsx)(gb,{src:c,alt:l,title:u})})}),t[4]=l,t[5]=c,t[6]=u,t[7]=f):f=t[7],f}var NL=Zn.extend({addNodeView(){return nr(ML)}});function PL(e,t){let n=ar(t),r;return e.descendants(e=>{if(r!==void 0)return!1;if(e.type.name!==`linkRefDef`)return;let t=e.attrs.label,i=e.attrs.href;typeof t==`string`&&typeof i==`string`&&ar(t)===n&&(r=i)}),r}function FL(e){let t=(0,Q.c)(3),{src:n,alt:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,$.jsx)(gb,{src:n,alt:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function IL(e){let t=(0,Q.c)(15),{node:n,editor:r,extension:i}=e,a=n.attrs.identifier,o=typeof a==`string`?a:``,s=n.attrs.alt,c=n.attrs.label,l=typeof s==`string`&&s.length>0?s:typeof c==`string`?c:``,u;t[0]===o?u=t[1]:(u=e=>{let{editor:t}=e;return PL(t.state.doc,o)},t[0]=o,t[1]=u);let d;t[2]!==r||t[3]!==u?(d={editor:r,selector:u},t[2]=r,t[3]=u,t[4]=d):d=t[4];let f=kr(d),p=i.options.docName,m;t[5]!==p||t[6]!==r?(m=typeof p==`string`&&p?p:Xt(r)??void 0,t[5]=p,t[6]=r,t[7]=m):m=t[7];let h=m,g;t[8]!==f||t[9]!==h?(g=f===void 0?void 0:Zi(f,h),t[8]=f,t[9]=h,t[10]=g):g=t[10];let _=g,v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v={sizes:void 0},t[11]=v):v=t[11];let y;return t[12]!==l||t[13]!==_?(y=(0,$.jsx)(Xr,{as:`span`,"data-image-reference-view":!0,"data-clipboard-inline-leaf":`imageReference`,children:(0,$.jsx)(Ly,{wrapElement:`span`,zoomMargin:20,zoomImg:v,children:(0,$.jsx)(FL,{src:_,alt:l})})}),t[12]=l,t[13]=_,t[14]=y):y=t[14],y}var LL=On.extend({addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return nr(IL)}});function RL(e,t){let n=e;for(;n&&typeof n.hasAttribute==`function`;){if(n.hasAttribute(`data-wiki-embed`)){let e=n.getAttribute(`data-target`)??``;if(!e)return null;let r=po(e,t,{literal:!0});return r?{kind:n.tagName===`IMG`?`image`:`asset`,relPath:r,title:r.split(`/`).pop()??e}:null}if(n.hasAttribute(`data-wiki-link`)){let e=n.getAttribute(`data-target`)??``;return e?{kind:`wiki-link`,relPath:`${e}.md`,title:e}:null}if(n.tagName===`A`&&n.hasAttribute(`href`)){let e=mo(n.getAttribute(`href`)??``,t);if(e?.kind===`asset`){let n=po(e.url,t,{literal:e.literal});return n?{kind:`asset`,relPath:n,title:n.split(`/`).pop()??e.url}:null}}if(n.tagName===`IMG`){let e=n.getAttribute(`src`)??``;if(e){let n=mo(e,t);if(n?.kind===`asset`){let e=po(n.url,t,{literal:n.literal});return e?{kind:`image`,relPath:e,title:e.split(`/`).pop()??n.url}:null}}}n=n.parentElement}return null}var zL=new G(`asset-context-menu`);function BL(e){return new J({key:zL,view(t){let n=e.showAssetMenu??(e=>{let t=globalThis.window?.okDesktop;return t?t.shell.showAssetMenu({relPath:e.relPath,title:e.title,kind:e.kind}):Promise.resolve()}),r=t=>{if(!(t.target instanceof Element))return;let r=RL(t.target,e.sourceDocName);r&&(t.preventDefault(),n(r))};return t.dom.addEventListener(`contextmenu`,r),{destroy(){t.dom.removeEventListener(`contextmenu`,r)}}}})}var VL=e=>{let t=(0,Q.c)(18),{kind:n,ariaLabel:r,onDeactivate:i,children:a,triggerReference:o,layout:s,className:c,"data-slot":l}=e,u=s===void 0?`standard`:s,f=(0,Z.useRef)(null),p,m;t[0]===o?(p=t[1],m=t[2]):(p=()=>{let e=f.current;if(e)return j(o,e,()=>{let t=o.getBoundingClientRect();e.isConnected&&(e.style.left=`${t.left}px`,e.style.top=`${t.top}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`)})},m=[o],t[0]=o,t[1]=p,t[2]=m),(0,Z.useLayoutEffect)(p,m);let h;t[3]===i?h=t[4]:(h=e=>{e||i()},t[3]=i,t[4]=h);let g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(ba,{asChild:!0,children:(0,$.jsx)(`span`,{ref:f,"aria-hidden":`true`,style:{position:`fixed`,pointerEvents:`none`,left:`-9999px`,top:`-9999px`,width:0,height:0}})}),t[5]=g):g=t[5];let _=u===`wide`?`w-[min(720px,calc(100%-1rem))]`:`w-80`,v;t[6]!==c||t[7]!==_?(v=d(`ok-interaction-prop-panel pointer-events-auto p-3`,_,c),t[6]=c,t[7]=_,t[8]=v):v=t[8];let y;t[9]!==r||t[10]!==a||t[11]!==l||t[12]!==n||t[13]!==v?(y=(0,$.jsx)(ya,{side:`bottom`,align:`start`,sideOffset:8,"aria-label":r,"data-ok-prop-panel":n,"data-ok-declines-keyboard":``,"data-slot":l,onOpenAutoFocus:HL,onCloseAutoFocus:UL,onPointerDownOutside:WL,onFocusOutside:GL,onInteractOutside:KL,className:v,children:a}),t[9]=r,t[10]=a,t[11]=l,t[12]=n,t[13]=v,t[14]=y):y=t[14];let b;return t[15]!==h||t[16]!==y?(b=(0,$.jsxs)(xa,{open:!0,onOpenChange:h,children:[g,y]}),t[15]=h,t[16]=y,t[17]=b):b=t[17],b};function HL(e){return e.preventDefault()}function UL(e){return e.preventDefault()}function WL(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function GL(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function KL(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}async function qL(e,t){let n=null,r;try{n=await e.json()}catch(e){r=e}if(r instanceof Error&&r.name===`AbortError`)throw r;if(e.ok)return r!==void 0&&console.warn(`[parse-server-response] 2xx response with non-JSON body:`,r instanceof Error?r.message:String(r)),{ok:!0,body:r===void 0?n:null};if(r!==void 0){let t=r instanceof Error?r.message:String(r);return{ok:!1,title:`Server error (HTTP ${e.status}): ${t}`}}return{ok:!1,title:mt(n)??t}}function JL(e,t,n,r){let i=e.safeParse(t);return i.success?i.data:(console.warn(`[parse-server-response] schema drift:`,n,`bodyShape=`,typeof t==`object`&&t?Object.keys(t):typeof t,`issues=`,i.error.issues),r)}function YL(e){let t=e.trim();return/\.(md|mdx)$/i.test(t)?t:`${t}.md`}function XL(e){let t=e.initialDir.trim().replace(/^\/+|\/+$/g,``),n=YL(e.suggestedName);return t?`${t}/${n}`:n}async function ZL(e){let t=await qL(await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})}),`Failed to create page`);if(!t.ok)throw Error(t.title);let n=e.replace(/\.(mdx|md)$/i,``);return{docName:JL(it,t.body,`create-page`,{docName:n}).docName}}async function QL(e){return ZL(XL(e))}async function $L(e,t){let{docName:n}=await QL(e);return t.addPage(n),We([`files`,`backlinks`,`graph`]),t.onCreated?.(n),{docName:n}}var eR=new Map([[vi,`<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/>`],[hi,`<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"/><path d="M14 2v5a1 1 0 0 0 1 1h5"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/>`],[Qn,`<rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>`],[Qn,`<rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>`],[Ql,`<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"/><path d="M14 2v5a1 1 0 0 0 1 1h5"/>`],[ci,`<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/>`],[_r,`<path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path d="M16 9a5 5 0 0 1 0 6"/><path d="M19.364 18.364a9 9 0 0 0 0-12.728"/>`],[Mi,`<path d="M18 6 6 18"/><path d="m6 6 12 12"/>`]]),tR=new Map;function nR(e){let t=tR.get(e);if(t!==void 0)return t;let n=`<svg xmlns="http://www.w3.org/2000/svg" width="0.75rem" height="0.75rem" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${eR.get(e)??eR.get(hi)}</svg>`;return tR.set(e,n),n}var rR=`0 0 32 32`,iR=`M26.7075 10.2925L19.7075 3.2925C19.6146 3.19967 19.5042 3.12605 19.3829 3.07586C19.2615 3.02568 19.1314 2.9999 19 3H7C6.46957 3 5.96086 3.21071 5.58579 3.58579C5.21071 3.96086 5 4.46957 5 5V14C5 14.2652 5.10536 14.5196 5.29289 14.7071C5.48043 14.8946 5.73478 15 6 15C6.26522 15 6.51957 14.8946 6.70711 14.7071C6.89464 14.5196 7 14.2652 7 14V5H18V11C18 11.2652 18.1054 11.5196 18.2929 11.7071C18.4804 11.8946 18.7348 12 19 12H25V28C25 28.2652 25.1054 28.5196 25.2929 28.7071C25.4804 28.8946 25.7348 29 26 29C26.2652 29 26.5196 28.8946 26.7071 28.7071C26.8946 28.5196 27 28.2652 27 28V11C27.0001 10.8686 26.9743 10.7385 26.9241 10.6172C26.8739 10.4958 26.8003 10.3854 26.7075 10.2925ZM20 6.41375L23.5863 10H20V6.41375ZM18 18H16C15.7348 18 15.4804 18.1054 15.2929 18.2929C15.1054 18.4804 15 18.7348 15 19V26C15 26.2652 15.1054 26.5196 15.2929 26.7071C15.4804 26.8946 15.7348 27 16 27H18C19.1935 27 20.3381 26.5259 21.182 25.682C22.0259 24.8381 22.5 23.6935 22.5 22.5C22.5 21.3065 22.0259 20.1619 21.182 19.318C20.3381 18.4741 19.1935 18 18 18ZM18 25H17V20H18C18.663 20 19.2989 20.2634 19.7678 20.7322C20.2366 21.2011 20.5 21.837 20.5 22.5C20.5 23.163 20.2366 23.7989 19.7678 24.2678C19.2989 24.7366 18.663 25 18 25ZM13 19V26C13 26.2652 12.8946 26.5196 12.7071 26.7071C12.5196 26.8946 12.2652 27 12 27C11.7348 27 11.4804 26.8946 11.2929 26.7071C11.1054 26.5196 11 26.2652 11 26V22.1725L9.31875 24.5737C9.22652 24.7053 9.10396 24.8126 8.96144 24.8868C8.81892 24.9609 8.66064 24.9996 8.5 24.9996C8.33936 24.9996 8.18108 24.9609 8.03856 24.8868C7.89604 24.8126 7.77348 24.7053 7.68125 24.5737L6 22.1725V26C6 26.2652 5.89464 26.5196 5.70711 26.7071C5.51957 26.8946 5.26522 27 5 27C4.73478 27 4.48043 26.8946 4.29289 26.7071C4.10536 26.5196 4 26.2652 4 26V19C4.00009 18.7874 4.06791 18.5804 4.19363 18.409C4.31935 18.2376 4.49642 18.1107 4.69915 18.0467C4.90188 17.9828 5.11971 17.9851 5.32104 18.0533C5.52236 18.1216 5.6967 18.2522 5.81875 18.4263L8.5 22.2563L11.1812 18.4263C11.3033 18.2522 11.4776 18.1216 11.679 18.0533C11.8803 17.9851 12.0981 17.9828 12.3008 18.0467C12.5036 18.1107 12.6807 18.2376 12.8064 18.409C12.9321 18.5804 12.9999 18.7874 13 19Z`,aR=`0 0 24 24`,oR=`M23.9428 19.8058a0.1962 0.1962 0 0 0 -0.1679 -0.0337c-1.26 -1.8552 -2.8727 -3.6104 -4.4186 -5.3152l-0.2521 -0.284c-0.0016 -0.0732 -0.0667 -0.1207 -0.1342 -0.1504 -0.0284 -0.0277 -0.0562 -0.0558 -0.0843 -0.0837 -0.0505 -0.1005 -0.1685 -0.1673 -0.2858 -0.1005 -0.4706 0.2347 -0.9068 0.5855 -1.3274 0.9195 -0.5536 0.4345 -1.1085 0.8695 -1.6296 1.354a5.0577 5.0577 0 0 0 -0.5879 0.6185c-0.0842 0.1168 -0.0168 0.2172 0.0843 0.2672 -0.3701 0.3677 -0.7402 0.736 -1.109 1.1198a0.1896 0.1896 0 0 0 -0.0506 0.1342c0 0.05 0.0337 0.1 0.0668 0.1168l0.6559 0.5012v0.0169c0.9237 0.9194 2.5538 2.1729 4.2844 3.5268 0.2515 0.201 0.5205 0.4014 0.7727 0.6017 0.1173 0.1342 0.2346 0.2847 0.3357 0.4182 0.0506 0.0662 0.1685 0.0837 0.2353 0.0331 0.0337 0.0337 0.0843 0.0668 0.118 0.1005a0.2395 0.2395 0 0 0 0.1004 0.0337 0.1534 0.1534 0 0 0 0.1348 -0.0668 0.2371 0.2371 0 0 0 0.0331 -0.1004c0.0175 0 0.0169 0.0168 0.0337 0.0168a0.1915 0.1915 0 0 0 0.1348 -0.0505l3.058 -3.3265c0.1198 -0.1159 0.0135 -0.2668 -0.0005 -0.2672zm-7.6277 -0.1336 -1.5459 -1.1704 -0.151 -0.0998c-0.0337 -0.0169 -0.0674 -0.0506 -0.1011 -0.0668l-0.1174 -0.1005c0.6597 -0.659 1.3297 -1.3074 1.9996 -1.9557 -0.4874 0.4844 -1.4622 1.9057 -1.2606 2.3733 0.0023 0 0.0186 0.0419 0.0674 0.0842 0.3704 0.311 0.7398 0.6232 1.109 0.9357zm4.0997 3.1261 -1.277 -0.97a26.9056 26.9056 0 0 0 -1.5795 -1.5044c0.689 0.5181 1.2769 0.9694 1.3611 1.053 0.6722 0.585 0.6379 0.485 1.0922 0.8696l0.5542 0.4008c-0.0735 0.103 -0.151 0.1477 -0.151 0.151zm0.3357 0.2503 -0.0337 -0.0168c0.0506 -0.0331 0.1011 -0.0668 0.1517 -0.1168zM0.5885 3.4751c0.0331 0.2172 0.0843 0.4344 0.1174 0.6354 0.2015 1.103 0.4031 2.1061 0.7726 2.8583l0.1516 0.568c0.0506 0.2173 0.1342 0.485 0.2185 0.5519 0.8568 0.7521 2.1674 1.8714 3.5785 2.9419a0.1775 0.1775 0 0 0 0.2185 0s0 0.0162 0.0168 0.0162a0.1528 0.1528 0 0 0 0.118 0.0506 0.1912 0.1912 0 0 0 0.1341 -0.0506c1.798 -1.9887 3.1418 -3.6267 4.0997 -4.9974 0.0674 -0.0668 0.0843 -0.1673 0.0843 -0.251 0.0668 -0.0668 0.1173 -0.1504 0.1847 -0.2004 0.0668 -0.0668 0.0668 -0.184 0 -0.2346l-0.0168 -0.0163c0 -0.033 -0.0169 -0.0836 -0.0506 -0.1005 -0.42 -0.4007 -0.722 -0.6848 -1.0416 -0.9856A93.5546 93.5546 0 0 1 6.822 1.9876c-0.0169 -0.0169 -0.0337 -0.0337 -0.0674 -0.0337 -0.3358 -0.1168 -1.0248 -0.2341 -1.8817 -0.3845C3.596 1.3527 1.865 1.0519 0.3027 0.583c0 0 -0.1011 0 -0.118 0.0169L0.1348 0.6505C0.0498 0.7139 0.0222 0.7058 0 0.7167c0.017 0.1005 0.017 0.1673 0.0506 0.2846 0 0.0331 0.0673 0.3009 0.0673 0.334zm7.1909 4.7802 -0.0337 0.0337a0.0362 0.0362 0 0 1 0.0337 -0.0337zM6.553 2.238c0.101 0.1005 0.5211 0.5019 0.6216 0.5855 -0.4369 -0.201 -1.5284 -0.7022 -2.0333 -0.8695 0.5043 0.1005 1.1933 0.201 1.4117 0.284ZM0.7901 1.4027c0.2521 0.4344 0.4537 1.9388 0.6553 3.4095 -0.118 -0.4682 -0.2016 -0.9357 -0.3027 -1.3708C0.9917 2.673 0.84 1.9876 0.6385 1.3858c0.1232 0 0.1516 0.0212 0.1516 0.0169zm-0.2858 -0.3683c0 -0.0162 0 -0.033 -0.0169 -0.033 0.0843 0 0.1342 0.0168 0.2016 0.0499 0.0006 0.0057 -0.1448 -0.0169 -0.1847 -0.0169zM23.6738 0.8172c0.0169 -0.0662 -0.3358 -0.367 -0.2184 -0.3845 0.2527 -0.0163 0.2527 -0.4008 0 -0.4008 -0.3358 0.0169 -0.6884 0.0999 -1.008 0.1504 -0.5878 0.1168 -1.1926 0.2341 -1.781 0.3671 -1.327 0.2846 -2.6375 0.5855 -3.9481 0.937 -0.4032 0.1167 -0.857 0.2003 -1.2432 0.4007 -0.1348 0.0668 -0.118 0.2004 -0.0506 0.284 -0.0337 0.0169 -0.0505 0.0169 -0.0842 0.0337 -0.1174 0.0169 -0.2185 0.0337 -0.3358 0.05 -0.1011 0.0168 -0.1516 0.1004 -0.1348 0.201 0 0.0162 0.0169 0.0499 0.0169 0.0661 -0.7059 0.9363 -1.4954 1.9226 -2.3523 2.9757 -0.84 0.9694 -1.7306 1.9893 -2.6212 3.0424 -2.8396 3.3096 -6.0487 7.0705 -9.5936 10.38a0.1613 0.1613 0 0 0 0 0.2341c0.0169 0.0163 0.0337 0.0331 0.0506 0.0331 -0.0506 0.0506 -0.1011 0.0843 -0.1517 0.1336 -0.0337 0.0337 -0.0505 0.0668 -0.0505 0.1005a0.364 0.364 0 0 0 -0.0668 0.0837c-0.0674 0.0667 -0.0674 0.1835 0.0169 0.234 0.0667 0.0662 0.1847 0.0662 0.2346 -0.0168 0.0175 -0.0169 0.0175 -0.0337 0.0337 -0.0337a0.2648 0.2648 0 0 1 0.3701 0c0.2016 0.2178 0.4032 0.435 0.588 0.6186l-0.4201 -0.3508c-0.0674 -0.0668 -0.1847 -0.05 -0.2347 0.0168 -0.068 0.0662 -0.0511 0.1835 0.0163 0.234l4.4691 3.7273c0.0337 0.0337 0.0674 0.0337 0.118 0.0337 0.0505 0 0.0842 -0.0169 0.1173 -0.0506l0.101 -0.0999c0.017 0.0163 0.05 0.0163 0.0669 0.0163 0.0505 0 0.0842 -0.0163 0.118 -0.05 6.0486 -6.0505 10.9216 -10.6141 16.4997 -14.6927 0.05 -0.0331 0.0668 -0.1 0.0668 -0.1505 0.0674 0 0.118 -0.05 0.151 -0.1167 1.0254 -3.1255 1.227 -5.9007 1.2938 -7.2709 0 -0.0579 0.0169 -0.0371 0.0169 -0.0668 0.0168 -0.0337 0.0168 -0.0505 0.0168 -0.0505a0.9784 0.9784 0 0 0 -0.0668 -0.6186zm-10.82 4.9144c0.2684 -0.3008 0.5374 -0.6186 0.8064 -0.9026 -1.7306 2.2734 -4.6033 5.7665 -8.67 9.9288C7.7626 11.699 10.5517 8.54 12.854 5.7316ZM5.1414 23.4662c-0.0162 -0.0168 -0.0162 -0.0168 0 -0.0168zm2.5033 -2.156c0.1348 -0.1505 0.2695 -0.284 0.4206 -0.4345 0 0 0 0.0163 0.0168 0.0163 -0.2236 0.1978 -0.4334 0.4182 -0.4374 0.4182zm0.6896 -0.6686c0.0994 -0.0993 0.14 -0.1724 0.2852 -0.3177 0.9917 -1.0193 2.0164 -2.0393 3.058 -3.0755l0.0169 -0.0168c0.2521 -0.2004 0.5542 -0.4177 0.8232 -0.6186a228.0627 228.0627 0 0 0 -4.1833 4.0286zm6.5187 -16.732c-0.5543 0.719 -1.1759 1.6716 -1.697 2.4238 -1.6463 2.3733 -6.9393 8.1735 -7.0566 8.274A1189.6473 1189.6473 0 0 1 1.26 19.204l-0.1005 0.1005c-0.0843 -0.1005 -0.0843 -0.251 0.0168 -0.3346 7.476 -7.0037 12.0132 -12.837 13.845 -15.3944 -0.0506 0.1167 -0.0843 0.2166 -0.1685 0.334zm2.9064 3.4269c-0.6716 -0.3851 -0.9905 -0.9869 -0.8064 -1.5712l0.0506 -0.201a0.7753 0.7753 0 0 1 0.0842 -0.1666c0.1848 -0.301 0.4538 -0.5518 0.7564 -0.7023 0.0163 0 0.0331 0 0.05 -0.0168 -0.0169 -0.0337 -0.0169 -0.0837 -0.0169 -0.1336 0.0169 -0.1005 0.0843 -0.1673 0.2016 -0.1673 0.2016 0 0.8238 0.1841 1.059 0.3845 0.0669 0.05 0.1343 0.1168 0.2017 0.1836 0.0842 0.1004 0.2184 0.2677 0.2852 0.4013 0.0337 0.0169 0.0674 0.1841 0.118 0.2678 0.0336 0.1336 0.0667 0.284 0.0505 0.4176 -0.0169 0.0169 0 0.1167 -0.0169 0.1167a1.6055 1.6055 0 0 1 -0.2184 0.6186c-0.0307 0.0307 0.0064 0.0119 -0.0505 0.0668 -0.0843 0.1342 -0.2016 0.251 -0.319 0.3346 -0.3869 0.2672 -0.8238 0.3508 -1.2606 0.234 -0.1105 -0.0473 -0.1672 -0.0667 -0.1685 -0.0667zm4.3692 1.4039c0 0.0168 -0.0168 0.0499 0 0.0667 -0.0337 0 -0.0505 0.0169 -0.0842 0.0337 -1.3274 0.9689 -2.6212 1.9888 -3.915 3.0256 1.109 -0.9868 2.218 -1.9894 3.3776 -2.9756 0.3358 -0.3009 0.5711 -0.6854 0.6379 -1.1199l0.1685 -1.003v-0.0332c0.0842 -0.201 0.4032 -0.1173 0.3526 0.1 -0.0042 -0.0012 -0.1731 0.795 -0.5374 1.9057z`;function sR(e){return e===`.md`||e===`.mdx`}function cR(e){switch(R(e)){case`image`:return nR(Qn);case`video`:return nR(ci);case`audio`:return nR(_r);case`excalidraw`:return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${aR}" fill="currentColor" aria-hidden="true"><path d="${oR}"/></svg>`;default:return nR(Ql)}}function lR(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{d:iR}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(`svg`,{"aria-hidden":`true`,className:n,fill:`currentColor`,viewBox:rR,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function uR(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{d:oR}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(`svg`,{"aria-hidden":`true`,className:n,fill:`currentColor`,viewBox:aR,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function dR(e){let t=ys(e).toLowerCase();return t?sR(t)?{kind:`file`,path:e}:{kind:`file`,path:e,bodyIndexed:!1}:{kind:`folder`,path:e}}function fR(e){let t=(0,Q.c)(6),{path:n,className:r,showExtensionBadge:i}=e,a;t[0]===n?a=t[1]:(a=dR(n),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,$.jsx)(mR,{...a,className:r,showExtensionBadge:i}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function pR(e){let{kind:t,bodyIndexed:n}=dR(e);if(t===`folder`)return nR(vi);let r=(n===!1?ys(e):ys(e)||`.md`).toLowerCase();return sR(r)?`<svg xmlns="http://www.w3.org/2000/svg" width="0.75rem" height="0.75rem" viewBox="${rR}" fill="currentColor" aria-hidden="true"><path d="${iR}"/></svg>`:cR(r)}function mR(e){let t=(0,Q.c)(25),{kind:n,path:r,docExt:i,bodyIndexed:a,className:o,showExtensionBadge:s}=e,c=s===void 0?!0:s;if(n===`folder`){let e;t[0]===o?e=t[1]:(e=d(`shrink-0`,o),t[0]=o,t[1]=e);let n;return t[2]===e?n=t[3]:(n=(0,$.jsx)(vi,{"aria-hidden":`true`,className:e,"data-file-entry-icon":`folder`}),t[2]=e,t[3]=n),n}let l;t[4]!==a||t[5]!==i||t[6]!==r?(l=a===!1?ys(r):i??(ys(r)||`.md`),t[4]=a,t[5]=i,t[6]=r,t[7]=l):l=t[7];let u=l,f,p,m,h;if(t[8]!==o||t[9]!==u||t[10]!==c){let e=u.toLowerCase(),n=R(e);f=c&&u&&e!==`.md`?u.slice(1).toUpperCase():null;let r=n===`image`&&`text-chart-5`,i;t[15]!==o||t[16]!==r?(i=d(o,r),t[15]=o,t[16]=r,t[17]=i):i=t[17];let a=i;p=`relative inline-flex shrink-0`,m=e||`file`,h=sR(e)?(0,$.jsx)(lR,{className:a,"data-testid":`file-entry-icon-markdown`}):n===`image`?(0,$.jsx)(Qn,{"aria-hidden":`true`,className:a,"data-testid":`file-entry-icon-image`}):n===`video`?(0,$.jsx)(ci,{"aria-hidden":`true`,className:a,"data-testid":`file-entry-icon-video`}):n===`audio`?(0,$.jsx)(_r,{"aria-hidden":`true`,className:a,"data-testid":`file-entry-icon-audio`}):n===`excalidraw`?(0,$.jsx)(uR,{className:a,"data-testid":`file-entry-icon-excalidraw`}):(0,$.jsx)(Ql,{"aria-hidden":`true`,className:a,"data-testid":`file-entry-icon-file`}),t[8]=o,t[9]=u,t[10]=c,t[11]=f,t[12]=p,t[13]=m,t[14]=h}else f=t[11],p=t[12],m=t[13],h=t[14];let g;t[18]===f?g=t[19]:(g=f?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`-right-1 -bottom-1 absolute rounded-sm bg-background px-0.5 font-medium text-[0.5rem] text-muted-foreground leading-none`,"data-testid":`file-entry-extension-badge`,children:f}):null,t[18]=f,t[19]=g);let _;return t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==g?(_=(0,$.jsxs)(`span`,{className:p,"data-file-entry-icon":m,children:[h,g]}),t[20]=p,t[21]=m,t[22]=h,t[23]=g,t[24]=_):_=t[24],_}var hR=8;function gR(e){return e.trim().replace(/^\/+/,``).replace(/\.mdx?$/i,``).replace(/\/+$/g,``)}function _R(e){return e.startsWith(`/`)&&!e.startsWith(`//`)}function vR(e){return e.split(`/`).at(-1)??e}function yR(e){return e.split(`/`)[0]?.startsWith(`.`)??!1}function bR(e,t){if(!t)return 0;let n=e.toLowerCase(),r=vR(e).toLowerCase();return n===t?0:r===t?1:n.startsWith(t)?2:r.startsWith(t)?3:r.includes(t)?4:n.includes(t)?5:null}function xR(e){switch(e){case`page`:return 0;case`folder`:return 1;case`asset`:return 2}}function SR(e){let t=[],n=new Set;function r(e,r){let i=gR(r);if(!i)return;let a=`${e}:${i.toLowerCase()}`;n.has(a)||(n.add(a),t.push({kind:e,path:i}))}for(let t of e.pages)r(`page`,t);for(let t of e.folderPaths??[])r(`folder`,t);if(e.includeAssets)for(let t of e.assetPaths??[])r(`asset`,t);return t}function CR(e){let t=gR(e.value).toLowerCase(),n=t===``,r=[];for(let n of SR(e)){let e=bR(n.path,t);e!==null&&r.push({suggestion:n,score:e})}return r.sort((e,t)=>{if(e.score!==t.score)return e.score-t.score;let r=xR(e.suggestion.kind)-xR(t.suggestion.kind);if(r!==0)return r;if(n){let n=!!yR(e.suggestion.path)-+!!yR(t.suggestion.path);if(n!==0)return n}return e.suggestion.path.localeCompare(t.suggestion.path)}),r.slice(0,e.limit??hR).map(e=>e.suggestion)}var wR=`[data-ok-link-path-suggestion-panel]`;function TR(e){return e instanceof Element&&e.closest(wR)!==null}function ER(e){TR(e.target)&&e.preventDefault()}function DR(e){switch(e.kind){case`page`:return(0,$.jsx)(mR,{className:`size-3.5`,docExt:`.md`,kind:`file`,path:e.path});case`folder`:return(0,$.jsx)(mR,{className:`size-3.5`,kind:`folder`,path:e.path});case`asset`:return(0,$.jsx)(mR,{bodyIndexed:!1,className:`size-3.5`,kind:`file`,path:e.path})}}function OR(e,t){if(e){if(typeof e==`function`){e(t);return}e.current=t}}function kR(e){let t=(0,Q.c)(54),n,r,i,a,s,c,l,u,f,p,m,h,g,_;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],s=t[5],c=t[6],l=t[7],u=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14]):({value:_,pages:p,folderPaths:i,assetPaths:n,includeAssets:h,loading:g,onValueChange:f,onKeyDown:l,onSuggestionSelect:u,onFocus:c,onBlur:s,className:r,ref:m,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=f,t[10]=p,t[11]=m,t[12]=h,t[13]=g,t[14]=_);let v=h===void 0?!1:h,y=g===void 0?!1:g,{_:b}=o(),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),[T,M]=(0,Z.useState)(0),N=(0,Z.useRef)(null),P=(0,Z.useRef)(null),F=(0,Z.useId)(),I,L,R;if(t[15]!==_){let e=_.trim();I=e===``,L=_R(_),R=!Qa(e)&&!e.startsWith(`#`),t[15]=_,t[16]=I,t[17]=L,t[18]=R}else I=t[16],L=t[17],R=t[18];let te=I||R,ne=te?CR({value:I?``:_,pages:p,folderPaths:i,assetPaths:n,includeAssets:v}):[],re=ne.map(PR).join(`\0`),ie=ne.length>0,ae=x&&!C&&te&&(ie||y),oe=ae||x&&!C&&(I||L)&&!y&&!ie,se=Math.min(T,Math.max(ne.length-1,0)),z=ie?`${F}-option-${se}`:void 0,B;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>{M(0)},t[19]=B):B=t[19],(0,Z.useEffect)(B,[re]);let ce,V;t[20]!==z||t[21]!==oe?(ce=()=>{!oe||!z||document.getElementById(z)?.scrollIntoView?.({block:`nearest`})},V=[z,oe],t[20]=z,t[21]=oe,t[22]=ce,t[23]=V):(ce=t[22],V=t[23]),(0,Z.useEffect)(ce,V);let H,U;t[24]===oe?(H=t[25],U=t[26]):(H=()=>{if(!oe)return;let e=N.current,t=P.current;if(!e||!t)return;let n=e,r=t,i=function(){k(n,r,{placement:`bottom-start`,strategy:`fixed`,middleware:[A(4),E({padding:8}),D({padding:8}),O({padding:8,apply(e){let{availableHeight:t,availableWidth:n,elements:r}=e;Object.assign(r.floating.style,{width:`${Math.min(480,n)}px`,maxHeight:`${Math.min(208,Math.max(96,t))}px`})}})]}).then(e=>{let{x:t,y:n}=e;r.isConnected&&Object.assign(r.style,{left:`${t}px`,top:`${n}px`})}).catch(e=>{r.isConnected&&console.warn(`[LinkPathSuggestionInput] computePosition failed`,e)})},a=j(n,r,i);return i(),a},U=[oe],t[24]=oe,t[25]=H,t[26]=U),(0,Z.useLayoutEffect)(H,U);let W;t[27]===m?W=t[28]:(W=function(e){N.current=e,OR(m,e)},t[27]=m,t[28]=W);let le=W,G=function(e){u?u(e):f(e.path),w(!0),requestAnimationFrame(()=>N.current?.focus())},ue=function(e){if(ae&&ie){if(e.key===`ArrowDown`){e.preventDefault(),M(e=>Math.min(e+1,ne.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),M(NR);return}if(e.key===`Enter`){e.preventDefault();let t=ne[se];t&&G(t);return}if(e.key===`Escape`){e.preventDefault(),w(!0);return}}if(oe&&e.key===`Escape`){e.preventDefault(),w(!0);return}l?.(e)},K;t[29]===b?K=t[30]:(K=function(e){switch(e){case`page`:return b({id:`6WdDG7`});case`folder`:return b({id:`kNqMMd`});case`asset`:return b({id:`bUUVED`})}},t[29]=b,t[30]=K);let de=K,fe=oe?(0,$.jsx)(`div`,{ref:P,id:F,role:`listbox`,"aria-label":b({id:`mBltnd`}),"data-ok-layer-spawned":``,"data-ok-link-path-suggestion-panel":``,className:`fixed z-70 max-h-52 overflow-y-auto overscroll-y-contain rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md subtle-scrollbar pointer-events-auto`,onWheel:MR,onTouchMove:jR,children:ie?ne.map((e,t)=>{let n=t===se,r=de(e.kind);return(0,$.jsxs)(ee,{id:`${F}-option-${t}`,type:`button`,role:`option`,"aria-label":`/${e.path} ${r}`,"aria-selected":n,variant:`ghost`,className:d(`h-auto w-full justify-start gap-2 rounded-sm px-2 py-1.5 text-left font-normal`,n&&`bg-accent text-accent-foreground`),onMouseDown:AR,onClick:()=>G(e),children:[DR(e),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:`/${e.path}`,children:[`/`,e.path]}),(0,$.jsx)(`span`,{className:`shrink-0 text-muted-foreground text-xs`,children:r})]},`${e.kind}:${e.path}`)}):(0,$.jsx)(`div`,{role:`status`,className:`px-2 py-1.5 text-muted-foreground text-sm`,children:b(y?{id:`sxTdZI`}:{id:`_QwkMu`})})}):null,pe;t[31]===f?pe=t[32]:(pe=e=>{w(!1),f(e.target.value)},t[31]=f,t[32]=pe);let q;t[33]===c?q=t[34]:(q=e=>{S(!0),c?.(e)},t[33]=c,t[34]=q);let me;t[35]===s?me=t[36]:(me=e=>{S(!1),s?.(e)},t[35]=s,t[36]=me);let J=oe?F:void 0,he;t[37]!==z||t[38]!==r||t[39]!==ue||t[40]!==a||t[41]!==le||t[42]!==oe||t[43]!==pe||t[44]!==q||t[45]!==me||t[46]!==J||t[47]!==_?(he=(0,$.jsx)(Ka,{...a,ref:le,value:_,onChange:pe,onFocus:q,onBlur:me,onKeyDown:ue,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":oe,"aria-controls":J,"aria-activedescendant":z,autoComplete:`off`,className:r}),t[37]=z,t[38]=r,t[39]=ue,t[40]=a,t[41]=le,t[42]=oe,t[43]=pe,t[44]=q,t[45]=me,t[46]=J,t[47]=_,t[48]=he):he=t[48];let ge;t[49]===fe?ge=t[50]:(ge=fe&&(0,Ss.createPortal)(fe,document.body),t[49]=fe,t[50]=ge);let _e;return t[51]!==he||t[52]!==ge?(_e=(0,$.jsxs)(`div`,{className:`relative`,children:[he,ge]}),t[51]=he,t[52]=ge,t[53]=_e):_e=t[53],_e}function AR(e){return e.preventDefault()}function jR(e){e.stopPropagation()}function MR(e){e.stopPropagation()}function NR(e){return Math.max(e-1,0)}function PR(e){return`${e.kind}:${e.path}`}function FR(e){let t=(0,Q.c)(15),{metadata:n}=e,r=n.faviconDataUri?.startsWith(`data:image/`)?n.faviconDataUri:null,i;t[0]===r?i=t[1]:(i=r?(0,$.jsx)(`img`,{"data-slot":`external-link-preview-favicon`,src:r,alt:``,"aria-hidden":`true`,width:16,height:16,className:`size-4 shrink-0 rounded-sm`}):null,t[0]=r,t[1]=i);let a;t[2]===n.domain?a=t[3]:(a=(0,$.jsx)(`span`,{"data-slot":`external-link-preview-domain`,className:`truncate text-xs font-medium text-muted-foreground`,children:n.domain}),t[2]=n.domain,t[3]=a);let o;t[4]!==i||t[5]!==a?(o=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6];let s;t[7]===n.title?s=t[8]:(s=n.title?(0,$.jsx)(`div`,{"data-slot":`external-link-preview-title`,className:`mt-1 line-clamp-2 text-sm font-medium text-foreground`,children:n.title}):null,t[7]=n.title,t[8]=s);let c;t[9]===n.description?c=t[10]:(c=n.description?(0,$.jsx)(`p`,{"data-slot":`external-link-preview-description`,className:`mt-1 line-clamp-3 text-xs text-muted-foreground`,children:n.description}):null,t[9]=n.description,t[10]=c);let l;return t[11]!==o||t[12]!==s||t[13]!==c?(l=(0,$.jsxs)(`div`,{"data-slot":`external-link-preview-card`,className:`mt-2.5 border-t border-border/70 pt-2.5`,children:[o,s,c]}),t[11]=o,t[12]=s,t[13]=c,t[14]=l):l=t[14],l}var IR=6e4,LR=60*IR,RR=24*LR,zR=7*RR,BR=30*RR,VR=365*RR;function HR(e,t){let n=Date.parse(e);if(Number.isNaN(n))return null;let r=Math.max(0,t-n);return r<IR?Y._({id:`xOTzt5`}):r<LR?Y._({id:`zbymaY`,values:{0:Math.floor(r/IR)}}):r<RR?Y._({id:`optX0N`,values:{0:Math.floor(r/LR)}}):r<zR?Y._({id:`l1l8sj`,values:{0:Math.floor(r/RR)}}):r<BR?Y._({id:`xV5sXw`,values:{0:Math.floor(r/zR)}}):r<VR?Y._({id:`0NkNB5`,values:{0:Math.floor(r/BR)}}):Y._({id:`lY27jj`,values:{0:Math.floor(r/VR)}})}function UR(e){let t=(0,Q.c)(22),{preview:n}=e,[r]=(0,Z.useState)(GR),i;t[0]!==r||t[1]!==n.lastEditedAt?(i=n.lastEditedAt?HR(n.lastEditedAt,r):null,t[0]=r,t[1]=n.lastEditedAt,t[2]=i):i=t[2];let o=i,s=n.tags!==void 0&&n.tags.length>0,c=o!==null||n.backlinkCount!==void 0,l;t[3]===n.title?l=t[4]:(l=(0,$.jsx)(`div`,{"data-slot":`internal-doc-preview-title`,className:`truncate text-sm font-medium text-foreground`,children:n.title}),t[3]=n.title,t[4]=l);let u;t[5]===n.folderPath?u=t[6]:(u=n.folderPath?(0,$.jsxs)(`div`,{"data-slot":`internal-doc-preview-folder`,className:`mt-0.5 flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(vi,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`truncate`,children:n.folderPath})]}):null,t[5]=n.folderPath,t[6]=u);let d;t[7]!==s||t[8]!==n.tags?(d=s?(0,$.jsx)(`div`,{"data-slot":`internal-doc-preview-tags`,className:`mt-1.5 flex flex-wrap gap-1`,children:n.tags?.map(WR)}):null,t[7]=s,t[8]=n.tags,t[9]=d):d=t[9];let f;t[10]===n.excerpt?f=t[11]:(f=n.excerpt===void 0?null:n.excerpt?(0,$.jsx)(`p`,{"data-slot":`internal-doc-preview-excerpt`,className:`mt-1.5 line-clamp-3 text-xs text-muted-foreground`,children:n.excerpt}):(0,$.jsx)(`p`,{"data-slot":`internal-doc-preview-empty`,className:`mt-1.5 text-xs italic text-muted-foreground/70`,children:(0,$.jsx)(a,{id:`Rb1zMa`})}),t[10]=n.excerpt,t[11]=f);let p;t[12]!==o||t[13]!==c||t[14]!==n.backlinkCount?(p=c?(0,$.jsxs)(`div`,{"data-slot":`internal-doc-preview-meta`,className:`mt-1.5 flex items-center gap-2.5 text-[11px] text-muted-foreground/80`,children:[o?(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Wl,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(a,{id:`Xisk4u`,values:{editedAgo:o}})]}):null,n.backlinkCount===void 0?null:(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(lu,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(a,{id:`HjNrT0`,values:{0:n.backlinkCount}})]})]}):null,t[12]=o,t[13]=c,t[14]=n.backlinkCount,t[15]=p):p=t[15];let m;return t[16]!==l||t[17]!==u||t[18]!==d||t[19]!==f||t[20]!==p?(m=(0,$.jsxs)(`div`,{"data-slot":`internal-doc-preview-card`,className:`mt-2.5 border-t border-border/70 pt-2.5`,children:[l,u,d,f,p]}),t[16]=l,t[17]=u,t[18]=d,t[19]=f,t[20]=p,t[21]=m):m=t[21],m}function WR(e){return(0,$.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,children:e},e)}function GR(){return Date.now()}var KR=new Map,qR=new Map;async function JR(e,t){let n=await fetch(`/api/link-preview`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e}),signal:t});if(!n.ok)return null;let r=$e.safeParse(await n.json());return!r.success||!r.data.ok?null:r.data.metadata}function YR(e,t){let n=KR.get(e);if(n)return KR.delete(e),KR.set(e,n),Promise.resolve(n);let r=qR.get(e);if(r)return r;let i=(async()=>{try{let n=await JR(e,t);if(n)for(KR.set(e,n);KR.size>128;){let e=KR.keys().next().value;if(e===void 0)break;KR.delete(e)}return n}catch(e){return(!(e instanceof Error)||e.name!==`AbortError`)&&console.warn(`[link-preview] external preview fetch failed:`,e instanceof Error?e.message:String(e)),null}finally{qR.delete(e)}})();return qR.set(e,i),i}function XR(e){let t=(0,Q.c)(4),{url:n,enabled:r}=e,[i,a]=(0,Z.useState)(null),o,s;return t[0]!==r||t[1]!==n?(o=()=>{if(!r||!n)return;let e=new AbortController;return YR(n,e.signal).then(t=>{e.signal.aborted||!t||a({url:n,metadata:t})}),()=>e.abort()},s=[n,r],t[0]=r,t[1]=n,t[2]=o,t[3]=s):(o=t[2],s=t[3]),(0,Z.useEffect)(o,s),!r||!n?null:i?.url===n?i.metadata:null}var ZR=3,QR=240,$R=400,ez=/^(#{1,6})\s+(.*)$/;function tz(e,t={}){let n=t.maxLines??ZR,r=t.maxChars??QR,i=t.anchor?.trim()||null,{body:a}=et(e),o=a.split(`
|
|
108
108
|
`).map(nz),s=((i?iz(o,i,n):null)??rz(o,n)).join(` `).replace(/\s+/g,` `).trim();return s.length<=r?s:`${Iu(s,r).trimEnd()}…`}function nz(e){return e.endsWith(`\r`)?e.slice(0,-1):e}function rz(e,t){let n=Qr(),r=[],i=!1,a=Math.min(e.length,$R);for(let o=0;o<a&&r.length<t;o++){let t=e[o]??``;if(n(t))continue;if(ez.test(t)){if(i)break;continue}let a=oz(t);a&&(r.push(a),i=!0)}return r}function iz(e,t,n){let r=az(e,t);if(!r)return null;let i=[],a=oz(e[r.index]??``);a&&i.push(a);let o=Qr();for(let t=0;t<=r.index;t++)o(e[t]??``);let s=Math.min(e.length,r.index+1+$R);for(let t=r.index+1;t<s&&i.length<n;t++){let n=e[t]??``;if(o(n))continue;let a=n.match(ez);if(a){if((a[1]??``).length<=r.level)break;continue}let s=oz(n);s&&i.push(s)}return i}function az(e,t){let n=ao(t),r=Qr(),i=new Map,a=Math.min(e.length,$R);for(let o=0;o<a;o++){let a=e[o]??``;if(r(a))continue;let s=a.match(ez);if(!s)continue;let c=Za((s[2]??``).trim(),i);if(c&&(c===t||c===n))return{index:o,level:(s[1]??``).length}}return null}function oz(e){if(cz(e))return``;let t=e;return t=t.replace(/^\s*(?:>\s?)+/,``),t=t.replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+|#{1,6}\s+)/,``),t=t.replace(/!\[\[[^\]]*\]\]/g,``),t=t.replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`),t=t.replace(/\[\[([^\]]+)\]\]/g,(e,t)=>sz(t)),t=t.replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`),t=t.replace(/\[([^\]]*)\]\[[^\]]*\]/g,`$1`),t=t.replace(/``([^`]+)``/g,`$1`),t=t.replace(/`([^`]+)`/g,`$1`),t=t.replace(/\*\*\*([^*]+)\*\*\*/g,`$1`),t=t.replace(/\*\*([^*]+)\*\*/g,`$1`),t=t.replace(/\*([^*]+)\*/g,`$1`),t=t.replace(/___([^_]+)___/g,`$1`),t=t.replace(/__([^_]+)__/g,`$1`),t=t.replace(/(^|[^A-Za-z0-9])_([^_]+)_(?![A-Za-z0-9])/g,`$1$2`),t=t.replace(/~~([^~]+)~~/g,`$1`),t=t.replace(/<((?:https?|mailto):[^>]+)>/g,`$1`),t=t.replace(/<\/?[A-Za-z][^>]*>/g,``),t=t.replace(/\\([\\`*_{}[\]()#+\-.!~>|])/g,`$1`),t.replace(/\s+/g,` `).trim()}function sz(e){let t=e.indexOf(`|`);if(t>=0){let n=e.slice(t+1).trim();if(n)return n}return((t>=0?e.slice(0,t):e).split(`#`)[0]??``).trim()}function cz(e){let t=e.trim();return t?!!(/^([-*_])(?:[ \t]*\1){2,}$/.test(t)||/^=+$/.test(t)):!1}function lz(e){let t=e.lastIndexOf(`/`);return t>0?e.slice(0,t):null}function uz(e){let{frontmatter:t}=et(e);return t?zt(st(t)):[]}function dz(e,t){return{tags:uz(e),excerpt:tz(e,{anchor:t})}}var fz=new Map,pz=new Map,mz=new Map,hz=new Map;async function gz(e){let t=await fetch(`/api/document?docName=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`document read failed: ${t.status}`);return nt.parse(await t.json()).content}async function _z(e){let t=await fetch(`/api/backlink-counts?docNames=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`backlink-counts failed: ${t.status}`);let{counts:n}=rt.parse(await t.json());return n[e]??0}function vz(e){let t=fz.get(e);if(t!==void 0)return fz.delete(e),fz.set(e,t),Promise.resolve(t);let n=mz.get(e);if(n)return n;let r=(async()=>{try{let t=await gz(e);for(fz.set(e,t);fz.size>128;){let e=fz.keys().next().value;if(e===void 0)break;fz.delete(e)}return t}catch(e){return(!(e instanceof Error)||e.name!==`AbortError`)&&console.warn(`[link-preview] internal doc read failed:`,e instanceof Error?e.message:String(e)),null}finally{mz.delete(e)}})();return mz.set(e,r),r}function yz(e){let t=pz.get(e);if(t!==void 0)return pz.delete(e),pz.set(e,t),Promise.resolve(t);let n=hz.get(e);if(n)return n;let r=(async()=>{try{let t=await _z(e);for(pz.set(e,t);pz.size>128;){let e=pz.keys().next().value;if(e===void 0)break;pz.delete(e)}return t}catch(e){return(!(e instanceof Error)||e.name!==`AbortError`)&&console.warn(`[link-preview] backlink-count read failed:`,e instanceof Error?e.message:String(e)),null}finally{hz.delete(e)}})();return hz.set(e,r),r}function bz(e){let t=(0,Q.c)(21),{docName:n,anchor:r,enabled:i}=e,{pageTitles:a,pageMeta:o}=ns(),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),d,f;if(t[0]!==r||t[1]!==n||t[2]!==i?(d=()=>{if(!i||!n)return;let e=!1;return vz(n).then(t=>{e||t===null||c({docName:n,anchor:r,fields:dz(t,r)})}),yz(n).then(t=>{e||t===null||u({docName:n,count:t})}),()=>{e=!0}},f=[n,r,i],t[0]=r,t[1]=n,t[2]=i,t[3]=d,t[4]=f):(d=t[3],f=t[4]),(0,Z.useEffect)(d,f),!i||!n)return null;let p=s!==null&&s.docName===n&&s.anchor===r?s.fields:null,m=l!==null&&l.docName===n?l.count:null,h;t[5]!==n||t[6]!==a?(h=a.get(n)??n,t[5]=n,t[6]=a,t[7]=h):h=t[7];let g;t[8]===n?g=t[9]:(g=lz(n),t[8]=n,t[9]=g);let _;t[10]!==n||t[11]!==o?(_=o.get(n)?.modified??null,t[10]=n,t[11]=o,t[12]=_):_=t[12];let v=p?.tags,y=p?.excerpt,b=m??void 0,x;return t[13]!==n||t[14]!==h||t[15]!==g||t[16]!==_||t[17]!==v||t[18]!==y||t[19]!==b?(x={docName:n,title:h,folderPath:g,lastEditedAt:_,tags:v,excerpt:y,backlinkCount:b},t[13]=n,t[14]=h,t[15]=g,t[16]=_,t[17]=v,t[18]=y,t[19]=b,t[20]=x):x=t[20],x}function xz(e,t){return I_.getState(e)?.byId.get(t)??null}function Sz(e){let{editor:t,layer:n,renderPropPanel:r,handlePrimary:i}=e;return{onRegister:e=>{n.register({type:e.markType,nodeId:e.id,controls:{propPanel:e=>r({editor:t,nodeId:e.nodeId,deactivate:e.deactivate})},handlePrimary:i?e=>i({editor:t,nodeId:e.nodeId,newTab:e.newTab}):void 0})},onDeregister:e=>{n.deregister(e)}}}function Cz(e){let{editor:t,layer:n,markTypes:r,predicate:i,renderPropPanel:a,handlePrimary:o}=e,s=Sz({editor:t,layer:n,renderPropPanel:a,handlePrimary:o});return H_({markTypes:[...r],predicate:i,onRegister:s.onRegister,onDeregister:s.onDeregister})}function wz(e){let t=nv(e.editor);return Cz({...e,layer:t})}function Tz(e,t){let n=(0,Q.c)(4),[r,i]=(0,Z.useState)(null),a,o;return n[0]!==e||n[1]!==t?(a=()=>{if(!t||!e){i(null);return}let n=!1;return i(null),ir(e).then(e=>{n||i(e)}).catch(()=>{n||i([])}),()=>{n=!0}},o=[e,t],n[0]=e,n[1]=t,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Z.useEffect)(a,o),r}function Ez(e,t){let n=e.trim();return n?n.startsWith(`#`)?`anchor`:Qa(n)?`external`:`doc`:t}function Dz(e){return e?.kind===`doc`?`doc`:e?.kind===`anchor`?`anchor`:`external`}function Oz(e){let t=(0,Q.c)(84),{open:n,href:r,text:i,pages:s,folderPaths:c,loading:l,onOpenChange:u,onSave:f}=e,[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(`doc`),x=(0,Z.useId)(),S=(0,Z.useId)(),C=(0,Z.useId)(),w=(0,Z.useId)(),{_:T}=o(),E=(0,Z.useRef)(!1),D=(0,Z.useRef)(``),O,k;t[0]!==r||t[1]!==n||t[2]!==i?(O=()=>{if(!n){E.current=!1;return}if(E.current)return;E.current=!0,D.current=i,v(i);let e=Hn(r);if(b(Dz(e)),e?.kind===`doc`){m(e.docName),g(e.anchor??``);return}if(e?.kind===`anchor`){m(`#${e.anchor}`),g(``);return}m(e?.kind===`external`?e.url:r),g(``)},k=[n,r,i],t[0]=r,t[1]=n,t[2]=i,t[3]=O,t[4]=k):(O=t[3],k=t[4]),(0,Z.useEffect)(O,k);let A,j,M;t[5]!==y||t[6]!==p||t[7]!==s?(A=go(p),j=y===`doc`,M=j&&io(A,s),t[5]=y,t[6]=p,t[7]=s,t[8]=A,t[9]=j,t[10]=M):(A=t[8],j=t[9],M=t[10]);let N=Tz(A,M&&n),P=!!N?.length,F;t[11]!==A||t[12]!==j||t[13]!==h||t[14]!==_||t[15]!==p||t[16]!==u||t[17]!==f?(F=function(){let e=p.trim();e&&(f(j?Ln(A,h.trim()||null):e,_,_.trim()!==D.current.trim()),u(!1))},t[11]=A,t[12]=j,t[13]=h,t[14]=_,t[15]=p,t[16]=u,t[17]=f,t[18]=F):F=t[18];let I=F,L;t[19]===I?L=t[20]:(L=function(e){e.key===`Enter`&&(e.preventDefault(),I())},t[19]=I,t[20]=L);let R=L,te;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(te=function(e){m(e.path),b(`doc`),g(``)},t[21]=te):te=t[21];let ne=te,re;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(Ii,{children:(0,$.jsx)(a,{id:`B11p-O`})}),t[22]=re):re=t[22];let ie;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsxs)(Vi,{children:[re,(0,$.jsx)(Fi,{children:(0,$.jsx)(a,{id:`RobAKV`})})]}),t[23]=ie):ie=t[23];let ae;t[24]===j?ae=t[25]:(ae=j?(0,$.jsx)(a,{id:`6WdDG7`}):(0,$.jsx)(a,{id:`6vEr3W`}),t[24]=j,t[25]=ae);let oe;t[26]!==ae||t[27]!==x?(oe=(0,$.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:x,children:ae}),t[26]=ae,t[27]=x,t[28]=oe):oe=t[28];let se;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>{m(e),b(t=>Ez(e,t))},t[29]=se):se=t[29];let z;t[30]===T?z=t[31]:(z=T({id:`Xl-UUg`}),t[30]=T,t[31]=z);let B;t[32]!==p||t[33]!==c||t[34]!==R||t[35]!==l||t[36]!==s||t[37]!==z||t[38]!==x?(B=(0,$.jsx)(kR,{id:x,value:p,pages:s,folderPaths:c,loading:l,onValueChange:se,onSuggestionSelect:ne,placeholder:z,autoFocus:!0,onKeyDown:R}),t[32]=p,t[33]=c,t[34]=R,t[35]=l,t[36]=s,t[37]=z,t[38]=x,t[39]=B):B=t[39];let ce;t[40]!==oe||t[41]!==B?(ce=(0,$.jsxs)(`div`,{children:[oe,B]}),t[40]=oe,t[41]=B,t[42]=ce):ce=t[42];let V;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(a,{id:`QqBQu1`,components:{0:(0,$.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[43]=V):V=t[43];let H;t[44]===C?H=t[45]:(H=(0,$.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:C,children:V}),t[44]=C,t[45]=H);let U;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>v(e.target.value),t[46]=U):U=t[46];let W;t[47]===T?W=t[48]:(W=T({id:`yYR6za`}),t[47]=T,t[48]=W);let le;t[49]!==_||t[50]!==R||t[51]!==C||t[52]!==W?(le=(0,$.jsx)(Ka,{id:C,value:_,onChange:U,placeholder:W,onKeyDown:R}),t[49]=_,t[50]=R,t[51]=C,t[52]=W,t[53]=le):le=t[53];let G;t[54]!==H||t[55]!==le?(G=(0,$.jsxs)(`div`,{children:[H,le]}),t[54]=H,t[55]=le,t[56]=G):G=t[56];let ue;t[57]!==T||t[58]!==S||t[59]!==j||t[60]!==h||t[61]!==R||t[62]!==w||t[63]!==N||t[64]!==P?(ue=j?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:S,children:(0,$.jsx)(a,{id:`Tjc1pH`,components:{0:(0,$.jsx)(`span`,{className:`font-normal text-muted-foreground`})}})}),(0,$.jsx)(Ka,{id:S,value:h,onChange:e=>g(e.target.value),placeholder:T({id:`W-ntoW`}),onKeyDown:R}),P?(0,$.jsx)(`div`,{id:w,className:`mt-1.5 max-h-36 overflow-y-auto subtle-scrollbar rounded-md border border-border bg-muted/30`,children:N.map(e=>(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":h===e.slug,className:d(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,h===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>g(h===e.slug?``:e.slug),children:[(0,$.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,$.jsx)(`span`,{className:`truncate`,children:e.text})]},`${e.slug}-${e.level}-${e.text}`))}):null]}):null,t[57]=T,t[58]=S,t[59]=j,t[60]=h,t[61]=R,t[62]=w,t[63]=N,t[64]=P,t[65]=ue):ue=t[65];let K;t[66]!==ce||t[67]!==G||t[68]!==ue?(K=(0,$.jsxs)(Ri,{className:`space-y-6 pb-1`,children:[ce,G,ue]}),t[66]=ce,t[67]=G,t[68]=ue,t[69]=K):K=t[69];let de;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(Bi,{asChild:!0,children:(0,$.jsx)(ee,{variant:`outline`,children:(0,$.jsx)(a,{id:`dEgA5A`})})}),t[70]=de):de=t[70];let fe;t[71]===p?fe=t[72]:(fe=p.trim(),t[71]=p,t[72]=fe);let pe=!fe,q;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(a,{id:`tfDRzk`}),t[73]=q):q=t[73];let me;t[74]!==I||t[75]!==pe?(me=(0,$.jsxs)(zi,{children:[de,(0,$.jsx)(ee,{onClick:I,disabled:pe,children:q})]}),t[74]=I,t[75]=pe,t[76]=me):me=t[76];let J;t[77]!==K||t[78]!==me?(J=(0,$.jsxs)(Li,{className:`sm:max-w-xl`,"data-ok-layer-spawned":``,onPointerDownOutside:ER,onFocusOutside:ER,onInteractOutside:ER,children:[ie,K,me]}),t[77]=K,t[78]=me,t[79]=J):J=t[79];let he;return t[80]!==u||t[81]!==n||t[82]!==J?(he=(0,$.jsx)(Hi,{open:n,onOpenChange:u,children:J}),t[80]=u,t[81]=n,t[82]=J,t[83]=he):he=t[83],he}function kz(e){let t=(0,Q.c)(103),{editor:n,nodeId:r,sourceDocName:i,onClose:s,onNavigate:c}=e,l=xz(n.state,r),u=l?.attrs?.href??``,f=l?.attrs?.linkStyle,p=f!==`full`&&f!==`collapsed`&&f!==`shortcut`,[m,h]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),x;t[0]!==r||t[1]!==h?(x=()=>{F_(r)&&h(!0)},t[0]=r,t[1]=h,t[2]=x):x=t[2];let S;t[3]===r?S=t[4]:(S=[r],t[3]=r,t[4]=S),(0,Z.useEffect)(x,S);let{addPage:C,assetPaths:w,filePaths:T,folderPaths:E,pages:D,pagesBySlug:O,pagesByBasename:k,loading:A}=ns(),{_:j}=o(),M=u?mo(u,i):null,N=M?.kind===`doc`&&ur(u,i,w,T,{literal:!1}),P=M?.kind===`doc`&&!N?$n(M.docName,{pages:D,folderPaths:E,pagesBySlug:O,pagesByBasename:k}):null,F=bz({docName:M?.kind===`doc`&&P?.kind===`navigate`&&P.displayState===`resolved`?P.hashDocName:null,anchor:M?.kind===`doc`?M.anchor:null,enabled:!0}),{projectLocalConfig:I}=pt(),L=XR({url:M?.kind===`external`?M.url:null,enabled:I?.linkPreviews?.enabled??!1});if(!l)return null;let R=n.state.doc.textBetween(l.from,l.to),te;t[5]!==n||t[6]!==r?(te=function(e,t,i){let a=xz(n.state,r);if(!a)return;let o=t.trim();if(!i||!o){n.chain().setTextSelection({from:a.from,to:a.to}).extendMarkRange(`link`).updateAttributes(`link`,{href:e}).run();return}let s=n.schema.marks.link;if(!s)return;let c=s.create({href:e}),l=n.schema.text(o,[c]);n.view.dispatch(n.state.tr.replaceWith(a.from,a.to,l))},t[5]=n,t[6]=r,t[7]=te):te=t[7];let ne=te,re;t[8]!==n||t[9]!==r||t[10]!==s?(re=function(){let e=xz(n.state,r);e&&(n.chain().focus().setTextSelection({from:e.from,to:e.to}).extendMarkRange(`link`).unsetLink().run(),s())},t[8]=n,t[9]=r,t[10]=s,t[11]=re):re=t[11];let ie=re,ae;t[12]!==n||t[13]!==r||t[14]!==s||t[15]!==h?(ae=function(e){if(e){h(!0);return}let t=xz(n.state,r);if(t?.attrs?.href??``){h(!1);return}t&&n.chain().focus().deleteRange({from:t.from,to:t.to}).run(),s()},t[12]=n,t[13]=r,t[14]=s,t[15]=h,t[16]=ae):ae=t[16];let oe=p?(0,$.jsx)(Oz,{open:m,href:u,text:R,pages:D,folderPaths:E,loading:A,onOpenChange:u?h:ae,onSave:ne}):null;if(!u){let e;return t[17]===oe?e=t[18]:(e=(0,$.jsx)($.Fragment,{children:oe}),t[17]=oe,t[18]=e),e}let se=M?.kind===`doc`?`${M.docName}${M.anchor?`#${M.anchor}`:``}`:M?.kind===`anchor`?`#${M.anchor}`:M?.kind===`external`?M.url:u,B=function(e){let t=xz(n.state,r);t&&n.chain().setTextSelection({from:t.from,to:t.to}).extendMarkRange(`link`).updateAttributes(`link`,{href:Ln(e,M?.kind===`doc`?M.anchor??null:null)}).run()},V,H=!1,U=!1,W=null;if(A){let e;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Si,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[19]=e):e=t[19],V={icon:e,text:j({id:`yQE2r9`}),className:`text-muted-foreground/80`}}else if(M?.kind===`asset`){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ql,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[20]=e):e=t[20],V={icon:e,text:j({id:`yWWThY`}),className:`text-muted-foreground`}}else if(M?.kind===`external`){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(yi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[21]=e):e=t[21],V={icon:e,text:j({id:`zgSFyG`}),className:`text-muted-foreground`}}else if(M?.kind===`anchor`){let e;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ql,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[22]=e):e=t[22],V={icon:e,text:j({id:`dprWmL`}),className:`text-muted-foreground`}}else if(M?.kind===`doc`)if(U=P?.kind===`navigate`&&P.displayState===`folder`,H=P?.kind===`create`,W=P?.kind===`create`?{initialDir:P.initialDir,suggestedName:P.suggestedName}:null,U){let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(vi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[23]=e):e=t[23],V={icon:e,text:j({id:`kNqMMd`}),className:`text-muted-foreground`}}else if(H){let e;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Nt,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[24]=e):e=t[24],V={icon:e,text:j({id:`8F1i42`}),className:`text-destructive`}}else{let e;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ql,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[25]=e):e=t[25],V={icon:e,text:j({id:`JtD-Br`}),className:`text-muted-foreground`}}else{let e;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Nt,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[26]=e):e=t[26],V={icon:e,text:j({id:`-g6KIS`}),className:`text-muted-foreground/80`}}let le=M?.kind===`external`,G=M?.kind===`doc`?Kn({docName:P?.kind===`navigate`?P.hashDocName:M.docName,anchor:M.anchor}):M?.kind===`anchor`?Kn({docName:i,anchor:M.anchor}):M?.kind===`external`&&Ja(M.url)?M.url:null,ue=!A&&G!==null&&(M?.kind===`anchor`||M?.kind===`external`||M?.kind===`doc`&&!H&&!U),K;t[27]!==n.state||t[28]!==n.view||t[29]!==r?(K=()=>{let e=xz(n.state,r);if(!e)return new DOMRect;try{return ce(n.view,e.from,e.to)}catch{return new DOMRect}},t[27]=n.state,t[28]=n.view,t[29]=r,t[30]=K):K=t[30];let de;t[31]!==n.view.dom||t[32]!==K?(de={getBoundingClientRect:K,contextElement:n.view.dom},t[31]=n.view.dom,t[32]=K,t[33]=de):de=t[33];let fe=de,pe;t[34]!==j||t[35]!==C||t[36]!==y||t[37]!==W||t[38]!==s||t[39]!==B?(pe=async function(){if(!(!W||y)){b(!0);try{await $L(W,{addPage:C,onCreated(e){B(e),window.location.hash=pa(e),s()}}),b(!1)}catch(e){let t=e;z.error(t instanceof Error?t.message:j({id:`tfi40B`})),b(!1)}}},t[34]=j,t[35]=C,t[36]=y,t[37]=W,t[38]=s,t[39]=B,t[40]=pe):pe=t[40];let q=pe,me=d(`flex shrink-0`,V.className),J;t[41]!==V.icon||t[42]!==me?(J=(0,$.jsx)(`span`,{className:me,children:V.icon}),t[41]=V.icon,t[42]=me,t[43]=J):J=t[43];let he=J,ge;t[44]!==he||t[45]!==H||t[46]!==V.text?(ge=H?(0,$.jsxs)(v,{children:[(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(`span`,{className:`flex shrink-0`,"data-slot":`internal-link-prop-panel-icon-trigger`,children:he})}),(0,$.jsx)(_,{children:V.text})]}):he,t[44]=he,t[45]=H,t[46]=V.text,t[47]=ge):ge=t[47];let _e=ge,ve=`${V.text}: ${se}`,ye;t[48]!==se||t[49]!==le||t[50]!==H||t[51]!==G||t[52]!==ue||t[53]!==s||t[54]!==c?(ye=(0,$.jsx)(g,{asChild:!0,children:ue?(0,$.jsx)(`a`,{href:G??void 0,...le?{target:`_blank`,rel:`noopener noreferrer`}:{},onClick:e=>rn(e,c,s),"data-slot":`internal-link-prop-panel-text`,className:`block truncate text-sm font-medium text-foreground underline-offset-2 hover:underline focus-visible:underline`,children:se}):(0,$.jsx)(`span`,{"data-slot":`internal-link-prop-panel-text`,className:d(`block truncate text-sm font-medium`,H?`text-muted-foreground`:`text-foreground`),children:se})}),t[48]=se,t[49]=le,t[50]=H,t[51]=G,t[52]=ue,t[53]=s,t[54]=c,t[55]=ye):ye=t[55];let be;t[56]===se?be=t[57]:(be=(0,$.jsx)(_,{className:`max-w-80 break-all`,children:se}),t[56]=se,t[57]=be);let xe;t[58]!==ye||t[59]!==be?(xe=(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(v,{children:[ye,be]})}),t[58]=ye,t[59]=be,t[60]=xe):xe=t[60];let Se;t[61]!==q||t[62]!==y||t[63]!==H?(Se=H?(0,$.jsxs)(ee,{type:`button`,size:`sm`,variant:`link`,disabled:y,onClick:()=>void q(),"data-slot":`internal-link-prop-panel-create`,className:`flex items-center text-foreground`,children:[(0,$.jsx)(Di,{className:`size-3.5`,"aria-hidden":`true`}),y?(0,$.jsx)(a,{id:`HM56Bx`}):(0,$.jsx)(a,{id:`XRuL0i`})]}):null,t[61]=q,t[62]=y,t[63]=H,t[64]=Se):Se=t[64];let Ce;t[65]!==j||t[66]!==p||t[67]!==h?(Ce=p?(0,$.jsxs)(v,{disableHoverableContent:!0,children:[(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(ee,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":j({id:`ePK91l`}),onClick:()=>h(!0),"data-slot":`internal-link-prop-panel-edit`,children:(0,$.jsx)(Ei,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,$.jsx)(_,{children:(0,$.jsx)(a,{id:`ePK91l`})})]}):null,t[65]=j,t[66]=p,t[67]=h,t[68]=Ce):Ce=t[68];let we;t[69]===u?we=t[70]:(we=(0,$.jsx)(bs,{copyContent:u}),t[69]=u,t[70]=we);let Te;t[71]===j?Te=t[72]:(Te=j({id:`t_YqKh`}),t[71]=j,t[72]=Te);let Ee;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,$.jsx)(Ai,{className:`size-3.5`,"aria-hidden":`true`}),t[73]=Ee):Ee=t[73];let De;t[74]!==ie||t[75]!==Te?(De=(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(ee,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":Te,onClick:ie,"data-slot":`internal-link-prop-panel-remove`,children:Ee})}),t[74]=ie,t[75]=Te,t[76]=De):De=t[76];let Oe;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,$.jsx)(_,{children:(0,$.jsx)(a,{id:`t_YqKh`})}),t[77]=Oe):Oe=t[77];let ke;t[78]===De?ke=t[79]:(ke=(0,$.jsxs)(v,{disableHoverableContent:!0,children:[De,Oe]}),t[78]=De,t[79]=ke);let Ae;t[80]!==Se||t[81]!==Ce||t[82]!==we||t[83]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[Se,Ce,we,ke]}),t[80]=Se,t[81]=Ce,t[82]=we,t[83]=ke,t[84]=Ae):Ae=t[84];let Y;t[85]!==_e||t[86]!==xe||t[87]!==Ae?(Y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_e,xe,Ae]}),t[85]=_e,t[86]=xe,t[87]=Ae,t[88]=Y):Y=t[88];let je;t[89]===F?je=t[90]:(je=F?(0,$.jsx)(UR,{preview:F}):null,t[89]=F,t[90]=je);let Me;t[91]===L?Me=t[92]:(Me=L?(0,$.jsx)(FR,{metadata:L}):null,t[91]=L,t[92]=Me);let Ne;t[93]!==s||t[94]!==ve||t[95]!==Y||t[96]!==je||t[97]!==Me||t[98]!==fe?(Ne=(0,$.jsxs)(VL,{kind:`internal-link`,ariaLabel:ve,onDeactivate:s,triggerReference:fe,className:`w-96`,children:[Y,je,Me]}),t[93]=s,t[94]=ve,t[95]=Y,t[96]=je,t[97]=Me,t[98]=fe,t[99]=Ne):Ne=t[99];let Pe;return t[100]!==oe||t[101]!==Ne?(Pe=(0,$.jsxs)($.Fragment,{children:[oe,Ne]}),t[100]=oe,t[101]=Ne,t[102]=Pe):Pe=t[102],Pe}new G(`markIdentityDecoration`);var Az=`data-mark-id`,jz=new G(`linkResolutionDecoration`);function Mz(e,t,n,r,i){if(t.size===0)return null;let a=[];for(let e of t.values()){if(!n.has(e.markType))continue;let t=r(e,i),o={[Az]:e.id};t!==null&&Object.assign(o,t),a.push(W.inline(e.from,e.to,o))}return a.length===0?null:U.create(e,a)}function Nz(e){let t=new Set(e.markTypes),{computeAttrs:n}=e;return new J({key:jz,state:{init:()=>({version:0}),apply(e,t){let n=e.getMeta(jz);return n&&typeof n==`object`&&n.refresh?{version:t.version+1}:t}},props:{decorations(e){let r=I_.getState(e);if(!r)return null;let i=es();return Mz(e.doc,r.byId,t,n,i)}},view(e){X(`ok/render/decoration-merge`,{markTypes:Array.from(t).join(`,`)},{startTime:performance.now(),duration:0});let n=()=>{e.dispatch(e.state.tr.setMeta(jz,{refresh:!0}))},r=$o(n),i=vr(n);return{destroy(){r(),i()}}}})}function Pz(e){let{href:t,sourceForm:n,docName:r,classified:i}=e,a=eo(t),o=n===`wikiembed`;if(i?.kind!==`asset`&&!(o&&a!==null))return{kind:`not-asset`};let s=i?.kind===`asset`?i.url:t,c=i?.kind===`asset`?i.ext:a??``,l=o,u=po(s,r,{literal:l});return u?{kind:`asset`,url:s,ext:c,literal:l,projectRelPath:u}:{kind:`refused`}}function Fz(e,t,n){return{url:e,projectRelPath:t,ext:n,title:t.split(`/`).pop()??e}}function Iz(e,t,n){let{url:r,ext:i,literal:a,projectRelPath:o}=e;if(n.assetPaths===void 0&&n.filePaths===void 0)return Fz(r,o,i);let s=Ur(r,t,n.assetPaths,n.filePaths,{literal:a});return s===null?null:Fz(r,s,i)}function Lz(e,t,n){if(n===null)return null;let r=Ur(e,t,n.assetPaths,n.filePaths,{literal:!1});return r===null?null:Fz(e,r,eo(e)??``)}var Rz=Kr.extend({addOptions(){return{...this.parent?.(),docName:``}},renderHTML({HTMLAttributes:e}){let t=typeof e.href==`string`?e.href:``;return[`span`,Oe(e,{"data-link":``,role:`link`,tabindex:`0`,"aria-label":t?`Link: ${t}`:`Link`,style:`touch-action: manipulation;`}),0]},addProseMirrorPlugins(){let e=this.options.docName??``,t=({editor:t,nodeId:n,newTab:r})=>{let i=xz(t.state,n),a=i?.attrs?.href;if(typeof a!=`string`||!a)return!1;let o=mo(a,e),s=Pz({href:a,sourceForm:i?.attrs?.sourceForm,docName:e,classified:o});if(s.kind===`refused`)return!1;if(s.kind===`asset`){let t=es();if(t===null)return!1;let n=Iz(s,e,t);return n===null?!1:(sn({...n,newTab:r}),!0)}if(!o)return!1;switch(o.kind){case`asset`:return!1;case`doc`:{let t=es();if($n(o.docName,{pages:t?.pages??new Set,folderPaths:t?.folderPaths??new Set}).kind===`create`){let n=Lz(a,e,t);return n===null?!1:(sn({...n,newTab:r}),!0)}return r?un({docName:o.docName,anchor:o.anchor}):fn(o),!0}case`anchor`:return r?un({docName:e,anchor:o.anchor}):fn(o),!0;case`external`:return Ja(o.url)?(qa(o.url),!0):!1;default:return ho(o)}};return[wz({editor:this.editor,markTypes:[`link`],renderPropPanel:({editor:n,nodeId:r,deactivate:i})=>(0,Z.createElement)(kz,{editor:n,nodeId:r,sourceDocName:e,onClose:i,onNavigate:e=>t({editor:n,nodeId:r,newTab:e})}),handlePrimary:t}),Nz({markTypes:[`link`],computeAttrs:hr(e)}),BL({sourceDocName:e})]}}),zz=56,Bz=2,Vz=150,Hz=2e3;function Uz(e,t,n){return e.top+e.height/2-(n+t)/2}function Wz(e,t){let n=Math.max(0,t.scrollHeight-t.clientHeight);return Math.max(0,Math.min(e,n))}function Gz(e){let{docName:t,container:n,measureTarget:r,placement:i,intent:a,grade:o,landedMode:s,transition:c,onOutcome:l,onDiscardQueuedTarget:u,toolbarOffset:d=zz,driftThresholdPx:f=Bz,quietMs:p=Vz,abandonAfterMs:m=Hz}=e,h=e.contentColumn??n.firstElementChild,g=_d(t,`landing`),_=xd(t,{yieldsToNavigation:a===`toggle`,supersede:()=>j(`superseded`)}),v=n.style.overflowAnchor;n.style.overflowAnchor=`none`,c&&X(`ok/mode-switch/transition`,{from:c.from,to:c.to,grade:o});let y=!1,b=null,x,S,C=0,w,T=()=>{let e=r();return e===null?null:Wz(i===`center`?Uz(e,n.clientHeight,d):e.top-d,n)},E=()=>{let e=T();if(e===null)return{measurable:!1,moved:!1};b=e;let t=Math.abs(n.scrollTop-e)>f;return t&&(n.scrollTop=e),{measurable:!0,moved:t}},D=()=>n.scrollTop-(T()??b??n.scrollTop),O=()=>{x&&clearTimeout(x),S&&clearTimeout(S),C&&cancelAnimationFrame(C),w?.disconnect(),n.removeEventListener(`wheel`,N),n.removeEventListener(`touchstart`,N),window.removeEventListener(`keydown`,P,!0),n.removeEventListener(`contentvisibilityautostatechange`,F,!0),n.style.overflowAnchor=v,g.release(),_.release()},k=()=>{if(y)return;y=!0;let e;try{E(),e=D(),b!==null&&md({docName:t,container:n,targetScrollTop:n.scrollTop,mode:s})}finally{O()}X(`ok/landing/land`,{grade:o,delta:e}),l?.({status:`landed`,delta:e})},A=()=>{if(y)return;y=!0;let e=b??n.scrollTop,t;try{t=D()}finally{O()}X(`ok/landing/abandoned`,{grade:o,target:e,delta:t}),l?.({status:`abandoned`,delta:t})},j=e=>{y||(y=!0,O(),e===`mode-flip`&&u?.(),l?.({status:`cancelled`,reason:e}))},M=()=>{x&&clearTimeout(x),x=setTimeout(k,p)};function N(){j(`user-scroll`)}function P(e){e.composedPath().includes(n)&&N()}function F(){if(y)return;let{measurable:e,moved:t}=E();e&&(t||x===void 0)&&M()}try{E().measurable&&M(),n.addEventListener(`contentvisibilityautostatechange`,F,!0),n.addEventListener(`wheel`,N,{passive:!0}),n.addEventListener(`touchstart`,N,{passive:!0}),window.addEventListener(`keydown`,P,!0),typeof ResizeObserver<`u`&&h&&(w=new ResizeObserver(F),w.observe(h)),C=requestAnimationFrame(F),S=setTimeout(A,m)}catch(e){throw y=!0,O(),e}return{cancel:j}}function Kz(e){switch(e){case`bulletList`:case`orderedList`:case`taskList`:case`list`:return`list`;case`codeBlock`:case`code`:return`code`;case`horizontalRule`:case`thematicBreak`:return`thematicBreak`;case`jsxComponent`:case`mdxJsxFlowElement`:case`mdxJsxTextElement`:return`jsx`;case`htmlBlock`:case`html`:return`html`;default:return e}}function qz(e){return typeof e!=`object`||!e?``:`value`in e&&typeof e.value==`string`?e.value:`children`in e&&Array.isArray(e.children)?e.children.map(qz).join(``):``}function Jz(e,t){let{frontmatter:n,body:r}=et(e),i=n===``?0:n.split(`
|
|
109
109
|
`).length-1;try{return{blocks:t.parseToEditorMdast(r).children.map(e=>({start:(e.position?.start.line??1/0)+i,end:(e.position?.end.line??-1/0)+i,kind:Kz(e.type),text:qz(e)})),fmLineCount:i}}catch{return performance.mark(`ok/block-spans/parse-failed`),{blocks:[],fmLineCount:i}}}function Yz(e,t){let{blocks:n,fmLineCount:r}=Jz(e,t);return{spans:n.map(e=>({start:e.start,end:e.end})),fmLineCount:r}}function Xz(e,t){if(e.length===0)return null;let n=0,r=e.length-1,i=e.length-1;for(;n<=r;){let a=n+r>>1,o=e[a];o!==void 0&&o.end>=t?(i=a,r=a-1):n=a+1}return i}function Zz(e){let t=0;for(let n=e.childCount-1;n>=0;n--){let r=e.child(n);if(r.type.name!==`paragraph`||r.content.size!==0)break;t++}return t===e.childCount?0:e.childCount}function Qz(e,t,n){let r=e.childCount,i=Math.max(0,Math.min(t,r)),a=Math.max(i,Math.min(n,r));if(a<=i)return null;let o=0;for(let t=0;t<i;t++)o+=e.child(t).nodeSize;let s=o;for(let t=i;t<a;t++)o+=e.child(t).nodeSize;let c=o,l=e.content.size,u=Math.max(0,Math.min(s,l)),d=Math.max(u,Math.min(c,l));return d<=u?null:{from:u,to:d}}function $z(e){let t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
110
|
-
`&&t.push(n+1);return t}function eB(e,t,n){return t<=1?0:t-1>=e.length?n:e[t-1]??n}function tB(e,t){let n=0,r=e.length-1,i=1;for(;n<=r;){let a=n+r>>1;(e[a]??0)<=t?(i=a+1,n=a+1):r=a-1}return i}function nB(e,t,n){return Math.max(t,Math.min(e,n))}function rB(e,t){let n=e=>e.replace(/\s+/g,` `).trim();return n(e)===n(t)}function iB(e,t){return t.inRange?t.tripwireOk?rB(e.content,t.text)?`exact`:e.kind===t.kind?`same-type-ordinal`:`ordinal`:`ordinal`:`clamped`}function aB(e){let t=null,n=null;function r(r){return n!==null&&t===r?n:(n={blocks:Jz(r,e).blocks,lineStarts:$z(r)},t=r,n)}return{captureFromWysiwyg(e,t,n){if(e.childCount===0)return null;let r=nB(t,0,e.content.size),i=0,a=e.childCount-1,o=0;for(let t=0;t<e.childCount;t++){let n=e.child(t).nodeSize;if(r<i+n){a=t,o=i+1;break}i+=n,o=i+1}let s=e.child(a),c={blockIndex:a,kind:Kz(s.type.name),content:s.textContent};return n?.refine&&(c.selectionInBlock=Math.max(0,r-o)),c},captureFromSource(e,t,n){let{blocks:i,lineStarts:a}=r(e);if(i.length===0)return null;let o=nB(t,0,e.length),s=Xz(i,tB(a,o));if(s===null)return null;let c=i[s];if(!c)return null;let l={blockIndex:s,kind:c.kind,content:c.text};if(n?.refine){let t=eB(a,c.start,e.length);l.selectionInBlock=Math.max(0,o-t)}return l},resolveInSource(e,{source:t,doc:n}){let{blocks:i,lineStarts:a}=r(t);if(i.length===0)return null;let o=e.blockIndex>=0&&e.blockIndex<i.length,s=Zz(n)===i.length,c=i[nB(e.blockIndex,0,i.length-1)],l=eB(a,c.start,t.length),u=Math.min(eB(a,c.end+1,t.length),t.length),d=iB(e,{inRange:o,tripwireOk:s,kind:c.kind,text:c.text}),f=l;return d===`exact`&&e.selectionInBlock!==void 0&&(f=nB(l+e.selectionInBlock,l,u)),{blockStart:l,blockEnd:u,point:f,confidence:d}},resolveInWysiwyg(e,{source:t,doc:n}){let i=Zz(n);if(i===0)return null;let{blocks:a}=r(t),o=e.blockIndex>=0&&e.blockIndex<i,s=i===a.length,c=nB(e.blockIndex,0,i-1),l=Qz(n,c,c+1);if(l===null)return null;let u=n.child(c),d=iB(e,{inRange:o,tripwireOk:s,kind:Kz(u.type.name),text:u.textContent});return{blockStart:l.from,blockEnd:l.to,point:l.from,confidence:d}}}}var oB=wo.define(),sB=wo.define(),cB=So.mark({class:D_}),lB=To.define({create(){return So.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(oB)?n=So.set([cB.range(e.value.from,e.value.to)]):e.is(sB)&&(n=So.none);return n},provide:e=>xo.decorations.from(e)}),uB=new WeakMap,dB=Do.define(e=>({destroy(){let t=uB.get(e);t!==void 0&&(clearTimeout(t),uB.delete(e))}}));function fB(e,t,n,r){let i=O_(e.state.doc.length,t,n,r);if(!i)return;e.dispatch({effects:oB.of(i)});let a=uB.get(e);a!==void 0&&clearTimeout(a);let o=setTimeout(()=>{uB.delete(e),e.dispatch({effects:sB.of(null)})},li);uB.set(e,o)}function pB(){return[lB,dB]}var mB=3e4;function hB(){let e=new Map,t=e=>e?Date.now()-e.rememberedAt>mB?null:e.navigation:null;return{remember(t,n){e.set(t,{navigation:n,rememberedAt:Date.now()})},peek(n){return t(e.get(n))},consume(n){let r=e.get(n);return e.delete(n),t(r)},clear(t){e.delete(t)},clearForTest(){e.clear()}}}var gB=hB(),_B=hB(),vB=gB.remember,yB=gB.peek,bB=gB.consume,xB=gB.clear;gB.clearForTest;var SB=_B.remember,CB=_B.peek,wB=_B.consume,TB=_B.clear;_B.clearForTest;function EB(e,t,n){return{start:Ta(e,t),end:Ta(e,n)}}function DB(e,t){let n=Fa(e.start,t),r=Fa(e.end,t);return n===null||r===null||r.index<=n.index?null:n.index}var OB=`open-knowledge:view-in-source`,kB=null;function AB(){return kB??=aB(oi()),kB}function jB(e,t,n,r,i=`toggle`){let a=r.captureFromWysiwyg(e,t,{refine:i===`jump`});if(!a)return null;let o=r.resolveInSource(a,{source:n.toString(),doc:e});return{kind:`selection-offset`,intent:i,anchor:a,pin:o?EB(n,o.blockStart,o.blockEnd):void 0}}function MB(e){let{editor:t,docName:n,ytext:r}=e,i=br(t);if(!i)return;let a=e.pmPosition??i.state.selection.from,o=jB(i.state.doc,a,r,AB(),`jump`);o&&vB(n,o),window.dispatchEvent(new CustomEvent(OB,{detail:{docName:n}}))}function NB(e,t,n,r,i){let a=r.captureFromSource(e,t);if(!a)return null;let o=i?r.resolveInSource(a,{source:e,doc:i}):null;return{kind:`selection-offset`,anchor:a,pin:o?EB(n,o.blockStart,o.blockEnd):void 0}}function PB(e,t){let{source:n,pmDoc:r,ydoc:i,resolver:a}=t;if(e.pin){let t=DB(e.pin,i);if(t===null){let t=a.resolveInWysiwyg(e.anchor,{source:n,doc:r});return t?{...t,point:t.blockStart,confidence:`clamped`}:null}let o=a.captureFromSource(n,t);if(o)return a.resolveInWysiwyg(o,{source:n,doc:r})}return a.resolveInWysiwyg(e.anchor,{source:n,doc:r})}function FB(e,t){let{source:n,pmDoc:r,ydoc:i,resolver:a}=t;if(e.pin){let t=DB(e.pin,i);if(t===null){let t=a.resolveInSource(e.anchor,{source:n,doc:r});return t?{...t,point:t.blockStart,confidence:`clamped`}:null}let o=a.captureFromSource(n,t);if(o)return a.resolveInSource(o,{source:n,doc:r})}return a.resolveInSource(e.anchor,{source:n,doc:r})}function IB(e,t){try{return e.coordsAtPos(t)}catch{return null}}function LB(e,t,n){let r=Math.max(0,Math.min(n,e.state.doc.length)),i=t.getBoundingClientRect().top,a=IB(e,r);if(a)return{top:a.top-i+t.scrollTop,height:a.bottom-a.top};try{let n=e.lineBlockAt(r);return{top:e.documentTop-i+t.scrollTop+n.top,height:n.height}}catch{return null}}function RB(e,t){if(e.isDestroyed)return null;try{let n=e.nodeDOM(t);if(n instanceof HTMLElement)return n;let{node:r}=e.domAtPos(t);return r instanceof HTMLElement?r:r.parentElement}catch{return null}}function zB(e,t,n){if(e.isDestroyed)return null;let r=RB(e,Math.max(0,Math.min(n,e.state.doc.content.size)));if(!r)return null;let i=r.getBoundingClientRect(),a=t.getBoundingClientRect().top;return{top:i.top-a+t.scrollTop,height:i.height}}function BB(){return typeof document>`u`?null:rp()}function VB(e,t){let n=t.getBoundingClientRect(),r=n.left+n.width/2,i=di();for(let t of[i+1,i+12,i+40]){let i=e.posAtCoords({left:r,top:n.top+t});if(i)return i.pos}return null}function HB(e,t){let n=t.getBoundingClientRect(),r=n.left+n.width/2,i=di();for(let t of[i+1,i+12,i+40]){let i=e.posAtCoords({x:r,y:n.top+t});if(i!==null)return i}return null}function UB(e){let{from:t,to:n,docName:r,ytext:i}=e;t===`wysiwyg`&&n===`source`?WB(r,i):t===`source`&&n===`wysiwyg`&&GB(r,i)}function WB(e,t){let n=yB(e);if(n&&n.kind!==`selection-offset`)return;let r=Uu(e);if(!r)return;let i=br(r);if(!i)return;let a=BB();if(!a)return;let o=VB(i,a);if(o===null)return;let s=jB(i.state.doc,o,t,AB());s&&vB(e,s)}function GB(e,t){let n=An(e);if(!n)return;let r=BB();if(!r)return;let i=HB(n,r);if(i===null)return;let a=Uu(e),o=a?br(a)?.state.doc:void 0,s=NB(t.toString(),i,t,AB(),o);s&&SB(e,s)}function KB(e){let{view:t,docName:n,navigation:r,ydoc:i,transition:a}=e,o=Uu(n),s=o?br(o)?.state.doc:void 0;if(!s)return null;let c=FB(r,{source:t.state.doc.toString(),pmDoc:s,ydoc:i,resolver:AB()});if(!c)return null;let l=BB();if(!l)return null;let u=c,d=r.intent===`jump`,f=d?u.point:u.blockStart;t.dispatch({effects:xo.scrollIntoView(f,{y:`start`})});let p=!1,m=null,h=xd(n,{yieldsToNavigation:!d,supersede:()=>{p=!0,h.release()}}),g=e=>{if(!p){if(IB(t,f)===null&&e<8){requestAnimationFrame(()=>g(e+1));return}try{d&&(t.dispatch({selection:No.cursor(f)}),t.focus())}finally{h.release()}m=Gz({docName:n,container:l,contentColumn:t.contentDOM,measureTarget:()=>LB(t,l,f),placement:d?`center`:`top`,intent:d?`jump`:`toggle`,grade:u.confidence,landedMode:`source`,transition:a,toolbarOffset:di(),onOutcome:d?e=>{e.status===`landed`&&fB(t,u.blockStart,u.blockEnd,u.confidence)}:void 0,onDiscardQueuedTarget:()=>xB(n)})}};return g(0),{cancel:e=>{p=!0,h.release(),m?.cancel(e)}}}function qB(e){let{editor:t,docName:n,navigation:r,ydoc:i,transition:a}=e,o=br(t);if(!o)return null;let s=PB(r,{source:i.getText(`source`).toString(),pmDoc:o.state.doc,ydoc:i,resolver:AB()});if(!s)return null;let c=BB();if(!c)return null;let l=s;return Gz({docName:n,container:c,contentColumn:o.dom,measureTarget:()=>zB(o,c,l.point),placement:`top`,intent:`toggle`,grade:l.confidence,landedMode:`wysiwyg`,transition:a,toolbarOffset:di(),onDiscardQueuedTarget:()=>TB(n)})}function JB(e){let t=(0,Q.c)(19),{editor:n,getTargetPosition:r}=e,{_:i}=o(),a;t[0]!==n||t[1]!==r?(a=()=>{let e=Xt(n),t=Yn(n);if(e===null||!t)return;let i=r?.();r&&i===void 0||MB({editor:n,docName:e,ytext:t.getText(`source`),pmPosition:i})},t[0]=n,t[1]=r,t[2]=a):a=t[2];let s=a,c;t[3]===i?c=t[4]:(c=i({id:`M0jOcG`}),t[3]=i,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Rt,{className:`size-3.5`,"aria-hidden":`true`}),t[5]=l):l=t[5];let u;t[6]!==s||t[7]!==c?(u=(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(ee,{type:`button`,variant:`ghost`,size:`icon-xs`,"data-testid":`view-in-source-bubble-button`,className:`text-accent-foreground/80`,"aria-label":c,onMouseDown:YB,onClick:s,children:l})}),t[6]=s,t[7]=c,t[8]=u):u=t[8];let d;t[9]===i?d=t[10]:(d=i({id:`M0jOcG`}),t[9]=i,t[10]=d);let p;t[11]===d?p=t[12]:(p=(0,$.jsx)(`span`,{children:d}),t[11]=d,t[12]=p);let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(f,{"aria-label":Ae(`view-source-at-cursor`),children:ke(`view-source-at-cursor`)}),t[13]=m):m=t[13];let h;t[14]===p?h=t[15]:(h=(0,$.jsxs)(_,{side:`bottom`,sideOffset:8,children:[p,m]}),t[14]=p,t[15]=h);let y;return t[16]!==u||t[17]!==h?(y=(0,$.jsxs)(v,{children:[u,h]}),t[16]=u,t[17]=h,t[18]=y):y=t[18],y}function YB(e){return e.preventDefault()}function XB(e){let t=(0,Q.c)(23),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({label:i,Icon:n,onClick:a,selected:s,className:r,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s?`true`:void 0,l;t[7]===a?l=t[8]:(l=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())},t[7]=a,t[8]=l);let u;t[9]===r?u=t[10]:(u=d(`flex w-full items-center justify-center gap-2 rounded-md border border-dashed border-border bg-transparent px-3 py-2 text-center text-sm text-muted-foreground transition-colors hover:bg-muted/50 cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,r),t[9]=r,t[10]=u);let f;t[11]===n?f=t[12]:(f=(0,$.jsx)(n,{size:16,"aria-hidden":`true`}),t[11]=n,t[12]=f);let p;t[13]===i?p=t[14]:(p=(0,$.jsx)(`span`,{children:i}),t[13]=i,t[14]=p);let m;return t[15]!==a||t[16]!==o||t[17]!==c||t[18]!==l||t[19]!==u||t[20]!==f||t[21]!==p?(m=(0,$.jsxs)(`div`,{...o,role:`button`,tabIndex:-1,contentEditable:!1,"data-descriptor-placeholder":``,"data-selected":c,onClick:a,onMouseDown:ZB,onKeyDown:l,className:u,children:[f,p]}),t[15]=a,t[16]=o,t[17]=c,t[18]=l,t[19]=u,t[20]=f,t[21]=p,t[22]=m):m=t[22],m}function ZB(e){e.preventDefault(),e.stopPropagation()}function QB(e){let t=e.trim();if(/^#[0-9a-fA-F]{6}$/.test(t))return t.toLowerCase();if(/^#[0-9a-fA-F]{3}$/.test(t)){let[,e,n,r]=t.match(/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/)??[];return`#${e}${e}${n}${n}${r}${r}`.toLowerCase()}return`#000000`}function $B(e){let t=(0,Q.c)(42),{id:n,value:r,onChange:i,autoFocus:a}=e,{_:s}=o(),c=(0,Z.useRef)(null),l;t[0]===i?l=t[1]:(l=e=>i(e.target.value),t[0]=i,t[1]=l);let u=a?``:void 0,f=r?`pl-7`:void 0,p;t[2]===f?p=t[3]:(p=d(`h-7 text-sm`,f),t[2]=f,t[3]=p);let m;t[4]!==a||t[5]!==n||t[6]!==l||t[7]!==u||t[8]!==p||t[9]!==r?(m=(0,$.jsx)(Ka,{id:n,type:`text`,value:r,placeholder:`#F05032 or rgb(240,80,50)`,onChange:l,autoFocus:a,"data-prop-autofocus":u,className:p,"data-color-picker-input":``}),t[4]=a,t[5]=n,t[6]=l,t[7]=u,t[8]=p,t[9]=r,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=r&&(0,$.jsx)(`span`,{style:{backgroundColor:r},className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 rounded-sm border border-border`,"aria-hidden":`true`,"data-color-picker-swatch":``}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===s?_=t[17]:(_=s({id:`TiPvBP`}),t[16]=s,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>c.current?.click(),t[18]=v):v=t[18];let y=r||`transparent`,b;t[19]===y?b=t[20]:(b=(0,$.jsx)(`span`,{style:{backgroundColor:y},className:`size-3.5 rounded-sm border border-border`,"aria-hidden":`true`}),t[19]=y,t[20]=b);let x;t[21]!==b||t[22]!==_?(x=(0,$.jsx)(ee,{type:`button`,variant:`outline`,size:`xs`,"aria-label":_,"data-color-picker-trigger":``,className:`h-7 gap-1 px-2`,onClick:v,children:b}),t[21]=b,t[22]=_,t[23]=x):x=t[23];let S;t[24]===r?S=t[25]:(S=QB(r),t[24]=r,t[25]=S);let C;t[26]===i?C=t[27]:(C=e=>i(e.target.value),t[26]=i,t[27]=C);let w;t[28]!==S||t[29]!==C?(w=(0,$.jsx)(`input`,{ref:c,type:`color`,value:S,onChange:C,tabIndex:-1,"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 size-7 opacity-0`,"data-color-picker-native":``}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==x||t[32]!==w?(T=(0,$.jsxs)(`div`,{className:`relative`,children:[x,w]}),t[31]=x,t[32]=w,t[33]=T):T=t[33];let E;t[34]!==s||t[35]!==i||t[36]!==r?(E=r&&(0,$.jsx)(ee,{type:`button`,variant:`ghost`,size:`xs`,"aria-label":s({id:`cb-0G0`}),"data-color-picker-clear":``,className:`h-7 px-1.5`,onClick:()=>i(``),children:(0,$.jsx)(Jl,{className:`size-3`,"aria-hidden":`true`})}),t[34]=s,t[35]=i,t[36]=r,t[37]=E):E=t[37];let D;return t[38]!==T||t[39]!==E||t[40]!==g?(D=(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[g,T,E]}),t[38]=T,t[39]=E,t[40]=g,t[41]=D):D=t[41],D}function eV(e){let t=(0,Q.c)(51),{id:n,value:r,onChange:i,suggestions:a,listLabel:o,emptyMessage:s,placeholder:c,autoFocus:l,ariaInvalid:u,ariaDescribedBy:f,dataPropAutofocus:p,className:m,onSubmit:h}=e,[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(0),b,x;t[0]!==v||t[1]!==a.length?(b=()=>{v>=a.length&&y(0)},x=[v,a.length],t[0]=v,t[1]=a.length,t[2]=b,t[3]=x):(b=t[2],x=t[3]),(0,Z.useEffect)(b,x);let S=(0,Z.useId)(),C=(0,Z.useRef)(null),w=g&&a.length>0,T=g&&a.length===0&&s!==void 0,E;t[4]===i?E=t[5]:(E=e=>{i(e.value),_(!1),y(0),C.current?.focus()},t[4]=i,t[5]=E);let D=E,O=w||T,k;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>_(e),t[6]=k):k=t[6];let A=w?S:void 0,j=w&&a[v]?`${S}-opt-${v}`:void 0,M;t[7]===i?M=t[8]:(M=e=>{i(e.target.value),_(!0),y(0)},t[7]=i,t[8]=M);let N,P;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>{_(!0)},N=()=>{_(!1)},t[9]=N,t[10]=P):(N=t[9],P=t[10]);let F;t[11]!==v||t[12]!==w||t[13]!==h||t[14]!==D||t[15]!==T||t[16]!==a?(F=e=>{if(!Bt(e)){if(e.key===`ArrowDown`){if(a.length===0)return;e.preventDefault(),_(!0),y(e=>(e+1)%a.length);return}if(e.key===`ArrowUp`){if(a.length===0)return;e.preventDefault(),_(!0),y(e=>(e-1+a.length)%a.length);return}if(e.key===`Enter`){if(w){let t=a[v];if(t){e.preventDefault(),D(t);return}}h&&(e.preventDefault(),h());return}if(e.key===`Escape`){if(!w&&!T)return;e.preventDefault(),e.stopPropagation(),_(!1);return}e.key===`Tab`&&_(!1)}},t[11]=v,t[12]=w,t[13]=h,t[14]=D,t[15]=T,t[16]=a,t[17]=F):F=t[17];let I;t[18]!==f||t[19]!==u||t[20]!==l||t[21]!==m||t[22]!==p||t[23]!==n||t[24]!==w||t[25]!==c||t[26]!==F||t[27]!==A||t[28]!==j||t[29]!==M||t[30]!==r?(I=(0,$.jsx)(ba,{asChild:!0,children:(0,$.jsx)(Ka,{ref:C,id:n,type:`text`,value:r,placeholder:c,autoFocus:l,"data-prop-autofocus":p,"aria-invalid":u,"aria-describedby":f,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":w,"aria-controls":A,"aria-activedescendant":j,className:m,onChange:M,onClick:P,onBlur:N,onKeyDown:F})}),t[18]=f,t[19]=u,t[20]=l,t[21]=m,t[22]=p,t[23]=n,t[24]=w,t[25]=c,t[26]=F,t[27]=A,t[28]=j,t[29]=M,t[30]=r,t[31]=I):I=t[31];let L;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>{let t=e.target;t instanceof Node&&C.current?.contains(t)&&e.preventDefault()},t[32]=L):L=t[32];let ee;t[33]!==s||t[34]!==v||t[35]!==o||t[36]!==S||t[37]!==D||t[38]!==a?(ee=a.length===0?s!==void 0&&(0,$.jsx)(`p`,{className:`px-2 py-1 text-xs text-muted-foreground wrap-break-word`,children:s}):(0,$.jsx)(`div`,{id:S,role:`listbox`,"aria-label":o,className:`flex flex-col gap-px`,children:a.map((e,t)=>{let n=`${S}-opt-${t}`,r=t===v;return(0,$.jsxs)(`button`,{id:n,type:`button`,role:`option`,"aria-selected":r,"data-testid":`suggestion-option`,"data-highlighted":r?``:void 0,className:d(`flex w-full flex-col items-start gap-0.5 rounded-sm px-2 py-1 text-left text-xs`,`transition-colors`,r?`bg-accent text-accent-foreground`:`hover:bg-accent/50`),onMouseEnter:()=>y(t),onMouseDown:t=>{t.preventDefault(),D(e)},children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),e.detail!==void 0&&(0,$.jsx)(`span`,{className:r?`text-accent-foreground/70`:`text-muted-foreground`,children:e.detail})]},e.value)})}),t[33]=s,t[34]=v,t[35]=o,t[36]=S,t[37]=D,t[38]=a,t[39]=ee):ee=t[39];let R;t[40]===ee?R=t[41]:(R=(0,$.jsx)(ya,{align:`start`,sideOffset:4,className:`z-70 w-(--radix-popover-trigger-width) p-1`,"data-ok-declines-keyboard":``,onMouseDown:rV,onOpenAutoFocus:nV,onCloseAutoFocus:tV,onInteractOutside:L,children:ee}),t[40]=ee,t[41]=R);let te;t[42]!==I||t[43]!==R||t[44]!==O?(te=(0,$.jsxs)(xa,{open:O,onOpenChange:k,children:[I,R]}),t[42]=I,t[43]=R,t[44]=O,t[45]=te):te=t[45];let ne=T?s:``,re;t[46]===ne?re=t[47]:(re=(0,$.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`sr-only`,children:ne}),t[46]=ne,t[47]=re);let ie;return t[48]!==te||t[49]!==re?(ie=(0,$.jsxs)($.Fragment,{children:[te,re]}),t[48]=te,t[49]=re,t[50]=ie):ie=t[50],ie}function tV(e){e.preventDefault()}function nV(e){e.preventDefault()}function rV(e){e.preventDefault()}function iV(e){let t=(0,Q.c)(16),n,r;t[0]===e?(n=t[1],r=t[2]):({value:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let{_:i}=o(),a=ts(),s;t[3]===a?.pages?s=t[4]:(s=a?.pages??[],t[3]=a?.pages,t[4]=s);let c;t[5]!==a?.pageTitles||t[6]!==s||t[7]!==r?(c=ri([...s].map(e=>({kind:`page`,docName:e,title:a?.pageTitles.get(e)??e.split(`/`).pop()??e})),r.trim()).map(aV),t[5]=a?.pageTitles,t[6]=s,t[7]=r,t[8]=c):c=t[8];let l=c,u;t[9]===i?u=t[10]:(u=i({id:`hwdlGS`}),t[9]=i,t[10]=u);let d;return t[11]!==n||t[12]!==l||t[13]!==u||t[14]!==r?(d=(0,$.jsx)(eV,{...n,value:r,suggestions:l,listLabel:u}),t[11]=n,t[12]=l,t[13]=u,t[14]=r,t[15]=d):d=t[15],d}function aV(e){return{value:e.docName,label:e.title,detail:e.title===e.docName?void 0:e.docName}}function oV(e){let t=(0,Q.c)(55),{id:n,value:r,onChange:i,autoFocus:s}=e,{_:c}=o(),[l,u]=(0,Z.useState)(!1),f;t[0]===r?f=t[1]:(f=sv(r),t[0]=r,t[1]=f);let p=f,m;t[2]===r?m=t[3]:(m=r.startsWith(`lucide:`)?r.slice(7):null,t[2]=r,t[3]=m);let h=m,g;t[4]===i?g=t[5]:(g=e=>i(e.target.value),t[4]=i,t[5]=g);let _=s?``:void 0,v=p?`pl-7`:void 0,y;t[6]===v?y=t[7]:(y=d(`h-7 text-sm`,v),t[6]=v,t[7]=y);let b;t[8]!==s||t[9]!==n||t[10]!==g||t[11]!==_||t[12]!==y||t[13]!==r?(b=(0,$.jsx)(Ka,{id:n,type:`text`,value:r,placeholder:`lucide:Lightbulb or 📘`,onChange:g,autoFocus:s,"data-prop-autofocus":_,className:y,"data-icon-picker-input":``}),t[8]=s,t[9]=n,t[10]=g,t[11]=_,t[12]=y,t[13]=r,t[14]=b):b=t[14];let x;t[15]===p?x=t[16]:(x=p&&(0,$.jsx)(p,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),t[15]=p,t[16]=x);let S;t[17]!==b||t[18]!==x?(S=(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[b,x]}),t[17]=b,t[18]=x,t[19]=S):S=t[19];let C;t[20]===c?C=t[21]:(C=c({id:`jDhTLC`}),t[20]=c,t[21]=C);let w;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(jt,{className:`size-3`,"aria-hidden":`true`}),t[22]=w):w=t[22];let T;t[23]!==l||t[24]!==C?(T=(0,$.jsx)(va,{asChild:!0,children:(0,$.jsx)(ee,{type:`button`,variant:`outline`,size:`xs`,"aria-label":C,"aria-haspopup":`listbox`,"aria-expanded":l,"data-icon-picker-trigger":``,className:`h-7 gap-1 px-2`,children:w})}),t[23]=l,t[24]=C,t[25]=T):T=t[25];let E;t[26]===c?E=t[27]:(E=c({id:`DiZ3pq`}),t[26]=c,t[27]=E);let D;t[28]===c?D=t[29]:(D=c({id:`l_6JHD`}),t[28]=c,t[29]=D);let O;t[30]===D?O=t[31]:(O=(0,$.jsx)(QD,{placeholder:D,className:`h-8 text-sm`}),t[30]=D,t[31]=O);let k;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(eO,{children:(0,$.jsx)(a,{id:`NmaGHf`})}),t[32]=k):k=t[32];let A;t[33]!==i||t[34]!==r.length?(A=r.length>0&&(0,$.jsx)(tO,{children:(0,$.jsxs)(nO,{value:`__clear__`,onSelect:()=>{i(``),u(!1)},className:`gap-2 text-muted-foreground`,"data-icon-picker-clear":``,children:[(0,$.jsx)(Mi,{className:`size-3.5`,"aria-hidden":`true`}),`Clear icon`]})}),t[33]=i,t[34]=r.length,t[35]=A):A=t[35];let j;t[36]!==i||t[37]!==h?(j=ov.map(e=>{let[t,n]=e,r=t===h;return(0,$.jsx)(nO,{value:t,onSelect:()=>{i(`lucide:${t}`),u(!1)},title:t,"aria-label":t,"data-icon-picker-item":t,"data-icon-picker-selected":r?``:void 0,className:d(`flex aspect-square items-center justify-center rounded-md p-0`,r?`bg-foreground/10 text-foreground ring-1 ring-foreground/30`:`text-muted-foreground hover:bg-muted`),children:(0,$.jsx)(n,{className:`size-4`,"aria-hidden":`true`})},t)}),t[36]=i,t[37]=h,t[38]=j):j=t[38];let M;t[39]===j?M=t[40]:(M=(0,$.jsx)(tO,{heading:`Lucide`,children:(0,$.jsx)(RD.Group,{className:`[&_[cmdk-group-items]]:grid [&_[cmdk-group-items]]:grid-cols-6 [&_[cmdk-group-items]]:gap-1 [&_[cmdk-group-items]]:p-1`,children:j})}),t[39]=j,t[40]=M);let N;t[41]!==A||t[42]!==M?(N=(0,$.jsxs)($D,{className:`max-h-64`,children:[k,A,M]}),t[41]=A,t[42]=M,t[43]=N):N=t[43];let P;t[44]!==E||t[45]!==O||t[46]!==N?(P=(0,$.jsx)(ya,{align:`end`,className:`z-70 w-72 p-0`,onOpenAutoFocus:sV,children:(0,$.jsxs)(XD,{label:E,children:[O,N]})}),t[44]=E,t[45]=O,t[46]=N,t[47]=P):P=t[47];let F;t[48]!==l||t[49]!==T||t[50]!==P?(F=(0,$.jsxs)(xa,{open:l,onOpenChange:u,children:[T,P]}),t[48]=l,t[49]=T,t[50]=P,t[51]=F):F=t[51];let I;return t[52]!==F||t[53]!==S?(I=(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[S,F]}),t[52]=F,t[53]=S,t[54]=I):I=t[54],I}function sV(e){return e.preventDefault()}var cV=80,lV={kind:`unavailable`},uV={kind:`ready`,entries:[]},dV=new Set([`paragraph`,`heading`,`emphasis`,`strong`,`delete`,`link`,`linkReference`,`tableCell`,`mdxJsxTextElement`]);function fV(e){if(typeof e.value==`string`)return e.value;let t=dV.has(e.type)?``:` `;return(e.children??[]).map(fV).join(t)}function pV(e){let t=(e.children??[]).map(fV).join(` `).replace(/\s+/g,` `).trim();return t.length<=cV?t:`${Iu(t,cV).trimEnd()}…`}function mV(e){let t=[],n=new Set,r=e=>{if(e.type===`mdxJsxFlowElement`&&e.name===`MirrorSource`){let r=e,i=nx(r);i&&!n.has(i)&&(n.add(i),t.push({name:i,preview:pV(r)}))}for(let t of e.children??[])r(t)};return r(e),t}function hV(e,t){let n;try{n=oi().parseToMdast(t)}catch(t){return console.warn(`[Mirror] parseToMdast failed while listing source names`,{docName:e,err:t}),lV}return{kind:`ready`,entries:mV(n)}}function gV(e){let t=(0,Q.c)(3),n=ts(),r=e!==``&&n?.pages.has(e)===!0,i=Bv(r?e:null);if(!r)return lV;switch(i.kind){case`empty`:return uV;case`ready`:{let n;return t[0]!==e||t[1]!==i.text?(n=hV(e,i.text),t[0]=e,t[1]=i.text,t[2]=n):n=t[2],n}case`loading`:case`unreachable`:case`at-capacity`:return lV}}var _V=8;function vV(e){let t=(0,Q.c)(23),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({docName:n,value:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{_:a}=o(),s=gV(n),c,l;if(t[4]!==s.entries||t[5]!==s.kind||t[6]!==i){c=s.kind===`ready`?s.entries:[];let e=i.trim().toLowerCase();l=c.filter(t=>t.name.toLowerCase().includes(e)||t.preview.toLowerCase().includes(e)).slice(0,_V).map(yV),t[4]=s.entries,t[5]=s.kind,t[6]=i,t[7]=c,t[8]=l}else c=t[7],l=t[8];let u=l,d;if(s.kind===`ready`&&c.length===0){let e;t[9]!==a||t[10]!==n?(e=a({id:`GndE4v`,values:{docName:n}}),t[9]=a,t[10]=n,t[11]=e):e=t[11],d=e}else if(s.kind===`ready`&&u.length===0){let e;t[12]!==a||t[13]!==n?(e=a({id:`fZ_eNM`,values:{docName:n}}),t[12]=a,t[13]=n,t[14]=e):e=t[14],d=e}let f;t[15]===a?f=t[16]:(f=a({id:`sxDZ7M`}),t[15]=a,t[16]=f);let p;return t[17]!==d||t[18]!==r||t[19]!==u||t[20]!==f||t[21]!==i?(p=(0,$.jsx)(eV,{...r,value:i,suggestions:u,listLabel:f,emptyMessage:d}),t[17]=d,t[18]=r,t[19]=u,t[20]=f,t[21]=i,t[22]=p):p=t[22],p}function yV(e){return{value:e.name,label:e.name,detail:e.preview===``?void 0:e.preview}}function bV(e){let[t]=e.split(`/`);switch(t){case`image`:return`image`;case`video`:return`video`;case`audio`:return`audio`;case`application`:return e===`application/pdf`?`pdf`:null;case`text`:return`text`;default:return null}}function xV(e){if(e.length===1&&e[0]===`*/*`)return`all`;let t=new Set;for(let n of e){if(n===`*/*`)return`all`;let e=bV(n);e&&t.add(e)}return t}function SV(e){let t=e.lastIndexOf(`.`);return t<0||t<e.lastIndexOf(`/`)?``:e.slice(t+1).toLowerCase()}function CV(e,t){let n=xV(t),r=[];for(let t of e){if(n===`all`){r.push(t);continue}let e=R(SV(t));e&&n.has(e)&&r.push(t)}return r}var wV=8,TV=new Set,EV=null;function DV(e){return{path:e,basename:e.split(`/`).pop()??e}}function OV(e){let t=e.map(e=>e.path).join(``);return EV?.fingerprint===t||(EV={fingerprint:t,byPath:new Map(e.map(e=>[e.path,e])),itemsInOrder:e,corpus:kn(e.map(e=>gi({kind:`page`,path:e.path,title:e.basename})))}),EV}function kV(e){let t=e.trim();return t.startsWith(`/`)?t.slice(1):t}function AV(e,t){let n=kV(t);return n?qt(e.corpus,n,{intent:`autocomplete`,limit:wV}).map(t=>e.byPath.get(t.document.path)).filter(e=>!!e):e.itemsInOrder.slice(0,wV)}function jV(e){let t=(0,Q.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({value:i,accept:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{_:a}=o(),s=ts()?.assetPaths??TV,c;t[4]!==n||t[5]!==s||t[6]!==i?(c=AV(OV(CV(s,n).map(DV)),i).map(MV),t[4]=n,t[5]=s,t[6]=i,t[7]=c):c=t[7];let l=c,u;t[8]===a?u=t[9]:(u=a({id:`Xhm7gG`}),t[8]=a,t[9]=u);let d;return t[10]!==r||t[11]!==l||t[12]!==u||t[13]!==i?(d=(0,$.jsx)(eV,{...r,value:i,suggestions:l,listLabel:u}),t[10]=r,t[11]=l,t[12]=u,t[13]=i,t[14]=d):d=t[14],d}function MV(e){return{value:`/${e.path}`,label:e.basename,detail:e.basename===e.path?void 0:e.path}}function NV(){if(typeof window>`u`)return null;let e=window.location.hash.match(/^#\/([^?#]+)/);return e?decodeURIComponent(e[1]):null}var PV=`/api/upload`;async function FV(e,t,n={}){if(n.singleFile)throw new Yg(qg(),`single-file-mode`);let r=n.fetch??globalThis.fetch,i=e.size,a=n.docName===void 0?NV():n.docName;if(!a)throw Error(`No document is open`);let o=new FormData;o.append(`file`,e),o.append(`parentDocName`,`${a}.md`);let s;try{s=await r(PV,{method:`POST`,body:o})}catch(t){let n;try{n=await n_({file:e,sizeAtDrop:i,error:t})}catch(e){console.error(`[uploadFile] upload failed, and diagnosing it failed too`,{docName:a,networkError:t,reportError:e})}throw n?(console.error(`[uploadFile] upload failed before reaching the server`,{...n.log,docName:a}),new Yg(n.message,n.kind)):Error(t instanceof Error?t.message:String(t))}let c;try{c=await s.json()}catch(e){throw new pi(`Upload response is not JSON.`,{cause:e,status:s.status})}if(!s.ok){let e=Ye.safeParse(c);if(!e.success)throw new pi(`Upload error response did not match ProblemDetails.`,{cause:e.error,status:s.status});let t=$g(e.data);throw t?new Xg(t):Error(e.data.title)}let l=Je.safeParse(c);if(!l.success)throw new pi(`Upload success response did not match UploadAssetSuccess.`,{cause:l.error,status:s.status});let u=l.data.path??l.data.src;return{url:u.startsWith(`/`)?u:`/${u}`}}function IV(e,t,n){return n<=0?Y._({id:`XXA1b_`,values:{componentLabel:e}}):Y._({id:`Qe47G0`,values:{componentLabel:e,childCount:n}})}function LV(e){for(let t of e)if(t.type===`string`&&t.hidden!==!0&&t.advanced!==!0&&t.autoFocus===!0)return t.name;return null}function RV(e){if(!e)return e;let t=e.replace(/[_-]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1)}var zV=new Set([`auto`,`inherit`,`initial`,`unset`]),BV=new Set([`px`,`%`,`rem`,`em`,`vh`,`vw`,`ch`,`ex`,`fr`]),VV=/^(-?\d+(?:\.\d+)?)([a-z%]*)$/i;function HV(e){let t=e.trim();if(!t)return{valid:!1,reason:`empty`};if(zV.has(t.toLowerCase()))return{valid:!0};let n=t.match(VV);if(!n)return{valid:!1,reason:`malformed-syntax`};let r=(n[2]??``).toLowerCase();return r===``||BV.has(r)?{valid:!0}:{valid:!1,reason:`unknown-unit`}}function UV(e){if(e.valid)return null;switch(e.reason){case`empty`:return null;case`malformed-syntax`:return`Enter a number (e.g. 100), a number with a CSS unit (e.g. 100px, 50%, 26rem), or one of: auto, inherit, initial, unset.`;case`unknown-unit`:return`Unknown CSS unit. Use px, %, rem, em, vh, vw, ch, ex, or fr.`}}var WV={video:ne,audio:ae,image:te},GV={youtube:[`youtube.com`,`youtu.be`,`youtube-nocookie.com`],vimeo:[`vimeo.com`],loom:[`loom.com`]};function KV(e){let t=e.toLowerCase();for(let e of Object.keys(GV)){let n=GV[e];for(let r of n)if(t===r||t.endsWith(`.${r}`))return e}return null}function qV(e){let t=e.lastIndexOf(`/`),n=t>=0?e.slice(t+1):e,r=n.lastIndexOf(`.`);return r>0?n.slice(r+1).toLowerCase():``}var JV=`https://placeholder.invalid`;function YV(e,t){let n=e.trim();if(n.length===0)return{valid:!0};let r,i=!0;try{r=new URL(n)}catch{try{r=new URL(n,JV),i=!1}catch{return{valid:!1,reason:`invalid-url`}}}if(t===`video`&&Yt(n)!==null||t===`video`&&ui(n)||t===`video`&&Fn(n))return{valid:!0};let a=i?KV(r.hostname):null;if(a!==null)return{valid:!1,reason:`embed-provider`,provider:a};if(r.protocol===`data:`)return{valid:!1,reason:`data-uri`};let o=qV(r.pathname),s=WV[t];return o===``?i?{valid:!0}:{valid:!1,reason:`wrong-extension`,extension:``}:s.has(o)?{valid:!0}:{valid:!1,reason:`wrong-extension`,extension:o}}function XV(e){if(e.length===0)return;let t=e[0]?.toLowerCase()??``;if(t.startsWith(`video/`))return`video`;if(t.startsWith(`audio/`))return`audio`;if(t.startsWith(`image/`))return`image`}function ZV(e){return`Direct ${e} file URL — ${Array.from(WV[e]).map(e=>`.${e}`).join(`, `)}`}var QV={youtube:`YouTube`,vimeo:`Vimeo`,loom:`Loom`};function $V(e,t){if(e.valid)return``;if(e.reason===`invalid-url`)return`Not a valid URL.`;if(e.reason===`data-uri`)return`Data URIs are not supported for media fields. Use a hosted file URL.`;if(e.reason===`embed-provider`){let n=QV[e.provider];return t===`video`?`Unrecognized ${n} URL. Paste a valid ${n} share or embed link, or a direct ${t} file URL.`:`${n} URLs are not direct ${t} files. Paste a direct ${t} file URL.`}let n=Array.from(WV[t]).map(e=>`.${e}`).join(`, `);return e.extension===``?`Missing file extension. Accepts: ${n}.`:`Unsupported extension .${e.extension}. Accepts: ${n}.`}function eH(e){return`ok.propPanel.advanced.${e}`}function tH(e){try{return typeof localStorage>`u`?!1:localStorage.getItem(eH(e))===`true`}catch{return!1}}function nH(e,t){try{if(typeof localStorage>`u`)return;localStorage.setItem(eH(e),t?`true`:`false`)}catch{}}function rH(e,t){let n=0;for(let r of e){let e=t[r.name],i=`defaultValue`in r?r.defaultValue:void 0;e!==void 0&&e!==i&&(n+=1)}return n}async function iH(e,t,n,r){try{let{url:i}=await FV(e,t,{singleFile:r});n(i)}catch(e){if(e instanceof Yg||e instanceof Xg){z.error(e.message);return}let t=e instanceof Error?e.message:String(e);z.error(Y._({id:`02P3hL`,values:{message:t}}))}}function aH(e){let t=(0,Q.c)(14),{descriptor:n,values:r,onChange:i,onDismiss:o}=e,s;t[0]===r?s=t[1]:(s=e=>!(`hidden`in e&&e.hidden)&&e.hideWhen?.(r)!==!0&&e.type!==`reactnode`,t[0]=r,t[1]=s);let c=n.props.filter(s),l=c.filter(sH),u=c.filter(oH),d=rH(u,r),f;t[2]===n.props?f=t[3]:(f=LV(n.props),t[2]=n.props,t[3]=f);let p=f,m;t[4]===n.name?m=t[5]:(m=()=>tH(n.name),t[4]=n.name,t[5]=m);let[h,g]=(0,Z.useState)(m);if(c.length===0)return null;let _;t[6]!==p||t[7]!==i||t[8]!==o||t[9]!==r?(_=e=>(0,$.jsx)(lH,{propDef:e,value:r[e.name],values:r,onChange:t=>i(e.name,t),onDismiss:o,isAutoFocused:e.name===p},e.name),t[6]=p,t[7]=i,t[8]=o,t[9]=r,t[10]=_):_=t[10];let v=l.map(_),S=u.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,$.jsxs)(x,{open:h,onOpenChange:e=>{g(e),nH(n.name,e)},children:[(0,$.jsxs)(b,{"data-prop-panel-advanced-trigger":``,className:`group flex w-full items-center justify-between rounded px-1 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground uppercase font-mono`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(jt,{className:`size-3 transition-transform group-data-[state=closed]:-rotate-90`}),(0,$.jsx)(a,{id:`sxkWRg`})]}),d>0&&(0,$.jsx)(Pi,{variant:`secondary`,"data-prop-panel-advanced-count":``,children:d})]}),(0,$.jsx)(y,{className:`flex flex-col gap-4 pt-2`,children:u.map(e=>(0,$.jsx)(lH,{propDef:e,value:r[e.name],values:r,onChange:t=>i(e.name,t),onDismiss:o,isAutoFocused:e.name===p},e.name))})]})]}),C;return t[11]!==v||t[12]!==S?(C=(0,$.jsxs)(`div`,{"data-prop-panel":``,className:`flex flex-col gap-4 py-2 text-sm`,children:[v,S]}),t[11]=v,t[12]=S,t[13]=C):C=t[13],C}function oH(e){return`advanced`in e&&e.advanced}function sH(e){return!(`advanced`in e&&e.advanced)}function cH(e){throw Error(`PropPanel: unhandled PropDef type ${JSON.stringify(e)}`)}function lH(e){let t=(0,Q.c)(151),{propDef:n,value:r,values:i,onChange:a,onDismiss:o,isAutoFocused:s}=e,c;t[0]===o?c=t[1]:(c=o?e=>{e.key===`Enter`&&(e.preventDefault(),o())}:void 0,t[0]=o,t[1]=c);let l=c;switch(n.type){case`reactnode`:return null;case`string`:{let e=`prop-${n.name}`,c=n.accept,u=c!==void 0&&c.length>0,d=!n.required&&n.defaultValue===void 0,f,p,m,h;if(t[2]!==c||t[3]!==l||t[4]!==s||t[5]!==a||t[6]!==o||t[7]!==n.colorPicker||t[8]!==n.cssLengthInput||t[9]!==n.documentPicker||t[10]!==n.iconPicker||t[11]!==n.language||t[12]!==n.mirrorSourcePicker||t[13]!==n.name||t[14]!==e||t[15]!==d||t[16]!==r||t[17]!==i){h=Symbol.for(`react.early_return_sentinel`);bb0:{if(p=xb(r),n.language){let r=`${e}-label`,i;t[22]===n.name?i=t[23]:(i=RV(n.name),t[22]=n.name,t[23]=i);let o;t[24]!==r||t[25]!==e||t[26]!==i?(o=(0,$.jsx)(`label`,{id:r,htmlFor:e,className:`text-xs text-muted-foreground`,children:i}),t[24]=r,t[25]=e,t[26]=i,t[27]=o):o=t[27];let c;t[28]!==a||t[29]!==d?(c=e=>{if(e===``&&d){a(void 0);return}a(e)},t[28]=a,t[29]=d,t[30]=c):c=t[30],h=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[o,(0,$.jsx)(ei,{id:e,ariaLabelledBy:r,value:p,language:n.language,onChange:c,autoFocus:s})]});break bb0}if(n.iconPicker){let r;t[31]===n.name?r=t[32]:(r=RV(n.name),t[31]=n.name,t[32]=r);let i;t[33]!==e||t[34]!==r?(i=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:r}),t[33]=e,t[34]=r,t[35]=i):i=t[35];let o;t[36]!==a||t[37]!==d?(o=e=>{if(e===``&&d){a(void 0);return}a(e)},t[36]=a,t[37]=d,t[38]=o):o=t[38],h=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i,(0,$.jsx)(oV,{id:e,value:p,onChange:o,autoFocus:s})]});break bb0}if(n.colorPicker){let r;t[39]===n.name?r=t[40]:(r=RV(n.name),t[39]=n.name,t[40]=r);let i;t[41]!==e||t[42]!==r?(i=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:r}),t[41]=e,t[42]=r,t[43]=i):i=t[43];let o;t[44]!==a||t[45]!==d?(o=e=>{if(e===``&&d){a(void 0);return}a(e)},t[44]=a,t[45]=d,t[46]=o):o=t[46],h=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i,(0,$.jsx)($B,{id:e,value:p,onChange:o,autoFocus:s})]});break bb0}let u;t[47]!==a||t[48]!==d?(u=e=>{a(e===``&&d?void 0:e)},t[47]=a,t[48]=d,t[49]=u):u=t[49];let g=u;if(n.documentPicker){let r;t[50]===n.name?r=t[51]:(r=RV(n.name),t[50]=n.name,t[51]=r);let i;t[52]!==e||t[53]!==r?(i=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:r}),t[52]=e,t[53]=r,t[54]=i):i=t[54],h=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i,(0,$.jsx)(iV,{id:e,value:p,onChange:g,onSubmit:o,autoFocus:s,dataPropAutofocus:s?``:void 0,className:`h-7 text-sm`})]});break bb0}if(n.mirrorSourcePicker!==void 0){let r;t[55]===n.name?r=t[56]:(r=RV(n.name),t[55]=n.name,t[56]=r);let a;t[57]!==e||t[58]!==r?(a=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:r}),t[57]=e,t[58]=r,t[59]=a):a=t[59];let c=i[n.mirrorSourcePicker],l;t[60]===c?l=t[61]:(l=xb(c),t[60]=c,t[61]=l),h=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[a,(0,$.jsx)(vV,{id:e,docName:l,value:p,onChange:g,onSubmit:o,autoFocus:s,dataPropAutofocus:s?``:void 0,className:`h-7 text-sm`})]});break bb0}if(n.cssLengthInput){let r=HV(p),i=r.valid?null:UV(r),o;t[62]===n.name?o=t[63]:(o=RV(n.name),t[62]=n.name,t[63]=o);let c;t[64]!==e||t[65]!==o?(c=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[64]=e,t[65]=o,t[66]=c):c=t[66];let u;t[67]!==a||t[68]!==d?(u=e=>{let t=e.target.value;if(t===``&&d){a(void 0);return}a(t)},t[67]=a,t[68]=d,t[69]=u):u=t[69],h=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,(0,$.jsx)(Ka,{id:e,type:`text`,value:p,placeholder:`100px, 50%, 26rem, auto`,onChange:u,onKeyDown:l,autoFocus:s,"data-prop-autofocus":s?``:void 0,"aria-invalid":i===null?void 0:!0,"aria-describedby":i===null?void 0:`${e}-error`,className:`h-7 text-sm`,"data-prop-css-length-input":``}),i!==null&&(0,$.jsx)(`p`,{id:`${e}-error`,"data-prop-css-length-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:i})]});break bb0}let _=c===void 0?void 0:XV(c),v=_===void 0?null:YV(p,_);f=v!==null&&!v.valid&&_!==void 0&&p.trim().length>0?$V(v,_):null,m=_===void 0?void 0:ZV(_)}t[2]=c,t[3]=l,t[4]=s,t[5]=a,t[6]=o,t[7]=n.colorPicker,t[8]=n.cssLengthInput,t[9]=n.documentPicker,t[10]=n.iconPicker,t[11]=n.language,t[12]=n.mirrorSourcePicker,t[13]=n.name,t[14]=e,t[15]=d,t[16]=r,t[17]=i,t[18]=f,t[19]=p,t[20]=m,t[21]=h}else f=t[18],p=t[19],m=t[20],h=t[21];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let g=m,_;t[70]===n.name?_=t[71]:(_=RV(n.name),t[70]=n.name,t[71]=_);let v;t[72]!==e||t[73]!==_?(v=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:_}),t[72]=e,t[73]=_,t[74]=v):v=t[74];let y;t[75]!==c||t[76]!==l||t[77]!==s||t[78]!==f||t[79]!==g||t[80]!==a||t[81]!==o||t[82]!==e||t[83]!==p||t[84]!==d?(y=c===void 0?(0,$.jsx)(Ka,{id:e,type:`text`,value:p,placeholder:g,onChange:e=>{let t=e.target.value;if(t===``&&d){a(void 0);return}a(t)},onKeyDown:l,autoFocus:s,"data-prop-autofocus":s?``:void 0,"aria-invalid":f===null?void 0:!0,"aria-describedby":f===null?void 0:`${e}-error`,className:`h-7 text-sm`}):(0,$.jsx)(jV,{id:e,value:p,onChange:e=>{if(e===``&&d){a(void 0);return}a(e)},onSubmit:o,accept:c,placeholder:g,autoFocus:s,dataPropAutofocus:s?``:void 0,ariaInvalid:f===null?void 0:!0,ariaDescribedBy:f===null?void 0:`${e}-error`,className:`h-7 text-sm`}),t[75]=c,t[76]=l,t[77]=s,t[78]=f,t[79]=g,t[80]=a,t[81]=o,t[82]=e,t[83]=p,t[84]=d,t[85]=y):y=t[85];let b;t[86]!==c||t[87]!==a||t[88]!==u?(b=u&&(0,$.jsx)(dH,{accept:c,onUploaded:e=>a(e)}),t[86]=c,t[87]=a,t[88]=u,t[89]=b):b=t[89];let x;t[90]!==y||t[91]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[y,b]}),t[90]=y,t[91]=b,t[92]=x):x=t[92];let S;t[93]!==f||t[94]!==e?(S=f!==null&&(0,$.jsx)(`p`,{id:`${e}-error`,"data-prop-media-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:f}),t[93]=f,t[94]=e,t[95]=S):S=t[95];let C;return t[96]!==v||t[97]!==x||t[98]!==S?(C=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[v,x,S]}),t[96]=v,t[97]=x,t[98]=S,t[99]=C):C=t[99],C}case`boolean`:{let e=`prop-${n.name}`,i;t[100]===n.name?i=t[101]:(i=RV(n.name),t[100]=n.name,t[101]=i);let o=i,s;t[102]!==e||t[103]!==o?(s=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[102]=e,t[103]=o,t[104]=s):s=t[104];let c=!!r,l;t[105]===a?l=t[106]:(l=e=>a(e),t[105]=a,t[106]=l);let u;t[107]!==e||t[108]!==c||t[109]!==l?(u=(0,$.jsx)(L,{id:e,checked:c,onCheckedChange:l}),t[107]=e,t[108]=c,t[109]=l,t[110]=u):u=t[110];let d;return t[111]!==s||t[112]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[s,u]}),t[111]=s,t[112]=u,t[113]=d):d=t[113],d}case`enum`:{let e=`prop-${n.name}`,i=r??n.enumValues[0]??``,o;t[114]===n.name?o=t[115]:(o=RV(n.name),t[114]=n.name,t[115]=o);let s;t[116]!==e||t[117]!==o?(s=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[116]=e,t[117]=o,t[118]=s):s=t[118];let c;t[119]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(F,{}),t[119]=c):c=t[119];let l;t[120]===e?l=t[121]:(l=(0,$.jsx)(P,{id:e,size:`sm`,children:c}),t[120]=e,t[121]=l);let u;t[122]===n.enumValues?u=t[123]:(u=n.enumValues.map(uH),t[122]=n.enumValues,t[123]=u);let d;t[124]===u?d=t[125]:(d=(0,$.jsx)(N,{className:`z-70`,children:u}),t[124]=u,t[125]=d);let f;t[126]!==i||t[127]!==a||t[128]!==l||t[129]!==d?(f=(0,$.jsxs)(I,{value:i,onValueChange:a,children:[l,d]}),t[126]=i,t[127]=a,t[128]=l,t[129]=d,t[130]=f):f=t[130];let p;return t[131]!==s||t[132]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s,f]}),t[131]=s,t[132]=f,t[133]=p):p=t[133],p}case`number`:{let e=`prop-${n.name}`,i;t[134]===n.name?i=t[135]:(i=RV(n.name),t[134]=n.name,t[135]=i);let o;t[136]!==e||t[137]!==i?(o=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:i}),t[136]=e,t[137]=i,t[138]=o):o=t[138];let s=r==null?``:String(r),c;t[139]===a?c=t[140]:(c=e=>{let t=e.target.value;if(t===``){a(void 0);return}if(t===`-`)return;let n=Number(t);Number.isNaN(n)||a(n)},t[139]=a,t[140]=c);let u;t[141]!==l||t[142]!==e||t[143]!==s||t[144]!==c?(u=(0,$.jsx)(Ka,{id:e,type:`number`,inputMode:`numeric`,value:s,onChange:c,onKeyDown:l,className:`h-7 text-sm`}),t[141]=l,t[142]=e,t[143]=s,t[144]=c,t[145]=u):u=t[145];let d;return t[146]!==o||t[147]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[o,u]}),t[146]=o,t[147]=u,t[148]=d):d=t[148],d}default:{let e;return t[149]===n?e=t[150]:(e=cH(n),t[149]=n,t[150]=e),e}}}function uH(e){return(0,$.jsx)(M,{value:e,children:e},e)}function dH(e){let t=(0,Q.c)(18),{accept:n,onUploaded:r}=e,i=xs(),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null),l;t[0]===n?l=t[1]:(l=n.join(`,`),t[0]=n,t[1]=l);let u;t[2]!==n||t[3]!==r||t[4]!==i?(u=async e=>{let t=e.target.files?.[0];if(t){s(!0);try{await iH(t,n,r,i)}catch{}s(!1),c.current&&(c.current.value=``)}},t[2]=n,t[3]=r,t[4]=i,t[5]=u):u=t[5];let d;t[6]!==l||t[7]!==u?(d=(0,$.jsx)(`input`,{ref:c,type:`file`,accept:l,className:`hidden`,"data-prop-upload-input":``,onChange:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>c.current?.click(),t[9]=f):f=t[9];let p;t[10]===o?p=t[11]:(p=o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Si,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(a,{id:`_eguJc`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ou,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(a,{id:`eJitUk`})]}),t[10]=o,t[11]=p);let m;t[12]!==p||t[13]!==o?(m=(0,$.jsx)(ee,{type:`button`,variant:`outline`,size:`sm`,disabled:o,"data-prop-upload-trigger":``,className:`h-7 w-full justify-center gap-1.5 px-2 text-xs`,onClick:f,children:p}),t[12]=p,t[13]=o,t[14]=m):m=t[14];let h;return t[15]!==d||t[16]!==m?(h=(0,$.jsxs)($.Fragment,{children:[d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17],h}var fH=`selectionStatePlugin/origin`,pH=`selectionStatePlugin/refresh`,mH=new G(`selectionState`),hH=new Set,gH={selectedBlockId:null,ancestorChain:[],selectionOrigin:`programmatic`,isDragging:!1,rangeEncompassedBlockIds:hH};function _H(e){return mH.getState(e.state)??gH}function vH(e,t){let n=[],{$from:r}=t;for(let t=1;t<=r.depth;t++){let i=r.node(t);if(i.type.name!==`jsxComponent`)continue;let a=r.before(t);n.push(yH(e,i,a))}if(t instanceof xe){let r=t.node;r.type.name===`jsxComponent`&&n.push(yH(e,r,t.from))}return n}function yH(e,t,n){let r=t.attrs.componentName??`unknown`;return{bridgeId:bH(e,n),componentName:r,pos:n}}function bH(e,t){return Sw.getState(e)?.posToId.get(t)??`pos-${t}`}function xH(e,t){if(t instanceof xe)return hH;let{from:n,to:r}=t;if(n>=r)return hH;let i=Sw.getState(e)?.posToId;if(!i)return hH;let a=null;for(let[t,o]of i){if(t<n)continue;let i=e.doc.nodeAt(t);i&&(t+i.nodeSize>r||(a||=new Set,a.add(o)))}return a??hH}function SH(e,t,n={}){let r=vH(e,e.selection),i=r[r.length-1],a=xH(e,e.selection),o={selectedBlockId:i?.bridgeId??null,ancestorChain:r,selectionOrigin:n.origin??t.selectionOrigin,isDragging:n.isDragging??t.isDragging,rangeEncompassedBlockIds:a};return CH(t,o)?t:o}function CH(e,t){if(e===t)return!0;if(e.selectedBlockId!==t.selectedBlockId||e.selectionOrigin!==t.selectionOrigin||e.isDragging!==t.isDragging||e.ancestorChain.length!==t.ancestorChain.length)return!1;for(let n=0;n<e.ancestorChain.length;n++){let r=e.ancestorChain[n],i=t.ancestorChain[n];if(r.bridgeId!==i.bridgeId||r.componentName!==i.componentName||r.pos!==i.pos)return!1}if(e.rangeEncompassedBlockIds.size!==t.rangeEncompassedBlockIds.size)return!1;for(let n of e.rangeEncompassedBlockIds)if(!t.rangeEncompassedBlockIds.has(n))return!1;return!0}var wH=new WeakMap;function TH(e,t,n,r){let i=r?.isDragging??t.isDragging,a=!!e.getMeta(pH),o=e.selectionSet&&!a,s=e.getMeta(fH),c=o?r?.pendingOrigin??null:null,l=s??c??t.selectionOrigin;return o&&r&&(r.pendingOrigin=null),SH(n,t,{origin:l,isDragging:i})}var EH=_e.create({name:`selectionStatePlugin`,addProseMirrorPlugins(){let e=this.editor,t=new J({key:mH,state:{init(e,t){return SH(t,gH)},apply(e,n,r,i){return TH(e,n,i,wH.get(t))}},props:{handleDOMEvents:{mousedown:()=>{let e=wH.get(t);return e&&(e.pendingOrigin=`pointer`),!1},pointerdown:()=>{let e=wH.get(t);return e&&(e.pendingOrigin=`pointer`),!1}},handleKeyDown:(e,n)=>{if(DH(n.key)){let e=wH.get(t);e&&(e.pendingOrigin=`keyboard`)}return!1}},view(n){wH.set(t,{pendingOrigin:null,isDragging:!1});let r=n.dom.parentElement??n.dom,i=()=>{let n=wH.get(t);n&&(n.isDragging=!0,OH(e))},a=()=>{let n=wH.get(t);n&&(n.isDragging=!1,OH(e))};return r.addEventListener(`dragstart`,i,!0),r.addEventListener(`dragend`,a,!0),r.addEventListener(`drop`,a,!0),{destroy:()=>{r.removeEventListener(`dragstart`,i,!0),r.removeEventListener(`dragend`,a,!0),r.removeEventListener(`drop`,a,!0),wH.delete(t)}}}});return[t]}});function DH(e){return e===`ArrowUp`||e===`ArrowDown`||e===`ArrowLeft`||e===`ArrowRight`||e===`Tab`||e===`Escape`||e===`Enter`||e===`Home`||e===`End`||e===`PageUp`||e===`PageDown`}function OH(e){queueMicrotask(()=>{if(!e.isDestroyed)try{let t=e.state.tr.setMeta(pH,!0);e.view.dispatch(t)}catch{}})}function kH(e){let t=(0,Q.c)(5),n;t[0]===e?n=t[1]:(n=()=>e?_H(e):null,t[0]=e,t[1]=n);let[r,i]=(0,Z.useState)(n),a,o;return t[2]===e?(a=t[3],o=t[4]):(a=()=>{if(!e){i(null);return}i(_H(e));let t=()=>{i(_H(e))};return e.on(`transaction`,t),e.on(`selectionUpdate`,t),()=>{e.off(`transaction`,t),e.off(`selectionUpdate`,t)}},o=[e],t[2]=e,t[3]=a,t[4]=o),(0,Z.useEffect)(a,o),r}function AH(e,t){if(e.hasChildren)return!1;let n=LV(e.props);return n===null?!1:t[n]===``}function jH(e){let t=e.placeholder?.label,n=`Add ${(e.displayName??e.name).toLowerCase()}`;return{label:t??n,Icon:iv(e.placeholder?.icon??e.icon)}}function MH(e,t){let n=e.state.schema.nodes.paragraph?.create();if(!n)return!1;let r=e.state.tr.insert(t,n);return r.doc.content.size===e.state.doc.content.size?!1:(r.setSelection(K.near(r.doc.resolve(t+1))),e.dispatch(r.scrollIntoView()),!0)}function NH(e,t,n){let{doc:r}=e.state,i=ve.findFrom(r.resolve(t+n),1,!0);return i?(e.dispatch(e.state.tr.setSelection(i).scrollIntoView()),!0):!1}function PH(e,t,n){let{doc:r}=e.state,i=new yn(r.resolve(t+n)).map(r,new Ce);return i instanceof yn?(e.dispatch(e.state.tr.setSelection(i).scrollIntoView()),!0):!1}function FH(e){if(!e.attrs.sourceDirty&&e.attrs.sourceRaw)return e.attrs.sourceRaw;let t=oi(),n=e.type.schema.node(`doc`,null,[e]);return t.serialize(n.toJSON()).trim()}function IH(e,t,n){let r=t();if(r===void 0)return{kind:`removed`};let i=e.nodeAt(r);return i?{kind:i.eq(n)?`current`:`changed`,pos:r,node:i}:{kind:`removed`}}function LH(e,t){return e.type===t.type&&e.attrs.kind===`element`&&e.attrs.componentName===t.attrs.componentName}function RH(e,t,n){Fr(t),console.warn(JSON.stringify({event:`jsx-component-action-aborted`,action:t,reason:n,component:e.descriptorName===`*`?`wildcard`:e.descriptorName,rawComponentName:String(e.node.attrs.componentName??``).slice(0,200)})),z.info(n===`removed`?Y._({id:`BfTQmM`}):Y._({id:`NXNzgx`}))}function zH(e,t){let n=IH(e.editor.state.doc,e.getPos,e.node);return n.kind===`current`?n:(RH(e,t,n.kind),null)}var BH=new Set(Ji.map(e=>`${e}:`)),VH=6e4,HH=10,UH=new Map;function WH(e,t){let n=t.toLowerCase();ai(n);let r=Date.now(),i=UH.get(n);if(!i||r-i.windowStart>=VH)UH.set(n,{windowStart:r,count:1});else if(i.count+=1,i.count>HH)return;typeof console<`u`&&typeof console.warn==`function`&&console.warn(JSON.stringify({event:`jsx-prop-dropped`,reason:e,prop:t}))}var GH=new Set([`href`,`src`,`action`,`formaction`,`poster`,`cite`,`data`,`manifest`,`background`,`ping`,`xlinkhref`,`xlinkactuate`,`xlinkrole`,`xlinkarcrole`,`xlinkshow`,`url`,`link`]),KH=new Set([`dangerouslysetinnerhtml`,`ref`,`key`,`defaultvalue`,`defaultchecked`,`__proto__`,`constructor`,`prototype`]),qH=1e4;function JH(e){let t=e.toLowerCase();return!!(KH.has(t)||t.length>=3&&t.startsWith(`on`))}function YH(e){return GH.has(e.toLowerCase())}function XH(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t||t.startsWith(`#`)||t.startsWith(`//`)||Qi(t))return e;let n=t.indexOf(`:`),r=t.slice(0,n+1).toLowerCase();return BH.has(r)?e:`#`}function ZH(e){if(e.length>qH)return``;let t=e.toLowerCase();return/url\s*\(\s*['"]?\s*(?:javascript|vbscript|data)\s*:/.test(t)||/\bexpression\s*\(/.test(t)?``:e}function QH(e){if(e==null)return e;if(Array.isArray(e)){let t=!1,n=Array(e.length);for(let r=0;r<e.length;r++){let i=QH(e[r]);n[r]=i,i!==e[r]&&(t=!0)}return t?n:e}if(typeof e!=`object`)return e;let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;let n=e,r=!1,i={};for(let[e,t]of Object.entries(n)){if(JH(e)){WH(`dangerous-prop-name-nested`,e),r=!0;continue}if(YH(e)&&typeof t==`string`){let n=XH(t);n!==t&&(r=!0),i[e]=n}else{let n=QH(t);n!==t&&(r=!0),i[e]=n}}return r?i:e}function $H(e){let t=si(e);if(t)throw RangeError(t);let n=!1,r={};for(let[t,i]of Object.entries(e)){if(JH(t)){WH(`dangerous-prop-name`,t),n=!0;continue}if(YH(t)){let e=XH(i);e!==i&&(n=!0),r[t]=e;continue}if(t===`style`){if(typeof i==`string`){let e=ZH(i);e!==i&&(n=!0),r[t]=e}else n=!0;continue}let e=QH(i);e!==i&&(n=!0),r[t]=e}return n?r:e}var eU=new Set([`img`,`CommonMarkImage`,`video`,`audio`,`Pdf`,`File`,`Excalidraw`]);function tU(e,t,n){if(!eU.has(e)||!n)return t;let r=t.src;if(typeof r!=`string`)return t;let i=Zi(r,n);return i===r?t:{...t,src:i}}var nU=`jsx-component-wrapper my-2`;function rU(e,t,n=!1){let r=fi(t.props,e.props??{}),i={};for(let[e,a]of Object.entries(r))t.reactNodePropNames.has(e)&&!(n&&e===`children`&&typeof a==`string`&&a!==``)||(i[e]=a);return $H(i)}function iU(e,t,n=!1){let r=si(e.props);if(r)return{props:{},error:r};try{return{props:rU(e,t,n),error:null}}catch(e){if(e instanceof RangeError&&e.message===`Component props exceed the rendering budget`)return{props:{},error:e.message};throw e}}function aU(e,t){let n=e.docName;return typeof n==`string`&&n?n:Xt(t)}function oU(e,t,n){let r=e.surface===`compat`?e.translateProps(t):t;return tU(e.name,r,n)}function sU(e,t){let n=t.align;return n===`left`||n===`right`||n===`center`?n:HI.has(e.name)?`center`:void 0}function cU(e,t){return{"data-jsx-component":``,"data-component-type":e.name.toLowerCase(),"data-component-name":e.name,"data-align":sU(e,t)}}function lU(e,t){return!e.hasChildren&&t.childCount===0?`component-children min-h-0 m-0 p-0`:`component-children`}function uU(e,t,n,r){let i=n instanceof Error?n:Error(String(n));return console.warn(JSON.stringify({event:`jsx-render-failure`,component:e,rawComponentName:String(t??``).slice(0,200),error:String(i),stack:r.componentStack})),lr(e),i}function dU(e){let t=(0,Q.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`jsx-component-error-fallback`,children:n}),t[0]=n,t[1]=r),r}function fU(e){let t=(0,Q.c)(13),{children:n,resetKey:r,onError:i,descriptorName:a,rawComponentName:o}=e,s;t[0]===r?s=t[1]:(s=[r],t[0]=r,t[1]=s);let c;t[2]!==a||t[3]!==i||t[4]!==o?(c=(e,t)=>{i(uU(a,o,e,t))},t[2]=a,t[3]=i,t[4]=o,t[5]=c):c=t[5];let l;t[6]===n?l=t[7]:(l=e=>(0,$.jsx)(dU,{...e,children:n}),t[6]=n,t[7]=l);let d;return t[8]!==n||t[9]!==s||t[10]!==c||t[11]!==l?(d=(0,$.jsx)(u,{resetKeys:s,onError:c,fallbackRender:l,children:n}),t[8]=n,t[9]=s,t[10]=c,t[11]=l,t[12]=d):d=t[12],d}function pU(e){let t=si(e);if(t)throw RangeError(t);return mU(e)}function mU(e){if(typeof e!=`object`||!e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(mU).join(`,`)}]`;let t=Object.entries(e);return t.sort(([e],[t])=>e<t?-1:+(e>t)),`{${t.map(([e,t])=>`${JSON.stringify(e)}:${mU(t)}`).join(`,`)}}`}function hU(e){return e.kind===`element`?e:null}function gU(e,t){if(typeof e!=`object`||!e)return!1;let{type:n,name:r}=e;return n===`mdxJsxAttribute`&&typeof r==`string`&&t.has(r)}function _U(e,t,n,r){let i=t.props.find(e=>e.name===n)?.legacyNames??[],a=new Set(r===void 0?[n,...i]:i),o={...e.props};for(let e of a)delete o[e];r!==void 0&&(o[n]=r),n===`src`&&e.componentName===`CommonMarkImage`&&r!==e.props.src&&delete o.sourceUrl;let s=Array.isArray(e.attributes)?e.attributes:[];return{...e,attributes:a.size===0?s:s.filter(e=>!gU(e,a)),props:o,sourceDirty:!0}}var vU=3;function yU(e){let t=(0,Q.c)(60),{node:n,editor:r,extension:i,getPos:s,selected:c}=e,{_:l}=o(),u=ZS(n.attrs.componentName),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(!1),h=(0,Z.useRef)(!1),g=(0,Z.useRef)(!1),_=typeof s==`function`?s():void 0,v=aO(),y=!1,b=0,x=1;try{if(_!==void 0){let e=r.state.doc.resolve(_);e.depth>0&&e.parent.type.name===`jsxComponent`&&(y=!0,b=e.index(e.depth),x=e.parent.childCount)}}catch(e){let t=e;if(!(t instanceof RangeError))throw t}let S=y&&b>0,C=y&&b<x-1,w=kH(r),T=typeof _==`number`?bH(r.state,_):null,E=T!==null&&(w?.rangeEncompassedBlockIds.has(T)??!1),D;t[0]===w?.ancestorChain?D=t[1]:(D=w?.ancestorChain.at(-1)?.bridgeId??null,t[0]=w?.ancestorChain,t[1]=D);let O=T!==null&&D===T,k=c&&!E&&O,A=T!==null&&!O&&(w?.ancestorChain.some(e=>e.bridgeId===T)??!1),j=k&&w?w.selectionOrigin:void 0,M=k&&(w?.isDragging??!1),N=u.props.some(TU),P=n.attrs.props??{},{props:F,error:I}=iU(n.attrs,u),L=N&&u.props.some(e=>e.type!==`string`||!e.required||`hidden`in e&&e.hidden?!1:!Object.hasOwn(F,e.name)),R=AH(u,P),te=R?jH(u):null,ne=!u.hasChildren||!!u.isSelfClosing,re=u.name===`MermaidFence`?{propName:`chart`,language:`mermaid`}:u.name===`Math`||u.name===`DollarMath`||u.name===`MathFence`?{propName:`formula`,language:`latex`}:null,[ie,ae]=(0,Z.useState)(!1),[oe,se]=(0,Z.useState)(!1),[z,B]=(0,Z.useState)(!1),ce=re!==null,V=re?P[re.propName]:void 0,H=ce&&!N&&r.isEditable&&(typeof V!=`string`||V.trim()===``),U=H?jH(u):null;(0,Z.useEffect)(()=>{c&&!g.current&&(N||ce)&&fC(_)&&(N?m(!0):ae(!0)),g.current=c},[c,N,ce,_]);let W=oU(u,F,aU(i.options,r)),le=u.name===`MermaidFence`&&typeof W.chart==`string`?W.chart:null,G=le!==null&&le.trim()!==``?le:null,ue=G!==null,K;t[2]!==ue||t[3]!==se?(K=()=>{ue||se(!1)},t[2]=ue,t[3]=se,t[4]=K):K=t[4];let de;t[5]===ue?de=t[6]:(de=[ue],t[5]=ue,t[6]=de),(0,Z.useEffect)(K,de);let fe=u.name===`Excalidraw`&&Xv(W.src);(0,Z.useEffect)(()=>{fe||B(!1)},[fe]);let pe=`${u.name}::${pU(F)}`,q={editor:r,getPos:s,node:n,descriptorName:u.name},me=(e,t)=>RH(q,e,t),J=e=>zH(q,e),he=e=>{let t=IH(r.state.doc,s,n);return t.kind===`removed`||!LH(t.node,n)?(me(e,t.kind===`removed`?`removed`:`changed`),null):t},ge=e=>{let t=J(`insert-child`);if(!t)return;let n=t.pos+1+t.node.content.size;r.chain().focus().insertContentAt(n,lC(e)).run(),pC(r,n,ZS(e))},_e=u.name===`*`||d!==null,ve=(0,Z.useRef)(!1),ye=(0,Z.useRef)(0),[be,xe]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{if(!_e||ve.current||be)return;let e=FH(n),t=u.name===`*`?`Unregistered component: ${n.attrs.componentName}`:`Render error in <${u.displayName??u.name}>: ${d?.message??`unknown`}`,i=n.type.schema.nodes.rawMdxFallback.create({reason:t},n.type.schema.text(e)),a=!1,o,c=()=>{if(a||!wr(r))return;let e=e=>{let t=u.name===`*`?`wildcard`:u.name;if(console.warn(JSON.stringify({event:`jsx-component-auto-convert-failed`,component:t,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:e.slice(0,500),retry:ye.current})),Sr(t),ye.current+=1,ye.current<vU){let e=50*(2**ye.current-1);o=setTimeout(()=>{a||c()},e)}else a||xe(!0)},t=br(r);if(!t){e(`ProseMirror view not mounted`);return}try{let e=IH(t.state.doc,s,n);if(e.kind!==`current`)return;let r=e.pos;t.dispatch(xn(t.state.tr.replaceWith(r,r+n.nodeSize,i))),ve.current=!0,tr(u.name===`*`?`wildcard`:u.name)}catch(t){let n=t;e(n instanceof Error?n.message:String(n))}},l=requestAnimationFrame(c);return()=>{a=!0,cancelAnimationFrame(l),o!==void 0&&clearTimeout(o)}},[_e,n,r,s,u,d,be]),be){let e=n.attrs.componentName,i=u.displayName??u.name,a=u.name===`*`?l({id:`Kh1n4a`,values:{componentName:e}}):l({id:`g58Kwy`,values:{descriptorLabel:i}}),o=()=>{try{let e=FH(n);typeof navigator<`u`&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(e)}catch(e){let t=e;mr(u.name),console.warn(JSON.stringify({event:`jsx-component-stuck-copy-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t instanceof Error?t.message.slice(0,500):String(t).slice(0,500)}))}},s=()=>{try{let e=J(`delete-stuck`);if(!e)return;r.chain().focus().setNodeSelection(e.pos).deleteSelection().run()}catch(e){let t=e;if(!(t instanceof RangeError))throw t;Hr(u.name),console.warn(JSON.stringify({event:`jsx-component-stuck-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},c;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c={[Gy]:`true`},t[7]=c):c=t[7];let d;t[8]===a?d=t[9]:(d=(0,$.jsx)(`span`,{className:`flex-1`,children:a}),t[8]=a,t[9]=d);let f;t[10]===l?f=t[11]:(f=l({id:`E2Mv-X`}),t[10]=l,t[11]=f);let p;t[12]!==o||t[13]!==f?(p=(0,$.jsx)(`button`,{type:`button`,className:`text-xs underline hover:no-underline`,onClick:o,children:f}),t[12]=o,t[13]=f,t[14]=p):p=t[14];let m;t[15]===l?m=t[16]:(m=l({id:`cnGeoo`}),t[15]=l,t[16]=m);let h;return t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Ir,{className:`component-children`}),t[17]=h):h=t[17],(0,$.jsxs)(Xr,{className:`jsx-component-wrapper my-2`,children:[(0,$.jsxs)(`div`,{className:`text-xs font-mono text-muted-foreground px-2 py-2 border border-destructive/40 rounded flex items-center gap-2`,contentEditable:!1,...c,children:[d,p,(0,$.jsx)(`button`,{type:`button`,className:`text-xs underline hover:no-underline`,onClick:s,children:m})]}),h]})}if(I){let e;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e={[Gy]:`true`},t[18]=e):e=t[18];let n;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`span`,{role:`status`,children:(0,$.jsx)(a,{id:`MzoWIU`})}),t[19]=n):n=t[19];let i;return t[20]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(Ir,{className:`component-children`}),t[20]=i):i=t[20],(0,$.jsxs)(Xr,{className:`jsx-component-wrapper my-2`,"data-jsx-props-error":``,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-2 py-1 text-xs text-warning`,contentEditable:!1,...e,children:[n,(0,$.jsx)(JB,{editor:r,getTargetPosition:()=>J(`edit-source`)?.pos})]}),i]})}if(_e){let e=n.attrs.componentName,r=u.displayName??u.name,i=u.name===`*`?l({id:`oJl7eO`,values:{componentName:e}}):l({id:`bcDHUM`,values:{descriptorLabel:r}}),a;t[21]===i?a=t[22]:(a=(0,$.jsx)(`div`,{className:`text-xs font-mono text-muted-foreground px-2 py-1`,contentEditable:!1,children:i}),t[21]=i,t[22]=a);let o;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Ir,{className:`component-children`}),t[23]=o):o=t[23];let s;return t[24]===a?s=t[25]:(s=(0,$.jsxs)(Xr,{className:`jsx-component-wrapper my-2`,children:[a,o]}),t[24]=a,t[25]=s),s}let Se=u.Component,Ce=u.displayName??u.name,we=u.displayName??u.name,Te=u.displayName??u.name,Ee=e=>{if(R||H||!ne)return;let t=e.target;if(!e.currentTarget.contains(t)||t.closest(`.jsx-component-chrome`)||t.closest(`.jsx-add-child-pill, .jsx-empty-child-placeholder`)||t.closest(`a[href]`))return;let i=IH(r.state.doc,s,n);if(i.kind!==`current`)return;let a=i.pos,o=a+n.nodeSize,c=r.state.selection.from;c<a||c>=o||r.chain().focus().setNodeSelection(a).run()},De=()=>{let e=J(`open-properties`);e&&(r.chain().focus().setNodeSelection(e.pos).run(),m(!0))},Oe=u.displayName??u.name,ke=!!u.emptyChildName,Ae=ke?IV(Oe,u.emptyChildName,n.childCount):void 0,Y=e=>{let t=e.target;if(e.key===`Backspace`||e.key===`Delete`){if(!k||!e.currentTarget.contains(t)||t.matches(`input, textarea`))return;e.preventDefault();try{let e=J(`delete-keyboard`);if(!e)return;r.chain().focus().setNodeSelection(e.pos).deleteSelection().run()||($r(u.name),console.warn(JSON.stringify({event:`jsx-component-keyboard-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:`chain-dispatch-returned-false`})))}catch(e){let t=e;if(!(t instanceof RangeError))throw t;$r(u.name),console.warn(JSON.stringify({event:`jsx-component-keyboard-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}return}e.key!==`Enter`&&e.key!==` `||c&&N&&(t.closest(`.jsx-component-chrome`)||t.closest(`input, textarea, select, button`)||(e.preventDefault(),m(!0)))},je=e=>{m(e),!e&&requestAnimationFrame(()=>{try{let e=IH(r.state.doc,s,n);if(e.kind!==`current`)return;let{pos:t,node:i}=e,a=t+i.nodeSize,o=r.state.selection.from;if(o<t||o>=a)return;(!ne||!NH(r.view,t,i.nodeSize)&&!PH(r.view,t,i.nodeSize))&&r.chain().setNodeSelection(t).run()}catch(e){let t=e;if(!(t instanceof RangeError))throw t;Or(u.name),console.warn(JSON.stringify({event:`jsx-component-popover-close-restore-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}})},Me=cU(u,P),Ne;t[26]===y?Ne=t[27]:(Ne=y?{draggable:`false`,onDragStart:wU}:{"data-drag-handle":``,draggable:`true`},t[26]=y,t[27]=Ne);let Pe;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(Pe={[Gy]:`true`},t[28]=Pe):Pe=t[28];let Fe;t[29]!==l||t[30]!==Ce?(Fe=l({id:`MCjC9A`,values:{deleteDescriptorLabel:Ce}}),t[29]=l,t[30]=Ce,t[31]=Fe):Fe=t[31];let Ie;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=(0,$.jsx)(Ai,{size:12,"aria-hidden":`true`}),t[32]=Ie):Ie=t[32];let Le;t[33]!==oe||t[34]!==G||t[35]!==se?(Le=G===null?null:(0,$.jsx)(Ot,{chart:G,open:oe,onOpenChange:se}),t[33]=oe,t[34]=G,t[35]=se,t[36]=Le):Le=t[36];let Re;t[37]!==l||t[38]!==P||t[39]!==u||t[40]!==ie||t[41]!==re||t[42]!==r.isEditable||t[43]!==r.state.tr||t[44]!==r.view||t[45]!==_||t[46]!==W||t[47]!==he||t[48]!==ae?(Re=re&&typeof _==`number`?(0,$.jsx)(lF,{open:ie,onOpenChange:ae,initialValue:typeof P[re.propName]==`string`?P[re.propName]:``,language:re.language,title:l({id:`ky9Tuc`,values:{0:u.displayName??u.name}}),renderPreview:(e,t)=>{let n=u.Component;return(0,$.jsx)(`div`,{className:`flex h-full w-full items-center justify-center p-4`,children:(0,$.jsx)(n,{...W,[re.propName]:e,...u.name===`MermaidFence`&&{className:`border-0 bg-transparent rounded-none`,editBinding:{canEdit:r.isEditable,commitChart:t}}})})},onSave:e=>{let t=he(`edit-source`);if(!t)return;let{pos:n,node:i}=t,a=hU(i.attrs);if(a)try{let t={...a.props,[re.propName]:e},i={...a,props:t,sourceDirty:!0};r.view.dispatch(r.state.tr.setNodeMarkup(n,null,i)),En()}catch(e){let t=e;if(!(t instanceof RangeError))throw t;console.warn(`[JsxComponentView] edit-save failed — position race`,t)}}}):null,t[37]=l,t[38]=P,t[39]=u,t[40]=ie,t[41]=re,t[42]=r.isEditable,t[43]=r.state.tr,t[44]=r.view,t[45]=_,t[46]=W,t[47]=he,t[48]=ae,t[49]=Re):Re=t[49];let ze;return t[50]!==u||t[51]!==r||t[52]!==N||t[53]!==ne||t[54]!==F||t[55]!==Te||t[56]!==he||t[57]!==m||t[58]!==R?(ze=N&&(0,$.jsxs)(ya,{side:R?`bottom`:`right`,align:R?`center`:`start`,sideOffset:R?-4:8,className:`w-64 p-3 z-60 overflow-y-auto subtle-scrollbar max-h-(--radix-popper-available-height) overscroll-contain`,onInteractOutside:()=>{h.current=!0},onCloseAutoFocus:e=>{let t=h.current;if(h.current=!1,!ne&&t)return;e.preventDefault();let n=br(r);n&&!n.isDestroyed&&n.focus()},children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,$.jsx)(a,{id:`Mnavhe`,values:{propPanelDescriptorLabel:Te}})}),(0,$.jsx)(aH,{descriptor:u,values:F,onDismiss:()=>m(!1),onChange:(e,t)=>{let n=he(`edit-properties`);if(!n)return;let{pos:i,node:a}=n,o=hU(a.attrs);o&&(r.view.dispatch(r.state.tr.setNodeMarkup(i,null,_U(o,u,e,t))),En())}}),(0,$.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-border pt-2`,children:(0,$.jsx)(ee,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>m(!1),className:`h-7 px-3 text-xs`,children:(0,$.jsx)(a,{id:`DPfwMq`})})})]}),t[50]=u,t[51]=r,t[52]=N,t[53]=ne,t[54]=F,t[55]=Te,t[56]=he,t[57]=m,t[58]=R,t[59]=ze):ze=t[59],(0,$.jsxs)(xa,{open:p,onOpenChange:je,children:[(0,$.jsxs)(Xr,{className:nU,...Me,"data-selected":k?`true`:void 0,"data-has-child-selected":A?`true`:void 0,"data-range-selected":E?`true`:void 0,"data-selection-origin":j,"data-dragging":M?`true`:void 0,"data-needs-config":L?`true`:void 0,role:ke?`group`:void 0,"aria-label":Ae,tabIndex:k?0:-1,...Ne,onClick:Ee,onKeyDown:Y,children:[(0,$.jsxs)(`div`,{className:`jsx-component-chrome`,contentEditable:!1,onMouseDown:CU,...Pe,children:[u.name===`Embed`&&typeof F.src==`string`&&/^https?:\/\//i.test(F.src)&&(0,$.jsx)(`a`,{href:F.src,target:`_blank`,rel:`noopener noreferrer`,className:`jsx-chrome-btn`,"aria-label":l({id:`iOHg1t`}),onMouseDown:SU,children:(0,$.jsx)(Yl,{size:12,"aria-hidden":`true`})}),u.name===`Mirror`&&xb(F.src)!==``&&(()=>{let e=xb(F.src),t=xb(F.name);return(0,$.jsx)(`a`,{href:t===``?pa(e):oa(e,t),className:`jsx-chrome-btn`,"aria-label":l({id:`3a_Bd7`,values:{mirrorSrc:e}}),title:l({id:`0kTAXe`,values:{mirrorSrc:e}}),onMouseDown:xU,children:(0,$.jsx)(Yl,{size:12,"aria-hidden":`true`})})})(),S&&(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`QyioBP`}),onClick:()=>{try{let e=J(`move-up`);if(!e)return;let t=e.pos,i=r.state.doc.resolve(t),a=i.index(i.depth);if(a===0)return;let o=t-i.node(i.depth).child(a-1).nodeSize,s=t+n.nodeSize,c=r.state.tr,l=r.state.doc.slice(t,t+n.nodeSize),u=r.state.doc.slice(o,t);c.replaceWith(o,s,l.content.append(u.content)),r.view.dispatch(c.scrollIntoView())}catch(e){let t=e;if(!(t instanceof RangeError))throw t;or(`up`),console.warn(JSON.stringify({event:`jsx-component-move-failed`,direction:`up`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},children:(0,$.jsx)(yt,{size:12,"aria-hidden":`true`})}),C&&(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`3Ib6FN`}),onClick:()=>{try{let e=J(`move-down`);if(!e)return;let t=e.pos,i=r.state.doc.resolve(t),a=i.index(i.depth),o=i.node(i.depth);if(a>=o.childCount-1)return;let s=o.child(a+1),c=t,l=t+n.nodeSize+s.nodeSize,u=r.state.tr,d=r.state.doc.slice(t,t+n.nodeSize),f=r.state.doc.slice(t+n.nodeSize,l);u.replaceWith(c,l,f.content.append(d.content)),r.view.dispatch(u.scrollIntoView())}catch(e){let t=e;if(!(t instanceof RangeError))throw t;or(`down`),console.warn(JSON.stringify({event:`jsx-component-move-failed`,direction:`down`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},children:(0,$.jsx)(vt,{size:12,"aria-hidden":`true`})}),re&&typeof _==`number`?(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`ky9Tuc`,values:{0:u.displayName??u.name}}),"data-testid":`jsx-component-edit-btn`,onClick:()=>ae(!0),children:(0,$.jsx)(Ei,{size:12,"aria-hidden":`true`})}):null,G===null?null:(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`HimZ41`}),"data-testid":`jsx-component-expand-btn`,onClick:()=>se(!0),children:(0,$.jsx)(Ci,{size:12,"aria-hidden":`true`})}),fe?(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`lT6wjt`}),"data-testid":`jsx-component-expand-board-btn`,onClick:()=>B(!0),children:(0,$.jsx)(Ci,{size:12,"aria-hidden":`true`})}):null,!v&&Xu(n).length>0&&typeof _==`number`?(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`INp_z6`,values:{0:u.displayName??u.name}}),"data-testid":`jsx-component-ask-ai-btn`,onClick:()=>{try{let e=J(`comment`);if(!e)return;r.commands.setNodeSelection(e.pos)}catch(e){let t=e;console.warn(JSON.stringify({event:`jsx-component-chrome-ask-ai-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t instanceof Error?t.message.slice(0,500):String(t)}));return}requestAnimationFrame(()=>{try{Fl()}catch(e){let t=e;console.warn(JSON.stringify({event:`jsx-component-chrome-ask-ai-emit-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t instanceof Error?t.message.slice(0,500):String(t)}))}})},children:(0,$.jsx)(ki,{size:12,"aria-hidden":`true`})}):null,(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn jsx-chrome-btn--delete`,"aria-label":Fe,onClick:()=>{try{let e=J(`delete-chrome`);if(!e)return;r.chain().focus().setNodeSelection(e.pos).deleteSelection().run()||(Rr(u.name),console.warn(JSON.stringify({event:`jsx-component-chrome-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:`chain-dispatch-returned-false`})))}catch(e){let t=e;if(!(t instanceof RangeError))throw t;Rr(u.name),console.warn(JSON.stringify({event:`jsx-component-chrome-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},children:Ie}),N&&(0,$.jsx)(va,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"data-jsx-gear":``,"aria-label":l({id:`XPJ0sN`,values:{settingsDescriptorLabel:we}}),children:(0,$.jsx)(Ht,{size:12,"aria-hidden":`true`})})})]}),R&&te?(0,$.jsx)(ba,{asChild:!0,children:(0,$.jsx)(XB,{label:te.label,Icon:te.Icon,onClick:De,selected:k})}):H&&U?(0,$.jsx)(XB,{label:U.label,Icon:U.Icon,onClick:()=>ae(!0),selected:k}):(0,$.jsx)(fU,{resetKey:pe,onError:f,descriptorName:u.name===`*`?`wildcard`:u.name,rawComponentName:n.attrs.componentName??``,children:(0,$.jsx)(xt,{value:typeof s==`function`?{editor:r,getPos:()=>{let e=IH(r.state.doc,s,n);return e.kind!==`removed`&&LH(e.node,n)?e.pos:void 0},addChild:u.emptyChildName?()=>{let e=u.emptyChildName;ge(e)}:null}:null,children:(0,$.jsx)(Se,{...W,...G===null?{}:{onExpand:()=>se(!0)},...fe?{expandOpen:z,onExpandOpenChange:B}:{},children:(0,$.jsx)(Ir,{className:lU(u,n),...!u.hasChildren||u.isSelfClosing?{contentEditable:!1}:{}})})})}),u.emptyChildName&&!(u.name===`Tabs`&&n.childCount>0)&&(()=>{let e=u.emptyChildName;return(0,$.jsx)(`button`,{type:`button`,contentEditable:!1,className:n.childCount===0?`jsx-empty-child-placeholder`:`jsx-add-child-pill`,onMouseDown:bU,onClick:()=>{let e=u.emptyChildName;ge(e)},"data-clipboard-omit":`true`,children:(0,$.jsx)(`span`,{children:(0,$.jsx)(a,{id:`7Fkcej`,values:{addChildName:e}})})})})()]}),Le,Re,ze]})}function bU(e){return e.stopPropagation()}function xU(e){return e.stopPropagation()}function SU(e){return e.stopPropagation()}function CU(e){return e.stopPropagation()}function wU(e){return e.preventDefault()}function TU(e){return!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`}var EU=Gn.extend({addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return nr(yU)}});function DU(e){let t=(0,Q.c)(4),{node:n}=e,r=n.attrs.componentName||``;if(!r){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Xr,{as:`span`,"data-jsx-inline":``,children:(0,$.jsx)(Ir,{as:`span`})}),t[0]=e):e=t[0],e}let i;return t[1]!==r||t[2]!==e?(i=(0,$.jsx)(OU,{...e,name:r}),t[1]=r,t[2]=e,t[3]=i):i=t[3],i}function OU(e){let t=(0,Q.c)(73),{node:n,selected:r,editor:i,getPos:o,extension:s,name:c}=e,l=ZS(c),{Component:d}=l,[f,p]=(0,Z.useState)(!1),m=(0,Z.useRef)(!1),{props:h,error:g}=iU(n.attrs,l,!0),_=tU(l.name,h,aU(s.options,i)),v=`${l.name}::${pU(h)}`,y;t[0]!==i||t[1]!==o||t[2]!==p?(y=()=>{let e=()=>{let e=typeof o==`function`?o():void 0,t=i.state.selection,n=t instanceof xe&&typeof e==`number`&&t.from===e;n&&!m.current?p(!0):!n&&m.current&&p(!1),m.current=n};return i.on(`selectionUpdate`,e),e(),()=>{i.off(`selectionUpdate`,e)}},t[0]=i,t[1]=o,t[2]=p,t[3]=y):y=t[3];let b;t[4]!==i||t[5]!==o?(b=[i,o],t[4]=i,t[5]=o,t[6]=b):b=t[6],(0,Z.useEffect)(y,b);let x;if(t[7]!==h){let{children:e,...n}=h;x=n,t[7]=h,t[8]=x}else x=t[8];if(g){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e={[Gy]:`true`},t[9]=e):e=t[9];let r;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`span`,{role:`status`,children:(0,$.jsx)(a,{id:`MzoWIU`})}),t[10]=r):r=t[10];let s;t[11]!==l.name||t[12]!==i||t[13]!==o||t[14]!==n?(s=()=>zH({editor:i,getPos:o,node:n,descriptorName:l.name},`edit-source`)?.pos,t[11]=l.name,t[12]=i,t[13]=o,t[14]=n,t[15]=s):s=t[15];let c;return t[16]!==i||t[17]!==s?(c=(0,$.jsx)(Xr,{as:`span`,"data-jsx-inline":``,"data-jsx-props-error":``,children:(0,$.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1 text-xs text-warning`,contentEditable:!1,...e,children:[r,(0,$.jsx)(JB,{editor:i,getTargetPosition:s})]})}),t[16]=i,t[17]=s,t[18]=c):c=t[18],c}let S=r?`jsx-inline-selected`:void 0,C;t[19]===v?C=t[20]:(C=[v],t[19]=v,t[20]=C);let w;t[21]!==l.name||t[22]!==c?(w=(e,t)=>{let n=e instanceof Error?e:Error(String(e));console.warn(JSON.stringify({event:`jsx-render-failure`,component:l.name===`*`?`wildcard`:l.name,rawComponentName:c.slice(0,200),error:String(n),stack:t.componentStack})),lr(l.name)},t[21]=l.name,t[22]=c,t[23]=w):w=t[23];let T;t[24]===c?T=t[25]:(T=()=>(0,$.jsxs)(`span`,{className:`text-xs font-mono text-destructive`,children:[`[`,c,`]`]}),t[24]=c,t[25]=T);let E;t[26]!==d||t[27]!==_?(E=(0,$.jsx)(d,{..._}),t[26]=d,t[27]=_,t[28]=E):E=t[28];let D;t[29]!==C||t[30]!==w||t[31]!==T||t[32]!==E?(D=(0,$.jsx)(va,{asChild:!0,children:(0,$.jsx)(`span`,{"data-jsx-inline-widget":``,children:(0,$.jsx)(u,{resetKeys:C,onError:w,fallbackRender:T,children:E})})}),t[29]=C,t[30]=w,t[31]=T,t[32]=E,t[33]=D):D=t[33];let O;t[34]!==i.isDestroyed||t[35]!==i.state||t[36]!==i.view||t[37]!==o?(O=e=>{if(e.preventDefault(),i.isDestroyed)return;let t=typeof o==`function`?o():void 0;if(typeof t==`number`){let e=i.state,n=e.doc.nodeAt(t);if(n?.type.name===`jsxInline`){let r=t+n.nodeSize;r<=e.doc.content.size&&i.view.dispatch(e.tr.setSelection(K.create(e.doc,r)))}}i.view.focus()},t[34]=i.isDestroyed,t[35]=i.state,t[36]=i.view,t[37]=o,t[38]=O):O=t[38];let k=l.displayName??c,A;t[39]===k?A=t[40]:(A=(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,$.jsx)(a,{id:`hxnF0I`,values:{0:k}})}),t[39]=k,t[40]=A);let j;t[41]!==l||t[42]!==i.state.doc||t[43]!==i.state.tr||t[44]!==i.view||t[45]!==o?(j=(e,t)=>{let n=typeof o==`function`?o():void 0;if(typeof n!=`number`)return;let r=i.state.doc.nodeAt(n);if(r?.type.name!==`jsxInline`)return;let a=hU(r.attrs);if(!a)return;let s=i.state.tr.setNodeMarkup(n,null,_U(a,l,e,t));s.setSelection(xe.create(s.doc,n)),i.view.dispatch(s)},t[41]=l,t[42]=i.state.doc,t[43]=i.state.tr,t[44]=i.view,t[45]=o,t[46]=j):j=t[46];let M;t[47]===p?M=t[48]:(M=()=>p(!1),t[47]=p,t[48]=M);let N;t[49]!==l||t[50]!==x||t[51]!==j||t[52]!==M?(N=(0,$.jsx)(aH,{descriptor:l,values:x,onChange:j,onDismiss:M}),t[49]=l,t[50]=x,t[51]=j,t[52]=M,t[53]=N):N=t[53];let P;t[54]===p?P=t[55]:(P=()=>p(!1),t[54]=p,t[55]=P);let F;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(a,{id:`DPfwMq`}),t[56]=F):F=t[56];let I;t[57]===P?I=t[58]:(I=(0,$.jsx)(ee,{variant:`secondary`,size:`sm`,className:`mt-2 w-full`,onClick:P,children:F}),t[57]=P,t[58]=I);let L;t[59]!==A||t[60]!==N||t[61]!==I||t[62]!==O?(L=(0,$.jsxs)(ya,{className:`z-[60] w-72 p-3`,side:`bottom`,align:`start`,onOpenAutoFocus:kU,onCloseAutoFocus:O,children:[A,N,I]}),t[59]=A,t[60]=N,t[61]=I,t[62]=O,t[63]=L):L=t[63];let R;t[64]!==f||t[65]!==p||t[66]!==L||t[67]!==D?(R=(0,$.jsxs)(xa,{open:f,onOpenChange:p,children:[D,L]}),t[64]=f,t[65]=p,t[66]=L,t[67]=D,t[68]=R):R=t[68];let te;return t[69]!==c||t[70]!==R||t[71]!==S?(te=(0,$.jsx)(Xr,{as:`span`,"data-jsx-inline":``,"data-component-name":c,contentEditable:!1,className:S,children:R}),t[69]=c,t[70]=R,t[71]=S,t[72]=te):te=t[72],te}function kU(e){e.preventDefault()}var AU=Jn.extend({addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return nr(DU)},addProseMirrorPlugins(){return[new J({props:{handleDOMEvents:{mousedown(e,t){let n=t.target;if(!(n instanceof Element))return!1;let r=n.closest(`[data-jsx-inline][data-component-name]`);if(!r||!e.dom.contains(r)||!r.getAttribute(`data-component-name`))return!1;let i=null;try{let t=e.posAtDOM(r,0);for(let n of[t-1,t]){let t=n>=0?e.state.doc.nodeAt(n):null;if(t?.type.name===`jsxInline`&&t.attrs.componentName){i=n;break}}}catch{return!1}return i===null?!1:(t.preventDefault(),e.dispatch(e.state.tr.setSelection(xe.create(e.state.doc,i))),e.focus(),!0)}}}})]}}),jU={name:`InlineMath`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,category:`content`,description:`Inline math`,props:[{name:`formula`,type:`string`,required:!0,autoFocus:!0,description:`LaTeX inline math source`}]},MU=(0,Z.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-BCLP08X6.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,Q.c)(4),r;n[0]===t.formula?r=n[1]:(r=e.renderToString(t.formula,{displayMode:!1,throwOnError:!1,strict:`ignore`,trust:!1}),n[0]=t.formula,n[1]=r);let i=r,a;return n[2]===i?a=n[3]:(a=(0,$.jsx)(`span`,{className:`math math-inline`,dangerouslySetInnerHTML:{__html:i}}),n[2]=i,n[3]=a),a}return{default:t}});function NU(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`span`,{className:`math math-inline math-placeholder math-placeholder-empty inline-flex items-center gap-1 rounded-sm border border-dashed border-muted-foreground/40 bg-muted/30 px-1.5 py-0.5 text-xs italic text-muted-foreground hover:bg-muted/60 cursor-pointer`,"data-component-type":`math-inline`,children:`f(x)`}),e[0]=t):t=e[0],t}function PU(e){let t=(0,Q.c)(2),n;return t[0]===e.formula?n=t[1]:(n=(0,$.jsx)(`span`,{className:`math math-inline math-placeholder`,"data-component-type":`math-inline`,children:e.formula}),t[0]=e.formula,t[1]=n),n}function FU(e){let t=(0,Q.c)(43),{node:n,selected:r,getPos:i,editor:o}=e,s=typeof n.attrs.formula==`string`?n.attrs.formula:``,c=typeof n.attrs.id==`string`?n.attrs.id:void 0,[l,d]=(0,Z.useState)(!1),f=(0,Z.useRef)(!1),p;t[0]!==o.state||t[1]!==i||t[2]!==r?(p=()=>{let e=r&&o.state.selection instanceof xe;e&&!f.current?(fC(typeof i==`function`?i()??0:0),d(!0)):!e&&f.current&&d(!1),f.current=e},t[0]=o.state,t[1]=i,t[2]=r,t[3]=p):p=t[3];let m;t[4]!==o||t[5]!==i||t[6]!==r?(m=[r,i,o],t[4]=o,t[5]=i,t[6]=r,t[7]=m):m=t[7],(0,Z.useEffect)(p,m);let h=r?`math-inline-selected`:void 0,g;t[8]===c?g=t[9]:(g=c?{id:c}:{},t[8]=c,t[9]=g);let _;t[10]===s?_=t[11]:(_=s?(0,$.jsx)(u,{resetKeys:[s],onError:LU,fallbackRender:()=>(0,$.jsx)(`span`,{className:`math math-inline math-error`,children:s}),children:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(PU,{formula:s}),children:(0,$.jsx)(MU,{formula:s})})}):(0,$.jsx)(NU,{}),t[10]=s,t[11]=_);let v;t[12]!==s||t[13]!==g||t[14]!==_?(v=(0,$.jsx)(va,{asChild:!0,children:(0,$.jsx)(`span`,{className:`math-inline-trigger`,"data-component-type":`math-inline`,"data-formula":s,...g,children:_})}),t[12]=s,t[13]=g,t[14]=_,t[15]=v):v=t[15];let y;t[16]!==o.state||t[17]!==o.view||t[18]!==i?(y=e=>{e.preventDefault();let t=typeof i==`function`?i():void 0;if(typeof t==`number`){let e=o.state,n=e.doc.nodeAt(t);if(n?.type.name===`mathInline`){let r=t+n.nodeSize;r<=e.doc.content.size&&o.view.dispatch(e.tr.setSelection(K.create(e.doc,r)))}}o.view.focus()},t[16]=o.state,t[17]=o.view,t[18]=i,t[19]=y):y=t[19];let b;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,$.jsx)(a,{id:`EOjU5V`})}),t[20]=b):b=t[20];let x;t[21]===s?x=t[22]:(x={formula:s},t[21]=s,t[22]=x);let S;t[23]!==o.state||t[24]!==o.view||t[25]!==i?(S=(e,t)=>{let n=typeof i==`function`?i():void 0;if(typeof n!=`number`)return;let r=o.state.doc.nodeAt(n);if(r?.type.name!==`mathInline`)return;let a=o.state.tr.setNodeMarkup(n,null,{...r.attrs,[e]:t??``});a.setSelection(xe.create(a.doc,n)),o.view.dispatch(a)},t[23]=o.state,t[24]=o.view,t[25]=i,t[26]=S):S=t[26];let C;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>d(!1),t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==x?(w=(0,$.jsx)(aH,{descriptor:jU,values:x,onChange:S,onDismiss:C}),t[28]=S,t[29]=x,t[30]=w):w=t[30];let T;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>d(!1),t[31]=T):T=t[31];let E;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-border pt-2`,children:(0,$.jsx)(ee,{type:`button`,size:`sm`,variant:`ghost`,onClick:T,className:`h-7 px-3 text-xs`,children:(0,$.jsx)(a,{id:`DPfwMq`})})}),t[32]=E):E=t[32];let D;t[33]!==w||t[34]!==y?(D=(0,$.jsxs)(ya,{className:`z-[60] w-72 p-3`,side:`bottom`,align:`start`,onOpenAutoFocus:IU,onCloseAutoFocus:y,children:[b,w,E]}),t[33]=w,t[34]=y,t[35]=D):D=t[35];let O;t[36]!==l||t[37]!==D||t[38]!==v?(O=(0,$.jsxs)(xa,{open:l,onOpenChange:d,children:[v,D]}),t[36]=l,t[37]=D,t[38]=v,t[39]=O):O=t[39];let k;return t[40]!==O||t[41]!==h?(k=(0,$.jsx)(Xr,{as:`span`,className:h,children:O}),t[40]=O,t[41]=h,t[42]=k):k=t[42],k}function IU(e){e.preventDefault()}function LU(e,t){let n=e instanceof Error?e:Error(String(e));console.warn(JSON.stringify({event:`jsx-render-failure`,component:`mathInline`,rawComponentName:`mathInline`,error:String(n),stack:t.componentStack})),lr(`mathInline`)}var RU=mn.extend({addNodeView(){return nr(FU)}});function zU(e,t){if(!e.selection.empty)return null;let n=t===`up`||t===`left`?-1:1,r=e.selection.$head,i=n>0?r.after():r.before();if(typeof i!=`number`)return null;let a=ve.near(e.doc.resolve(i),n);return a.$head?.parent.type.name===`rawMdxFallback`?a:null}function BU(e,t){let{state:n,view:r}=e;if(!r.endOfTextblock(t))return!1;let i=zU(n,t);return i?(r.dispatch(n.tr.setSelection(i)),!0):!1}var VU=on.extend({addKeyboardShortcuts(){return{ArrowLeft:({editor:e})=>BU(e,`left`),ArrowRight:({editor:e})=>BU(e,`right`),ArrowUp:({editor:e})=>BU(e,`up`),ArrowDown:({editor:e})=>BU(e,`down`)}},addNodeView(){return nr(qr,{stopEvent:()=>!0,ignoreMutation:()=>!0})}});function HU({editor:e,item:t,range:n}){let r=[],i;try{e.chain().focus().deleteRange(n).command(n=>{try{t.command({editor:e,chain:n.chain,state:n.state,afterCommit:e=>r.push(e)})}catch(e){i=e}return!0}).run()}catch(e){console.error(`[slash-command] deleteRange failed for "${t.name}"`,e),i!==void 0&&console.error(`[slash-command] command "${t.name}" threw an error`,i);return}i!==void 0&&console.error(`[slash-command] command "${t.name}" threw an error`,i);for(let e of r)try{e()}catch(e){console.error(`[slash-command] afterCommit callback for "${t.name}" threw an error`,e)}}function UU(e){return e.category===`skills`?e.description:void 0}function WU(e){let t=e.preview?.description??UU(e);return t===void 0?``:`. ${t}`}function GU(e){let t=(0,Q.c)(53),{items:n,selectedIndex:r,categoryLabels:i,onSelect:s,onHoverIndex:c}=e,l=(0,Z.useRef)(null),u=(0,Z.useId)(),{_:d}=o(),f=r>=0&&r<n.length?`${u}-option-${r}`:void 0,p=qU,m,h;if(t[0]===r?(m=t[1],h=t[2]):(m=()=>{let e=l.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(r);t&&t.scrollIntoView({block:`nearest`})},h=[r],t[0]=r,t[1]=m,t[2]=h),(0,Z.useEffect)(m,h),n.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[3]=e):e=t[3];let n;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{ref:l,role:`status`,"aria-live":`polite`,className:`w-56 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:e,onMouseDown:p,children:(0,$.jsx)(a,{id:`Ev2r9A`})}),t[4]=n):n=t[4],n}let g,_,v,y,b,x,S,C,w,T,E,D,O;if(t[5]!==d||t[6]!==f||t[7]!==i||t[8]!==n||t[9]!==u||t[10]!==c||t[11]!==s||t[12]!==r){let e=[],a=0,o=new Map;for(let t of n){o.set(t,a++);let n=e.find(e=>e.key===t.category);n?n.items.push(t):e.push({key:t.category,items:[t]})}_=r>=0&&r<n.length?n[r]:null;let m;t[26]===n?m=t[27]:(m=n.some(KU),t[26]=n,t[27]=m),g=m,x=`flex items-start gap-2`,S=l,C=`listbox`,t[28]===d?w=t[29]:(w=d({id:`RlCInP`}),t[28]=d,t[29]=w),T=f,E=-1,D=p,O=`w-56 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(v={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[30]=v):v=t[30];let h;t[31]===_?h=t[32]:(h=_?`${_.label}${WU(_)}`:``,t[31]=_,t[32]=h),t[33]===h?y=t[34]:(y=(0,$.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:h}),t[33]=h,t[34]=y),b=e.map(e=>(0,$.jsxs)(`div`,{role:`group`,"aria-labelledby":`${u}-group-${e.key}`,children:[(0,$.jsx)(`div`,{id:`${u}-group-${e.key}`,className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground`,children:i[e.key]??e.key}),e.items.map(e=>{let t=o.get(e)??0,n=t===r,i=e.icon;return(0,$.jsxs)(`button`,{id:`${u}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseEnter:()=>c?.(t),onMouseDown:t=>{t.preventDefault(),s(e)},children:[(0,$.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.label}),UU(e)===void 0?null:(0,$.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:UU(e)})]})]},e.name)})]},e.key)),t[5]=d,t[6]=f,t[7]=i,t[8]=n,t[9]=u,t[10]=c,t[11]=s,t[12]=r,t[13]=g,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S,t[20]=C,t[21]=w,t[22]=T,t[23]=E,t[24]=D,t[25]=O}else g=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18],S=t[19],C=t[20],w=t[21],T=t[22],E=t[23],D=t[24],O=t[25];let k;t[35]!==v||t[36]!==y||t[37]!==b||t[38]!==S||t[39]!==C||t[40]!==w||t[41]!==T||t[42]!==E||t[43]!==D||t[44]!==O?(k=(0,$.jsxs)(`div`,{ref:S,role:C,"aria-label":w,"aria-activedescendant":T,tabIndex:E,onMouseDown:D,className:O,style:v,children:[y,b]}),t[35]=v,t[36]=y,t[37]=b,t[38]=S,t[39]=C,t[40]=w,t[41]=T,t[42]=E,t[43]=D,t[44]=O,t[45]=k):k=t[45];let A;t[46]!==g||t[47]!==_?(A=g?(0,$.jsx)(`aside`,{"aria-hidden":`true`,onMouseDown:p,className:`ok-suggestion-preview w-64 rounded-lg border bg-popover p-2 shadow-md ${_?.preview?``:`invisible`}`,children:_?.preview?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mb-2 flex aspect-5/3 items-center justify-center overflow-hidden rounded-md bg-muted/40 p-3 *:max-h-full *:max-w-full [&_img]:size-full [&_img]:rounded-md [&_img]:object-contain`,children:_.preview.render()}),(0,$.jsx)(`p`,{className:`line-clamp-3 px-1 pb-1 text-xs text-muted-foreground`,children:_.preview.description})]}):null}):null,t[46]=g,t[47]=_,t[48]=A):A=t[48];let j;return t[49]!==x||t[50]!==k||t[51]!==A?(j=(0,$.jsxs)(`div`,{className:x,children:[k,A]}),t[49]=x,t[50]=k,t[51]=A,t[52]=j):j=t[52],j}function KU(e){return e.preview}function qU(e){return e.preventDefault()}var JU=new G(`slashCommand`);function YU(e){let{sources:t,categoryOrder:n,query:r,state:i,editor:a}=e,o=t.flatMap(e=>{try{return e(a===void 0?void 0:{editor:a})}catch(e){return console.error(`[slash-command] item source threw an error`,e),[]}}),s=e=>{let t=n.indexOf(e);return t===-1?1/0:t},c=o.map((e,t)=>({item:e,i:t})).sort((e,t)=>{let n=s(e.item.category)-s(t.item.category);return n===0?e.i-t.i:n}).map(e=>e.item);return kC(kw(i)?c.filter(e=>!e.insertsBlockComponent):c,r)}var XU=_e.create({name:`slashCommand`,addOptions(){return{itemsSources:[OC],categoryLabels:{basic:`Basic blocks`,insert:`Insert`}}},addProseMirrorPlugins(){let e=this;return[hn({editor:this.editor,pluginKey:JU,char:`/`,startOfLine:!1,allowedPrefixes:[..._n],findSuggestionMatch:tn(Cr),allow:Tr,items:({query:t,editor:n})=>YU({sources:e.options.itemsSources,categoryOrder:[...new Set([`skills`,`basic`,`insert`,...Object.keys(e.options.categoryLabels)])],query:t,state:n.state,editor:n}),command:({editor:e,range:t,props:n})=>HU({editor:e,item:n,range:t}),render:()=>{let t=null,n=null,r=0,i={popup:null,stopAutoUpdate:null},a=null,o=e=>{e!==r&&(r=e,s())},s=()=>{!t||!n||t.updateProps({items:n.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:n.command,onHoverIndex:o})};return{onStart(s){n=s,r=0;let c=Br(()=>n,`slash-command`,{clipToEditorPane:!0});i.popup=c.popup,a=c.doPosition,t=new zr(GU,{props:{items:s.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:s.command,onHoverIndex:o},editor:s.editor}),c.popup.appendChild(t.element),i.stopAutoUpdate=c.startAutoUpdate(),c.reveal()},onUpdate(e){n=e,r=Math.min(r,Math.max(0,e.items.length-1)),s(),a?.()},onKeyDown({event:e}){if(!n||n.items.length===0)return!1;let t=n.items;if(e.key===`ArrowDown`)return r=(r+1)%t.length,s(),!0;if(e.key===`ArrowUp`)return r=(r-1+t.length)%t.length,s(),!0;if(e.key===`Enter`||e.key===`Tab`){let e=t[r];return e&&n.command(e),!0}return e.key,!1},onExit(){Ar(i),a=null,t?.destroy(),t=null,n=null,r=0}}}})]}}),ZU=new G(`sourceDirty`),QU=_e.create({name:`sourceDirtyObserver`,addProseMirrorPlugins(){return[new J({key:ZU,appendTransaction(e,t,n){if(!e.some(e=>e.docChanged&&vn(e)))return null;let r=new Ce;for(let t of e)r.appendMapping(t.mapping);let i=r.invert(),a=[];if(n.doc.descendants((e,n)=>{if(e.type.name!==`jsxComponent`||e.attrs.sourceDirty)return;let r=i.map(n),o=t.doc.nodeAt(r),s=o?.type.name!==`jsxComponent`,c=typeof e.attrs.sourceRaw==`string`&&e.attrs.sourceRaw.length>0;if(s&&c)return;if(!o){(e.content.size>0||Object.keys(e.attrs.props??{}).length>0)&&a.push({pos:n});return}if(o.type.name!==`jsxComponent`){a.push({pos:n});return}let l=!$U(o.attrs.props,e.attrs.props),u=!o.content.eq(e.content);(l||u)&&a.push({pos:n})}),a.length===0)return null;let o=n.tr;for(let{pos:e}of a)o.setNodeAttribute(e,`sourceDirty`,!0);return o}})]}});function $U(e,t){if(Object.is(e,t))return!0;if(e==null||t==null||typeof e!=typeof t||typeof e!=`object`)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!$U(e[n],t[n]))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!$U(e[r],t[r]))return!1;return!0}var eW=_e.create({name:`tabFocusTrap`,priority:1,addKeyboardShortcuts(){return{Tab:()=>!0,"Shift-Tab":()=>!0}}});function tW(e,t){let n=e.doc.nodeAt(t);if(n?.type.name!==`table`)return null;let r=Tn.get(n);return{map:r,tableStart:t+1,table:n,left:0,top:0,right:r.width,bottom:r.height}}function nW(e,t){let n=tW(e,t);return n?nn(e.tr,n,n.map.width):null}function rW(e,t){let n=tW(e,t);return n?ln(e.tr,n,n.map.height):null}function iW(e,t){if(!e.dom.contains(t))return null;let n;try{n=e.posAtDOM(t,0)}catch{return null}return n<0?null:jn(e.state.doc.resolve(n))?.pos??null}var aW=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="M12 5v14"/></svg>`;function oW(e,t){let n=document.createElement(`button`);return n.type=`button`,n.className=`ok-table-insert-bar ok-table-insert-${e}`,n.setAttribute(`aria-label`,t),n.tabIndex=-1,n.setAttribute(Gy,`true`),n.innerHTML=aW,n.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation()}),n}var sW=class{overlays=new Map;mount;lastEditable;view;editor;resizeObserver;positionFrame=null;constructor(e,t){this.view=e,this.editor=t,this.mount=e.dom.parentElement??e.dom,this.lastEditable=t.isEditable,this.resizeObserver=typeof ResizeObserver>`u`?null:new ResizeObserver(()=>this.positionAll()),this.resizeObserver?.observe(e.dom),this.reconcile()}update(e,t){let n=this.editor.isEditable!==this.lastEditable;this.lastEditable=this.editor.isEditable,!(!n&&t.doc.eq(this.view.state.doc))&&(this.reconcile(),this.schedulePositionAll())}destroy(){this.removeAllOverlays(),this.resizeObserver?.disconnect(),this.positionFrame!=null&&cancelAnimationFrame(this.positionFrame),this.positionFrame=null}schedulePositionAll(){this.positionFrame!=null||this.overlays.size===0||(this.positionFrame=requestAnimationFrame(()=>{this.positionFrame=null,this.positionAll()}))}positionAll(){let e=Array.from(this.overlays,([e,t])=>{let n=e.getBoundingClientRect(),r=t.container.getBoundingClientRect();return{overlay:t,left:n.left-r.left,top:n.top-r.top,width:n.width,height:n.height}});for(let{overlay:t,left:n,top:r,width:i,height:a}of e){let e=`${n}|${r}|${i}|${a}`;t.placement!==e&&(t.placement=e,Object.assign(t.colBar.style,{left:`${n+i}px`,top:`${r}px`,height:`${a}px`}),Object.assign(t.rowBar.style,{left:`${n}px`,top:`${r+a}px`,width:`${i}px`}))}}reconcile(){if(!this.editor.isEditable){this.removeAllOverlays();return}let e=new Set(this.view.dom.querySelectorAll(`.tableWrapper`));for(let t of this.overlays.keys())e.has(t)||this.removeOverlay(t);for(let t of e)this.overlays.has(t)||this.addOverlay(t)}addOverlay(e){let t=document.createElement(`div`);t.className=`ok-table-insert-controls`,t.setAttribute(Gy,`true`);let n=oW(`column`,`Add column`),r=oW(`row`,`Add row`);n.addEventListener(`click`,()=>this.insert(e,nW)),r.addEventListener(`click`,()=>this.insert(e,rW)),t.append(n,r),this.mount.appendChild(t);let i=e=>{let t=e.target instanceof Element?e.target.closest(`td, th`):null,i=t?.parentElement;n.classList.toggle(`is-active`,!!t&&t===i?.lastElementChild),r.classList.toggle(`is-active`,!!i&&i===i.parentElement?.lastElementChild)},a=()=>{n.classList.remove(`is-active`),r.classList.remove(`is-active`)};e.addEventListener(`pointerover`,i),e.addEventListener(`pointerleave`,a),this.resizeObserver?.observe(e),this.overlays.set(e,{container:t,colBar:n,rowBar:r,placement:``,cleanup:()=>{this.resizeObserver?.unobserve(e),e.removeEventListener(`pointerover`,i),e.removeEventListener(`pointerleave`,a),t.remove()}})}removeAllOverlays(){for(let e of this.overlays.keys())this.removeOverlay(e)}removeOverlay(e){let t=this.overlays.get(e);t&&(t.cleanup(),this.overlays.delete(e))}insert(e,t){let n=e.querySelector(`table`);if(!n)return;let r=iW(this.view,n);if(r===null)return;let i=t(this.view.state,r);i&&(this.view.dispatch(i),this.view.focus())}},cW=_e.create({name:`tableInsertControls`,addProseMirrorPlugins(){let e=this.editor;return[new J({key:new G(`tableInsertControls`),view:t=>new sW(t,e)})]}});function lW(e){let{selection:t}=e;if(!(t instanceof K))return null;let n=gn(t.$from);if(!n)return null;let r=n.node(-1),i=n.start(-1),a=Tn.get(r),o=a.findCell(n.pos-i);if(o.bottom===a.height){let t=ln(e.tr,{map:a,tableStart:i,table:r,left:0,top:0,right:a.width,bottom:a.height},a.height),n=t.doc.nodeAt(i-1);if(!n)return null;let s=i+Tn.get(n).positionAt(a.height,o.left,n);return t.setSelection(K.near(t.doc.resolve(s+1))),t.scrollIntoView()}let s=a.positionAt(o.bottom,o.left,r),c=r.nodeAt(s);if(!c)return null;let l=i+s,u=e.tr;return u.setSelection(K.near(u.doc.resolve(l+c.nodeSize-1),-1)),u.scrollIntoView()}var uW=_e.create({name:`tableRowEnter`,addKeyboardShortcuts(){return{Enter:({editor:e})=>{let t=lW(e.state);return t?(e.view.dispatch(t),!0):!1}}}}),dW=`ok:tag-click`;function fW(e){if(typeof document>`u`)return;let t={value:e};document.dispatchEvent(new CustomEvent(dW,{detail:t}))}function pW(e){return e instanceof Element?e.closest(`a[data-tag]`):null}var mW=_e.create({name:`tagClick`,addProseMirrorPlugins(){return[new J({props:{handleDOMEvents:{click(e,t){let n=pW(t.target);if(!n)return!1;let r=n.getAttribute(`data-tag`);return r?(t.preventDefault(),t.stopPropagation(),fW(r),!0):!1}}}})]}});function hW(e,t,n){if(typeof t!=`number`||!n||!Fo.test(n))return!1;let{state:r,view:i}=e,a=r.doc.nodeAt(t);if(a?.type.name!==`tag`)return!1;let o=r.tr.setNodeMarkup(t,null,{...a.attrs,value:n}),s=t+a.nodeSize;return o.insertText(` `,s),o.setSelection(K.create(o.doc,s+1)),i.dispatch(o),i.focus(),!0}function gW(e,t){if(typeof t!=`number`)return;let{state:n,view:r}=e,i=n.doc.nodeAt(t);if(i?.type.name!==`tag`)return;let a=n.tr.delete(t,t+i.nodeSize);r.dispatch(a),r.focus()}function _W(e){let t=(0,Q.c)(3),{value:n}=e,r=`#tag/${n}`,i;return t[0]!==r||t[1]!==n?(i=(0,$.jsxs)(`a`,{className:`tag`,"data-tag":n,href:r,children:[`#`,n]}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function vW(e){let t=(0,Q.c)(22),{initialDraft:n,onCommit:r,onCancel:i}=e,{_:a}=o(),s=(0,Z.useRef)(null),[c,l]=(0,Z.useState)(n),u=(0,Z.useRef)(n),d=(0,Z.useRef)(!1),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>e!==``&&!Fo.test(e)?!1:(u.current=e,l(e),!0),t[0]=f):f=t[0];let p=f,m,h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{let e=requestAnimationFrame(()=>{s.current?.focus()});return()=>cancelAnimationFrame(e)},h=[],t[1]=m,t[2]=h):(m=t[1],h=t[2]),(0,Z.useEffect)(m,h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono`,children:`#`}),t[3]=g):g=t[3];let _=Math.max(c.length,8),v;t[4]===a?v=t[5]:(v=a({id:`U2pMtf`}),t[4]=a,t[5]=v);let y;t[6]===a?y=t[7]:(y=a({id:`knjOzA`}),t[6]=a,t[7]=y);let b,x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{let t=e.target.value;if(e.nativeEvent.isComposing){l(t);return}p(t)},x=e=>{p(e.currentTarget.value)||l(u.current)},t[8]=b,t[9]=x):(b=t[8],x=t[9]);let S,C;t[10]!==c||t[11]!==i||t[12]!==r?(S=e=>{Bt(e)||(e.key===`Enter`||e.key===` `?(e.preventDefault(),d.current=!0,r(c)||(d.current=!1,i())):(e.key===`Escape`||e.key===`Backspace`&&c===``)&&(e.preventDefault(),i()))},C=()=>{if(!d.current){if(c===``){i();return}Fo.test(c)?r(c):i()}},t[10]=c,t[11]=i,t[12]=r,t[13]=S,t[14]=C):(S=t[13],C=t[14]);let w;return t[15]!==c||t[16]!==S||t[17]!==C||t[18]!==_||t[19]!==v||t[20]!==y?(w=(0,$.jsxs)(`span`,{className:`tag tag-placeholder inline-flex items-center rounded-sm border border-dashed border-muted-foreground/40 bg-muted/30 px-1.5 py-0.5 text-xs text-muted-foreground`,"data-component-type":`tag-placeholder`,children:[g,(0,$.jsx)(`input`,{ref:s,type:`text`,value:c,size:_,placeholder:v,"aria-label":y,spellCheck:!1,autoCorrect:`off`,autoCapitalize:`off`,className:`bg-transparent border-0 p-0 outline-none focus:outline-none focus:ring-0 text-inherit font-inherit`,onChange:b,onCompositionEnd:x,onKeyDown:S,onBlur:C})]}),t[15]=c,t[16]=S,t[17]=C,t[18]=_,t[19]=v,t[20]=y,t[21]=w):w=t[21],w}function yW(e){let t=(0,Q.c)(5),{node:n,getPos:r,editor:i}=e,a=typeof n.attrs.value==`string`?n.attrs.value:``;if(a===``){let e;return t[0]!==i||t[1]!==r?(e=(0,$.jsx)(Xr,{as:`span`,children:(0,$.jsx)(vW,{initialDraft:``,onCommit:e=>hW(i,typeof r==`function`?r():void 0,e),onCancel:()=>gW(i,typeof r==`function`?r():void 0)})}),t[0]=i,t[1]=r,t[2]=e):e=t[2],e}let o;return t[3]===a?o=t[4]:(o=(0,$.jsx)(Xr,{as:`span`,children:(0,$.jsx)(_W,{value:a})}),t[3]=a,t[4]=o),o}function bW(e){return e.kind===`create`?`create:${e.value}`:`tag:${e.value}`}function xW(e){if(e.kind===`create`){let t=e.value;return Y._({id:`XPqe3B`,values:{tagValue:t}})}let t=Y._({id:`pckX1A`,values:{0:e.count}}),n=e.value;return Y._({id:`m2T1Xj`,values:{tagValue:n,uses:t}})}function SW(e){let t=(0,Q.c)(38),{items:n,query:r,selectedIndex:i,onSelect:s,onHover:c,loading:l,error:u}=e,d=l===void 0?!1:l,f=u===void 0?null:u,{_:p}=o(),m=(0,Z.useRef)(null),h=(0,Z.useId)(),g=i>=0&&i<n.length?`${h}-option-${i}`:void 0,_,v;t[0]===i?(_=t[1],v=t[2]):(_=()=>{let e=m.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(i);t&&t.scrollIntoView({block:`nearest`})},v=[i],t[0]=i,t[1]=_,t[2]=v),(0,Z.useEffect)(_,v);let y=CW;if(d){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[3]=e):e=t[3];let n;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{ref:m,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:e,onMouseDown:y,children:(0,$.jsx)(a,{id:`a_u4ck`})}),t[4]=n):n=t[4],n}if(n.length===0){let e;if(t[5]!==p||t[6]!==f||t[7]!==r){let n=r.trim();e=f??p(n?{id:`9R7pRC`,values:{trimmed:n}}:{id:`KRJ6xh`}),t[5]=p,t[6]=f,t[7]=r,t[8]=e}else e=t[8];let n=e,i;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(i={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[9]=i):i=t[9];let a;return t[10]===n?a=t[11]:(a=(0,$.jsx)(`div`,{ref:m,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:i,onMouseDown:y,children:n}),t[10]=n,t[11]=a),a}let b=i>=0&&i<n.length?n[i]:null,x;t[12]===p?x=t[13]:(x=p({id:`SCoBBH`}),t[12]=p,t[13]=x);let S;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(S={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[14]=S):S=t[14];let C;t[15]===b?C=t[16]:(C=b?xW(b):``,t[15]=b,t[16]=C);let w;t[17]===C?w=t[18]:(w=(0,$.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:C}),t[17]=C,t[18]=w);let T;t[19]===f?T=t[20]:(T=f&&(0,$.jsx)(`div`,{className:`rounded-md px-2 py-1.5 text-xs text-warning`,children:f}),t[19]=f,t[20]=T);let E;if(t[21]!==n||t[22]!==h||t[23]!==c||t[24]!==s||t[25]!==i){let e;t[27]!==h||t[28]!==c||t[29]!==s||t[30]!==i?(e=(e,t)=>{let n=t===i,r=bW(e),o=e.kind===`create`;return(0,$.jsxs)(`button`,{id:`${h}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,"data-testid":o?`tag-suggestion-create`:`tag-suggestion-tag-${e.value}`,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),s(e)},onPointerMove:c?()=>c(t):void 0,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-xs text-muted-foreground`,children:`#`}),(0,$.jsx)(`span`,{className:`truncate font-medium flex-1`,children:e.value}),o?(0,$.jsx)(`span`,{className:`shrink-0 rounded-sm bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary`,children:(0,$.jsx)(a,{id:`isRobC`})}):(0,$.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground tabular-nums`,children:e.count})]},r)},t[27]=h,t[28]=c,t[29]=s,t[30]=i,t[31]=e):e=t[31],E=n.map(e),t[21]=n,t[22]=h,t[23]=c,t[24]=s,t[25]=i,t[26]=E}else E=t[26];let D;return t[32]!==g||t[33]!==E||t[34]!==x||t[35]!==w||t[36]!==T?(D=(0,$.jsxs)(`div`,{ref:m,role:`listbox`,"aria-label":x,"aria-activedescendant":g,tabIndex:-1,onMouseDown:y,className:`w-64 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,style:S,children:[w,T,E]}),t[32]=g,t[33]=E,t[34]=x,t[35]=w,t[36]=T,t[37]=D):D=t[37],D}function CW(e){return e.preventDefault()}var wW=new G(`tagSuggestion`),TW=8,EW=RegExp(`(^|[\\s])#(${Ro})?$`,`u`);async function DW(){let e=await fetch(`/api/tags`);if(!e.ok)throw Error(`/api/tags responded with ${e.status}`);let t=await e.json();return Array.isArray(t.tags)?t.tags:[]}function OW(e,t){let n=t.trim(),r=n.toLowerCase(),i=n===``?e.slice():e.filter(e=>e.name.toLowerCase().includes(r));return i.sort((e,t)=>{let n=+!e.name.toLowerCase().startsWith(r),i=+!t.name.toLowerCase().startsWith(r);return n===i?t.count===e.count?e.name.localeCompare(t.name):t.count-e.count:n-i}),i}function kW(e,t){let n=OW(e,t).slice(0,TW).map(e=>({kind:`tag`,value:e.name,count:e.count,isLeaf:e.isLeaf})),r=t.trim();return r&&Fo.test(r)&&!e.some(e=>e.name===r)&&n.push({kind:`create`,value:r}),n}function AW(e){let{$position:t}=e,n=t.parent.textBetween(0,t.parentOffset,void 0,``).match(EW);if(!n)return null;let r=n[2]??``,i=t.start(),a=n[1].length;return{range:{from:i+((n.index??0)+a),to:t.pos},query:r,text:`#${r}`}}function jW(e){let t=[],n=!1,r=null,i=null;return hn({editor:e,pluginKey:wW,char:`#`,allowedPrefixes:null,findSuggestionMatch:AW,allow:Tr,items:async({query:e})=>{if(!n){r||=DW();try{t=await r,i=null}catch(e){console.error(`[tag-suggestion] Failed to fetch tags:`,e),i=`Failed to load tags. Press Escape and type # again to retry, or continue typing to create a new tag.`,t=[]}finally{n=!0,r=null}}return kW(t,e)},command:({editor:e,range:t,props:n})=>{try{let r=n.value;if(!r||!Fo.test(r))return;e.chain().focus().deleteRange(t).insertContent({type:`tag`,attrs:{value:r}}).insertContent(` `).run()}catch(e){console.error(`[tag-suggestion] command failed`,{item:n,range:t},e)}},render:()=>{let e=null,a=null,o=0,s={popup:null,stopAutoUpdate:null},c=null,l=null,u=e=>{a?.command(e)},d=e=>{o!==e&&(o=e,p(null))};function f(e,t,r){let a=t===null?!n:t;return{items:e.items,query:e.query??``,selectedIndex:o,onSelect:r,onHover:d,loading:a,error:i}}let p=t=>{!e||!a||e.updateProps(f(a,t,u))};return{onBeforeStart(t){a=t,o=0;let n=Br(()=>a,`tag-suggestion`,{clipToEditorPane:!0});s.popup=n.popup,c=n.doPosition,l=n.reveal,e=new zr(SW,{props:f(t,!0,u),editor:t.editor}),n.popup.appendChild(e.element),s.stopAutoUpdate=n.startAutoUpdate()},onStart(e){a=e,o=0,p(null),l?.()},onUpdate(e){a=e,o=Math.min(o,Math.max(0,e.items.length-1)),p(null),c?.()},onKeyDown({event:e}){if(!a)return!1;let t=a.items;if(e.key===`ArrowDown`)return t.length===0?!1:(o=(o+1)%t.length,p(null),!0);if(e.key===`ArrowUp`)return t.length===0?!1:(o=(o-1+t.length)%t.length,p(null),!0);if(e.key===`Enter`||e.key===`Tab`){let e=t[o];if(e)return a.command(e),!0;let n=(a.query??``).trim();return n&&Fo.test(n)?(a.command({kind:`create`,value:n}),!0):!1}return e.key,!1},onExit(){Ar(s),c=null,l=null,e?.destroy(),e=null,a=null,o=0,t=[],i=null,n=!1,r=null}}}})}var MW=Un.extend({priority:200,addNodeView(){return nr(yW)},addKeyboardShortcuts(){return{Backspace:()=>{if(wW.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeBefore;if(t?.type.name===`tag`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from-t.nodeSize,e.from)),!0}return!1},Delete:()=>{if(wW.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeAfter;if(t?.type.name===`tag`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from,e.from+t.nodeSize)),!0}return!1}}},addProseMirrorPlugins(){return[jW(this.editor)]}}),NW=`ok-trailing-affordance`,PW=new G(`trailingAffordance`);function FW(e){let t=e.lastChild;return t!=null&&t.type.name!==`paragraph`}function IW(e){let{doc:t}=e.state,n=t.lastChild;if(!n)return null;let r=e.nodeDOM(t.content.size-n.nodeSize);if(!(r instanceof HTMLElement))return null;let i=r.getBoundingClientRect();return i.height===0&&i.top===0?null:i.bottom}function LW(e){let t=Number.parseFloat(getComputedStyle(e.dom).getPropertyValue(Mn));return Number.isFinite(t)?t:0}function RW(e,t){if(!e.editable||!FW(e.state.doc))return!1;let n=t.target;if(n instanceof Element&&n.closest(`.ok-trailing-affordance`))return!0;let r=IW(e);if(r==null)return!1;let i=e.dom.getBoundingClientRect(),a=i.bottom-LW(e);return t.clientY>r&&t.clientY<=a&&t.clientX>=i.left&&t.clientX<=i.right}function zW(e){MH(e,e.state.doc.content.size)&&e.focus()}function BW(){let e=document.createElement(`div`);e.className=NW,e.setAttribute(Gy,`true`),e.setAttribute(`contenteditable`,`false`),e.setAttribute(`aria-hidden`,`true`);let t=document.createElement(`span`);return t.className=`${NW}-plus`,t.innerHTML=sL,e.append(t),e}function VW(e,t){PW.getState(e.state)!==t&&e.dispatch(e.state.tr.setMeta(PW,t).setMeta(`addToHistory`,!1))}var HW=4;function UW(){return typeof window>`u`?null:window.matchMedia?.(`(pointer: coarse)`)??null}function WW(){let e=null,t=UW();function n(n,r){let i=e;return!i||i.id!==r.pointerId||(e=null,Math.abs(r.clientX-i.x)>HW||Math.abs(r.clientY-i.y)>HW)||!n.state.selection.empty||!RW(n,r)?!1:(r.preventDefault(),zW(n),VW(n,n.editable&&t?.matches===!0),!0)}return new J({key:PW,state:{init:()=>!1,apply(e,t){let n=e.getMeta(PW);return typeof n==`boolean`?n:t}},view(e){let n=()=>VW(e,e.editable&&t?.matches===!0),r=e.editable;return queueMicrotask(()=>{e.isDestroyed||n()}),t?.addEventListener(`change`,n),{update(e){e.editable!==r&&(r=e.editable,n())},destroy(){t?.removeEventListener(`change`,n)}}},props:{decorations(e){return PW.getState(e)!==!0||!FW(e.doc)?null:U.create(e.doc,[W.widget(e.doc.content.size,BW,{side:1})])},handleDOMEvents:{mousemove(e,n){return t?.matches||VW(e,RW(e,n)),!1},mouseleave(e){return t?.matches||VW(e,!1),!1},pointerdown(t,n){let r=n;return e&&e.id!==r.pointerId||(e=null,r.button!==0||r.ctrlKey)||!RW(t,r)||(e={id:r.pointerId,x:r.clientX,y:r.clientY}),!1},pointerup(e,t){return n(e,t)},pointercancel(t,n){let r=n;return e?.id===r.pointerId&&(e=null),!1}}}})}var GW=_e.create({name:`trailingAffordance`,addProseMirrorPlugins(){return[WW()]}}),KW=2048,qW=24;function JW(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim();if(t===``||t.length>KW)return{kind:`unsupported`,value:``};if(eG(t))return{kind:`emoji`,value:t};let n=tG(t);return n===`url`?{kind:`url`,value:t}:n===`path`?{kind:`path`,value:Lo(`/api/asset?path=${encodeURIComponent($W(t))}`)}:{kind:`unsupported`,value:``}}function YW(e){return QW(e.banner).kind===`unsupported`?QW(e.cover).kind===`unsupported`?null:`cover`:`banner`}function XW(e){if(typeof e==`string`&&e.trim()===``)return null;let t=typeof e==`number`?e:typeof e==`string`?Number(e):NaN;return Number.isFinite(t)?t<0?0:t>1?1:t:null}function ZW(e){return e===null?`center`:`center ${Math.round(e*100)}%`}function QW(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim(),n=zn(t),r=n?n.target:t;if(r===``||r.length>KW)return{kind:`unsupported`,value:``};let i=tG(r);return i===`url`?{kind:`url`,value:r}:i===`path`?{kind:`path`,value:Lo(`/api/asset?path=${encodeURIComponent($W(r))}`)}:{kind:`unsupported`,value:``}}function $W(e){return e.startsWith(`/`)?e.slice(1):e}function eG(e){if(/\p{L}/u.test(e)||e.includes(`/`))return!1;let t=0;for(let n of e)t++;if(t>qW)return!1;let n=e.lastIndexOf(`.`);if(n>-1){let t=e.slice(n+1).toLowerCase();if(te.has(t))return!1}return!0}function tG(e){let t=nG(e);if(!t||!te.has(t))return`unsupported`;let n=e.indexOf(`:`),r=e.indexOf(`/`);return n>-1&&(r===-1||n<r)?Yi(e)?`url`:`unsupported`:e.startsWith(`//`)||e.includes(`?`)||e.includes(`#`)||e.startsWith(`../`)||e.includes(`/../`)?`unsupported`:`path`}function nG(e){let t=e.lastIndexOf(`/`),n=t>-1?e.slice(t+1):e,r=n.search(/[?#]/),i=r>-1?n.slice(0,r):n,a=i.lastIndexOf(`.`);return a<=0||a===i.length-1?null:i.slice(a+1).toLowerCase()}function rG(e){let t=(0,Q.c)(133),{open:n,target:r,alias:i,anchor:s,pages:c,assetPaths:l,filePaths:u,loading:f,onOpenChange:p,onSave:m}=e,[h,g]=(0,Z.useState)(r),[_,v]=(0,Z.useState)(i??``),[y,b]=(0,Z.useState)(s??``),x=(0,Z.useId)(),S=(0,Z.useId)(),C=(0,Z.useId)(),w=(0,Z.useId)(),{_:T}=o(),E;t[0]!==l||t[1]!==h||t[2]!==u?(E=ro(h,l,u),t[0]=l,t[1]=h,t[2]=u,t[3]=E):E=t[3];let D=E,O;t[4]!==l||t[5]!==h||t[6]!==u||t[7]!==c?(O=io(h,c,l,u),t[4]=l,t[5]=h,t[6]=u,t[7]=c,t[8]=O):O=t[8];let k=Tz(h,O&&!D&&n),A=(0,Z.useRef)(!1),j,M;t[9]!==i||t[10]!==s||t[11]!==n||t[12]!==r?(j=()=>{if(!n){A.current=!1;return}A.current||(A.current=!0,g(r),v(i??``),b(s??``))},M=[n,r,i,s],t[9]=i,t[10]=s,t[11]=n,t[12]=r,t[13]=j,t[14]=M):(j=t[13],M=t[14]),(0,Z.useEffect)(j,M);let N;t[15]!==_||t[16]!==y||t[17]!==h||t[18]!==p||t[19]!==m?(N=function(){let e=h.trim();e&&(m(e,_.trim()||null,y.trim()||null),p(!1))},t[15]=_,t[16]=y,t[17]=h,t[18]=p,t[19]=m,t[20]=N):N=t[20];let P=N,F;t[21]===P?F=t[22]:(F=function(e){e.key===`Enter`&&(e.preventDefault(),P())},t[21]=P,t[22]=F);let I=F,L;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=function(e){g(e.path),b(``)},t[23]=L):L=t[23];let R=L,te,ne,re,ie,ae,oe,se,z,B,ce,V,H,U,W,le,G,ue;if(t[24]!==T||t[25]!==C||t[26]!==S||t[27]!==l||t[28]!==_||t[29]!==y||t[30]!==h||t[31]!==I||t[32]!==w||t[33]!==k||t[34]!==f||t[35]!==p||t[36]!==n||t[37]!==c||t[38]!==x){let e=new Map,r=k?.map(t=>{let n=e.get(t.slug)??0;e.set(t.slug,n+1);let r=n===0?t.slug:`${t.slug}-${n}`;return{...t,reactKey:r}}),i=!!r?.length;re=Hi,W=n,le=p,ne=Li,z=`sm:max-w-xl`,B=``,ce=ER,V=ER,H=ER;let o;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Ii,{children:(0,$.jsx)(a,{id:`xzktOa`})}),t[56]=o):o=t[56],t[57]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsxs)(Vi,{children:[o,(0,$.jsx)(Fi,{children:(0,$.jsx)(a,{id:`Jhj_lh`})})]}),t[57]=U):U=t[57],te=Ri,ae=`space-y-6`;let s;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(a,{id:`lGs_bQ`,components:{0:(0,$.jsx)(`span`,{className:`text-destructive`})}}),t[58]=s):s=t[58];let u;t[59]===x?u=t[60]:(u=(0,$.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:x,children:s}),t[59]=x,t[60]=u);let m;t[61]===T?m=t[62]:(m=T({id:`aM23Wr`}),t[61]=T,t[62]=m);let E;t[63]!==l||t[64]!==h||t[65]!==I||t[66]!==f||t[67]!==c||t[68]!==m||t[69]!==x?(E=(0,$.jsx)(kR,{id:x,value:h,pages:c,assetPaths:l,includeAssets:!0,loading:f,onValueChange:g,onSuggestionSelect:R,placeholder:m,autoFocus:!0,"aria-required":`true`,onKeyDown:I}),t[63]=l,t[64]=h,t[65]=I,t[66]=f,t[67]=c,t[68]=m,t[69]=x,t[70]=E):E=t[70],t[71]!==u||t[72]!==E?(oe=(0,$.jsxs)(`div`,{children:[u,E]}),t[71]=u,t[72]=E,t[73]=oe):oe=t[73];let D;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(a,{id:`OTF92M`,components:{0:(0,$.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[74]=D):D=t[74];let O;t[75]===C?O=t[76]:(O=(0,$.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:C,children:D}),t[75]=C,t[76]=O);let A;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>v(e.target.value),t[77]=A):A=t[77];let j;t[78]===T?j=t[79]:(j=T({id:`BH56dn`}),t[78]=T,t[79]=j);let M;t[80]!==C||t[81]!==_||t[82]!==I||t[83]!==j?(M=(0,$.jsx)(Ka,{id:C,value:_,onChange:A,placeholder:j,onKeyDown:I}),t[80]=C,t[81]=_,t[82]=I,t[83]=j,t[84]=M):M=t[84],t[85]!==O||t[86]!==M?(se=(0,$.jsxs)(`div`,{children:[O,M]}),t[85]=O,t[86]=M,t[87]=se):se=t[87];let N;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(a,{id:`Tjc1pH`,components:{0:(0,$.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[88]=N):N=t[88],t[89]===S?G=t[90]:(G=(0,$.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:S,children:N}),t[89]=S,t[90]=G);let P;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>b(e.target.value),t[91]=P):P=t[91];let F;t[92]===T?F=t[93]:(F=T({id:`W-ntoW`}),t[92]=T,t[93]=F),t[94]!==S||t[95]!==y||t[96]!==I||t[97]!==F?(ue=(0,$.jsx)(Ka,{id:S,value:y,onChange:P,placeholder:F,onKeyDown:I}),t[94]=S,t[95]=y,t[96]=I,t[97]=F,t[98]=ue):ue=t[98],ie=i&&(0,$.jsx)(`div`,{id:w,className:`mt-1.5 max-h-36 overflow-y-auto subtle-scrollbar rounded-md border border-border bg-muted/30`,children:r.map(e=>(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":y===e.slug,className:d(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,y===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>b(y===e.slug?``:e.slug),children:[(0,$.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,$.jsx)(`span`,{className:`truncate`,children:e.text})]},e.reactKey))}),t[24]=T,t[25]=C,t[26]=S,t[27]=l,t[28]=_,t[29]=y,t[30]=h,t[31]=I,t[32]=w,t[33]=k,t[34]=f,t[35]=p,t[36]=n,t[37]=c,t[38]=x,t[39]=te,t[40]=ne,t[41]=re,t[42]=ie,t[43]=ae,t[44]=oe,t[45]=se,t[46]=z,t[47]=B,t[48]=ce,t[49]=V,t[50]=H,t[51]=U,t[52]=W,t[53]=le,t[54]=G,t[55]=ue}else te=t[39],ne=t[40],re=t[41],ie=t[42],ae=t[43],oe=t[44],se=t[45],z=t[46],B=t[47],ce=t[48],V=t[49],H=t[50],U=t[51],W=t[52],le=t[53],G=t[54],ue=t[55];let K;t[99]!==ie||t[100]!==G||t[101]!==ue?(K=(0,$.jsxs)(`div`,{children:[G,ue,ie]}),t[99]=ie,t[100]=G,t[101]=ue,t[102]=K):K=t[102];let de;t[103]!==ae||t[104]!==oe||t[105]!==se||t[106]!==K?(de=(0,$.jsxs)(`div`,{className:ae,children:[oe,se,K]}),t[103]=ae,t[104]=oe,t[105]=se,t[106]=K,t[107]=de):de=t[107];let fe;t[108]!==te||t[109]!==de?(fe=(0,$.jsx)(te,{children:de}),t[108]=te,t[109]=de,t[110]=fe):fe=t[110];let pe;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(Bi,{asChild:!0,children:(0,$.jsx)(ee,{variant:`outline`,children:(0,$.jsx)(a,{id:`dEgA5A`})})}),t[111]=pe):pe=t[111];let q;t[112]===h?q=t[113]:(q=h.trim(),t[112]=h,t[113]=q);let me=!q,J;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,$.jsx)(a,{id:`tfDRzk`}),t[114]=J):J=t[114];let he;t[115]!==P||t[116]!==me?(he=(0,$.jsxs)(zi,{children:[pe,(0,$.jsx)(ee,{onClick:P,disabled:me,children:J})]}),t[115]=P,t[116]=me,t[117]=he):he=t[117];let ge;t[118]!==ne||t[119]!==z||t[120]!==B||t[121]!==ce||t[122]!==V||t[123]!==H||t[124]!==U||t[125]!==fe||t[126]!==he?(ge=(0,$.jsxs)(ne,{className:z,"data-ok-layer-spawned":B,onPointerDownOutside:ce,onFocusOutside:V,onInteractOutside:H,children:[U,fe,he]}),t[118]=ne,t[119]=z,t[120]=B,t[121]=ce,t[122]=V,t[123]=H,t[124]=U,t[125]=fe,t[126]=he,t[127]=ge):ge=t[127];let _e;return t[128]!==re||t[129]!==W||t[130]!==le||t[131]!==ge?(_e=(0,$.jsx)(re,{open:W,onOpenChange:le,children:ge}),t[128]=re,t[129]=W,t[130]=le,t[131]=ge,t[132]=_e):_e=t[132],_e}function iG(e){let t=(0,Q.c)(119),{editor:n,getPos:r,onClose:i,onNavigate:s}=e,c=r(),l=c==null?null:n.state.doc.nodeAt(c),u=String(l?.attrs.target??``),f=cn(l?.attrs.alias),p=cn(l?.attrs.anchor),m=Vn({target:u,alias:f,anchor:p}),{addPage:h,assetPaths:y,filePaths:b,folderPaths:x,pages:S,pagesBySlug:C,pagesByBasename:w,loading:T}=ns(),E=to(u,p,{pages:S,pagesBySlug:C,pagesByBasename:w,assetPaths:y,filePaths:b}),D=E?.kind===`external`?E:null,O=E?.kind===`asset`?ro(E.url,y,b)??E.url.replace(/^\//,``):null,k=O?null:$n(u,{pages:S,folderPaths:x,pagesBySlug:C,pagesByBasename:w,fallbackTargets:co(u)}),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),{_:P}=o(),F=bz({docName:!D&&!T&&k?.kind===`navigate`&&k.displayState===`resolved`?k.hashDocName:null,anchor:p,enabled:!0});if(!l)return null;let I;t[0]!==n.state||t[1]!==n.view||t[2]!==r?(I=function(e,t,i){let a=r();a!=null&&n.view.dispatch(n.state.tr.setNodeMarkup(a,void 0,{...n.state.doc.nodeAt(a)?.attrs,target:e,alias:t,anchor:i}))},t[0]=n.state,t[1]=n.view,t[2]=r,t[3]=I):I=t[3];let L=I,R;t[4]!==n.state||t[5]!==n.view||t[6]!==r||t[7]!==i?(R=function(){let e=r();if(e==null)return;let t=n.state.doc.nodeAt(e);t&&(n.view.dispatch(n.state.tr.delete(e,e+t.nodeSize)),i())},t[4]=n.state,t[5]=n.view,t[6]=r,t[7]=i,t[8]=R):R=t[8];let te=R,ne=function(e){if(e!==u){let t=r();if(t==null)return;n.view.dispatch(n.state.tr.setNodeMarkup(t,void 0,{...n.state.doc.nodeAt(t)?.attrs,target:e,alias:f??m}))}},re=function(){return k?.kind===`create`?{initialDir:k.initialDir,suggestedName:k.suggestedName}:null},ie=async function(){let e=re();if(!(!e||M)){N(!0);try{await $L(e,{addPage:h,onCreated(e){ne(e),window.location.hash=pa(e),i()}}),N(!1)}catch(e){let t=e;z.error(t instanceof Error?t.message:P({id:`tfi40B`})),N(!1)}}},ae=!D&&!T&&O!==null,oe=!D&&!T&&k?.kind===`navigate`&&k.displayState===`resolved`,se=!D&&!T&&k?.kind===`navigate`&&k.displayState===`folder`,B=!D&&!T&&!O&&k?.kind===`create`,V=!!D,H=D?Ja(D.url)?D.url:null:ae&&O?ca(O):oe&&k?.kind===`navigate`?Kn({docName:k.hashDocName,anchor:p}):null,U=!T&&H!==null&&(V||ae||oe),W,le,G,ue,K;if(t[9]!==P||t[10]!==f||t[11]!==p||t[12]!==O||t[13]!==n.state||t[14]!==n.view||t[15]!==D||t[16]!==r||t[17]!==ae||t[18]!==se||t[19]!==oe||t[20]!==B||t[21]!==T||t[22]!==u){if(T){let e;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Si,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[28]=e):e=t[28],G={icon:e,text:P({id:`yQE2r9`}),className:`text-muted-foreground/80`}}else if(D){let e;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(yi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[29]=e):e=t[29],G={icon:e,text:P({id:`hpDtUm`}),className:`text-muted-foreground`}}else if(ae){let e;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Xl,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[30]=e):e=t[30],G={icon:e,text:P({id:`bUUVED`}),className:`text-muted-foreground`}}else if(se){let e;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(vi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[31]=e):e=t[31],G={icon:e,text:P({id:`kNqMMd`}),className:`text-muted-foreground`}}else if(B){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Nt,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[32]=e):e=t[32],G={icon:e,text:P({id:`8F1i42`}),className:`text-destructive`}}else if(oe){let e;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ql,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[33]=e):e=t[33],G={icon:e,text:P({id:`Hrz9NY`}),className:`text-muted-foreground`}}else{let e;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Nt,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[34]=e):e=t[34],G={icon:e,text:P({id:`DeDYLr`}),className:`text-muted-foreground/80`}}let e;t[35]!==n.state||t[36]!==n.view||t[37]!==r?(e=()=>{let e=r();if(typeof e!=`number`)return new DOMRect;let t=n.state.doc.nodeAt(e);if(!t)return new DOMRect;try{return ce(n.view,e,e+t.nodeSize)}catch{return new DOMRect}},t[35]=n.state,t[36]=n.view,t[37]=r,t[38]=e):e=t[38];let i;t[39]!==n.view.dom||t[40]!==e?(i={getBoundingClientRect:e,contextElement:n.view.dom},t[39]=n.view.dom,t[40]=e,t[41]=i):i=t[41],K=i,le=O??(D?D.url:`${u}${p?`#${p}`:``}`);let a=p?`${u}#${p}`:u;W=f?`[[${a}|${f}]]`:`[[${a}]]`,ue=d(`flex shrink-0`,G.className),t[9]=P,t[10]=f,t[11]=p,t[12]=O,t[13]=n.state,t[14]=n.view,t[15]=D,t[16]=r,t[17]=ae,t[18]=se,t[19]=oe,t[20]=B,t[21]=T,t[22]=u,t[23]=W,t[24]=le,t[25]=G,t[26]=ue,t[27]=K}else W=t[23],le=t[24],G=t[25],ue=t[26],K=t[27];let de;t[42]!==G.icon||t[43]!==ue?(de=(0,$.jsx)(`span`,{className:ue,children:G.icon}),t[42]=G.icon,t[43]=ue,t[44]=de):de=t[44];let fe=de,pe;t[45]!==fe||t[46]!==B||t[47]!==G.text?(pe=B?(0,$.jsxs)(v,{children:[(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(`span`,{className:`flex shrink-0`,"data-slot":`wiki-link-prop-panel-icon-trigger`,children:fe})}),(0,$.jsx)(_,{children:G.text})]}):fe,t[45]=fe,t[46]=B,t[47]=G.text,t[48]=pe):pe=t[48];let q=pe,me=`${G.text}: ${le}`,J;t[49]!==le||t[50]!==V||t[51]!==B||t[52]!==H||t[53]!==U||t[54]!==i||t[55]!==s?(J=(0,$.jsx)(g,{asChild:!0,children:U?(0,$.jsx)(`a`,{href:H??void 0,...V?{target:`_blank`,rel:`noopener noreferrer`}:{},onClick:e=>rn(e,s,i),"data-slot":`wiki-link-prop-panel-text`,className:`block truncate text-sm font-medium text-foreground underline-offset-2 hover:underline focus-visible:underline`,children:le}):(0,$.jsx)(`span`,{"data-slot":`wiki-link-prop-panel-text`,className:d(`block truncate text-sm font-medium`,B?`text-muted-foreground`:`text-foreground`),children:le})}),t[49]=le,t[50]=V,t[51]=B,t[52]=H,t[53]=U,t[54]=i,t[55]=s,t[56]=J):J=t[56];let he;t[57]===le?he=t[58]:(he=(0,$.jsx)(_,{className:`max-w-80 break-all`,children:le}),t[57]=le,t[58]=he);let ge;t[59]!==J||t[60]!==he?(ge=(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(v,{children:[J,he]})}),t[59]=J,t[60]=he,t[61]=ge):ge=t[61];let _e;t[62]!==ie||t[63]!==M||t[64]!==B?(_e=B?(0,$.jsxs)(ee,{type:`button`,size:`sm`,variant:`link`,disabled:M,onClick:()=>void ie(),"data-slot":`wiki-link-prop-panel-create`,className:`flex items-center text-foreground`,children:[(0,$.jsx)(Di,{className:`size-3.5`,"aria-hidden":`true`}),M?(0,$.jsx)(a,{id:`HM56Bx`}):(0,$.jsx)(a,{id:`XRuL0i`})]}):null,t[62]=ie,t[63]=M,t[64]=B,t[65]=_e):_e=t[65];let ve;t[66]===P?ve=t[67]:(ve=P({id:`ePK91l`}),t[66]=P,t[67]=ve);let ye;t[68]===j?ye=t[69]:(ye=()=>j(!0),t[68]=j,t[69]=ye);let be;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,$.jsx)(Ei,{className:`size-3.5`,"aria-hidden":`true`}),t[70]=be):be=t[70];let xe;t[71]!==ve||t[72]!==ye?(xe=(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(ee,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":ve,onClick:ye,"data-slot":`wiki-link-prop-panel-edit`,children:be})}),t[71]=ve,t[72]=ye,t[73]=xe):xe=t[73];let Se;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,$.jsx)(_,{children:(0,$.jsx)(a,{id:`ePK91l`})}),t[74]=Se):Se=t[74];let Ce;t[75]===xe?Ce=t[76]:(Ce=(0,$.jsxs)(v,{disableHoverableContent:!0,children:[xe,Se]}),t[75]=xe,t[76]=Ce);let we;t[77]===W?we=t[78]:(we=(0,$.jsx)(bs,{copyContent:W}),t[77]=W,t[78]=we);let Te;t[79]===P?Te=t[80]:(Te=P({id:`t_YqKh`}),t[79]=P,t[80]=Te);let Ee;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,$.jsx)(Ai,{className:`size-3.5`,"aria-hidden":`true`}),t[81]=Ee):Ee=t[81];let De;t[82]!==te||t[83]!==Te?(De=(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(ee,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":Te,onClick:te,"data-slot":`wiki-link-prop-panel-remove`,children:Ee})}),t[82]=te,t[83]=Te,t[84]=De):De=t[84];let Oe;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,$.jsx)(_,{children:(0,$.jsx)(a,{id:`t_YqKh`})}),t[85]=Oe):Oe=t[85];let ke;t[86]===De?ke=t[87]:(ke=(0,$.jsxs)(v,{disableHoverableContent:!0,children:[De,Oe]}),t[86]=De,t[87]=ke);let Ae;t[88]!==_e||t[89]!==Ce||t[90]!==we||t[91]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[_e,Ce,we,ke]}),t[88]=_e,t[89]=Ce,t[90]=we,t[91]=ke,t[92]=Ae):Ae=t[92];let Y;t[93]!==q||t[94]!==ge||t[95]!==Ae?(Y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[q,ge,Ae]}),t[93]=q,t[94]=ge,t[95]=Ae,t[96]=Y):Y=t[96];let je;t[97]===F?je=t[98]:(je=F?(0,$.jsx)(UR,{preview:F}):null,t[97]=F,t[98]=je);let Me;t[99]!==i||t[100]!==Y||t[101]!==je||t[102]!==me||t[103]!==K?(Me=(0,$.jsxs)(VL,{kind:`wiki-link`,ariaLabel:me,onDeactivate:i,triggerReference:K,className:`w-96`,children:[Y,je]}),t[99]=i,t[100]=Y,t[101]=je,t[102]=me,t[103]=K,t[104]=Me):Me=t[104];let Ne;t[105]!==f||t[106]!==p||t[107]!==y||t[108]!==A||t[109]!==b||t[110]!==L||t[111]!==T||t[112]!==S||t[113]!==j||t[114]!==u?(Ne=(0,$.jsx)(rG,{open:A,target:u,alias:f,anchor:p,pages:S,assetPaths:y,filePaths:b,loading:T,onOpenChange:j,onSave:L}),t[105]=f,t[106]=p,t[107]=y,t[108]=A,t[109]=b,t[110]=L,t[111]=T,t[112]=S,t[113]=j,t[114]=u,t[115]=Ne):Ne=t[115];let Pe;return t[116]!==Me||t[117]!==Ne?(Pe=(0,$.jsxs)($.Fragment,{children:[Me,Ne]}),t[116]=Me,t[117]=Ne,t[118]=Pe):Pe=t[118],Pe}var aG=0;function oG(){return`wiki-link-${++aG}`}function sG(e){let t=e.doc??(typeof document<`u`?document:{createElement:null,createTextNode:null}),n=t.createElement(`span`);n.setAttribute(`data-wiki-link`,``),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`data-target`,e.target),n.setAttribute(`data-alias`,e.alias??``),n.setAttribute(`data-anchor`,e.anchor??``),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`Wiki link: ${e.target}${e.anchor?`#${e.anchor}`:``}`),n.classList.add(`wiki-link-chip`),n.style.touchAction=`manipulation`;let r=t.createElement(`span`);r.setAttribute(`data-wiki-link-icon`,``),r.setAttribute(`aria-hidden`,`true`),n.appendChild(r);let i=e.alias??`${e.target}${e.anchor?`#${e.anchor}`:``}`,a=t.createTextNode(i);return n.appendChild(a),{dom:n,iconSpan:r}}var cG=new WeakMap,lG=512;function uG(e,t){if(!t||!e)return null;let n=fo(e,t);if(!n)return null;let r=t.pageIcons?.get(n);if(!r)return null;let i=JW(r);return i.kind===`unsupported`?null:i}function dG(e,t,n){if(!n)return fG(e,t,n);let r=cG.get(n);r||(r=new Map,cG.set(n,r));let i=JSON.stringify([e,t,Mr()]),a=r.get(i);if(a!==void 0)return a;let o=fG(e,t,n);return r.size>=lG&&r.clear(),r.set(i,o),o}function fG(e,t,n){if(!e)return null;let r=to(e,t,n??new Set);if(!r)return null;if(r.kind===`external`)return`external`;if(!n)return`loading`;if(r.kind===`asset`)return n.assetPaths===void 0&&n.filePaths===void 0||ro(r.url,n.assetPaths??new Set,n.filePaths)?`asset`:Mr()?`unresolved`:null;let i=$n(e,{pages:n.pages,folderPaths:n.folderPaths,pagesBySlug:n.pagesBySlug,pagesByBasename:n.pagesByBasename,fallbackTargets:co(e)});return i.kind===`create`?Mr()?`unresolved`:null:i.displayState}function pG(e,t){let n=t??``;if(e.getAttribute(`data-resolution-state`)!==n){if(!n){e.removeAttribute(`data-resolution-state`);return}e.setAttribute(`data-resolution-state`,n)}}function mG(e,t,n=document){let r=t?.kind??``,i=t?.value??``;if(e.getAttribute(`data-kind`)===r&&e.getAttribute(`data-value`)===i)return;for(e.setAttribute(`data-kind`,r),e.setAttribute(`data-value`,i);e.firstChild;)e.removeChild(e.firstChild);if(!t)return;if(t.kind===`emoji`){e.appendChild(n.createTextNode(t.value));return}let a=n.createElement(`img`);a.setAttribute(`src`,t.value),a.setAttribute(`alt`,``),a.setAttribute(`draggable`,`false`),a.setAttribute(`referrerpolicy`,`no-referrer`),e.appendChild(a)}var hG=Jt.extend({priority:200,addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=oG(),{dom:i,iconSpan:a}=sG({nodeId:r,target:String(t.attrs.target??``),alias:t.attrs.alias==null?null:String(t.attrs.alias),anchor:t.attrs.anchor==null?null:String(t.attrs.anchor)}),o=t,s=()=>{let e=String(o.attrs.target??``),t=o.attrs.anchor==null?null:String(o.attrs.anchor),n=es();mG(a,uG(e,n)),pG(i,dG(e,t,n))};s();let c=$o(s),l=vr(s),u=()=>{let e=n();return typeof e==`number`?e:void 0},d=nv(e),f=({newTab:e})=>{let t=o.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=typeof t.anchor==`string`?t.anchor:null,i=es(),a=to(n,r,i??new Set);if(!a)return!1;if(a.kind===`doc`){let t=$n(n,{pages:i?.pages??new Set,folderPaths:i?.folderPaths??new Set,pagesBySlug:i?.pagesBySlug,pagesByBasename:i?.pagesByBasename,fallbackTargets:co(n)});if(t.kind===`create`)return!1;let r=t.kind===`navigate`?t.hashDocName:a.docName;return e?un({docName:r,anchor:a.anchor}):window.location.assign(Kn({docName:r,anchor:a.anchor})),!0}if(a.kind===`asset`){let t=ro(a.url,i?.assetPaths??new Set,i?.filePaths)??a.url.replace(/^\//,``);return e?Wr(ca(t)):window.location.hash=ca(t),!0}return Ja(a.url)?(qa(a.url),!0):!1};return d.register({type:`wikiLink`,nodeId:r,getPos:u,controls:{propPanel:t=>(0,Z.createElement)(iG,{editor:e,getPos:u,onClose:t.deactivate,onNavigate:e=>f({newTab:e})})},handlePrimary:f}),{dom:i,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLink`)return!1;o=e;let t=String(e.attrs.target??``),n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor);i.setAttribute(`data-target`,t),i.setAttribute(`data-alias`,n??``),i.setAttribute(`data-anchor`,r??``),i.setAttribute(`aria-label`,`Wiki link: ${t}${r?`#${r}`:``}`);let a=n??`${t}${r?`#${r}`:``}`,c=i.lastChild;return c&&c.nodeType===3?c.nodeValue=a:i.appendChild(i.ownerDocument.createTextNode(a)),s(),!0},destroy:()=>{d.deregister(r),c(),l()}}}},addKeyboardShortcuts(){return{Backspace:()=>{if(sr.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeBefore;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from-t.nodeSize,e.from)),!0}return!1},Delete:()=>{if(sr.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeAfter;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from,e.from+t.nodeSize)),!0}return!1}}},addProseMirrorPlugins(){return[Zr(this.editor)]}});function gG(e){let t=(0,Q.c)(3),{src:n,alt:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,$.jsx)(gb,{src:n,alt:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var _G=0;function vG(){return`wiki-link-embed-${++_G}`}function yG(e){let t=e.doc??(typeof document<`u`?document:{createElement:null,createTextNode:null}),n=t.createElement(`a`);n.setAttribute(`data-wiki-embed`,``),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`data-target`,e.target),n.setAttribute(`data-alias`,e.alias??``),n.setAttribute(`data-anchor`,e.anchor??``),n.setAttribute(`href`,e.href),n.setAttribute(`target`,`_blank`),n.setAttribute(`rel`,`noopener noreferrer`),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`Embed: ${e.target}${e.anchor?`#${e.anchor}`:``}`),n.classList.add(`wiki-link-embed-chip`),n.style.touchAction=`manipulation`;let r=e.alias??`${e.target}${e.anchor?`#${e.anchor}`:``}`,i=t.createTextNode(r);return n.appendChild(i),{dom:n}}function bG(e,t){e.setAttribute(`data-wiki-embed`,``),e.setAttribute(`data-node-id`,t.nodeId),e.setAttribute(`data-target`,t.target),e.setAttribute(`data-alias`,t.alias??``),e.setAttribute(`contenteditable`,`false`)}function xG(e){let t=eo(e);return t!==null&&te.has(t)}function SG(e){let t=e.target;if(!t)return null;let n=e.resolvedSrc&&e.resolvedSrc.length>0?e.resolvedSrc:t,r=eo(t);if(r===null)return null;let i=po(n,``,{literal:!0});return i===null?null:{url:n,projectRelPath:i,ext:r,title:i.split(`/`).pop()??n}}var CG=_i.extend({addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=vG(),i=t,a=String(t.attrs.target??``),o=t.attrs.alias==null?null:String(t.attrs.alias),s=t.attrs.anchor==null?null:String(t.attrs.anchor),c=t.attrs.resolvedSrc==null?null:String(t.attrs.resolvedSrc);if(xG(a)){let t=new zr(gG,{editor:e,props:{src:c??a,alt:o??a},as:`span`,className:`wiki-link-embed-image`}),n=t.element;return bG(n,{nodeId:r,target:a,alias:o}),{dom:n,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLinkEmbed`)return!1;i=e;let a=String(e.attrs.target??``),o=e.attrs.alias==null?null:String(e.attrs.alias),s=e.attrs.resolvedSrc==null?null:String(e.attrs.resolvedSrc);if(!xG(a))return!1;let c=s??a;return bG(n,{nodeId:r,target:a,alias:o}),t.updateProps({src:c,alt:o??a}),!0},destroy:()=>t.destroy()}}let{dom:l}=yG({nodeId:r,target:a,alias:o,anchor:s,href:c??a});l.addEventListener(`click`,e=>{e.preventDefault()});let u=()=>{let e=n();return typeof e==`number`?e:void 0},d=nv(e);return d.register({type:`wikiLinkEmbed`,nodeId:r,getPos:u,controls:{},handlePrimary:({newTab:e})=>{let t=i.attrs,n=SG({target:typeof t.target==`string`?t.target:``,resolvedSrc:typeof t.resolvedSrc==`string`?t.resolvedSrc:null});return n===null?!1:(sn({...n,newTab:e}),!0)}}),{dom:l,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLinkEmbed`)return!1;i=e;let t=String(e.attrs.target??``);if(xG(t))return!1;let n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor),a=(e.attrs.resolvedSrc==null?null:String(e.attrs.resolvedSrc))??t;return l.setAttribute(`data-target`,t),l.setAttribute(`data-alias`,n??``),l.setAttribute(`data-anchor`,r??``),l.setAttribute(`href`,a),l.setAttribute(`aria-label`,`Embed: ${t}${r?`#${r}`:``}`),l.textContent=n??`${t}${r?`#${r}`:``}`,!0},destroy:()=>{d.deregister(r)}}}}}),wG=[OC,_C,TC,yC],TG=[...Qt.map(e=>{if(e.name===`jsxComponent`)return EU;if(e.name===`jsxInline`)return AU;if(e.name===`image`){let t=e.options??{};return NL.configure({...t,inline:!0})}return e.name===`imageReference`?LL:e.name===`rawMdxFallback`?VU:e.name===`wikiLink`?hG:e.name===`wikiLinkEmbed`?CG:e.name===`link`?Rz:e.name===`mathInline`?RU:e.name===`tag`?MW:e.name===`codeBlock`?qF:e}),Fw,XU.configure({itemsSources:[...wG,pw],categoryLabels:{skills:`Skills`,content:`Components`,layout:`Layout`,media:`Media`,data:`Data`,embed:`Embeds`}}),bn,AL,eW,ng.configure({onDrop(e,t,n){if(p_(e))for(let r of t)m_(r,e,n)},onPaste(e,t,n){if(p_(e))for(let n of t)m_(n,e,e.state.selection.from)}}),jL,Sg,mW,kL,DL,xw,GW,cW,uW,QU,Kg,y_,E_,og,Dw,EH,M_,_e.create({name:`chunkWrapperDecoration`,addProseMirrorPlugins(){return[Uw()]}})],EG=new Set([`link`,`wikiLink`,`jsxComponent`,`jsxInline`,`imageReference`]);function DG(e,t){return e.map(e=>EG.has(e.name)?e.configure({docName:t}):e)}var OG=`ok-replay-outbox`,kG=`entry`,AG=`buffer`,jG=5e3,MG=class extends Error{constructor(e,t){super(`[replay-outbox] ${e} timed out after ${jG}ms: ${t}`),this.name=`ReplayOutboxTimeoutError`}};function NG(e,t,n){return new Promise((r,i)=>{let a=setTimeout(()=>{i(new MG(e,t))},jG);n.then(e=>{clearTimeout(a),r(e)},e=>{clearTimeout(a),i(e)})})}function PG(){return typeof indexedDB<`u`&&typeof indexedDB.databases==`function`}function FG({branch:e,docName:t,namespace:n}){return`${$i(OG,n)}:${e}:${t}`}function IG(e){return new Promise((t,n)=>{let r=indexedDB.open(e);r.onupgradeneeded=()=>{let e=r.result;e.objectStoreNames.contains(kG)||e.createObjectStore(kG)},r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)})}async function LG(e){return PG()?(await indexedDB.databases()).some(t=>t.name===e):!1}async function RG(e,t){if(!PG())return!1;let{docName:n}=e,r=FG(e);return NG(`write`,n,(async()=>{let e=await IG(r);try{return await new Promise((n,r)=>{let i=e.transaction(kG,`readwrite`);i.objectStore(kG).put({delta:t.delta,fullState:t.fullState},AG),i.oncomplete=()=>n(),i.onerror=()=>r(i.error),i.onabort=()=>r(i.error??Error(`replay-outbox write aborted`)),typeof i.commit==`function`&&i.commit()}),!0}finally{e.close()}})())}async function zG(e){if(!PG())return null;let{docName:t}=e,n=FG(e);return NG(`read`,t,(async()=>{if(!await LG(n))return null;let e=await IG(n);try{let t=await new Promise((t,n)=>{let r=e.transaction(kG,`readonly`).objectStore(kG).get(AG);r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)});if(t==null)return null;let n=t;return!(n.delta instanceof Uint8Array)||!(n.fullState instanceof Uint8Array)?null:{delta:n.delta,fullState:n.fullState}}finally{e.close()}})())}async function BG(e){if(!PG())return!1;let{docName:t}=e,n=FG(e);return NG(`consume`,t,(async()=>{if(!await LG(n))return!1;let e=await IG(n);try{return await new Promise((t,n)=>{let r=e.transaction(kG,`readwrite`),i=r.objectStore(kG),a=!1,o=i.count(AG);o.onsuccess=()=>{a=o.result>0},i.delete(AG),r.oncomplete=()=>t(a),r.onerror=()=>n(r.error),r.onabort=()=>n(r.error??Error(`replay-outbox consume aborted`))})}finally{e.close()}})())}function VG(){return ha(`SYNC_TIMEOUT_MS`,3e4)}var HG=class extends Error{docName;elapsedMs;constructor(e,t){super(`Sync timed out for "${e}" after ${t}ms`),this.name=`SyncTimeoutError`,this.docName=e,this.elapsedMs=t}},UG=class extends Error{docName;constructor(e){super(`Provider disconnected before sync for "${e}"`),this.name=`PreSyncDisconnectError`,this.docName=e}},WG=class extends Error{docName;constructor(e){super(`Document not found: "${e}"`),this.name=`DocumentNotFoundError`,this.docName=e}},GG=class extends Error{docName;cause;constructor(e,t){let n=t instanceof Error?t.message:String(t??`unknown`);super(`Bridge setup failed for "${e}": ${n}`),this.name=`BridgeSetupError`,this.docName=e,this.cause=t}},KG=class extends Error{docName;missingCapability;constructor(e,t){super(`Server is missing capability "${t}" required to open "${e}".`),this.name=`ServerCapabilityMismatchError`,this.docName=e,this.missingCapability=t}},qG=new Map,JG=!1;function YG(){for(let e of qG.values())if(!e.settled)return!0;return!1}function XG(){typeof document>`u`||document.visibilityState===`visible`&&ZG(Date.now())}function ZG(e){let t=[];for(let[n,r]of qG){if(r.settled)continue;let i=e-r.createdAt;if(i<VG())continue;r.settled=!0;let a=new HG(n,i);tK(r),r.reject(a);let o=hf(n);o!==void 0&&Ef(o),t.push({docName:n,elapsedMs:i})}if(t.length>0){let e=t.map(e=>`${e.docName} (${e.elapsedMs}ms)`).join(`, `);console.warn(`[syncPromise] reaped ${t.length} timed-out ${t.length===1?`entry`:`entries`} on visibility restore (tab-sleep recovered): ${e}`)}return YG()||$G(),t.length}function QG(){JG||typeof document>`u`||(document.addEventListener(`visibilitychange`,XG),JG=!0)}function $G(){JG&&(typeof document>`u`||(document.removeEventListener(`visibilitychange`,XG),JG=!1))}var eK=new Map;function tK(e){e.detached||(e.detached=!0,e.timeoutHandle!==null&&clearTimeout(e.timeoutHandle),e.provider.off(`synced`,e.onSynced),e.provider.off(`close`,e.onClose))}function nK(e,t){let n=qG.get(e);if(n)return n.promise;let r=eK.get(e);if(r!==void 0){eK.delete(e);let n=r===`timeout`?new HG(e,0):new UG(e);console.warn(`[syncPromise] ${e} rejected on creation (test hook, armed ${r}): ${n.message}`),X(`ok/sync/create`,{docName:e,mountId:hf(e),warm:!1,armed:r}),X(`ok/sync/reject`,{docName:e,mountId:hf(e),reason:`armed-${r}`});let i=iK(n);return qG.set(e,aK(i,t)),i}if(t.synced){console.log(`[syncPromise] ${e} resolved synchronously (warm provider)`);let n=hf(e);X(`ok/sync/create`,{docName:e,mountId:n,warm:!0}),X(`ok/sync/resolve`,{docName:e,mountId:n,elapsedMs:0,warm:!0}),X.histogram(`ok/sync/resolve-elapsed-ms`,n===void 0?{docName:e,warm:!0}:{docName:e,mountId:n,warm:!0},0);let r=Promise.resolve();return qG.set(e,rK(r,t)),r}let i=Date.now(),{promise:a,resolve:o,reject:s}=Promise.withResolvers(),c=()=>{let t=qG.get(e);if(!t||t.settled)return;t.settled=!0,t.resolved=!0;let n=Date.now()-t.createdAt;console.log(`[syncPromise] ${e} resolved in ${n}ms`);let r=hf(e);if(X(`ok/sync/resolve`,{docName:e,mountId:r,elapsedMs:n,warm:!1}),X.histogram(`ok/sync/resolve-elapsed-ms`,r===void 0?{docName:e}:{docName:e,mountId:r},n),tK(t),YG()||$G(),t.resolve(),rs(),r!==void 0){let i=Date.now();Tf(r,`ok.sync-promise`,{"doc.name":e,elapsed_ms:n},t.createdAt,i),Ef(r,i)}},l=({event:t})=>{let n=qG.get(e);if(!n||n.settled)return;n.settled=!0;let r=new UG(e),i=t?.code??null,a=t?.reason??null;console.warn(`[syncPromise] ${e} rejected: ${r.message} (close ${i??`<none>`} "${a??``}")`);let o=hf(e);X(`ok/sync/reject`,{docName:e,mountId:o,reason:`pre-sync-disconnect`,closeCode:i,closeReason:a}),tK(n),YG()||$G(),n.reject(r),o!==void 0&&Ef(o)},u={promise:a,resolve:o,reject:s,createdAt:i,timeoutHandle:setTimeout(()=>{let t=qG.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt,r=new HG(e,n);console.warn(`[syncPromise] ${e} rejected: ${r.message}`);let i=hf(e);X(`ok/sync/reject`,{docName:e,mountId:i,reason:`timeout`,elapsedMs:n}),tK(t),YG()||$G(),t.reject(r),i!==void 0&&Ef(i)},VG()),provider:t,onSynced:c,onClose:l,settled:!1,resolved:!1,detached:!1};return qG.set(e,u),t.on(`synced`,c),t.on(`close`,l),QG(),X(`ok/sync/create`,{docName:e,mountId:hf(e),warm:!1}),a}function rK(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!0,detached:!0}}function iK(e){let t=Promise.reject(e);t.catch(()=>{});let n=t;return n.status=`rejected`,n.reason=e,n}function aK(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!1,detached:!0}}function oK(e){return qG.get(e)?.resolved===!0}function sK(e){let t=qG.get(e);t&&(t.settled=!0,tK(t),qG.delete(e),YG()||$G())}function cK(e,t){let n=qG.get(e);if(!n||n.settled)return!1;n.settled=!0,console.warn(`[syncPromise] ${e} rejected: ${t.message}`),tK(n),YG()||$G(),n.reject(t);let r=hf(e);return r!==void 0&&Ef(r),!0}var lK=Object.freeze({kind:`tab-replay`}),uK=Object.freeze({kind:`idle`}),dK=5,fK=4408,pK=`forced`;function mK(e,t){return()=>{}}var hK=null;function gK(){return hK??=H(TG),hK}var _K=4e3,vK=1e4;function yK(e){try{return e.getText(`source`).length>0||e.getXmlFragment(`default`).length>0}catch{return!1}}var bK=class extends Error{docName;timeoutMs;constructor(e,t){super(`client persistence clearData timed out for ${e} after ${t}ms`),this.docName=e,this.timeoutMs=t,this.name=`ClientPersistenceClearTimeoutError`}},xK=class extends Error{docName;timeoutMs;constructor(e,t){super(`stored-state epoch peek timed out for ${e} after ${t}ms`),this.docName=e,this.timeoutMs=t,this.name=`StoredEpochPeekTimeoutError`}},SK=`ok-last-observed-branch`,CK=`ok-doc-lineage-epochs`,wK=5e3,TK=ha(`MAX_BUFFER_BYTES`,1*1024*1024),EK=ha(`MAX_POOL`,10),DK=class{_entries=new Map;get entries(){return this._entries}lruOrder=[];activeDocName=null;visibleDocNames=new Set;maxSize;wsUrl;recycleDebounceMs;clearDataTimeoutMs;flushOnHideEnabled=!0;unsyncedWorkListeners=new Set;replaysInFlight=0;onChange=null;tabIdentity=null;serverRestartRecoveryState=uK;cachedServerInstanceId=null;pendingServerInstanceKnown=null;recoveryMismatchStaleClaim;handledStaleClaims=new Set;bufferedUpdates=new Map;pendingClears=new Map;clearFailures=new Set;persistenceFactory;peekStoredEpoch;storage;lastObservedBranchKey;docLineageEpochsKey;storageNamespace;constructor(e,t,n){this.maxSize=e,this.wsUrl=t,this.recycleDebounceMs=n?.recycleDebounceMs??_K,this.clearDataTimeoutMs=n?.clearDataTimeoutMs??vK,this.persistenceFactory=n?.persistenceFactory??Yh,this.peekStoredEpoch=n?.peekStoredLineageEpoch??Xh,n?.storage===void 0?this.storage=globalThis.localStorage===void 0?null:globalThis.localStorage:this.storage=n.storage;let r=n?.storageNamespace??null;this.storageNamespace=r,this.lastObservedBranchKey=$i(SK,r),this.docLineageEpochsKey=$i(CK,r)}setTabIdentity(e){this.tabIdentity=e}setExpectedServerInstanceId(e){let t=e!==null&&e.length>0?e:null,n=this.cachedServerInstanceId!==null&&this.cachedServerInstanceId.length>0?this.cachedServerInstanceId:null;if(!(n!==null&&t===n)){if(n!==null&&t!==null){this.handleServerInstanceMismatch(n),this.cachedServerInstanceId=t,this.resolvePendingServerInstanceKnown(t);return}this.cachedServerInstanceId=e,t!==null&&(this.resolvePendingServerInstanceKnown(t),this.attachDeferredPersistence(t))}}resolvePendingServerInstanceKnown(e){if(this.pendingServerInstanceKnown===null)return;let t=this.pendingServerInstanceKnown;this.pendingServerInstanceKnown=null,t.resolve(e)}whenServerInstanceKnown(){return this.cachedServerInstanceId!==null&&this.cachedServerInstanceId.length>0?Promise.resolve(this.cachedServerInstanceId):(this.pendingServerInstanceKnown===null&&(this.pendingServerInstanceKnown=Promise.withResolvers()),this.pendingServerInstanceKnown.promise)}buildPersistence(e,t,n){return this.persistenceFactory({branch:this.normalizedObservedBranch(),serverInstanceId:e,docName:t,doc:n})}async validateStoredStateThenAttach(e,t){if(e.persistenceAttachOwned)return;e.persistenceAttachOwned=!0;let n=e.docName,r=()=>this._entries.get(n)===e&&e.kind===`active`&&e.persistence===null&&!this.pendingClears.has(n);if(!r())return;let i;try{i=await new Promise((e,r)=>{let i=setTimeout(()=>{r(new xK(n,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);this.peekStoredEpoch({branch:this.normalizedObservedBranch(),serverInstanceId:t,docName:n}).then(t=>{clearTimeout(i),e(t)},e=>{clearTimeout(i),r(e)})})}catch(e){this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`peek`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)});return}if(!r())return;if(i===null){this.attachValidatedPersistence(e,t);return}if(!e.hasSynced&&(await this.awaitFirstSyncOrDestroy(e),!r()||!e.hasSynced))return;let a=e.provider.document.getMap(`lifecycle`).get(xh),o=typeof a==`string`&&a.length>0?a:null;if(o===i){this.attachValidatedPersistence(e,t);return}this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(n),via:`stored-state-validation`,staleEpoch:i,liveEpoch:o??`<absent>`});let s=this.activeDocName===n;this.runCloseAndClearPersistence(n),this.open(n)!==null&&s&&this.setActive(n)}attachValidatedPersistence(e,t){let n=e.docName;try{let r=this.buildPersistence(t,n,e.provider.document);e.persistence=r,this.notify(),this.scheduleCacheBackfill(e,r)}catch(e){this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`attach`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)})}}scheduleCacheBackfill(e,t){this.backfillCacheAfterFirstSync(e,t).catch(t=>{this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(e.docName),phase:`backfill`,errorName:t instanceof Error?t.name:`non-error-throw`,errorMessage:t instanceof Error?t.message:String(t)})})}async backfillCacheAfterFirstSync(e,t){await t.whenSynced,e.hasSynced||await this.awaitFirstSyncOrDestroy(e),!(this._entries.get(e.docName)!==e||e.kind!==`active`||e.persistence!==t||!e.hasSynced)&&await t.flushFullState()}async awaitFirstSyncOrDestroy(e){e.hasSynced||await new Promise(t=>{let n=()=>{e.provider.off(`synced`,n),e.provider.off(`destroy`,n),t()};e.provider.on(`synced`,n),e.provider.on(`destroy`,n)})}attachDeferredPersistence(e){for(let t of Array.from(this._entries.values()))if(t.kind===`active`&&t.persistence===null&&this._entries.get(t.docName)===t){if(t.hasSynced&&t.lineageEpochRecordAtOpen!==null){let e=t.provider.document.getMap(`lifecycle`).get(xh);if(typeof e==`string`&&e.length>0&&e!==t.lineageEpochRecordAtOpen){let n=t.docName;this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(n),via:`deferred-attach`,staleEpoch:t.lineageEpochRecordAtOpen,liveEpoch:e});let r=this.activeDocName===n;this.runCloseAndClearPersistence(n),this.open(n)!==null&&r&&this.setActive(n);continue}}this.validateStoredStateThenAttach(t,e)}}getServerRestartRecoveryState(){return this.serverRestartRecoveryState}observeDiskAck(e,t){let n=this.entries.get(e);n?.kind===`active`&&(n.lastDiskAckedSV=$h(n.lastDiskAckedSV,t))}observeDiskAckBatch(e){for(let[t,n]of Object.entries(e))this.observeDiskAck(t,n)}lastObservedBranch=null;lastObservedBranchInitialized=!1;getOrInitObservedBranch(){if(this.lastObservedBranchInitialized)return this.lastObservedBranch;this.lastObservedBranchInitialized=!0;try{let e=this.storage?.getItem(this.lastObservedBranchKey)??null;e!==null&&e.length>0&&(this.lastObservedBranch=e)}catch{}return this.lastObservedBranch}persistObservedBranch(e){this.lastObservedBranch=e,this.lastObservedBranchInitialized=!0;try{e===null||e.length===0?this.storage?.removeItem(this.lastObservedBranchKey):this.storage?.setItem(this.lastObservedBranchKey,e)}catch{}}docLineageEpochs=new Map;docLineageEpochsEnvelopeConsumed=!1;normalizedObservedBranch(){return this.getOrInitObservedBranch()??`_unknown_`}consumeLineageEpochEnvelopeIfValid(){if(this.docLineageEpochsEnvelopeConsumed)return;let e=this.cachedServerInstanceId;if(!(e===null||e.length===0)){this.docLineageEpochsEnvelopeConsumed=!0;try{let t=this.storage?.getItem(this.docLineageEpochsKey)??null;if(t===null)return;let n=JSON.parse(t);if(typeof n!=`object`||!n)return;let r=n;if(r.branch!==this.normalizedObservedBranch()||r.serverInstanceId!==e||typeof r.epochs!=`object`||r.epochs===null)return;for(let[e,t]of Object.entries(r.epochs))typeof t==`string`&&t.length>0&&!this.docLineageEpochs.has(e)&&this.docLineageEpochs.set(e,t)}catch(e){e instanceof DOMException||console.warn(JSON.stringify({event:`ok-lineage-epoch-envelope-read-error`,errorName:e instanceof Error?e.name:typeof e,message:e instanceof Error?e.message:String(e)}))}}}getRecordedLineageEpoch(e){let t=this.docLineageEpochs.get(e);return t===void 0?(this.consumeLineageEpochEnvelopeIfValid(),this.docLineageEpochs.get(e)??null):t}persistLineageEpochEnvelope(){let e=this.cachedServerInstanceId;if(!(e===null||e.length===0))try{this.storage?.setItem(this.docLineageEpochsKey,JSON.stringify({branch:this.normalizedObservedBranch(),serverInstanceId:e,epochs:Object.fromEntries(this.docLineageEpochs)}))}catch{}}recordLineageEpoch(e,t){this.docLineageEpochs.get(e)!==t&&(this.docLineageEpochs.set(e,t),this.persistLineageEpochEnvelope())}deleteLineageEpochRecord(e){this.docLineageEpochs.delete(e)&&this.persistLineageEpochEnvelope()}withClearDataTimeout(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>{r(new bK(e,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);t.then(()=>{clearTimeout(i),n()},e=>{clearTimeout(i),r(e)})})}recoveryTelemetryBase(e,t){let n={docName:e,branch:this.normalizedObservedBranch()},r=t===void 0?this.recoveryMismatchStaleClaim:t;return r!==void 0&&r.length>0&&(n.serverInstanceId=r),this.storageNamespace!==null&&(n.project=ea(this.storageNamespace)),n}emitStructuredClientRecoveryEvent(e){console.warn(JSON.stringify(e))}outboxFailureFields(e){return{failureKind:e instanceof MG?`timeout`:`rejected`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)}}emitStructuredClientBreadcrumb(e){console.info(JSON.stringify(e))}clearRecoveryMismatchStaleClaimIfTerminal(){let e=this.serverRestartRecoveryState.kind;(e===`idle`||e===`failed`)&&(this.recoveryMismatchStaleClaim=void 0)}beginServerRestartRecovery(e,t){this.emitStructuredClientBreadcrumb({event:`ok-pool-restart-recovery-begin`,phase:`clearing-local-cache`,docCount:e.length}),this.serverRestartRecoveryState={kind:`recovering`,phase:`clearing-local-cache`,docNames:e,failedDocNames:[],startedAt:t};for(let t of e)sK(t);this.notify()}enterServerRestartReconnect(e,t,n,r){if(this.emitStructuredClientBreadcrumb({event:`ok-pool-restart-recovery-reconnecting`,docCount:e.length,failedCount:t.length}),e.length===0){this.serverRestartRecoveryState=t.length===0?uK:{kind:`failed`,reason:r,docNames:t,failedDocNames:t,startedAt:n},this.clearRecoveryMismatchStaleClaimIfTerminal(),this.notify();return}this.serverRestartRecoveryState={kind:`recovering`,phase:`reconnecting`,docNames:e,failedDocNames:t,startedAt:n,...t.length>0?{clearFailureReason:r}:{}},this.notify()}markServerRestartRecoverySynced(e){let t=this.serverRestartRecoveryState;if(t.kind!==`recovering`||t.phase!==`reconnecting`||!t.docNames.includes(e))return;let n=t.docNames.filter(t=>t!==e);if(this.emitStructuredClientBreadcrumb({event:`ok-pool-restart-recovery-synced`,docName:e,remaining:n.length}),n.length>0){this.serverRestartRecoveryState={...t,docNames:n};return}if(t.failedDocNames.length>0){this.serverRestartRecoveryState={kind:`failed`,reason:t.clearFailureReason??`clear-data-failed`,docNames:t.failedDocNames,failedDocNames:t.failedDocNames,startedAt:t.startedAt},this.clearRecoveryMismatchStaleClaimIfTerminal();return}this.serverRestartRecoveryState=uK,this.clearRecoveryMismatchStaleClaimIfTerminal()}setObservedBranch(e){this.persistObservedBranch(e)}compareAndUpdateObservedBranch(e){let t=this.getOrInitObservedBranch();return this.persistObservedBranch(e),t!==null&&t!==e}onBranchMismatch=null;branchMismatchInFlight=null;mismatchInFlight=null;setOnBranchMismatch(e){if(e===null){this.onBranchMismatch=null;return}this.onBranchMismatch=()=>{if(this.branchMismatchInFlight!==null)return;let t=Promise.resolve().then(e).finally(()=>{this.branchMismatchInFlight===t&&(this.branchMismatchInFlight=null)});this.branchMismatchInFlight=t}}onRenameRedirect=null;onDocDeleted=null;setOnRenameRedirect(e){this.onRenameRedirect=e}setOnDocDeleted(e){this.onDocDeleted=e}setOnChange(e){this.onChange=e}notify(){this.onChange?.()}evictListeners=new Set;onEvict(e){return this.evictListeners.add(e),()=>{this.evictListeners.delete(e)}}fireEvict(e){for(let t of this.evictListeners)try{t(e)}catch(t){console.warn(`[ProviderPool] evict listener threw for ${e}:`,t)}}touch(e){let t=this.lruOrder.indexOf(e);t!==-1&&this.lruOrder.splice(t,1),this.lruOrder.push(e)}setVisibleDocNames(e){let t=new Set;for(let n of e)Ov(n)||t.add(n);t.size===this.visibleDocNames.size&&[...t].every(e=>this.visibleDocNames.has(e))||(this.visibleDocNames=t,this.trimToCapacity(),X(`ok/pool/visible-set`,{visibleCount:this.visibleDocNames.size,poolSize:this.entries.size}))}isProtected(e){return e===this.activeDocName||this.visibleDocNames.has(e)}effectiveCapacity(){let e=this.visibleDocNames.size+ +(this.activeDocName!==null&&!this.visibleDocNames.has(this.activeDocName));return Math.max(this.maxSize,e)}trimToCapacity(){for(;this.entries.size>this.effectiveCapacity()&&this.evictLru(););}open(e){if(Ov(e))return null;let t=this.entries.get(e);if(t!==void 0&&t.kind===`active`&&t.hasSynced&&t.syncState===`disconnected`&&t.provider.unsyncedChanges===0&&!yK(t.provider.document)){X(`ok/pool/recycle-disconnected-on-open`,{docName:e}),this.emitStructuredClientBreadcrumb({event:`ok-pool-recycle-disconnected-on-open`,docName:e}),this.recycleDisconnectedEntry(e);let t=this.entries.get(e);if(t!==void 0)return t}let n=this.entries.get(e);if(n){let t=n.lastAccessedAt;return n.lastAccessedAt=Date.now(),this.touch(e),this.notify(),X(`ok/pool/open`,{docName:e,hit:!0,lastAccessedAt:t,poolEventId:n.poolEventId}),X.count(`ok/pool/open`,{hit:!0}),n}let r=Date.now();this.entries.size>=this.effectiveCapacity()&&this.evictLru();let i=this.cachedServerInstanceId,a=this.getRecordedLineageEpoch(e),o=ja(this.tabIdentity,i,this.getOrInitObservedBranch(),i!==null&&i.length>0?a:null),s=new Ma({url:eg(this.wsUrl),name:e,forceSyncInterval:wK,token:o}),c=this.cachedServerInstanceId;this.clearFailures.has(e)&&this.runCloseAndClearPersistence(e);let l=this.pendingClears.get(e),u=c!==null&&c.length>0&&l===void 0&&a!==null?this.buildPersistence(c,e,s.document):null,d=Ni(),f={kind:`active`,provider:s,persistence:u,lastServerSyncedSV:null,lastDiskAckedSV:null,observerCleanup:null,observerFireCounterCleanup:mK(s.document,e),syncState:`connecting`,docName:e,lastAccessedAt:Date.now(),poolEventId:d,hasSynced:!1,pendingRecycleTimer:null,bridgeSetupFailed:!1,serverDrivenCloseReauthInFlight:!1,serverDrivenCloseReauthAttempts:0,persistenceAttachOwned:!1,lineageEpochRecordAtOpen:a};X(`ok/pool/open`,{docName:e,hit:!1,poolEventId:d}),X.count(`ok/pool/open`,{hit:!1}),s.on(`status`,({status:t})=>{f.kind!==`active`||this.entries.get(e)!==f||t===`disconnected`&&(f.syncState=`disconnected`,this.notify())}),s.on(`synced`,()=>{if(f.kind!==`active`||this.entries.get(e)!==f)return;f.syncState=`synced`,f.hasSynced=!0,f.lastServerSyncedSV=Zh(s.document);let t=s.document.getMap(`lifecycle`).get(xh);if(typeof t==`string`&&t.length>0&&this.recordLineageEpoch(e,t),f.pendingRecycleTimer&&=(clearTimeout(f.pendingRecycleTimer),null),f.serverDrivenCloseReauthAttempts=0,this.markServerRestartRecoverySynced(e),this.notify(),!f.observerCleanup)try{let t=s.document,n=new Jr({extensions:TG});f.observerCleanup=Ut({doc:t,xmlFragment:t.getXmlFragment(`default`),ytext:t.getText(`source`),mdManager:n,schema:gK(),onSyncError:(t,n)=>{console.warn(`[Sync] ${t} failed for ${e}:`,n.message)}})}catch(t){console.error(`[ProviderPool] setupObservers init failed for ${e}:`,t),f.bridgeSetupFailed=!0,cK(e,new GG(e,t))}}),s.on(`disconnect`,()=>{f.kind!==`active`||this.entries.get(e)!==f||(f.syncState=`disconnected`,this.notify(),f.hasSynced&&s.unsyncedChanges===0&&!yK(s.document)&&!f.pendingRecycleTimer&&(this.emitStructuredClientBreadcrumb({event:`ok-pool-recycle-timer-armed`,docName:e,debounceMs:this.recycleDebounceMs}),f.pendingRecycleTimer=setTimeout(()=>{if(f.kind===`active`&&(f.pendingRecycleTimer=null,this.entries.get(e)===f)){if(s.unsyncedChanges>0){X(`ok/pool/recycle-skipped-unsynced`,{docName:e}),this.emitStructuredClientBreadcrumb({event:`ok-pool-recycle-skipped-unsynced`,docName:e});return}this.recycleDisconnectedEntry(e)}},this.recycleDebounceMs)))}),s.on(`authenticationFailed`,({reason:t})=>{let n=[`server-instance-mismatch`,`branch-mismatch`,`rename-redirect`,`doc-deleted`,`doc-lineage-mismatch`],r=t.indexOf(`:`),a=r===-1?t:t.slice(0,r);if(!n.includes(a)){console.warn(JSON.stringify({event:`ok-auth-failed-unknown-reason`,reason:t}));return}let o=r===-1?``:t.slice(r+1),s=o.length>0?o:void 0,c=a;if(c===`server-instance-mismatch`){if(i===null)return;this.handleServerInstanceMismatch(i);return}if(c===`branch-mismatch`){this.onBranchMismatch?.();return}if(c===`rename-redirect`){if(s===void 0||s.length===0){console.warn(JSON.stringify({event:`rename-redirect-missing-payload`,fromDocName:e}));return}let t=e,n=s;this.deleteLineageEpochRecord(t);let r=this.entries.get(t),i=r!==void 0&&r.kind===`active`;this.onRenameRedirect?.({fromDocName:t,toDocName:n,hadOpenProvider:i});return}if(c===`doc-deleted`){this.deleteLineageEpochRecord(e);let t=this.entries.get(e),n=t!==void 0&&t.kind===`active`;this.onDocDeleted?.({docName:e,hadOpenProvider:n});return}if(c===`doc-lineage-mismatch`){if(f.kind!==`active`||this.entries.get(e)!==f)return;this.deleteLineageEpochRecord(e),this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(e),via:`auth-rejection`,staleEpoch:f.lineageEpochRecordAtOpen??``});let t=this.activeDocName===e;this.runCloseAndClearPersistence(e),this.open(e)!==null&&t&&this.setActive(e);return}}),s.on(`close`,({event:t})=>{if(!(f.kind!==`active`||this.entries.get(e)!==f)&&t?.reason){if(t.code===fK&&t.reason===pK){this.emitStructuredClientBreadcrumb({event:`ok-provider-half-open-forced-close`,docName:e,code:t.code,reason:t.reason});return}if(!f.serverDrivenCloseReauthInFlight){if(f.serverDrivenCloseReauthAttempts>=dK){f.serverDrivenCloseReauthAttempts===dK&&(f.serverDrivenCloseReauthAttempts=dK+1,console.warn(JSON.stringify({event:`ok-provider-server-driven-close-reauth-ceiling`,docName:e,attempts:dK,reason:t?.reason??`<unknown>`,code:t?.code??null})));return}f.serverDrivenCloseReauthAttempts+=1,f.serverDrivenCloseReauthInFlight=!0,s.sendToken().catch(t=>{console.warn(JSON.stringify({event:`ok-provider-server-driven-close-reauth-failed`,docName:e,message:t instanceof Error?t.message:String(t)}))}).finally(()=>{f.kind===`active`&&this.entries.get(e)===f&&(f.serverDrivenCloseReauthInFlight=!1)}),console.info(JSON.stringify({event:`ok-provider-server-driven-close-reauth`,docName:e,reason:t.reason,code:t?.code??null}))}}}),s.on(`unsyncedChanges`,()=>this.emitUnsyncedWork()),this.emitUnsyncedWork();let p=this.recoveryMismatchStaleClaim,m=async()=>{if(f.kind!==`active`||this.entries.get(e)!==f)return;let t=this.normalizedObservedBranch(),n,r=t,i,a=this.bufferedUpdates.get(e);if(a!==void 0){if(a.branch!==t){this.discardBufferedUpdate(e),this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-branch-mismatch`,...this.recoveryTelemetryBase(e,p),reason:`buffer-captured-on-another-branch`});return}this.bufferedUpdates.delete(e),n=a,r=a.branch,i=a.durable}else try{let r=await zG({branch:t,docName:e,namespace:this.storageNamespace});if(r===null)return;n=r,i=!0}catch(t){this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-outbox-read-failed`,...this.recoveryTelemetryBase(e,p),...this.outboxFailureFields(t)});return}if(i){let t;try{t=await BG({branch:r,docName:e,namespace:this.storageNamespace})}catch(t){this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-outbox-consume-failed`,...this.recoveryTelemetryBase(e,p),...this.outboxFailureFields(t)});return}if(!t){this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-superseded`,...this.recoveryTelemetryBase(e,p),reason:`claimed-by-another-tab`});return}}if(f.kind!==`active`||this.entries.get(e)!==f){this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-abandoned`,...this.recoveryTelemetryBase(e,p),reason:`entry-replaced-during-consume`,replayByteLength:n.delta.byteLength});return}try{if(n.fullState!==null&&this.replayBufferedContent(e,s,n.fullState))return;Pa(s.document,n.delta,lK),this.emitStructuredClientBreadcrumb({event:`ok-pool-buffer-replay-delta-applied`,docName:e,deltaBytes:n.delta.byteLength})}catch(t){let r=t instanceof Error?t.name:`non-error-throw`;this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-failed`,...this.recoveryTelemetryBase(e,p),replayByteLength:n.delta.byteLength,errorName:r,errorMessage:t instanceof Error?t.message:String(t)})}},h=()=>{s.off(`synced`,h),this.replaysInFlight+=1,m().catch(t=>{this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-unexpected-error`,...this.recoveryTelemetryBase(e),errorName:t instanceof Error?t.name:`non-error-throw`,errorMessage:t instanceof Error?t.message:String(t)})}).finally(()=>{--this.replaysInFlight,this.emitUnsyncedWork()})};if(s.on(`synced`,h),this._entries.set(e,f),this.touch(e),this.notify(),u!==null&&this.scheduleCacheBackfill(f,u),u===null&&c!==null&&c.length>0&&l===void 0&&this.validateStoredStateThenAttach(f,c),l!==void 0&&c!==null&&c.length>0){let t=c;l.then(()=>{this.attachDeferredPersistenceForEntry(f,t)},t=>{console.warn(JSON.stringify({event:`ok-pool-deferred-persistence-attach-skipped`,docName:e,reason:`pending-clear-failed`,message:t instanceof Error?t.message:String(t)}))})}let g=hf(e);return g!==void 0&&Tf(g,`ok.provider-pool.open`,{"doc.name":e},r,Date.now()),f}attachDeferredPersistenceForEntry(e,t){let n=this._entries.get(e.docName);n!==e||n.kind!==`active`||n.persistence!==null||this.validateStoredStateThenAttach(n,t)}handleServerInstanceMismatch(e){if(this.handledStaleClaims.has(e)){this.emitStructuredClientBreadcrumb({event:`ok-pool-mismatch-transition-deduped`,reason:`claim-already-handled`,staleClaim:e});return}if(this.handledStaleClaims.add(e),this.cachedServerInstanceId===e&&(this.cachedServerInstanceId=null),this.mismatchInFlight!==null){this.emitStructuredClientBreadcrumb({event:`ok-pool-mismatch-transition-deduped`,reason:`recycle-in-flight`,staleClaim:e,inflightForClaim:this.recoveryMismatchStaleClaim??``});return}this.recoveryMismatchStaleClaim=e.length>0?e:void 0;let t=Array.from(this.entries.entries());this.emitStructuredClientBreadcrumb({event:`ok-pool-mismatch-recycle-begin`,entryCount:t.length,branch:this.normalizedObservedBranch()});let n=Date.now(),r=this.normalizedObservedBranch(),i=[],a=this.activeDocName,o=a!==null&&t.some(([e,t])=>e===a&&t.kind===`active`)?[a]:[],s=a??t.find(([,e])=>e.kind===`active`)?.[0]??``;s.length>0&&this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-epoch-mismatch`,...this.recoveryTelemetryBase(s)}),this.beginServerRestartRecovery(o,n);for(let[e,n]of t)n.kind===`active`&&!o.includes(e)&&sK(e);for(let[e,n]of t){if(n.kind!==`active`)continue;let t=n.lastDiskAckedSV??n.lastServerSyncedSV;if(t===null){this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-skipped-no-baseline`,...this.recoveryTelemetryBase(e),reason:`no-disk-ack-or-server-sync-vector`});continue}let a=Qh(n.provider.document,t);if(a.byteLength>TK){X(`ok/pool/buffer-overflow`,{docName:e,bytes:a.byteLength});continue}if(a.byteLength>0){let t=wa(n.provider.document),o=t.byteLength>TK?null:t,s={delta:a,fullState:o,branch:r,durable:!1};this.bufferedUpdates.set(e,s),o!==null&&i.push(RG({branch:r,docName:e,namespace:this.storageNamespace},{delta:a,fullState:o}).then(t=>{t?s.durable=!0:this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-outbox-unavailable`,...this.recoveryTelemetryBase(e),reason:`indexeddb-databases-unsupported`})}).catch(t=>{this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-outbox-write-failed`,...this.recoveryTelemetryBase(e),...this.outboxFailureFields(t)})})),this.emitStructuredClientBreadcrumb({event:`ok-pool-mismatch-buffer-captured`,docName:e,deltaBytes:a.byteLength,fullStateBytes:o===null?0:o.byteLength})}}let c=[];for(let[e,n]of t)n.kind===`active`&&n.persistence!==null&&c.push({docName:e,persistence:n.persistence});let l=()=>{let e=c.map(({docName:e,persistence:t})=>({docName:e,promise:this.withClearDataTimeout(e,t.clearData())}));return this.emitStructuredClientBreadcrumb({event:`ok-pool-mismatch-clears-begin`,count:e.length}),Promise.allSettled(e.map(e=>e.promise)).then(t=>{let r=[],i=[],o=!1;t.forEach((t,n)=>{let a=e[n];if(!a)return;let s=a.docName;if(t.status===`rejected`){r.push(s);let e=t.reason instanceof bK;if(e&&(o=!0),e)this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-clear-failed`,...this.recoveryTelemetryBase(s),failureKind:`timeout`});else{let e=t.reason instanceof Error?t.reason.name:`unknown`;this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-clear-failed`,...this.recoveryTelemetryBase(s),failureKind:`rejected`,errorName:e,errorMessage:t.reason instanceof Error?t.reason.message:String(t.reason)})}}else i.push(s)});let s=i.filter(e=>e===a);if(r.length>0){let e=o?`clear-data-timeout`:`clear-data-failed`;console.warn(JSON.stringify({event:`ok-mismatch-recycle-partial-clears-failed`,failedDocs:r,clearedDocs:i})),this.enterServerRestartReconnect(s,r,n,e);for(let e of i)this.recycleDisconnectedEntry(e);return}this.enterServerRestartReconnect(s,[],n,`clear-data-failed`),this.recycleAllEntries()})},u=(i.length===0?l():Promise.allSettled(i).then(l)).finally(()=>{this.mismatchInFlight===u&&(this.mismatchInFlight=null,this.handledStaleClaims.clear())});this.mismatchInFlight=u}replayBufferedContent(e,t,n){let r=new Na;try{Pa(r,n);let i=r.getText(`source`).toString(),a=Wt(r.getXmlFragment(`default`),gK()).toJSON(),o=new Jr({extensions:TG}).serialize(a),{frontmatter:s,body:c}=et(i),l=t.document.getText(`source`).toString(),{body:u}=et(l),d=Gi(u),f=Gi(c)===d&&!qi(u,c),p=Gi(o)===d&&!qi(u,o);if(f&&p)return!0;let m;if(f)m=Ki(s,o).md;else if(p)m=i;else return this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-diverged`,...this.recoveryTelemetryBase(e)}),!1;if(m!==l){let e=Math.min(m.length,l.length),n=0;for(;n<e&&m[n]===l[n];)n+=1;let r=0;for(;r<e-n&&m[m.length-1-r]===l[l.length-1-r];)r+=1;let i=t.document.getText(`source`);t.document.transact(()=>{i.delete(n,l.length-n-r),i.insert(n,m.slice(n,m.length-r))},lK)}return this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-content-applied`,...this.recoveryTelemetryBase(e),surface:f?`fragment`:`ytext`}),!0}catch(t){return this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-content-failed`,...this.recoveryTelemetryBase(e),errorName:t instanceof Error?t.name:`non-error-throw`,errorMessage:t instanceof Error?t.message:String(t)}),!1}finally{r.destroy()}}awaitMismatchSettled(){return this.mismatchInFlight??Promise.resolve()}isMismatchRecycleInFlight(){return this.mismatchInFlight!==null}recycleAllEntries(){let e=Array.from(this.entries.keys());this.emitStructuredClientBreadcrumb({event:`ok-pool-recycle-all`,count:e.length});for(let t of e)this.recycleDisconnectedEntry(t)}prewarm(e){if(Ov(e))return null;let t=this.entries.get(e);if(t)return t;let n=this.open(e);if(!n)return null;let r=this.lruOrder.indexOf(e);return r!==-1&&(this.lruOrder.splice(r,1),this.lruOrder.unshift(e)),n}close(e){let t=this.entries.get(e);t&&(this.destroyEntry(t),this._entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),this.discardBufferedUpdate(e),this.activeDocName===e&&(this.activeDocName=null),this.notify())}async closeAndClearPersistence(e){try{await this.runCloseAndClearPersistence(e)}catch{}}runCloseAndClearPersistence(e){let t=this.pendingClears.get(e);if(t!==void 0)return t;let{promise:n,resolve:r,reject:i}=Promise.withResolvers();this.pendingClears.set(e,n);let a=()=>{this.pendingClears.get(e)===n&&this.pendingClears.delete(e)};return n.then(a,a),this.executeCloseAndClearPersistence(e).then(r,i),n}async executeCloseAndClearPersistence(e){this.clearFailures.delete(e);let t=this.entries.get(e);if(t?.kind===`active`&&t.persistence!==null){let n=t.persistence;try{this.close(e)}catch(t){console.warn(`[ProviderPool] close before clearData threw for ${e}:`,t)}try{await this.withClearDataTimeout(e,n.clearData())}catch(t){throw console.warn(`[ProviderPool] clearData on rename failed for ${e}:`,t),this.clearFailures.add(e),t}return}if(t)try{this.close(e)}catch(t){console.warn(`[ProviderPool] close before IDB-by-name delete threw for ${e}:`,t)}let n=this.normalizedObservedBranch(),r=this.cachedServerInstanceId;if(r===null)return;let i=`ok-ydoc:${n}:${r}:${e}`;try{await this.withClearDataTimeout(e,new Promise((e,t)=>{let n=indexedDB.deleteDatabase(i);n.onsuccess=()=>e(),n.onerror=()=>t(n.error),n.onblocked=()=>{console.warn(`[ProviderPool] IDB delete blocked for ${i}`)}}))}catch(t){throw console.warn(`[ProviderPool] IDB delete on rename failed for ${i}:`,t),this.clearFailures.add(e),t}}clearBufferedUpdates(){for(let e of Array.from(this.bufferedUpdates.keys()))this.discardBufferedUpdate(e)}discardBufferedUpdate(e){let t=this.bufferedUpdates.get(e);this.bufferedUpdates.delete(e),t!==void 0&&(this.emitUnsyncedWork(),t.durable&&BG({branch:t.branch,docName:e,namespace:this.storageNamespace}).catch(t=>{this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-outbox-discard-failed`,...this.recoveryTelemetryBase(e),...this.outboxFailureFields(t)})}))}__test_seedBufferedUpdate(e,t,n={}){this.bufferedUpdates.set(e,{delta:t,fullState:n.fullState??null,branch:n.branch??this.normalizedObservedBranch(),durable:n.durable??!1})}__test_bufferedUpdatesSize(){return this.bufferedUpdates.size}__test_hasBufferedUpdate(e){return this.bufferedUpdates.has(e)}__test_getBufferedUpdate(e){return this.bufferedUpdates.get(e)?.delta}setActive(e){let t=this.entries.get(e);if(!t)throw Error(`[ProviderPool] Cannot setActive — "${e}" is not open`);t.lastAccessedAt=Date.now(),this.touch(e),this.activeDocName=e,this.notify()}clearActive(){this.activeDocName!==null&&(this.activeDocName=null,this.notify())}getActive(){return this.activeDocName?this.entries.get(this.activeDocName)??null:null}getActiveDocName(){return this.activeDocName}has(e){return this.entries.has(e)}peek(e){return this.entries.get(e)??null}setFlushOnHideEnabled(e){this.flushOnHideEnabled=e}flushOnHide(){if(this.flushOnHideEnabled&&this.mismatchInFlight===null)for(let e of this._entries.values())e.kind===`active`&&e.provider.unsyncedChanges>0&&(e.provider.forceSync(),e.persistence?.flushFullState().catch(t=>{this.emitStructuredClientRecoveryEvent({event:`ok-pool-flush-on-hide-failed`,...this.recoveryTelemetryBase(e.docName),errorName:t instanceof Error?t.name:`non-error-throw`,errorMessage:t instanceof Error?t.message:String(t)})}))}resyncOnVisible(){if(this.flushOnHideEnabled&&this.mismatchInFlight===null)for(let e of this._entries.values())e.kind===`active`&&e.syncState===`synced`&&e.provider.forceSync()}hasAnyUnsyncedWork(){for(let e of this._entries.values())if(e.kind===`active`&&e.provider.unsyncedChanges>0)return!0;return!1}hasUnsavedWork(){return this.hasAnyUnsyncedWork()||this.hasPendingReplay()}hasPendingReplay(){if(this.replaysInFlight>0)return!0;for(let e of this.bufferedUpdates.values())if(!e.durable)return!0;return!1}openDocNames(){let e=[];for(let[t,n]of this._entries)n.kind===`active`&&e.push(t);return e}docNamesToOpenForReplay(){let e=[];for(let[t,n]of this.bufferedUpdates)!n.durable&&!this.entries.has(t)&&e.push(t);return e}addUnsyncedWorkListener(e){return this.unsyncedWorkListeners.add(e),()=>{this.unsyncedWorkListeners.delete(e)}}emitUnsyncedWork(){for(let e of this.unsyncedWorkListeners)try{e()}catch(e){this.emitStructuredClientRecoveryEvent({event:`ok-pool-unsynced-work-listener-threw`,error:e instanceof Error?e.message:String(e)})}}recycle(e){this.recycleDisconnectedEntry(e)}dispose(){for(let e of this._entries.values())this.destroyEntry(e);this._entries.clear(),this.lruOrder=[],this.activeDocName=null,this.visibleDocNames.clear(),this.onChange=null,this.bufferedUpdates.clear(),this.pendingClears.clear(),this.clearFailures.clear(),this.handledStaleClaims.clear(),this.docLineageEpochs.clear(),this.docLineageEpochsEnvelopeConsumed=!1,this.onBranchMismatch=null,this.branchMismatchInFlight=null,this.mismatchInFlight=null,this.onRenameRedirect=null,this.onDocDeleted=null,this.evictListeners.clear(),this.serverRestartRecoveryState=uK,this.cachedServerInstanceId=null,this.pendingServerInstanceKnown=null,this.tabIdentity=null,this.recoveryMismatchStaleClaim=void 0,this.unsyncedWorkListeners.clear(),this.flushOnHideEnabled=!0}evictLru(){for(let e of this.lruOrder)if(!this.isProtected(e))return X(`ok/pool/evict-lru`,{docName:e}),this.close(e),!0;return!1}destroyEntry(e){if(e.kind===`tearing-down`)return;let t=e.observerCleanup,n=e.observerFireCounterCleanup,r=e.persistence,i=e.pendingRecycleTimer,a=e.docName,o=e;o.kind=`tearing-down`,o.persistence=null,o.observerCleanup=null,o.observerFireCounterCleanup=null,o.pendingRecycleTimer=null,o.serverDrivenCloseReauthInFlight=!1,o.serverDrivenCloseReauthAttempts=0,i&&clearTimeout(i),sK(a),this.fireEvict(a);try{t?.()}catch(e){console.warn(`[ProviderPool] observer cleanup threw for ${a}:`,e)}try{n?.()}catch(e){console.warn(`[ProviderPool] observer-fire-counter cleanup threw for ${a}:`,e)}r!==null&&r.destroy().catch(e=>{console.warn(`[ProviderPool] persistence destroy failed for ${a}:`,e)});try{o.provider.destroy()}catch(e){console.warn(`[ProviderPool] Provider destroy failed for ${a}:`,e)}}recycleDisconnectedEntry(e){let t=this.entries.get(e);if(t?.kind!==`active`)return;let n=this.activeDocName===e;if(X(`ok/pool/recycle-disconnected`,{docName:e,wasActive:n}),this.emitStructuredClientBreadcrumb({event:`ok-pool-recycle-entry`,docName:e,wasActive:n}),this.destroyEntry(t),this._entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),n){this.open(e)&&this.setActive(e);return}this.notify()}},OK=Ni(),kK=!1;function AK(e){kK||(kK=!0,console.warn(`[principal-fetch] failed to resolve principal — falling back to random identity.`,e))}var jK=(0,Z.createContext)(null),MK=/\.(md|mdx)$/i,NK=null;function PK(e){return NK||(NK=new DK(EK,e,{storageNamespace:ta()?.contentDir??null}),kp(NK)),NK}var FK={activeDocName:null,activeProvider:null,syncState:`connecting`,serverRestartRecovery:{kind:`idle`},poolEntries:[]};function IK(){if(typeof window>`u`)return null;let e=window.okDesktop;return e?.config.mode===`editor`?e:null}function LK(){return typeof window>`u`?null:dh(window.okDesktop?.config.mode,window.location.origin)}function RK(){if(typeof window>`u`)return sh(null);let e=LK();return e?fh(window.localStorage===void 0?null:window.localStorage,e):sh(null)}var zK=`new-tab:`,BK=`new-tab:blob-runner:`,VK={files:zK,"blob-runner":BK};function HK(e){return UK(e)?`blob-runner`:`files`}function UK(e){return e?.startsWith(BK)??!1}function WK(e){let t=Km(e);switch(t.kind){case`doc`:return pa(t.docName);case`folder`:return aa(t.folderPath);case`asset`:return ca(t.assetPath);case`skill-file`:return da({scope:t.scope,name:t.name,path:t.path});case`skill-preview`:return la({flavor:t.flavor,source:t.source,name:t.name,subtitle:t.subtitle,level:t.level})}}function GK(e){typeof window<`u`&&!ra(window.location.hash,e)&&(uf(e),window.location.hash=e)}function KK(e){if(!e)throw Error(`removal reconciler is not initialized`);return e}function qK(e){let t=Km(e);switch(t.kind){case`doc`:return{kind:`doc`,target:t.docName,docName:t.docName};case`folder`:return{kind:`folder`,target:t.folderPath,folderPath:t.folderPath};case`asset`:return tq(t.assetPath);case`skill-file`:return{kind:`skill-file`,target:`${t.scope}/${t.name}${t.host?`:${t.host}`:``}/${t.path}`,scope:t.scope,name:t.name,path:t.path,...t.host?{host:t.host}:{}};case`skill-preview`:return{kind:`skill-preview`,target:`${t.flavor}/${t.source}/${t.name}`,flavor:t.flavor,source:t.source,name:t.name,subtitle:t.subtitle,level:t.level}}}function JK(e){return e.activeNewTabId!==null||e.activeTabId===null?e.activeTarget===null?e:{...e,activeTarget:null}:(e.activeTarget?Gm(e.activeTarget):null)===e.activeTabId?e:{...e,activeTarget:qK(e.activeTabId)}}function YK(e){return{...e,panes:e.panes.map(JK)}}function XK(){let e=Os()?sh(null):RK();return YK(Gp({panes:e.panes,focusedPaneId:e.focusedPaneId}))}function ZK(e){return!e.activeTarget||e.activeTarget.kind===`large-file`?null:lo(e.activeTarget)}function QK(e){let t=new Set;for(let n of e.panes){let e=ZK(n);e&&t.add(e)}return t}function $K(e){let t=ua(e);if(t)return Um(t);let n=na(e);if(n)return Fm(n);let r=ma(e);if(r)return Lm(r);let i=ia(e);if(!i)return null;let a=i.trim();if(/\/+$/.test(a)){let e=a.replace(/\/+$/g,``);return e?Hm(e):null}return Vm(i)}function eq(e,t,n){return!e||!n||!ra(t,pa(e))||MK.test(e)||!MK.test(n)?!1:n.replace(MK,``)===e}function tq(e){return{kind:`asset`,target:e,assetPath:e,mediaKind:R(e.split(`.`).pop()??``)}}function nq(e){switch(e.kind){case`doc`:return`doc:${e.docName}`;case`folder-index`:return`folder-index:${e.docName}:${e.folderPath}:${e.noteKind}`;case`folder`:return`folder:${e.folderPath}`;case`asset`:return`asset:${e.assetPath}:${e.mediaKind??``}`;case`skill-file`:return`skill-file:${e.scope}:${e.name}:${e.path}`;case`skills`:return`skills:hub`;case`skill-preview`:return`skill-preview:${e.flavor}:${e.source}:${e.name}:${e.subtitle}:${e.path??``}`;case`large-file`:return`large-file:${e.docName}:${e.size}:${e.limit}`;case`missing`:return`missing:${e.target}`}}function rq(e,t){return e===t?!0:!e||!t?!1:nq(e)===nq(t)}function iq(e,t){return e===t?!0:e.activeDocName!==t.activeDocName||e.activeProvider!==t.activeProvider||e.syncState!==t.syncState||e.serverRestartRecovery!==t.serverRestartRecovery||e.poolEntries.length!==t.poolEntries.length?!1:e.poolEntries.every((e,n)=>{let r=t.poolEntries[n];return e.docName===r.docName&&e.provider===r.provider&&e.poolEventId===r.poolEventId})}function aq(e){let t=e.getActive(),n=[];for(let t of e.entries.values())n.push({docName:t.docName,provider:t.provider,lastAccessedAt:t.lastAccessedAt,poolEventId:t.poolEventId});return n.sort((e,t)=>t.lastAccessedAt-e.lastAccessedAt),{activeDocName:e.getActiveDocName(),activeProvider:t?.provider??null,syncState:t?.syncState??`connecting`,serverRestartRecovery:e.getServerRestartRecoveryState(),poolEntries:n}}function oq(e){let t=(0,Q.c)(252),{children:n}=e,[r,i]=(0,Z.useState)(FK),[a,o]=(0,Z.useState)(XK),s=(0,Z.useRef)(a),c;t[0]===a.panes?c=t[1]:(c=()=>new Map(a.panes.map(Sq)),t[0]=a.panes,t[1]=c);let[l,u]=(0,Z.useState)(c),d=(0,Z.useRef)(l),f,p,m,h;if(t[2]!==l||t[3]!==a){let e=Yp(a),n;t[8]===a?n=t[9]:(n=$p(a),t[8]=a,t[9]=n),f=n;let r;t[10]===a?r=t[11]:(r=em(a),t[10]=a,t[11]=r),p=r;let i;t[12]===a.panes?i=t[13]:(i=new Map(a.panes.map(xq)),t[12]=a.panes,t[13]=i),m=i,h=th(l.get(e.id)??[],e.openTabs,e.newTabIds),t[2]=l,t[3]=a,t[4]=f,t[5]=p,t[6]=m,t[7]=h}else f=t[4],p=t[5],m=t[6],h=t[7];let g=h,[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(1),b=(0,Z.useRef)(1),x;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(x=[],t[14]=x):x=t[14];let S=(0,Z.useRef)(x),C=(0,Z.useRef)(null),w=(0,Z.useRef)(!1),T=(0,Z.useRef)(`unread`),[E,D]=(0,Z.useState)(null),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(`doc`),[M,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(0),{collabUrl:I,terminal:L,lastError:ee,retry:R}=_o(),[te,ne]=(0,Z.useState)(null),re;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(re=[],t[15]=re):re=t[15];let ie=(0,Z.useRef)(re),ae;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(ae=function(){let e=``;do e=`pane-${b.current}`,b.current+=1;while(s.current.panes.some(t=>t.id===e));return e},t[16]=ae):ae=t[16];let oe=ae,se;t[17]===I?se=t[18]:(se=function(e,t){let n=t===void 0?!1:t,r=Yp(e);if(I!==null){let t=PK(I),n=QK(e);t.setVisibleDocNames(n);for(let e of n)t.open(e);let i=ZK(r);i?(t.open(i),t.setActive(i)):t.clearActive()}if(!n)return;let i=``;r.activeNewTabId!==null||r.activeTabId!==null&&(i=WK(r.activeTabId)),GK(i)},t[17]=I,t[18]=se);let z=se,B;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(B=function(e,t){return e.focusedPaneId!==t.focusedPaneId||e.panes.length!==t.panes.length?!1:e.panes.every((e,n)=>{let r=t.panes[n];return r!==void 0&&e.id===r.id&&e.activeTabId===r.activeTabId&&e.activeNewTabId===r.activeNewTabId&&e.previewTabId===r.previewTabId&&Math.abs(e.size-r.size)<1e-9&&rq(e.activeTarget,r.activeTarget)&&e.openTabs.join(`\0`)===r.openTabs.join(`\0`)&&e.pinnedTabIds.join(`\0`)===r.pinnedTabIds.join(`\0`)&&e.newTabIds.join(`\0`)===r.newTabIds.join(`\0`)})},t[19]=B):B=t[19];let ce=B,V;t[20]===z?V=t[21]:(V=function(e,t){let n=t===void 0?!1:t,r=YK(Jp(e));if(ce(s.current,r)){z(s.current,n);return}s.current=r;let i=new Set(r.panes.map(bq));for(let e of d.current.keys())i.has(e)||d.current.delete(e);for(let e of r.panes)d.current.set(e.id,th(d.current.get(e.id)??[],e.openTabs,e.newTabIds));u(new Map(d.current)),o(e=>e===r?e:r),z(r,n)},t[20]=z,t[21]=V);let H=V,U;t[22]===H?U=t[23]:(U=function(e,t,n){let r=n===void 0?{}:n,i=s.current;if(!i.panes.some(t=>t.id===e))return;let a=tm(i,e,t);H(r.focus?{...a,focusedPaneId:e}:a,r.updateHash)},t[22]=H,t[23]=U);let W=U,le=YK(om(a,l)),G=Yp(le),ue;t[24]!==I||t[25]!==H||t[26]!==_?(ue=()=>{if(I===null||_)return;if(Os()){ks(),cf(),T.current=`suppressed`,v(!0);return}let e=!1,t=IK(),n=LK(),r=typeof localStorage<`u`?localStorage:null;return(t?t.project.getSessionState():Promise.resolve(n?fh(r,n):sh(null))).then(t=>{if(T.current=`applied`,e)return;let n=sh(t);if(w.current)return;let r=s.current,i=YK(Gp({panes:n.panes,focusedPaneId:n.focusedPaneId})),a=i.focusedPaneId;for(let e of r.panes)for(let t of e.openTabs){let n=Qp(i,t);if(n){if(!n.openTabs.includes(t)){i=tm(i,n.id,n=>({...n,openTabs:[...n.openTabs,t],pinnedTabIds:e.pinnedTabIds.includes(t)?[...n.pinnedTabIds,t]:n.pinnedTabIds}));continue}e.pinnedTabIds.includes(t)&&!n.pinnedTabIds.includes(t)&&(i=tm(i,n.id,e=>({...e,pinnedTabIds:[...e.pinnedTabIds,t]})));continue}i=tm(i,a,n=>({...n,openTabs:[...n.openTabs,t],pinnedTabIds:e.pinnedTabIds.includes(t)?[...n.pinnedTabIds,t]:n.pinnedTabIds}))}let o=Yp(r);o.newTabIds.length>0&&(i=tm(i,a,e=>({...e,newTabIds:[...new Set([...e.newTabIds,...o.newTabIds])],activeNewTabId:o.activeNewTabId,activeTabId:o.activeNewTabId?null:e.activeTabId,activeTarget:o.activeNewTabId?null:e.activeTarget}))),i=nm(i,r,n);let c=window.location.hash,l=$K(c),u=l?Qp(i,l):null;if(u&&l&&o.activeNewTabId===null){let e=Qp(r,l),t=e?.activeTabId===l?e.activeTarget:null;i={...tm(i,u.id,e=>JK({...e,activeTabId:l,activeNewTabId:null,activeTarget:t})),focusedPaneId:u.id}}let f=ia(window.location.hash),p=Yp(i).activeTabId,m=p?WK(p):null,h=p?qm(p):null,g=f===null&&window.location.hash.length===0||m!==null&&ra(m,window.location.hash)||eq(f,window.location.hash,h);i=YK(Jp(i));for(let e of i.panes)d.current.set(e.id,[...e.openTabs,...e.newTabIds]);H(i,g&&p!==null)}).catch(yq).finally(()=>{e||v(!0)}),()=>{e=!0}},t[24]=I,t[25]=H,t[26]=_,t[27]=ue):ue=t[27];let K;t[28]!==I||t[29]!==_?(K=[I,_],t[28]=I,t[29]=_,t[30]=K):K=t[30],(0,Z.useEffect)(ue,K);let de,fe;t[31]!==f.length||t[32]!==_||t[33]!==a?(de=()=>{if(!_||!Jm(T.current,f.length))return;let e=lh(a),t=IK();if(t){t.project.setSessionState(e).catch(vq);return}let n=LK();n&&ph(typeof localStorage<`u`?localStorage:null,n,e)},fe=[f.length,_,a],t[31]=f.length,t[32]=_,t[33]=a,t[34]=de,t[35]=fe):(de=t[34],fe=t[35]),(0,Z.useEffect)(de,fe);let pe;t[36]===_?pe=t[37]:(pe=function(){_||(w.current=!0)},t[36]=_,t[37]=pe);let q=pe,me;t[38]!==H||t[39]!==q?(me=function(e,t,n){let r=t===void 0?[]:t,i=n===void 0?[]:n;q();let a=t=>rh([t],e,2**53-1,r,[],i)[0]??null;for(let[t,n]of d.current)d.current.set(t,ih(n,e,r,i));let o=Yp(s.current).activeTabId,c=gm(s.current,{type:`remap-tabs`,remap:a}).workspace,l=Yp(c).activeTabId;H(c,o!==null&&o!==l)},t[38]=H,t[39]=q,t[40]=me):me=t[40];let J=me,he;t[41]===I?he=t[42]:(he=function(e,t){if(I===null)return;let n=new Set;for(let e of $p(t)){let t=qm(e);t&&n.add(t)}let r=PK(I);for(let t of e){let e=qm(t);e&&!n.has(e)&&r.close(e)}},t[41]=I,t[42]=he);let ge=he,_e;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(_e=function(e,t,n){return e.activeTabId&&t.has(e.activeTabId)?e.activeTabId:e.activeNewTabId&&t.has(e.activeNewTabId)&&e.activeNewTabId,n},t[43]=_e):_e=t[43];let ve=_e,ye;t[44]!==ge||t[45]!==H||t[46]!==q?(ye=(e,t,n)=>{let r=n===void 0?{}:n,i=s.current.panes.find(t=>t.id===e);if(!i)return;let a=new Set(r.force?t.filter(e=>i.openTabs.includes(e)):eh(t,i.pinnedTabIds).filter(e=>i.openTabs.includes(e)));if(a.size===0)return;if(q(),!r.force)for(let t of i.openTabs.filter(e=>a.has(e)))S.current=_m(S.current,{paneId:e,tabId:t},50);let o=s.current.focusedPaneId===e,c=ve(i,a,gm(s.current,{type:`close-tabs`,paneId:e,tabIds:[...a]}).workspace);ge(a,c),H(c,o)},t[44]=ge,t[45]=H,t[46]=q,t[47]=ye):ye=t[47];let be=ye,xe;t[48]===be?xe=t[49]:(xe=function(e,t){let n=t===void 0?{}:t,r=new Set(e.filter(_q));for(let e of s.current.panes.map(gq)){let t=s.current.panes.find(t=>t.id===e);if(!t)continue;let i=t.openTabs.filter(e=>r.has(e));i.length>0&&be(e,i,n)}},t[48]=be,t[49]=xe);let Se=xe,Ce;t[50]!==Se||t[51]!==I||t[52]!==H||t[53]!==J?(Ce=function(){return pf({captureRenameSnapshots:cp,getActivePoolDocName:()=>I===null?null:PK(I).getActiveDocName(),hasPooledDocument:e=>I!==null&&PK(I).has(e),closeAndClear:async e=>{I!==null&&await PK(I).closeAndClearPersistence(e)},openAndActivate:e=>{if(I===null)return;let t=PK(I);t.open(e),t.setActive(e)},remapTabs:e=>{let{renamed:t,renamedFolders:n,renamedAssets:r}=e;return J(t,n,r)},closeTabs:e=>Se(e,{force:!0}),removeDocumentTab:e=>{let t=gm(s.current,{type:`prune-tabs`,keep:t=>qm(t)!==e}).workspace;H(t)},remapActiveTargetForRename:(e,t)=>ZK(Yp(s.current))===t,clearActiveTargetForRemoval:e=>{H({...s.current,panes:s.current.panes.map(t=>t.activeTarget&&lo(t.activeTarget)===e?{...t,activeTarget:null}:t)})},navigateToDocument:hq,navigateHome:()=>{let e=Yp(s.current);GK(e.activeTabId?WK(e.activeTabId):``)},showDocumentDeletedState:mq})},t[50]=Se,t[51]=I,t[52]=H,t[53]=J,t[54]=Ce):Ce=t[54];let we=Ce,Te;t[55]===we?Te=t[56]:(Te=()=>{C.current=we()},t[55]=we,t[56]=Te),(0,Z.useEffect)(Te);let Ee;t[57]!==I||t[58]!==z?(Ee=()=>{if(I===null)return;let e=!1,t=PK(I),n=()=>{i(e=>{let n=aq(t);return iq(e,n)?e:n})};return n(),z(s.current),t.setOnBranchMismatch(()=>{let{times:e,escalate:n}=Hd(ie.current,Date.now());return ie.current=e,n&&ne({kind:`refused`,at:Date.now()}),of(t)}),t.setOnRenameRedirect(e=>{let{fromDocName:t,toDocName:n,hadOpenProvider:r}=e;(async()=>{let e;try{await KK(C.current).reconcileAuthRename({fromDocName:t,toDocName:n})}catch(r){let i=r;e=i,console.warn(JSON.stringify({event:`removal-cleanup-error`,kind:`renamed`,fromDocName:t,toDocName:n,message:String(i instanceof Error?i.message:i)}))}console.info(JSON.stringify({event:`removal.cleanup`,kind:`renamed`,fromDocName:t,toDocName:n,hadOpenProvider:r,hadStaleIdb:!r,source:`auth-rejection`,errored:e!==void 0}))})()}),t.setOnDocDeleted(e=>{let{docName:t,hadOpenProvider:n}=e;(async()=>{let e;try{await KK(C.current).reconcileAuthRemoval({docName:t})}catch(n){let r=n;e=r,console.warn(JSON.stringify({event:`removal-cleanup-error`,kind:`deleted`,docName:t,message:String(r instanceof Error?r.message:r)}))}console.info(JSON.stringify({event:`removal.cleanup`,kind:`deleted`,fromDocName:t,hadOpenProvider:n,hadStaleIdb:!n,source:`auth-rejection`,errored:e!==void 0}))})()}),t.setOnChange(n),fetch(`/api/principal`).then(pq).then(n=>{if(e)return;let r=qe.safeParse(n);r.success?(t.setTabIdentity({principalId:r.data.id,tabSessionId:OK}),D(r.data)):AK(r.error)}).catch(t=>{e||AK(t)}),of(t),()=>{e=!0,t.setOnChange(null),t.setOnRenameRedirect(null),t.setOnDocDeleted(null)}},t[57]=I,t[58]=z,t[59]=Ee):Ee=t[59];let De;t[60]===I?De=t[61]:(De=[I],t[60]=I,t[61]=De),(0,Z.useEffect)(Ee,De);let Oe=function(e,t){let n=t===void 0?!0:t,r=s.current.panes.find(t=>t.id===e);if(!r)return;let i=le.panes.find(t=>t.id===e),a=s.current;if(i?.activeTabId&&i.activeTabId!==r.activeTabId)a=gm(a,{type:`activate-tab`,paneId:e,tabId:i.activeTabId}).workspace;else if(i?.activeNewTabId&&i.activeNewTabId!==r.activeNewTabId)a=tm(a,e,e=>({...e,activeTabId:null,activeNewTabId:i.activeNewTabId,activeTarget:null}));else if(a.focusedPaneId===e)return;H(Xp({...a,panes:a.panes.map(t=>t.id===e?JK(t):t)},e),n)},ke;t[62]===H?ke=t[63]:(ke=function(e,t,n){let r=n===void 0?!0:n,i=s.current.panes.find(t=>t.id===e);i&&i.openTabs.includes(t)&&H(gm(s.current,{type:`activate-tab`,paneId:e,tabId:t}).workspace,r)},t[62]=H,t[63]=ke);let Ae=ke,Y,je,Me,Ne,Pe;if(t[64]!==ge||t[65]!==I||t[66]!==H||t[67]!==q||t[68]!==W){je=e=>{X(`ok/nav/open-document`,{docName:e,transition:!1}),Ne({kind:`doc`,target:e,docName:e},{disposition:`permanent`,consumeActiveNewTab:!0})},Me=e=>{X(`ok/nav/open-document`,{docName:e,transition:!1}),je(e)};let e;t[74]!==H||t[75]!==W?(e=function(e,t){let n=s.current.panes.find(t=>t.id===e);if(!n)return;let r=(n.activeNewTabId!==null&&HK(n.activeNewTabId)===t?n.activeNewTabId:null)??n.newTabIds.find(e=>HK(e)===t);if(r){W(n.id,e=>({...e,activeNewTabId:r,activeTabId:null,activeTarget:null}),{updateHash:!0});return}let i=`${VK[t]}${y.current}`;y.current+=1,H(gm(s.current,{type:`open-new-tab`,paneId:n.id,tabId:i}).workspace,!0)},t[74]=H,t[75]=W,t[76]=e):e=t[76],Y=e,Ne=(e,t,n,r)=>{let i=t===void 0?{}:t,a=r===void 0?`activate-owner`:r;if(I===null)return;i.deliberate!==!1&&Ga();let o=n??s.current.focusedPaneId,c=PK(I);if(e.kind===`skills`){Y(o,`files`);return}let l=lo(e),u=Gm(e);if(!u)return;if(l&&e.kind!==`large-file`){let e=c.open(l);if(!e)return;zd(l,e.poolEventId)}let d=gm(s.current,{type:`open-target`,paneId:o,tabId:u,target:e,disposition:i.disposition??(i.tabBehavior===`replace-active`?`preview`:`permanent`),consumeActiveNewTab:i.consumeActiveNewTab??!0,existingTabBehavior:a});d.replacedPreviewTabId!==null&&q();let f=d.workspace;if(e.kind===`skill-preview`&&e.level){let t=new Set(Rm($p(f),{flavor:e.flavor,name:e.name,subtitle:e.subtitle??``,level:e.level},u));if(t.size>0){q();for(let e of f.panes.map(fq)){let n=f.panes.find(t=>t.id===e);if(!n)continue;let r=n.openTabs.filter(e=>t.has(e));r.length!==0&&(f=gm(f,{type:`close-tabs`,paneId:e,tabIds:r}).workspace)}ge(t,f)}}H(f)},Pe=(e,t)=>{Ne(e,t)},t[64]=ge,t[65]=I,t[66]=H,t[67]=q,t[68]=W,t[69]=Y,t[70]=je,t[71]=Me,t[72]=Ne,t[73]=Pe}else Y=t[69],je=t[70],Me=t[71],Ne=t[72],Pe=t[73];let Fe=Pe,Ie;t[77]===Ne?Ie=t[78]:(Ie=(e,t,n)=>{Ne(t,n,e,`open-in-pane`)},t[77]=Ne,t[78]=Ie);let Le=Ie,Re;t[79]===Ne?Re=t[80]:(Re=(e,t)=>{X(`ok/nav/open-target`,{docName:lo(e),kind:e.kind,transition:!1}),Ne(e,t)},t[79]=Ne,t[80]=Re);let ze=Re,Be;t[81]===Ae?Be=t[82]:(Be=e=>Ae(s.current.focusedPaneId,e),t[81]=Ae,t[82]=Be);let Ve=Be,He;t[83]===Y?He=t[84]:(He=()=>{Ga(),Y(s.current.focusedPaneId,`blob-runner`)},t[83]=Y,t[84]=He);let Ge=He,Ke;t[85]===H?Ke=t[86]:(Ke=e=>{if(!s.current.panes.find(t=>t.id===e))return;let t=`${zK}${y.current}`;y.current+=1,H(gm(s.current,{type:`open-new-tab`,paneId:e,tabId:t}).workspace,!0)},t[85]=H,t[86]=Ke);let Je=Ke,Ye;t[87]===Je?Ye=t[88]:(Ye=()=>Je(s.current.focusedPaneId),t[87]=Je,t[88]=Ye);let Xe=Ye,Ze;t[89]===be?Ze=t[90]:(Ze=(e,t)=>be(e,[t]),t[89]=be,t[90]=Ze);let Qe=Ze,$e;t[91]===Qe?$e=t[92]:($e=e=>Qe(s.current.focusedPaneId,e),t[91]=Qe,t[92]=$e);let et=$e,tt;t[93]!==H||t[94]!==q?(tt=(e,t)=>{q();let n=s.current.panes.find(t=>t.id===e);if(!n?.newTabIds.includes(t))return;let r=n.activeNewTabId===t,i=gm(s.current,{type:`close-tabs`,paneId:e,tabIds:[t]}).workspace;H(i,s.current.focusedPaneId===e&&r)},t[93]=H,t[94]=q,t[95]=tt):tt=t[95];let nt=tt,rt;t[96]===nt?rt=t[97]:(rt=e=>nt(s.current.focusedPaneId,e),t[96]=nt,t[97]=rt);let it=rt,at;t[98]!==nt||t[99]!==Qe?(at=()=>{let e=Yp(s.current),t=e.activeNewTabId;if(t)return nt(e.id,t),!0;let n=new Set(e.pinnedTabIds),r=new Set(e.openTabs.filter(e=>!n.has(e))),i=e.activeTabId&&r.has(e.activeTabId)?e.activeTabId:null,a=d.current.get(e.id)??[],o=i??a.find(e=>r.has(e));if(o)return Qe(e.id,o),!0;let c=new Set(e.newTabIds),l=a.find(e=>c.has(e));if(l)return nt(e.id,l),!0;let u=s.current.panes.find(dq);if(!u)return!1;let f=u.activeNewTabId??u.newTabIds[0]??null;if(f)return nt(u.id,f),!0;let p=(u.activeTabId&&!u.pinnedTabIds.includes(u.activeTabId)?u.activeTabId:null)??u.openTabs.find(e=>!u.pinnedTabIds.includes(e));return p?(Qe(u.id,p),!0):!1},t[98]=nt,t[99]=Qe,t[100]=at):at=t[100];let ot=at,st;t[101]===H?st=t[102]:(st=function(e,t){s.current.panes.find(t=>t.id===e)?.newTabIds.includes(t)&&H(gm(s.current,{type:`activate-tab`,paneId:e,tabId:t}).workspace,!0)},t[101]=H,t[102]=st);let ct=st,lt;t[103]===H?lt=t[104]:(lt=function(e,t){s.current.panes.find(t=>t.id===e)?.openTabs.includes(t)&&H(gm(s.current,{type:`pin-tab`,paneId:e,tabId:t}).workspace)},t[103]=H,t[104]=lt);let ut=lt,ft;t[105]!==H||t[106]!==q?(ft=function(e,t){s.current.panes.find(t=>t.id===e)?.pinnedTabIds.includes(t)&&(q(),H(gm(s.current,{type:`unpin-tab`,paneId:e,tabId:t}).workspace))},t[105]=H,t[106]=q,t[107]=ft):ft=t[107];let pt=ft,mt;t[108]===H?mt=t[109]:(mt=function(e,t,n){let r=s.current.panes.find(t=>t.id===e);if(!r)return;let i=new Set([...r.openTabs,...r.newTabIds]),a=t.filter(e=>i.has(e));for(let e of[...r.openTabs,...r.newTabIds])a.includes(e)||a.push(e);d.current.set(e,a),u(new Map(d.current));let o=a.filter(e=>r.openTabs.includes(e)),c=a.filter(e=>r.newTabIds.includes(e)),l=gm(s.current,{type:`reorder-tabs`,paneId:e,tabIds:o,draggedTabId:n}).workspace;H({...l,panes:l.panes.map(t=>t.id===e?{...t,newTabIds:c}:t)})},t[108]=H,t[109]=mt);let ht=mt,gt;t[110]===H?gt=t[111]:(gt=function(e,t,n){let r=s.current.panes.find(t=>t.openTabs.includes(e)||t.newTabIds.includes(e)),i=s.current.panes.find(e=>e.id===t);if(!r||!i)return;let a=th(d.current.get(t)??[],i.openTabs,i.newTabIds).filter(t=>t!==e),o=Math.max(0,Math.min(n,a.length)),c=sm(a,r.newTabIds.includes(e)?i.newTabIds:i.openTabs,o),l=gm(s.current,{type:`move-tab`,tabId:e,paneId:t,index:c}).workspace;r.id!==t&&(d.current.set(r.id,th(d.current.get(r.id)??[],r.openTabs,r.newTabIds).filter(t=>t!==e)),a.splice(o,0,e),d.current.set(t,a)),H(l,!0)},t[110]=H,t[111]=gt);let _t=gt,vt;t[112]===H?vt=t[113]:(vt=function(e,t,n){let r=s.current.panes.find(t=>t.openTabs.includes(e)||t.newTabIds.includes(e));if(!r)return null;let i=oe(),a=gm(s.current,{type:`split-tab`,tabId:e,paneId:t,side:n,newPaneId:i}).workspace,o=a.panes.find(e=>e.id===i);return o?(d.current.set(r.id,th(d.current.get(r.id)??[],r.openTabs,r.newTabIds).filter(t=>t!==e)),d.current.set(o.id,[e]),H(a,!0),o.id):null},t[112]=H,t[113]=vt);let yt=vt,bt;t[114]===yt?bt=t[115]:(bt=function(e,t){let n=Qp(s.current,e);return n?yt(e,n.id,t):null},t[114]=yt,t[115]=bt);let xt=bt,St;t[116]===H?St=t[117]:(St=function(e){e.size!==0&&H(gm(s.current,{type:`resize-panes`,sizes:s.current.panes.map(t=>e.get(t.id)??t.size)}).workspace)},t[116]=H,t[117]=St);let Ct=St,wt;t[118]===H?wt=t[119]:(wt=function(e,t){H(gm(s.current,{type:`promote-preview`,paneId:e,tabId:t}).workspace)},t[118]=H,t[119]=wt);let Tt=wt,Et;t[120]===H?Et=t[121]:(Et=function(){H(gm(s.current,{type:`promote-all-previews`}).workspace)},t[120]=H,t[121]=Et);let Dt=Et,Ot;t[122]===Tt?Ot=t[123]:(Ot=function(e){let t=Qp(s.current,e);!t||t.previewTabId!==e||Tt(t.id,e)},t[122]=Tt,t[123]=Ot);let kt=Ot,At,jt;t[124]===kt?(At=t[125],jt=t[126]):(At=()=>hh(kt),jt=[kt],t[124]=kt,t[125]=At,t[126]=jt),(0,Z.useEffect)(At,jt);let Mt,Nt;t[127]===ot?(Mt=t[128],Nt=t[129]):(Mt=()=>dt(e=>{e===`close-active-tab-or-window`&&(Wa(),ot()||window.close())}),Nt=[ot],t[127]=ot,t[128]=Mt,t[129]=Nt),(0,Z.useEffect)(Mt,Nt);let Pt=ZK(G),Ft;t[130]!==Pt||t[131]!==r.activeDocName||t[132]!==r.activeProvider||t[133]!==r.poolEntries?(Ft=r.activeDocName===Pt?r.activeProvider:r.poolEntries.find(e=>e.docName===Pt)?.provider??null,t[130]=Pt,t[131]=r.activeDocName,t[132]=r.activeProvider,t[133]=r.poolEntries,t[134]=Ft):Ft=t[134];let It=Ft,Lt;t[135]===Y?Lt=t[136]:(Lt=()=>{let e=Yp(s.current);e.activeNewTabId===null&&(e.openTabs.length===0&&e.newTabIds.length===0||Y(e.id,`files`))},t[135]=Y,t[136]=Lt);let Rt;t[137]!==I||t[138]!==H||t[139]!==q?(Rt=e=>{q();let t=ZK(Yp(s.current))===e,n=gm(s.current,{type:`prune-tabs`,keep:t=>qm(t)!==e}).workspace;I!==null&&PK(I).close(e),H(n,t)},t[137]=I,t[138]=H,t[139]=q,t[140]=Rt):Rt=t[140];let zt;t[141]===ut?zt=t[142]:(zt=e=>ut(s.current.focusedPaneId,e),t[141]=ut,t[142]=zt);let Bt;t[143]===pt?Bt=t[144]:(Bt=e=>pt(s.current.focusedPaneId,e),t[143]=pt,t[144]=Bt);let Vt;t[145]===ht?Vt=t[146]:(Vt=(e,t)=>ht(s.current.focusedPaneId,e,t),t[145]=ht,t[146]=Vt);let Ht=G.activeNewTabId!==null,Ut;t[147]===ct?Ut=t[148]:(Ut=e=>ct(s.current.focusedPaneId,e),t[147]=ct,t[148]=Ut);let Wt;t[149]===H?Wt=t[150]:(Wt=()=>{let e=[...S.current];for(;e.length>0;){let t=e.shift();if(!t)continue;if(Qp(s.current,t.tabId)){S.current=e;continue}let n=s.current.panes.find(e=>e.id===t.paneId)??Yp(s.current);S.current=e;let r=qK(t.tabId);H(gm(s.current,{type:`open-target`,paneId:n.id,tabId:t.tabId,target:r,disposition:`permanent`,consumeActiveNewTab:!1}).workspace,!0);return}S.current=[]},t[149]=H,t[150]=Wt);let Gt;t[151]!==ge||t[152]!==H||t[153]!==q?(Gt=e=>{let{pages:t,folderPaths:n,assetPaths:r,filePaths:i}=e,a=new Set(s.current.panes.flatMap(uq)),o=typeof window<`u`?ia(window.location.hash):null,c=new Set(s.current.panes.flatMap(lq)),l=$p(s.current),u=nh(l,{pages:new Set([...t,...a]),folderPaths:n,assetPaths:r,filePaths:i,keepMissingDocName:null,keepHashDocName:o,keepFolderPaths:c});if(u.length===l.length)return;let d=new Set(u),f=l.filter(e=>!d.has(e));q();let p=Yp(s.current).activeTabId,m=p!==null&&!d.has(p),h=gm(s.current,{type:`prune-tabs`,keep:e=>d.has(e)}).workspace;ge(f,h),H(h,m)},t[151]=ge,t[152]=H,t[153]=q,t[154]=Gt):Gt=t[154];let Kt,qt;t[155]===we?(Kt=t[156],qt=t[157]):(Kt=e=>we().reconcileLocalRename(e),qt=e=>we().reconcileLocalRemoval(e),t[155]=we,t[156]=Kt,t[157]=qt);let Jt,Yt;t[158]===I?(Jt=t[159],Yt=t[160]):(Jt=e=>{I!==null&&PK(I).recycle(e)},Yt=e=>I===null?null:PK(I).prewarm(e)?.poolEventId??null,t[158]=I,t[159]=Jt,t[160]=Yt);let Xt,Zt,Qt,$t,en;t[161]===I?(Xt=t[162],Zt=t[163],Qt=t[164],$t=t[165],en=t[166]):(Xt=e=>{I!==null&&PK(I).setExpectedServerInstanceId(e)},Zt=async e=>{if(I===null)return;let t=PK(I);t.setObservedBranch(e),ie.current=[],ne({kind:`branch-switch`,branch:e,at:Date.now()}),await Xd(t,e),We([`files`,`backlinks`,`graph`]),Ue(e)},Qt=async e=>{if(I===null)return;let t=PK(I);t.compareAndUpdateObservedBranch(e)&&(ie.current=[],ne({kind:`branch-switch`,branch:e,at:Date.now()}),await Xd(t,e),We([`files`,`backlinks`,`graph`]),Ue(e))},$t=(e,t)=>{I!==null&&PK(I).observeDiskAck(e,t)},en=async()=>{I!==null&&await of(PK(I))},t[161]=I,t[162]=Xt,t[163]=Zt,t[164]=Qt,t[165]=$t,t[166]=en);let tn;t[167]===Symbol.for(`react.memo_cache_sentinel`)?(tn=()=>ne(null),t[167]=tn):tn=t[167];let nn;t[168]!==Pt||t[169]!==M||t[170]!==A?(nn=(e,t)=>{if(!Pt&&t){GK(pa(t)),N(e),j(`agent`),F(cq);return}if(A===`agent`&&M===e&&Md()){j(`doc`);return}N(e),j(`agent`),F(sq)},t[168]=Pt,t[169]=M,t[170]=A,t[171]=nn):nn=t[171];let rn;t[172]===Symbol.for(`react.memo_cache_sentinel`)?(rn=()=>{j(`doc`),N(null)},t[172]=rn):rn=t[172];let an;t[173]!==ct||t[174]!==Ve||t[175]!==Ae||t[176]!==Pt||t[177]!==It||t[178]!==ot||t[179]!==it||t[180]!==nt||t[181]!==et||t[182]!==Qe||t[183]!==Se||t[184]!==be||t[185]!==ee||t[186]!==L||t[187]!==I||t[188]!==te||t[189]!==M||t[190]!==P||t[191]!==A||t[192]!==Oe||t[193]!==xt||t[194]!==_t||t[195]!==Ge||t[196]!==je||t[197]!==Me||t[198]!==Xe||t[199]!==Je||t[200]!==f||t[201]!==Fe||t[202]!==Le||t[203]!==ze||t[204]!==ut||t[205]!==p||t[206]!==m||t[207]!==E||t[208]!==Dt||t[209]!==Tt||t[210]!==ht||t[211]!==Ct||t[212]!==R||t[213]!==r.poolEntries||t[214]!==r.serverRestartRecovery||t[215]!==r.syncState||t[216]!==yt||t[217]!==G.activeNewTabId||t[218]!==G.activeTabId||t[219]!==G.activeTarget||t[220]!==G.newTabIds||t[221]!==le.focusedPaneId||t[222]!==le.panes||t[223]!==O||t[224]!==Lt||t[225]!==Rt||t[226]!==zt||t[227]!==Bt||t[228]!==Vt||t[229]!==Ht||t[230]!==Ut||t[231]!==Wt||t[232]!==Gt||t[233]!==Kt||t[234]!==qt||t[235]!==Jt||t[236]!==Yt||t[237]!==Xt||t[238]!==Zt||t[239]!==Qt||t[240]!==$t||t[241]!==en||t[242]!==nn||t[243]!==_||t[244]!==pt||t[245]!==g||t[246]!==l||t[247]!==a?(an={principal:E,activeTarget:G.activeTarget,activeTabId:G.activeTabId,activeDocName:Pt,activeProvider:It,workspace:a,panes:le.panes,focusedPaneId:le.focusedPaneId,focusPane:Oe,activateTabInPane:Ae,activateNewTabInPane:ct,openNewTabInPane:Je,closeTabInPane:Qe,closeTabsInPane:be,closeNewTabInPane:nt,pinTabInPane:ut,unpinTabInPane:pt,reorderTabsInPane:ht,moveTabToPane:_t,splitTab:yt,moveTabToNewPane:xt,resizePanes:Ct,openTabs:f,pinnedTabIds:p,visibleTabIdsByPane:l,previewTabIdsByPane:m,visibleTabIds:g,tabSessionLoaded:_,syncState:r.syncState,serverRestartRecovery:r.serverRestartRecovery,poolEntries:r.poolEntries,openDocument:je,openDocumentTransition:Me,openTarget:Fe,openTargetInPane:Le,openTargetTransition:ze,promoteTabInPane:Tt,promoteAllPreviewTabs:Dt,clearTarget:Lt,closeDocument:Rt,closeActiveTabOrWindow:ot,closeTab:et,pinTab:zt,unpinTab:Bt,activateTab:Ve,reorderTabs:Vt,newTabIds:G.newTabIds,activeNewTabId:G.activeNewTabId,isNewTabActive:Ht,openNewTab:Xe,openBlobRunner:Ge,activateNewTab:Ut,closeNewTab:it,reopenClosedTab:Wt,closeTabs:Se,syncOpenTabsWithKnownTargets:Gt,reconcileLocalRename:Kt,reconcileLocalRemoval:qt,recycleDocument:Jt,prewarm:Yt,systemProvider:O,setSystemProvider:k,updateServerInstanceId:Xt,onBranchSwitched:Zt,observeBranch:Qt,observeDiskAck:$t,refreshServerInfo:en,collabUrl:I,collabTerminal:L,contentRecycleNotice:te,dismissContentRecycleNotice:tn,collabLastError:ee,retryCollab:R,docPanelMode:A,docPanelAgentId:M,docPanelExpandSignal:P,openActivityPanel:nn,closeActivityPanel:rn},t[173]=ct,t[174]=Ve,t[175]=Ae,t[176]=Pt,t[177]=It,t[178]=ot,t[179]=it,t[180]=nt,t[181]=et,t[182]=Qe,t[183]=Se,t[184]=be,t[185]=ee,t[186]=L,t[187]=I,t[188]=te,t[189]=M,t[190]=P,t[191]=A,t[192]=Oe,t[193]=xt,t[194]=_t,t[195]=Ge,t[196]=je,t[197]=Me,t[198]=Xe,t[199]=Je,t[200]=f,t[201]=Fe,t[202]=Le,t[203]=ze,t[204]=ut,t[205]=p,t[206]=m,t[207]=E,t[208]=Dt,t[209]=Tt,t[210]=ht,t[211]=Ct,t[212]=R,t[213]=r.poolEntries,t[214]=r.serverRestartRecovery,t[215]=r.syncState,t[216]=yt,t[217]=G.activeNewTabId,t[218]=G.activeTabId,t[219]=G.activeTarget,t[220]=G.newTabIds,t[221]=le.focusedPaneId,t[222]=le.panes,t[223]=O,t[224]=Lt,t[225]=Rt,t[226]=zt,t[227]=Bt,t[228]=Vt,t[229]=Ht,t[230]=Ut,t[231]=Wt,t[232]=Gt,t[233]=Kt,t[234]=qt,t[235]=Jt,t[236]=Yt,t[237]=Xt,t[238]=Zt,t[239]=Qt,t[240]=$t,t[241]=en,t[242]=nn,t[243]=_,t[244]=pt,t[245]=g,t[246]=l,t[247]=a,t[248]=an):an=t[248];let on=an,sn;return t[249]!==n||t[250]!==on?(sn=(0,$.jsx)(jK,{value:on,children:n}),t[249]=n,t[250]=on,t[251]=sn):sn=t[251],sn}function sq(e){return e+1}function cq(e){return e+1}function lq(e){return e.activeTarget?.kind===`folder`?[e.activeTarget.folderPath]:[]}function uq(e){return e.activeTarget?.kind===`missing`?[e.activeTarget.target]:[]}function dq(e){return e.newTabIds.length>0||e.openTabs.some(t=>!e.pinnedTabIds.includes(t))}function fq(e){return e.id}function pq(e){return e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))}function mq(e){return ct()?qd(e):!1}function hq(e){return GK(pa(e))}function gq(e){return e.id}function _q(e){return e.length>0}function vq(e){console.warn(`[editor-tabs] failed to persist tab session:`,e)}function yq(e){console.error(`[editor-tabs] failed to restore tab session:`,e)}function bq(e){return e.id}function xq(e){return[e.id,e.previewTabId]}function Sq(e){return[e.id,[...e.openTabs,...e.newTabIds]]}function Cq(){return(0,Z.use)(jK)?.openBlobRunner??null}function wq(){let e=(0,Z.use)(jK);if(!e)throw Error(`useDocumentContext must be used within <DocumentProvider />`);return e}function Tq(){let e=(0,Q.c)(3),{openDocumentTransition:t,openTargetTransition:n}=wq(),r;return e[0]!==t||e[1]!==n?(r={openDocumentTransition:t,openTargetTransition:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],r}export{Xz as $,df as $n,Yl as $r,JC as $t,cU as A,Ml as Ai,zm as An,Gu as Ar,wN as At,JB as B,cc as Bi,gp as Bn,yu as Br,rO as Bt,DW as C,Kc as Ci,_h as Cn,td as Cr,eI as Ct,EU as D,El as Di,qm as Dn,Uu as Dr,vP as Dt,fW as E,Nc as Ei,Um as En,Zu as Er,jP as Et,FH as F,Dl as Fi,ah as Fn,ku as Fr,eO as Ft,OB as G,As as Gi,Df as Gn,uu as Gr,$C as Gt,MB as H,Ps as Hi,mp as Hn,hu as Hr,Lw as Ht,jH as I,el as Ii,Gm as In,Ou as Ir,tO as It,wB as J,Bf as Jn,iu as Jr,ew as Jt,xB as K,Ds as Ki,Hf as Kn,lu as Kr,aw as Kt,AH as L,sc as Li,Wm as Ln,Du as Lr,QD as Lt,uU as M,ol as Mi,Zm as Mn,Iu as Mr,aO as Mt,oU as N,Lc as Ni,Ym as Nn,Lu as Nr,XD as Nt,nU as O,Pl as Oi,Vm as On,Wu as Or,VN as Ot,aU as P,Pc as Pi,Km as Pn,Au as Pr,ZD as Pt,pB as Q,gf as Qn,Ql as Qr,KC as Qt,_H as R,lc as Ri,np as Rn,Cu as Rr,nO as Rt,JW as S,Wc as Si,yh as Sn,Qu as Sr,FI as St,dW as T,sl as Ti,vh as Tn,Xu as Tr,MP as Tt,KB as U,Vs as Ui,tp as Un,fu as Ur,Cw as Ut,UB as V,Bs as Vi,_p as Vn,_u as Vr,iO as Vt,qB as W,Hs as Wi,Ep as Wn,du as Wr,gw as Wt,CB as X,_f as Xn,tu as Xr,HC as Xt,yB as Y,Nf as Yn,nu as Yr,YC as Yt,vB as Z,hf as Zn,eu as Zr,ZC as Zt,TG as _,$c as _i,a_ as _n,nd as _r,rL as _t,Tq as a,Ll as ai,EC as an,Ud as ar,aR as at,YW as b,Mc as bi,bg as bn,rd as br,zI as bt,GG as c,Bc as ci,xb as cn,pd as cr,iR as ct,KG as d,Uc as di,Xv as dn,yd as dr,nR as dt,ql as ei,GC as en,rf as er,Qz as et,HG as f,gl as fi,Nv as fn,dd as fr,$L as ft,DG as g,Al as gi,P_ as gn,cd as gr,aL as gt,oK as h,Cl as hi,ev as hn,vd as hr,iL as ht,wq as i,zl as ii,IC as in,Bd as ir,oR as it,iU as j,Il as ji,Hm as jn,Hu as jr,LN as jt,lU as k,_l as ki,eh as kn,Vu as kr,NN as kt,WG as l,Gc as li,gb as ln,Od as lr,rR as lt,nK as m,Fl as mi,nv as mn,ld as mr,JL as mt,PK as n,Hl as ni,QC as nn,Jd as nr,Yz as nt,Cq as o,Tl as oi,ZS as on,Rd as or,mR as ot,sK as p,jl as pi,Ov as pn,kd as pr,qL as pt,bB as q,Vf as qn,cu as qr,tw as qt,UK as r,Vl as ri,LC as rn,Yd as rr,kR as rt,wK as s,Vc as si,Cx as sn,jd as sr,fR as st,oq as t,Kl as ti,WC as tn,nf as tr,Zz as tt,UG as u,ll as ui,lb as un,fd as ur,pR as ut,ZW as v,nl as vi,Yg as vn,$u as vr,eL as vt,OW as w,wl as wi,gh as wn,id as wr,eF as wt,QW as x,Ec as xi,bh as xn,sd as xr,VI as xt,XW as y,zc as yi,Xg as yn,od as yr,nL as yt,FV as z,uc as zi,ap as zn,xu as zr,$D as zt};
|
|
110
|
+
`&&t.push(n+1);return t}function eB(e,t,n){return t<=1?0:t-1>=e.length?n:e[t-1]??n}function tB(e,t){let n=0,r=e.length-1,i=1;for(;n<=r;){let a=n+r>>1;(e[a]??0)<=t?(i=a+1,n=a+1):r=a-1}return i}function nB(e,t,n){return Math.max(t,Math.min(e,n))}function rB(e,t){let n=e=>e.replace(/\s+/g,` `).trim();return n(e)===n(t)}function iB(e,t){return t.inRange?t.tripwireOk?rB(e.content,t.text)?`exact`:e.kind===t.kind?`same-type-ordinal`:`ordinal`:`ordinal`:`clamped`}function aB(e){let t=null,n=null;function r(r){return n!==null&&t===r?n:(n={blocks:Jz(r,e).blocks,lineStarts:$z(r)},t=r,n)}return{captureFromWysiwyg(e,t,n){if(e.childCount===0)return null;let r=nB(t,0,e.content.size),i=0,a=e.childCount-1,o=0;for(let t=0;t<e.childCount;t++){let n=e.child(t).nodeSize;if(r<i+n){a=t,o=i+1;break}i+=n,o=i+1}let s=e.child(a),c={blockIndex:a,kind:Kz(s.type.name),content:s.textContent};return n?.refine&&(c.selectionInBlock=Math.max(0,r-o)),c},captureFromSource(e,t,n){let{blocks:i,lineStarts:a}=r(e);if(i.length===0)return null;let o=nB(t,0,e.length),s=Xz(i,tB(a,o));if(s===null)return null;let c=i[s];if(!c)return null;let l={blockIndex:s,kind:c.kind,content:c.text};if(n?.refine){let t=eB(a,c.start,e.length);l.selectionInBlock=Math.max(0,o-t)}return l},resolveInSource(e,{source:t,doc:n}){let{blocks:i,lineStarts:a}=r(t);if(i.length===0)return null;let o=e.blockIndex>=0&&e.blockIndex<i.length,s=Zz(n)===i.length,c=i[nB(e.blockIndex,0,i.length-1)],l=eB(a,c.start,t.length),u=Math.min(eB(a,c.end+1,t.length),t.length),d=iB(e,{inRange:o,tripwireOk:s,kind:c.kind,text:c.text}),f=l;return d===`exact`&&e.selectionInBlock!==void 0&&(f=nB(l+e.selectionInBlock,l,u)),{blockStart:l,blockEnd:u,point:f,confidence:d}},resolveInWysiwyg(e,{source:t,doc:n}){let i=Zz(n);if(i===0)return null;let{blocks:a}=r(t),o=e.blockIndex>=0&&e.blockIndex<i,s=i===a.length,c=nB(e.blockIndex,0,i-1),l=Qz(n,c,c+1);if(l===null)return null;let u=n.child(c),d=iB(e,{inRange:o,tripwireOk:s,kind:Kz(u.type.name),text:u.textContent});return{blockStart:l.from,blockEnd:l.to,point:l.from,confidence:d}}}}var oB=wo.define(),sB=wo.define(),cB=So.mark({class:D_}),lB=To.define({create(){return So.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(oB)?n=So.set([cB.range(e.value.from,e.value.to)]):e.is(sB)&&(n=So.none);return n},provide:e=>xo.decorations.from(e)}),uB=new WeakMap,dB=Do.define(e=>({destroy(){let t=uB.get(e);t!==void 0&&(clearTimeout(t),uB.delete(e))}}));function fB(e,t,n,r){let i=O_(e.state.doc.length,t,n,r);if(!i)return;e.dispatch({effects:oB.of(i)});let a=uB.get(e);a!==void 0&&clearTimeout(a);let o=setTimeout(()=>{uB.delete(e),e.dispatch({effects:sB.of(null)})},li);uB.set(e,o)}function pB(){return[lB,dB]}var mB=3e4;function hB(){let e=new Map,t=e=>e?Date.now()-e.rememberedAt>mB?null:e.navigation:null;return{remember(t,n){e.set(t,{navigation:n,rememberedAt:Date.now()})},peek(n){return t(e.get(n))},consume(n){let r=e.get(n);return e.delete(n),t(r)},clear(t){e.delete(t)},clearForTest(){e.clear()}}}var gB=hB(),_B=hB(),vB=gB.remember,yB=gB.peek,bB=gB.consume,xB=gB.clear;gB.clearForTest;var SB=_B.remember,CB=_B.peek,wB=_B.consume,TB=_B.clear;_B.clearForTest;function EB(e,t,n){return{start:Ta(e,t),end:Ta(e,n)}}function DB(e,t){let n=Fa(e.start,t),r=Fa(e.end,t);return n===null||r===null||r.index<=n.index?null:n.index}var OB=`open-knowledge:view-in-source`,kB=null;function AB(){return kB??=aB(oi()),kB}function jB(e,t,n,r,i=`toggle`){let a=r.captureFromWysiwyg(e,t,{refine:i===`jump`});if(!a)return null;let o=r.resolveInSource(a,{source:n.toString(),doc:e});return{kind:`selection-offset`,intent:i,anchor:a,pin:o?EB(n,o.blockStart,o.blockEnd):void 0}}function MB(e){let{editor:t,docName:n,ytext:r}=e,i=br(t);if(!i)return;let a=e.pmPosition??i.state.selection.from,o=jB(i.state.doc,a,r,AB(),`jump`);o&&vB(n,o),window.dispatchEvent(new CustomEvent(OB,{detail:{docName:n}}))}function NB(e,t,n,r,i){let a=r.captureFromSource(e,t);if(!a)return null;let o=i?r.resolveInSource(a,{source:e,doc:i}):null;return{kind:`selection-offset`,anchor:a,pin:o?EB(n,o.blockStart,o.blockEnd):void 0}}function PB(e,t){let{source:n,pmDoc:r,ydoc:i,resolver:a}=t;if(e.pin){let t=DB(e.pin,i);if(t===null){let t=a.resolveInWysiwyg(e.anchor,{source:n,doc:r});return t?{...t,point:t.blockStart,confidence:`clamped`}:null}let o=a.captureFromSource(n,t);if(o)return a.resolveInWysiwyg(o,{source:n,doc:r})}return a.resolveInWysiwyg(e.anchor,{source:n,doc:r})}function FB(e,t){let{source:n,pmDoc:r,ydoc:i,resolver:a}=t;if(e.pin){let t=DB(e.pin,i);if(t===null){let t=a.resolveInSource(e.anchor,{source:n,doc:r});return t?{...t,point:t.blockStart,confidence:`clamped`}:null}let o=a.captureFromSource(n,t);if(o)return a.resolveInSource(o,{source:n,doc:r})}return a.resolveInSource(e.anchor,{source:n,doc:r})}function IB(e,t){try{return e.coordsAtPos(t)}catch{return null}}function LB(e,t,n){let r=Math.max(0,Math.min(n,e.state.doc.length)),i=t.getBoundingClientRect().top,a=IB(e,r);if(a)return{top:a.top-i+t.scrollTop,height:a.bottom-a.top};try{let n=e.lineBlockAt(r);return{top:e.documentTop-i+t.scrollTop+n.top,height:n.height}}catch{return null}}function RB(e,t){if(e.isDestroyed)return null;try{let n=e.nodeDOM(t);if(n instanceof HTMLElement)return n;let{node:r}=e.domAtPos(t);return r instanceof HTMLElement?r:r.parentElement}catch{return null}}function zB(e,t,n){if(e.isDestroyed)return null;let r=RB(e,Math.max(0,Math.min(n,e.state.doc.content.size)));if(!r)return null;let i=r.getBoundingClientRect(),a=t.getBoundingClientRect().top;return{top:i.top-a+t.scrollTop,height:i.height}}function BB(){return typeof document>`u`?null:rp()}function VB(e,t){let n=t.getBoundingClientRect(),r=n.left+n.width/2,i=di();for(let t of[i+1,i+12,i+40]){let i=e.posAtCoords({left:r,top:n.top+t});if(i)return i.pos}return null}function HB(e,t){let n=t.getBoundingClientRect(),r=n.left+n.width/2,i=di();for(let t of[i+1,i+12,i+40]){let i=e.posAtCoords({x:r,y:n.top+t});if(i!==null)return i}return null}function UB(e){let{from:t,to:n,docName:r,ytext:i}=e;t===`wysiwyg`&&n===`source`?WB(r,i):t===`source`&&n===`wysiwyg`&&GB(r,i)}function WB(e,t){let n=yB(e);if(n&&n.kind!==`selection-offset`)return;let r=Uu(e);if(!r)return;let i=br(r);if(!i)return;let a=BB();if(!a)return;let o=VB(i,a);if(o===null)return;let s=jB(i.state.doc,o,t,AB());s&&vB(e,s)}function GB(e,t){let n=An(e);if(!n)return;let r=BB();if(!r)return;let i=HB(n,r);if(i===null)return;let a=Uu(e),o=a?br(a)?.state.doc:void 0,s=NB(t.toString(),i,t,AB(),o);s&&SB(e,s)}function KB(e){let{view:t,docName:n,navigation:r,ydoc:i,transition:a}=e,o=Uu(n),s=o?br(o)?.state.doc:void 0;if(!s)return null;let c=FB(r,{source:t.state.doc.toString(),pmDoc:s,ydoc:i,resolver:AB()});if(!c)return null;let l=BB();if(!l)return null;let u=c,d=r.intent===`jump`,f=d?u.point:u.blockStart;t.dispatch({effects:xo.scrollIntoView(f,{y:`start`})});let p=!1,m=null,h=xd(n,{yieldsToNavigation:!d,supersede:()=>{p=!0,h.release()}}),g=e=>{if(!p){if(IB(t,f)===null&&e<8){requestAnimationFrame(()=>g(e+1));return}try{d&&(t.dispatch({selection:No.cursor(f)}),t.focus())}finally{h.release()}m=Gz({docName:n,container:l,contentColumn:t.contentDOM,measureTarget:()=>LB(t,l,f),placement:d?`center`:`top`,intent:d?`jump`:`toggle`,grade:u.confidence,landedMode:`source`,transition:a,toolbarOffset:di(),onOutcome:d?e=>{e.status===`landed`&&fB(t,u.blockStart,u.blockEnd,u.confidence)}:void 0,onDiscardQueuedTarget:()=>xB(n)})}};return g(0),{cancel:e=>{p=!0,h.release(),m?.cancel(e)}}}function qB(e){let{editor:t,docName:n,navigation:r,ydoc:i,transition:a}=e,o=br(t);if(!o)return null;let s=PB(r,{source:i.getText(`source`).toString(),pmDoc:o.state.doc,ydoc:i,resolver:AB()});if(!s)return null;let c=BB();if(!c)return null;let l=s;return Gz({docName:n,container:c,contentColumn:o.dom,measureTarget:()=>zB(o,c,l.point),placement:`top`,intent:`toggle`,grade:l.confidence,landedMode:`wysiwyg`,transition:a,toolbarOffset:di(),onDiscardQueuedTarget:()=>TB(n)})}function JB(e){let t=(0,Q.c)(19),{editor:n,getTargetPosition:r}=e,{_:i}=o(),a;t[0]!==n||t[1]!==r?(a=()=>{let e=Xt(n),t=Yn(n);if(e===null||!t)return;let i=r?.();r&&i===void 0||MB({editor:n,docName:e,ytext:t.getText(`source`),pmPosition:i})},t[0]=n,t[1]=r,t[2]=a):a=t[2];let s=a,c;t[3]===i?c=t[4]:(c=i({id:`M0jOcG`}),t[3]=i,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Rt,{className:`size-3.5`,"aria-hidden":`true`}),t[5]=l):l=t[5];let u;t[6]!==s||t[7]!==c?(u=(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(ee,{type:`button`,variant:`ghost`,size:`icon-xs`,"data-testid":`view-in-source-bubble-button`,className:`text-accent-foreground/80`,"aria-label":c,onMouseDown:YB,onClick:s,children:l})}),t[6]=s,t[7]=c,t[8]=u):u=t[8];let d;t[9]===i?d=t[10]:(d=i({id:`M0jOcG`}),t[9]=i,t[10]=d);let p;t[11]===d?p=t[12]:(p=(0,$.jsx)(`span`,{children:d}),t[11]=d,t[12]=p);let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(f,{"aria-label":Ae(`view-source-at-cursor`),children:ke(`view-source-at-cursor`)}),t[13]=m):m=t[13];let h;t[14]===p?h=t[15]:(h=(0,$.jsxs)(_,{side:`bottom`,sideOffset:8,children:[p,m]}),t[14]=p,t[15]=h);let y;return t[16]!==u||t[17]!==h?(y=(0,$.jsxs)(v,{children:[u,h]}),t[16]=u,t[17]=h,t[18]=y):y=t[18],y}function YB(e){return e.preventDefault()}function XB(e){let t=(0,Q.c)(23),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({label:i,Icon:n,onClick:a,selected:s,className:r,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s?`true`:void 0,l;t[7]===a?l=t[8]:(l=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())},t[7]=a,t[8]=l);let u;t[9]===r?u=t[10]:(u=d(`flex w-full items-center justify-center gap-2 rounded-md border border-dashed border-border bg-transparent px-3 py-2 text-center text-sm text-muted-foreground transition-colors hover:bg-muted/50 cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,r),t[9]=r,t[10]=u);let f;t[11]===n?f=t[12]:(f=(0,$.jsx)(n,{size:16,"aria-hidden":`true`}),t[11]=n,t[12]=f);let p;t[13]===i?p=t[14]:(p=(0,$.jsx)(`span`,{children:i}),t[13]=i,t[14]=p);let m;return t[15]!==a||t[16]!==o||t[17]!==c||t[18]!==l||t[19]!==u||t[20]!==f||t[21]!==p?(m=(0,$.jsxs)(`div`,{...o,role:`button`,tabIndex:-1,contentEditable:!1,"data-descriptor-placeholder":``,"data-selected":c,onClick:a,onMouseDown:ZB,onKeyDown:l,className:u,children:[f,p]}),t[15]=a,t[16]=o,t[17]=c,t[18]=l,t[19]=u,t[20]=f,t[21]=p,t[22]=m):m=t[22],m}function ZB(e){e.preventDefault(),e.stopPropagation()}function QB(e){let t=e.trim();if(/^#[0-9a-fA-F]{6}$/.test(t))return t.toLowerCase();if(/^#[0-9a-fA-F]{3}$/.test(t)){let[,e,n,r]=t.match(/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/)??[];return`#${e}${e}${n}${n}${r}${r}`.toLowerCase()}return`#000000`}function $B(e){let t=(0,Q.c)(42),{id:n,value:r,onChange:i,autoFocus:a}=e,{_:s}=o(),c=(0,Z.useRef)(null),l;t[0]===i?l=t[1]:(l=e=>i(e.target.value),t[0]=i,t[1]=l);let u=a?``:void 0,f=r?`pl-7`:void 0,p;t[2]===f?p=t[3]:(p=d(`h-7 text-sm`,f),t[2]=f,t[3]=p);let m;t[4]!==a||t[5]!==n||t[6]!==l||t[7]!==u||t[8]!==p||t[9]!==r?(m=(0,$.jsx)(Ka,{id:n,type:`text`,value:r,placeholder:`#F05032 or rgb(240,80,50)`,onChange:l,autoFocus:a,"data-prop-autofocus":u,className:p,"data-color-picker-input":``}),t[4]=a,t[5]=n,t[6]=l,t[7]=u,t[8]=p,t[9]=r,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=r&&(0,$.jsx)(`span`,{style:{backgroundColor:r},className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 rounded-sm border border-border`,"aria-hidden":`true`,"data-color-picker-swatch":``}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===s?_=t[17]:(_=s({id:`TiPvBP`}),t[16]=s,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>c.current?.click(),t[18]=v):v=t[18];let y=r||`transparent`,b;t[19]===y?b=t[20]:(b=(0,$.jsx)(`span`,{style:{backgroundColor:y},className:`size-3.5 rounded-sm border border-border`,"aria-hidden":`true`}),t[19]=y,t[20]=b);let x;t[21]!==b||t[22]!==_?(x=(0,$.jsx)(ee,{type:`button`,variant:`outline`,size:`xs`,"aria-label":_,"data-color-picker-trigger":``,className:`h-7 gap-1 px-2`,onClick:v,children:b}),t[21]=b,t[22]=_,t[23]=x):x=t[23];let S;t[24]===r?S=t[25]:(S=QB(r),t[24]=r,t[25]=S);let C;t[26]===i?C=t[27]:(C=e=>i(e.target.value),t[26]=i,t[27]=C);let w;t[28]!==S||t[29]!==C?(w=(0,$.jsx)(`input`,{ref:c,type:`color`,value:S,onChange:C,tabIndex:-1,"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 size-7 opacity-0`,"data-color-picker-native":``}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==x||t[32]!==w?(T=(0,$.jsxs)(`div`,{className:`relative`,children:[x,w]}),t[31]=x,t[32]=w,t[33]=T):T=t[33];let E;t[34]!==s||t[35]!==i||t[36]!==r?(E=r&&(0,$.jsx)(ee,{type:`button`,variant:`ghost`,size:`xs`,"aria-label":s({id:`cb-0G0`}),"data-color-picker-clear":``,className:`h-7 px-1.5`,onClick:()=>i(``),children:(0,$.jsx)(Jl,{className:`size-3`,"aria-hidden":`true`})}),t[34]=s,t[35]=i,t[36]=r,t[37]=E):E=t[37];let D;return t[38]!==T||t[39]!==E||t[40]!==g?(D=(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[g,T,E]}),t[38]=T,t[39]=E,t[40]=g,t[41]=D):D=t[41],D}function eV(e){let t=(0,Q.c)(51),{id:n,value:r,onChange:i,suggestions:a,listLabel:o,emptyMessage:s,placeholder:c,autoFocus:l,ariaInvalid:u,ariaDescribedBy:f,dataPropAutofocus:p,className:m,onSubmit:h}=e,[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(0),b,x;t[0]!==v||t[1]!==a.length?(b=()=>{v>=a.length&&y(0)},x=[v,a.length],t[0]=v,t[1]=a.length,t[2]=b,t[3]=x):(b=t[2],x=t[3]),(0,Z.useEffect)(b,x);let S=(0,Z.useId)(),C=(0,Z.useRef)(null),w=g&&a.length>0,T=g&&a.length===0&&s!==void 0,E;t[4]===i?E=t[5]:(E=e=>{i(e.value),_(!1),y(0),C.current?.focus()},t[4]=i,t[5]=E);let D=E,O=w||T,k;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>_(e),t[6]=k):k=t[6];let A=w?S:void 0,j=w&&a[v]?`${S}-opt-${v}`:void 0,M;t[7]===i?M=t[8]:(M=e=>{i(e.target.value),_(!0),y(0)},t[7]=i,t[8]=M);let N,P;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>{_(!0)},N=()=>{_(!1)},t[9]=N,t[10]=P):(N=t[9],P=t[10]);let F;t[11]!==v||t[12]!==w||t[13]!==h||t[14]!==D||t[15]!==T||t[16]!==a?(F=e=>{if(!Bt(e)){if(e.key===`ArrowDown`){if(a.length===0)return;e.preventDefault(),_(!0),y(e=>(e+1)%a.length);return}if(e.key===`ArrowUp`){if(a.length===0)return;e.preventDefault(),_(!0),y(e=>(e-1+a.length)%a.length);return}if(e.key===`Enter`){if(w){let t=a[v];if(t){e.preventDefault(),D(t);return}}h&&(e.preventDefault(),h());return}if(e.key===`Escape`){if(!w&&!T)return;e.preventDefault(),e.stopPropagation(),_(!1);return}e.key===`Tab`&&_(!1)}},t[11]=v,t[12]=w,t[13]=h,t[14]=D,t[15]=T,t[16]=a,t[17]=F):F=t[17];let I;t[18]!==f||t[19]!==u||t[20]!==l||t[21]!==m||t[22]!==p||t[23]!==n||t[24]!==w||t[25]!==c||t[26]!==F||t[27]!==A||t[28]!==j||t[29]!==M||t[30]!==r?(I=(0,$.jsx)(ba,{asChild:!0,children:(0,$.jsx)(Ka,{ref:C,id:n,type:`text`,value:r,placeholder:c,autoFocus:l,"data-prop-autofocus":p,"aria-invalid":u,"aria-describedby":f,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":w,"aria-controls":A,"aria-activedescendant":j,className:m,onChange:M,onClick:P,onBlur:N,onKeyDown:F})}),t[18]=f,t[19]=u,t[20]=l,t[21]=m,t[22]=p,t[23]=n,t[24]=w,t[25]=c,t[26]=F,t[27]=A,t[28]=j,t[29]=M,t[30]=r,t[31]=I):I=t[31];let L;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>{let t=e.target;t instanceof Node&&C.current?.contains(t)&&e.preventDefault()},t[32]=L):L=t[32];let ee;t[33]!==s||t[34]!==v||t[35]!==o||t[36]!==S||t[37]!==D||t[38]!==a?(ee=a.length===0?s!==void 0&&(0,$.jsx)(`p`,{className:`px-2 py-1 text-xs text-muted-foreground wrap-break-word`,children:s}):(0,$.jsx)(`div`,{id:S,role:`listbox`,"aria-label":o,className:`flex flex-col gap-px`,children:a.map((e,t)=>{let n=`${S}-opt-${t}`,r=t===v;return(0,$.jsxs)(`button`,{id:n,type:`button`,role:`option`,"aria-selected":r,"data-testid":`suggestion-option`,"data-highlighted":r?``:void 0,className:d(`flex w-full flex-col items-start gap-0.5 rounded-sm px-2 py-1 text-left text-xs`,`transition-colors`,r?`bg-accent text-accent-foreground`:`hover:bg-accent/50`),onMouseEnter:()=>y(t),onMouseDown:t=>{t.preventDefault(),D(e)},children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.label}),e.detail!==void 0&&(0,$.jsx)(`span`,{className:r?`text-accent-foreground/70`:`text-muted-foreground`,children:e.detail})]},e.value)})}),t[33]=s,t[34]=v,t[35]=o,t[36]=S,t[37]=D,t[38]=a,t[39]=ee):ee=t[39];let R;t[40]===ee?R=t[41]:(R=(0,$.jsx)(ya,{align:`start`,sideOffset:4,className:`z-70 w-(--radix-popover-trigger-width) p-1`,"data-ok-declines-keyboard":``,onMouseDown:rV,onOpenAutoFocus:nV,onCloseAutoFocus:tV,onInteractOutside:L,children:ee}),t[40]=ee,t[41]=R);let te;t[42]!==I||t[43]!==R||t[44]!==O?(te=(0,$.jsxs)(xa,{open:O,onOpenChange:k,children:[I,R]}),t[42]=I,t[43]=R,t[44]=O,t[45]=te):te=t[45];let ne=T?s:``,re;t[46]===ne?re=t[47]:(re=(0,$.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`sr-only`,children:ne}),t[46]=ne,t[47]=re);let ie;return t[48]!==te||t[49]!==re?(ie=(0,$.jsxs)($.Fragment,{children:[te,re]}),t[48]=te,t[49]=re,t[50]=ie):ie=t[50],ie}function tV(e){e.preventDefault()}function nV(e){e.preventDefault()}function rV(e){e.preventDefault()}function iV(e){let t=(0,Q.c)(16),n,r;t[0]===e?(n=t[1],r=t[2]):({value:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let{_:i}=o(),a=ts(),s;t[3]===a?.pages?s=t[4]:(s=a?.pages??[],t[3]=a?.pages,t[4]=s);let c;t[5]!==a?.pageTitles||t[6]!==s||t[7]!==r?(c=ri([...s].map(e=>({kind:`page`,docName:e,title:a?.pageTitles.get(e)??e.split(`/`).pop()??e})),r.trim()).map(aV),t[5]=a?.pageTitles,t[6]=s,t[7]=r,t[8]=c):c=t[8];let l=c,u;t[9]===i?u=t[10]:(u=i({id:`hwdlGS`}),t[9]=i,t[10]=u);let d;return t[11]!==n||t[12]!==l||t[13]!==u||t[14]!==r?(d=(0,$.jsx)(eV,{...n,value:r,suggestions:l,listLabel:u}),t[11]=n,t[12]=l,t[13]=u,t[14]=r,t[15]=d):d=t[15],d}function aV(e){return{value:e.docName,label:e.title,detail:e.title===e.docName?void 0:e.docName}}function oV(e){let t=(0,Q.c)(55),{id:n,value:r,onChange:i,autoFocus:s}=e,{_:c}=o(),[l,u]=(0,Z.useState)(!1),f;t[0]===r?f=t[1]:(f=sv(r),t[0]=r,t[1]=f);let p=f,m;t[2]===r?m=t[3]:(m=r.startsWith(`lucide:`)?r.slice(7):null,t[2]=r,t[3]=m);let h=m,g;t[4]===i?g=t[5]:(g=e=>i(e.target.value),t[4]=i,t[5]=g);let _=s?``:void 0,v=p?`pl-7`:void 0,y;t[6]===v?y=t[7]:(y=d(`h-7 text-sm`,v),t[6]=v,t[7]=y);let b;t[8]!==s||t[9]!==n||t[10]!==g||t[11]!==_||t[12]!==y||t[13]!==r?(b=(0,$.jsx)(Ka,{id:n,type:`text`,value:r,placeholder:`lucide:Lightbulb or 📘`,onChange:g,autoFocus:s,"data-prop-autofocus":_,className:y,"data-icon-picker-input":``}),t[8]=s,t[9]=n,t[10]=g,t[11]=_,t[12]=y,t[13]=r,t[14]=b):b=t[14];let x;t[15]===p?x=t[16]:(x=p&&(0,$.jsx)(p,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),t[15]=p,t[16]=x);let S;t[17]!==b||t[18]!==x?(S=(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[b,x]}),t[17]=b,t[18]=x,t[19]=S):S=t[19];let C;t[20]===c?C=t[21]:(C=c({id:`jDhTLC`}),t[20]=c,t[21]=C);let w;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(jt,{className:`size-3`,"aria-hidden":`true`}),t[22]=w):w=t[22];let T;t[23]!==l||t[24]!==C?(T=(0,$.jsx)(va,{asChild:!0,children:(0,$.jsx)(ee,{type:`button`,variant:`outline`,size:`xs`,"aria-label":C,"aria-haspopup":`listbox`,"aria-expanded":l,"data-icon-picker-trigger":``,className:`h-7 gap-1 px-2`,children:w})}),t[23]=l,t[24]=C,t[25]=T):T=t[25];let E;t[26]===c?E=t[27]:(E=c({id:`DiZ3pq`}),t[26]=c,t[27]=E);let D;t[28]===c?D=t[29]:(D=c({id:`l_6JHD`}),t[28]=c,t[29]=D);let O;t[30]===D?O=t[31]:(O=(0,$.jsx)(QD,{placeholder:D,className:`h-8 text-sm`}),t[30]=D,t[31]=O);let k;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(eO,{children:(0,$.jsx)(a,{id:`NmaGHf`})}),t[32]=k):k=t[32];let A;t[33]!==i||t[34]!==r.length?(A=r.length>0&&(0,$.jsx)(tO,{children:(0,$.jsxs)(nO,{value:`__clear__`,onSelect:()=>{i(``),u(!1)},className:`gap-2 text-muted-foreground`,"data-icon-picker-clear":``,children:[(0,$.jsx)(Mi,{className:`size-3.5`,"aria-hidden":`true`}),`Clear icon`]})}),t[33]=i,t[34]=r.length,t[35]=A):A=t[35];let j;t[36]!==i||t[37]!==h?(j=ov.map(e=>{let[t,n]=e,r=t===h;return(0,$.jsx)(nO,{value:t,onSelect:()=>{i(`lucide:${t}`),u(!1)},title:t,"aria-label":t,"data-icon-picker-item":t,"data-icon-picker-selected":r?``:void 0,className:d(`flex aspect-square items-center justify-center rounded-md p-0`,r?`bg-foreground/10 text-foreground ring-1 ring-foreground/30`:`text-muted-foreground hover:bg-muted`),children:(0,$.jsx)(n,{className:`size-4`,"aria-hidden":`true`})},t)}),t[36]=i,t[37]=h,t[38]=j):j=t[38];let M;t[39]===j?M=t[40]:(M=(0,$.jsx)(tO,{heading:`Lucide`,children:(0,$.jsx)(RD.Group,{className:`[&_[cmdk-group-items]]:grid [&_[cmdk-group-items]]:grid-cols-6 [&_[cmdk-group-items]]:gap-1 [&_[cmdk-group-items]]:p-1`,children:j})}),t[39]=j,t[40]=M);let N;t[41]!==A||t[42]!==M?(N=(0,$.jsxs)($D,{className:`max-h-64`,children:[k,A,M]}),t[41]=A,t[42]=M,t[43]=N):N=t[43];let P;t[44]!==E||t[45]!==O||t[46]!==N?(P=(0,$.jsx)(ya,{align:`end`,className:`z-70 w-72 p-0`,onOpenAutoFocus:sV,children:(0,$.jsxs)(XD,{label:E,children:[O,N]})}),t[44]=E,t[45]=O,t[46]=N,t[47]=P):P=t[47];let F;t[48]!==l||t[49]!==T||t[50]!==P?(F=(0,$.jsxs)(xa,{open:l,onOpenChange:u,children:[T,P]}),t[48]=l,t[49]=T,t[50]=P,t[51]=F):F=t[51];let I;return t[52]!==F||t[53]!==S?(I=(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[S,F]}),t[52]=F,t[53]=S,t[54]=I):I=t[54],I}function sV(e){return e.preventDefault()}var cV=80,lV={kind:`unavailable`},uV={kind:`ready`,entries:[]},dV=new Set([`paragraph`,`heading`,`emphasis`,`strong`,`delete`,`link`,`linkReference`,`tableCell`,`mdxJsxTextElement`]);function fV(e){if(typeof e.value==`string`)return e.value;let t=dV.has(e.type)?``:` `;return(e.children??[]).map(fV).join(t)}function pV(e){let t=(e.children??[]).map(fV).join(` `).replace(/\s+/g,` `).trim();return t.length<=cV?t:`${Iu(t,cV).trimEnd()}…`}function mV(e){let t=[],n=new Set,r=e=>{if(e.type===`mdxJsxFlowElement`&&e.name===`MirrorSource`){let r=e,i=nx(r);i&&!n.has(i)&&(n.add(i),t.push({name:i,preview:pV(r)}))}for(let t of e.children??[])r(t)};return r(e),t}function hV(e,t){let n;try{n=oi().parseToMdast(t)}catch(t){return console.warn(`[Mirror] parseToMdast failed while listing source names`,{docName:e,err:t}),lV}return{kind:`ready`,entries:mV(n)}}function gV(e){let t=(0,Q.c)(3),n=ts(),r=e!==``&&n?.pages.has(e)===!0,i=Bv(r?e:null);if(!r)return lV;switch(i.kind){case`empty`:return uV;case`ready`:{let n;return t[0]!==e||t[1]!==i.text?(n=hV(e,i.text),t[0]=e,t[1]=i.text,t[2]=n):n=t[2],n}case`loading`:case`unreachable`:case`at-capacity`:return lV}}var _V=8;function vV(e){let t=(0,Q.c)(23),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({docName:n,value:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{_:a}=o(),s=gV(n),c,l;if(t[4]!==s.entries||t[5]!==s.kind||t[6]!==i){c=s.kind===`ready`?s.entries:[];let e=i.trim().toLowerCase();l=c.filter(t=>t.name.toLowerCase().includes(e)||t.preview.toLowerCase().includes(e)).slice(0,_V).map(yV),t[4]=s.entries,t[5]=s.kind,t[6]=i,t[7]=c,t[8]=l}else c=t[7],l=t[8];let u=l,d;if(s.kind===`ready`&&c.length===0){let e;t[9]!==a||t[10]!==n?(e=a({id:`GndE4v`,values:{docName:n}}),t[9]=a,t[10]=n,t[11]=e):e=t[11],d=e}else if(s.kind===`ready`&&u.length===0){let e;t[12]!==a||t[13]!==n?(e=a({id:`fZ_eNM`,values:{docName:n}}),t[12]=a,t[13]=n,t[14]=e):e=t[14],d=e}let f;t[15]===a?f=t[16]:(f=a({id:`sxDZ7M`}),t[15]=a,t[16]=f);let p;return t[17]!==d||t[18]!==r||t[19]!==u||t[20]!==f||t[21]!==i?(p=(0,$.jsx)(eV,{...r,value:i,suggestions:u,listLabel:f,emptyMessage:d}),t[17]=d,t[18]=r,t[19]=u,t[20]=f,t[21]=i,t[22]=p):p=t[22],p}function yV(e){return{value:e.name,label:e.name,detail:e.preview===``?void 0:e.preview}}function bV(e){let[t]=e.split(`/`);switch(t){case`image`:return`image`;case`video`:return`video`;case`audio`:return`audio`;case`application`:return e===`application/pdf`?`pdf`:null;case`text`:return`text`;default:return null}}function xV(e){if(e.length===1&&e[0]===`*/*`)return`all`;let t=new Set;for(let n of e){if(n===`*/*`)return`all`;let e=bV(n);e&&t.add(e)}return t}function SV(e){let t=e.lastIndexOf(`.`);return t<0||t<e.lastIndexOf(`/`)?``:e.slice(t+1).toLowerCase()}function CV(e,t){let n=xV(t),r=[];for(let t of e){if(n===`all`){r.push(t);continue}let e=R(SV(t));e&&n.has(e)&&r.push(t)}return r}var wV=8,TV=new Set,EV=null;function DV(e){return{path:e,basename:e.split(`/`).pop()??e}}function OV(e){let t=e.map(e=>e.path).join(``);return EV?.fingerprint===t||(EV={fingerprint:t,byPath:new Map(e.map(e=>[e.path,e])),itemsInOrder:e,corpus:kn(e.map(e=>gi({kind:`page`,path:e.path,title:e.basename})))}),EV}function kV(e){let t=e.trim();return t.startsWith(`/`)?t.slice(1):t}function AV(e,t){let n=kV(t);return n?qt(e.corpus,n,{intent:`autocomplete`,limit:wV}).map(t=>e.byPath.get(t.document.path)).filter(e=>!!e):e.itemsInOrder.slice(0,wV)}function jV(e){let t=(0,Q.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({value:i,accept:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{_:a}=o(),s=ts()?.assetPaths??TV,c;t[4]!==n||t[5]!==s||t[6]!==i?(c=AV(OV(CV(s,n).map(DV)),i).map(MV),t[4]=n,t[5]=s,t[6]=i,t[7]=c):c=t[7];let l=c,u;t[8]===a?u=t[9]:(u=a({id:`Xhm7gG`}),t[8]=a,t[9]=u);let d;return t[10]!==r||t[11]!==l||t[12]!==u||t[13]!==i?(d=(0,$.jsx)(eV,{...r,value:i,suggestions:l,listLabel:u}),t[10]=r,t[11]=l,t[12]=u,t[13]=i,t[14]=d):d=t[14],d}function MV(e){return{value:`/${e.path}`,label:e.basename,detail:e.basename===e.path?void 0:e.path}}function NV(){if(typeof window>`u`)return null;let e=window.location.hash.match(/^#\/([^?#]+)/);return e?decodeURIComponent(e[1]):null}var PV=`/api/upload`;async function FV(e,t,n={}){if(n.singleFile)throw new Yg(qg(),`single-file-mode`);let r=n.fetch??globalThis.fetch,i=e.size,a=n.docName===void 0?NV():n.docName;if(!a)throw Error(`No document is open`);let o=new FormData;o.append(`file`,e),o.append(`parentDocName`,`${a}.md`);let s;try{s=await r(PV,{method:`POST`,body:o})}catch(t){let n;try{n=await n_({file:e,sizeAtDrop:i,error:t})}catch(e){console.error(`[uploadFile] upload failed, and diagnosing it failed too`,{docName:a,networkError:t,reportError:e})}throw n?(console.error(`[uploadFile] upload failed before reaching the server`,{...n.log,docName:a}),new Yg(n.message,n.kind)):Error(t instanceof Error?t.message:String(t))}let c;try{c=await s.json()}catch(e){throw new pi(`Upload response is not JSON.`,{cause:e,status:s.status})}if(!s.ok){let e=Ye.safeParse(c);if(!e.success)throw new pi(`Upload error response did not match ProblemDetails.`,{cause:e.error,status:s.status});let t=$g(e.data);throw t?new Xg(t):Error(e.data.title)}let l=Je.safeParse(c);if(!l.success)throw new pi(`Upload success response did not match UploadAssetSuccess.`,{cause:l.error,status:s.status});let u=l.data.path??l.data.src;return{url:u.startsWith(`/`)?u:`/${u}`}}function IV(e,t,n){return n<=0?Y._({id:`XXA1b_`,values:{componentLabel:e}}):Y._({id:`Qe47G0`,values:{componentLabel:e,childCount:n}})}function LV(e){for(let t of e)if(t.type===`string`&&t.hidden!==!0&&t.advanced!==!0&&t.autoFocus===!0)return t.name;return null}function RV(e){if(!e)return e;let t=e.replace(/[_-]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1)}var zV=new Set([`auto`,`inherit`,`initial`,`unset`]),BV=new Set([`px`,`%`,`rem`,`em`,`vh`,`vw`,`ch`,`ex`,`fr`]),VV=/^(-?\d+(?:\.\d+)?)([a-z%]*)$/i;function HV(e){let t=e.trim();if(!t)return{valid:!1,reason:`empty`};if(zV.has(t.toLowerCase()))return{valid:!0};let n=t.match(VV);if(!n)return{valid:!1,reason:`malformed-syntax`};let r=(n[2]??``).toLowerCase();return r===``||BV.has(r)?{valid:!0}:{valid:!1,reason:`unknown-unit`}}function UV(e){if(e.valid)return null;switch(e.reason){case`empty`:return null;case`malformed-syntax`:return`Enter a number (e.g. 100), a number with a CSS unit (e.g. 100px, 50%, 26rem), or one of: auto, inherit, initial, unset.`;case`unknown-unit`:return`Unknown CSS unit. Use px, %, rem, em, vh, vw, ch, ex, or fr.`}}var WV={video:ne,audio:ae,image:te},GV={youtube:[`youtube.com`,`youtu.be`,`youtube-nocookie.com`],vimeo:[`vimeo.com`],loom:[`loom.com`]};function KV(e){let t=e.toLowerCase();for(let e of Object.keys(GV)){let n=GV[e];for(let r of n)if(t===r||t.endsWith(`.${r}`))return e}return null}function qV(e){let t=e.lastIndexOf(`/`),n=t>=0?e.slice(t+1):e,r=n.lastIndexOf(`.`);return r>0?n.slice(r+1).toLowerCase():``}var JV=`https://placeholder.invalid`;function YV(e,t){let n=e.trim();if(n.length===0)return{valid:!0};let r,i=!0;try{r=new URL(n)}catch{try{r=new URL(n,JV),i=!1}catch{return{valid:!1,reason:`invalid-url`}}}if(t===`video`&&Yt(n)!==null||t===`video`&&ui(n)||t===`video`&&Fn(n))return{valid:!0};let a=i?KV(r.hostname):null;if(a!==null)return{valid:!1,reason:`embed-provider`,provider:a};if(r.protocol===`data:`)return{valid:!1,reason:`data-uri`};let o=qV(r.pathname),s=WV[t];return o===``?i?{valid:!0}:{valid:!1,reason:`wrong-extension`,extension:``}:s.has(o)?{valid:!0}:{valid:!1,reason:`wrong-extension`,extension:o}}function XV(e){if(e.length===0)return;let t=e[0]?.toLowerCase()??``;if(t.startsWith(`video/`))return`video`;if(t.startsWith(`audio/`))return`audio`;if(t.startsWith(`image/`))return`image`}function ZV(e){return`Direct ${e} file URL — ${Array.from(WV[e]).map(e=>`.${e}`).join(`, `)}`}var QV={youtube:`YouTube`,vimeo:`Vimeo`,loom:`Loom`};function $V(e,t){if(e.valid)return``;if(e.reason===`invalid-url`)return`Not a valid URL.`;if(e.reason===`data-uri`)return`Data URIs are not supported for media fields. Use a hosted file URL.`;if(e.reason===`embed-provider`){let n=QV[e.provider];return t===`video`?`Unrecognized ${n} URL. Paste a valid ${n} share or embed link, or a direct ${t} file URL.`:`${n} URLs are not direct ${t} files. Paste a direct ${t} file URL.`}let n=Array.from(WV[t]).map(e=>`.${e}`).join(`, `);return e.extension===``?`Missing file extension. Accepts: ${n}.`:`Unsupported extension .${e.extension}. Accepts: ${n}.`}function eH(e){return`ok.propPanel.advanced.${e}`}function tH(e){try{return typeof localStorage>`u`?!1:localStorage.getItem(eH(e))===`true`}catch{return!1}}function nH(e,t){try{if(typeof localStorage>`u`)return;localStorage.setItem(eH(e),t?`true`:`false`)}catch{}}function rH(e,t){let n=0;for(let r of e){let e=t[r.name],i=`defaultValue`in r?r.defaultValue:void 0;e!==void 0&&e!==i&&(n+=1)}return n}async function iH(e,t,n,r){try{let{url:i}=await FV(e,t,{singleFile:r});n(i)}catch(e){if(e instanceof Yg||e instanceof Xg){z.error(e.message);return}let t=e instanceof Error?e.message:String(e);z.error(Y._({id:`02P3hL`,values:{message:t}}))}}function aH(e){let t=(0,Q.c)(14),{descriptor:n,values:r,onChange:i,onDismiss:o}=e,s;t[0]===r?s=t[1]:(s=e=>!(`hidden`in e&&e.hidden)&&e.hideWhen?.(r)!==!0&&e.type!==`reactnode`,t[0]=r,t[1]=s);let c=n.props.filter(s),l=c.filter(sH),u=c.filter(oH),d=rH(u,r),f;t[2]===n.props?f=t[3]:(f=LV(n.props),t[2]=n.props,t[3]=f);let p=f,m;t[4]===n.name?m=t[5]:(m=()=>tH(n.name),t[4]=n.name,t[5]=m);let[h,g]=(0,Z.useState)(m);if(c.length===0)return null;let _;t[6]!==p||t[7]!==i||t[8]!==o||t[9]!==r?(_=e=>(0,$.jsx)(lH,{propDef:e,value:r[e.name],values:r,onChange:t=>i(e.name,t),onDismiss:o,isAutoFocused:e.name===p},e.name),t[6]=p,t[7]=i,t[8]=o,t[9]=r,t[10]=_):_=t[10];let v=l.map(_),S=u.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,$.jsxs)(x,{open:h,onOpenChange:e=>{g(e),nH(n.name,e)},children:[(0,$.jsxs)(b,{"data-prop-panel-advanced-trigger":``,className:`group flex w-full items-center justify-between rounded px-1 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground uppercase font-mono`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(jt,{className:`size-3 transition-transform group-data-[state=closed]:-rotate-90`}),(0,$.jsx)(a,{id:`sxkWRg`})]}),d>0&&(0,$.jsx)(Pi,{variant:`secondary`,"data-prop-panel-advanced-count":``,children:d})]}),(0,$.jsx)(y,{className:`flex flex-col gap-4 pt-2`,children:u.map(e=>(0,$.jsx)(lH,{propDef:e,value:r[e.name],values:r,onChange:t=>i(e.name,t),onDismiss:o,isAutoFocused:e.name===p},e.name))})]})]}),C;return t[11]!==v||t[12]!==S?(C=(0,$.jsxs)(`div`,{"data-prop-panel":``,className:`flex flex-col gap-4 py-2 text-sm`,children:[v,S]}),t[11]=v,t[12]=S,t[13]=C):C=t[13],C}function oH(e){return`advanced`in e&&e.advanced}function sH(e){return!(`advanced`in e&&e.advanced)}function cH(e){throw Error(`PropPanel: unhandled PropDef type ${JSON.stringify(e)}`)}function lH(e){let t=(0,Q.c)(151),{propDef:n,value:r,values:i,onChange:a,onDismiss:o,isAutoFocused:s}=e,c;t[0]===o?c=t[1]:(c=o?e=>{e.key===`Enter`&&(e.preventDefault(),o())}:void 0,t[0]=o,t[1]=c);let l=c;switch(n.type){case`reactnode`:return null;case`string`:{let e=`prop-${n.name}`,c=n.accept,u=c!==void 0&&c.length>0,d=!n.required&&n.defaultValue===void 0,f,p,m,h;if(t[2]!==c||t[3]!==l||t[4]!==s||t[5]!==a||t[6]!==o||t[7]!==n.colorPicker||t[8]!==n.cssLengthInput||t[9]!==n.documentPicker||t[10]!==n.iconPicker||t[11]!==n.language||t[12]!==n.mirrorSourcePicker||t[13]!==n.name||t[14]!==e||t[15]!==d||t[16]!==r||t[17]!==i){h=Symbol.for(`react.early_return_sentinel`);bb0:{if(p=xb(r),n.language){let r=`${e}-label`,i;t[22]===n.name?i=t[23]:(i=RV(n.name),t[22]=n.name,t[23]=i);let o;t[24]!==r||t[25]!==e||t[26]!==i?(o=(0,$.jsx)(`label`,{id:r,htmlFor:e,className:`text-xs text-muted-foreground`,children:i}),t[24]=r,t[25]=e,t[26]=i,t[27]=o):o=t[27];let c;t[28]!==a||t[29]!==d?(c=e=>{if(e===``&&d){a(void 0);return}a(e)},t[28]=a,t[29]=d,t[30]=c):c=t[30],h=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[o,(0,$.jsx)(ei,{id:e,ariaLabelledBy:r,value:p,language:n.language,onChange:c,autoFocus:s})]});break bb0}if(n.iconPicker){let r;t[31]===n.name?r=t[32]:(r=RV(n.name),t[31]=n.name,t[32]=r);let i;t[33]!==e||t[34]!==r?(i=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:r}),t[33]=e,t[34]=r,t[35]=i):i=t[35];let o;t[36]!==a||t[37]!==d?(o=e=>{if(e===``&&d){a(void 0);return}a(e)},t[36]=a,t[37]=d,t[38]=o):o=t[38],h=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i,(0,$.jsx)(oV,{id:e,value:p,onChange:o,autoFocus:s})]});break bb0}if(n.colorPicker){let r;t[39]===n.name?r=t[40]:(r=RV(n.name),t[39]=n.name,t[40]=r);let i;t[41]!==e||t[42]!==r?(i=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:r}),t[41]=e,t[42]=r,t[43]=i):i=t[43];let o;t[44]!==a||t[45]!==d?(o=e=>{if(e===``&&d){a(void 0);return}a(e)},t[44]=a,t[45]=d,t[46]=o):o=t[46],h=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i,(0,$.jsx)($B,{id:e,value:p,onChange:o,autoFocus:s})]});break bb0}let u;t[47]!==a||t[48]!==d?(u=e=>{a(e===``&&d?void 0:e)},t[47]=a,t[48]=d,t[49]=u):u=t[49];let g=u;if(n.documentPicker){let r;t[50]===n.name?r=t[51]:(r=RV(n.name),t[50]=n.name,t[51]=r);let i;t[52]!==e||t[53]!==r?(i=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:r}),t[52]=e,t[53]=r,t[54]=i):i=t[54],h=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i,(0,$.jsx)(iV,{id:e,value:p,onChange:g,onSubmit:o,autoFocus:s,dataPropAutofocus:s?``:void 0,className:`h-7 text-sm`})]});break bb0}if(n.mirrorSourcePicker!==void 0){let r;t[55]===n.name?r=t[56]:(r=RV(n.name),t[55]=n.name,t[56]=r);let a;t[57]!==e||t[58]!==r?(a=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:r}),t[57]=e,t[58]=r,t[59]=a):a=t[59];let c=i[n.mirrorSourcePicker],l;t[60]===c?l=t[61]:(l=xb(c),t[60]=c,t[61]=l),h=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[a,(0,$.jsx)(vV,{id:e,docName:l,value:p,onChange:g,onSubmit:o,autoFocus:s,dataPropAutofocus:s?``:void 0,className:`h-7 text-sm`})]});break bb0}if(n.cssLengthInput){let r=HV(p),i=r.valid?null:UV(r),o;t[62]===n.name?o=t[63]:(o=RV(n.name),t[62]=n.name,t[63]=o);let c;t[64]!==e||t[65]!==o?(c=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[64]=e,t[65]=o,t[66]=c):c=t[66];let u;t[67]!==a||t[68]!==d?(u=e=>{let t=e.target.value;if(t===``&&d){a(void 0);return}a(t)},t[67]=a,t[68]=d,t[69]=u):u=t[69],h=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,(0,$.jsx)(Ka,{id:e,type:`text`,value:p,placeholder:`100px, 50%, 26rem, auto`,onChange:u,onKeyDown:l,autoFocus:s,"data-prop-autofocus":s?``:void 0,"aria-invalid":i===null?void 0:!0,"aria-describedby":i===null?void 0:`${e}-error`,className:`h-7 text-sm`,"data-prop-css-length-input":``}),i!==null&&(0,$.jsx)(`p`,{id:`${e}-error`,"data-prop-css-length-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:i})]});break bb0}let _=c===void 0?void 0:XV(c),v=_===void 0?null:YV(p,_);f=v!==null&&!v.valid&&_!==void 0&&p.trim().length>0?$V(v,_):null,m=_===void 0?void 0:ZV(_)}t[2]=c,t[3]=l,t[4]=s,t[5]=a,t[6]=o,t[7]=n.colorPicker,t[8]=n.cssLengthInput,t[9]=n.documentPicker,t[10]=n.iconPicker,t[11]=n.language,t[12]=n.mirrorSourcePicker,t[13]=n.name,t[14]=e,t[15]=d,t[16]=r,t[17]=i,t[18]=f,t[19]=p,t[20]=m,t[21]=h}else f=t[18],p=t[19],m=t[20],h=t[21];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let g=m,_;t[70]===n.name?_=t[71]:(_=RV(n.name),t[70]=n.name,t[71]=_);let v;t[72]!==e||t[73]!==_?(v=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:_}),t[72]=e,t[73]=_,t[74]=v):v=t[74];let y;t[75]!==c||t[76]!==l||t[77]!==s||t[78]!==f||t[79]!==g||t[80]!==a||t[81]!==o||t[82]!==e||t[83]!==p||t[84]!==d?(y=c===void 0?(0,$.jsx)(Ka,{id:e,type:`text`,value:p,placeholder:g,onChange:e=>{let t=e.target.value;if(t===``&&d){a(void 0);return}a(t)},onKeyDown:l,autoFocus:s,"data-prop-autofocus":s?``:void 0,"aria-invalid":f===null?void 0:!0,"aria-describedby":f===null?void 0:`${e}-error`,className:`h-7 text-sm`}):(0,$.jsx)(jV,{id:e,value:p,onChange:e=>{if(e===``&&d){a(void 0);return}a(e)},onSubmit:o,accept:c,placeholder:g,autoFocus:s,dataPropAutofocus:s?``:void 0,ariaInvalid:f===null?void 0:!0,ariaDescribedBy:f===null?void 0:`${e}-error`,className:`h-7 text-sm`}),t[75]=c,t[76]=l,t[77]=s,t[78]=f,t[79]=g,t[80]=a,t[81]=o,t[82]=e,t[83]=p,t[84]=d,t[85]=y):y=t[85];let b;t[86]!==c||t[87]!==a||t[88]!==u?(b=u&&(0,$.jsx)(dH,{accept:c,onUploaded:e=>a(e)}),t[86]=c,t[87]=a,t[88]=u,t[89]=b):b=t[89];let x;t[90]!==y||t[91]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[y,b]}),t[90]=y,t[91]=b,t[92]=x):x=t[92];let S;t[93]!==f||t[94]!==e?(S=f!==null&&(0,$.jsx)(`p`,{id:`${e}-error`,"data-prop-media-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:f}),t[93]=f,t[94]=e,t[95]=S):S=t[95];let C;return t[96]!==v||t[97]!==x||t[98]!==S?(C=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[v,x,S]}),t[96]=v,t[97]=x,t[98]=S,t[99]=C):C=t[99],C}case`boolean`:{let e=`prop-${n.name}`,i;t[100]===n.name?i=t[101]:(i=RV(n.name),t[100]=n.name,t[101]=i);let o=i,s;t[102]!==e||t[103]!==o?(s=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[102]=e,t[103]=o,t[104]=s):s=t[104];let c=!!r,l;t[105]===a?l=t[106]:(l=e=>a(e),t[105]=a,t[106]=l);let u;t[107]!==e||t[108]!==c||t[109]!==l?(u=(0,$.jsx)(L,{id:e,checked:c,onCheckedChange:l}),t[107]=e,t[108]=c,t[109]=l,t[110]=u):u=t[110];let d;return t[111]!==s||t[112]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[s,u]}),t[111]=s,t[112]=u,t[113]=d):d=t[113],d}case`enum`:{let e=`prop-${n.name}`,i=r??n.enumValues[0]??``,o;t[114]===n.name?o=t[115]:(o=RV(n.name),t[114]=n.name,t[115]=o);let s;t[116]!==e||t[117]!==o?(s=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[116]=e,t[117]=o,t[118]=s):s=t[118];let c;t[119]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(F,{}),t[119]=c):c=t[119];let l;t[120]===e?l=t[121]:(l=(0,$.jsx)(P,{id:e,size:`sm`,children:c}),t[120]=e,t[121]=l);let u;t[122]===n.enumValues?u=t[123]:(u=n.enumValues.map(uH),t[122]=n.enumValues,t[123]=u);let d;t[124]===u?d=t[125]:(d=(0,$.jsx)(N,{className:`z-70`,children:u}),t[124]=u,t[125]=d);let f;t[126]!==i||t[127]!==a||t[128]!==l||t[129]!==d?(f=(0,$.jsxs)(I,{value:i,onValueChange:a,children:[l,d]}),t[126]=i,t[127]=a,t[128]=l,t[129]=d,t[130]=f):f=t[130];let p;return t[131]!==s||t[132]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s,f]}),t[131]=s,t[132]=f,t[133]=p):p=t[133],p}case`number`:{let e=`prop-${n.name}`,i;t[134]===n.name?i=t[135]:(i=RV(n.name),t[134]=n.name,t[135]=i);let o;t[136]!==e||t[137]!==i?(o=(0,$.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:i}),t[136]=e,t[137]=i,t[138]=o):o=t[138];let s=r==null?``:String(r),c;t[139]===a?c=t[140]:(c=e=>{let t=e.target.value;if(t===``){a(void 0);return}if(t===`-`)return;let n=Number(t);Number.isNaN(n)||a(n)},t[139]=a,t[140]=c);let u;t[141]!==l||t[142]!==e||t[143]!==s||t[144]!==c?(u=(0,$.jsx)(Ka,{id:e,type:`number`,inputMode:`numeric`,value:s,onChange:c,onKeyDown:l,className:`h-7 text-sm`}),t[141]=l,t[142]=e,t[143]=s,t[144]=c,t[145]=u):u=t[145];let d;return t[146]!==o||t[147]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[o,u]}),t[146]=o,t[147]=u,t[148]=d):d=t[148],d}default:{let e;return t[149]===n?e=t[150]:(e=cH(n),t[149]=n,t[150]=e),e}}}function uH(e){return(0,$.jsx)(M,{value:e,children:e},e)}function dH(e){let t=(0,Q.c)(18),{accept:n,onUploaded:r}=e,i=xs(),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null),l;t[0]===n?l=t[1]:(l=n.join(`,`),t[0]=n,t[1]=l);let u;t[2]!==n||t[3]!==r||t[4]!==i?(u=async e=>{let t=e.target.files?.[0];if(t){s(!0);try{await iH(t,n,r,i)}catch{}s(!1),c.current&&(c.current.value=``)}},t[2]=n,t[3]=r,t[4]=i,t[5]=u):u=t[5];let d;t[6]!==l||t[7]!==u?(d=(0,$.jsx)(`input`,{ref:c,type:`file`,accept:l,className:`hidden`,"data-prop-upload-input":``,onChange:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>c.current?.click(),t[9]=f):f=t[9];let p;t[10]===o?p=t[11]:(p=o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Si,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(a,{id:`_eguJc`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ou,{className:`size-3.5`,"aria-hidden":`true`}),(0,$.jsx)(a,{id:`eJitUk`})]}),t[10]=o,t[11]=p);let m;t[12]!==p||t[13]!==o?(m=(0,$.jsx)(ee,{type:`button`,variant:`outline`,size:`sm`,disabled:o,"data-prop-upload-trigger":``,className:`h-7 w-full justify-center gap-1.5 px-2 text-xs`,onClick:f,children:p}),t[12]=p,t[13]=o,t[14]=m):m=t[14];let h;return t[15]!==d||t[16]!==m?(h=(0,$.jsxs)($.Fragment,{children:[d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17],h}var fH=`selectionStatePlugin/origin`,pH=`selectionStatePlugin/refresh`,mH=new G(`selectionState`),hH=new Set,gH={selectedBlockId:null,ancestorChain:[],selectionOrigin:`programmatic`,isDragging:!1,rangeEncompassedBlockIds:hH};function _H(e){return mH.getState(e.state)??gH}function vH(e,t){let n=[],{$from:r}=t;for(let t=1;t<=r.depth;t++){let i=r.node(t);if(i.type.name!==`jsxComponent`)continue;let a=r.before(t);n.push(yH(e,i,a))}if(t instanceof xe){let r=t.node;r.type.name===`jsxComponent`&&n.push(yH(e,r,t.from))}return n}function yH(e,t,n){let r=t.attrs.componentName??`unknown`;return{bridgeId:bH(e,n),componentName:r,pos:n}}function bH(e,t){return Sw.getState(e)?.posToId.get(t)??`pos-${t}`}function xH(e,t){if(t instanceof xe)return hH;let{from:n,to:r}=t;if(n>=r)return hH;let i=Sw.getState(e)?.posToId;if(!i)return hH;let a=null;for(let[t,o]of i){if(t<n)continue;let i=e.doc.nodeAt(t);i&&(t+i.nodeSize>r||(a||=new Set,a.add(o)))}return a??hH}function SH(e,t,n={}){let r=vH(e,e.selection),i=r[r.length-1],a=xH(e,e.selection),o={selectedBlockId:i?.bridgeId??null,ancestorChain:r,selectionOrigin:n.origin??t.selectionOrigin,isDragging:n.isDragging??t.isDragging,rangeEncompassedBlockIds:a};return CH(t,o)?t:o}function CH(e,t){if(e===t)return!0;if(e.selectedBlockId!==t.selectedBlockId||e.selectionOrigin!==t.selectionOrigin||e.isDragging!==t.isDragging||e.ancestorChain.length!==t.ancestorChain.length)return!1;for(let n=0;n<e.ancestorChain.length;n++){let r=e.ancestorChain[n],i=t.ancestorChain[n];if(r.bridgeId!==i.bridgeId||r.componentName!==i.componentName||r.pos!==i.pos)return!1}if(e.rangeEncompassedBlockIds.size!==t.rangeEncompassedBlockIds.size)return!1;for(let n of e.rangeEncompassedBlockIds)if(!t.rangeEncompassedBlockIds.has(n))return!1;return!0}var wH=new WeakMap;function TH(e,t,n,r){let i=r?.isDragging??t.isDragging,a=!!e.getMeta(pH),o=e.selectionSet&&!a,s=e.getMeta(fH),c=o?r?.pendingOrigin??null:null,l=s??c??t.selectionOrigin;return o&&r&&(r.pendingOrigin=null),SH(n,t,{origin:l,isDragging:i})}var EH=_e.create({name:`selectionStatePlugin`,addProseMirrorPlugins(){let e=this.editor,t=new J({key:mH,state:{init(e,t){return SH(t,gH)},apply(e,n,r,i){return TH(e,n,i,wH.get(t))}},props:{handleDOMEvents:{mousedown:()=>{let e=wH.get(t);return e&&(e.pendingOrigin=`pointer`),!1},pointerdown:()=>{let e=wH.get(t);return e&&(e.pendingOrigin=`pointer`),!1}},handleKeyDown:(e,n)=>{if(DH(n.key)){let e=wH.get(t);e&&(e.pendingOrigin=`keyboard`)}return!1}},view(n){wH.set(t,{pendingOrigin:null,isDragging:!1});let r=n.dom.parentElement??n.dom,i=()=>{let n=wH.get(t);n&&(n.isDragging=!0,OH(e))},a=()=>{let n=wH.get(t);n&&(n.isDragging=!1,OH(e))};return r.addEventListener(`dragstart`,i,!0),r.addEventListener(`dragend`,a,!0),r.addEventListener(`drop`,a,!0),{destroy:()=>{r.removeEventListener(`dragstart`,i,!0),r.removeEventListener(`dragend`,a,!0),r.removeEventListener(`drop`,a,!0),wH.delete(t)}}}});return[t]}});function DH(e){return e===`ArrowUp`||e===`ArrowDown`||e===`ArrowLeft`||e===`ArrowRight`||e===`Tab`||e===`Escape`||e===`Enter`||e===`Home`||e===`End`||e===`PageUp`||e===`PageDown`}function OH(e){queueMicrotask(()=>{if(!e.isDestroyed)try{let t=e.state.tr.setMeta(pH,!0);e.view.dispatch(t)}catch{}})}function kH(e){let t=(0,Q.c)(5),n;t[0]===e?n=t[1]:(n=()=>e?_H(e):null,t[0]=e,t[1]=n);let[r,i]=(0,Z.useState)(n),a,o;return t[2]===e?(a=t[3],o=t[4]):(a=()=>{if(!e){i(null);return}i(_H(e));let t=()=>{i(_H(e))};return e.on(`transaction`,t),e.on(`selectionUpdate`,t),()=>{e.off(`transaction`,t),e.off(`selectionUpdate`,t)}},o=[e],t[2]=e,t[3]=a,t[4]=o),(0,Z.useEffect)(a,o),r}function AH(e,t){if(e.hasChildren)return!1;let n=LV(e.props);return n===null?!1:t[n]===``}function jH(e){let t=e.placeholder?.label,n=`Add ${(e.displayName??e.name).toLowerCase()}`;return{label:t??n,Icon:iv(e.placeholder?.icon??e.icon)}}function MH(e,t){let n=e.state.schema.nodes.paragraph?.create();if(!n)return!1;let r=e.state.tr.insert(t,n);return r.doc.content.size===e.state.doc.content.size?!1:(r.setSelection(K.near(r.doc.resolve(t+1))),e.dispatch(r.scrollIntoView()),!0)}function NH(e,t,n){let{doc:r}=e.state,i=ve.findFrom(r.resolve(t+n),1,!0);return i?(e.dispatch(e.state.tr.setSelection(i).scrollIntoView()),!0):!1}function PH(e,t,n){let{doc:r}=e.state,i=new yn(r.resolve(t+n)).map(r,new Ce);return i instanceof yn?(e.dispatch(e.state.tr.setSelection(i).scrollIntoView()),!0):!1}function FH(e){if(!e.attrs.sourceDirty&&e.attrs.sourceRaw)return e.attrs.sourceRaw;let t=oi(),n=e.type.schema.node(`doc`,null,[e]);return t.serialize(n.toJSON()).trim()}function IH(e,t,n){let r=t();if(r===void 0)return{kind:`removed`};let i=e.nodeAt(r);return i?{kind:i.eq(n)?`current`:`changed`,pos:r,node:i}:{kind:`removed`}}function LH(e,t){return e.type===t.type&&e.attrs.kind===`element`&&e.attrs.componentName===t.attrs.componentName}function RH(e,t,n){Fr(t),console.warn(JSON.stringify({event:`jsx-component-action-aborted`,action:t,reason:n,component:e.descriptorName===`*`?`wildcard`:e.descriptorName,rawComponentName:String(e.node.attrs.componentName??``).slice(0,200)})),z.info(n===`removed`?Y._({id:`BfTQmM`}):Y._({id:`NXNzgx`}))}function zH(e,t){let n=IH(e.editor.state.doc,e.getPos,e.node);return n.kind===`current`?n:(RH(e,t,n.kind),null)}var BH=new Set(Ji.map(e=>`${e}:`)),VH=6e4,HH=10,UH=new Map;function WH(e,t){let n=t.toLowerCase();ai(n);let r=Date.now(),i=UH.get(n);if(!i||r-i.windowStart>=VH)UH.set(n,{windowStart:r,count:1});else if(i.count+=1,i.count>HH)return;typeof console<`u`&&typeof console.warn==`function`&&console.warn(JSON.stringify({event:`jsx-prop-dropped`,reason:e,prop:t}))}var GH=new Set([`href`,`src`,`action`,`formaction`,`poster`,`cite`,`data`,`manifest`,`background`,`ping`,`xlinkhref`,`xlinkactuate`,`xlinkrole`,`xlinkarcrole`,`xlinkshow`,`url`,`link`]),KH=new Set([`dangerouslysetinnerhtml`,`ref`,`key`,`defaultvalue`,`defaultchecked`,`__proto__`,`constructor`,`prototype`]),qH=1e4;function JH(e){let t=e.toLowerCase();return!!(KH.has(t)||t.length>=3&&t.startsWith(`on`))}function YH(e){return GH.has(e.toLowerCase())}function XH(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t||t.startsWith(`#`)||t.startsWith(`//`)||Qi(t))return e;let n=t.indexOf(`:`),r=t.slice(0,n+1).toLowerCase();return BH.has(r)?e:`#`}function ZH(e){if(e.length>qH)return``;let t=e.toLowerCase();return/url\s*\(\s*['"]?\s*(?:javascript|vbscript|data)\s*:/.test(t)||/\bexpression\s*\(/.test(t)?``:e}function QH(e){if(e==null)return e;if(Array.isArray(e)){let t=!1,n=Array(e.length);for(let r=0;r<e.length;r++){let i=QH(e[r]);n[r]=i,i!==e[r]&&(t=!0)}return t?n:e}if(typeof e!=`object`)return e;let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;let n=e,r=!1,i={};for(let[e,t]of Object.entries(n)){if(JH(e)){WH(`dangerous-prop-name-nested`,e),r=!0;continue}if(YH(e)&&typeof t==`string`){let n=XH(t);n!==t&&(r=!0),i[e]=n}else{let n=QH(t);n!==t&&(r=!0),i[e]=n}}return r?i:e}function $H(e){let t=si(e);if(t)throw RangeError(t);let n=!1,r={};for(let[t,i]of Object.entries(e)){if(JH(t)){WH(`dangerous-prop-name`,t),n=!0;continue}if(YH(t)){let e=XH(i);e!==i&&(n=!0),r[t]=e;continue}if(t===`style`){if(typeof i==`string`){let e=ZH(i);e!==i&&(n=!0),r[t]=e}else n=!0;continue}let e=QH(i);e!==i&&(n=!0),r[t]=e}return n?r:e}var eU=new Set([`img`,`CommonMarkImage`,`video`,`audio`,`Pdf`,`File`,`Excalidraw`]);function tU(e,t,n){if(!eU.has(e)||!n)return t;let r=t.src;if(typeof r!=`string`)return t;let i=Zi(r,n);return i===r?t:{...t,src:i}}var nU=`jsx-component-wrapper my-2`;function rU(e,t,n=!1){let r=fi(t.props,e.props??{}),i={};for(let[e,a]of Object.entries(r))t.reactNodePropNames.has(e)&&!(n&&e===`children`&&typeof a==`string`&&a!==``)||(i[e]=a);return $H(i)}function iU(e,t,n=!1){let r=si(e.props);if(r)return{props:{},error:r};try{return{props:rU(e,t,n),error:null}}catch(e){if(e instanceof RangeError&&e.message===`Component props exceed the rendering budget`)return{props:{},error:e.message};throw e}}function aU(e,t){let n=e.docName;return typeof n==`string`&&n?n:Xt(t)}function oU(e,t,n){let r=e.surface===`compat`?e.translateProps(t):t;return tU(e.name,r,n)}function sU(e,t){let n=t.align;return n===`left`||n===`right`||n===`center`?n:HI.has(e.name)?`center`:void 0}function cU(e,t){return{"data-jsx-component":``,"data-component-type":e.name.toLowerCase(),"data-component-name":e.name,"data-align":sU(e,t)}}function lU(e,t){return!e.hasChildren&&t.childCount===0?`component-children min-h-0 m-0 p-0`:`component-children`}function uU(e,t,n,r){let i=n instanceof Error?n:Error(String(n));return console.warn(JSON.stringify({event:`jsx-render-failure`,component:e,rawComponentName:String(t??``).slice(0,200),error:String(i),stack:r.componentStack})),lr(e),i}function dU(e){let t=(0,Q.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`jsx-component-error-fallback`,children:n}),t[0]=n,t[1]=r),r}function fU(e){let t=(0,Q.c)(13),{children:n,resetKey:r,onError:i,descriptorName:a,rawComponentName:o}=e,s;t[0]===r?s=t[1]:(s=[r],t[0]=r,t[1]=s);let c;t[2]!==a||t[3]!==i||t[4]!==o?(c=(e,t)=>{i(uU(a,o,e,t))},t[2]=a,t[3]=i,t[4]=o,t[5]=c):c=t[5];let l;t[6]===n?l=t[7]:(l=e=>(0,$.jsx)(dU,{...e,children:n}),t[6]=n,t[7]=l);let d;return t[8]!==n||t[9]!==s||t[10]!==c||t[11]!==l?(d=(0,$.jsx)(u,{resetKeys:s,onError:c,fallbackRender:l,children:n}),t[8]=n,t[9]=s,t[10]=c,t[11]=l,t[12]=d):d=t[12],d}function pU(e){let t=si(e);if(t)throw RangeError(t);return mU(e)}function mU(e){if(typeof e!=`object`||!e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(mU).join(`,`)}]`;let t=Object.entries(e);return t.sort(([e],[t])=>e<t?-1:+(e>t)),`{${t.map(([e,t])=>`${JSON.stringify(e)}:${mU(t)}`).join(`,`)}}`}function hU(e){return e.kind===`element`?e:null}function gU(e,t){if(typeof e!=`object`||!e)return!1;let{type:n,name:r}=e;return n===`mdxJsxAttribute`&&typeof r==`string`&&t.has(r)}function _U(e,t,n,r){let i=t.props.find(e=>e.name===n)?.legacyNames??[],a=new Set(r===void 0?[n,...i]:i),o={...e.props};for(let e of a)delete o[e];r!==void 0&&(o[n]=r),n===`src`&&e.componentName===`CommonMarkImage`&&r!==e.props.src&&delete o.sourceUrl;let s=Array.isArray(e.attributes)?e.attributes:[];return{...e,attributes:a.size===0?s:s.filter(e=>!gU(e,a)),props:o,sourceDirty:!0}}var vU=3;function yU(e){let t=(0,Q.c)(60),{node:n,editor:r,extension:i,getPos:s,selected:c}=e,{_:l}=o(),u=ZS(n.attrs.componentName),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(!1),h=(0,Z.useRef)(!1),g=(0,Z.useRef)(!1),_=typeof s==`function`?s():void 0,v=aO(),y=!1,b=0,x=1;try{if(_!==void 0){let e=r.state.doc.resolve(_);e.depth>0&&e.parent.type.name===`jsxComponent`&&(y=!0,b=e.index(e.depth),x=e.parent.childCount)}}catch(e){let t=e;if(!(t instanceof RangeError))throw t}let S=y&&b>0,C=y&&b<x-1,w=kH(r),T=typeof _==`number`?bH(r.state,_):null,E=T!==null&&(w?.rangeEncompassedBlockIds.has(T)??!1),D;t[0]===w?.ancestorChain?D=t[1]:(D=w?.ancestorChain.at(-1)?.bridgeId??null,t[0]=w?.ancestorChain,t[1]=D);let O=T!==null&&D===T,k=c&&!E&&O,A=T!==null&&!O&&(w?.ancestorChain.some(e=>e.bridgeId===T)??!1),j=k&&w?w.selectionOrigin:void 0,M=k&&(w?.isDragging??!1),N=u.props.some(TU),P=n.attrs.props??{},{props:F,error:I}=iU(n.attrs,u),L=N&&u.props.some(e=>e.type!==`string`||!e.required||`hidden`in e&&e.hidden?!1:!Object.hasOwn(F,e.name)),R=AH(u,P),te=R?jH(u):null,ne=!u.hasChildren||!!u.isSelfClosing,re=u.name===`MermaidFence`?{propName:`chart`,language:`mermaid`}:u.name===`Math`||u.name===`DollarMath`||u.name===`MathFence`?{propName:`formula`,language:`latex`}:null,[ie,ae]=(0,Z.useState)(!1),[oe,se]=(0,Z.useState)(!1),[z,B]=(0,Z.useState)(!1),ce=re!==null,V=re?P[re.propName]:void 0,H=ce&&!N&&r.isEditable&&(typeof V!=`string`||V.trim()===``),U=H?jH(u):null;(0,Z.useEffect)(()=>{c&&!g.current&&(N||ce)&&fC(_)&&(N?m(!0):ae(!0)),g.current=c},[c,N,ce,_]);let W=oU(u,F,aU(i.options,r)),le=u.name===`MermaidFence`&&typeof W.chart==`string`?W.chart:null,G=le!==null&&le.trim()!==``?le:null,ue=G!==null,K;t[2]!==ue||t[3]!==se?(K=()=>{ue||se(!1)},t[2]=ue,t[3]=se,t[4]=K):K=t[4];let de;t[5]===ue?de=t[6]:(de=[ue],t[5]=ue,t[6]=de),(0,Z.useEffect)(K,de);let fe=u.name===`Excalidraw`&&Xv(W.src);(0,Z.useEffect)(()=>{fe||B(!1)},[fe]);let pe=`${u.name}::${pU(F)}`,q={editor:r,getPos:s,node:n,descriptorName:u.name},me=(e,t)=>RH(q,e,t),J=e=>zH(q,e),he=e=>{let t=IH(r.state.doc,s,n);return t.kind===`removed`||!LH(t.node,n)?(me(e,t.kind===`removed`?`removed`:`changed`),null):t},ge=e=>{let t=J(`insert-child`);if(!t)return;let n=t.pos+1+t.node.content.size;r.chain().focus().insertContentAt(n,lC(e)).run(),pC(r,n,ZS(e))},_e=u.name===`*`||d!==null,ve=(0,Z.useRef)(!1),ye=(0,Z.useRef)(0),[be,xe]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{if(!_e||ve.current||be)return;let e=FH(n),t=u.name===`*`?`Unregistered component: ${n.attrs.componentName}`:`Render error in <${u.displayName??u.name}>: ${d?.message??`unknown`}`,i=n.type.schema.nodes.rawMdxFallback.create({reason:t},n.type.schema.text(e)),a=!1,o,c=()=>{if(a||!wr(r))return;let e=e=>{let t=u.name===`*`?`wildcard`:u.name;if(console.warn(JSON.stringify({event:`jsx-component-auto-convert-failed`,component:t,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:e.slice(0,500),retry:ye.current})),Sr(t),ye.current+=1,ye.current<vU){let e=50*(2**ye.current-1);o=setTimeout(()=>{a||c()},e)}else a||xe(!0)},t=br(r);if(!t){e(`ProseMirror view not mounted`);return}try{let e=IH(t.state.doc,s,n);if(e.kind!==`current`)return;let r=e.pos;t.dispatch(xn(t.state.tr.replaceWith(r,r+n.nodeSize,i))),ve.current=!0,tr(u.name===`*`?`wildcard`:u.name)}catch(t){let n=t;e(n instanceof Error?n.message:String(n))}},l=requestAnimationFrame(c);return()=>{a=!0,cancelAnimationFrame(l),o!==void 0&&clearTimeout(o)}},[_e,n,r,s,u,d,be]),be){let e=n.attrs.componentName,i=u.displayName??u.name,a=u.name===`*`?l({id:`Kh1n4a`,values:{componentName:e}}):l({id:`g58Kwy`,values:{descriptorLabel:i}}),o=()=>{try{let e=FH(n);typeof navigator<`u`&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(e)}catch(e){let t=e;mr(u.name),console.warn(JSON.stringify({event:`jsx-component-stuck-copy-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t instanceof Error?t.message.slice(0,500):String(t).slice(0,500)}))}},s=()=>{try{let e=J(`delete-stuck`);if(!e)return;r.chain().focus().setNodeSelection(e.pos).deleteSelection().run()}catch(e){let t=e;if(!(t instanceof RangeError))throw t;Hr(u.name),console.warn(JSON.stringify({event:`jsx-component-stuck-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},c;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c={[Gy]:`true`},t[7]=c):c=t[7];let d;t[8]===a?d=t[9]:(d=(0,$.jsx)(`span`,{className:`flex-1`,children:a}),t[8]=a,t[9]=d);let f;t[10]===l?f=t[11]:(f=l({id:`E2Mv-X`}),t[10]=l,t[11]=f);let p;t[12]!==o||t[13]!==f?(p=(0,$.jsx)(`button`,{type:`button`,className:`text-xs underline hover:no-underline`,onClick:o,children:f}),t[12]=o,t[13]=f,t[14]=p):p=t[14];let m;t[15]===l?m=t[16]:(m=l({id:`cnGeoo`}),t[15]=l,t[16]=m);let h;return t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Ir,{className:`component-children`}),t[17]=h):h=t[17],(0,$.jsxs)(Xr,{className:`jsx-component-wrapper my-2`,children:[(0,$.jsxs)(`div`,{className:`text-xs font-mono text-muted-foreground px-2 py-2 border border-destructive/40 rounded flex items-center gap-2`,contentEditable:!1,...c,children:[d,p,(0,$.jsx)(`button`,{type:`button`,className:`text-xs underline hover:no-underline`,onClick:s,children:m})]}),h]})}if(I){let e;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e={[Gy]:`true`},t[18]=e):e=t[18];let n;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`span`,{role:`status`,children:(0,$.jsx)(a,{id:`MzoWIU`})}),t[19]=n):n=t[19];let i;return t[20]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(Ir,{className:`component-children`}),t[20]=i):i=t[20],(0,$.jsxs)(Xr,{className:`jsx-component-wrapper my-2`,"data-jsx-props-error":``,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-2 py-1 text-xs text-warning`,contentEditable:!1,...e,children:[n,(0,$.jsx)(JB,{editor:r,getTargetPosition:()=>J(`edit-source`)?.pos})]}),i]})}if(_e){let e=n.attrs.componentName,r=u.displayName??u.name,i=u.name===`*`?l({id:`oJl7eO`,values:{componentName:e}}):l({id:`bcDHUM`,values:{descriptorLabel:r}}),a;t[21]===i?a=t[22]:(a=(0,$.jsx)(`div`,{className:`text-xs font-mono text-muted-foreground px-2 py-1`,contentEditable:!1,children:i}),t[21]=i,t[22]=a);let o;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Ir,{className:`component-children`}),t[23]=o):o=t[23];let s;return t[24]===a?s=t[25]:(s=(0,$.jsxs)(Xr,{className:`jsx-component-wrapper my-2`,children:[a,o]}),t[24]=a,t[25]=s),s}let Se=u.Component,Ce=u.displayName??u.name,we=u.displayName??u.name,Te=u.displayName??u.name,Ee=e=>{if(R||H||!ne)return;let t=e.target;if(!e.currentTarget.contains(t)||t.closest(`.jsx-component-chrome`)||t.closest(`.jsx-add-child-pill, .jsx-empty-child-placeholder`)||t.closest(`a[href]`))return;let i=IH(r.state.doc,s,n);if(i.kind!==`current`)return;let a=i.pos,o=a+n.nodeSize,c=r.state.selection.from;c<a||c>=o||r.chain().focus().setNodeSelection(a).run()},De=()=>{let e=J(`open-properties`);e&&(r.chain().focus().setNodeSelection(e.pos).run(),m(!0))},Oe=u.displayName??u.name,ke=!!u.emptyChildName,Ae=ke?IV(Oe,u.emptyChildName,n.childCount):void 0,Y=e=>{let t=e.target;if(e.key===`Backspace`||e.key===`Delete`){if(!k||!e.currentTarget.contains(t)||t.matches(`input, textarea`))return;e.preventDefault();try{let e=J(`delete-keyboard`);if(!e)return;r.chain().focus().setNodeSelection(e.pos).deleteSelection().run()||($r(u.name),console.warn(JSON.stringify({event:`jsx-component-keyboard-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:`chain-dispatch-returned-false`})))}catch(e){let t=e;if(!(t instanceof RangeError))throw t;$r(u.name),console.warn(JSON.stringify({event:`jsx-component-keyboard-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}return}e.key!==`Enter`&&e.key!==` `||c&&N&&(t.closest(`.jsx-component-chrome`)||t.closest(`input, textarea, select, button`)||(e.preventDefault(),m(!0)))},je=e=>{m(e),!e&&requestAnimationFrame(()=>{try{let e=IH(r.state.doc,s,n);if(e.kind!==`current`)return;let{pos:t,node:i}=e,a=t+i.nodeSize,o=r.state.selection.from;if(o<t||o>=a)return;(!ne||!NH(r.view,t,i.nodeSize)&&!PH(r.view,t,i.nodeSize))&&r.chain().setNodeSelection(t).run()}catch(e){let t=e;if(!(t instanceof RangeError))throw t;Or(u.name),console.warn(JSON.stringify({event:`jsx-component-popover-close-restore-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}})},Me=cU(u,P),Ne;t[26]===y?Ne=t[27]:(Ne=y?{draggable:`false`,onDragStart:wU}:{"data-drag-handle":``,draggable:`true`},t[26]=y,t[27]=Ne);let Pe;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(Pe={[Gy]:`true`},t[28]=Pe):Pe=t[28];let Fe;t[29]!==l||t[30]!==Ce?(Fe=l({id:`MCjC9A`,values:{deleteDescriptorLabel:Ce}}),t[29]=l,t[30]=Ce,t[31]=Fe):Fe=t[31];let Ie;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=(0,$.jsx)(Ai,{size:12,"aria-hidden":`true`}),t[32]=Ie):Ie=t[32];let Le;t[33]!==oe||t[34]!==G||t[35]!==se?(Le=G===null?null:(0,$.jsx)(Ot,{chart:G,open:oe,onOpenChange:se}),t[33]=oe,t[34]=G,t[35]=se,t[36]=Le):Le=t[36];let Re;t[37]!==l||t[38]!==P||t[39]!==u||t[40]!==ie||t[41]!==re||t[42]!==r.isEditable||t[43]!==r.state.tr||t[44]!==r.view||t[45]!==_||t[46]!==W||t[47]!==he||t[48]!==ae?(Re=re&&typeof _==`number`?(0,$.jsx)(lF,{open:ie,onOpenChange:ae,initialValue:typeof P[re.propName]==`string`?P[re.propName]:``,language:re.language,title:l({id:`ky9Tuc`,values:{0:u.displayName??u.name}}),renderPreview:(e,t)=>{let n=u.Component;return(0,$.jsx)(`div`,{className:`flex h-full w-full items-center justify-center p-4`,children:(0,$.jsx)(n,{...W,[re.propName]:e,...u.name===`MermaidFence`&&{className:`border-0 bg-transparent rounded-none`,editBinding:{canEdit:r.isEditable,commitChart:t}}})})},onSave:e=>{let t=he(`edit-source`);if(!t)return;let{pos:n,node:i}=t,a=hU(i.attrs);if(a)try{let t={...a.props,[re.propName]:e},i={...a,props:t,sourceDirty:!0};r.view.dispatch(r.state.tr.setNodeMarkup(n,null,i)),En()}catch(e){let t=e;if(!(t instanceof RangeError))throw t;console.warn(`[JsxComponentView] edit-save failed — position race`,t)}}}):null,t[37]=l,t[38]=P,t[39]=u,t[40]=ie,t[41]=re,t[42]=r.isEditable,t[43]=r.state.tr,t[44]=r.view,t[45]=_,t[46]=W,t[47]=he,t[48]=ae,t[49]=Re):Re=t[49];let ze;return t[50]!==u||t[51]!==r||t[52]!==N||t[53]!==ne||t[54]!==F||t[55]!==Te||t[56]!==he||t[57]!==m||t[58]!==R?(ze=N&&(0,$.jsxs)(ya,{side:R?`bottom`:`right`,align:R?`center`:`start`,sideOffset:R?-4:8,className:`w-64 p-3 z-60 overflow-y-auto subtle-scrollbar max-h-(--radix-popper-available-height) overscroll-contain`,onInteractOutside:()=>{h.current=!0},onCloseAutoFocus:e=>{let t=h.current;if(h.current=!1,!ne&&t)return;e.preventDefault();let n=br(r);n&&!n.isDestroyed&&n.focus()},children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,$.jsx)(a,{id:`Mnavhe`,values:{propPanelDescriptorLabel:Te}})}),(0,$.jsx)(aH,{descriptor:u,values:F,onDismiss:()=>m(!1),onChange:(e,t)=>{let n=he(`edit-properties`);if(!n)return;let{pos:i,node:a}=n,o=hU(a.attrs);o&&(r.view.dispatch(r.state.tr.setNodeMarkup(i,null,_U(o,u,e,t))),En())}}),(0,$.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-border pt-2`,children:(0,$.jsx)(ee,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>m(!1),className:`h-7 px-3 text-xs`,children:(0,$.jsx)(a,{id:`DPfwMq`})})})]}),t[50]=u,t[51]=r,t[52]=N,t[53]=ne,t[54]=F,t[55]=Te,t[56]=he,t[57]=m,t[58]=R,t[59]=ze):ze=t[59],(0,$.jsxs)(xa,{open:p,onOpenChange:je,children:[(0,$.jsxs)(Xr,{className:nU,...Me,"data-selected":k?`true`:void 0,"data-has-child-selected":A?`true`:void 0,"data-range-selected":E?`true`:void 0,"data-selection-origin":j,"data-dragging":M?`true`:void 0,"data-needs-config":L?`true`:void 0,role:ke?`group`:void 0,"aria-label":Ae,tabIndex:k?0:-1,...Ne,onClick:Ee,onKeyDown:Y,children:[(0,$.jsxs)(`div`,{className:`jsx-component-chrome`,contentEditable:!1,onMouseDown:CU,...Pe,children:[u.name===`Embed`&&typeof F.src==`string`&&/^https?:\/\//i.test(F.src)&&(0,$.jsx)(`a`,{href:F.src,target:`_blank`,rel:`noopener noreferrer`,className:`jsx-chrome-btn`,"aria-label":l({id:`iOHg1t`}),onMouseDown:SU,children:(0,$.jsx)(Yl,{size:12,"aria-hidden":`true`})}),u.name===`Mirror`&&xb(F.src)!==``&&(()=>{let e=xb(F.src),t=xb(F.name);return(0,$.jsx)(`a`,{href:t===``?pa(e):oa(e,t),className:`jsx-chrome-btn`,"aria-label":l({id:`3a_Bd7`,values:{mirrorSrc:e}}),title:l({id:`0kTAXe`,values:{mirrorSrc:e}}),onMouseDown:xU,children:(0,$.jsx)(Yl,{size:12,"aria-hidden":`true`})})})(),S&&(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`QyioBP`}),onClick:()=>{try{let e=J(`move-up`);if(!e)return;let t=e.pos,i=r.state.doc.resolve(t),a=i.index(i.depth);if(a===0)return;let o=t-i.node(i.depth).child(a-1).nodeSize,s=t+n.nodeSize,c=r.state.tr,l=r.state.doc.slice(t,t+n.nodeSize),u=r.state.doc.slice(o,t);c.replaceWith(o,s,l.content.append(u.content)),r.view.dispatch(c.scrollIntoView())}catch(e){let t=e;if(!(t instanceof RangeError))throw t;or(`up`),console.warn(JSON.stringify({event:`jsx-component-move-failed`,direction:`up`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},children:(0,$.jsx)(yt,{size:12,"aria-hidden":`true`})}),C&&(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`3Ib6FN`}),onClick:()=>{try{let e=J(`move-down`);if(!e)return;let t=e.pos,i=r.state.doc.resolve(t),a=i.index(i.depth),o=i.node(i.depth);if(a>=o.childCount-1)return;let s=o.child(a+1),c=t,l=t+n.nodeSize+s.nodeSize,u=r.state.tr,d=r.state.doc.slice(t,t+n.nodeSize),f=r.state.doc.slice(t+n.nodeSize,l);u.replaceWith(c,l,f.content.append(d.content)),r.view.dispatch(u.scrollIntoView())}catch(e){let t=e;if(!(t instanceof RangeError))throw t;or(`down`),console.warn(JSON.stringify({event:`jsx-component-move-failed`,direction:`down`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},children:(0,$.jsx)(vt,{size:12,"aria-hidden":`true`})}),re&&typeof _==`number`?(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`ky9Tuc`,values:{0:u.displayName??u.name}}),"data-testid":`jsx-component-edit-btn`,onClick:()=>ae(!0),children:(0,$.jsx)(Ei,{size:12,"aria-hidden":`true`})}):null,G===null?null:(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`HimZ41`}),"data-testid":`jsx-component-expand-btn`,onClick:()=>se(!0),children:(0,$.jsx)(Ci,{size:12,"aria-hidden":`true`})}),fe?(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`lT6wjt`}),"data-testid":`jsx-component-expand-board-btn`,onClick:()=>B(!0),children:(0,$.jsx)(Ci,{size:12,"aria-hidden":`true`})}):null,!v&&Xu(n).length>0&&typeof _==`number`?(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`INp_z6`,values:{0:u.displayName??u.name}}),"data-testid":`jsx-component-ask-ai-btn`,onClick:()=>{try{let e=J(`comment`);if(!e)return;r.commands.setNodeSelection(e.pos)}catch(e){let t=e;console.warn(JSON.stringify({event:`jsx-component-chrome-ask-ai-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t instanceof Error?t.message.slice(0,500):String(t)}));return}requestAnimationFrame(()=>{try{Fl()}catch(e){let t=e;console.warn(JSON.stringify({event:`jsx-component-chrome-ask-ai-emit-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t instanceof Error?t.message.slice(0,500):String(t)}))}})},children:(0,$.jsx)(ki,{size:12,"aria-hidden":`true`})}):null,(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn jsx-chrome-btn--delete`,"aria-label":Fe,onClick:()=>{try{let e=J(`delete-chrome`);if(!e)return;r.chain().focus().setNodeSelection(e.pos).deleteSelection().run()||(Rr(u.name),console.warn(JSON.stringify({event:`jsx-component-chrome-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:`chain-dispatch-returned-false`})))}catch(e){let t=e;if(!(t instanceof RangeError))throw t;Rr(u.name),console.warn(JSON.stringify({event:`jsx-component-chrome-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},children:Ie}),N&&(0,$.jsx)(va,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"data-jsx-gear":``,"aria-label":l({id:`XPJ0sN`,values:{settingsDescriptorLabel:we}}),children:(0,$.jsx)(Ht,{size:12,"aria-hidden":`true`})})})]}),R&&te?(0,$.jsx)(ba,{asChild:!0,children:(0,$.jsx)(XB,{label:te.label,Icon:te.Icon,onClick:De,selected:k})}):H&&U?(0,$.jsx)(XB,{label:U.label,Icon:U.Icon,onClick:()=>ae(!0),selected:k}):(0,$.jsx)(fU,{resetKey:pe,onError:f,descriptorName:u.name===`*`?`wildcard`:u.name,rawComponentName:n.attrs.componentName??``,children:(0,$.jsx)(Tt,{value:typeof s==`function`?{editor:r,getPos:()=>{let e=IH(r.state.doc,s,n);return e.kind!==`removed`&&LH(e.node,n)?e.pos:void 0},addChild:u.emptyChildName?()=>{let e=u.emptyChildName;ge(e)}:null}:null,children:(0,$.jsx)(Se,{...W,...G===null?{}:{onExpand:()=>se(!0)},...fe?{expandOpen:z,onExpandOpenChange:B}:{},children:(0,$.jsx)(Ir,{className:lU(u,n),...!u.hasChildren||u.isSelfClosing?{contentEditable:!1}:{}})})})}),u.emptyChildName&&!(u.name===`Tabs`&&n.childCount>0)&&(()=>{let e=u.emptyChildName;return(0,$.jsx)(`button`,{type:`button`,contentEditable:!1,className:n.childCount===0?`jsx-empty-child-placeholder`:`jsx-add-child-pill`,onMouseDown:bU,onClick:()=>{let e=u.emptyChildName;ge(e)},"data-clipboard-omit":`true`,children:(0,$.jsx)(`span`,{children:(0,$.jsx)(a,{id:`7Fkcej`,values:{addChildName:e}})})})})()]}),Le,Re,ze]})}function bU(e){return e.stopPropagation()}function xU(e){return e.stopPropagation()}function SU(e){return e.stopPropagation()}function CU(e){return e.stopPropagation()}function wU(e){return e.preventDefault()}function TU(e){return!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`}var EU=Gn.extend({addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return nr(yU)}});function DU(e){let t=(0,Q.c)(4),{node:n}=e,r=n.attrs.componentName||``;if(!r){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Xr,{as:`span`,"data-jsx-inline":``,children:(0,$.jsx)(Ir,{as:`span`})}),t[0]=e):e=t[0],e}let i;return t[1]!==r||t[2]!==e?(i=(0,$.jsx)(OU,{...e,name:r}),t[1]=r,t[2]=e,t[3]=i):i=t[3],i}function OU(e){let t=(0,Q.c)(73),{node:n,selected:r,editor:i,getPos:o,extension:s,name:c}=e,l=ZS(c),{Component:d}=l,[f,p]=(0,Z.useState)(!1),m=(0,Z.useRef)(!1),{props:h,error:g}=iU(n.attrs,l,!0),_=tU(l.name,h,aU(s.options,i)),v=`${l.name}::${pU(h)}`,y;t[0]!==i||t[1]!==o||t[2]!==p?(y=()=>{let e=()=>{let e=typeof o==`function`?o():void 0,t=i.state.selection,n=t instanceof xe&&typeof e==`number`&&t.from===e;n&&!m.current?p(!0):!n&&m.current&&p(!1),m.current=n};return i.on(`selectionUpdate`,e),e(),()=>{i.off(`selectionUpdate`,e)}},t[0]=i,t[1]=o,t[2]=p,t[3]=y):y=t[3];let b;t[4]!==i||t[5]!==o?(b=[i,o],t[4]=i,t[5]=o,t[6]=b):b=t[6],(0,Z.useEffect)(y,b);let x;if(t[7]!==h){let{children:e,...n}=h;x=n,t[7]=h,t[8]=x}else x=t[8];if(g){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e={[Gy]:`true`},t[9]=e):e=t[9];let r;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`span`,{role:`status`,children:(0,$.jsx)(a,{id:`MzoWIU`})}),t[10]=r):r=t[10];let s;t[11]!==l.name||t[12]!==i||t[13]!==o||t[14]!==n?(s=()=>zH({editor:i,getPos:o,node:n,descriptorName:l.name},`edit-source`)?.pos,t[11]=l.name,t[12]=i,t[13]=o,t[14]=n,t[15]=s):s=t[15];let c;return t[16]!==i||t[17]!==s?(c=(0,$.jsx)(Xr,{as:`span`,"data-jsx-inline":``,"data-jsx-props-error":``,children:(0,$.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1 text-xs text-warning`,contentEditable:!1,...e,children:[r,(0,$.jsx)(JB,{editor:i,getTargetPosition:s})]})}),t[16]=i,t[17]=s,t[18]=c):c=t[18],c}let S=r?`jsx-inline-selected`:void 0,C;t[19]===v?C=t[20]:(C=[v],t[19]=v,t[20]=C);let w;t[21]!==l.name||t[22]!==c?(w=(e,t)=>{let n=e instanceof Error?e:Error(String(e));console.warn(JSON.stringify({event:`jsx-render-failure`,component:l.name===`*`?`wildcard`:l.name,rawComponentName:c.slice(0,200),error:String(n),stack:t.componentStack})),lr(l.name)},t[21]=l.name,t[22]=c,t[23]=w):w=t[23];let T;t[24]===c?T=t[25]:(T=()=>(0,$.jsxs)(`span`,{className:`text-xs font-mono text-destructive`,children:[`[`,c,`]`]}),t[24]=c,t[25]=T);let E;t[26]!==d||t[27]!==_?(E=(0,$.jsx)(d,{..._}),t[26]=d,t[27]=_,t[28]=E):E=t[28];let D;t[29]!==C||t[30]!==w||t[31]!==T||t[32]!==E?(D=(0,$.jsx)(va,{asChild:!0,children:(0,$.jsx)(`span`,{"data-jsx-inline-widget":``,children:(0,$.jsx)(u,{resetKeys:C,onError:w,fallbackRender:T,children:E})})}),t[29]=C,t[30]=w,t[31]=T,t[32]=E,t[33]=D):D=t[33];let O;t[34]!==i.isDestroyed||t[35]!==i.state||t[36]!==i.view||t[37]!==o?(O=e=>{if(e.preventDefault(),i.isDestroyed)return;let t=typeof o==`function`?o():void 0;if(typeof t==`number`){let e=i.state,n=e.doc.nodeAt(t);if(n?.type.name===`jsxInline`){let r=t+n.nodeSize;r<=e.doc.content.size&&i.view.dispatch(e.tr.setSelection(K.create(e.doc,r)))}}i.view.focus()},t[34]=i.isDestroyed,t[35]=i.state,t[36]=i.view,t[37]=o,t[38]=O):O=t[38];let k=l.displayName??c,A;t[39]===k?A=t[40]:(A=(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,$.jsx)(a,{id:`hxnF0I`,values:{0:k}})}),t[39]=k,t[40]=A);let j;t[41]!==l||t[42]!==i.state.doc||t[43]!==i.state.tr||t[44]!==i.view||t[45]!==o?(j=(e,t)=>{let n=typeof o==`function`?o():void 0;if(typeof n!=`number`)return;let r=i.state.doc.nodeAt(n);if(r?.type.name!==`jsxInline`)return;let a=hU(r.attrs);if(!a)return;let s=i.state.tr.setNodeMarkup(n,null,_U(a,l,e,t));s.setSelection(xe.create(s.doc,n)),i.view.dispatch(s)},t[41]=l,t[42]=i.state.doc,t[43]=i.state.tr,t[44]=i.view,t[45]=o,t[46]=j):j=t[46];let M;t[47]===p?M=t[48]:(M=()=>p(!1),t[47]=p,t[48]=M);let N;t[49]!==l||t[50]!==x||t[51]!==j||t[52]!==M?(N=(0,$.jsx)(aH,{descriptor:l,values:x,onChange:j,onDismiss:M}),t[49]=l,t[50]=x,t[51]=j,t[52]=M,t[53]=N):N=t[53];let P;t[54]===p?P=t[55]:(P=()=>p(!1),t[54]=p,t[55]=P);let F;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(a,{id:`DPfwMq`}),t[56]=F):F=t[56];let I;t[57]===P?I=t[58]:(I=(0,$.jsx)(ee,{variant:`secondary`,size:`sm`,className:`mt-2 w-full`,onClick:P,children:F}),t[57]=P,t[58]=I);let L;t[59]!==A||t[60]!==N||t[61]!==I||t[62]!==O?(L=(0,$.jsxs)(ya,{className:`z-[60] w-72 p-3`,side:`bottom`,align:`start`,onOpenAutoFocus:kU,onCloseAutoFocus:O,children:[A,N,I]}),t[59]=A,t[60]=N,t[61]=I,t[62]=O,t[63]=L):L=t[63];let R;t[64]!==f||t[65]!==p||t[66]!==L||t[67]!==D?(R=(0,$.jsxs)(xa,{open:f,onOpenChange:p,children:[D,L]}),t[64]=f,t[65]=p,t[66]=L,t[67]=D,t[68]=R):R=t[68];let te;return t[69]!==c||t[70]!==R||t[71]!==S?(te=(0,$.jsx)(Xr,{as:`span`,"data-jsx-inline":``,"data-component-name":c,contentEditable:!1,className:S,children:R}),t[69]=c,t[70]=R,t[71]=S,t[72]=te):te=t[72],te}function kU(e){e.preventDefault()}var AU=Jn.extend({addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return nr(DU)},addProseMirrorPlugins(){return[new J({props:{handleDOMEvents:{mousedown(e,t){let n=t.target;if(!(n instanceof Element))return!1;let r=n.closest(`[data-jsx-inline][data-component-name]`);if(!r||!e.dom.contains(r)||!r.getAttribute(`data-component-name`))return!1;let i=null;try{let t=e.posAtDOM(r,0);for(let n of[t-1,t]){let t=n>=0?e.state.doc.nodeAt(n):null;if(t?.type.name===`jsxInline`&&t.attrs.componentName){i=n;break}}}catch{return!1}return i===null?!1:(t.preventDefault(),e.dispatch(e.state.tr.setSelection(xe.create(e.state.doc,i))),e.focus(),!0)}}}})]}}),jU={name:`InlineMath`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,category:`content`,description:`Inline math`,props:[{name:`formula`,type:`string`,required:!0,autoFocus:!0,description:`LaTeX inline math source`}]},MU=(0,Z.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-BCLP08X6.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,Q.c)(4),r;n[0]===t.formula?r=n[1]:(r=e.renderToString(t.formula,{displayMode:!1,throwOnError:!1,strict:`ignore`,trust:!1}),n[0]=t.formula,n[1]=r);let i=r,a;return n[2]===i?a=n[3]:(a=(0,$.jsx)(`span`,{className:`math math-inline`,dangerouslySetInnerHTML:{__html:i}}),n[2]=i,n[3]=a),a}return{default:t}});function NU(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`span`,{className:`math math-inline math-placeholder math-placeholder-empty inline-flex items-center gap-1 rounded-sm border border-dashed border-muted-foreground/40 bg-muted/30 px-1.5 py-0.5 text-xs italic text-muted-foreground hover:bg-muted/60 cursor-pointer`,"data-component-type":`math-inline`,children:`f(x)`}),e[0]=t):t=e[0],t}function PU(e){let t=(0,Q.c)(2),n;return t[0]===e.formula?n=t[1]:(n=(0,$.jsx)(`span`,{className:`math math-inline math-placeholder`,"data-component-type":`math-inline`,children:e.formula}),t[0]=e.formula,t[1]=n),n}function FU(e){let t=(0,Q.c)(43),{node:n,selected:r,getPos:i,editor:o}=e,s=typeof n.attrs.formula==`string`?n.attrs.formula:``,c=typeof n.attrs.id==`string`?n.attrs.id:void 0,[l,d]=(0,Z.useState)(!1),f=(0,Z.useRef)(!1),p;t[0]!==o.state||t[1]!==i||t[2]!==r?(p=()=>{let e=r&&o.state.selection instanceof xe;e&&!f.current?(fC(typeof i==`function`?i()??0:0),d(!0)):!e&&f.current&&d(!1),f.current=e},t[0]=o.state,t[1]=i,t[2]=r,t[3]=p):p=t[3];let m;t[4]!==o||t[5]!==i||t[6]!==r?(m=[r,i,o],t[4]=o,t[5]=i,t[6]=r,t[7]=m):m=t[7],(0,Z.useEffect)(p,m);let h=r?`math-inline-selected`:void 0,g;t[8]===c?g=t[9]:(g=c?{id:c}:{},t[8]=c,t[9]=g);let _;t[10]===s?_=t[11]:(_=s?(0,$.jsx)(u,{resetKeys:[s],onError:LU,fallbackRender:()=>(0,$.jsx)(`span`,{className:`math math-inline math-error`,children:s}),children:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(PU,{formula:s}),children:(0,$.jsx)(MU,{formula:s})})}):(0,$.jsx)(NU,{}),t[10]=s,t[11]=_);let v;t[12]!==s||t[13]!==g||t[14]!==_?(v=(0,$.jsx)(va,{asChild:!0,children:(0,$.jsx)(`span`,{className:`math-inline-trigger`,"data-component-type":`math-inline`,"data-formula":s,...g,children:_})}),t[12]=s,t[13]=g,t[14]=_,t[15]=v):v=t[15];let y;t[16]!==o.state||t[17]!==o.view||t[18]!==i?(y=e=>{e.preventDefault();let t=typeof i==`function`?i():void 0;if(typeof t==`number`){let e=o.state,n=e.doc.nodeAt(t);if(n?.type.name===`mathInline`){let r=t+n.nodeSize;r<=e.doc.content.size&&o.view.dispatch(e.tr.setSelection(K.create(e.doc,r)))}}o.view.focus()},t[16]=o.state,t[17]=o.view,t[18]=i,t[19]=y):y=t[19];let b;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,$.jsx)(a,{id:`EOjU5V`})}),t[20]=b):b=t[20];let x;t[21]===s?x=t[22]:(x={formula:s},t[21]=s,t[22]=x);let S;t[23]!==o.state||t[24]!==o.view||t[25]!==i?(S=(e,t)=>{let n=typeof i==`function`?i():void 0;if(typeof n!=`number`)return;let r=o.state.doc.nodeAt(n);if(r?.type.name!==`mathInline`)return;let a=o.state.tr.setNodeMarkup(n,null,{...r.attrs,[e]:t??``});a.setSelection(xe.create(a.doc,n)),o.view.dispatch(a)},t[23]=o.state,t[24]=o.view,t[25]=i,t[26]=S):S=t[26];let C;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>d(!1),t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==x?(w=(0,$.jsx)(aH,{descriptor:jU,values:x,onChange:S,onDismiss:C}),t[28]=S,t[29]=x,t[30]=w):w=t[30];let T;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>d(!1),t[31]=T):T=t[31];let E;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-border pt-2`,children:(0,$.jsx)(ee,{type:`button`,size:`sm`,variant:`ghost`,onClick:T,className:`h-7 px-3 text-xs`,children:(0,$.jsx)(a,{id:`DPfwMq`})})}),t[32]=E):E=t[32];let D;t[33]!==w||t[34]!==y?(D=(0,$.jsxs)(ya,{className:`z-[60] w-72 p-3`,side:`bottom`,align:`start`,onOpenAutoFocus:IU,onCloseAutoFocus:y,children:[b,w,E]}),t[33]=w,t[34]=y,t[35]=D):D=t[35];let O;t[36]!==l||t[37]!==D||t[38]!==v?(O=(0,$.jsxs)(xa,{open:l,onOpenChange:d,children:[v,D]}),t[36]=l,t[37]=D,t[38]=v,t[39]=O):O=t[39];let k;return t[40]!==O||t[41]!==h?(k=(0,$.jsx)(Xr,{as:`span`,className:h,children:O}),t[40]=O,t[41]=h,t[42]=k):k=t[42],k}function IU(e){e.preventDefault()}function LU(e,t){let n=e instanceof Error?e:Error(String(e));console.warn(JSON.stringify({event:`jsx-render-failure`,component:`mathInline`,rawComponentName:`mathInline`,error:String(n),stack:t.componentStack})),lr(`mathInline`)}var RU=mn.extend({addNodeView(){return nr(FU)}});function zU(e,t){if(!e.selection.empty)return null;let n=t===`up`||t===`left`?-1:1,r=e.selection.$head,i=n>0?r.after():r.before();if(typeof i!=`number`)return null;let a=ve.near(e.doc.resolve(i),n);return a.$head?.parent.type.name===`rawMdxFallback`?a:null}function BU(e,t){let{state:n,view:r}=e;if(!r.endOfTextblock(t))return!1;let i=zU(n,t);return i?(r.dispatch(n.tr.setSelection(i)),!0):!1}var VU=on.extend({addKeyboardShortcuts(){return{ArrowLeft:({editor:e})=>BU(e,`left`),ArrowRight:({editor:e})=>BU(e,`right`),ArrowUp:({editor:e})=>BU(e,`up`),ArrowDown:({editor:e})=>BU(e,`down`)}},addNodeView(){return nr(qr,{stopEvent:()=>!0,ignoreMutation:()=>!0})}});function HU({editor:e,item:t,range:n}){let r=[],i;try{e.chain().focus().deleteRange(n).command(n=>{try{t.command({editor:e,chain:n.chain,state:n.state,afterCommit:e=>r.push(e)})}catch(e){i=e}return!0}).run()}catch(e){console.error(`[slash-command] deleteRange failed for "${t.name}"`,e),i!==void 0&&console.error(`[slash-command] command "${t.name}" threw an error`,i);return}i!==void 0&&console.error(`[slash-command] command "${t.name}" threw an error`,i);for(let e of r)try{e()}catch(e){console.error(`[slash-command] afterCommit callback for "${t.name}" threw an error`,e)}}function UU(e){return e.category===`skills`?e.description:void 0}function WU(e){let t=e.preview?.description??UU(e);return t===void 0?``:`. ${t}`}function GU(e){let t=(0,Q.c)(53),{items:n,selectedIndex:r,categoryLabels:i,onSelect:s,onHoverIndex:c}=e,l=(0,Z.useRef)(null),u=(0,Z.useId)(),{_:d}=o(),f=r>=0&&r<n.length?`${u}-option-${r}`:void 0,p=qU,m,h;if(t[0]===r?(m=t[1],h=t[2]):(m=()=>{let e=l.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(r);t&&t.scrollIntoView({block:`nearest`})},h=[r],t[0]=r,t[1]=m,t[2]=h),(0,Z.useEffect)(m,h),n.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[3]=e):e=t[3];let n;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{ref:l,role:`status`,"aria-live":`polite`,className:`w-56 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:e,onMouseDown:p,children:(0,$.jsx)(a,{id:`Ev2r9A`})}),t[4]=n):n=t[4],n}let g,_,v,y,b,x,S,C,w,T,E,D,O;if(t[5]!==d||t[6]!==f||t[7]!==i||t[8]!==n||t[9]!==u||t[10]!==c||t[11]!==s||t[12]!==r){let e=[],a=0,o=new Map;for(let t of n){o.set(t,a++);let n=e.find(e=>e.key===t.category);n?n.items.push(t):e.push({key:t.category,items:[t]})}_=r>=0&&r<n.length?n[r]:null;let m;t[26]===n?m=t[27]:(m=n.some(KU),t[26]=n,t[27]=m),g=m,x=`flex items-start gap-2`,S=l,C=`listbox`,t[28]===d?w=t[29]:(w=d({id:`RlCInP`}),t[28]=d,t[29]=w),T=f,E=-1,D=p,O=`w-56 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(v={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[30]=v):v=t[30];let h;t[31]===_?h=t[32]:(h=_?`${_.label}${WU(_)}`:``,t[31]=_,t[32]=h),t[33]===h?y=t[34]:(y=(0,$.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:h}),t[33]=h,t[34]=y),b=e.map(e=>(0,$.jsxs)(`div`,{role:`group`,"aria-labelledby":`${u}-group-${e.key}`,children:[(0,$.jsx)(`div`,{id:`${u}-group-${e.key}`,className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground`,children:i[e.key]??e.key}),e.items.map(e=>{let t=o.get(e)??0,n=t===r,i=e.icon;return(0,$.jsxs)(`button`,{id:`${u}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseEnter:()=>c?.(t),onMouseDown:t=>{t.preventDefault(),s(e)},children:[(0,$.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.label}),UU(e)===void 0?null:(0,$.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:UU(e)})]})]},e.name)})]},e.key)),t[5]=d,t[6]=f,t[7]=i,t[8]=n,t[9]=u,t[10]=c,t[11]=s,t[12]=r,t[13]=g,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S,t[20]=C,t[21]=w,t[22]=T,t[23]=E,t[24]=D,t[25]=O}else g=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18],S=t[19],C=t[20],w=t[21],T=t[22],E=t[23],D=t[24],O=t[25];let k;t[35]!==v||t[36]!==y||t[37]!==b||t[38]!==S||t[39]!==C||t[40]!==w||t[41]!==T||t[42]!==E||t[43]!==D||t[44]!==O?(k=(0,$.jsxs)(`div`,{ref:S,role:C,"aria-label":w,"aria-activedescendant":T,tabIndex:E,onMouseDown:D,className:O,style:v,children:[y,b]}),t[35]=v,t[36]=y,t[37]=b,t[38]=S,t[39]=C,t[40]=w,t[41]=T,t[42]=E,t[43]=D,t[44]=O,t[45]=k):k=t[45];let A;t[46]!==g||t[47]!==_?(A=g?(0,$.jsx)(`aside`,{"aria-hidden":`true`,onMouseDown:p,className:`ok-suggestion-preview w-64 rounded-lg border bg-popover p-2 shadow-md ${_?.preview?``:`invisible`}`,children:_?.preview?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mb-2 flex aspect-5/3 items-center justify-center overflow-hidden rounded-md bg-muted/40 p-3 *:max-h-full *:max-w-full [&_img]:size-full [&_img]:rounded-md [&_img]:object-contain`,children:_.preview.render()}),(0,$.jsx)(`p`,{className:`line-clamp-3 px-1 pb-1 text-xs text-muted-foreground`,children:_.preview.description})]}):null}):null,t[46]=g,t[47]=_,t[48]=A):A=t[48];let j;return t[49]!==x||t[50]!==k||t[51]!==A?(j=(0,$.jsxs)(`div`,{className:x,children:[k,A]}),t[49]=x,t[50]=k,t[51]=A,t[52]=j):j=t[52],j}function KU(e){return e.preview}function qU(e){return e.preventDefault()}var JU=new G(`slashCommand`);function YU(e){let{sources:t,categoryOrder:n,query:r,state:i,editor:a}=e,o=t.flatMap(e=>{try{return e(a===void 0?void 0:{editor:a})}catch(e){return console.error(`[slash-command] item source threw an error`,e),[]}}),s=e=>{let t=n.indexOf(e);return t===-1?1/0:t},c=o.map((e,t)=>({item:e,i:t})).sort((e,t)=>{let n=s(e.item.category)-s(t.item.category);return n===0?e.i-t.i:n}).map(e=>e.item);return kC(kw(i)?c.filter(e=>!e.insertsBlockComponent):c,r)}var XU=_e.create({name:`slashCommand`,addOptions(){return{itemsSources:[OC],categoryLabels:{basic:`Basic blocks`,insert:`Insert`}}},addProseMirrorPlugins(){let e=this;return[hn({editor:this.editor,pluginKey:JU,char:`/`,startOfLine:!1,allowedPrefixes:[..._n],findSuggestionMatch:tn(Cr),allow:Tr,items:({query:t,editor:n})=>YU({sources:e.options.itemsSources,categoryOrder:[...new Set([`skills`,`basic`,`insert`,...Object.keys(e.options.categoryLabels)])],query:t,state:n.state,editor:n}),command:({editor:e,range:t,props:n})=>HU({editor:e,item:n,range:t}),render:()=>{let t=null,n=null,r=0,i={popup:null,stopAutoUpdate:null},a=null,o=e=>{e!==r&&(r=e,s())},s=()=>{!t||!n||t.updateProps({items:n.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:n.command,onHoverIndex:o})};return{onStart(s){n=s,r=0;let c=Br(()=>n,`slash-command`,{clipToEditorPane:!0});i.popup=c.popup,a=c.doPosition,t=new zr(GU,{props:{items:s.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:s.command,onHoverIndex:o},editor:s.editor}),c.popup.appendChild(t.element),i.stopAutoUpdate=c.startAutoUpdate(),c.reveal()},onUpdate(e){n=e,r=Math.min(r,Math.max(0,e.items.length-1)),s(),a?.()},onKeyDown({event:e}){if(!n||n.items.length===0)return!1;let t=n.items;if(e.key===`ArrowDown`)return r=(r+1)%t.length,s(),!0;if(e.key===`ArrowUp`)return r=(r-1+t.length)%t.length,s(),!0;if(e.key===`Enter`||e.key===`Tab`){let e=t[r];return e&&n.command(e),!0}return e.key,!1},onExit(){Ar(i),a=null,t?.destroy(),t=null,n=null,r=0}}}})]}}),ZU=new G(`sourceDirty`),QU=_e.create({name:`sourceDirtyObserver`,addProseMirrorPlugins(){return[new J({key:ZU,appendTransaction(e,t,n){if(!e.some(e=>e.docChanged&&vn(e)))return null;let r=new Ce;for(let t of e)r.appendMapping(t.mapping);let i=r.invert(),a=[];if(n.doc.descendants((e,n)=>{if(e.type.name!==`jsxComponent`||e.attrs.sourceDirty)return;let r=i.map(n),o=t.doc.nodeAt(r),s=o?.type.name!==`jsxComponent`,c=typeof e.attrs.sourceRaw==`string`&&e.attrs.sourceRaw.length>0;if(s&&c)return;if(!o){(e.content.size>0||Object.keys(e.attrs.props??{}).length>0)&&a.push({pos:n});return}if(o.type.name!==`jsxComponent`){a.push({pos:n});return}let l=!$U(o.attrs.props,e.attrs.props),u=!o.content.eq(e.content);(l||u)&&a.push({pos:n})}),a.length===0)return null;let o=n.tr;for(let{pos:e}of a)o.setNodeAttribute(e,`sourceDirty`,!0);return o}})]}});function $U(e,t){if(Object.is(e,t))return!0;if(e==null||t==null||typeof e!=typeof t||typeof e!=`object`)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!$U(e[n],t[n]))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!$U(e[r],t[r]))return!1;return!0}var eW=_e.create({name:`tabFocusTrap`,priority:1,addKeyboardShortcuts(){return{Tab:()=>!0,"Shift-Tab":()=>!0}}});function tW(e,t){let n=e.doc.nodeAt(t);if(n?.type.name!==`table`)return null;let r=Tn.get(n);return{map:r,tableStart:t+1,table:n,left:0,top:0,right:r.width,bottom:r.height}}function nW(e,t){let n=tW(e,t);return n?nn(e.tr,n,n.map.width):null}function rW(e,t){let n=tW(e,t);return n?ln(e.tr,n,n.map.height):null}function iW(e,t){if(!e.dom.contains(t))return null;let n;try{n=e.posAtDOM(t,0)}catch{return null}return n<0?null:jn(e.state.doc.resolve(n))?.pos??null}var aW=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="M12 5v14"/></svg>`;function oW(e,t){let n=document.createElement(`button`);return n.type=`button`,n.className=`ok-table-insert-bar ok-table-insert-${e}`,n.setAttribute(`aria-label`,t),n.tabIndex=-1,n.setAttribute(Gy,`true`),n.innerHTML=aW,n.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation()}),n}var sW=class{overlays=new Map;mount;lastEditable;view;editor;resizeObserver;positionFrame=null;constructor(e,t){this.view=e,this.editor=t,this.mount=e.dom.parentElement??e.dom,this.lastEditable=t.isEditable,this.resizeObserver=typeof ResizeObserver>`u`?null:new ResizeObserver(()=>this.positionAll()),this.resizeObserver?.observe(e.dom),this.reconcile()}update(e,t){let n=this.editor.isEditable!==this.lastEditable;this.lastEditable=this.editor.isEditable,!(!n&&t.doc.eq(this.view.state.doc))&&(this.reconcile(),this.schedulePositionAll())}destroy(){this.removeAllOverlays(),this.resizeObserver?.disconnect(),this.positionFrame!=null&&cancelAnimationFrame(this.positionFrame),this.positionFrame=null}schedulePositionAll(){this.positionFrame!=null||this.overlays.size===0||(this.positionFrame=requestAnimationFrame(()=>{this.positionFrame=null,this.positionAll()}))}positionAll(){let e=Array.from(this.overlays,([e,t])=>{let n=e.getBoundingClientRect(),r=t.container.getBoundingClientRect();return{overlay:t,left:n.left-r.left,top:n.top-r.top,width:n.width,height:n.height}});for(let{overlay:t,left:n,top:r,width:i,height:a}of e){let e=`${n}|${r}|${i}|${a}`;t.placement!==e&&(t.placement=e,Object.assign(t.colBar.style,{left:`${n+i}px`,top:`${r}px`,height:`${a}px`}),Object.assign(t.rowBar.style,{left:`${n}px`,top:`${r+a}px`,width:`${i}px`}))}}reconcile(){if(!this.editor.isEditable){this.removeAllOverlays();return}let e=new Set(this.view.dom.querySelectorAll(`.tableWrapper`));for(let t of this.overlays.keys())e.has(t)||this.removeOverlay(t);for(let t of e)this.overlays.has(t)||this.addOverlay(t)}addOverlay(e){let t=document.createElement(`div`);t.className=`ok-table-insert-controls`,t.setAttribute(Gy,`true`);let n=oW(`column`,`Add column`),r=oW(`row`,`Add row`);n.addEventListener(`click`,()=>this.insert(e,nW)),r.addEventListener(`click`,()=>this.insert(e,rW)),t.append(n,r),this.mount.appendChild(t);let i=e=>{let t=e.target instanceof Element?e.target.closest(`td, th`):null,i=t?.parentElement;n.classList.toggle(`is-active`,!!t&&t===i?.lastElementChild),r.classList.toggle(`is-active`,!!i&&i===i.parentElement?.lastElementChild)},a=()=>{n.classList.remove(`is-active`),r.classList.remove(`is-active`)};e.addEventListener(`pointerover`,i),e.addEventListener(`pointerleave`,a),this.resizeObserver?.observe(e),this.overlays.set(e,{container:t,colBar:n,rowBar:r,placement:``,cleanup:()=>{this.resizeObserver?.unobserve(e),e.removeEventListener(`pointerover`,i),e.removeEventListener(`pointerleave`,a),t.remove()}})}removeAllOverlays(){for(let e of this.overlays.keys())this.removeOverlay(e)}removeOverlay(e){let t=this.overlays.get(e);t&&(t.cleanup(),this.overlays.delete(e))}insert(e,t){let n=e.querySelector(`table`);if(!n)return;let r=iW(this.view,n);if(r===null)return;let i=t(this.view.state,r);i&&(this.view.dispatch(i),this.view.focus())}},cW=_e.create({name:`tableInsertControls`,addProseMirrorPlugins(){let e=this.editor;return[new J({key:new G(`tableInsertControls`),view:t=>new sW(t,e)})]}});function lW(e){let{selection:t}=e;if(!(t instanceof K))return null;let n=gn(t.$from);if(!n)return null;let r=n.node(-1),i=n.start(-1),a=Tn.get(r),o=a.findCell(n.pos-i);if(o.bottom===a.height){let t=ln(e.tr,{map:a,tableStart:i,table:r,left:0,top:0,right:a.width,bottom:a.height},a.height),n=t.doc.nodeAt(i-1);if(!n)return null;let s=i+Tn.get(n).positionAt(a.height,o.left,n);return t.setSelection(K.near(t.doc.resolve(s+1))),t.scrollIntoView()}let s=a.positionAt(o.bottom,o.left,r),c=r.nodeAt(s);if(!c)return null;let l=i+s,u=e.tr;return u.setSelection(K.near(u.doc.resolve(l+c.nodeSize-1),-1)),u.scrollIntoView()}var uW=_e.create({name:`tableRowEnter`,addKeyboardShortcuts(){return{Enter:({editor:e})=>{let t=lW(e.state);return t?(e.view.dispatch(t),!0):!1}}}}),dW=`ok:tag-click`;function fW(e){if(typeof document>`u`)return;let t={value:e};document.dispatchEvent(new CustomEvent(dW,{detail:t}))}function pW(e){return e instanceof Element?e.closest(`a[data-tag]`):null}var mW=_e.create({name:`tagClick`,addProseMirrorPlugins(){return[new J({props:{handleDOMEvents:{click(e,t){let n=pW(t.target);if(!n)return!1;let r=n.getAttribute(`data-tag`);return r?(t.preventDefault(),t.stopPropagation(),fW(r),!0):!1}}}})]}});function hW(e,t,n){if(typeof t!=`number`||!n||!Fo.test(n))return!1;let{state:r,view:i}=e,a=r.doc.nodeAt(t);if(a?.type.name!==`tag`)return!1;let o=r.tr.setNodeMarkup(t,null,{...a.attrs,value:n}),s=t+a.nodeSize;return o.insertText(` `,s),o.setSelection(K.create(o.doc,s+1)),i.dispatch(o),i.focus(),!0}function gW(e,t){if(typeof t!=`number`)return;let{state:n,view:r}=e,i=n.doc.nodeAt(t);if(i?.type.name!==`tag`)return;let a=n.tr.delete(t,t+i.nodeSize);r.dispatch(a),r.focus()}function _W(e){let t=(0,Q.c)(3),{value:n}=e,r=`#tag/${n}`,i;return t[0]!==r||t[1]!==n?(i=(0,$.jsxs)(`a`,{className:`tag`,"data-tag":n,href:r,children:[`#`,n]}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function vW(e){let t=(0,Q.c)(22),{initialDraft:n,onCommit:r,onCancel:i}=e,{_:a}=o(),s=(0,Z.useRef)(null),[c,l]=(0,Z.useState)(n),u=(0,Z.useRef)(n),d=(0,Z.useRef)(!1),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>e!==``&&!Fo.test(e)?!1:(u.current=e,l(e),!0),t[0]=f):f=t[0];let p=f,m,h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{let e=requestAnimationFrame(()=>{s.current?.focus()});return()=>cancelAnimationFrame(e)},h=[],t[1]=m,t[2]=h):(m=t[1],h=t[2]),(0,Z.useEffect)(m,h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono`,children:`#`}),t[3]=g):g=t[3];let _=Math.max(c.length,8),v;t[4]===a?v=t[5]:(v=a({id:`U2pMtf`}),t[4]=a,t[5]=v);let y;t[6]===a?y=t[7]:(y=a({id:`knjOzA`}),t[6]=a,t[7]=y);let b,x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{let t=e.target.value;if(e.nativeEvent.isComposing){l(t);return}p(t)},x=e=>{p(e.currentTarget.value)||l(u.current)},t[8]=b,t[9]=x):(b=t[8],x=t[9]);let S,C;t[10]!==c||t[11]!==i||t[12]!==r?(S=e=>{Bt(e)||(e.key===`Enter`||e.key===` `?(e.preventDefault(),d.current=!0,r(c)||(d.current=!1,i())):(e.key===`Escape`||e.key===`Backspace`&&c===``)&&(e.preventDefault(),i()))},C=()=>{if(!d.current){if(c===``){i();return}Fo.test(c)?r(c):i()}},t[10]=c,t[11]=i,t[12]=r,t[13]=S,t[14]=C):(S=t[13],C=t[14]);let w;return t[15]!==c||t[16]!==S||t[17]!==C||t[18]!==_||t[19]!==v||t[20]!==y?(w=(0,$.jsxs)(`span`,{className:`tag tag-placeholder inline-flex items-center rounded-sm border border-dashed border-muted-foreground/40 bg-muted/30 px-1.5 py-0.5 text-xs text-muted-foreground`,"data-component-type":`tag-placeholder`,children:[g,(0,$.jsx)(`input`,{ref:s,type:`text`,value:c,size:_,placeholder:v,"aria-label":y,spellCheck:!1,autoCorrect:`off`,autoCapitalize:`off`,className:`bg-transparent border-0 p-0 outline-none focus:outline-none focus:ring-0 text-inherit font-inherit`,onChange:b,onCompositionEnd:x,onKeyDown:S,onBlur:C})]}),t[15]=c,t[16]=S,t[17]=C,t[18]=_,t[19]=v,t[20]=y,t[21]=w):w=t[21],w}function yW(e){let t=(0,Q.c)(5),{node:n,getPos:r,editor:i}=e,a=typeof n.attrs.value==`string`?n.attrs.value:``;if(a===``){let e;return t[0]!==i||t[1]!==r?(e=(0,$.jsx)(Xr,{as:`span`,children:(0,$.jsx)(vW,{initialDraft:``,onCommit:e=>hW(i,typeof r==`function`?r():void 0,e),onCancel:()=>gW(i,typeof r==`function`?r():void 0)})}),t[0]=i,t[1]=r,t[2]=e):e=t[2],e}let o;return t[3]===a?o=t[4]:(o=(0,$.jsx)(Xr,{as:`span`,children:(0,$.jsx)(_W,{value:a})}),t[3]=a,t[4]=o),o}function bW(e){return e.kind===`create`?`create:${e.value}`:`tag:${e.value}`}function xW(e){if(e.kind===`create`){let t=e.value;return Y._({id:`XPqe3B`,values:{tagValue:t}})}let t=Y._({id:`pckX1A`,values:{0:e.count}}),n=e.value;return Y._({id:`m2T1Xj`,values:{tagValue:n,uses:t}})}function SW(e){let t=(0,Q.c)(38),{items:n,query:r,selectedIndex:i,onSelect:s,onHover:c,loading:l,error:u}=e,d=l===void 0?!1:l,f=u===void 0?null:u,{_:p}=o(),m=(0,Z.useRef)(null),h=(0,Z.useId)(),g=i>=0&&i<n.length?`${h}-option-${i}`:void 0,_,v;t[0]===i?(_=t[1],v=t[2]):(_=()=>{let e=m.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(i);t&&t.scrollIntoView({block:`nearest`})},v=[i],t[0]=i,t[1]=_,t[2]=v),(0,Z.useEffect)(_,v);let y=CW;if(d){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[3]=e):e=t[3];let n;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{ref:m,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:e,onMouseDown:y,children:(0,$.jsx)(a,{id:`a_u4ck`})}),t[4]=n):n=t[4],n}if(n.length===0){let e;if(t[5]!==p||t[6]!==f||t[7]!==r){let n=r.trim();e=f??p(n?{id:`9R7pRC`,values:{trimmed:n}}:{id:`KRJ6xh`}),t[5]=p,t[6]=f,t[7]=r,t[8]=e}else e=t[8];let n=e,i;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(i={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[9]=i):i=t[9];let a;return t[10]===n?a=t[11]:(a=(0,$.jsx)(`div`,{ref:m,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:i,onMouseDown:y,children:n}),t[10]=n,t[11]=a),a}let b=i>=0&&i<n.length?n[i]:null,x;t[12]===p?x=t[13]:(x=p({id:`SCoBBH`}),t[12]=p,t[13]=x);let S;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(S={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[14]=S):S=t[14];let C;t[15]===b?C=t[16]:(C=b?xW(b):``,t[15]=b,t[16]=C);let w;t[17]===C?w=t[18]:(w=(0,$.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:C}),t[17]=C,t[18]=w);let T;t[19]===f?T=t[20]:(T=f&&(0,$.jsx)(`div`,{className:`rounded-md px-2 py-1.5 text-xs text-warning`,children:f}),t[19]=f,t[20]=T);let E;if(t[21]!==n||t[22]!==h||t[23]!==c||t[24]!==s||t[25]!==i){let e;t[27]!==h||t[28]!==c||t[29]!==s||t[30]!==i?(e=(e,t)=>{let n=t===i,r=bW(e),o=e.kind===`create`;return(0,$.jsxs)(`button`,{id:`${h}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,"data-testid":o?`tag-suggestion-create`:`tag-suggestion-tag-${e.value}`,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),s(e)},onPointerMove:c?()=>c(t):void 0,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-xs text-muted-foreground`,children:`#`}),(0,$.jsx)(`span`,{className:`truncate font-medium flex-1`,children:e.value}),o?(0,$.jsx)(`span`,{className:`shrink-0 rounded-sm bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary`,children:(0,$.jsx)(a,{id:`isRobC`})}):(0,$.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground tabular-nums`,children:e.count})]},r)},t[27]=h,t[28]=c,t[29]=s,t[30]=i,t[31]=e):e=t[31],E=n.map(e),t[21]=n,t[22]=h,t[23]=c,t[24]=s,t[25]=i,t[26]=E}else E=t[26];let D;return t[32]!==g||t[33]!==E||t[34]!==x||t[35]!==w||t[36]!==T?(D=(0,$.jsxs)(`div`,{ref:m,role:`listbox`,"aria-label":x,"aria-activedescendant":g,tabIndex:-1,onMouseDown:y,className:`w-64 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,style:S,children:[w,T,E]}),t[32]=g,t[33]=E,t[34]=x,t[35]=w,t[36]=T,t[37]=D):D=t[37],D}function CW(e){return e.preventDefault()}var wW=new G(`tagSuggestion`),TW=8,EW=RegExp(`(^|[\\s])#(${Ro})?$`,`u`);async function DW(){let e=await fetch(`/api/tags`);if(!e.ok)throw Error(`/api/tags responded with ${e.status}`);let t=await e.json();return Array.isArray(t.tags)?t.tags:[]}function OW(e,t){let n=t.trim(),r=n.toLowerCase(),i=n===``?e.slice():e.filter(e=>e.name.toLowerCase().includes(r));return i.sort((e,t)=>{let n=+!e.name.toLowerCase().startsWith(r),i=+!t.name.toLowerCase().startsWith(r);return n===i?t.count===e.count?e.name.localeCompare(t.name):t.count-e.count:n-i}),i}function kW(e,t){let n=OW(e,t).slice(0,TW).map(e=>({kind:`tag`,value:e.name,count:e.count,isLeaf:e.isLeaf})),r=t.trim();return r&&Fo.test(r)&&!e.some(e=>e.name===r)&&n.push({kind:`create`,value:r}),n}function AW(e){let{$position:t}=e,n=t.parent.textBetween(0,t.parentOffset,void 0,``).match(EW);if(!n)return null;let r=n[2]??``,i=t.start(),a=n[1].length;return{range:{from:i+((n.index??0)+a),to:t.pos},query:r,text:`#${r}`}}function jW(e){let t=[],n=!1,r=null,i=null;return hn({editor:e,pluginKey:wW,char:`#`,allowedPrefixes:null,findSuggestionMatch:AW,allow:Tr,items:async({query:e})=>{if(!n){r||=DW();try{t=await r,i=null}catch(e){console.error(`[tag-suggestion] Failed to fetch tags:`,e),i=`Failed to load tags. Press Escape and type # again to retry, or continue typing to create a new tag.`,t=[]}finally{n=!0,r=null}}return kW(t,e)},command:({editor:e,range:t,props:n})=>{try{let r=n.value;if(!r||!Fo.test(r))return;e.chain().focus().deleteRange(t).insertContent({type:`tag`,attrs:{value:r}}).insertContent(` `).run()}catch(e){console.error(`[tag-suggestion] command failed`,{item:n,range:t},e)}},render:()=>{let e=null,a=null,o=0,s={popup:null,stopAutoUpdate:null},c=null,l=null,u=e=>{a?.command(e)},d=e=>{o!==e&&(o=e,p(null))};function f(e,t,r){let a=t===null?!n:t;return{items:e.items,query:e.query??``,selectedIndex:o,onSelect:r,onHover:d,loading:a,error:i}}let p=t=>{!e||!a||e.updateProps(f(a,t,u))};return{onBeforeStart(t){a=t,o=0;let n=Br(()=>a,`tag-suggestion`,{clipToEditorPane:!0});s.popup=n.popup,c=n.doPosition,l=n.reveal,e=new zr(SW,{props:f(t,!0,u),editor:t.editor}),n.popup.appendChild(e.element),s.stopAutoUpdate=n.startAutoUpdate()},onStart(e){a=e,o=0,p(null),l?.()},onUpdate(e){a=e,o=Math.min(o,Math.max(0,e.items.length-1)),p(null),c?.()},onKeyDown({event:e}){if(!a)return!1;let t=a.items;if(e.key===`ArrowDown`)return t.length===0?!1:(o=(o+1)%t.length,p(null),!0);if(e.key===`ArrowUp`)return t.length===0?!1:(o=(o-1+t.length)%t.length,p(null),!0);if(e.key===`Enter`||e.key===`Tab`){let e=t[o];if(e)return a.command(e),!0;let n=(a.query??``).trim();return n&&Fo.test(n)?(a.command({kind:`create`,value:n}),!0):!1}return e.key,!1},onExit(){Ar(s),c=null,l=null,e?.destroy(),e=null,a=null,o=0,t=[],i=null,n=!1,r=null}}}})}var MW=Un.extend({priority:200,addNodeView(){return nr(yW)},addKeyboardShortcuts(){return{Backspace:()=>{if(wW.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeBefore;if(t?.type.name===`tag`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from-t.nodeSize,e.from)),!0}return!1},Delete:()=>{if(wW.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeAfter;if(t?.type.name===`tag`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from,e.from+t.nodeSize)),!0}return!1}}},addProseMirrorPlugins(){return[jW(this.editor)]}}),NW=`ok-trailing-affordance`,PW=new G(`trailingAffordance`);function FW(e){let t=e.lastChild;return t!=null&&t.type.name!==`paragraph`}function IW(e){let{doc:t}=e.state,n=t.lastChild;if(!n)return null;let r=e.nodeDOM(t.content.size-n.nodeSize);if(!(r instanceof HTMLElement))return null;let i=r.getBoundingClientRect();return i.height===0&&i.top===0?null:i.bottom}function LW(e){let t=Number.parseFloat(getComputedStyle(e.dom).getPropertyValue(Mn));return Number.isFinite(t)?t:0}function RW(e,t){if(!e.editable||!FW(e.state.doc))return!1;let n=t.target;if(n instanceof Element&&n.closest(`.ok-trailing-affordance`))return!0;let r=IW(e);if(r==null)return!1;let i=e.dom.getBoundingClientRect(),a=i.bottom-LW(e);return t.clientY>r&&t.clientY<=a&&t.clientX>=i.left&&t.clientX<=i.right}function zW(e){MH(e,e.state.doc.content.size)&&e.focus()}function BW(){let e=document.createElement(`div`);e.className=NW,e.setAttribute(Gy,`true`),e.setAttribute(`contenteditable`,`false`),e.setAttribute(`aria-hidden`,`true`);let t=document.createElement(`span`);return t.className=`${NW}-plus`,t.innerHTML=sL,e.append(t),e}function VW(e,t){PW.getState(e.state)!==t&&e.dispatch(e.state.tr.setMeta(PW,t).setMeta(`addToHistory`,!1))}var HW=4;function UW(){return typeof window>`u`?null:window.matchMedia?.(`(pointer: coarse)`)??null}function WW(){let e=null,t=UW();function n(n,r){let i=e;return!i||i.id!==r.pointerId||(e=null,Math.abs(r.clientX-i.x)>HW||Math.abs(r.clientY-i.y)>HW)||!n.state.selection.empty||!RW(n,r)?!1:(r.preventDefault(),zW(n),VW(n,n.editable&&t?.matches===!0),!0)}return new J({key:PW,state:{init:()=>!1,apply(e,t){let n=e.getMeta(PW);return typeof n==`boolean`?n:t}},view(e){let n=()=>VW(e,e.editable&&t?.matches===!0),r=e.editable;return queueMicrotask(()=>{e.isDestroyed||n()}),t?.addEventListener(`change`,n),{update(e){e.editable!==r&&(r=e.editable,n())},destroy(){t?.removeEventListener(`change`,n)}}},props:{decorations(e){return PW.getState(e)!==!0||!FW(e.doc)?null:U.create(e.doc,[W.widget(e.doc.content.size,BW,{side:1})])},handleDOMEvents:{mousemove(e,n){return t?.matches||VW(e,RW(e,n)),!1},mouseleave(e){return t?.matches||VW(e,!1),!1},pointerdown(t,n){let r=n;return e&&e.id!==r.pointerId||(e=null,r.button!==0||r.ctrlKey)||!RW(t,r)||(e={id:r.pointerId,x:r.clientX,y:r.clientY}),!1},pointerup(e,t){return n(e,t)},pointercancel(t,n){let r=n;return e?.id===r.pointerId&&(e=null),!1}}}})}var GW=_e.create({name:`trailingAffordance`,addProseMirrorPlugins(){return[WW()]}}),KW=2048,qW=24;function JW(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim();if(t===``||t.length>KW)return{kind:`unsupported`,value:``};if(eG(t))return{kind:`emoji`,value:t};let n=tG(t);return n===`url`?{kind:`url`,value:t}:n===`path`?{kind:`path`,value:Lo(`/api/asset?path=${encodeURIComponent($W(t))}`)}:{kind:`unsupported`,value:``}}function YW(e){return QW(e.banner).kind===`unsupported`?QW(e.cover).kind===`unsupported`?null:`cover`:`banner`}function XW(e){if(typeof e==`string`&&e.trim()===``)return null;let t=typeof e==`number`?e:typeof e==`string`?Number(e):NaN;return Number.isFinite(t)?t<0?0:t>1?1:t:null}function ZW(e){return e===null?`center`:`center ${Math.round(e*100)}%`}function QW(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim(),n=zn(t),r=n?n.target:t;if(r===``||r.length>KW)return{kind:`unsupported`,value:``};let i=tG(r);return i===`url`?{kind:`url`,value:r}:i===`path`?{kind:`path`,value:Lo(`/api/asset?path=${encodeURIComponent($W(r))}`)}:{kind:`unsupported`,value:``}}function $W(e){return e.startsWith(`/`)?e.slice(1):e}function eG(e){if(/\p{L}/u.test(e)||e.includes(`/`))return!1;let t=0;for(let n of e)t++;if(t>qW)return!1;let n=e.lastIndexOf(`.`);if(n>-1){let t=e.slice(n+1).toLowerCase();if(te.has(t))return!1}return!0}function tG(e){let t=nG(e);if(!t||!te.has(t))return`unsupported`;let n=e.indexOf(`:`),r=e.indexOf(`/`);return n>-1&&(r===-1||n<r)?Yi(e)?`url`:`unsupported`:e.startsWith(`//`)||e.includes(`?`)||e.includes(`#`)||e.startsWith(`../`)||e.includes(`/../`)?`unsupported`:`path`}function nG(e){let t=e.lastIndexOf(`/`),n=t>-1?e.slice(t+1):e,r=n.search(/[?#]/),i=r>-1?n.slice(0,r):n,a=i.lastIndexOf(`.`);return a<=0||a===i.length-1?null:i.slice(a+1).toLowerCase()}function rG(e){let t=(0,Q.c)(133),{open:n,target:r,alias:i,anchor:s,pages:c,assetPaths:l,filePaths:u,loading:f,onOpenChange:p,onSave:m}=e,[h,g]=(0,Z.useState)(r),[_,v]=(0,Z.useState)(i??``),[y,b]=(0,Z.useState)(s??``),x=(0,Z.useId)(),S=(0,Z.useId)(),C=(0,Z.useId)(),w=(0,Z.useId)(),{_:T}=o(),E;t[0]!==l||t[1]!==h||t[2]!==u?(E=ro(h,l,u),t[0]=l,t[1]=h,t[2]=u,t[3]=E):E=t[3];let D=E,O;t[4]!==l||t[5]!==h||t[6]!==u||t[7]!==c?(O=io(h,c,l,u),t[4]=l,t[5]=h,t[6]=u,t[7]=c,t[8]=O):O=t[8];let k=Tz(h,O&&!D&&n),A=(0,Z.useRef)(!1),j,M;t[9]!==i||t[10]!==s||t[11]!==n||t[12]!==r?(j=()=>{if(!n){A.current=!1;return}A.current||(A.current=!0,g(r),v(i??``),b(s??``))},M=[n,r,i,s],t[9]=i,t[10]=s,t[11]=n,t[12]=r,t[13]=j,t[14]=M):(j=t[13],M=t[14]),(0,Z.useEffect)(j,M);let N;t[15]!==_||t[16]!==y||t[17]!==h||t[18]!==p||t[19]!==m?(N=function(){let e=h.trim();e&&(m(e,_.trim()||null,y.trim()||null),p(!1))},t[15]=_,t[16]=y,t[17]=h,t[18]=p,t[19]=m,t[20]=N):N=t[20];let P=N,F;t[21]===P?F=t[22]:(F=function(e){e.key===`Enter`&&(e.preventDefault(),P())},t[21]=P,t[22]=F);let I=F,L;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=function(e){g(e.path),b(``)},t[23]=L):L=t[23];let R=L,te,ne,re,ie,ae,oe,se,z,B,ce,V,H,U,W,le,G,ue;if(t[24]!==T||t[25]!==C||t[26]!==S||t[27]!==l||t[28]!==_||t[29]!==y||t[30]!==h||t[31]!==I||t[32]!==w||t[33]!==k||t[34]!==f||t[35]!==p||t[36]!==n||t[37]!==c||t[38]!==x){let e=new Map,r=k?.map(t=>{let n=e.get(t.slug)??0;e.set(t.slug,n+1);let r=n===0?t.slug:`${t.slug}-${n}`;return{...t,reactKey:r}}),i=!!r?.length;re=Hi,W=n,le=p,ne=Li,z=`sm:max-w-xl`,B=``,ce=ER,V=ER,H=ER;let o;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Ii,{children:(0,$.jsx)(a,{id:`xzktOa`})}),t[56]=o):o=t[56],t[57]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsxs)(Vi,{children:[o,(0,$.jsx)(Fi,{children:(0,$.jsx)(a,{id:`Jhj_lh`})})]}),t[57]=U):U=t[57],te=Ri,ae=`space-y-6`;let s;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(a,{id:`lGs_bQ`,components:{0:(0,$.jsx)(`span`,{className:`text-destructive`})}}),t[58]=s):s=t[58];let u;t[59]===x?u=t[60]:(u=(0,$.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:x,children:s}),t[59]=x,t[60]=u);let m;t[61]===T?m=t[62]:(m=T({id:`aM23Wr`}),t[61]=T,t[62]=m);let E;t[63]!==l||t[64]!==h||t[65]!==I||t[66]!==f||t[67]!==c||t[68]!==m||t[69]!==x?(E=(0,$.jsx)(kR,{id:x,value:h,pages:c,assetPaths:l,includeAssets:!0,loading:f,onValueChange:g,onSuggestionSelect:R,placeholder:m,autoFocus:!0,"aria-required":`true`,onKeyDown:I}),t[63]=l,t[64]=h,t[65]=I,t[66]=f,t[67]=c,t[68]=m,t[69]=x,t[70]=E):E=t[70],t[71]!==u||t[72]!==E?(oe=(0,$.jsxs)(`div`,{children:[u,E]}),t[71]=u,t[72]=E,t[73]=oe):oe=t[73];let D;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(a,{id:`OTF92M`,components:{0:(0,$.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[74]=D):D=t[74];let O;t[75]===C?O=t[76]:(O=(0,$.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:C,children:D}),t[75]=C,t[76]=O);let A;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>v(e.target.value),t[77]=A):A=t[77];let j;t[78]===T?j=t[79]:(j=T({id:`BH56dn`}),t[78]=T,t[79]=j);let M;t[80]!==C||t[81]!==_||t[82]!==I||t[83]!==j?(M=(0,$.jsx)(Ka,{id:C,value:_,onChange:A,placeholder:j,onKeyDown:I}),t[80]=C,t[81]=_,t[82]=I,t[83]=j,t[84]=M):M=t[84],t[85]!==O||t[86]!==M?(se=(0,$.jsxs)(`div`,{children:[O,M]}),t[85]=O,t[86]=M,t[87]=se):se=t[87];let N;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(a,{id:`Tjc1pH`,components:{0:(0,$.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[88]=N):N=t[88],t[89]===S?G=t[90]:(G=(0,$.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:S,children:N}),t[89]=S,t[90]=G);let P;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>b(e.target.value),t[91]=P):P=t[91];let F;t[92]===T?F=t[93]:(F=T({id:`W-ntoW`}),t[92]=T,t[93]=F),t[94]!==S||t[95]!==y||t[96]!==I||t[97]!==F?(ue=(0,$.jsx)(Ka,{id:S,value:y,onChange:P,placeholder:F,onKeyDown:I}),t[94]=S,t[95]=y,t[96]=I,t[97]=F,t[98]=ue):ue=t[98],ie=i&&(0,$.jsx)(`div`,{id:w,className:`mt-1.5 max-h-36 overflow-y-auto subtle-scrollbar rounded-md border border-border bg-muted/30`,children:r.map(e=>(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":y===e.slug,className:d(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,y===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>b(y===e.slug?``:e.slug),children:[(0,$.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,$.jsx)(`span`,{className:`truncate`,children:e.text})]},e.reactKey))}),t[24]=T,t[25]=C,t[26]=S,t[27]=l,t[28]=_,t[29]=y,t[30]=h,t[31]=I,t[32]=w,t[33]=k,t[34]=f,t[35]=p,t[36]=n,t[37]=c,t[38]=x,t[39]=te,t[40]=ne,t[41]=re,t[42]=ie,t[43]=ae,t[44]=oe,t[45]=se,t[46]=z,t[47]=B,t[48]=ce,t[49]=V,t[50]=H,t[51]=U,t[52]=W,t[53]=le,t[54]=G,t[55]=ue}else te=t[39],ne=t[40],re=t[41],ie=t[42],ae=t[43],oe=t[44],se=t[45],z=t[46],B=t[47],ce=t[48],V=t[49],H=t[50],U=t[51],W=t[52],le=t[53],G=t[54],ue=t[55];let K;t[99]!==ie||t[100]!==G||t[101]!==ue?(K=(0,$.jsxs)(`div`,{children:[G,ue,ie]}),t[99]=ie,t[100]=G,t[101]=ue,t[102]=K):K=t[102];let de;t[103]!==ae||t[104]!==oe||t[105]!==se||t[106]!==K?(de=(0,$.jsxs)(`div`,{className:ae,children:[oe,se,K]}),t[103]=ae,t[104]=oe,t[105]=se,t[106]=K,t[107]=de):de=t[107];let fe;t[108]!==te||t[109]!==de?(fe=(0,$.jsx)(te,{children:de}),t[108]=te,t[109]=de,t[110]=fe):fe=t[110];let pe;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(Bi,{asChild:!0,children:(0,$.jsx)(ee,{variant:`outline`,children:(0,$.jsx)(a,{id:`dEgA5A`})})}),t[111]=pe):pe=t[111];let q;t[112]===h?q=t[113]:(q=h.trim(),t[112]=h,t[113]=q);let me=!q,J;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,$.jsx)(a,{id:`tfDRzk`}),t[114]=J):J=t[114];let he;t[115]!==P||t[116]!==me?(he=(0,$.jsxs)(zi,{children:[pe,(0,$.jsx)(ee,{onClick:P,disabled:me,children:J})]}),t[115]=P,t[116]=me,t[117]=he):he=t[117];let ge;t[118]!==ne||t[119]!==z||t[120]!==B||t[121]!==ce||t[122]!==V||t[123]!==H||t[124]!==U||t[125]!==fe||t[126]!==he?(ge=(0,$.jsxs)(ne,{className:z,"data-ok-layer-spawned":B,onPointerDownOutside:ce,onFocusOutside:V,onInteractOutside:H,children:[U,fe,he]}),t[118]=ne,t[119]=z,t[120]=B,t[121]=ce,t[122]=V,t[123]=H,t[124]=U,t[125]=fe,t[126]=he,t[127]=ge):ge=t[127];let _e;return t[128]!==re||t[129]!==W||t[130]!==le||t[131]!==ge?(_e=(0,$.jsx)(re,{open:W,onOpenChange:le,children:ge}),t[128]=re,t[129]=W,t[130]=le,t[131]=ge,t[132]=_e):_e=t[132],_e}function iG(e){let t=(0,Q.c)(119),{editor:n,getPos:r,onClose:i,onNavigate:s}=e,c=r(),l=c==null?null:n.state.doc.nodeAt(c),u=String(l?.attrs.target??``),f=cn(l?.attrs.alias),p=cn(l?.attrs.anchor),m=Vn({target:u,alias:f,anchor:p}),{addPage:h,assetPaths:y,filePaths:b,folderPaths:x,pages:S,pagesBySlug:C,pagesByBasename:w,loading:T}=ns(),E=to(u,p,{pages:S,pagesBySlug:C,pagesByBasename:w,assetPaths:y,filePaths:b}),D=E?.kind===`external`?E:null,O=E?.kind===`asset`?ro(E.url,y,b)??E.url.replace(/^\//,``):null,k=O?null:$n(u,{pages:S,folderPaths:x,pagesBySlug:C,pagesByBasename:w,fallbackTargets:co(u)}),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),{_:P}=o(),F=bz({docName:!D&&!T&&k?.kind===`navigate`&&k.displayState===`resolved`?k.hashDocName:null,anchor:p,enabled:!0});if(!l)return null;let I;t[0]!==n.state||t[1]!==n.view||t[2]!==r?(I=function(e,t,i){let a=r();a!=null&&n.view.dispatch(n.state.tr.setNodeMarkup(a,void 0,{...n.state.doc.nodeAt(a)?.attrs,target:e,alias:t,anchor:i}))},t[0]=n.state,t[1]=n.view,t[2]=r,t[3]=I):I=t[3];let L=I,R;t[4]!==n.state||t[5]!==n.view||t[6]!==r||t[7]!==i?(R=function(){let e=r();if(e==null)return;let t=n.state.doc.nodeAt(e);t&&(n.view.dispatch(n.state.tr.delete(e,e+t.nodeSize)),i())},t[4]=n.state,t[5]=n.view,t[6]=r,t[7]=i,t[8]=R):R=t[8];let te=R,ne=function(e){if(e!==u){let t=r();if(t==null)return;n.view.dispatch(n.state.tr.setNodeMarkup(t,void 0,{...n.state.doc.nodeAt(t)?.attrs,target:e,alias:f??m}))}},re=function(){return k?.kind===`create`?{initialDir:k.initialDir,suggestedName:k.suggestedName}:null},ie=async function(){let e=re();if(!(!e||M)){N(!0);try{await $L(e,{addPage:h,onCreated(e){ne(e),window.location.hash=pa(e),i()}}),N(!1)}catch(e){let t=e;z.error(t instanceof Error?t.message:P({id:`tfi40B`})),N(!1)}}},ae=!D&&!T&&O!==null,oe=!D&&!T&&k?.kind===`navigate`&&k.displayState===`resolved`,se=!D&&!T&&k?.kind===`navigate`&&k.displayState===`folder`,B=!D&&!T&&!O&&k?.kind===`create`,V=!!D,H=D?Ja(D.url)?D.url:null:ae&&O?ca(O):oe&&k?.kind===`navigate`?Kn({docName:k.hashDocName,anchor:p}):null,U=!T&&H!==null&&(V||ae||oe),W,le,G,ue,K;if(t[9]!==P||t[10]!==f||t[11]!==p||t[12]!==O||t[13]!==n.state||t[14]!==n.view||t[15]!==D||t[16]!==r||t[17]!==ae||t[18]!==se||t[19]!==oe||t[20]!==B||t[21]!==T||t[22]!==u){if(T){let e;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Si,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[28]=e):e=t[28],G={icon:e,text:P({id:`yQE2r9`}),className:`text-muted-foreground/80`}}else if(D){let e;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(yi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[29]=e):e=t[29],G={icon:e,text:P({id:`hpDtUm`}),className:`text-muted-foreground`}}else if(ae){let e;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Xl,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[30]=e):e=t[30],G={icon:e,text:P({id:`bUUVED`}),className:`text-muted-foreground`}}else if(se){let e;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(vi,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[31]=e):e=t[31],G={icon:e,text:P({id:`kNqMMd`}),className:`text-muted-foreground`}}else if(B){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Nt,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[32]=e):e=t[32],G={icon:e,text:P({id:`8F1i42`}),className:`text-destructive`}}else if(oe){let e;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ql,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[33]=e):e=t[33],G={icon:e,text:P({id:`Hrz9NY`}),className:`text-muted-foreground`}}else{let e;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Nt,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[34]=e):e=t[34],G={icon:e,text:P({id:`DeDYLr`}),className:`text-muted-foreground/80`}}let e;t[35]!==n.state||t[36]!==n.view||t[37]!==r?(e=()=>{let e=r();if(typeof e!=`number`)return new DOMRect;let t=n.state.doc.nodeAt(e);if(!t)return new DOMRect;try{return ce(n.view,e,e+t.nodeSize)}catch{return new DOMRect}},t[35]=n.state,t[36]=n.view,t[37]=r,t[38]=e):e=t[38];let i;t[39]!==n.view.dom||t[40]!==e?(i={getBoundingClientRect:e,contextElement:n.view.dom},t[39]=n.view.dom,t[40]=e,t[41]=i):i=t[41],K=i,le=O??(D?D.url:`${u}${p?`#${p}`:``}`);let a=p?`${u}#${p}`:u;W=f?`[[${a}|${f}]]`:`[[${a}]]`,ue=d(`flex shrink-0`,G.className),t[9]=P,t[10]=f,t[11]=p,t[12]=O,t[13]=n.state,t[14]=n.view,t[15]=D,t[16]=r,t[17]=ae,t[18]=se,t[19]=oe,t[20]=B,t[21]=T,t[22]=u,t[23]=W,t[24]=le,t[25]=G,t[26]=ue,t[27]=K}else W=t[23],le=t[24],G=t[25],ue=t[26],K=t[27];let de;t[42]!==G.icon||t[43]!==ue?(de=(0,$.jsx)(`span`,{className:ue,children:G.icon}),t[42]=G.icon,t[43]=ue,t[44]=de):de=t[44];let fe=de,pe;t[45]!==fe||t[46]!==B||t[47]!==G.text?(pe=B?(0,$.jsxs)(v,{children:[(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(`span`,{className:`flex shrink-0`,"data-slot":`wiki-link-prop-panel-icon-trigger`,children:fe})}),(0,$.jsx)(_,{children:G.text})]}):fe,t[45]=fe,t[46]=B,t[47]=G.text,t[48]=pe):pe=t[48];let q=pe,me=`${G.text}: ${le}`,J;t[49]!==le||t[50]!==V||t[51]!==B||t[52]!==H||t[53]!==U||t[54]!==i||t[55]!==s?(J=(0,$.jsx)(g,{asChild:!0,children:U?(0,$.jsx)(`a`,{href:H??void 0,...V?{target:`_blank`,rel:`noopener noreferrer`}:{},onClick:e=>rn(e,s,i),"data-slot":`wiki-link-prop-panel-text`,className:`block truncate text-sm font-medium text-foreground underline-offset-2 hover:underline focus-visible:underline`,children:le}):(0,$.jsx)(`span`,{"data-slot":`wiki-link-prop-panel-text`,className:d(`block truncate text-sm font-medium`,B?`text-muted-foreground`:`text-foreground`),children:le})}),t[49]=le,t[50]=V,t[51]=B,t[52]=H,t[53]=U,t[54]=i,t[55]=s,t[56]=J):J=t[56];let he;t[57]===le?he=t[58]:(he=(0,$.jsx)(_,{className:`max-w-80 break-all`,children:le}),t[57]=le,t[58]=he);let ge;t[59]!==J||t[60]!==he?(ge=(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(v,{children:[J,he]})}),t[59]=J,t[60]=he,t[61]=ge):ge=t[61];let _e;t[62]!==ie||t[63]!==M||t[64]!==B?(_e=B?(0,$.jsxs)(ee,{type:`button`,size:`sm`,variant:`link`,disabled:M,onClick:()=>void ie(),"data-slot":`wiki-link-prop-panel-create`,className:`flex items-center text-foreground`,children:[(0,$.jsx)(Di,{className:`size-3.5`,"aria-hidden":`true`}),M?(0,$.jsx)(a,{id:`HM56Bx`}):(0,$.jsx)(a,{id:`XRuL0i`})]}):null,t[62]=ie,t[63]=M,t[64]=B,t[65]=_e):_e=t[65];let ve;t[66]===P?ve=t[67]:(ve=P({id:`ePK91l`}),t[66]=P,t[67]=ve);let ye;t[68]===j?ye=t[69]:(ye=()=>j(!0),t[68]=j,t[69]=ye);let be;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,$.jsx)(Ei,{className:`size-3.5`,"aria-hidden":`true`}),t[70]=be):be=t[70];let xe;t[71]!==ve||t[72]!==ye?(xe=(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(ee,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":ve,onClick:ye,"data-slot":`wiki-link-prop-panel-edit`,children:be})}),t[71]=ve,t[72]=ye,t[73]=xe):xe=t[73];let Se;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,$.jsx)(_,{children:(0,$.jsx)(a,{id:`ePK91l`})}),t[74]=Se):Se=t[74];let Ce;t[75]===xe?Ce=t[76]:(Ce=(0,$.jsxs)(v,{disableHoverableContent:!0,children:[xe,Se]}),t[75]=xe,t[76]=Ce);let we;t[77]===W?we=t[78]:(we=(0,$.jsx)(bs,{copyContent:W}),t[77]=W,t[78]=we);let Te;t[79]===P?Te=t[80]:(Te=P({id:`t_YqKh`}),t[79]=P,t[80]=Te);let Ee;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,$.jsx)(Ai,{className:`size-3.5`,"aria-hidden":`true`}),t[81]=Ee):Ee=t[81];let De;t[82]!==te||t[83]!==Te?(De=(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(ee,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":Te,onClick:te,"data-slot":`wiki-link-prop-panel-remove`,children:Ee})}),t[82]=te,t[83]=Te,t[84]=De):De=t[84];let Oe;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,$.jsx)(_,{children:(0,$.jsx)(a,{id:`t_YqKh`})}),t[85]=Oe):Oe=t[85];let ke;t[86]===De?ke=t[87]:(ke=(0,$.jsxs)(v,{disableHoverableContent:!0,children:[De,Oe]}),t[86]=De,t[87]=ke);let Ae;t[88]!==_e||t[89]!==Ce||t[90]!==we||t[91]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[_e,Ce,we,ke]}),t[88]=_e,t[89]=Ce,t[90]=we,t[91]=ke,t[92]=Ae):Ae=t[92];let Y;t[93]!==q||t[94]!==ge||t[95]!==Ae?(Y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[q,ge,Ae]}),t[93]=q,t[94]=ge,t[95]=Ae,t[96]=Y):Y=t[96];let je;t[97]===F?je=t[98]:(je=F?(0,$.jsx)(UR,{preview:F}):null,t[97]=F,t[98]=je);let Me;t[99]!==i||t[100]!==Y||t[101]!==je||t[102]!==me||t[103]!==K?(Me=(0,$.jsxs)(VL,{kind:`wiki-link`,ariaLabel:me,onDeactivate:i,triggerReference:K,className:`w-96`,children:[Y,je]}),t[99]=i,t[100]=Y,t[101]=je,t[102]=me,t[103]=K,t[104]=Me):Me=t[104];let Ne;t[105]!==f||t[106]!==p||t[107]!==y||t[108]!==A||t[109]!==b||t[110]!==L||t[111]!==T||t[112]!==S||t[113]!==j||t[114]!==u?(Ne=(0,$.jsx)(rG,{open:A,target:u,alias:f,anchor:p,pages:S,assetPaths:y,filePaths:b,loading:T,onOpenChange:j,onSave:L}),t[105]=f,t[106]=p,t[107]=y,t[108]=A,t[109]=b,t[110]=L,t[111]=T,t[112]=S,t[113]=j,t[114]=u,t[115]=Ne):Ne=t[115];let Pe;return t[116]!==Me||t[117]!==Ne?(Pe=(0,$.jsxs)($.Fragment,{children:[Me,Ne]}),t[116]=Me,t[117]=Ne,t[118]=Pe):Pe=t[118],Pe}var aG=0;function oG(){return`wiki-link-${++aG}`}function sG(e){let t=e.doc??(typeof document<`u`?document:{createElement:null,createTextNode:null}),n=t.createElement(`span`);n.setAttribute(`data-wiki-link`,``),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`data-target`,e.target),n.setAttribute(`data-alias`,e.alias??``),n.setAttribute(`data-anchor`,e.anchor??``),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`Wiki link: ${e.target}${e.anchor?`#${e.anchor}`:``}`),n.classList.add(`wiki-link-chip`),n.style.touchAction=`manipulation`;let r=t.createElement(`span`);r.setAttribute(`data-wiki-link-icon`,``),r.setAttribute(`aria-hidden`,`true`),n.appendChild(r);let i=e.alias??`${e.target}${e.anchor?`#${e.anchor}`:``}`,a=t.createTextNode(i);return n.appendChild(a),{dom:n,iconSpan:r}}var cG=new WeakMap,lG=512;function uG(e,t){if(!t||!e)return null;let n=fo(e,t);if(!n)return null;let r=t.pageIcons?.get(n);if(!r)return null;let i=JW(r);return i.kind===`unsupported`?null:i}function dG(e,t,n){if(!n)return fG(e,t,n);let r=cG.get(n);r||(r=new Map,cG.set(n,r));let i=JSON.stringify([e,t,Mr()]),a=r.get(i);if(a!==void 0)return a;let o=fG(e,t,n);return r.size>=lG&&r.clear(),r.set(i,o),o}function fG(e,t,n){if(!e)return null;let r=to(e,t,n??new Set);if(!r)return null;if(r.kind===`external`)return`external`;if(!n)return`loading`;if(r.kind===`asset`)return n.assetPaths===void 0&&n.filePaths===void 0||ro(r.url,n.assetPaths??new Set,n.filePaths)?`asset`:Mr()?`unresolved`:null;let i=$n(e,{pages:n.pages,folderPaths:n.folderPaths,pagesBySlug:n.pagesBySlug,pagesByBasename:n.pagesByBasename,fallbackTargets:co(e)});return i.kind===`create`?Mr()?`unresolved`:null:i.displayState}function pG(e,t){let n=t??``;if(e.getAttribute(`data-resolution-state`)!==n){if(!n){e.removeAttribute(`data-resolution-state`);return}e.setAttribute(`data-resolution-state`,n)}}function mG(e,t,n=document){let r=t?.kind??``,i=t?.value??``;if(e.getAttribute(`data-kind`)===r&&e.getAttribute(`data-value`)===i)return;for(e.setAttribute(`data-kind`,r),e.setAttribute(`data-value`,i);e.firstChild;)e.removeChild(e.firstChild);if(!t)return;if(t.kind===`emoji`){e.appendChild(n.createTextNode(t.value));return}let a=n.createElement(`img`);a.setAttribute(`src`,t.value),a.setAttribute(`alt`,``),a.setAttribute(`draggable`,`false`),a.setAttribute(`referrerpolicy`,`no-referrer`),e.appendChild(a)}var hG=Jt.extend({priority:200,addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=oG(),{dom:i,iconSpan:a}=sG({nodeId:r,target:String(t.attrs.target??``),alias:t.attrs.alias==null?null:String(t.attrs.alias),anchor:t.attrs.anchor==null?null:String(t.attrs.anchor)}),o=t,s=()=>{let e=String(o.attrs.target??``),t=o.attrs.anchor==null?null:String(o.attrs.anchor),n=es();mG(a,uG(e,n)),pG(i,dG(e,t,n))};s();let c=$o(s),l=vr(s),u=()=>{let e=n();return typeof e==`number`?e:void 0},d=nv(e),f=({newTab:e})=>{let t=o.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=typeof t.anchor==`string`?t.anchor:null,i=es(),a=to(n,r,i??new Set);if(!a)return!1;if(a.kind===`doc`){let t=$n(n,{pages:i?.pages??new Set,folderPaths:i?.folderPaths??new Set,pagesBySlug:i?.pagesBySlug,pagesByBasename:i?.pagesByBasename,fallbackTargets:co(n)});if(t.kind===`create`)return!1;let r=t.kind===`navigate`?t.hashDocName:a.docName;return e?un({docName:r,anchor:a.anchor}):window.location.assign(Kn({docName:r,anchor:a.anchor})),!0}if(a.kind===`asset`){let t=ro(a.url,i?.assetPaths??new Set,i?.filePaths)??a.url.replace(/^\//,``);return e?Wr(ca(t)):window.location.hash=ca(t),!0}return Ja(a.url)?(qa(a.url),!0):!1};return d.register({type:`wikiLink`,nodeId:r,getPos:u,controls:{propPanel:t=>(0,Z.createElement)(iG,{editor:e,getPos:u,onClose:t.deactivate,onNavigate:e=>f({newTab:e})})},handlePrimary:f}),{dom:i,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLink`)return!1;o=e;let t=String(e.attrs.target??``),n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor);i.setAttribute(`data-target`,t),i.setAttribute(`data-alias`,n??``),i.setAttribute(`data-anchor`,r??``),i.setAttribute(`aria-label`,`Wiki link: ${t}${r?`#${r}`:``}`);let a=n??`${t}${r?`#${r}`:``}`,c=i.lastChild;return c&&c.nodeType===3?c.nodeValue=a:i.appendChild(i.ownerDocument.createTextNode(a)),s(),!0},destroy:()=>{d.deregister(r),c(),l()}}}},addKeyboardShortcuts(){return{Backspace:()=>{if(sr.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeBefore;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from-t.nodeSize,e.from)),!0}return!1},Delete:()=>{if(sr.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeAfter;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from,e.from+t.nodeSize)),!0}return!1}}},addProseMirrorPlugins(){return[Zr(this.editor)]}});function gG(e){let t=(0,Q.c)(3),{src:n,alt:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,$.jsx)(gb,{src:n,alt:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var _G=0;function vG(){return`wiki-link-embed-${++_G}`}function yG(e){let t=e.doc??(typeof document<`u`?document:{createElement:null,createTextNode:null}),n=t.createElement(`a`);n.setAttribute(`data-wiki-embed`,``),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`data-target`,e.target),n.setAttribute(`data-alias`,e.alias??``),n.setAttribute(`data-anchor`,e.anchor??``),n.setAttribute(`href`,e.href),n.setAttribute(`target`,`_blank`),n.setAttribute(`rel`,`noopener noreferrer`),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`Embed: ${e.target}${e.anchor?`#${e.anchor}`:``}`),n.classList.add(`wiki-link-embed-chip`),n.style.touchAction=`manipulation`;let r=e.alias??`${e.target}${e.anchor?`#${e.anchor}`:``}`,i=t.createTextNode(r);return n.appendChild(i),{dom:n}}function bG(e,t){e.setAttribute(`data-wiki-embed`,``),e.setAttribute(`data-node-id`,t.nodeId),e.setAttribute(`data-target`,t.target),e.setAttribute(`data-alias`,t.alias??``),e.setAttribute(`contenteditable`,`false`)}function xG(e){let t=eo(e);return t!==null&&te.has(t)}function SG(e){let t=e.target;if(!t)return null;let n=e.resolvedSrc&&e.resolvedSrc.length>0?e.resolvedSrc:t,r=eo(t);if(r===null)return null;let i=po(n,``,{literal:!0});return i===null?null:{url:n,projectRelPath:i,ext:r,title:i.split(`/`).pop()??n}}var CG=_i.extend({addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=vG(),i=t,a=String(t.attrs.target??``),o=t.attrs.alias==null?null:String(t.attrs.alias),s=t.attrs.anchor==null?null:String(t.attrs.anchor),c=t.attrs.resolvedSrc==null?null:String(t.attrs.resolvedSrc);if(xG(a)){let t=new zr(gG,{editor:e,props:{src:c??a,alt:o??a},as:`span`,className:`wiki-link-embed-image`}),n=t.element;return bG(n,{nodeId:r,target:a,alias:o}),{dom:n,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLinkEmbed`)return!1;i=e;let a=String(e.attrs.target??``),o=e.attrs.alias==null?null:String(e.attrs.alias),s=e.attrs.resolvedSrc==null?null:String(e.attrs.resolvedSrc);if(!xG(a))return!1;let c=s??a;return bG(n,{nodeId:r,target:a,alias:o}),t.updateProps({src:c,alt:o??a}),!0},destroy:()=>t.destroy()}}let{dom:l}=yG({nodeId:r,target:a,alias:o,anchor:s,href:c??a});l.addEventListener(`click`,e=>{e.preventDefault()});let u=()=>{let e=n();return typeof e==`number`?e:void 0},d=nv(e);return d.register({type:`wikiLinkEmbed`,nodeId:r,getPos:u,controls:{},handlePrimary:({newTab:e})=>{let t=i.attrs,n=SG({target:typeof t.target==`string`?t.target:``,resolvedSrc:typeof t.resolvedSrc==`string`?t.resolvedSrc:null});return n===null?!1:(sn({...n,newTab:e}),!0)}}),{dom:l,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLinkEmbed`)return!1;i=e;let t=String(e.attrs.target??``);if(xG(t))return!1;let n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor),a=(e.attrs.resolvedSrc==null?null:String(e.attrs.resolvedSrc))??t;return l.setAttribute(`data-target`,t),l.setAttribute(`data-alias`,n??``),l.setAttribute(`data-anchor`,r??``),l.setAttribute(`href`,a),l.setAttribute(`aria-label`,`Embed: ${t}${r?`#${r}`:``}`),l.textContent=n??`${t}${r?`#${r}`:``}`,!0},destroy:()=>{d.deregister(r)}}}}}),wG=[OC,_C,TC,yC],TG=[...Qt.map(e=>{if(e.name===`jsxComponent`)return EU;if(e.name===`jsxInline`)return AU;if(e.name===`image`){let t=e.options??{};return NL.configure({...t,inline:!0})}return e.name===`imageReference`?LL:e.name===`rawMdxFallback`?VU:e.name===`wikiLink`?hG:e.name===`wikiLinkEmbed`?CG:e.name===`link`?Rz:e.name===`mathInline`?RU:e.name===`tag`?MW:e.name===`codeBlock`?qF:e}),Fw,XU.configure({itemsSources:[...wG,pw],categoryLabels:{skills:`Skills`,content:`Components`,layout:`Layout`,media:`Media`,data:`Data`,embed:`Embeds`}}),bn,AL,eW,ng.configure({onDrop(e,t,n){if(p_(e))for(let r of t)m_(r,e,n)},onPaste(e,t,n){if(p_(e))for(let n of t)m_(n,e,e.state.selection.from)}}),jL,Sg,mW,kL,DL,xw,GW,cW,uW,QU,Kg,y_,E_,og,Dw,EH,M_,_e.create({name:`chunkWrapperDecoration`,addProseMirrorPlugins(){return[Uw()]}})],EG=new Set([`link`,`wikiLink`,`jsxComponent`,`jsxInline`,`imageReference`]);function DG(e,t){return e.map(e=>EG.has(e.name)?e.configure({docName:t}):e)}var OG=`ok-replay-outbox`,kG=`entry`,AG=`buffer`,jG=5e3,MG=class extends Error{constructor(e,t){super(`[replay-outbox] ${e} timed out after ${jG}ms: ${t}`),this.name=`ReplayOutboxTimeoutError`}};function NG(e,t,n){return new Promise((r,i)=>{let a=setTimeout(()=>{i(new MG(e,t))},jG);n.then(e=>{clearTimeout(a),r(e)},e=>{clearTimeout(a),i(e)})})}function PG(){return typeof indexedDB<`u`&&typeof indexedDB.databases==`function`}function FG({branch:e,docName:t,namespace:n}){return`${$i(OG,n)}:${e}:${t}`}function IG(e){return new Promise((t,n)=>{let r=indexedDB.open(e);r.onupgradeneeded=()=>{let e=r.result;e.objectStoreNames.contains(kG)||e.createObjectStore(kG)},r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)})}async function LG(e){return PG()?(await indexedDB.databases()).some(t=>t.name===e):!1}async function RG(e,t){if(!PG())return!1;let{docName:n}=e,r=FG(e);return NG(`write`,n,(async()=>{let e=await IG(r);try{return await new Promise((n,r)=>{let i=e.transaction(kG,`readwrite`);i.objectStore(kG).put({delta:t.delta,fullState:t.fullState},AG),i.oncomplete=()=>n(),i.onerror=()=>r(i.error),i.onabort=()=>r(i.error??Error(`replay-outbox write aborted`)),typeof i.commit==`function`&&i.commit()}),!0}finally{e.close()}})())}async function zG(e){if(!PG())return null;let{docName:t}=e,n=FG(e);return NG(`read`,t,(async()=>{if(!await LG(n))return null;let e=await IG(n);try{let t=await new Promise((t,n)=>{let r=e.transaction(kG,`readonly`).objectStore(kG).get(AG);r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)});if(t==null)return null;let n=t;return!(n.delta instanceof Uint8Array)||!(n.fullState instanceof Uint8Array)?null:{delta:n.delta,fullState:n.fullState}}finally{e.close()}})())}async function BG(e){if(!PG())return!1;let{docName:t}=e,n=FG(e);return NG(`consume`,t,(async()=>{if(!await LG(n))return!1;let e=await IG(n);try{return await new Promise((t,n)=>{let r=e.transaction(kG,`readwrite`),i=r.objectStore(kG),a=!1,o=i.count(AG);o.onsuccess=()=>{a=o.result>0},i.delete(AG),r.oncomplete=()=>t(a),r.onerror=()=>n(r.error),r.onabort=()=>n(r.error??Error(`replay-outbox consume aborted`))})}finally{e.close()}})())}function VG(){return ha(`SYNC_TIMEOUT_MS`,3e4)}var HG=class extends Error{docName;elapsedMs;constructor(e,t){super(`Sync timed out for "${e}" after ${t}ms`),this.name=`SyncTimeoutError`,this.docName=e,this.elapsedMs=t}},UG=class extends Error{docName;constructor(e){super(`Provider disconnected before sync for "${e}"`),this.name=`PreSyncDisconnectError`,this.docName=e}},WG=class extends Error{docName;constructor(e){super(`Document not found: "${e}"`),this.name=`DocumentNotFoundError`,this.docName=e}},GG=class extends Error{docName;cause;constructor(e,t){let n=t instanceof Error?t.message:String(t??`unknown`);super(`Bridge setup failed for "${e}": ${n}`),this.name=`BridgeSetupError`,this.docName=e,this.cause=t}},KG=class extends Error{docName;missingCapability;constructor(e,t){super(`Server is missing capability "${t}" required to open "${e}".`),this.name=`ServerCapabilityMismatchError`,this.docName=e,this.missingCapability=t}},qG=new Map,JG=!1;function YG(){for(let e of qG.values())if(!e.settled)return!0;return!1}function XG(){typeof document>`u`||document.visibilityState===`visible`&&ZG(Date.now())}function ZG(e){let t=[];for(let[n,r]of qG){if(r.settled)continue;let i=e-r.createdAt;if(i<VG())continue;r.settled=!0;let a=new HG(n,i);tK(r),r.reject(a);let o=hf(n);o!==void 0&&Ef(o),t.push({docName:n,elapsedMs:i})}if(t.length>0){let e=t.map(e=>`${e.docName} (${e.elapsedMs}ms)`).join(`, `);console.warn(`[syncPromise] reaped ${t.length} timed-out ${t.length===1?`entry`:`entries`} on visibility restore (tab-sleep recovered): ${e}`)}return YG()||$G(),t.length}function QG(){JG||typeof document>`u`||(document.addEventListener(`visibilitychange`,XG),JG=!0)}function $G(){JG&&(typeof document>`u`||(document.removeEventListener(`visibilitychange`,XG),JG=!1))}var eK=new Map;function tK(e){e.detached||(e.detached=!0,e.timeoutHandle!==null&&clearTimeout(e.timeoutHandle),e.provider.off(`synced`,e.onSynced),e.provider.off(`close`,e.onClose))}function nK(e,t){let n=qG.get(e);if(n)return n.promise;let r=eK.get(e);if(r!==void 0){eK.delete(e);let n=r===`timeout`?new HG(e,0):new UG(e);console.warn(`[syncPromise] ${e} rejected on creation (test hook, armed ${r}): ${n.message}`),X(`ok/sync/create`,{docName:e,mountId:hf(e),warm:!1,armed:r}),X(`ok/sync/reject`,{docName:e,mountId:hf(e),reason:`armed-${r}`});let i=iK(n);return qG.set(e,aK(i,t)),i}if(t.synced){console.log(`[syncPromise] ${e} resolved synchronously (warm provider)`);let n=hf(e);X(`ok/sync/create`,{docName:e,mountId:n,warm:!0}),X(`ok/sync/resolve`,{docName:e,mountId:n,elapsedMs:0,warm:!0}),X.histogram(`ok/sync/resolve-elapsed-ms`,n===void 0?{docName:e,warm:!0}:{docName:e,mountId:n,warm:!0},0);let r=Promise.resolve();return qG.set(e,rK(r,t)),r}let i=Date.now(),{promise:a,resolve:o,reject:s}=Promise.withResolvers(),c=()=>{let t=qG.get(e);if(!t||t.settled)return;t.settled=!0,t.resolved=!0;let n=Date.now()-t.createdAt;console.log(`[syncPromise] ${e} resolved in ${n}ms`);let r=hf(e);if(X(`ok/sync/resolve`,{docName:e,mountId:r,elapsedMs:n,warm:!1}),X.histogram(`ok/sync/resolve-elapsed-ms`,r===void 0?{docName:e}:{docName:e,mountId:r},n),tK(t),YG()||$G(),t.resolve(),rs(),r!==void 0){let i=Date.now();Tf(r,`ok.sync-promise`,{"doc.name":e,elapsed_ms:n},t.createdAt,i),Ef(r,i)}},l=({event:t})=>{let n=qG.get(e);if(!n||n.settled)return;n.settled=!0;let r=new UG(e),i=t?.code??null,a=t?.reason??null;console.warn(`[syncPromise] ${e} rejected: ${r.message} (close ${i??`<none>`} "${a??``}")`);let o=hf(e);X(`ok/sync/reject`,{docName:e,mountId:o,reason:`pre-sync-disconnect`,closeCode:i,closeReason:a}),tK(n),YG()||$G(),n.reject(r),o!==void 0&&Ef(o)},u={promise:a,resolve:o,reject:s,createdAt:i,timeoutHandle:setTimeout(()=>{let t=qG.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt,r=new HG(e,n);console.warn(`[syncPromise] ${e} rejected: ${r.message}`);let i=hf(e);X(`ok/sync/reject`,{docName:e,mountId:i,reason:`timeout`,elapsedMs:n}),tK(t),YG()||$G(),t.reject(r),i!==void 0&&Ef(i)},VG()),provider:t,onSynced:c,onClose:l,settled:!1,resolved:!1,detached:!1};return qG.set(e,u),t.on(`synced`,c),t.on(`close`,l),QG(),X(`ok/sync/create`,{docName:e,mountId:hf(e),warm:!1}),a}function rK(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!0,detached:!0}}function iK(e){let t=Promise.reject(e);t.catch(()=>{});let n=t;return n.status=`rejected`,n.reason=e,n}function aK(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!1,detached:!0}}function oK(e){return qG.get(e)?.resolved===!0}function sK(e){let t=qG.get(e);t&&(t.settled=!0,tK(t),qG.delete(e),YG()||$G())}function cK(e,t){let n=qG.get(e);if(!n||n.settled)return!1;n.settled=!0,console.warn(`[syncPromise] ${e} rejected: ${t.message}`),tK(n),YG()||$G(),n.reject(t);let r=hf(e);return r!==void 0&&Ef(r),!0}var lK=Object.freeze({kind:`tab-replay`}),uK=Object.freeze({kind:`idle`}),dK=5,fK=4408,pK=`forced`;function mK(e,t){return()=>{}}var hK=null;function gK(){return hK??=H(TG),hK}var _K=4e3,vK=1e4;function yK(e){try{return e.getText(`source`).length>0||e.getXmlFragment(`default`).length>0}catch{return!1}}var bK=class extends Error{docName;timeoutMs;constructor(e,t){super(`client persistence clearData timed out for ${e} after ${t}ms`),this.docName=e,this.timeoutMs=t,this.name=`ClientPersistenceClearTimeoutError`}},xK=class extends Error{docName;timeoutMs;constructor(e,t){super(`stored-state epoch peek timed out for ${e} after ${t}ms`),this.docName=e,this.timeoutMs=t,this.name=`StoredEpochPeekTimeoutError`}},SK=`ok-last-observed-branch`,CK=`ok-doc-lineage-epochs`,wK=5e3,TK=ha(`MAX_BUFFER_BYTES`,1*1024*1024),EK=ha(`MAX_POOL`,10),DK=class{_entries=new Map;get entries(){return this._entries}lruOrder=[];activeDocName=null;visibleDocNames=new Set;maxSize;wsUrl;recycleDebounceMs;clearDataTimeoutMs;flushOnHideEnabled=!0;unsyncedWorkListeners=new Set;replaysInFlight=0;onChange=null;tabIdentity=null;serverRestartRecoveryState=uK;cachedServerInstanceId=null;pendingServerInstanceKnown=null;recoveryMismatchStaleClaim;handledStaleClaims=new Set;bufferedUpdates=new Map;pendingClears=new Map;clearFailures=new Set;persistenceFactory;peekStoredEpoch;storage;lastObservedBranchKey;docLineageEpochsKey;storageNamespace;constructor(e,t,n){this.maxSize=e,this.wsUrl=t,this.recycleDebounceMs=n?.recycleDebounceMs??_K,this.clearDataTimeoutMs=n?.clearDataTimeoutMs??vK,this.persistenceFactory=n?.persistenceFactory??Yh,this.peekStoredEpoch=n?.peekStoredLineageEpoch??Xh,n?.storage===void 0?this.storage=globalThis.localStorage===void 0?null:globalThis.localStorage:this.storage=n.storage;let r=n?.storageNamespace??null;this.storageNamespace=r,this.lastObservedBranchKey=$i(SK,r),this.docLineageEpochsKey=$i(CK,r)}setTabIdentity(e){this.tabIdentity=e}setExpectedServerInstanceId(e){let t=e!==null&&e.length>0?e:null,n=this.cachedServerInstanceId!==null&&this.cachedServerInstanceId.length>0?this.cachedServerInstanceId:null;if(!(n!==null&&t===n)){if(n!==null&&t!==null){this.handleServerInstanceMismatch(n),this.cachedServerInstanceId=t,this.resolvePendingServerInstanceKnown(t);return}this.cachedServerInstanceId=e,t!==null&&(this.resolvePendingServerInstanceKnown(t),this.attachDeferredPersistence(t))}}resolvePendingServerInstanceKnown(e){if(this.pendingServerInstanceKnown===null)return;let t=this.pendingServerInstanceKnown;this.pendingServerInstanceKnown=null,t.resolve(e)}whenServerInstanceKnown(){return this.cachedServerInstanceId!==null&&this.cachedServerInstanceId.length>0?Promise.resolve(this.cachedServerInstanceId):(this.pendingServerInstanceKnown===null&&(this.pendingServerInstanceKnown=Promise.withResolvers()),this.pendingServerInstanceKnown.promise)}buildPersistence(e,t,n){return this.persistenceFactory({branch:this.normalizedObservedBranch(),serverInstanceId:e,docName:t,doc:n})}async validateStoredStateThenAttach(e,t){if(e.persistenceAttachOwned)return;e.persistenceAttachOwned=!0;let n=e.docName,r=()=>this._entries.get(n)===e&&e.kind===`active`&&e.persistence===null&&!this.pendingClears.has(n);if(!r())return;let i;try{i=await new Promise((e,r)=>{let i=setTimeout(()=>{r(new xK(n,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);this.peekStoredEpoch({branch:this.normalizedObservedBranch(),serverInstanceId:t,docName:n}).then(t=>{clearTimeout(i),e(t)},e=>{clearTimeout(i),r(e)})})}catch(e){this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`peek`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)});return}if(!r())return;if(i===null){this.attachValidatedPersistence(e,t);return}if(!e.hasSynced&&(await this.awaitFirstSyncOrDestroy(e),!r()||!e.hasSynced))return;let a=e.provider.document.getMap(`lifecycle`).get(xh),o=typeof a==`string`&&a.length>0?a:null;if(o===i){this.attachValidatedPersistence(e,t);return}this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(n),via:`stored-state-validation`,staleEpoch:i,liveEpoch:o??`<absent>`});let s=this.activeDocName===n;this.runCloseAndClearPersistence(n),this.open(n)!==null&&s&&this.setActive(n)}attachValidatedPersistence(e,t){let n=e.docName;try{let r=this.buildPersistence(t,n,e.provider.document);e.persistence=r,this.notify(),this.scheduleCacheBackfill(e,r)}catch(e){this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`attach`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)})}}scheduleCacheBackfill(e,t){this.backfillCacheAfterFirstSync(e,t).catch(t=>{this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(e.docName),phase:`backfill`,errorName:t instanceof Error?t.name:`non-error-throw`,errorMessage:t instanceof Error?t.message:String(t)})})}async backfillCacheAfterFirstSync(e,t){await t.whenSynced,e.hasSynced||await this.awaitFirstSyncOrDestroy(e),!(this._entries.get(e.docName)!==e||e.kind!==`active`||e.persistence!==t||!e.hasSynced)&&await t.flushFullState()}async awaitFirstSyncOrDestroy(e){e.hasSynced||await new Promise(t=>{let n=()=>{e.provider.off(`synced`,n),e.provider.off(`destroy`,n),t()};e.provider.on(`synced`,n),e.provider.on(`destroy`,n)})}attachDeferredPersistence(e){for(let t of Array.from(this._entries.values()))if(t.kind===`active`&&t.persistence===null&&this._entries.get(t.docName)===t){if(t.hasSynced&&t.lineageEpochRecordAtOpen!==null){let e=t.provider.document.getMap(`lifecycle`).get(xh);if(typeof e==`string`&&e.length>0&&e!==t.lineageEpochRecordAtOpen){let n=t.docName;this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(n),via:`deferred-attach`,staleEpoch:t.lineageEpochRecordAtOpen,liveEpoch:e});let r=this.activeDocName===n;this.runCloseAndClearPersistence(n),this.open(n)!==null&&r&&this.setActive(n);continue}}this.validateStoredStateThenAttach(t,e)}}getServerRestartRecoveryState(){return this.serverRestartRecoveryState}observeDiskAck(e,t){let n=this.entries.get(e);n?.kind===`active`&&(n.lastDiskAckedSV=$h(n.lastDiskAckedSV,t))}observeDiskAckBatch(e){for(let[t,n]of Object.entries(e))this.observeDiskAck(t,n)}lastObservedBranch=null;lastObservedBranchInitialized=!1;getOrInitObservedBranch(){if(this.lastObservedBranchInitialized)return this.lastObservedBranch;this.lastObservedBranchInitialized=!0;try{let e=this.storage?.getItem(this.lastObservedBranchKey)??null;e!==null&&e.length>0&&(this.lastObservedBranch=e)}catch{}return this.lastObservedBranch}persistObservedBranch(e){this.lastObservedBranch=e,this.lastObservedBranchInitialized=!0;try{e===null||e.length===0?this.storage?.removeItem(this.lastObservedBranchKey):this.storage?.setItem(this.lastObservedBranchKey,e)}catch{}}docLineageEpochs=new Map;docLineageEpochsEnvelopeConsumed=!1;normalizedObservedBranch(){return this.getOrInitObservedBranch()??`_unknown_`}consumeLineageEpochEnvelopeIfValid(){if(this.docLineageEpochsEnvelopeConsumed)return;let e=this.cachedServerInstanceId;if(!(e===null||e.length===0)){this.docLineageEpochsEnvelopeConsumed=!0;try{let t=this.storage?.getItem(this.docLineageEpochsKey)??null;if(t===null)return;let n=JSON.parse(t);if(typeof n!=`object`||!n)return;let r=n;if(r.branch!==this.normalizedObservedBranch()||r.serverInstanceId!==e||typeof r.epochs!=`object`||r.epochs===null)return;for(let[e,t]of Object.entries(r.epochs))typeof t==`string`&&t.length>0&&!this.docLineageEpochs.has(e)&&this.docLineageEpochs.set(e,t)}catch(e){e instanceof DOMException||console.warn(JSON.stringify({event:`ok-lineage-epoch-envelope-read-error`,errorName:e instanceof Error?e.name:typeof e,message:e instanceof Error?e.message:String(e)}))}}}getRecordedLineageEpoch(e){let t=this.docLineageEpochs.get(e);return t===void 0?(this.consumeLineageEpochEnvelopeIfValid(),this.docLineageEpochs.get(e)??null):t}persistLineageEpochEnvelope(){let e=this.cachedServerInstanceId;if(!(e===null||e.length===0))try{this.storage?.setItem(this.docLineageEpochsKey,JSON.stringify({branch:this.normalizedObservedBranch(),serverInstanceId:e,epochs:Object.fromEntries(this.docLineageEpochs)}))}catch{}}recordLineageEpoch(e,t){this.docLineageEpochs.get(e)!==t&&(this.docLineageEpochs.set(e,t),this.persistLineageEpochEnvelope())}deleteLineageEpochRecord(e){this.docLineageEpochs.delete(e)&&this.persistLineageEpochEnvelope()}withClearDataTimeout(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>{r(new bK(e,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);t.then(()=>{clearTimeout(i),n()},e=>{clearTimeout(i),r(e)})})}recoveryTelemetryBase(e,t){let n={docName:e,branch:this.normalizedObservedBranch()},r=t===void 0?this.recoveryMismatchStaleClaim:t;return r!==void 0&&r.length>0&&(n.serverInstanceId=r),this.storageNamespace!==null&&(n.project=ea(this.storageNamespace)),n}emitStructuredClientRecoveryEvent(e){console.warn(JSON.stringify(e))}outboxFailureFields(e){return{failureKind:e instanceof MG?`timeout`:`rejected`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)}}emitStructuredClientBreadcrumb(e){console.info(JSON.stringify(e))}clearRecoveryMismatchStaleClaimIfTerminal(){let e=this.serverRestartRecoveryState.kind;(e===`idle`||e===`failed`)&&(this.recoveryMismatchStaleClaim=void 0)}beginServerRestartRecovery(e,t){this.emitStructuredClientBreadcrumb({event:`ok-pool-restart-recovery-begin`,phase:`clearing-local-cache`,docCount:e.length}),this.serverRestartRecoveryState={kind:`recovering`,phase:`clearing-local-cache`,docNames:e,failedDocNames:[],startedAt:t};for(let t of e)sK(t);this.notify()}enterServerRestartReconnect(e,t,n,r){if(this.emitStructuredClientBreadcrumb({event:`ok-pool-restart-recovery-reconnecting`,docCount:e.length,failedCount:t.length}),e.length===0){this.serverRestartRecoveryState=t.length===0?uK:{kind:`failed`,reason:r,docNames:t,failedDocNames:t,startedAt:n},this.clearRecoveryMismatchStaleClaimIfTerminal(),this.notify();return}this.serverRestartRecoveryState={kind:`recovering`,phase:`reconnecting`,docNames:e,failedDocNames:t,startedAt:n,...t.length>0?{clearFailureReason:r}:{}},this.notify()}markServerRestartRecoverySynced(e){let t=this.serverRestartRecoveryState;if(t.kind!==`recovering`||t.phase!==`reconnecting`||!t.docNames.includes(e))return;let n=t.docNames.filter(t=>t!==e);if(this.emitStructuredClientBreadcrumb({event:`ok-pool-restart-recovery-synced`,docName:e,remaining:n.length}),n.length>0){this.serverRestartRecoveryState={...t,docNames:n};return}if(t.failedDocNames.length>0){this.serverRestartRecoveryState={kind:`failed`,reason:t.clearFailureReason??`clear-data-failed`,docNames:t.failedDocNames,failedDocNames:t.failedDocNames,startedAt:t.startedAt},this.clearRecoveryMismatchStaleClaimIfTerminal();return}this.serverRestartRecoveryState=uK,this.clearRecoveryMismatchStaleClaimIfTerminal()}setObservedBranch(e){this.persistObservedBranch(e)}compareAndUpdateObservedBranch(e){let t=this.getOrInitObservedBranch();return this.persistObservedBranch(e),t!==null&&t!==e}onBranchMismatch=null;branchMismatchInFlight=null;mismatchInFlight=null;setOnBranchMismatch(e){if(e===null){this.onBranchMismatch=null;return}this.onBranchMismatch=()=>{if(this.branchMismatchInFlight!==null)return;let t=Promise.resolve().then(e).finally(()=>{this.branchMismatchInFlight===t&&(this.branchMismatchInFlight=null)});this.branchMismatchInFlight=t}}onRenameRedirect=null;onDocDeleted=null;setOnRenameRedirect(e){this.onRenameRedirect=e}setOnDocDeleted(e){this.onDocDeleted=e}setOnChange(e){this.onChange=e}notify(){this.onChange?.()}evictListeners=new Set;onEvict(e){return this.evictListeners.add(e),()=>{this.evictListeners.delete(e)}}fireEvict(e){for(let t of this.evictListeners)try{t(e)}catch(t){console.warn(`[ProviderPool] evict listener threw for ${e}:`,t)}}touch(e){let t=this.lruOrder.indexOf(e);t!==-1&&this.lruOrder.splice(t,1),this.lruOrder.push(e)}setVisibleDocNames(e){let t=new Set;for(let n of e)Ov(n)||t.add(n);t.size===this.visibleDocNames.size&&[...t].every(e=>this.visibleDocNames.has(e))||(this.visibleDocNames=t,this.trimToCapacity(),X(`ok/pool/visible-set`,{visibleCount:this.visibleDocNames.size,poolSize:this.entries.size}))}isProtected(e){return e===this.activeDocName||this.visibleDocNames.has(e)}effectiveCapacity(){let e=this.visibleDocNames.size+ +(this.activeDocName!==null&&!this.visibleDocNames.has(this.activeDocName));return Math.max(this.maxSize,e)}trimToCapacity(){for(;this.entries.size>this.effectiveCapacity()&&this.evictLru(););}open(e){if(Ov(e))return null;let t=this.entries.get(e);if(t!==void 0&&t.kind===`active`&&t.hasSynced&&t.syncState===`disconnected`&&t.provider.unsyncedChanges===0&&!yK(t.provider.document)){X(`ok/pool/recycle-disconnected-on-open`,{docName:e}),this.emitStructuredClientBreadcrumb({event:`ok-pool-recycle-disconnected-on-open`,docName:e}),this.recycleDisconnectedEntry(e);let t=this.entries.get(e);if(t!==void 0)return t}let n=this.entries.get(e);if(n){let t=n.lastAccessedAt;return n.lastAccessedAt=Date.now(),this.touch(e),this.notify(),X(`ok/pool/open`,{docName:e,hit:!0,lastAccessedAt:t,poolEventId:n.poolEventId}),X.count(`ok/pool/open`,{hit:!0}),n}let r=Date.now();this.entries.size>=this.effectiveCapacity()&&this.evictLru();let i=this.cachedServerInstanceId,a=this.getRecordedLineageEpoch(e),o=ja(this.tabIdentity,i,this.getOrInitObservedBranch(),i!==null&&i.length>0?a:null),s=new Ma({url:eg(this.wsUrl),name:e,forceSyncInterval:wK,token:o}),c=this.cachedServerInstanceId;this.clearFailures.has(e)&&this.runCloseAndClearPersistence(e);let l=this.pendingClears.get(e),u=c!==null&&c.length>0&&l===void 0&&a!==null?this.buildPersistence(c,e,s.document):null,d=Ni(),f={kind:`active`,provider:s,persistence:u,lastServerSyncedSV:null,lastDiskAckedSV:null,observerCleanup:null,observerFireCounterCleanup:mK(s.document,e),syncState:`connecting`,docName:e,lastAccessedAt:Date.now(),poolEventId:d,hasSynced:!1,pendingRecycleTimer:null,bridgeSetupFailed:!1,serverDrivenCloseReauthInFlight:!1,serverDrivenCloseReauthAttempts:0,persistenceAttachOwned:!1,lineageEpochRecordAtOpen:a};X(`ok/pool/open`,{docName:e,hit:!1,poolEventId:d}),X.count(`ok/pool/open`,{hit:!1}),s.on(`status`,({status:t})=>{f.kind!==`active`||this.entries.get(e)!==f||t===`disconnected`&&(f.syncState=`disconnected`,this.notify())}),s.on(`synced`,()=>{if(f.kind!==`active`||this.entries.get(e)!==f)return;f.syncState=`synced`,f.hasSynced=!0,f.lastServerSyncedSV=Zh(s.document);let t=s.document.getMap(`lifecycle`).get(xh);if(typeof t==`string`&&t.length>0&&this.recordLineageEpoch(e,t),f.pendingRecycleTimer&&=(clearTimeout(f.pendingRecycleTimer),null),f.serverDrivenCloseReauthAttempts=0,this.markServerRestartRecoverySynced(e),this.notify(),!f.observerCleanup)try{let t=s.document,n=new Jr({extensions:TG});f.observerCleanup=Ut({doc:t,xmlFragment:t.getXmlFragment(`default`),ytext:t.getText(`source`),mdManager:n,schema:gK(),onSyncError:(t,n)=>{console.warn(`[Sync] ${t} failed for ${e}:`,n.message)}})}catch(t){console.error(`[ProviderPool] setupObservers init failed for ${e}:`,t),f.bridgeSetupFailed=!0,cK(e,new GG(e,t))}}),s.on(`disconnect`,()=>{f.kind!==`active`||this.entries.get(e)!==f||(f.syncState=`disconnected`,this.notify(),f.hasSynced&&s.unsyncedChanges===0&&!yK(s.document)&&!f.pendingRecycleTimer&&(this.emitStructuredClientBreadcrumb({event:`ok-pool-recycle-timer-armed`,docName:e,debounceMs:this.recycleDebounceMs}),f.pendingRecycleTimer=setTimeout(()=>{if(f.kind===`active`&&(f.pendingRecycleTimer=null,this.entries.get(e)===f)){if(s.unsyncedChanges>0){X(`ok/pool/recycle-skipped-unsynced`,{docName:e}),this.emitStructuredClientBreadcrumb({event:`ok-pool-recycle-skipped-unsynced`,docName:e});return}this.recycleDisconnectedEntry(e)}},this.recycleDebounceMs)))}),s.on(`authenticationFailed`,({reason:t})=>{let n=[`server-instance-mismatch`,`branch-mismatch`,`rename-redirect`,`doc-deleted`,`doc-lineage-mismatch`],r=t.indexOf(`:`),a=r===-1?t:t.slice(0,r);if(!n.includes(a)){console.warn(JSON.stringify({event:`ok-auth-failed-unknown-reason`,reason:t}));return}let o=r===-1?``:t.slice(r+1),s=o.length>0?o:void 0,c=a;if(c===`server-instance-mismatch`){if(i===null)return;this.handleServerInstanceMismatch(i);return}if(c===`branch-mismatch`){this.onBranchMismatch?.();return}if(c===`rename-redirect`){if(s===void 0||s.length===0){console.warn(JSON.stringify({event:`rename-redirect-missing-payload`,fromDocName:e}));return}let t=e,n=s;this.deleteLineageEpochRecord(t);let r=this.entries.get(t),i=r!==void 0&&r.kind===`active`;this.onRenameRedirect?.({fromDocName:t,toDocName:n,hadOpenProvider:i});return}if(c===`doc-deleted`){this.deleteLineageEpochRecord(e);let t=this.entries.get(e),n=t!==void 0&&t.kind===`active`;this.onDocDeleted?.({docName:e,hadOpenProvider:n});return}if(c===`doc-lineage-mismatch`){if(f.kind!==`active`||this.entries.get(e)!==f)return;this.deleteLineageEpochRecord(e),this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(e),via:`auth-rejection`,staleEpoch:f.lineageEpochRecordAtOpen??``});let t=this.activeDocName===e;this.runCloseAndClearPersistence(e),this.open(e)!==null&&t&&this.setActive(e);return}}),s.on(`close`,({event:t})=>{if(!(f.kind!==`active`||this.entries.get(e)!==f)&&t?.reason){if(t.code===fK&&t.reason===pK){this.emitStructuredClientBreadcrumb({event:`ok-provider-half-open-forced-close`,docName:e,code:t.code,reason:t.reason});return}if(!f.serverDrivenCloseReauthInFlight){if(f.serverDrivenCloseReauthAttempts>=dK){f.serverDrivenCloseReauthAttempts===dK&&(f.serverDrivenCloseReauthAttempts=dK+1,console.warn(JSON.stringify({event:`ok-provider-server-driven-close-reauth-ceiling`,docName:e,attempts:dK,reason:t?.reason??`<unknown>`,code:t?.code??null})));return}f.serverDrivenCloseReauthAttempts+=1,f.serverDrivenCloseReauthInFlight=!0,s.sendToken().catch(t=>{console.warn(JSON.stringify({event:`ok-provider-server-driven-close-reauth-failed`,docName:e,message:t instanceof Error?t.message:String(t)}))}).finally(()=>{f.kind===`active`&&this.entries.get(e)===f&&(f.serverDrivenCloseReauthInFlight=!1)}),console.info(JSON.stringify({event:`ok-provider-server-driven-close-reauth`,docName:e,reason:t.reason,code:t?.code??null}))}}}),s.on(`unsyncedChanges`,()=>this.emitUnsyncedWork()),this.emitUnsyncedWork();let p=this.recoveryMismatchStaleClaim,m=async()=>{if(f.kind!==`active`||this.entries.get(e)!==f)return;let t=this.normalizedObservedBranch(),n,r=t,i,a=this.bufferedUpdates.get(e);if(a!==void 0){if(a.branch!==t){this.discardBufferedUpdate(e),this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-branch-mismatch`,...this.recoveryTelemetryBase(e,p),reason:`buffer-captured-on-another-branch`});return}this.bufferedUpdates.delete(e),n=a,r=a.branch,i=a.durable}else try{let r=await zG({branch:t,docName:e,namespace:this.storageNamespace});if(r===null)return;n=r,i=!0}catch(t){this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-outbox-read-failed`,...this.recoveryTelemetryBase(e,p),...this.outboxFailureFields(t)});return}if(i){let t;try{t=await BG({branch:r,docName:e,namespace:this.storageNamespace})}catch(t){this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-outbox-consume-failed`,...this.recoveryTelemetryBase(e,p),...this.outboxFailureFields(t)});return}if(!t){this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-superseded`,...this.recoveryTelemetryBase(e,p),reason:`claimed-by-another-tab`});return}}if(f.kind!==`active`||this.entries.get(e)!==f){this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-abandoned`,...this.recoveryTelemetryBase(e,p),reason:`entry-replaced-during-consume`,replayByteLength:n.delta.byteLength});return}try{if(n.fullState!==null&&this.replayBufferedContent(e,s,n.fullState))return;Pa(s.document,n.delta,lK),this.emitStructuredClientBreadcrumb({event:`ok-pool-buffer-replay-delta-applied`,docName:e,deltaBytes:n.delta.byteLength})}catch(t){let r=t instanceof Error?t.name:`non-error-throw`;this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-failed`,...this.recoveryTelemetryBase(e,p),replayByteLength:n.delta.byteLength,errorName:r,errorMessage:t instanceof Error?t.message:String(t)})}},h=()=>{s.off(`synced`,h),this.replaysInFlight+=1,m().catch(t=>{this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-unexpected-error`,...this.recoveryTelemetryBase(e),errorName:t instanceof Error?t.name:`non-error-throw`,errorMessage:t instanceof Error?t.message:String(t)})}).finally(()=>{--this.replaysInFlight,this.emitUnsyncedWork()})};if(s.on(`synced`,h),this._entries.set(e,f),this.touch(e),this.notify(),u!==null&&this.scheduleCacheBackfill(f,u),u===null&&c!==null&&c.length>0&&l===void 0&&this.validateStoredStateThenAttach(f,c),l!==void 0&&c!==null&&c.length>0){let t=c;l.then(()=>{this.attachDeferredPersistenceForEntry(f,t)},t=>{console.warn(JSON.stringify({event:`ok-pool-deferred-persistence-attach-skipped`,docName:e,reason:`pending-clear-failed`,message:t instanceof Error?t.message:String(t)}))})}let g=hf(e);return g!==void 0&&Tf(g,`ok.provider-pool.open`,{"doc.name":e},r,Date.now()),f}attachDeferredPersistenceForEntry(e,t){let n=this._entries.get(e.docName);n!==e||n.kind!==`active`||n.persistence!==null||this.validateStoredStateThenAttach(n,t)}handleServerInstanceMismatch(e){if(this.handledStaleClaims.has(e)){this.emitStructuredClientBreadcrumb({event:`ok-pool-mismatch-transition-deduped`,reason:`claim-already-handled`,staleClaim:e});return}if(this.handledStaleClaims.add(e),this.cachedServerInstanceId===e&&(this.cachedServerInstanceId=null),this.mismatchInFlight!==null){this.emitStructuredClientBreadcrumb({event:`ok-pool-mismatch-transition-deduped`,reason:`recycle-in-flight`,staleClaim:e,inflightForClaim:this.recoveryMismatchStaleClaim??``});return}this.recoveryMismatchStaleClaim=e.length>0?e:void 0;let t=Array.from(this.entries.entries());this.emitStructuredClientBreadcrumb({event:`ok-pool-mismatch-recycle-begin`,entryCount:t.length,branch:this.normalizedObservedBranch()});let n=Date.now(),r=this.normalizedObservedBranch(),i=[],a=this.activeDocName,o=a!==null&&t.some(([e,t])=>e===a&&t.kind===`active`)?[a]:[],s=a??t.find(([,e])=>e.kind===`active`)?.[0]??``;s.length>0&&this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-epoch-mismatch`,...this.recoveryTelemetryBase(s)}),this.beginServerRestartRecovery(o,n);for(let[e,n]of t)n.kind===`active`&&!o.includes(e)&&sK(e);for(let[e,n]of t){if(n.kind!==`active`)continue;let t=n.lastDiskAckedSV??n.lastServerSyncedSV;if(t===null){this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-skipped-no-baseline`,...this.recoveryTelemetryBase(e),reason:`no-disk-ack-or-server-sync-vector`});continue}let a=Qh(n.provider.document,t);if(a.byteLength>TK){X(`ok/pool/buffer-overflow`,{docName:e,bytes:a.byteLength});continue}if(a.byteLength>0){let t=wa(n.provider.document),o=t.byteLength>TK?null:t,s={delta:a,fullState:o,branch:r,durable:!1};this.bufferedUpdates.set(e,s),o!==null&&i.push(RG({branch:r,docName:e,namespace:this.storageNamespace},{delta:a,fullState:o}).then(t=>{t?s.durable=!0:this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-outbox-unavailable`,...this.recoveryTelemetryBase(e),reason:`indexeddb-databases-unsupported`})}).catch(t=>{this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-outbox-write-failed`,...this.recoveryTelemetryBase(e),...this.outboxFailureFields(t)})})),this.emitStructuredClientBreadcrumb({event:`ok-pool-mismatch-buffer-captured`,docName:e,deltaBytes:a.byteLength,fullStateBytes:o===null?0:o.byteLength})}}let c=[];for(let[e,n]of t)n.kind===`active`&&n.persistence!==null&&c.push({docName:e,persistence:n.persistence});let l=()=>{let e=c.map(({docName:e,persistence:t})=>({docName:e,promise:this.withClearDataTimeout(e,t.clearData())}));return this.emitStructuredClientBreadcrumb({event:`ok-pool-mismatch-clears-begin`,count:e.length}),Promise.allSettled(e.map(e=>e.promise)).then(t=>{let r=[],i=[],o=!1;t.forEach((t,n)=>{let a=e[n];if(!a)return;let s=a.docName;if(t.status===`rejected`){r.push(s);let e=t.reason instanceof bK;if(e&&(o=!0),e)this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-clear-failed`,...this.recoveryTelemetryBase(s),failureKind:`timeout`});else{let e=t.reason instanceof Error?t.reason.name:`unknown`;this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-clear-failed`,...this.recoveryTelemetryBase(s),failureKind:`rejected`,errorName:e,errorMessage:t.reason instanceof Error?t.reason.message:String(t.reason)})}}else i.push(s)});let s=i.filter(e=>e===a);if(r.length>0){let e=o?`clear-data-timeout`:`clear-data-failed`;console.warn(JSON.stringify({event:`ok-mismatch-recycle-partial-clears-failed`,failedDocs:r,clearedDocs:i})),this.enterServerRestartReconnect(s,r,n,e);for(let e of i)this.recycleDisconnectedEntry(e);return}this.enterServerRestartReconnect(s,[],n,`clear-data-failed`),this.recycleAllEntries()})},u=(i.length===0?l():Promise.allSettled(i).then(l)).finally(()=>{this.mismatchInFlight===u&&(this.mismatchInFlight=null,this.handledStaleClaims.clear())});this.mismatchInFlight=u}replayBufferedContent(e,t,n){let r=new Na;try{Pa(r,n);let i=r.getText(`source`).toString(),a=Wt(r.getXmlFragment(`default`),gK()).toJSON(),o=new Jr({extensions:TG}).serialize(a),{frontmatter:s,body:c}=et(i),l=t.document.getText(`source`).toString(),{body:u}=et(l),d=Gi(u),f=Gi(c)===d&&!qi(u,c),p=Gi(o)===d&&!qi(u,o);if(f&&p)return!0;let m;if(f)m=Ki(s,o).md;else if(p)m=i;else return this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-diverged`,...this.recoveryTelemetryBase(e)}),!1;if(m!==l){let e=Math.min(m.length,l.length),n=0;for(;n<e&&m[n]===l[n];)n+=1;let r=0;for(;r<e-n&&m[m.length-1-r]===l[l.length-1-r];)r+=1;let i=t.document.getText(`source`);t.document.transact(()=>{i.delete(n,l.length-n-r),i.insert(n,m.slice(n,m.length-r))},lK)}return this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-content-applied`,...this.recoveryTelemetryBase(e),surface:f?`fragment`:`ytext`}),!0}catch(t){return this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-content-failed`,...this.recoveryTelemetryBase(e),errorName:t instanceof Error?t.name:`non-error-throw`,errorMessage:t instanceof Error?t.message:String(t)}),!1}finally{r.destroy()}}awaitMismatchSettled(){return this.mismatchInFlight??Promise.resolve()}isMismatchRecycleInFlight(){return this.mismatchInFlight!==null}recycleAllEntries(){let e=Array.from(this.entries.keys());this.emitStructuredClientBreadcrumb({event:`ok-pool-recycle-all`,count:e.length});for(let t of e)this.recycleDisconnectedEntry(t)}prewarm(e){if(Ov(e))return null;let t=this.entries.get(e);if(t)return t;let n=this.open(e);if(!n)return null;let r=this.lruOrder.indexOf(e);return r!==-1&&(this.lruOrder.splice(r,1),this.lruOrder.unshift(e)),n}close(e){let t=this.entries.get(e);t&&(this.destroyEntry(t),this._entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),this.discardBufferedUpdate(e),this.activeDocName===e&&(this.activeDocName=null),this.notify())}async closeAndClearPersistence(e){try{await this.runCloseAndClearPersistence(e)}catch{}}runCloseAndClearPersistence(e){let t=this.pendingClears.get(e);if(t!==void 0)return t;let{promise:n,resolve:r,reject:i}=Promise.withResolvers();this.pendingClears.set(e,n);let a=()=>{this.pendingClears.get(e)===n&&this.pendingClears.delete(e)};return n.then(a,a),this.executeCloseAndClearPersistence(e).then(r,i),n}async executeCloseAndClearPersistence(e){this.clearFailures.delete(e);let t=this.entries.get(e);if(t?.kind===`active`&&t.persistence!==null){let n=t.persistence;try{this.close(e)}catch(t){console.warn(`[ProviderPool] close before clearData threw for ${e}:`,t)}try{await this.withClearDataTimeout(e,n.clearData())}catch(t){throw console.warn(`[ProviderPool] clearData on rename failed for ${e}:`,t),this.clearFailures.add(e),t}return}if(t)try{this.close(e)}catch(t){console.warn(`[ProviderPool] close before IDB-by-name delete threw for ${e}:`,t)}let n=this.normalizedObservedBranch(),r=this.cachedServerInstanceId;if(r===null)return;let i=`ok-ydoc:${n}:${r}:${e}`;try{await this.withClearDataTimeout(e,new Promise((e,t)=>{let n=indexedDB.deleteDatabase(i);n.onsuccess=()=>e(),n.onerror=()=>t(n.error),n.onblocked=()=>{console.warn(`[ProviderPool] IDB delete blocked for ${i}`)}}))}catch(t){throw console.warn(`[ProviderPool] IDB delete on rename failed for ${i}:`,t),this.clearFailures.add(e),t}}clearBufferedUpdates(){for(let e of Array.from(this.bufferedUpdates.keys()))this.discardBufferedUpdate(e)}discardBufferedUpdate(e){let t=this.bufferedUpdates.get(e);this.bufferedUpdates.delete(e),t!==void 0&&(this.emitUnsyncedWork(),t.durable&&BG({branch:t.branch,docName:e,namespace:this.storageNamespace}).catch(t=>{this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-outbox-discard-failed`,...this.recoveryTelemetryBase(e),...this.outboxFailureFields(t)})}))}__test_seedBufferedUpdate(e,t,n={}){this.bufferedUpdates.set(e,{delta:t,fullState:n.fullState??null,branch:n.branch??this.normalizedObservedBranch(),durable:n.durable??!1})}__test_bufferedUpdatesSize(){return this.bufferedUpdates.size}__test_hasBufferedUpdate(e){return this.bufferedUpdates.has(e)}__test_getBufferedUpdate(e){return this.bufferedUpdates.get(e)?.delta}setActive(e){let t=this.entries.get(e);if(!t)throw Error(`[ProviderPool] Cannot setActive — "${e}" is not open`);t.lastAccessedAt=Date.now(),this.touch(e),this.activeDocName=e,this.notify()}clearActive(){this.activeDocName!==null&&(this.activeDocName=null,this.notify())}getActive(){return this.activeDocName?this.entries.get(this.activeDocName)??null:null}getActiveDocName(){return this.activeDocName}has(e){return this.entries.has(e)}peek(e){return this.entries.get(e)??null}setFlushOnHideEnabled(e){this.flushOnHideEnabled=e}flushOnHide(){if(this.flushOnHideEnabled&&this.mismatchInFlight===null)for(let e of this._entries.values())e.kind===`active`&&e.provider.unsyncedChanges>0&&(e.provider.forceSync(),e.persistence?.flushFullState().catch(t=>{this.emitStructuredClientRecoveryEvent({event:`ok-pool-flush-on-hide-failed`,...this.recoveryTelemetryBase(e.docName),errorName:t instanceof Error?t.name:`non-error-throw`,errorMessage:t instanceof Error?t.message:String(t)})}))}resyncOnVisible(){if(this.flushOnHideEnabled&&this.mismatchInFlight===null)for(let e of this._entries.values())e.kind===`active`&&e.syncState===`synced`&&e.provider.forceSync()}hasAnyUnsyncedWork(){for(let e of this._entries.values())if(e.kind===`active`&&e.provider.unsyncedChanges>0)return!0;return!1}hasUnsavedWork(){return this.hasAnyUnsyncedWork()||this.hasPendingReplay()}hasPendingReplay(){if(this.replaysInFlight>0)return!0;for(let e of this.bufferedUpdates.values())if(!e.durable)return!0;return!1}openDocNames(){let e=[];for(let[t,n]of this._entries)n.kind===`active`&&e.push(t);return e}docNamesToOpenForReplay(){let e=[];for(let[t,n]of this.bufferedUpdates)!n.durable&&!this.entries.has(t)&&e.push(t);return e}addUnsyncedWorkListener(e){return this.unsyncedWorkListeners.add(e),()=>{this.unsyncedWorkListeners.delete(e)}}emitUnsyncedWork(){for(let e of this.unsyncedWorkListeners)try{e()}catch(e){this.emitStructuredClientRecoveryEvent({event:`ok-pool-unsynced-work-listener-threw`,error:e instanceof Error?e.message:String(e)})}}recycle(e){this.recycleDisconnectedEntry(e)}dispose(){for(let e of this._entries.values())this.destroyEntry(e);this._entries.clear(),this.lruOrder=[],this.activeDocName=null,this.visibleDocNames.clear(),this.onChange=null,this.bufferedUpdates.clear(),this.pendingClears.clear(),this.clearFailures.clear(),this.handledStaleClaims.clear(),this.docLineageEpochs.clear(),this.docLineageEpochsEnvelopeConsumed=!1,this.onBranchMismatch=null,this.branchMismatchInFlight=null,this.mismatchInFlight=null,this.onRenameRedirect=null,this.onDocDeleted=null,this.evictListeners.clear(),this.serverRestartRecoveryState=uK,this.cachedServerInstanceId=null,this.pendingServerInstanceKnown=null,this.tabIdentity=null,this.recoveryMismatchStaleClaim=void 0,this.unsyncedWorkListeners.clear(),this.flushOnHideEnabled=!0}evictLru(){for(let e of this.lruOrder)if(!this.isProtected(e))return X(`ok/pool/evict-lru`,{docName:e}),this.close(e),!0;return!1}destroyEntry(e){if(e.kind===`tearing-down`)return;let t=e.observerCleanup,n=e.observerFireCounterCleanup,r=e.persistence,i=e.pendingRecycleTimer,a=e.docName,o=e;o.kind=`tearing-down`,o.persistence=null,o.observerCleanup=null,o.observerFireCounterCleanup=null,o.pendingRecycleTimer=null,o.serverDrivenCloseReauthInFlight=!1,o.serverDrivenCloseReauthAttempts=0,i&&clearTimeout(i),sK(a),this.fireEvict(a);try{t?.()}catch(e){console.warn(`[ProviderPool] observer cleanup threw for ${a}:`,e)}try{n?.()}catch(e){console.warn(`[ProviderPool] observer-fire-counter cleanup threw for ${a}:`,e)}r!==null&&r.destroy().catch(e=>{console.warn(`[ProviderPool] persistence destroy failed for ${a}:`,e)});try{o.provider.destroy()}catch(e){console.warn(`[ProviderPool] Provider destroy failed for ${a}:`,e)}}recycleDisconnectedEntry(e){let t=this.entries.get(e);if(t?.kind!==`active`)return;let n=this.activeDocName===e;if(X(`ok/pool/recycle-disconnected`,{docName:e,wasActive:n}),this.emitStructuredClientBreadcrumb({event:`ok-pool-recycle-entry`,docName:e,wasActive:n}),this.destroyEntry(t),this._entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),n){this.open(e)&&this.setActive(e);return}this.notify()}},OK=Ni(),kK=!1;function AK(e){kK||(kK=!0,console.warn(`[principal-fetch] failed to resolve principal — falling back to random identity.`,e))}var jK=(0,Z.createContext)(null),MK=/\.(md|mdx)$/i,NK=null;function PK(e){return NK||(NK=new DK(EK,e,{storageNamespace:ta()?.contentDir??null}),kp(NK)),NK}var FK={activeDocName:null,activeProvider:null,syncState:`connecting`,serverRestartRecovery:{kind:`idle`},poolEntries:[]};function IK(){if(typeof window>`u`)return null;let e=window.okDesktop;return e?.config.mode===`editor`?e:null}function LK(){return typeof window>`u`?null:dh(window.okDesktop?.config.mode,window.location.origin)}function RK(){if(typeof window>`u`)return sh(null);let e=LK();return e?fh(window.localStorage===void 0?null:window.localStorage,e):sh(null)}var zK=`new-tab:`,BK=`new-tab:blob-runner:`,VK={files:zK,"blob-runner":BK};function HK(e){return UK(e)?`blob-runner`:`files`}function UK(e){return e?.startsWith(BK)??!1}function WK(e){let t=Km(e);switch(t.kind){case`doc`:return pa(t.docName);case`folder`:return aa(t.folderPath);case`asset`:return ca(t.assetPath);case`skill-file`:return da({scope:t.scope,name:t.name,path:t.path});case`skill-preview`:return la({flavor:t.flavor,source:t.source,name:t.name,subtitle:t.subtitle,level:t.level})}}function GK(e){typeof window<`u`&&!ra(window.location.hash,e)&&(uf(e),window.location.hash=e)}function KK(e){if(!e)throw Error(`removal reconciler is not initialized`);return e}function qK(e){let t=Km(e);switch(t.kind){case`doc`:return{kind:`doc`,target:t.docName,docName:t.docName};case`folder`:return{kind:`folder`,target:t.folderPath,folderPath:t.folderPath};case`asset`:return tq(t.assetPath);case`skill-file`:return{kind:`skill-file`,target:`${t.scope}/${t.name}${t.host?`:${t.host}`:``}/${t.path}`,scope:t.scope,name:t.name,path:t.path,...t.host?{host:t.host}:{}};case`skill-preview`:return{kind:`skill-preview`,target:`${t.flavor}/${t.source}/${t.name}`,flavor:t.flavor,source:t.source,name:t.name,subtitle:t.subtitle,level:t.level}}}function JK(e){return e.activeNewTabId!==null||e.activeTabId===null?e.activeTarget===null?e:{...e,activeTarget:null}:(e.activeTarget?Gm(e.activeTarget):null)===e.activeTabId?e:{...e,activeTarget:qK(e.activeTabId)}}function YK(e){return{...e,panes:e.panes.map(JK)}}function XK(){let e=Os()?sh(null):RK();return YK(Gp({panes:e.panes,focusedPaneId:e.focusedPaneId}))}function ZK(e){return!e.activeTarget||e.activeTarget.kind===`large-file`?null:lo(e.activeTarget)}function QK(e){let t=new Set;for(let n of e.panes){let e=ZK(n);e&&t.add(e)}return t}function $K(e){let t=ua(e);if(t)return Um(t);let n=na(e);if(n)return Fm(n);let r=ma(e);if(r)return Lm(r);let i=ia(e);if(!i)return null;let a=i.trim();if(/\/+$/.test(a)){let e=a.replace(/\/+$/g,``);return e?Hm(e):null}return Vm(i)}function eq(e,t,n){return!e||!n||!ra(t,pa(e))||MK.test(e)||!MK.test(n)?!1:n.replace(MK,``)===e}function tq(e){return{kind:`asset`,target:e,assetPath:e,mediaKind:R(e.split(`.`).pop()??``)}}function nq(e){switch(e.kind){case`doc`:return`doc:${e.docName}`;case`folder-index`:return`folder-index:${e.docName}:${e.folderPath}:${e.noteKind}`;case`folder`:return`folder:${e.folderPath}`;case`asset`:return`asset:${e.assetPath}:${e.mediaKind??``}`;case`skill-file`:return`skill-file:${e.scope}:${e.name}:${e.path}`;case`skills`:return`skills:hub`;case`skill-preview`:return`skill-preview:${e.flavor}:${e.source}:${e.name}:${e.subtitle}:${e.path??``}`;case`large-file`:return`large-file:${e.docName}:${e.size}:${e.limit}`;case`missing`:return`missing:${e.target}`}}function rq(e,t){return e===t?!0:!e||!t?!1:nq(e)===nq(t)}function iq(e,t){return e===t?!0:e.activeDocName!==t.activeDocName||e.activeProvider!==t.activeProvider||e.syncState!==t.syncState||e.serverRestartRecovery!==t.serverRestartRecovery||e.poolEntries.length!==t.poolEntries.length?!1:e.poolEntries.every((e,n)=>{let r=t.poolEntries[n];return e.docName===r.docName&&e.provider===r.provider&&e.poolEventId===r.poolEventId})}function aq(e){let t=e.getActive(),n=[];for(let t of e.entries.values())n.push({docName:t.docName,provider:t.provider,lastAccessedAt:t.lastAccessedAt,poolEventId:t.poolEventId});return n.sort((e,t)=>t.lastAccessedAt-e.lastAccessedAt),{activeDocName:e.getActiveDocName(),activeProvider:t?.provider??null,syncState:t?.syncState??`connecting`,serverRestartRecovery:e.getServerRestartRecoveryState(),poolEntries:n}}function oq(e){let t=(0,Q.c)(252),{children:n}=e,[r,i]=(0,Z.useState)(FK),[a,o]=(0,Z.useState)(XK),s=(0,Z.useRef)(a),c;t[0]===a.panes?c=t[1]:(c=()=>new Map(a.panes.map(Sq)),t[0]=a.panes,t[1]=c);let[l,u]=(0,Z.useState)(c),d=(0,Z.useRef)(l),f,p,m,h;if(t[2]!==l||t[3]!==a){let e=Yp(a),n;t[8]===a?n=t[9]:(n=$p(a),t[8]=a,t[9]=n),f=n;let r;t[10]===a?r=t[11]:(r=em(a),t[10]=a,t[11]=r),p=r;let i;t[12]===a.panes?i=t[13]:(i=new Map(a.panes.map(xq)),t[12]=a.panes,t[13]=i),m=i,h=th(l.get(e.id)??[],e.openTabs,e.newTabIds),t[2]=l,t[3]=a,t[4]=f,t[5]=p,t[6]=m,t[7]=h}else f=t[4],p=t[5],m=t[6],h=t[7];let g=h,[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(1),b=(0,Z.useRef)(1),x;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(x=[],t[14]=x):x=t[14];let S=(0,Z.useRef)(x),C=(0,Z.useRef)(null),w=(0,Z.useRef)(!1),T=(0,Z.useRef)(`unread`),[E,D]=(0,Z.useState)(null),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(`doc`),[M,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(0),{collabUrl:I,terminal:L,lastError:ee,retry:R}=_o(),[te,ne]=(0,Z.useState)(null),re;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(re=[],t[15]=re):re=t[15];let ie=(0,Z.useRef)(re),ae;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(ae=function(){let e=``;do e=`pane-${b.current}`,b.current+=1;while(s.current.panes.some(t=>t.id===e));return e},t[16]=ae):ae=t[16];let oe=ae,se;t[17]===I?se=t[18]:(se=function(e,t){let n=t===void 0?!1:t,r=Yp(e);if(I!==null){let t=PK(I),n=QK(e);t.setVisibleDocNames(n);for(let e of n)t.open(e);let i=ZK(r);i?(t.open(i),t.setActive(i)):t.clearActive()}if(!n)return;let i=``;r.activeNewTabId!==null||r.activeTabId!==null&&(i=WK(r.activeTabId)),GK(i)},t[17]=I,t[18]=se);let z=se,B;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(B=function(e,t){return e.focusedPaneId!==t.focusedPaneId||e.panes.length!==t.panes.length?!1:e.panes.every((e,n)=>{let r=t.panes[n];return r!==void 0&&e.id===r.id&&e.activeTabId===r.activeTabId&&e.activeNewTabId===r.activeNewTabId&&e.previewTabId===r.previewTabId&&Math.abs(e.size-r.size)<1e-9&&rq(e.activeTarget,r.activeTarget)&&e.openTabs.join(`\0`)===r.openTabs.join(`\0`)&&e.pinnedTabIds.join(`\0`)===r.pinnedTabIds.join(`\0`)&&e.newTabIds.join(`\0`)===r.newTabIds.join(`\0`)})},t[19]=B):B=t[19];let ce=B,V;t[20]===z?V=t[21]:(V=function(e,t){let n=t===void 0?!1:t,r=YK(Jp(e));if(ce(s.current,r)){z(s.current,n);return}s.current=r;let i=new Set(r.panes.map(bq));for(let e of d.current.keys())i.has(e)||d.current.delete(e);for(let e of r.panes)d.current.set(e.id,th(d.current.get(e.id)??[],e.openTabs,e.newTabIds));u(new Map(d.current)),o(e=>e===r?e:r),z(r,n)},t[20]=z,t[21]=V);let H=V,U;t[22]===H?U=t[23]:(U=function(e,t,n){let r=n===void 0?{}:n,i=s.current;if(!i.panes.some(t=>t.id===e))return;let a=tm(i,e,t);H(r.focus?{...a,focusedPaneId:e}:a,r.updateHash)},t[22]=H,t[23]=U);let W=U,le=YK(om(a,l)),G=Yp(le),ue;t[24]!==I||t[25]!==H||t[26]!==_?(ue=()=>{if(I===null||_)return;if(Os()){ks(),cf(),T.current=`suppressed`,v(!0);return}let e=!1,t=IK(),n=LK(),r=typeof localStorage<`u`?localStorage:null;return(t?t.project.getSessionState():Promise.resolve(n?fh(r,n):sh(null))).then(t=>{if(T.current=`applied`,e)return;let n=sh(t);if(w.current)return;let r=s.current,i=YK(Gp({panes:n.panes,focusedPaneId:n.focusedPaneId})),a=i.focusedPaneId;for(let e of r.panes)for(let t of e.openTabs){let n=Qp(i,t);if(n){if(!n.openTabs.includes(t)){i=tm(i,n.id,n=>({...n,openTabs:[...n.openTabs,t],pinnedTabIds:e.pinnedTabIds.includes(t)?[...n.pinnedTabIds,t]:n.pinnedTabIds}));continue}e.pinnedTabIds.includes(t)&&!n.pinnedTabIds.includes(t)&&(i=tm(i,n.id,e=>({...e,pinnedTabIds:[...e.pinnedTabIds,t]})));continue}i=tm(i,a,n=>({...n,openTabs:[...n.openTabs,t],pinnedTabIds:e.pinnedTabIds.includes(t)?[...n.pinnedTabIds,t]:n.pinnedTabIds}))}let o=Yp(r);o.newTabIds.length>0&&(i=tm(i,a,e=>({...e,newTabIds:[...new Set([...e.newTabIds,...o.newTabIds])],activeNewTabId:o.activeNewTabId,activeTabId:o.activeNewTabId?null:e.activeTabId,activeTarget:o.activeNewTabId?null:e.activeTarget}))),i=nm(i,r,n);let c=window.location.hash,l=$K(c),u=l?Qp(i,l):null;if(u&&l&&o.activeNewTabId===null){let e=Qp(r,l),t=e?.activeTabId===l?e.activeTarget:null;i={...tm(i,u.id,e=>JK({...e,activeTabId:l,activeNewTabId:null,activeTarget:t})),focusedPaneId:u.id}}let f=ia(window.location.hash),p=Yp(i).activeTabId,m=p?WK(p):null,h=p?qm(p):null,g=f===null&&window.location.hash.length===0||m!==null&&ra(m,window.location.hash)||eq(f,window.location.hash,h);i=YK(Jp(i));for(let e of i.panes)d.current.set(e.id,[...e.openTabs,...e.newTabIds]);H(i,g&&p!==null)}).catch(yq).finally(()=>{e||v(!0)}),()=>{e=!0}},t[24]=I,t[25]=H,t[26]=_,t[27]=ue):ue=t[27];let K;t[28]!==I||t[29]!==_?(K=[I,_],t[28]=I,t[29]=_,t[30]=K):K=t[30],(0,Z.useEffect)(ue,K);let de,fe;t[31]!==f.length||t[32]!==_||t[33]!==a?(de=()=>{if(!_||!Jm(T.current,f.length))return;let e=lh(a),t=IK();if(t){t.project.setSessionState(e).catch(vq);return}let n=LK();n&&ph(typeof localStorage<`u`?localStorage:null,n,e)},fe=[f.length,_,a],t[31]=f.length,t[32]=_,t[33]=a,t[34]=de,t[35]=fe):(de=t[34],fe=t[35]),(0,Z.useEffect)(de,fe);let pe;t[36]===_?pe=t[37]:(pe=function(){_||(w.current=!0)},t[36]=_,t[37]=pe);let q=pe,me;t[38]!==H||t[39]!==q?(me=function(e,t,n){let r=t===void 0?[]:t,i=n===void 0?[]:n;q();let a=t=>rh([t],e,2**53-1,r,[],i)[0]??null;for(let[t,n]of d.current)d.current.set(t,ih(n,e,r,i));let o=Yp(s.current).activeTabId,c=gm(s.current,{type:`remap-tabs`,remap:a}).workspace,l=Yp(c).activeTabId;H(c,o!==null&&o!==l)},t[38]=H,t[39]=q,t[40]=me):me=t[40];let J=me,he;t[41]===I?he=t[42]:(he=function(e,t){if(I===null)return;let n=new Set;for(let e of $p(t)){let t=qm(e);t&&n.add(t)}let r=PK(I);for(let t of e){let e=qm(t);e&&!n.has(e)&&r.close(e)}},t[41]=I,t[42]=he);let ge=he,_e;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(_e=function(e,t,n){return e.activeTabId&&t.has(e.activeTabId)?e.activeTabId:e.activeNewTabId&&t.has(e.activeNewTabId)&&e.activeNewTabId,n},t[43]=_e):_e=t[43];let ve=_e,ye;t[44]!==ge||t[45]!==H||t[46]!==q?(ye=(e,t,n)=>{let r=n===void 0?{}:n,i=s.current.panes.find(t=>t.id===e);if(!i)return;let a=new Set(r.force?t.filter(e=>i.openTabs.includes(e)):eh(t,i.pinnedTabIds).filter(e=>i.openTabs.includes(e)));if(a.size===0)return;if(q(),!r.force)for(let t of i.openTabs.filter(e=>a.has(e)))S.current=_m(S.current,{paneId:e,tabId:t},50);let o=s.current.focusedPaneId===e,c=ve(i,a,gm(s.current,{type:`close-tabs`,paneId:e,tabIds:[...a]}).workspace);ge(a,c),H(c,o)},t[44]=ge,t[45]=H,t[46]=q,t[47]=ye):ye=t[47];let be=ye,xe;t[48]===be?xe=t[49]:(xe=function(e,t){let n=t===void 0?{}:t,r=new Set(e.filter(_q));for(let e of s.current.panes.map(gq)){let t=s.current.panes.find(t=>t.id===e);if(!t)continue;let i=t.openTabs.filter(e=>r.has(e));i.length>0&&be(e,i,n)}},t[48]=be,t[49]=xe);let Se=xe,Ce;t[50]!==Se||t[51]!==I||t[52]!==H||t[53]!==J?(Ce=function(){return pf({captureRenameSnapshots:cp,getActivePoolDocName:()=>I===null?null:PK(I).getActiveDocName(),hasPooledDocument:e=>I!==null&&PK(I).has(e),closeAndClear:async e=>{I!==null&&await PK(I).closeAndClearPersistence(e)},openAndActivate:e=>{if(I===null)return;let t=PK(I);t.open(e),t.setActive(e)},remapTabs:e=>{let{renamed:t,renamedFolders:n,renamedAssets:r}=e;return J(t,n,r)},closeTabs:e=>Se(e,{force:!0}),removeDocumentTab:e=>{let t=gm(s.current,{type:`prune-tabs`,keep:t=>qm(t)!==e}).workspace;H(t)},remapActiveTargetForRename:(e,t)=>ZK(Yp(s.current))===t,clearActiveTargetForRemoval:e=>{H({...s.current,panes:s.current.panes.map(t=>t.activeTarget&&lo(t.activeTarget)===e?{...t,activeTarget:null}:t)})},navigateToDocument:hq,navigateHome:()=>{let e=Yp(s.current);GK(e.activeTabId?WK(e.activeTabId):``)},showDocumentDeletedState:mq})},t[50]=Se,t[51]=I,t[52]=H,t[53]=J,t[54]=Ce):Ce=t[54];let we=Ce,Te;t[55]===we?Te=t[56]:(Te=()=>{C.current=we()},t[55]=we,t[56]=Te),(0,Z.useEffect)(Te);let Ee;t[57]!==I||t[58]!==z?(Ee=()=>{if(I===null)return;let e=!1,t=PK(I),n=()=>{i(e=>{let n=aq(t);return iq(e,n)?e:n})};return n(),z(s.current),t.setOnBranchMismatch(()=>{let{times:e,escalate:n}=Hd(ie.current,Date.now());return ie.current=e,n&&ne({kind:`refused`,at:Date.now()}),of(t)}),t.setOnRenameRedirect(e=>{let{fromDocName:t,toDocName:n,hadOpenProvider:r}=e;(async()=>{let e;try{await KK(C.current).reconcileAuthRename({fromDocName:t,toDocName:n})}catch(r){let i=r;e=i,console.warn(JSON.stringify({event:`removal-cleanup-error`,kind:`renamed`,fromDocName:t,toDocName:n,message:String(i instanceof Error?i.message:i)}))}console.info(JSON.stringify({event:`removal.cleanup`,kind:`renamed`,fromDocName:t,toDocName:n,hadOpenProvider:r,hadStaleIdb:!r,source:`auth-rejection`,errored:e!==void 0}))})()}),t.setOnDocDeleted(e=>{let{docName:t,hadOpenProvider:n}=e;(async()=>{let e;try{await KK(C.current).reconcileAuthRemoval({docName:t})}catch(n){let r=n;e=r,console.warn(JSON.stringify({event:`removal-cleanup-error`,kind:`deleted`,docName:t,message:String(r instanceof Error?r.message:r)}))}console.info(JSON.stringify({event:`removal.cleanup`,kind:`deleted`,fromDocName:t,hadOpenProvider:n,hadStaleIdb:!n,source:`auth-rejection`,errored:e!==void 0}))})()}),t.setOnChange(n),fetch(`/api/principal`).then(pq).then(n=>{if(e)return;let r=qe.safeParse(n);r.success?(t.setTabIdentity({principalId:r.data.id,tabSessionId:OK}),D(r.data)):AK(r.error)}).catch(t=>{e||AK(t)}),of(t),()=>{e=!0,t.setOnChange(null),t.setOnRenameRedirect(null),t.setOnDocDeleted(null)}},t[57]=I,t[58]=z,t[59]=Ee):Ee=t[59];let De;t[60]===I?De=t[61]:(De=[I],t[60]=I,t[61]=De),(0,Z.useEffect)(Ee,De);let Oe=function(e,t){let n=t===void 0?!0:t,r=s.current.panes.find(t=>t.id===e);if(!r)return;let i=le.panes.find(t=>t.id===e),a=s.current;if(i?.activeTabId&&i.activeTabId!==r.activeTabId)a=gm(a,{type:`activate-tab`,paneId:e,tabId:i.activeTabId}).workspace;else if(i?.activeNewTabId&&i.activeNewTabId!==r.activeNewTabId)a=tm(a,e,e=>({...e,activeTabId:null,activeNewTabId:i.activeNewTabId,activeTarget:null}));else if(a.focusedPaneId===e)return;H(Xp({...a,panes:a.panes.map(t=>t.id===e?JK(t):t)},e),n)},ke;t[62]===H?ke=t[63]:(ke=function(e,t,n){let r=n===void 0?!0:n,i=s.current.panes.find(t=>t.id===e);i&&i.openTabs.includes(t)&&H(gm(s.current,{type:`activate-tab`,paneId:e,tabId:t}).workspace,r)},t[62]=H,t[63]=ke);let Ae=ke,Y,je,Me,Ne,Pe;if(t[64]!==ge||t[65]!==I||t[66]!==H||t[67]!==q||t[68]!==W){je=e=>{X(`ok/nav/open-document`,{docName:e,transition:!1}),Ne({kind:`doc`,target:e,docName:e},{disposition:`permanent`,consumeActiveNewTab:!0})},Me=e=>{X(`ok/nav/open-document`,{docName:e,transition:!1}),je(e)};let e;t[74]!==H||t[75]!==W?(e=function(e,t){let n=s.current.panes.find(t=>t.id===e);if(!n)return;let r=(n.activeNewTabId!==null&&HK(n.activeNewTabId)===t?n.activeNewTabId:null)??n.newTabIds.find(e=>HK(e)===t);if(r){W(n.id,e=>({...e,activeNewTabId:r,activeTabId:null,activeTarget:null}),{updateHash:!0});return}let i=`${VK[t]}${y.current}`;y.current+=1,H(gm(s.current,{type:`open-new-tab`,paneId:n.id,tabId:i}).workspace,!0)},t[74]=H,t[75]=W,t[76]=e):e=t[76],Y=e,Ne=(e,t,n,r)=>{let i=t===void 0?{}:t,a=r===void 0?`activate-owner`:r;if(I===null)return;i.deliberate!==!1&&Ga();let o=n??s.current.focusedPaneId,c=PK(I);if(e.kind===`skills`){Y(o,`files`);return}let l=lo(e),u=Gm(e);if(!u)return;if(l&&e.kind!==`large-file`){let e=c.open(l);if(!e)return;zd(l,e.poolEventId)}let d=gm(s.current,{type:`open-target`,paneId:o,tabId:u,target:e,disposition:i.disposition??(i.tabBehavior===`replace-active`?`preview`:`permanent`),consumeActiveNewTab:i.consumeActiveNewTab??!0,existingTabBehavior:a});d.replacedPreviewTabId!==null&&q();let f=d.workspace;if(e.kind===`skill-preview`&&e.level){let t=new Set(Rm($p(f),{flavor:e.flavor,name:e.name,subtitle:e.subtitle??``,level:e.level},u));if(t.size>0){q();for(let e of f.panes.map(fq)){let n=f.panes.find(t=>t.id===e);if(!n)continue;let r=n.openTabs.filter(e=>t.has(e));r.length!==0&&(f=gm(f,{type:`close-tabs`,paneId:e,tabIds:r}).workspace)}ge(t,f)}}H(f)},Pe=(e,t)=>{Ne(e,t)},t[64]=ge,t[65]=I,t[66]=H,t[67]=q,t[68]=W,t[69]=Y,t[70]=je,t[71]=Me,t[72]=Ne,t[73]=Pe}else Y=t[69],je=t[70],Me=t[71],Ne=t[72],Pe=t[73];let Fe=Pe,Ie;t[77]===Ne?Ie=t[78]:(Ie=(e,t,n)=>{Ne(t,n,e,`open-in-pane`)},t[77]=Ne,t[78]=Ie);let Le=Ie,Re;t[79]===Ne?Re=t[80]:(Re=(e,t)=>{X(`ok/nav/open-target`,{docName:lo(e),kind:e.kind,transition:!1}),Ne(e,t)},t[79]=Ne,t[80]=Re);let ze=Re,Be;t[81]===Ae?Be=t[82]:(Be=e=>Ae(s.current.focusedPaneId,e),t[81]=Ae,t[82]=Be);let Ve=Be,He;t[83]===Y?He=t[84]:(He=()=>{Ga(),Y(s.current.focusedPaneId,`blob-runner`)},t[83]=Y,t[84]=He);let Ge=He,Ke;t[85]===H?Ke=t[86]:(Ke=e=>{if(!s.current.panes.find(t=>t.id===e))return;let t=`${zK}${y.current}`;y.current+=1,H(gm(s.current,{type:`open-new-tab`,paneId:e,tabId:t}).workspace,!0)},t[85]=H,t[86]=Ke);let Je=Ke,Ye;t[87]===Je?Ye=t[88]:(Ye=()=>Je(s.current.focusedPaneId),t[87]=Je,t[88]=Ye);let Xe=Ye,Ze;t[89]===be?Ze=t[90]:(Ze=(e,t)=>be(e,[t]),t[89]=be,t[90]=Ze);let Qe=Ze,$e;t[91]===Qe?$e=t[92]:($e=e=>Qe(s.current.focusedPaneId,e),t[91]=Qe,t[92]=$e);let et=$e,tt;t[93]!==H||t[94]!==q?(tt=(e,t)=>{q();let n=s.current.panes.find(t=>t.id===e);if(!n?.newTabIds.includes(t))return;let r=n.activeNewTabId===t,i=gm(s.current,{type:`close-tabs`,paneId:e,tabIds:[t]}).workspace;H(i,s.current.focusedPaneId===e&&r)},t[93]=H,t[94]=q,t[95]=tt):tt=t[95];let nt=tt,rt;t[96]===nt?rt=t[97]:(rt=e=>nt(s.current.focusedPaneId,e),t[96]=nt,t[97]=rt);let it=rt,at;t[98]!==nt||t[99]!==Qe?(at=()=>{let e=Yp(s.current),t=e.activeNewTabId;if(t)return nt(e.id,t),!0;let n=new Set(e.pinnedTabIds),r=new Set(e.openTabs.filter(e=>!n.has(e))),i=e.activeTabId&&r.has(e.activeTabId)?e.activeTabId:null,a=d.current.get(e.id)??[],o=i??a.find(e=>r.has(e));if(o)return Qe(e.id,o),!0;let c=new Set(e.newTabIds),l=a.find(e=>c.has(e));if(l)return nt(e.id,l),!0;let u=s.current.panes.find(dq);if(!u)return!1;let f=u.activeNewTabId??u.newTabIds[0]??null;if(f)return nt(u.id,f),!0;let p=(u.activeTabId&&!u.pinnedTabIds.includes(u.activeTabId)?u.activeTabId:null)??u.openTabs.find(e=>!u.pinnedTabIds.includes(e));return p?(Qe(u.id,p),!0):!1},t[98]=nt,t[99]=Qe,t[100]=at):at=t[100];let ot=at,st;t[101]===H?st=t[102]:(st=function(e,t){s.current.panes.find(t=>t.id===e)?.newTabIds.includes(t)&&H(gm(s.current,{type:`activate-tab`,paneId:e,tabId:t}).workspace,!0)},t[101]=H,t[102]=st);let ct=st,lt;t[103]===H?lt=t[104]:(lt=function(e,t){s.current.panes.find(t=>t.id===e)?.openTabs.includes(t)&&H(gm(s.current,{type:`pin-tab`,paneId:e,tabId:t}).workspace)},t[103]=H,t[104]=lt);let ut=lt,ft;t[105]!==H||t[106]!==q?(ft=function(e,t){s.current.panes.find(t=>t.id===e)?.pinnedTabIds.includes(t)&&(q(),H(gm(s.current,{type:`unpin-tab`,paneId:e,tabId:t}).workspace))},t[105]=H,t[106]=q,t[107]=ft):ft=t[107];let pt=ft,mt;t[108]===H?mt=t[109]:(mt=function(e,t,n){let r=s.current.panes.find(t=>t.id===e);if(!r)return;let i=new Set([...r.openTabs,...r.newTabIds]),a=t.filter(e=>i.has(e));for(let e of[...r.openTabs,...r.newTabIds])a.includes(e)||a.push(e);d.current.set(e,a),u(new Map(d.current));let o=a.filter(e=>r.openTabs.includes(e)),c=a.filter(e=>r.newTabIds.includes(e)),l=gm(s.current,{type:`reorder-tabs`,paneId:e,tabIds:o,draggedTabId:n}).workspace;H({...l,panes:l.panes.map(t=>t.id===e?{...t,newTabIds:c}:t)})},t[108]=H,t[109]=mt);let ht=mt,gt;t[110]===H?gt=t[111]:(gt=function(e,t,n){let r=s.current.panes.find(t=>t.openTabs.includes(e)||t.newTabIds.includes(e)),i=s.current.panes.find(e=>e.id===t);if(!r||!i)return;let a=th(d.current.get(t)??[],i.openTabs,i.newTabIds).filter(t=>t!==e),o=Math.max(0,Math.min(n,a.length)),c=sm(a,r.newTabIds.includes(e)?i.newTabIds:i.openTabs,o),l=gm(s.current,{type:`move-tab`,tabId:e,paneId:t,index:c}).workspace;r.id!==t&&(d.current.set(r.id,th(d.current.get(r.id)??[],r.openTabs,r.newTabIds).filter(t=>t!==e)),a.splice(o,0,e),d.current.set(t,a)),H(l,!0)},t[110]=H,t[111]=gt);let _t=gt,vt;t[112]===H?vt=t[113]:(vt=function(e,t,n){let r=s.current.panes.find(t=>t.openTabs.includes(e)||t.newTabIds.includes(e));if(!r)return null;let i=oe(),a=gm(s.current,{type:`split-tab`,tabId:e,paneId:t,side:n,newPaneId:i}).workspace,o=a.panes.find(e=>e.id===i);return o?(d.current.set(r.id,th(d.current.get(r.id)??[],r.openTabs,r.newTabIds).filter(t=>t!==e)),d.current.set(o.id,[e]),H(a,!0),o.id):null},t[112]=H,t[113]=vt);let yt=vt,bt;t[114]===yt?bt=t[115]:(bt=function(e,t){let n=Qp(s.current,e);return n?yt(e,n.id,t):null},t[114]=yt,t[115]=bt);let xt=bt,St;t[116]===H?St=t[117]:(St=function(e){e.size!==0&&H(gm(s.current,{type:`resize-panes`,sizes:s.current.panes.map(t=>e.get(t.id)??t.size)}).workspace)},t[116]=H,t[117]=St);let Ct=St,wt;t[118]===H?wt=t[119]:(wt=function(e,t){H(gm(s.current,{type:`promote-preview`,paneId:e,tabId:t}).workspace)},t[118]=H,t[119]=wt);let Tt=wt,Et;t[120]===H?Et=t[121]:(Et=function(){H(gm(s.current,{type:`promote-all-previews`}).workspace)},t[120]=H,t[121]=Et);let Dt=Et,Ot;t[122]===Tt?Ot=t[123]:(Ot=function(e){let t=Qp(s.current,e);!t||t.previewTabId!==e||Tt(t.id,e)},t[122]=Tt,t[123]=Ot);let kt=Ot,At,jt;t[124]===kt?(At=t[125],jt=t[126]):(At=()=>hh(kt),jt=[kt],t[124]=kt,t[125]=At,t[126]=jt),(0,Z.useEffect)(At,jt);let Mt,Nt;t[127]===ot?(Mt=t[128],Nt=t[129]):(Mt=()=>dt(e=>{e===`close-active-tab-or-window`&&(Wa(),ot()||window.close())}),Nt=[ot],t[127]=ot,t[128]=Mt,t[129]=Nt),(0,Z.useEffect)(Mt,Nt);let Pt=ZK(G),Ft;t[130]!==Pt||t[131]!==r.activeDocName||t[132]!==r.activeProvider||t[133]!==r.poolEntries?(Ft=r.activeDocName===Pt?r.activeProvider:r.poolEntries.find(e=>e.docName===Pt)?.provider??null,t[130]=Pt,t[131]=r.activeDocName,t[132]=r.activeProvider,t[133]=r.poolEntries,t[134]=Ft):Ft=t[134];let It=Ft,Lt;t[135]===Y?Lt=t[136]:(Lt=()=>{let e=Yp(s.current);e.activeNewTabId===null&&(e.openTabs.length===0&&e.newTabIds.length===0||Y(e.id,`files`))},t[135]=Y,t[136]=Lt);let Rt;t[137]!==I||t[138]!==H||t[139]!==q?(Rt=e=>{q();let t=ZK(Yp(s.current))===e,n=gm(s.current,{type:`prune-tabs`,keep:t=>qm(t)!==e}).workspace;I!==null&&PK(I).close(e),H(n,t)},t[137]=I,t[138]=H,t[139]=q,t[140]=Rt):Rt=t[140];let zt;t[141]===ut?zt=t[142]:(zt=e=>ut(s.current.focusedPaneId,e),t[141]=ut,t[142]=zt);let Bt;t[143]===pt?Bt=t[144]:(Bt=e=>pt(s.current.focusedPaneId,e),t[143]=pt,t[144]=Bt);let Vt;t[145]===ht?Vt=t[146]:(Vt=(e,t)=>ht(s.current.focusedPaneId,e,t),t[145]=ht,t[146]=Vt);let Ht=G.activeNewTabId!==null,Ut;t[147]===ct?Ut=t[148]:(Ut=e=>ct(s.current.focusedPaneId,e),t[147]=ct,t[148]=Ut);let Wt;t[149]===H?Wt=t[150]:(Wt=()=>{let e=[...S.current];for(;e.length>0;){let t=e.shift();if(!t)continue;if(Qp(s.current,t.tabId)){S.current=e;continue}let n=s.current.panes.find(e=>e.id===t.paneId)??Yp(s.current);S.current=e;let r=qK(t.tabId);H(gm(s.current,{type:`open-target`,paneId:n.id,tabId:t.tabId,target:r,disposition:`permanent`,consumeActiveNewTab:!1}).workspace,!0);return}S.current=[]},t[149]=H,t[150]=Wt);let Gt;t[151]!==ge||t[152]!==H||t[153]!==q?(Gt=e=>{let{pages:t,folderPaths:n,assetPaths:r,filePaths:i}=e,a=new Set(s.current.panes.flatMap(uq)),o=typeof window<`u`?ia(window.location.hash):null,c=new Set(s.current.panes.flatMap(lq)),l=$p(s.current),u=nh(l,{pages:new Set([...t,...a]),folderPaths:n,assetPaths:r,filePaths:i,keepMissingDocName:null,keepHashDocName:o,keepFolderPaths:c});if(u.length===l.length)return;let d=new Set(u),f=l.filter(e=>!d.has(e));q();let p=Yp(s.current).activeTabId,m=p!==null&&!d.has(p),h=gm(s.current,{type:`prune-tabs`,keep:e=>d.has(e)}).workspace;ge(f,h),H(h,m)},t[151]=ge,t[152]=H,t[153]=q,t[154]=Gt):Gt=t[154];let Kt,qt;t[155]===we?(Kt=t[156],qt=t[157]):(Kt=e=>we().reconcileLocalRename(e),qt=e=>we().reconcileLocalRemoval(e),t[155]=we,t[156]=Kt,t[157]=qt);let Jt,Yt;t[158]===I?(Jt=t[159],Yt=t[160]):(Jt=e=>{I!==null&&PK(I).recycle(e)},Yt=e=>I===null?null:PK(I).prewarm(e)?.poolEventId??null,t[158]=I,t[159]=Jt,t[160]=Yt);let Xt,Zt,Qt,$t,en;t[161]===I?(Xt=t[162],Zt=t[163],Qt=t[164],$t=t[165],en=t[166]):(Xt=e=>{I!==null&&PK(I).setExpectedServerInstanceId(e)},Zt=async e=>{if(I===null)return;let t=PK(I);t.setObservedBranch(e),ie.current=[],ne({kind:`branch-switch`,branch:e,at:Date.now()}),await Xd(t,e),We([`files`,`backlinks`,`graph`]),Ue(e)},Qt=async e=>{if(I===null)return;let t=PK(I);t.compareAndUpdateObservedBranch(e)&&(ie.current=[],ne({kind:`branch-switch`,branch:e,at:Date.now()}),await Xd(t,e),We([`files`,`backlinks`,`graph`]),Ue(e))},$t=(e,t)=>{I!==null&&PK(I).observeDiskAck(e,t)},en=async()=>{I!==null&&await of(PK(I))},t[161]=I,t[162]=Xt,t[163]=Zt,t[164]=Qt,t[165]=$t,t[166]=en);let tn;t[167]===Symbol.for(`react.memo_cache_sentinel`)?(tn=()=>ne(null),t[167]=tn):tn=t[167];let nn;t[168]!==Pt||t[169]!==M||t[170]!==A?(nn=(e,t)=>{if(!Pt&&t){GK(pa(t)),N(e),j(`agent`),F(cq);return}if(A===`agent`&&M===e&&Md()){j(`doc`);return}N(e),j(`agent`),F(sq)},t[168]=Pt,t[169]=M,t[170]=A,t[171]=nn):nn=t[171];let rn;t[172]===Symbol.for(`react.memo_cache_sentinel`)?(rn=()=>{j(`doc`),N(null)},t[172]=rn):rn=t[172];let an;t[173]!==ct||t[174]!==Ve||t[175]!==Ae||t[176]!==Pt||t[177]!==It||t[178]!==ot||t[179]!==it||t[180]!==nt||t[181]!==et||t[182]!==Qe||t[183]!==Se||t[184]!==be||t[185]!==ee||t[186]!==L||t[187]!==I||t[188]!==te||t[189]!==M||t[190]!==P||t[191]!==A||t[192]!==Oe||t[193]!==xt||t[194]!==_t||t[195]!==Ge||t[196]!==je||t[197]!==Me||t[198]!==Xe||t[199]!==Je||t[200]!==f||t[201]!==Fe||t[202]!==Le||t[203]!==ze||t[204]!==ut||t[205]!==p||t[206]!==m||t[207]!==E||t[208]!==Dt||t[209]!==Tt||t[210]!==ht||t[211]!==Ct||t[212]!==R||t[213]!==r.poolEntries||t[214]!==r.serverRestartRecovery||t[215]!==r.syncState||t[216]!==yt||t[217]!==G.activeNewTabId||t[218]!==G.activeTabId||t[219]!==G.activeTarget||t[220]!==G.newTabIds||t[221]!==le.focusedPaneId||t[222]!==le.panes||t[223]!==O||t[224]!==Lt||t[225]!==Rt||t[226]!==zt||t[227]!==Bt||t[228]!==Vt||t[229]!==Ht||t[230]!==Ut||t[231]!==Wt||t[232]!==Gt||t[233]!==Kt||t[234]!==qt||t[235]!==Jt||t[236]!==Yt||t[237]!==Xt||t[238]!==Zt||t[239]!==Qt||t[240]!==$t||t[241]!==en||t[242]!==nn||t[243]!==_||t[244]!==pt||t[245]!==g||t[246]!==l||t[247]!==a?(an={principal:E,activeTarget:G.activeTarget,activeTabId:G.activeTabId,activeDocName:Pt,activeProvider:It,workspace:a,panes:le.panes,focusedPaneId:le.focusedPaneId,focusPane:Oe,activateTabInPane:Ae,activateNewTabInPane:ct,openNewTabInPane:Je,closeTabInPane:Qe,closeTabsInPane:be,closeNewTabInPane:nt,pinTabInPane:ut,unpinTabInPane:pt,reorderTabsInPane:ht,moveTabToPane:_t,splitTab:yt,moveTabToNewPane:xt,resizePanes:Ct,openTabs:f,pinnedTabIds:p,visibleTabIdsByPane:l,previewTabIdsByPane:m,visibleTabIds:g,tabSessionLoaded:_,syncState:r.syncState,serverRestartRecovery:r.serverRestartRecovery,poolEntries:r.poolEntries,openDocument:je,openDocumentTransition:Me,openTarget:Fe,openTargetInPane:Le,openTargetTransition:ze,promoteTabInPane:Tt,promoteAllPreviewTabs:Dt,clearTarget:Lt,closeDocument:Rt,closeActiveTabOrWindow:ot,closeTab:et,pinTab:zt,unpinTab:Bt,activateTab:Ve,reorderTabs:Vt,newTabIds:G.newTabIds,activeNewTabId:G.activeNewTabId,isNewTabActive:Ht,openNewTab:Xe,openBlobRunner:Ge,activateNewTab:Ut,closeNewTab:it,reopenClosedTab:Wt,closeTabs:Se,syncOpenTabsWithKnownTargets:Gt,reconcileLocalRename:Kt,reconcileLocalRemoval:qt,recycleDocument:Jt,prewarm:Yt,systemProvider:O,setSystemProvider:k,updateServerInstanceId:Xt,onBranchSwitched:Zt,observeBranch:Qt,observeDiskAck:$t,refreshServerInfo:en,collabUrl:I,collabTerminal:L,contentRecycleNotice:te,dismissContentRecycleNotice:tn,collabLastError:ee,retryCollab:R,docPanelMode:A,docPanelAgentId:M,docPanelExpandSignal:P,openActivityPanel:nn,closeActivityPanel:rn},t[173]=ct,t[174]=Ve,t[175]=Ae,t[176]=Pt,t[177]=It,t[178]=ot,t[179]=it,t[180]=nt,t[181]=et,t[182]=Qe,t[183]=Se,t[184]=be,t[185]=ee,t[186]=L,t[187]=I,t[188]=te,t[189]=M,t[190]=P,t[191]=A,t[192]=Oe,t[193]=xt,t[194]=_t,t[195]=Ge,t[196]=je,t[197]=Me,t[198]=Xe,t[199]=Je,t[200]=f,t[201]=Fe,t[202]=Le,t[203]=ze,t[204]=ut,t[205]=p,t[206]=m,t[207]=E,t[208]=Dt,t[209]=Tt,t[210]=ht,t[211]=Ct,t[212]=R,t[213]=r.poolEntries,t[214]=r.serverRestartRecovery,t[215]=r.syncState,t[216]=yt,t[217]=G.activeNewTabId,t[218]=G.activeTabId,t[219]=G.activeTarget,t[220]=G.newTabIds,t[221]=le.focusedPaneId,t[222]=le.panes,t[223]=O,t[224]=Lt,t[225]=Rt,t[226]=zt,t[227]=Bt,t[228]=Vt,t[229]=Ht,t[230]=Ut,t[231]=Wt,t[232]=Gt,t[233]=Kt,t[234]=qt,t[235]=Jt,t[236]=Yt,t[237]=Xt,t[238]=Zt,t[239]=Qt,t[240]=$t,t[241]=en,t[242]=nn,t[243]=_,t[244]=pt,t[245]=g,t[246]=l,t[247]=a,t[248]=an):an=t[248];let on=an,sn;return t[249]!==n||t[250]!==on?(sn=(0,$.jsx)(jK,{value:on,children:n}),t[249]=n,t[250]=on,t[251]=sn):sn=t[251],sn}function sq(e){return e+1}function cq(e){return e+1}function lq(e){return e.activeTarget?.kind===`folder`?[e.activeTarget.folderPath]:[]}function uq(e){return e.activeTarget?.kind===`missing`?[e.activeTarget.target]:[]}function dq(e){return e.newTabIds.length>0||e.openTabs.some(t=>!e.pinnedTabIds.includes(t))}function fq(e){return e.id}function pq(e){return e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))}function mq(e){return ct()?qd(e):!1}function hq(e){return GK(pa(e))}function gq(e){return e.id}function _q(e){return e.length>0}function vq(e){console.warn(`[editor-tabs] failed to persist tab session:`,e)}function yq(e){console.error(`[editor-tabs] failed to restore tab session:`,e)}function bq(e){return e.id}function xq(e){return[e.id,e.previewTabId]}function Sq(e){return[e.id,[...e.openTabs,...e.newTabIds]]}function Cq(){return(0,Z.use)(jK)?.openBlobRunner??null}function wq(){let e=(0,Z.use)(jK);if(!e)throw Error(`useDocumentContext must be used within <DocumentProvider />`);return e}function Tq(){let e=(0,Q.c)(3),{openDocumentTransition:t,openTargetTransition:n}=wq(),r;return e[0]!==t||e[1]!==n?(r={openDocumentTransition:t,openTargetTransition:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],r}export{Xz as $,df as $n,Yl as $r,JC as $t,cU as A,Ml as Ai,zm as An,Gu as Ar,wN as At,JB as B,cc as Bi,gp as Bn,yu as Br,rO as Bt,DW as C,Kc as Ci,_h as Cn,td as Cr,eI as Ct,EU as D,El as Di,qm as Dn,Uu as Dr,vP as Dt,fW as E,Nc as Ei,Um as En,Zu as Er,jP as Et,FH as F,Dl as Fi,ah as Fn,ku as Fr,eO as Ft,OB as G,As as Gi,Df as Gn,uu as Gr,$C as Gt,MB as H,Ps as Hi,mp as Hn,hu as Hr,Lw as Ht,jH as I,el as Ii,Gm as In,Ou as Ir,tO as It,wB as J,Bf as Jn,iu as Jr,ew as Jt,xB as K,Ds as Ki,Hf as Kn,lu as Kr,aw as Kt,AH as L,sc as Li,Wm as Ln,Du as Lr,QD as Lt,uU as M,ol as Mi,Zm as Mn,Iu as Mr,aO as Mt,oU as N,Lc as Ni,Ym as Nn,Lu as Nr,XD as Nt,nU as O,Pl as Oi,Vm as On,Wu as Or,VN as Ot,aU as P,Pc as Pi,Km as Pn,Au as Pr,ZD as Pt,pB as Q,gf as Qn,Ql as Qr,KC as Qt,_H as R,lc as Ri,np as Rn,Cu as Rr,nO as Rt,JW as S,Wc as Si,yh as Sn,Qu as Sr,FI as St,dW as T,sl as Ti,vh as Tn,Xu as Tr,MP as Tt,KB as U,Vs as Ui,tp as Un,fu as Ur,Cw as Ut,UB as V,Bs as Vi,_p as Vn,_u as Vr,iO as Vt,qB as W,Hs as Wi,Ep as Wn,du as Wr,gw as Wt,CB as X,_f as Xn,tu as Xr,HC as Xt,yB as Y,Nf as Yn,nu as Yr,YC as Yt,vB as Z,hf as Zn,eu as Zr,ZC as Zt,TG as _,$c as _i,a_ as _n,nd as _r,rL as _t,Tq as a,Ll as ai,EC as an,Ud as ar,aR as at,YW as b,Mc as bi,bg as bn,rd as br,zI as bt,GG as c,Bc as ci,xb as cn,pd as cr,iR as ct,KG as d,Uc as di,Xv as dn,yd as dr,nR as dt,ql as ei,GC as en,rf as er,Qz as et,HG as f,gl as fi,Nv as fn,dd as fr,$L as ft,DG as g,Al as gi,P_ as gn,cd as gr,aL as gt,oK as h,Cl as hi,ev as hn,vd as hr,iL as ht,wq as i,zl as ii,IC as in,Bd as ir,oR as it,iU as j,Il as ji,Hm as jn,Hu as jr,LN as jt,lU as k,_l as ki,eh as kn,Vu as kr,NN as kt,WG as l,Gc as li,gb as ln,Od as lr,rR as lt,nK as m,Fl as mi,nv as mn,ld as mr,JL as mt,PK as n,Hl as ni,QC as nn,Jd as nr,Yz as nt,Cq as o,Tl as oi,ZS as on,Rd as or,mR as ot,sK as p,jl as pi,Ov as pn,kd as pr,qL as pt,bB as q,Vf as qn,cu as qr,tw as qt,UK as r,Vl as ri,LC as rn,Yd as rr,kR as rt,wK as s,Vc as si,Cx as sn,jd as sr,fR as st,oq as t,Kl as ti,WC as tn,nf as tr,Zz as tt,UG as u,ll as ui,lb as un,fd as ur,pR as ut,ZW as v,nl as vi,Yg as vn,$u as vr,eL as vt,OW as w,wl as wi,gh as wn,id as wr,eF as wt,QW as x,Ec as xi,bh as xn,sd as xr,VI as xt,XW as y,zc as yi,Xg as yn,od as yr,nL as yt,FV as z,uc as zi,ap as zn,xu as zr,$D as zt};
|