@inkeep/open-knowledge 0.86.13-beta.11 → 0.86.13-beta.12
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.mjs +6 -6
- package/dist/{constants-CEoiyxho.mjs → constants-lgAziYdA.mjs} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/init-BkJRnB38.mjs +1 -0
- package/dist/{init-9x_qc-tR.mjs → init-cLsVOMGp.mjs} +2 -2
- package/dist/{launch-json-removal-B2vDaDt_.mjs → launch-json-removal-CN1CHgue.mjs} +1 -1
- package/dist/loader-CPOmChym.mjs +1 -0
- package/dist/{loader-BEslh4cv.mjs → loader-Du9EUjvS.mjs} +1 -1
- package/dist/preview-Bx9qkaKf.mjs +1 -0
- package/dist/{preview-BninuqY_.mjs → preview-TPjat07q.mjs} +1 -1
- package/dist/public/assets/{AccountSection-DO3DBqb4.js → AccountSection-DkNM-aaM.js} +1 -1
- package/dist/public/assets/{ActivityModeContent-DVcVnWup.js → ActivityModeContent-Cz9Cmowv.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-x3CCcV25.js → AddPropertiesButton-D6KoQYQE.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-BgdvjgxQ.js → AgentDiffPane-BTmo_vE5.js} +1 -1
- package/dist/public/assets/{AttachmentsSection-CufomXzr.js → AttachmentsSection-BIAEmImw.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-Da6_AQHV.js → CodeMirrorPropInput-Cb0qKX2H.js} +2 -2
- package/dist/public/assets/{ContentRulesSection-BQRSKiuo.js → ContentRulesSection-BHp_wZCB.js} +1 -1
- package/dist/public/assets/DocumentContext-quy6vWUt.js +108 -0
- package/dist/public/assets/{EditorModeToggle-gpQwEdA5.js → EditorModeToggle-DdtUpmIe.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-D7Ef2U4o.js → ExcalidrawDocEditor-CtYrgqrg.js} +1 -1
- package/dist/public/assets/FeedbackForm-DLLqiHqI.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-DzI8QQDd.js → ImportSkillDialog-kYtjXTYj.js} +1 -1
- package/dist/public/assets/{LinkPreviewsSection-C6SHbFZE.js → LinkPreviewsSection-BB1bjNg_.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-BWNIXPKR.js → LintConfigEditor-B0L5rUzm.js} +1 -1
- package/dist/public/assets/{LintingSection-C3n9cIKZ.js → LintingSection-Cp1X5inf.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-DwQ_rX0c.js → ManagedArtifactProperties-BJZH6nDl.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-FyrkWzBk.js +1 -0
- package/dist/public/assets/{MermaidDocEditor-Bjmvt4LR.js → MermaidDocEditor-YIXLKQfo.js} +1 -1
- package/dist/public/assets/{NetworkAccessSection-Di6RJtDW.js → NetworkAccessSection-Da92wrve.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-BBhbNlQv.js → PropertyDisplayRow-ClnrK420.js} +1 -1
- package/dist/public/assets/{PublishToGitHubDialog-9Ib-YV9D.js → PublishToGitHubDialog-D4r8iRIM.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-Cje7CnxT.js → SchemaConfigEditor-asdMFShP.js} +1 -1
- package/dist/public/assets/{SearchSection-rfAZaOMJ.js → SearchSection-tlJeLCrv.js} +1 -1
- package/dist/public/assets/{SessionsHost-DpeAIl8Y.js → SessionsHost-CgCN1gRH.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-BMUec7wf.js → SettingsDialogBody-BHz_4a8o.js} +2 -2
- package/dist/public/assets/{ShareReceiveMissDialog-DJQuQnlJ.js → ShareReceiveMissDialog-klxlJzHP.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-DDGPrIwI.js → SkillToolbarControls-B_2irbtq.js} +1 -1
- package/dist/public/assets/{SourceEditor-BOd0KWEY.js → SourceEditor-B9jPdpu5.js} +1 -1
- package/dist/public/assets/{SyncSection-Xctto3fH.js → SyncSection-DydtYVIG.js} +1 -1
- package/dist/public/assets/{SyncStatusBadge-BtctkbGv.js → SyncStatusBadge-CNGrCDAE.js} +1 -1
- package/dist/public/assets/{TerminalSection-DaHUqAa4.js → TerminalSection-C1eHc1i7.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-Clq5VlQu.js → TerminalWindowApp-CiDlz-Ud.js} +1 -1
- package/dist/public/assets/{TextDocEditor-Cl8TCL0G.js → TextDocEditor-C4fsSdta.js} +1 -1
- package/dist/public/assets/{ThreadView-tpJS-2lg.js → ThreadView-NsjJBfHS.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-CvUV034M.js → TimelineDiffPane-csNGBZSW.js} +1 -1
- package/dist/public/assets/{client-version-EwtnMMsb.js → client-version-COAujf9p.js} +1 -1
- package/dist/public/assets/{comment-chips-C_EDZ-Hu.js → comment-chips-Dpwh4USo.js} +1 -1
- package/dist/public/assets/{config-provider-Doz2nQY6.js → config-provider-CogbMSvj.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-DhbSzF-G.js → doc-undo-manager-Bqo4zf83.js} +1 -1
- package/dist/public/assets/globals-CoB8ny3x.css +1 -0
- package/dist/public/assets/index-B2jMcsUA.js +2205 -0
- package/dist/public/assets/{lint-plugins-FU3d3PgN.js → lint-plugins-21YnDuGP.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-B0ssohqH.js → pending-receive-nav-store-CpSN4HBn.js} +1 -1
- package/dist/public/assets/{preferred-session-events-BPNtM2jo.js → preferred-session-events-DLC-rarq.js} +1 -1
- package/dist/public/assets/progress-Bt7UMtSN.js +10 -0
- package/dist/public/assets/{selection-context-Bn3EHA-u.js → selection-context-D7XIW34q.js} +1 -1
- package/dist/public/assets/{src-ChMmMQlB.js → src-D-d779sD.js} +1 -1
- package/dist/public/assets/{telemetry-impl-p_H1XvkI.js → telemetry-impl-D2OTUygc.js} +1 -1
- package/dist/public/assets/{telemetry-startup-BnQlqHJN.js → telemetry-startup-DeW1YLJb.js} +1 -1
- package/dist/public/assets/typing-burst-detector-CyrCfMRK.js +8 -0
- package/dist/public/assets/{uninstall-BNoyrj3Z.js → uninstall-B2fm_4nD.js} +1 -1
- package/dist/public/assets/{use-activity-panel-BD4h4iHm.js → use-activity-panel-DPGRlmhU.js} +1 -1
- package/dist/public/assets/{use-open-skill-DCkuVw_B.js → use-open-skill-CE_m88gf.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-B9d72X5i.js → use-terminal-enabled-OJQP8BOu.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-c02j5xr8.js → use-timeline-entry-diff-DLGmI-9t.js} +2 -2
- package/dist/public/index.html +20 -20
- package/dist/public/uninstall.html +3 -3
- package/dist/{registry-probes-Co_1kYVf.mjs → registry-probes-C6-7mNBK.mjs} +1 -1
- package/dist/{removal-file-path-KqIoo950.mjs → removal-file-path-DGHqE3V9.mjs} +1 -1
- package/dist/{repair-launch-json-DvGpPWHI.mjs → repair-launch-json-Df4heHjd.mjs} +1 -1
- package/dist/{repair-mcp-configs-Bnjo-Iln.mjs → repair-mcp-configs-BxNlmyXQ.mjs} +1 -1
- package/dist/{src-D-eiuuGk.mjs → src-CB2AxHE5.mjs} +1 -1
- package/dist/src-D6R5qRPv.mjs +1 -0
- package/dist/start-BpsPEUY2.mjs +1 -0
- package/dist/{start-CO2RC5j3.mjs → start-DP79VDPx.mjs} +2 -2
- package/package.json +4 -4
- package/dist/init-Dj0qWweG.mjs +0 -1
- package/dist/loader-CnJTppTU.mjs +0 -1
- package/dist/preview-DWnBzsSh.mjs +0 -1
- package/dist/public/assets/DocumentContext-D6OQAYyD.js +0 -108
- package/dist/public/assets/FeedbackForm-fr54jJxs.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-M6uLTHrG.js +0 -1
- package/dist/public/assets/globals-G6Xf2xYI.css +0 -1
- package/dist/public/assets/index---1MtPpY.js +0 -2205
- package/dist/public/assets/progress-CU7CUjkj.js +0 -10
- package/dist/public/assets/typing-burst-detector-DOHFapOU.js +0 -8
- package/dist/src-BaEuR3BM.mjs +0 -1
- package/dist/start-DnpfsUVL.mjs +0 -1
- /package/dist/public/assets/{globals-aghZx9Sb.js → globals-DOAk0eiA.js} +0 -0
package/dist/public/assets/{CodeMirrorPropInput-Da6_AQHV.js → CodeMirrorPropInput-Cb0qKX2H.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./dist-D5mDCusD.js","./chunk-CYidjpOJ.js","./dist-D2SphF3p.js","./w3c-keyname-C7Rznu6R.js","./dist-BxTTaZ5o.js","./dist-BkE9d74i.js","./dist-ohUCMPnT.js","./dist-DKYEqMZn.js","./dist-BIxJch_-.js","./stex-CUzil_LB.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./preload-helper-Chd9yIcd.js";import{t as n}from"./jsx-runtime-BUgB2tll.js";import{t as r}from"./react-f2sANaYj.js";import{r as i}from"./dist-Nvb76hAm.js";import{n as a}from"./dist-PQ5KMVDh.js";import{t as o}from"./react-dom-DPxgxlDT.js";import{t as s}from"./compiler-runtime-BfE3aGVn.js";import{n as c,t as l}from"./with-selector-zVo3Fruj.js";import{a as u,d,i as f,l as p,r as m,u as h}from"./floating-ui.dom-DkPPH5vF.js";import{a as g,d as _,g as v,i as y,l as b,n as x,o as S,r as C,t as w,u as T}from"./constants-upload-CVKO8P4d.js";import{$ as ee,A as E,B as te,C as ne,F as re,G as ie,K as D,L as O,N as ae,P as oe,Q as se,R as ce,S as le,T as ue,U as de,V as fe,W as pe,X as me,Y as he,_ as ge,a as _e,at as k,b as ve,bt as A,c as ye,ct as j,d as be,et as xe,f as Se,g as Ce,gt as we,h as Te,ht as Ee,it as M,k as N,l as De,mt as Oe,n as P,nt as ke,o as F,ot as Ae,p as je,q as Me,r as Ne,rt as Pe,s as Fe,st as Ie,t as Le,tt as Re,u as ze,ut as Be,v as Ve,vt as I,w as He,x as Ue,y as We,z as L}from"./dist-Dc8tD1th.js";import{t as Ge}from"./dist-C_FzPxEX2.js";import{t as Ke}from"./util-doc-name-DRKmy6g9.js";import{n as qe}from"./_envelope-q8XHEv4O-C-Qnl5Tu.js";import{C as Je,a as Ye,g as Xe,w as Ze}from"./schemas-api-CD98jV86.js";import{t as Qe}from"./note-window-mode-CI3Yju9B.js";import{i as $e}from"./use-apply-config-theme-CYFG76sS.js";import{t as et}from"./createLucideIcon-DdBzwsHe.js";import{t as tt}from"./folder-open-COGOeTzI.js";import{t as nt}from"./trash-2-CchZ0T47.js";import{n as rt,r as it}from"./structural-freshness-CIbkMFA3-CWi_lyiW.js";import{c as at,d as ot,l as st}from"./doc-hash-BJkweiX9.js";import{_ as ct,b as lt,d as ut,f as dt,g as ft,h as pt,j as mt,k as ht,o as gt,p as _t,v as vt,w as yt,x as bt}from"./navigation-targets-pcYc32Il.js";import{t as xt}from"./doc-paths-cEiFVCxr.js";import{$ as St,A as Ct,B as wt,C as Tt,E as Et,G as Dt,I as Ot,J as kt,K as At,M as jt,N as Mt,P as Nt,Q as Pt,R as Ft,S as It,T as Lt,W as Rt,X as zt,_ as Bt,at as Vt,b as Ht,c as Ut,d as Wt,et as Gt,f as Kt,g as qt,h as Jt,it as Yt,j as Xt,l as Zt,m as Qt,nt as $t,ot as en,p as tn,q as nn,s as rn,tt as an,u as on,w as sn,x as cn,y as ln,z as un}from"./config-provider-Doz2nQY6.js";import{At as dn,Ct as fn,E as pn,F as mn,G as hn,I as R,J as gn,K as _n,M as vn,Mt as yn,Nt as bn,P as z,Tt as xn,X as Sn,a as B,c as Cn,f as wn,l as Tn,lt as En,o as Dn,r as On,t as kn,ut as An}from"./dist-D2SphF3p.js";import{c as jn,d as Mn,f as V,l as Nn,n as Pn,p as Fn,r as In,s as Ln,t as Rn,u as zn}from"./cm-theme-DsKCc8Du.js";import{A as Bn,C as Vn,E as Hn,H as Un,I as Wn,L as Gn,M as Kn,N as qn,O as Jn,P as Yn,R as H,S as Xn,T as Zn,_ as Qn,a as $n,b as er,c as tr,h as nr,k as rr,m as ir,o as ar,t as or,x as sr,y as cr,z as lr}from"./lib-CY2yz3tg.js";import{t as ur}from"./ccount-Cc4-GkFF.js";import{n as dr,r as fr}from"./lib-D0X048Zn.js";import{c as pr,f as mr,n as hr,r as gr,t as _r,u as vr}from"./trim-lines-DUSR4OI1.js";import{u as yr}from"./space-separated-tokens-B5lqTxi5.js";import{n as br,t as xr}from"./syntax-sfl_d8Li.js";import{i as Sr,n as Cr}from"./page-list-cache-C-bM1SMu.js";import{t as wr}from"./documents-fetch-Y7Dt9_Tn.js";import{i as Tr,n as Er,r as Dr,t as Or}from"./dist-DseqKdAU.js";import{n as kr,r as Ar,t as jr}from"./dist-BxTTaZ5o.js";import{t as Mr}from"./dist-CjyZozAk.js";import{n as Nr}from"./dist-C2Kstufe.js";import{n as Pr}from"./dist-BvhrN0Uj.js";import{n as Fr}from"./dist-D5mDCusD.js";import{i as Ir,n as Lr,r as Rr}from"./dist-BpU-J2LR.js";import{n as zr}from"./dist-BkE9d74i.js";import{t as Br}from"./stex-CUzil_LB.js";import{n as Vr,r as Hr}from"./external-link-CldCnbtR.js";var Ur=et(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),Wr=et(`file-text`,[[`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:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Gr=et(`film`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]),Kr=et(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),qr=et(`volume-2`,[[`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`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]),U=n(),W=e(r(),1),Jr=e(o(),1),Yr=s(),Xr=c();function Zr(e){return e.editorView}var Qr=new Map([[32,` `],[9,` `],[160,`\xA0`]]);function $r(e){let t=/^&#(x[0-9A-Fa-f]+|X[0-9A-Fa-f]+|[0-9]+);$/.exec(e);if(!t)return null;let n=t[1],r=n[0]===`x`||n[0]===`X`,i=Number.parseInt(r?n.slice(1):n,r?16:10);return Number.isNaN(i)?null:i}function ei(e){let t=$r(e);return t!==null&&Qr.has(t)}function ti(e){let t=$r(e);return t===null?null:Qr.get(t)??null}var ni=/&#(?:x[0-9A-Fa-f]+|X[0-9A-Fa-f]+|[0-9]+);/g;function ri(e){ni.lastIndex=0;let t=e.match(ni);if(t===null||t.join(``)!==e)return null;let n=``;for(let e of t){let t=ti(e);if(t===null)return null;n+=t}return n}var ii=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},ai=/[\uD800-\uDBFF]/,oi=/[\uDC00-\uDFFF]/,si=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&ai.test(e[n-1])&&n--;r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1];)r++;return r>0&&oi.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},ci=(e,t)=>e>>>t|e<<32-t,li=e=>ci(e,2)^ci(e,13)^ci(e,22),ui=e=>ci(e,6)^ci(e,11)^ci(e,25),di=e=>ci(e,7)^ci(e,18)^e>>>3,fi=e=>ci(e,17)^ci(e,19)^e>>>10,pi=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),mi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),hi=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(mi),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=fi(t[e-2])+t[e-7]+di(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7];for(let e=0,u,d;e<64;e++)u=l+ui(o)+(o&s^~o&c)+pi[e]+t[e]>>>0,d=li(n)+(n&r^n&i^r&i)>>>0,l=c,c=s,s=o,o=a+u>>>0,a=i,i=r,r=n,n=u+d>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=o,e[5]+=s,e[6]+=c,e[7]+=l}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3<e.length;n++)this._W[n]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!=0){for(this._W.fill(0,n,16);t<e.length;)this._W[n]|=e[t]<<(3-t%4)*8,t++;this._W[n]|=128<<(3-t%4)*8}this._updateHash()}let n=t%64!=0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let n=3;n>=0&&t<e.length;n--)this._W[r]|=e[t++]<<n*8;n||(this._W[r-(t%4==0?0:1)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/Gt,this._W[15]=e.byteLength*8,this._updateHash();let i=new Uint8Array(32);for(let e=0;e<this._H.length;e++)for(let t=0;t<4;t++)i[e*4+t]=this._H[e]>>>(3-t)*8;return i}},gi=e=>new hi().digest(e),G=new k(`y-sync`),_i=new k(`y-undo`),vi=new k(`yjs-cursor`),yi=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},bi=e=>Dt(yi(gi(Rt(e)))),xi=()=>({mapping:new Map,isOMark:new Map}),Si=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!jt(t.ds,e.id),Ci=[{light:`#ecd44433`,dark:`#ecd444`}],wi=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=Yt();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,zt(t))}return e.get(n)},Ti=(e,{colors:t=Ci,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new ki(e,a),c=new M({props:{editable:e=>{let t=G.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:G,state:{init:(i,a)=>({type:e,doc:e.doc,binding:s,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(e,t)=>{let n=e.getMeta(G);if(n!==void 0){t=Object.assign({},t);for(let e in n)t[e]=n[e]}return t.addToHistory=e.getMeta(`addToHistory`)!==!1,t.isChangeOrigin=n!==void 0&&!!n.isChangeOrigin,t.isUndoRedoOperation=n!==void 0&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,s.prosemirrorView!==null&&n!==void 0&&(n.snapshot!=null||n.prevSnapshot!=null)&&un(0,()=>{s.prosemirrorView!=null&&(n.restore==null?s._renderSnapshot(n.snapshot,n.prevSnapshot,t):(s._renderSnapshot(n.snapshot,n.snapshot,t),delete t.restore,delete t.snapshot,delete t.prevSnapshot,s.mux(()=>{s._prosemirrorChanged(s.prosemirrorView.state.doc)})))}),t}},view:e=>(s.initView(e),a??s._forceRerender(),i(),{update:()=>{let t=c.getState(e.state);if(t.snapshot==null&&t.prevSnapshot==null&&(o||e.state.doc.content.findDiffStart(e.state.doc.type.createAndFill().content)!==null)){if(o=!0,t.addToHistory===!1&&!t.isChangeOrigin){let t=_i.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}s.mux(()=>{t.doc.transact(n=>{n.meta.set(`addToHistory`,t.addToHistory),s._prosemirrorChanged(e.state.doc)},G)})}},destroy:()=>{s.destroy()}})});return c},Ei=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new ke(e.doc));else if(t.type===`node`){let r=sa(n.doc,n.type,t.anchor,n.mapping);e.setSelection(Di(e,r))}else{let r=sa(n.doc,n.type,t.anchor,n.mapping),i=sa(n.doc,n.type,t.head,n.mapping);r!==null&&i!==null&&e.setSelection(j.between(e.doc.resolve(r),e.doc.resolve(i)))}},Di=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?Pe.create(e.doc,t):j.near(n)},Oi=(e,t)=>({type:t.selection.jsonID,anchor:aa(t.selection.anchor,e.type,e.mapping),head:aa(t.selection.head,e.type,e.mapping)}),ki=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=ii(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Oi(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta(`addToHistory`,!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(At&&this._domSelectionInView===null&&(un(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;let t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);let n=t.getBoundingClientRect(),r=wt.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(e,t){t||=Et(It(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(G,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>ji(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new A(I.from(e),0,0));t.setMeta(G,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.prosemirrorView.state.selection:null,t=this.type.toArray().map(e=>ji(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new A(I.from(t),0,0));if(e){let t=$t(an(e.anchor,0),n.doc.content.size),r=$t(an(e.head,0),n.doc.content.size);n.setSelection(j.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(G,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=Ot(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&St(),r=new on({gc:!1}),ln(r,t),t=Ot(r),ln(r,e),e=Ot(r),i._item===null){let e=Array.from(this.doc.share.keys()).find(e=>this.doc.share.get(e)===this.type);i=r.getXmlFragment(e)}else{let e=r.store.clients.get(i._item.id.client)??[];i=e[Ct(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{Nt(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:wi(n.colorMapping,n.colors,r)}},s=Ft(i,new tn(t.ds,e.sv)).map(n=>!n._item.deleted||Si(n._item,e)||Si(n._item,t)?ji(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,o):null).filter(e=>e!==null),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new A(I.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(G,{isChangeOrigin:!0}))},G)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=G.getState(this.prosemirrorView.state);if(e.length===0||n.snapshot!=null||n.prevSnapshot!=null){this.renderSnapshot(n.snapshot,n.prevSnapshot);return}this.mux(()=>{let e=(e,t)=>this.mapping.delete(t);Nt(t,t.deleteSet,e=>{if(e.constructor===Wt){let t=e.content.type;t&&this.mapping.delete(t)}}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>Ai(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new A(I.from(n),0,0));Ei(r,this.beforeTransactionSelection,this),r=r.setMeta(G,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof Qt}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{Qi(this.doc,this.type,e,this),this.beforeTransactionSelection=Oi(this,this.prosemirrorView.state)},G)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.on(`afterAllTransactions`,this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.off(`afterAllTransactions`,this.afterAllTransactions))}},Ai=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof qt)return ji(e,t,n,r,i,a);throw Pt()}return o},ji=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof qt){let s=Ai(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof Jt&&!s._item.deleted&&s._item.id.client===s.doc.clientID&&(e.applyDelta([{retain:e.length},...s.toDelta()]),s.doc.transact(e=>{s._item.delete(e)}));let c=Mi(e,t,n,r,i,a);c!==null&&c.forEach(e=>{e!==null&&o.push(e)})}};r===void 0||i===void 0?e.toArray().forEach(s):Ft(e,new tn(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(Si(e._item,r)?Si(e._item,i)||(s.ychange=a?a(`added`,e._item.id):{type:`added`}):s.ychange=a?a(`removed`,e._item.id):{type:`removed`});let c=Vi(s),l=Xi(c.marks,t),u=t.node(e.nodeName,c.plain,o,l.length?l:void 0);return n.mapping.set(e,u),u}catch(r){console.warn(`[y-prosemirror] schema.node(`+e.nodeName+`) threw:`,String(r&&r.message||r));let i=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};if(t.nodes[e.nodeName]&&t.nodes[e.nodeName].spec&&t.nodes[e.nodeName].spec.inline)i.inline++;else if(i.block++,t.nodes.rawMdxFallback)try{let i=t.node(`rawMdxFallback`,{reason:String(r&&r.message||r)},[t.text(e.nodeName)]);return n.mapping.set(e,i),i}catch(e){console.warn(`[y-prosemirror] rawMdxFallback substitution also failed:`,String(e&&e.message||e))}return n.mapping.delete(e),null}},Mi=(e,t,n,r,i,a)=>{let o=[],s=e.toDelta(r,i,a);try{for(let e=0;e<s.length;e++){let n=s[e];o.push(t.text(n.insert,Xi(n.attributes,t)))}}catch(e){console.warn(`[y-prosemirror] schema.text() threw:`,String(e&&e.message||e));let t=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};return t.inline++,null}return o},Ni=(e,t)=>{let n=new Bt,r=e.map(e=>({insert:e.text,attributes:Zi(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},Pi=(e,t)=>{let n=new qt(e.type.name);for(let t in e.attrs){let r=e.attrs[t];r!==null&&t!==`ychange`&&n.setAttribute(t,r)}let r=Zi(e.marks||[],t);for(let e in r)n.setAttribute(Bi+e,{...r[e]});return n.insert(0,Ri(e).map(e=>Fi(e,t))),t.mapping.set(n,e),n},Fi=(e,t)=>e instanceof Array?Ni(e,t):Pi(e,t),Ii=e=>typeof e==`object`&&!!e,Li=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]!==null),r=n.length===Object.keys(t).filter(e=>t[e]!==null).length;for(let i=0;i<n.length&&r;i++){let a=n[i],o=e[a],s=t[a];r=a===`ychange`||o===s||Ii(o)&&Ii(s)&&Li(o,s)}return r},Ri=e=>{let t=e.content.content,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.isText){let r=[];for(let n=t[e];e<t.length&&n.isText;n=t[++e])r.push(n);e--,n.push(r)}else n.push(r)}return n},zi=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&kt(e.attributes||{}).length===t[n].marks.length&&nn(e.attributes,(e,r)=>{let i=Yi(r),a=t[n].marks;return a.find(e=>e.type.name===i)?Li(e,a.find(e=>e.type.name===i)?.attrs):!1}))},Bi=`ymark:`,Vi=e=>{let t={},n={};for(let r in e)r.startsWith(Bi)?n[r.slice(6)]=e[r]:t[r]=e[r];return{plain:t,marks:n}},Hi=(e,t)=>{let n=Object.keys(e);return n.length===t.length?n.every(n=>{let r=Yi(n),i=t.find(e=>e.type.name===r);return i?Li(e[n],i.attrs):!1}):!1},Ui=(e,t)=>{if(e instanceof qt&&!(t instanceof Array)&&$i(e,t)){let n=Ri(t),r=Vi(e.getAttributes());return e._length===n.length&&Hi(r.marks,t.marks)&&Li(r.plain,t.attrs)&&e.toArray().every((e,t)=>Ui(e,n[t]))}return e instanceof Bt&&t instanceof Array&&zi(e,t)},Wi=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),Gi=(e,t,n)=>{let r=e.toArray(),i=Ri(t),a=i.length,o=r.length,s=$t(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(Wi(n.mapping.get(e),t))u=!0;else if(!Ui(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(Wi(n.mapping.get(e),t))u=!0;else if(!Ui(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},Ki=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Ut?t+=n.content.str:n.content instanceof rn&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},qi=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=Ki(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,Zi(e.marks,n))})),{insert:o,remove:s,index:c}=si(i,a.map(e=>e.insert).join(``));e.delete(c,s),e.insert(c,o),e.applyDelta(a.map(e=>({retain:e.insert.length,attributes:e.attributes})))},Ji=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Yi=e=>Ji.exec(e)?.[1]??e,Xi=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(Yi(r),e[r]));return n},Zi=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=en(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${bi(e.toJSON())}`:e.type.name]=e.attrs}}),n},Qi=(e,t,n,r)=>{if(t instanceof qt&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof qt){let e=t.getAttributes(),i=n.attrs;for(let n in i)i[n]===null?t.removeAttribute(n):e[n]!==i[n]&&n!==`ychange`&&t.setAttribute(n,i[n]);for(let n in e)i[n]===void 0&&!n.startsWith(Bi)&&t.removeAttribute(n);let a=Zi(n.marks||[],r);for(let n in a){let r=e[Bi+n];(r===void 0||!Li(r,a[n]))&&t.setAttribute(Bi+n,{...a[n]})}for(let n in e)n.startsWith(Bi)&&a[n.slice(6)]===void 0&&t.removeAttribute(n)}let i=Ri(n),a=i.length,o=t.toArray(),s=o.length,c=$t(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!Wi(r.mapping.get(e),t))if(Ui(e,t))r.mapping.set(e,t);else break}for(;u+l+1<c;u++){let e=o[s-u-1],t=i[a-u-1];if(!Wi(r.mapping.get(e),t))if(Ui(e,t))r.mapping.set(e,t);else break}e.transact(()=>{for(;s-l-u>0&&a-l-u>0;){let n=o[l],c=i[l],d=o[s-u-1],f=i[a-u-1];if(n instanceof Bt&&c instanceof Array)zi(n,c)||qi(n,c,r),l+=1;else{let i=n instanceof qt&&$i(n,c),a=d instanceof qt&&$i(d,f);if(i&&a){let e=Gi(n,c,r),t=Gi(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(Qi(e,n,c,r),l+=1):a?(Qi(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[Fi(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof Bt?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):n>0&&(t.slice(l,l+n).forEach(e=>r.mapping.delete(e)),t.delete(l,n)),l+u<a){let e=[];for(let t=l;t<a-u;t++)e.push(Fi(i[t],r));t.insert(l,e)}},G)},$i=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,ea=null,ta=class{constructor(e,t,n){this.view=e,this.key=t,this.value=n}apply(){let e=G.getState(this.view.state);if(e&&e.binding&&!e.binding.isDestroyed){let e=this.view.state.tr;e.setMeta(this.key,this.value),this.view.dispatch(e)}}},na=class e{constructor(e=[]){this.entries=e}getFirst(){return this.entries[0]}dequeueFirst(){return this.entries.shift()}isEmpty(){return this.entries.length===0}static fromViewsToUpdate(){let t=ea;ea=null;let n=[];return t.forEach((e,t)=>{e.forEach((e,r)=>{n.push(new ta(t,r,e))})}),new e(n)}},ra=(e=na.fromViewsToUpdate(),t=!1)=>{let n=!0;for(;!e.isEmpty();){let r=e.getFirst();try{r.apply()}catch(r){if(r instanceof RangeError){t&&n&&e.dequeueFirst(),e.isEmpty()||un(0,()=>ra(e,!0));return}throw r}n=!1,e.dequeueFirst()}},ia=(e,t,n)=>{ea||(ea=new Map,un(0,ra)),en(ea,e,Vt).set(t,n)},aa=(e,t,n)=>{if(e===0)return Lt(t,0,-1);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof Bt){if(r._length>=e)return Lt(r,e,-1);if(e-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:r._item.next.content.type)}}else{let i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&e<i)r=r._first.content.type,e--;else{if(e===1&&r._length===0&&i>1)return new Kt(r._item===null?null:r._item.id,r._item===null?Xt(r):null,null);if(e-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(e===0)return r=r._item===null?r:r._item.parent,new Kt(r._item===null?null:r._item.id,r._item===null?Xt(r):null,null);do r=r._item.parent,e--;while(r!==t&&r._item.next===null);r!==t&&(r=r._item.next.content.type)}}}if(r===null)throw St();if(e===0&&r.constructor!==Bt&&r!==t)return oa(r._item.parent,r._item)}return Lt(t,t._length,-1)},oa=(e,t)=>{let n=null,r=null;return e._item===null?r=Xt(e):n=Tt(e._item.id.client,e._item.id.clock),new Kt(n,r,t.id)},sa=(e,t,n,r)=>{let i=cn(n,e);if(i===null||i.type!==t&&!Mt(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===Bt)o=i.index;else if(a._item===null||!a._item.deleted){let e=a._first,t=0;for(;t<a._length&&t<i.index&&e!==null;){if(!e.deleted){let n=e.content.type;if(t++,n instanceof Bt)o+=n._length;else{let e=r.get(n);if(e==null)return null;o+=e.nodeSize}}e=e.right}o+=1}for(;a!==t&&a._item!==null;){let e=a._item.parent;if(e._item===null||!e._item.deleted){o+=1;let t=e._first;for(;t!==null;){let e=t.content.type;if(e===a)break;if(!t.deleted)if(e instanceof Bt)o+=e._length;else{let t=r.get(e);if(t==null)return null;o+=t.nodeSize}t=t.right}}a=e}return o-1},ca=(e,t)=>{let n=e.toArray().map(e=>ji(e,t,xi())).filter(e=>e!==null);return I.fromArray(n)},la=(e,t)=>t.topNodeType.create(null,ca(e,t)),ua=(e,t)=>{let n=xi(),r=e.toArray().map(e=>ji(e,t,n)).filter(e=>e!==null);return{doc:t.topNodeType.create(null,I.fromArray(r)),meta:n,mapping:n.mapping}},da=(e,t,n)=>e!==t,fa=e=>{let t=document.createElement(`span`);t.classList.add(`ProseMirror-yjs-cursor`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);let r=document.createTextNode(``),i=document.createTextNode(``);return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(i,null),t},pa=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),ma=/^#[0-9a-fA-F]{6}$/,ha=(e,t,n,r,i)=>{let a=G.getState(e);if(a==null||a.doc==null||a.binding==null)return me.create(e.doc,[]);let o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?me.create(e.doc,[]):(t.getStates().forEach((t,c)=>{if(n(o.clientID,c,t)&&t.cursor!=null){let n=t.user||{};n.color==null?n.color=`#ffa500`:ma.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`;let l=sa(o,a.type,sn(t.cursor.anchor),a.binding.mapping),u=sa(o,a.type,sn(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=an(e.doc.content.size-1,0);l=$t(l,t),u=$t(u,t),s.push(he.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=$t(l,u),o=an(l,u);s.push(he.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),me.create(e.doc,s))},ga=(e,{awarenessStateFilter:t=da,cursorBuilder:n=fa,selectionBuilder:r=pa,getSelection:i=e=>e.selection}={},a=`cursor`)=>new M({key:vi,state:{init(i,a){return ha(a,e,t,n,r)},apply(i,a,o,s){let c=G.getState(s),l=i.getMeta(vi);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?ha(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>vi.getState(e)},view:t=>{let n=()=>{t.docView&&ia(t,vi,{awarenessUpdated:!0})},r=()=>{let n=G.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=aa(o.anchor,n.type,n.binding.mapping),c=aa(o.head,n.type,n.binding.mapping);(r.cursor==null||!Ht(sn(r.cursor.anchor),s)||!Ht(sn(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&sa(n.doc,n.type,sn(r.cursor.anchor),n.binding.mapping)!==null&&e.setLocalStateField(a,null)};return e.on(`change`,n),t.dom.addEventListener(`focusin`,r),t.dom.addEventListener(`focusout`,r),{update:r,destroy:()=>{t.dom.removeEventListener(`focusin`,r),t.dom.removeEventListener(`focusout`,r),e.off(`change`,n),e.setLocalStateField(a,null)}}}}),_a=e=>{let t=_i.getState(e).undoManager;if(t!=null)return t.undo(),!0},va=e=>{let t=_i.getState(e).undoManager;if(t!=null)return t.redo(),!0},ya=new Set([`paragraph`]),ba=(e,t)=>!(e instanceof Wt)||!(e.content instanceof Zt)||!(e.content.type instanceof Jt||e.content.type instanceof qt&&t.has(e.content.type.nodeName))||e.content.type._length===0,xa=({protectedNodes:e=ya,trackedOrigins:t=[],undoManager:n=null}={})=>new M({key:_i,state:{init:(r,i)=>{let a=G.getState(i),o=n||new Qt(a.type,{trackedOrigins:new Set([G].concat(t)),deleteFilter:t=>ba(t,e),captureTransaction:e=>e.meta.get(`addToHistory`)!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(e,t,n,r)=>{let i=G.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:Oi(i,n),hasUndoOps:o,hasRedoOps:s}:o!==t.hasUndoOps||s!==t.hasRedoOps?Object.assign({},t,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):t}},view:e=>{let t=G.getState(e.state),n=_i.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,_i.getState(e.state).prevSel)}),n.on(`stack-item-popped`,({stackItem:e})=>{let n=t.binding;n&&(n.beforeTransactionSelection=e.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy()}}}}),Sa=new Map,Ca=new Set;function wa(){for(let e of Ca)e()}function Ta(e,t,n){Sa.set(e,{view:t,host:n}),wa()}function Ea(e,t){Sa.get(e)?.view===t&&(Sa.delete(e),wa())}function Da(e){let t=Sa.get(e);return t?.host===`sourceEditor`?t.view:null}function Oa(e){return Sa.get(e)??null}function ka(e){return Ca.add(e),()=>{Ca.delete(e)}}var Aa=new WeakMap,ja=new WeakMap;function Ma(e,t){Aa.set(e,t)}function Na(e){return Aa.get(e)??!1}function Pa(e,t){ja.set(e,t)}function Fa(e){return ja.get(e)??!1}function Ia(e){return!Na(e)}var La=`autonomousFragmentEdit/swap`;function Ra(e){return e.setMeta(La,!0)}function za(e,t,n){return n===t.textContent?Ra(e):e}function Ba(e){return e.getMeta(La)===!0}function Va(e){return!e.getMeta(G)&&!Ba(e)}var Ha=/^[A-Za-z0-9]{20,}$/,Ua=/^(?:\d+s?|(?:\d+h)?(?:\d+m)?(?:\d+s)?)$/;function Wa(e){let t=e.toLowerCase();return t===`loom.com`||t===`www.loom.com`}function Ga(e){let t=e.pathname.match(/^\/(?:share|embed)\/([A-Za-z0-9]+)\/?$/);if(!t)return null;let n=t[1]??``;return Ha.test(n)?n:null}function Ka(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`||!Wa(t.hostname))return null;let n=Ga(t);if(!n)return null;let r=t.searchParams.get(`t`);return{id:n,startRaw:r&&r.length>0&&Ua.test(r)?r:null}}function qa(e){return Ka(e)!==null}function Ja(e){let t=e.toLowerCase();return t===`vimeo.com`||t===`www.vimeo.com`||t===`player.vimeo.com`}function Ya(e){if(typeof e!=`string`||e.length===0)return!1;let t;try{t=new URL(e)}catch{return!1}return t.protocol!==`http:`&&t.protocol!==`https:`?!1:Ja(t.hostname)}var Xa=/^[A-Za-z0-9_-]{11}$/;function Za(e){let t=e.toLowerCase();return t===`youtube.com`||t===`www.youtube.com`||t===`m.youtube.com`||t===`music.youtube.com`||t===`youtu.be`||t===`youtube-nocookie.com`||t===`www.youtube-nocookie.com`}function Qa(e){if(e.length===0)return null;if(/^[0-9]+$/.test(e)){let t=Number.parseInt(e,10);return t>0?t:null}let t=e.match(/^(?:([0-9]+)h)?(?:([0-9]+)m)?(?:([0-9]+)s?)?$/);if(!t)return null;let n=t[1]?Number.parseInt(t[1],10):0,r=t[2]?Number.parseInt(t[2],10):0,i=t[3]?Number.parseInt(t[3],10):0,a=n*3600+r*60+i;return a>0?a:null}function $a(e){if(e.hostname.toLowerCase()===`youtu.be`){let t=e.pathname.replace(/^\//,``).split(`/`)[0]??``;return Xa.test(t)?t:null}if(e.pathname===`/watch`){let t=e.searchParams.get(`v`)??``;return Xa.test(t)?t:null}let t=e.pathname.match(/^\/(?:embed|shorts|v)\/([A-Za-z0-9_-]{11})\/?$/);return t?t[1]??null:null}function eo(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`||!Za(t.hostname))return null;let n=$a(t);if(!n)return null;let r=t.searchParams.get(`t`)??t.searchParams.get(`start`)??``;return{id:n,startSeconds:r.length>0?Qa(r):null,noCookie:t.hostname.toLowerCase().endsWith(`youtube-nocookie.com`)}}function to(e,t){let n=Array.isArray(e.attrs.attributes)?e.attrs.attributes.filter(e=>typeof e==`object`&&!!e&&`type`in e):[],r=e.attrs.props??{},i=new Map,a=new Set;if(t)for(let e of t)e.omitOnDefault===!0&&`defaultValue`in e&&e.defaultValue!==void 0&&i.set(e.name,e.defaultValue),e.type===`string`&&e.required===!1&&e.defaultValue===void 0&&a.add(e.name);for(let[e,t]of Object.entries(r)){let r=n.findIndex(t=>t.type===`mdxJsxAttribute`&&t.name===e);if(i.has(e)&&Object.is(i.get(e),t)){r>=0&&n.splice(r,1);continue}if(a.has(e)&&t===``){r>=0&&n.splice(r,1);continue}if(r>=0){let e=n[r];if(e.type===`mdxJsxAttribute`&&e.value!=null&&typeof e.value==`object`&&e.value.type===`mdxJsxAttributeValueExpression`&&no(e.value.value,t))continue}let o=ro(e,t);r>=0?n[r]=o:n.push(o)}return n}function no(e,t){try{return JSON.stringify(JSON.parse(e))===JSON.stringify(t)}catch{return!1}}function ro(e,t){if(t===!0)return{type:`mdxJsxAttribute`,name:e,value:null};if(t===!1)return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:`false`}};if(t==null)return{type:`mdxJsxAttribute`,name:e,value:null};if(typeof t==`string`)return{type:`mdxJsxAttribute`,name:e,value:t};if(typeof t==`number`)return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:JSON.stringify(t)}};if(typeof t==`object`){let n;try{n=JSON.stringify(t)}catch{n=String(t)}return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:n}}}return{type:`mdxJsxAttribute`,name:e,value:String(t)}}function io(e,t,n,r){return{type:`mdxJsxFlowElement`,name:e,attributes:to(t,r),children:n.all(t),data:{}}}function ao(e,t,n){let r=t.attrs.props?.children;return{type:`mdxJsxTextElement`,name:e,attributes:to(t,n),children:typeof r==`string`&&r!==``?[{type:`text`,value:r}]:[],data:{}}}var oo=[{name:`type`,type:`enum`,enumValues:[`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`],defaultValue:`note`,required:!1,description:`Callout variant`},{name:`title`,type:`string`,required:!1,description:`Optional heading shown above the body`},{name:`icon`,type:`string`,required:!1,advanced:!0,description:"Custom lucide icon override (e.g. `lucide:Lightbulb`)",iconPicker:!0},{name:`color`,type:`string`,required:!1,advanced:!0,description:"Optional accent color override (hex — e.g. `#F05032`)",colorPicker:!0},{name:`collapsible`,type:`boolean`,required:!1,defaultValue:!1,advanced:!0,description:"Render as a foldable `<details>` (Obsidian `[!TYPE]+/-`)"},{name:`defaultOpen`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,description:`When collapsible, start in the open state`,hideWhen:e=>e.collapsible!==!0},{name:`children`,type:`reactnode`,required:!0,description:`Callout content`}],so=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Image source URL`,accept:x,autoFocus:!0},{name:`alt`,type:`string`,required:!0,description:`Alt text`},{name:`width`,type:`number`,required:!1,advanced:!0,description:`Image width`},{name:`height`,type:`number`,required:!1,advanced:!0,description:`Image height`},{name:`srcset`,type:`string`,required:!1,advanced:!0,description:`Responsive image candidate set (e.g. "x.png 1x, y.png 2x")`},{name:`sizes`,type:`string`,required:!1,advanced:!0,description:`Responsive image sizes hint paired with srcset`},{name:`loading`,type:`enum`,enumValues:[`eager`,`lazy`],defaultValue:`lazy`,required:!1,advanced:!0,omitOnDefault:!0,description:`Native img loading strategy (defaults to lazy)`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`decoding`,type:`enum`,enumValues:[`sync`,`async`,`auto`],defaultValue:`auto`,required:!1,advanced:!0,omitOnDefault:!0,description:`Hint for how the browser should decode the image`},{name:`fetchpriority`,type:`enum`,enumValues:[`high`,`low`,`auto`],defaultValue:`auto`,required:!1,advanced:!0,omitOnDefault:!0,description:`Resource fetch priority hint`},{name:`crossorigin`,type:`enum`,enumValues:[`anonymous`,`use-credentials`],required:!1,advanced:!0,description:`CORS mode for the image fetch`},{name:`referrerpolicy`,type:`string`,required:!1,advanced:!0,description:`Referrer policy for the image fetch (HTML referrerpolicy values)`},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`,hidden:!0}],co=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Embedded page URL (must start with http:// or https://)`,autoFocus:!0},{name:`title`,type:`string`,required:!1,description:`Iframe title (accessible label for screen readers)`},{name:`width`,type:`string`,required:!1,advanced:!0,description:`Embed width as a CSS length (e.g. "100%", "640px")`,cssLengthInput:!0},{name:`height`,type:`string`,required:!1,advanced:!0,description:`Embed height as a CSS length (e.g. "26rem", "480px")`,cssLengthInput:!0},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`,hidden:!0}],lo=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Video source URL`,accept:y,autoFocus:!0},{name:`controls`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,omitOnDefault:!0,description:`Show native HTML5 video controls (defaults to true)`,hideWhen:e=>typeof e.src==`string`&&(Ya(e.src)||qa(e.src))},{name:`autoplay`,type:`boolean`,required:!1,advanced:!0,description:`Begin playback as soon as possible (usually requires muted)`},{name:`poster`,type:`string`,required:!1,advanced:!0,description:`Poster image URL shown before playback`,accept:x,hideWhen:e=>typeof e.src==`string`&&(Ya(e.src)||qa(e.src))},{name:`width`,type:`number`,required:!1,advanced:!0,description:`Video width`},{name:`height`,type:`number`,required:!1,advanced:!0,description:`Video height`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`muted`,type:`boolean`,required:!1,advanced:!0,description:`Mute audio on load`},{name:`loop`,type:`boolean`,required:!1,advanced:!0,description:`Restart from the beginning when playback ends`,hideWhen:e=>typeof e.src==`string`&&qa(e.src)},{name:`playsinline`,type:`boolean`,required:!1,advanced:!0,description:`Play inline on iOS rather than entering fullscreen`,hideWhen:e=>typeof e.src==`string`&&(Ya(e.src)||qa(e.src))},{name:`preload`,type:`enum`,enumValues:[`none`,`metadata`,`auto`],required:!1,advanced:!0,description:`Hint for how much of the video to preload`,hideWhen:e=>typeof e.src==`string`&&(eo(e.src)!==null||Ya(e.src)||qa(e.src))},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`,hidden:!0}],uo=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Audio source URL`,accept:w,autoFocus:!0},{name:`controls`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,omitOnDefault:!0,description:`Show native HTML5 audio controls (defaults to true)`},{name:`autoplay`,type:`boolean`,required:!1,advanced:!0,description:`Begin playback as soon as possible (usually requires muted)`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`muted`,type:`boolean`,required:!1,advanced:!0,description:`Mute audio on load`},{name:`loop`,type:`boolean`,required:!1,advanced:!0,description:`Restart from the beginning when playback ends`},{name:`preload`,type:`enum`,enumValues:[`none`,`metadata`,`auto`],required:!1,advanced:!0,description:`Hint for how much of the audio to preload`}],fo=[{name:`title`,type:`string`,required:!0,description:`Heading shown inside the <summary>`},{name:`defaultOpen`,type:`boolean`,required:!1,defaultValue:!1,description:`When true, the block renders expanded on initial load`},{name:`icon`,type:`string`,required:!1,advanced:!0,description:"Custom lucide icon override (e.g. `lucide:Rocket`)",iconPicker:!0},{name:`description`,type:`string`,required:!1,advanced:!0,description:`Optional subtitle rendered below the title inside <summary>`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#advanced-options`)"},{name:`name`,type:`string`,required:!1,advanced:!0,description:`HTML5 <details name=> group — siblings with the same name are mutually exclusive`}],po=[oo[0],oo[1],oo[4],oo[5],oo[6]],mo=[so[0],so[1],so[7]],ho=[fo[0],fo[1],fo[4],fo[5]],go=[{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`,`justify`],required:!1,defaultValue:`center`,description:"Block alignment from the `<div align>` attribute."},{name:`tag`,type:`string`,required:!1,defaultValue:`div`,hidden:!0,description:`Source wrapper tag (div or center).`},{name:`sourceAttrs`,type:`string`,required:!1,defaultValue:``,hidden:!0,description:`Raw opener-tag attribute bytes preserved for round-trip.`}],_o=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Alt text (Obsidian alias syntax: `![[file.png|alt text]]`)"}],vo=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Title text (Obsidian alias syntax: `![[clip.mp4|title]]`)"}],yo=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Title text (Obsidian alias syntax: `![[song.mp3|title]]`)"}],bo=[{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#install-tabs`)"}],xo=[{name:`label`,type:`string`,required:!0,autoFocus:!0,defaultValue:`Tab`,description:`Tab strip label — shown in the clickable pill at the top`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#tab-npm`)"}],So=[{name:`formula`,type:`string`,required:!0,autoFocus:!0,language:`latex`,description:`LaTeX math source (rendered with KaTeX in the browser)`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#eq-pythagoras`)"},{name:`language`,type:`string`,required:!1,advanced:!0,description:"Forward-compat hint for the math source language (default `latex`). Reserved for future MathJax / Typst / AsciiMath substrates."}],Co=[So[0]],wo=[So[0]],To=[{name:`chart`,type:`string`,required:!0,hidden:!0,description:`Mermaid chart source (graph / flowchart / sequenceDiagram / class / state / etc.)`}],Eo=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Display name override (Obsidian alias syntax: `![[file.zip|label]]`)"}],Do=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`File URL`,accept:[`*/*`],autoFocus:!0}],Oo=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`PDF source URL`,accept:C,autoFocus:!0},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Accessible label for the embedded PDF viewer`},{name:`anchor`,type:`string`,required:!1,advanced:!0,description:"PDF viewer parameters as a single URL-fragment string (e.g. `page=3&height=600`)"}],ko=[{name:`src`,type:`string`,required:!0,description:"Path to the `.excalidraw` board this embed renders",autoFocus:!0},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Accessible label for the embedded board`}],Ao=[{name:`src`,type:`string`,required:!0,description:"Path of the source doc, extension-less (e.g. `api-spec`).",autoFocus:!0},{name:`anchor`,type:`string`,required:!0,description:"Id of the `<MirrorSource>` block within the source doc."}],jo=[{name:`id`,type:`string`,required:!0,description:"Stable id agents and authors use to reference this block from `<Mirror>` elsewhere.",autoFocus:!0},{name:`children`,type:`reactnode`,required:!0,description:`Block content this MirrorSource owns — paragraphs, callouts, code, nested JSX, anything.`}];function Mo(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function No(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function Po(e){let t=e.attrs.props,n=t?.target??``,r=typeof t?.alias==`string`&&t.alias.length>0?t.alias:null,i=typeof t?.anchor==`string`&&t.anchor.length>0?t.anchor:null,a=typeof t?.sourceTarget==`string`?t.sourceTarget:null,o=typeof t?.sourceAnchor==`string`?t.sourceAnchor:null,s=typeof t?.sourceAlias==`string`?t.sourceAlias:null,c=r??(i?`${n}#${i}`:n);return{type:`wikiLinkEmbed`,value:c,data:{target:n,anchor:i,alias:r,sourceTarget:a,sourceAnchor:o,sourceAlias:s},children:[{type:`text`,value:c}]}}var Fo=[{name:`Callout`,surface:`canonical`,hasChildren:!0,props:oo,icon:`MessageSquareWarning`,category:`content`,displayName:`Callout`,description:`Alert / admonition with 15 type variants — 5 GFM (note, tip, important, warning, caution) plus 10 Obsidian-parity (abstract, info, todo, success, question, failure, danger, bug, example, quote)`,searchTerms:[`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`,`alert`,`admonition`,`callout`],serialize:(e,t)=>io(`Callout`,e,t,oo)},{name:`img`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:so,icon:`Image`,category:`media`,displayName:`Image`,description:`Image with click-to-zoom and HTML-native attributes`,searchTerms:[`image`,`zoom`,`picture`,`photo`],placeholder:{label:`Add an image`},serialize:(e,t)=>io(`img`,e,t,so)},{name:`video`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:lo,icon:`SquarePlay`,category:`media`,displayName:`Video`,description:`HTML5 video player with native controls`,searchTerms:[`video`,`media`,`player`,`mp4`,`webm`,`movie`],placeholder:{label:`Add a video`},serialize:(e,t)=>io(`video`,e,t,lo)},{name:`audio`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:uo,icon:`Volume2`,category:`media`,displayName:`Audio`,description:`HTML5 audio player with native controls`,searchTerms:[`audio`,`sound`,`music`,`mp3`,`podcast`,`player`],placeholder:{label:`Add audio`},serialize:(e,t)=>io(`audio`,e,t,uo)},{name:`Pdf`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:Oo,icon:`FileText`,category:`media`,displayName:`PDF`,description:"Embedded PDF viewer (`#page=N` to open at page N, `#height=N` for viewer height)",searchTerms:[`pdf`,`document`,`embed`,`pdfjs`],placeholder:{label:`Add a PDF`},serialize:(e,t)=>io(`Pdf`,e,t,Oo)},{name:`Excalidraw`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:ko,icon:`PenTool`,category:`embed`,displayName:`Excalidraw`,description:"Embedded snapshot of an `.excalidraw` board, linking to its canvas editor",searchTerms:[`excalidraw`,`board`,`whiteboard`,`sketch`,`drawing`,`canvas`],serialize:(e,t)=>io(`Excalidraw`,e,t,ko)},{name:`File`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:Do,icon:`Paperclip`,category:`media`,displayName:`File`,description:`Downloadable file attachment — inline row with name + size + download link`,searchTerms:[`file`,`attachment`,`download`,`document`,`zip`,`docx`,`doc`],placeholder:{label:`Add a file`},serialize:(e,t)=>io(`File`,e,t,Do)},{name:`Embed`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:co,icon:`AppWindow`,category:`embed`,displayName:`Embed`,description:'Inline web embed (iframe) — drop a URL, get a resizable preview pane. For YouTube / Vimeo / Loom prefer `<video src="…">` (player props, click-facade); `<Embed>` auto-rewrites watch URLs as a fallback.',searchTerms:[`embed`,`iframe`,`website`,`page`,`inline`,`frame`,`preview`],placeholder:{label:`Embed a URL`},serialize:(e,t)=>io(`Embed`,e,t,co)},{name:`Accordion`,surface:`canonical`,hasChildren:!0,props:fo,icon:`ChevronRight`,category:`content`,displayName:`Accordion`,description:"Standalone expand/collapse via native HTML5 <details>/<summary>. Group siblings with the `name` prop for exclusive-accordion UX.",searchTerms:[`accordion`,`expandable`,`details`,`disclosure`,`collapse`,`fold`],exampleBody:`Body content revealed when the accordion is expanded.`,serialize:(e,t)=>io(`Accordion`,e,t,fo)},{name:`Toggle`,surface:`canonical`,hasChildren:!0,props:fo,icon:`ChevronRight`,category:`content`,displayName:`Toggle`,description:"Standalone expand/collapse block (Notion-style). Same render + props as `<Accordion>` — pick whichever vocabulary matches the vault.",searchTerms:[`toggle`,`collapsible`,`expand`,`details`,`disclosure`,`fold`],exampleBody:`Body content revealed when the toggle is expanded.`,serialize:(e,t)=>io(`Toggle`,e,t,fo)},{name:`Tabs`,surface:`canonical`,hasChildren:!0,emptyChildName:`Tab`,props:bo,icon:`LayoutPanelTop`,category:`content`,displayName:`Tabs`,description:"Horizontal tab strip + active panel below. Each `<Tab>` child is one panel; clickable pills at the top switch the active one. Active selection is ephemeral (resets on reload).",searchTerms:[`tabs`,`tabbed`,`panels`,`tabgroup`,`switcher`],exampleBody:`<Tab label="One">Body of the first tab panel.</Tab>
|
|
2
|
+
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./preload-helper-Chd9yIcd.js";import{t as n}from"./jsx-runtime-BUgB2tll.js";import{t as r}from"./react-f2sANaYj.js";import{r as i}from"./dist-Nvb76hAm.js";import{n as a}from"./dist-PQ5KMVDh.js";import{t as o}from"./react-dom-DPxgxlDT.js";import{t as s}from"./compiler-runtime-BfE3aGVn.js";import{n as c,t as l}from"./with-selector-zVo3Fruj.js";import{a as u,d,i as f,l as p,r as m,u as h}from"./floating-ui.dom-DkPPH5vF.js";import{a as g,d as _,g as v,i as y,l as b,n as x,o as S,r as C,t as w,u as T}from"./constants-upload-CVKO8P4d.js";import{$ as ee,A as E,B as te,C as ne,F as re,G as ie,K as D,L as O,N as ae,P as oe,Q as se,R as ce,S as le,T as ue,U as de,V as fe,W as pe,X as me,Y as he,_ as ge,a as _e,at as k,b as ve,bt as A,c as ye,ct as j,d as be,et as xe,f as Se,g as Ce,gt as we,h as Te,ht as Ee,it as M,k as N,l as De,mt as Oe,n as P,nt as ke,o as F,ot as Ae,p as je,q as Me,r as Ne,rt as Pe,s as Fe,st as Ie,t as Le,tt as Re,u as ze,ut as Be,v as Ve,vt as I,w as He,x as Ue,y as We,z as L}from"./dist-Dc8tD1th.js";import{t as Ge}from"./dist-C_FzPxEX2.js";import{t as Ke}from"./util-doc-name-DRKmy6g9.js";import{n as qe}from"./_envelope-q8XHEv4O-C-Qnl5Tu.js";import{C as Je,a as Ye,g as Xe,w as Ze}from"./schemas-api-CD98jV86.js";import{t as Qe}from"./note-window-mode-CI3Yju9B.js";import{i as $e}from"./use-apply-config-theme-CYFG76sS.js";import{t as et}from"./createLucideIcon-DdBzwsHe.js";import{t as tt}from"./folder-open-COGOeTzI.js";import{t as nt}from"./trash-2-CchZ0T47.js";import{n as rt,r as it}from"./structural-freshness-CIbkMFA3-CWi_lyiW.js";import{c as at,d as ot,l as st}from"./doc-hash-BJkweiX9.js";import{_ as ct,b as lt,d as ut,f as dt,g as ft,h as pt,j as mt,k as ht,o as gt,p as _t,v as vt,w as yt,x as bt}from"./navigation-targets-pcYc32Il.js";import{t as xt}from"./doc-paths-cEiFVCxr.js";import{$ as St,A as Ct,B as wt,C as Tt,E as Et,G as Dt,I as Ot,J as kt,K as At,M as jt,N as Mt,P as Nt,Q as Pt,R as Ft,S as It,T as Lt,W as Rt,X as zt,_ as Bt,at as Vt,b as Ht,c as Ut,d as Wt,et as Gt,f as Kt,g as qt,h as Jt,it as Yt,j as Xt,l as Zt,m as Qt,nt as $t,ot as en,p as tn,q as nn,s as rn,tt as an,u as on,w as sn,x as cn,y as ln,z as un}from"./config-provider-CogbMSvj.js";import{At as dn,Ct as fn,E as pn,F as mn,G as hn,I as R,J as gn,K as _n,M as vn,Mt as yn,Nt as bn,P as z,Tt as xn,X as Sn,a as B,c as Cn,f as wn,l as Tn,lt as En,o as Dn,r as On,t as kn,ut as An}from"./dist-D2SphF3p.js";import{c as jn,d as Mn,f as V,l as Nn,n as Pn,p as Fn,r as In,s as Ln,t as Rn,u as zn}from"./cm-theme-DsKCc8Du.js";import{A as Bn,C as Vn,E as Hn,H as Un,I as Wn,L as Gn,M as Kn,N as qn,O as Jn,P as Yn,R as H,S as Xn,T as Zn,_ as Qn,a as $n,b as er,c as tr,h as nr,k as rr,m as ir,o as ar,t as or,x as sr,y as cr,z as lr}from"./lib-CY2yz3tg.js";import{t as ur}from"./ccount-Cc4-GkFF.js";import{n as dr,r as fr}from"./lib-D0X048Zn.js";import{c as pr,f as mr,n as hr,r as gr,t as _r,u as vr}from"./trim-lines-DUSR4OI1.js";import{u as yr}from"./space-separated-tokens-B5lqTxi5.js";import{n as br,t as xr}from"./syntax-sfl_d8Li.js";import{i as Sr,n as Cr}from"./page-list-cache-C-bM1SMu.js";import{t as wr}from"./documents-fetch-Y7Dt9_Tn.js";import{i as Tr,n as Er,r as Dr,t as Or}from"./dist-DseqKdAU.js";import{n as kr,r as Ar,t as jr}from"./dist-BxTTaZ5o.js";import{t as Mr}from"./dist-CjyZozAk.js";import{n as Nr}from"./dist-C2Kstufe.js";import{n as Pr}from"./dist-BvhrN0Uj.js";import{n as Fr}from"./dist-D5mDCusD.js";import{i as Ir,n as Lr,r as Rr}from"./dist-BpU-J2LR.js";import{n as zr}from"./dist-BkE9d74i.js";import{t as Br}from"./stex-CUzil_LB.js";import{n as Vr,r as Hr}from"./external-link-CldCnbtR.js";var Ur=et(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),Wr=et(`file-text`,[[`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:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Gr=et(`film`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]),Kr=et(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),qr=et(`volume-2`,[[`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`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]),U=n(),W=e(r(),1),Jr=e(o(),1),Yr=s(),Xr=c();function Zr(e){return e.editorView}var Qr=new Map([[32,` `],[9,` `],[160,`\xA0`]]);function $r(e){let t=/^&#(x[0-9A-Fa-f]+|X[0-9A-Fa-f]+|[0-9]+);$/.exec(e);if(!t)return null;let n=t[1],r=n[0]===`x`||n[0]===`X`,i=Number.parseInt(r?n.slice(1):n,r?16:10);return Number.isNaN(i)?null:i}function ei(e){let t=$r(e);return t!==null&&Qr.has(t)}function ti(e){let t=$r(e);return t===null?null:Qr.get(t)??null}var ni=/&#(?:x[0-9A-Fa-f]+|X[0-9A-Fa-f]+|[0-9]+);/g;function ri(e){ni.lastIndex=0;let t=e.match(ni);if(t===null||t.join(``)!==e)return null;let n=``;for(let e of t){let t=ti(e);if(t===null)return null;n+=t}return n}var ii=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},ai=/[\uD800-\uDBFF]/,oi=/[\uDC00-\uDFFF]/,si=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&ai.test(e[n-1])&&n--;r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1];)r++;return r>0&&oi.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},ci=(e,t)=>e>>>t|e<<32-t,li=e=>ci(e,2)^ci(e,13)^ci(e,22),ui=e=>ci(e,6)^ci(e,11)^ci(e,25),di=e=>ci(e,7)^ci(e,18)^e>>>3,fi=e=>ci(e,17)^ci(e,19)^e>>>10,pi=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),mi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),hi=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(mi),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=fi(t[e-2])+t[e-7]+di(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7];for(let e=0,u,d;e<64;e++)u=l+ui(o)+(o&s^~o&c)+pi[e]+t[e]>>>0,d=li(n)+(n&r^n&i^r&i)>>>0,l=c,c=s,s=o,o=a+u>>>0,a=i,i=r,r=n,n=u+d>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=o,e[5]+=s,e[6]+=c,e[7]+=l}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3<e.length;n++)this._W[n]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!=0){for(this._W.fill(0,n,16);t<e.length;)this._W[n]|=e[t]<<(3-t%4)*8,t++;this._W[n]|=128<<(3-t%4)*8}this._updateHash()}let n=t%64!=0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let n=3;n>=0&&t<e.length;n--)this._W[r]|=e[t++]<<n*8;n||(this._W[r-(t%4==0?0:1)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/Gt,this._W[15]=e.byteLength*8,this._updateHash();let i=new Uint8Array(32);for(let e=0;e<this._H.length;e++)for(let t=0;t<4;t++)i[e*4+t]=this._H[e]>>>(3-t)*8;return i}},gi=e=>new hi().digest(e),G=new k(`y-sync`),_i=new k(`y-undo`),vi=new k(`yjs-cursor`),yi=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},bi=e=>Dt(yi(gi(Rt(e)))),xi=()=>({mapping:new Map,isOMark:new Map}),Si=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!jt(t.ds,e.id),Ci=[{light:`#ecd44433`,dark:`#ecd444`}],wi=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=Yt();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,zt(t))}return e.get(n)},Ti=(e,{colors:t=Ci,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new ki(e,a),c=new M({props:{editable:e=>{let t=G.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:G,state:{init:(i,a)=>({type:e,doc:e.doc,binding:s,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(e,t)=>{let n=e.getMeta(G);if(n!==void 0){t=Object.assign({},t);for(let e in n)t[e]=n[e]}return t.addToHistory=e.getMeta(`addToHistory`)!==!1,t.isChangeOrigin=n!==void 0&&!!n.isChangeOrigin,t.isUndoRedoOperation=n!==void 0&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,s.prosemirrorView!==null&&n!==void 0&&(n.snapshot!=null||n.prevSnapshot!=null)&&un(0,()=>{s.prosemirrorView!=null&&(n.restore==null?s._renderSnapshot(n.snapshot,n.prevSnapshot,t):(s._renderSnapshot(n.snapshot,n.snapshot,t),delete t.restore,delete t.snapshot,delete t.prevSnapshot,s.mux(()=>{s._prosemirrorChanged(s.prosemirrorView.state.doc)})))}),t}},view:e=>(s.initView(e),a??s._forceRerender(),i(),{update:()=>{let t=c.getState(e.state);if(t.snapshot==null&&t.prevSnapshot==null&&(o||e.state.doc.content.findDiffStart(e.state.doc.type.createAndFill().content)!==null)){if(o=!0,t.addToHistory===!1&&!t.isChangeOrigin){let t=_i.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}s.mux(()=>{t.doc.transact(n=>{n.meta.set(`addToHistory`,t.addToHistory),s._prosemirrorChanged(e.state.doc)},G)})}},destroy:()=>{s.destroy()}})});return c},Ei=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new ke(e.doc));else if(t.type===`node`){let r=sa(n.doc,n.type,t.anchor,n.mapping);e.setSelection(Di(e,r))}else{let r=sa(n.doc,n.type,t.anchor,n.mapping),i=sa(n.doc,n.type,t.head,n.mapping);r!==null&&i!==null&&e.setSelection(j.between(e.doc.resolve(r),e.doc.resolve(i)))}},Di=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?Pe.create(e.doc,t):j.near(n)},Oi=(e,t)=>({type:t.selection.jsonID,anchor:aa(t.selection.anchor,e.type,e.mapping),head:aa(t.selection.head,e.type,e.mapping)}),ki=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=ii(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Oi(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta(`addToHistory`,!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(At&&this._domSelectionInView===null&&(un(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;let t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);let n=t.getBoundingClientRect(),r=wt.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(e,t){t||=Et(It(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(G,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>ji(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new A(I.from(e),0,0));t.setMeta(G,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.prosemirrorView.state.selection:null,t=this.type.toArray().map(e=>ji(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new A(I.from(t),0,0));if(e){let t=$t(an(e.anchor,0),n.doc.content.size),r=$t(an(e.head,0),n.doc.content.size);n.setSelection(j.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(G,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=Ot(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&St(),r=new on({gc:!1}),ln(r,t),t=Ot(r),ln(r,e),e=Ot(r),i._item===null){let e=Array.from(this.doc.share.keys()).find(e=>this.doc.share.get(e)===this.type);i=r.getXmlFragment(e)}else{let e=r.store.clients.get(i._item.id.client)??[];i=e[Ct(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{Nt(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:wi(n.colorMapping,n.colors,r)}},s=Ft(i,new tn(t.ds,e.sv)).map(n=>!n._item.deleted||Si(n._item,e)||Si(n._item,t)?ji(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,o):null).filter(e=>e!==null),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new A(I.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(G,{isChangeOrigin:!0}))},G)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=G.getState(this.prosemirrorView.state);if(e.length===0||n.snapshot!=null||n.prevSnapshot!=null){this.renderSnapshot(n.snapshot,n.prevSnapshot);return}this.mux(()=>{let e=(e,t)=>this.mapping.delete(t);Nt(t,t.deleteSet,e=>{if(e.constructor===Wt){let t=e.content.type;t&&this.mapping.delete(t)}}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>Ai(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new A(I.from(n),0,0));Ei(r,this.beforeTransactionSelection,this),r=r.setMeta(G,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof Qt}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{Qi(this.doc,this.type,e,this),this.beforeTransactionSelection=Oi(this,this.prosemirrorView.state)},G)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.on(`afterAllTransactions`,this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.off(`afterAllTransactions`,this.afterAllTransactions))}},Ai=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof qt)return ji(e,t,n,r,i,a);throw Pt()}return o},ji=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof qt){let s=Ai(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof Jt&&!s._item.deleted&&s._item.id.client===s.doc.clientID&&(e.applyDelta([{retain:e.length},...s.toDelta()]),s.doc.transact(e=>{s._item.delete(e)}));let c=Mi(e,t,n,r,i,a);c!==null&&c.forEach(e=>{e!==null&&o.push(e)})}};r===void 0||i===void 0?e.toArray().forEach(s):Ft(e,new tn(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(Si(e._item,r)?Si(e._item,i)||(s.ychange=a?a(`added`,e._item.id):{type:`added`}):s.ychange=a?a(`removed`,e._item.id):{type:`removed`});let c=Vi(s),l=Xi(c.marks,t),u=t.node(e.nodeName,c.plain,o,l.length?l:void 0);return n.mapping.set(e,u),u}catch(r){console.warn(`[y-prosemirror] schema.node(`+e.nodeName+`) threw:`,String(r&&r.message||r));let i=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};if(t.nodes[e.nodeName]&&t.nodes[e.nodeName].spec&&t.nodes[e.nodeName].spec.inline)i.inline++;else if(i.block++,t.nodes.rawMdxFallback)try{let i=t.node(`rawMdxFallback`,{reason:String(r&&r.message||r)},[t.text(e.nodeName)]);return n.mapping.set(e,i),i}catch(e){console.warn(`[y-prosemirror] rawMdxFallback substitution also failed:`,String(e&&e.message||e))}return n.mapping.delete(e),null}},Mi=(e,t,n,r,i,a)=>{let o=[],s=e.toDelta(r,i,a);try{for(let e=0;e<s.length;e++){let n=s[e];o.push(t.text(n.insert,Xi(n.attributes,t)))}}catch(e){console.warn(`[y-prosemirror] schema.text() threw:`,String(e&&e.message||e));let t=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};return t.inline++,null}return o},Ni=(e,t)=>{let n=new Bt,r=e.map(e=>({insert:e.text,attributes:Zi(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},Pi=(e,t)=>{let n=new qt(e.type.name);for(let t in e.attrs){let r=e.attrs[t];r!==null&&t!==`ychange`&&n.setAttribute(t,r)}let r=Zi(e.marks||[],t);for(let e in r)n.setAttribute(Bi+e,{...r[e]});return n.insert(0,Ri(e).map(e=>Fi(e,t))),t.mapping.set(n,e),n},Fi=(e,t)=>e instanceof Array?Ni(e,t):Pi(e,t),Ii=e=>typeof e==`object`&&!!e,Li=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]!==null),r=n.length===Object.keys(t).filter(e=>t[e]!==null).length;for(let i=0;i<n.length&&r;i++){let a=n[i],o=e[a],s=t[a];r=a===`ychange`||o===s||Ii(o)&&Ii(s)&&Li(o,s)}return r},Ri=e=>{let t=e.content.content,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.isText){let r=[];for(let n=t[e];e<t.length&&n.isText;n=t[++e])r.push(n);e--,n.push(r)}else n.push(r)}return n},zi=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&kt(e.attributes||{}).length===t[n].marks.length&&nn(e.attributes,(e,r)=>{let i=Yi(r),a=t[n].marks;return a.find(e=>e.type.name===i)?Li(e,a.find(e=>e.type.name===i)?.attrs):!1}))},Bi=`ymark:`,Vi=e=>{let t={},n={};for(let r in e)r.startsWith(Bi)?n[r.slice(6)]=e[r]:t[r]=e[r];return{plain:t,marks:n}},Hi=(e,t)=>{let n=Object.keys(e);return n.length===t.length?n.every(n=>{let r=Yi(n),i=t.find(e=>e.type.name===r);return i?Li(e[n],i.attrs):!1}):!1},Ui=(e,t)=>{if(e instanceof qt&&!(t instanceof Array)&&$i(e,t)){let n=Ri(t),r=Vi(e.getAttributes());return e._length===n.length&&Hi(r.marks,t.marks)&&Li(r.plain,t.attrs)&&e.toArray().every((e,t)=>Ui(e,n[t]))}return e instanceof Bt&&t instanceof Array&&zi(e,t)},Wi=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),Gi=(e,t,n)=>{let r=e.toArray(),i=Ri(t),a=i.length,o=r.length,s=$t(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(Wi(n.mapping.get(e),t))u=!0;else if(!Ui(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(Wi(n.mapping.get(e),t))u=!0;else if(!Ui(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},Ki=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Ut?t+=n.content.str:n.content instanceof rn&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},qi=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=Ki(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,Zi(e.marks,n))})),{insert:o,remove:s,index:c}=si(i,a.map(e=>e.insert).join(``));e.delete(c,s),e.insert(c,o),e.applyDelta(a.map(e=>({retain:e.insert.length,attributes:e.attributes})))},Ji=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Yi=e=>Ji.exec(e)?.[1]??e,Xi=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(Yi(r),e[r]));return n},Zi=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=en(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${bi(e.toJSON())}`:e.type.name]=e.attrs}}),n},Qi=(e,t,n,r)=>{if(t instanceof qt&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof qt){let e=t.getAttributes(),i=n.attrs;for(let n in i)i[n]===null?t.removeAttribute(n):e[n]!==i[n]&&n!==`ychange`&&t.setAttribute(n,i[n]);for(let n in e)i[n]===void 0&&!n.startsWith(Bi)&&t.removeAttribute(n);let a=Zi(n.marks||[],r);for(let n in a){let r=e[Bi+n];(r===void 0||!Li(r,a[n]))&&t.setAttribute(Bi+n,{...a[n]})}for(let n in e)n.startsWith(Bi)&&a[n.slice(6)]===void 0&&t.removeAttribute(n)}let i=Ri(n),a=i.length,o=t.toArray(),s=o.length,c=$t(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!Wi(r.mapping.get(e),t))if(Ui(e,t))r.mapping.set(e,t);else break}for(;u+l+1<c;u++){let e=o[s-u-1],t=i[a-u-1];if(!Wi(r.mapping.get(e),t))if(Ui(e,t))r.mapping.set(e,t);else break}e.transact(()=>{for(;s-l-u>0&&a-l-u>0;){let n=o[l],c=i[l],d=o[s-u-1],f=i[a-u-1];if(n instanceof Bt&&c instanceof Array)zi(n,c)||qi(n,c,r),l+=1;else{let i=n instanceof qt&&$i(n,c),a=d instanceof qt&&$i(d,f);if(i&&a){let e=Gi(n,c,r),t=Gi(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(Qi(e,n,c,r),l+=1):a?(Qi(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[Fi(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof Bt?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):n>0&&(t.slice(l,l+n).forEach(e=>r.mapping.delete(e)),t.delete(l,n)),l+u<a){let e=[];for(let t=l;t<a-u;t++)e.push(Fi(i[t],r));t.insert(l,e)}},G)},$i=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,ea=null,ta=class{constructor(e,t,n){this.view=e,this.key=t,this.value=n}apply(){let e=G.getState(this.view.state);if(e&&e.binding&&!e.binding.isDestroyed){let e=this.view.state.tr;e.setMeta(this.key,this.value),this.view.dispatch(e)}}},na=class e{constructor(e=[]){this.entries=e}getFirst(){return this.entries[0]}dequeueFirst(){return this.entries.shift()}isEmpty(){return this.entries.length===0}static fromViewsToUpdate(){let t=ea;ea=null;let n=[];return t.forEach((e,t)=>{e.forEach((e,r)=>{n.push(new ta(t,r,e))})}),new e(n)}},ra=(e=na.fromViewsToUpdate(),t=!1)=>{let n=!0;for(;!e.isEmpty();){let r=e.getFirst();try{r.apply()}catch(r){if(r instanceof RangeError){t&&n&&e.dequeueFirst(),e.isEmpty()||un(0,()=>ra(e,!0));return}throw r}n=!1,e.dequeueFirst()}},ia=(e,t,n)=>{ea||(ea=new Map,un(0,ra)),en(ea,e,Vt).set(t,n)},aa=(e,t,n)=>{if(e===0)return Lt(t,0,-1);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof Bt){if(r._length>=e)return Lt(r,e,-1);if(e-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:r._item.next.content.type)}}else{let i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&e<i)r=r._first.content.type,e--;else{if(e===1&&r._length===0&&i>1)return new Kt(r._item===null?null:r._item.id,r._item===null?Xt(r):null,null);if(e-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(e===0)return r=r._item===null?r:r._item.parent,new Kt(r._item===null?null:r._item.id,r._item===null?Xt(r):null,null);do r=r._item.parent,e--;while(r!==t&&r._item.next===null);r!==t&&(r=r._item.next.content.type)}}}if(r===null)throw St();if(e===0&&r.constructor!==Bt&&r!==t)return oa(r._item.parent,r._item)}return Lt(t,t._length,-1)},oa=(e,t)=>{let n=null,r=null;return e._item===null?r=Xt(e):n=Tt(e._item.id.client,e._item.id.clock),new Kt(n,r,t.id)},sa=(e,t,n,r)=>{let i=cn(n,e);if(i===null||i.type!==t&&!Mt(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===Bt)o=i.index;else if(a._item===null||!a._item.deleted){let e=a._first,t=0;for(;t<a._length&&t<i.index&&e!==null;){if(!e.deleted){let n=e.content.type;if(t++,n instanceof Bt)o+=n._length;else{let e=r.get(n);if(e==null)return null;o+=e.nodeSize}}e=e.right}o+=1}for(;a!==t&&a._item!==null;){let e=a._item.parent;if(e._item===null||!e._item.deleted){o+=1;let t=e._first;for(;t!==null;){let e=t.content.type;if(e===a)break;if(!t.deleted)if(e instanceof Bt)o+=e._length;else{let t=r.get(e);if(t==null)return null;o+=t.nodeSize}t=t.right}}a=e}return o-1},ca=(e,t)=>{let n=e.toArray().map(e=>ji(e,t,xi())).filter(e=>e!==null);return I.fromArray(n)},la=(e,t)=>t.topNodeType.create(null,ca(e,t)),ua=(e,t)=>{let n=xi(),r=e.toArray().map(e=>ji(e,t,n)).filter(e=>e!==null);return{doc:t.topNodeType.create(null,I.fromArray(r)),meta:n,mapping:n.mapping}},da=(e,t,n)=>e!==t,fa=e=>{let t=document.createElement(`span`);t.classList.add(`ProseMirror-yjs-cursor`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);let r=document.createTextNode(``),i=document.createTextNode(``);return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(i,null),t},pa=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),ma=/^#[0-9a-fA-F]{6}$/,ha=(e,t,n,r,i)=>{let a=G.getState(e);if(a==null||a.doc==null||a.binding==null)return me.create(e.doc,[]);let o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?me.create(e.doc,[]):(t.getStates().forEach((t,c)=>{if(n(o.clientID,c,t)&&t.cursor!=null){let n=t.user||{};n.color==null?n.color=`#ffa500`:ma.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`;let l=sa(o,a.type,sn(t.cursor.anchor),a.binding.mapping),u=sa(o,a.type,sn(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=an(e.doc.content.size-1,0);l=$t(l,t),u=$t(u,t),s.push(he.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=$t(l,u),o=an(l,u);s.push(he.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),me.create(e.doc,s))},ga=(e,{awarenessStateFilter:t=da,cursorBuilder:n=fa,selectionBuilder:r=pa,getSelection:i=e=>e.selection}={},a=`cursor`)=>new M({key:vi,state:{init(i,a){return ha(a,e,t,n,r)},apply(i,a,o,s){let c=G.getState(s),l=i.getMeta(vi);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?ha(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>vi.getState(e)},view:t=>{let n=()=>{t.docView&&ia(t,vi,{awarenessUpdated:!0})},r=()=>{let n=G.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=aa(o.anchor,n.type,n.binding.mapping),c=aa(o.head,n.type,n.binding.mapping);(r.cursor==null||!Ht(sn(r.cursor.anchor),s)||!Ht(sn(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&sa(n.doc,n.type,sn(r.cursor.anchor),n.binding.mapping)!==null&&e.setLocalStateField(a,null)};return e.on(`change`,n),t.dom.addEventListener(`focusin`,r),t.dom.addEventListener(`focusout`,r),{update:r,destroy:()=>{t.dom.removeEventListener(`focusin`,r),t.dom.removeEventListener(`focusout`,r),e.off(`change`,n),e.setLocalStateField(a,null)}}}}),_a=e=>{let t=_i.getState(e).undoManager;if(t!=null)return t.undo(),!0},va=e=>{let t=_i.getState(e).undoManager;if(t!=null)return t.redo(),!0},ya=new Set([`paragraph`]),ba=(e,t)=>!(e instanceof Wt)||!(e.content instanceof Zt)||!(e.content.type instanceof Jt||e.content.type instanceof qt&&t.has(e.content.type.nodeName))||e.content.type._length===0,xa=({protectedNodes:e=ya,trackedOrigins:t=[],undoManager:n=null}={})=>new M({key:_i,state:{init:(r,i)=>{let a=G.getState(i),o=n||new Qt(a.type,{trackedOrigins:new Set([G].concat(t)),deleteFilter:t=>ba(t,e),captureTransaction:e=>e.meta.get(`addToHistory`)!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(e,t,n,r)=>{let i=G.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:Oi(i,n),hasUndoOps:o,hasRedoOps:s}:o!==t.hasUndoOps||s!==t.hasRedoOps?Object.assign({},t,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):t}},view:e=>{let t=G.getState(e.state),n=_i.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,_i.getState(e.state).prevSel)}),n.on(`stack-item-popped`,({stackItem:e})=>{let n=t.binding;n&&(n.beforeTransactionSelection=e.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy()}}}}),Sa=new Map,Ca=new Set;function wa(){for(let e of Ca)e()}function Ta(e,t,n){Sa.set(e,{view:t,host:n}),wa()}function Ea(e,t){Sa.get(e)?.view===t&&(Sa.delete(e),wa())}function Da(e){let t=Sa.get(e);return t?.host===`sourceEditor`?t.view:null}function Oa(e){return Sa.get(e)??null}function ka(e){return Ca.add(e),()=>{Ca.delete(e)}}var Aa=new WeakMap,ja=new WeakMap;function Ma(e,t){Aa.set(e,t)}function Na(e){return Aa.get(e)??!1}function Pa(e,t){ja.set(e,t)}function Fa(e){return ja.get(e)??!1}function Ia(e){return!Na(e)}var La=`autonomousFragmentEdit/swap`;function Ra(e){return e.setMeta(La,!0)}function za(e,t,n){return n===t.textContent?Ra(e):e}function Ba(e){return e.getMeta(La)===!0}function Va(e){return!e.getMeta(G)&&!Ba(e)}var Ha=/^[A-Za-z0-9]{20,}$/,Ua=/^(?:\d+s?|(?:\d+h)?(?:\d+m)?(?:\d+s)?)$/;function Wa(e){let t=e.toLowerCase();return t===`loom.com`||t===`www.loom.com`}function Ga(e){let t=e.pathname.match(/^\/(?:share|embed)\/([A-Za-z0-9]+)\/?$/);if(!t)return null;let n=t[1]??``;return Ha.test(n)?n:null}function Ka(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`||!Wa(t.hostname))return null;let n=Ga(t);if(!n)return null;let r=t.searchParams.get(`t`);return{id:n,startRaw:r&&r.length>0&&Ua.test(r)?r:null}}function qa(e){return Ka(e)!==null}function Ja(e){let t=e.toLowerCase();return t===`vimeo.com`||t===`www.vimeo.com`||t===`player.vimeo.com`}function Ya(e){if(typeof e!=`string`||e.length===0)return!1;let t;try{t=new URL(e)}catch{return!1}return t.protocol!==`http:`&&t.protocol!==`https:`?!1:Ja(t.hostname)}var Xa=/^[A-Za-z0-9_-]{11}$/;function Za(e){let t=e.toLowerCase();return t===`youtube.com`||t===`www.youtube.com`||t===`m.youtube.com`||t===`music.youtube.com`||t===`youtu.be`||t===`youtube-nocookie.com`||t===`www.youtube-nocookie.com`}function Qa(e){if(e.length===0)return null;if(/^[0-9]+$/.test(e)){let t=Number.parseInt(e,10);return t>0?t:null}let t=e.match(/^(?:([0-9]+)h)?(?:([0-9]+)m)?(?:([0-9]+)s?)?$/);if(!t)return null;let n=t[1]?Number.parseInt(t[1],10):0,r=t[2]?Number.parseInt(t[2],10):0,i=t[3]?Number.parseInt(t[3],10):0,a=n*3600+r*60+i;return a>0?a:null}function $a(e){if(e.hostname.toLowerCase()===`youtu.be`){let t=e.pathname.replace(/^\//,``).split(`/`)[0]??``;return Xa.test(t)?t:null}if(e.pathname===`/watch`){let t=e.searchParams.get(`v`)??``;return Xa.test(t)?t:null}let t=e.pathname.match(/^\/(?:embed|shorts|v)\/([A-Za-z0-9_-]{11})\/?$/);return t?t[1]??null:null}function eo(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`||!Za(t.hostname))return null;let n=$a(t);if(!n)return null;let r=t.searchParams.get(`t`)??t.searchParams.get(`start`)??``;return{id:n,startSeconds:r.length>0?Qa(r):null,noCookie:t.hostname.toLowerCase().endsWith(`youtube-nocookie.com`)}}function to(e,t){let n=Array.isArray(e.attrs.attributes)?e.attrs.attributes.filter(e=>typeof e==`object`&&!!e&&`type`in e):[],r=e.attrs.props??{},i=new Map,a=new Set;if(t)for(let e of t)e.omitOnDefault===!0&&`defaultValue`in e&&e.defaultValue!==void 0&&i.set(e.name,e.defaultValue),e.type===`string`&&e.required===!1&&e.defaultValue===void 0&&a.add(e.name);for(let[e,t]of Object.entries(r)){let r=n.findIndex(t=>t.type===`mdxJsxAttribute`&&t.name===e);if(i.has(e)&&Object.is(i.get(e),t)){r>=0&&n.splice(r,1);continue}if(a.has(e)&&t===``){r>=0&&n.splice(r,1);continue}if(r>=0){let e=n[r];if(e.type===`mdxJsxAttribute`&&e.value!=null&&typeof e.value==`object`&&e.value.type===`mdxJsxAttributeValueExpression`&&no(e.value.value,t))continue}let o=ro(e,t);r>=0?n[r]=o:n.push(o)}return n}function no(e,t){try{return JSON.stringify(JSON.parse(e))===JSON.stringify(t)}catch{return!1}}function ro(e,t){if(t===!0)return{type:`mdxJsxAttribute`,name:e,value:null};if(t===!1)return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:`false`}};if(t==null)return{type:`mdxJsxAttribute`,name:e,value:null};if(typeof t==`string`)return{type:`mdxJsxAttribute`,name:e,value:t};if(typeof t==`number`)return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:JSON.stringify(t)}};if(typeof t==`object`){let n;try{n=JSON.stringify(t)}catch{n=String(t)}return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:n}}}return{type:`mdxJsxAttribute`,name:e,value:String(t)}}function io(e,t,n,r){return{type:`mdxJsxFlowElement`,name:e,attributes:to(t,r),children:n.all(t),data:{}}}function ao(e,t,n){let r=t.attrs.props?.children;return{type:`mdxJsxTextElement`,name:e,attributes:to(t,n),children:typeof r==`string`&&r!==``?[{type:`text`,value:r}]:[],data:{}}}var oo=[{name:`type`,type:`enum`,enumValues:[`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`],defaultValue:`note`,required:!1,description:`Callout variant`},{name:`title`,type:`string`,required:!1,description:`Optional heading shown above the body`},{name:`icon`,type:`string`,required:!1,advanced:!0,description:"Custom lucide icon override (e.g. `lucide:Lightbulb`)",iconPicker:!0},{name:`color`,type:`string`,required:!1,advanced:!0,description:"Optional accent color override (hex — e.g. `#F05032`)",colorPicker:!0},{name:`collapsible`,type:`boolean`,required:!1,defaultValue:!1,advanced:!0,description:"Render as a foldable `<details>` (Obsidian `[!TYPE]+/-`)"},{name:`defaultOpen`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,description:`When collapsible, start in the open state`,hideWhen:e=>e.collapsible!==!0},{name:`children`,type:`reactnode`,required:!0,description:`Callout content`}],so=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Image source URL`,accept:x,autoFocus:!0},{name:`alt`,type:`string`,required:!0,description:`Alt text`},{name:`width`,type:`number`,required:!1,advanced:!0,description:`Image width`},{name:`height`,type:`number`,required:!1,advanced:!0,description:`Image height`},{name:`srcset`,type:`string`,required:!1,advanced:!0,description:`Responsive image candidate set (e.g. "x.png 1x, y.png 2x")`},{name:`sizes`,type:`string`,required:!1,advanced:!0,description:`Responsive image sizes hint paired with srcset`},{name:`loading`,type:`enum`,enumValues:[`eager`,`lazy`],defaultValue:`lazy`,required:!1,advanced:!0,omitOnDefault:!0,description:`Native img loading strategy (defaults to lazy)`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`decoding`,type:`enum`,enumValues:[`sync`,`async`,`auto`],defaultValue:`auto`,required:!1,advanced:!0,omitOnDefault:!0,description:`Hint for how the browser should decode the image`},{name:`fetchpriority`,type:`enum`,enumValues:[`high`,`low`,`auto`],defaultValue:`auto`,required:!1,advanced:!0,omitOnDefault:!0,description:`Resource fetch priority hint`},{name:`crossorigin`,type:`enum`,enumValues:[`anonymous`,`use-credentials`],required:!1,advanced:!0,description:`CORS mode for the image fetch`},{name:`referrerpolicy`,type:`string`,required:!1,advanced:!0,description:`Referrer policy for the image fetch (HTML referrerpolicy values)`},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`,hidden:!0}],co=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Embedded page URL (must start with http:// or https://)`,autoFocus:!0},{name:`title`,type:`string`,required:!1,description:`Iframe title (accessible label for screen readers)`},{name:`width`,type:`string`,required:!1,advanced:!0,description:`Embed width as a CSS length (e.g. "100%", "640px")`,cssLengthInput:!0},{name:`height`,type:`string`,required:!1,advanced:!0,description:`Embed height as a CSS length (e.g. "26rem", "480px")`,cssLengthInput:!0},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`,hidden:!0}],lo=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Video source URL`,accept:y,autoFocus:!0},{name:`controls`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,omitOnDefault:!0,description:`Show native HTML5 video controls (defaults to true)`,hideWhen:e=>typeof e.src==`string`&&(Ya(e.src)||qa(e.src))},{name:`autoplay`,type:`boolean`,required:!1,advanced:!0,description:`Begin playback as soon as possible (usually requires muted)`},{name:`poster`,type:`string`,required:!1,advanced:!0,description:`Poster image URL shown before playback`,accept:x,hideWhen:e=>typeof e.src==`string`&&(Ya(e.src)||qa(e.src))},{name:`width`,type:`number`,required:!1,advanced:!0,description:`Video width`},{name:`height`,type:`number`,required:!1,advanced:!0,description:`Video height`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`muted`,type:`boolean`,required:!1,advanced:!0,description:`Mute audio on load`},{name:`loop`,type:`boolean`,required:!1,advanced:!0,description:`Restart from the beginning when playback ends`,hideWhen:e=>typeof e.src==`string`&&qa(e.src)},{name:`playsinline`,type:`boolean`,required:!1,advanced:!0,description:`Play inline on iOS rather than entering fullscreen`,hideWhen:e=>typeof e.src==`string`&&(Ya(e.src)||qa(e.src))},{name:`preload`,type:`enum`,enumValues:[`none`,`metadata`,`auto`],required:!1,advanced:!0,description:`Hint for how much of the video to preload`,hideWhen:e=>typeof e.src==`string`&&(eo(e.src)!==null||Ya(e.src)||qa(e.src))},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`,hidden:!0}],uo=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Audio source URL`,accept:w,autoFocus:!0},{name:`controls`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,omitOnDefault:!0,description:`Show native HTML5 audio controls (defaults to true)`},{name:`autoplay`,type:`boolean`,required:!1,advanced:!0,description:`Begin playback as soon as possible (usually requires muted)`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`muted`,type:`boolean`,required:!1,advanced:!0,description:`Mute audio on load`},{name:`loop`,type:`boolean`,required:!1,advanced:!0,description:`Restart from the beginning when playback ends`},{name:`preload`,type:`enum`,enumValues:[`none`,`metadata`,`auto`],required:!1,advanced:!0,description:`Hint for how much of the audio to preload`}],fo=[{name:`title`,type:`string`,required:!0,description:`Heading shown inside the <summary>`},{name:`defaultOpen`,type:`boolean`,required:!1,defaultValue:!1,description:`When true, the block renders expanded on initial load`},{name:`icon`,type:`string`,required:!1,advanced:!0,description:"Custom lucide icon override (e.g. `lucide:Rocket`)",iconPicker:!0},{name:`description`,type:`string`,required:!1,advanced:!0,description:`Optional subtitle rendered below the title inside <summary>`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#advanced-options`)"},{name:`name`,type:`string`,required:!1,advanced:!0,description:`HTML5 <details name=> group — siblings with the same name are mutually exclusive`}],po=[oo[0],oo[1],oo[4],oo[5],oo[6]],mo=[so[0],so[1],so[7]],ho=[fo[0],fo[1],fo[4],fo[5]],go=[{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`,`justify`],required:!1,defaultValue:`center`,description:"Block alignment from the `<div align>` attribute."},{name:`tag`,type:`string`,required:!1,defaultValue:`div`,hidden:!0,description:`Source wrapper tag (div or center).`},{name:`sourceAttrs`,type:`string`,required:!1,defaultValue:``,hidden:!0,description:`Raw opener-tag attribute bytes preserved for round-trip.`}],_o=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Alt text (Obsidian alias syntax: `![[file.png|alt text]]`)"}],vo=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Title text (Obsidian alias syntax: `![[clip.mp4|title]]`)"}],yo=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Title text (Obsidian alias syntax: `![[song.mp3|title]]`)"}],bo=[{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#install-tabs`)"}],xo=[{name:`label`,type:`string`,required:!0,autoFocus:!0,defaultValue:`Tab`,description:`Tab strip label — shown in the clickable pill at the top`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#tab-npm`)"}],So=[{name:`formula`,type:`string`,required:!0,autoFocus:!0,language:`latex`,description:`LaTeX math source (rendered with KaTeX in the browser)`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#eq-pythagoras`)"},{name:`language`,type:`string`,required:!1,advanced:!0,description:"Forward-compat hint for the math source language (default `latex`). Reserved for future MathJax / Typst / AsciiMath substrates."}],Co=[So[0]],wo=[So[0]],To=[{name:`chart`,type:`string`,required:!0,hidden:!0,description:`Mermaid chart source (graph / flowchart / sequenceDiagram / class / state / etc.)`}],Eo=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Display name override (Obsidian alias syntax: `![[file.zip|label]]`)"}],Do=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`File URL`,accept:[`*/*`],autoFocus:!0}],Oo=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`PDF source URL`,accept:C,autoFocus:!0},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Accessible label for the embedded PDF viewer`},{name:`anchor`,type:`string`,required:!1,advanced:!0,description:"PDF viewer parameters as a single URL-fragment string (e.g. `page=3&height=600`)"}],ko=[{name:`src`,type:`string`,required:!0,description:"Path to the `.excalidraw` board this embed renders",autoFocus:!0},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Accessible label for the embedded board`}],Ao=[{name:`src`,type:`string`,required:!0,description:"Path of the source doc, extension-less (e.g. `api-spec`).",autoFocus:!0},{name:`anchor`,type:`string`,required:!0,description:"Id of the `<MirrorSource>` block within the source doc."}],jo=[{name:`id`,type:`string`,required:!0,description:"Stable id agents and authors use to reference this block from `<Mirror>` elsewhere.",autoFocus:!0},{name:`children`,type:`reactnode`,required:!0,description:`Block content this MirrorSource owns — paragraphs, callouts, code, nested JSX, anything.`}];function Mo(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function No(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function Po(e){let t=e.attrs.props,n=t?.target??``,r=typeof t?.alias==`string`&&t.alias.length>0?t.alias:null,i=typeof t?.anchor==`string`&&t.anchor.length>0?t.anchor:null,a=typeof t?.sourceTarget==`string`?t.sourceTarget:null,o=typeof t?.sourceAnchor==`string`?t.sourceAnchor:null,s=typeof t?.sourceAlias==`string`?t.sourceAlias:null,c=r??(i?`${n}#${i}`:n);return{type:`wikiLinkEmbed`,value:c,data:{target:n,anchor:i,alias:r,sourceTarget:a,sourceAnchor:o,sourceAlias:s},children:[{type:`text`,value:c}]}}var Fo=[{name:`Callout`,surface:`canonical`,hasChildren:!0,props:oo,icon:`MessageSquareWarning`,category:`content`,displayName:`Callout`,description:`Alert / admonition with 15 type variants — 5 GFM (note, tip, important, warning, caution) plus 10 Obsidian-parity (abstract, info, todo, success, question, failure, danger, bug, example, quote)`,searchTerms:[`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`,`alert`,`admonition`,`callout`],serialize:(e,t)=>io(`Callout`,e,t,oo)},{name:`img`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:so,icon:`Image`,category:`media`,displayName:`Image`,description:`Image with click-to-zoom and HTML-native attributes`,searchTerms:[`image`,`zoom`,`picture`,`photo`],placeholder:{label:`Add an image`},serialize:(e,t)=>io(`img`,e,t,so)},{name:`video`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:lo,icon:`SquarePlay`,category:`media`,displayName:`Video`,description:`HTML5 video player with native controls`,searchTerms:[`video`,`media`,`player`,`mp4`,`webm`,`movie`],placeholder:{label:`Add a video`},serialize:(e,t)=>io(`video`,e,t,lo)},{name:`audio`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:uo,icon:`Volume2`,category:`media`,displayName:`Audio`,description:`HTML5 audio player with native controls`,searchTerms:[`audio`,`sound`,`music`,`mp3`,`podcast`,`player`],placeholder:{label:`Add audio`},serialize:(e,t)=>io(`audio`,e,t,uo)},{name:`Pdf`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:Oo,icon:`FileText`,category:`media`,displayName:`PDF`,description:"Embedded PDF viewer (`#page=N` to open at page N, `#height=N` for viewer height)",searchTerms:[`pdf`,`document`,`embed`,`pdfjs`],placeholder:{label:`Add a PDF`},serialize:(e,t)=>io(`Pdf`,e,t,Oo)},{name:`Excalidraw`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:ko,icon:`PenTool`,category:`embed`,displayName:`Excalidraw`,description:"Embedded snapshot of an `.excalidraw` board, linking to its canvas editor",searchTerms:[`excalidraw`,`board`,`whiteboard`,`sketch`,`drawing`,`canvas`],serialize:(e,t)=>io(`Excalidraw`,e,t,ko)},{name:`File`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:Do,icon:`Paperclip`,category:`media`,displayName:`File`,description:`Downloadable file attachment — inline row with name + size + download link`,searchTerms:[`file`,`attachment`,`download`,`document`,`zip`,`docx`,`doc`],placeholder:{label:`Add a file`},serialize:(e,t)=>io(`File`,e,t,Do)},{name:`Embed`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:co,icon:`AppWindow`,category:`embed`,displayName:`Embed`,description:'Inline web embed (iframe) — drop a URL, get a resizable preview pane. For YouTube / Vimeo / Loom prefer `<video src="…">` (player props, click-facade); `<Embed>` auto-rewrites watch URLs as a fallback.',searchTerms:[`embed`,`iframe`,`website`,`page`,`inline`,`frame`,`preview`],placeholder:{label:`Embed a URL`},serialize:(e,t)=>io(`Embed`,e,t,co)},{name:`Accordion`,surface:`canonical`,hasChildren:!0,props:fo,icon:`ChevronRight`,category:`content`,displayName:`Accordion`,description:"Standalone expand/collapse via native HTML5 <details>/<summary>. Group siblings with the `name` prop for exclusive-accordion UX.",searchTerms:[`accordion`,`expandable`,`details`,`disclosure`,`collapse`,`fold`],exampleBody:`Body content revealed when the accordion is expanded.`,serialize:(e,t)=>io(`Accordion`,e,t,fo)},{name:`Toggle`,surface:`canonical`,hasChildren:!0,props:fo,icon:`ChevronRight`,category:`content`,displayName:`Toggle`,description:"Standalone expand/collapse block (Notion-style). Same render + props as `<Accordion>` — pick whichever vocabulary matches the vault.",searchTerms:[`toggle`,`collapsible`,`expand`,`details`,`disclosure`,`fold`],exampleBody:`Body content revealed when the toggle is expanded.`,serialize:(e,t)=>io(`Toggle`,e,t,fo)},{name:`Tabs`,surface:`canonical`,hasChildren:!0,emptyChildName:`Tab`,props:bo,icon:`LayoutPanelTop`,category:`content`,displayName:`Tabs`,description:"Horizontal tab strip + active panel below. Each `<Tab>` child is one panel; clickable pills at the top switch the active one. Active selection is ephemeral (resets on reload).",searchTerms:[`tabs`,`tabbed`,`panels`,`tabgroup`,`switcher`],exampleBody:`<Tab label="One">Body of the first tab panel.</Tab>
|
|
3
3
|
<Tab label="Two">Body of the second tab panel.</Tab>`,serialize:(e,t)=>io(`Tabs`,e,t,bo)},{name:`Tab`,surface:`canonical`,hasChildren:!0,props:xo,icon:`PanelTop`,category:`content`,displayName:`Tab`,description:"A single tab panel inside a `<Tabs>` container — carries the strip label and the block-content body.",searchTerms:[`tab`,`panel`],exampleBody:"Panel content — must be nested inside a `<Tabs>` parent.",serialize:(e,t)=>io(`Tab`,e,t,xo)},{name:`Math`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:So,icon:`Sigma`,category:`content`,displayName:`Math`,description:`Block math equation rendered with KaTeX from a LaTeX source string`,searchTerms:[`math`,`latex`,`equation`,`formula`,`katex`,`tex`],serialize:(e,t)=>io(`Math`,e,t,So)},{name:`MermaidFence`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:To,icon:`Workflow`,category:`content`,displayName:`Mermaid`,placeholder:{label:`Add a Mermaid diagram`},description:"Diagram rendered from Mermaid source (flowchart, sequence, class, state, ER, gantt, pie). Authored exclusively as ` ```mermaid ` fenced code.",searchTerms:[`mermaid`,`diagram`,`flowchart`,`graph`,`sequence`,`sequencediagram`,`class`,`state`,`er`,`erdiagram`,`gantt`,`pie`,`chart`],serialize:e=>({type:`code`,lang:`mermaid`,meta:null,value:e.attrs.props?.chart??``})},{name:`Mirror`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:Ao,icon:`CopyPlus`,category:`content`,displayName:`Mirror`,description:"Render a read-only copy of a `<MirrorSource>` block from another doc. Use to keep the same content in sync across multiple docs without copy-paste — edits land at the source, every Mirror reflects the change.",searchTerms:[`mirror`,`sync`,`synced`,`transclude`,`embed`,`reference`,`shared block`],serialize:(e,t)=>io(`Mirror`,e,t,Ao)},{name:`MirrorSource`,surface:`canonical`,hasChildren:!0,props:jo,icon:`GitBranch`,category:`content`,displayName:`Mirror Source`,description:'Mark a block as the source of truth for content that appears in multiple docs. Wrap any block content; `<Mirror src="…" anchor="<id>">` references render this verbatim read-only at every call-site. Edit here, propagate everywhere.',searchTerms:[`mirror source`,`sync source`,`source block`,`master block`,`shared`],exampleBody:"Authoritative content lives inside this block — edits here propagate to every `<Mirror>` that references this id.",serialize:(e,t)=>io(`MirrorSource`,e,t,jo)},{name:`GFMCallout`,surface:`compat`,hasChildren:!0,props:po,icon:`MessageSquareWarning`,category:`content`,displayName:`GFM Callout`,description:"GFM blockquote alert (`> [!NOTE]`) — read-only compat. Preserves `> [!NOTE]` syntax on round-trip; insert a fresh Callout block for the full prop surface.",rendersAs:`Callout`,translateProps:e=>e,serialize:(e,t)=>{let n=e.attrs.props,r=new Set([`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`]),i=n?.type??`note`;return{type:`blockquote`,children:[{type:`html`,value:`[!${(r.has(i.toLowerCase())?i:`note`).toUpperCase()}]${n?.collapsible?n.defaultOpen===!1?`-`:`+`:``}${n?.title?` ${n.title}`:``}`},...t.all(e).filter(e=>{if(e.type!==`paragraph`)return!0;let t=e;return Array.isArray(t.children)&&t.children.length>0})]}}},{name:`CommonMarkImage`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:mo,icon:`Image`,category:`media`,displayName:`CommonMark Image`,description:'CommonMark image (``) — read-only compat. Preserves `` syntax on round-trip; insert a fresh Image block for the full HTML-native attribute surface (srcset, sizes, decoding, etc.).',rendersAs:`img`,translateProps:e=>e,serialize:e=>{let t=e.attrs.props;return{type:`paragraph`,children:[{type:`image`,url:t?.sourceUrl??t?.src??``,alt:t?.alt??``,title:t?.title??null}]}}},{name:`WikiEmbedImage`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:_o,icon:`ZoomIn`,category:`media`,displayName:`Wiki Embed Image`,description:"Obsidian-style `![[file.png]]` wiki-embed — read-only compat. Edit the alt-text via the alias slot; the embed target / anchor stay on the prop bag and round-trip byte-identical.",rendersAs:`img`,translateProps:e=>{let t=typeof e.alias==`string`&&e.alias.length>0?e.alias:null,n=typeof e.target==`string`?e.target:``;return{src:e.src,alt:t??n}},serialize:Po},{name:`WikiEmbedVideo`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:vo,icon:`Film`,category:`media`,displayName:`Wiki Embed Video`,description:"Obsidian-style `![[clip.mp4]]` wiki-embed — read-only compat. Edit the title via the alias slot; the embed target / anchor stay on the prop bag and round-trip byte-identical.",rendersAs:`video`,translateProps:e=>{let t=typeof e.alias==`string`&&e.alias.length>0?e.alias:null,n=typeof e.target==`string`?e.target:``;return{src:e.src,title:t??n}},serialize:Po},{name:`WikiEmbedAudio`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:yo,icon:`Volume2`,category:`media`,displayName:`Wiki Embed Audio`,description:"Obsidian-style `![[song.mp3]]` wiki-embed — read-only compat. Edit the title via the alias slot; the embed target / anchor stay on the prop bag and round-trip byte-identical.",rendersAs:`audio`,translateProps:e=>{let t=typeof e.alias==`string`&&e.alias.length>0?e.alias:null,n=typeof e.target==`string`?e.target:``;return{src:e.src,title:t??n}},serialize:Po},{name:`WikiEmbedFile`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:Eo,icon:`Paperclip`,category:`media`,displayName:`Wiki Embed File`,description:"Obsidian-style `![[file.zip]]` wiki-embed — read-only compat for arbitrary downloadable attachments. Renders through the `File` canonical (inline row with file-up icon + bold name + optional dim size). Edit the display name via the alias slot.",rendersAs:`File`,translateProps:e=>{let t=typeof e.alias==`string`&&e.alias.length>0?e.alias:null,n=typeof e.size==`string`&&e.size.length>0?e.size:null;return{src:e.src,name:t??void 0,size:n??void 0}},serialize:Po},{name:`HtmlDetailsAccordion`,surface:`compat`,hasChildren:!0,props:ho,icon:`ChevronRight`,category:`content`,displayName:`HTML5 Details`,description:"HTML5 `<details><summary>` collapsible — read-only compat. Preserves `<details>` syntax on round-trip; insert a fresh Accordion block for icon / description / group-name props.",rendersAs:`Accordion`,translateProps:e=>e,serialize:(e,t)=>{let n=e.attrs.props,r=n?.defaultOpen?` open`:``,i=n?.name?` name="${Mo(n.name)}"`:``,a=n?.id?` id="${Mo(n.id)}"`:``,o=n?.title?.trim(),s=o?`<summary>${No(o)}</summary>`:``;return{type:`mdxJsxFlowElement`,name:`HtmlDetailsAccordion`,attributes:[],children:t.all(e),data:{htmlBoundary:{opener:`<details${r}${i}${a}>\n${s}`,closer:`</details>`}}}}},{name:`HtmlAlignBlock`,surface:`canonical`,hasChildren:!0,props:go,icon:`AlignCenter`,category:`content`,displayName:`Align block`,description:"GitHub-style `<div align>` wrapper. Children render as normal blocks with the alignment applied; the `<div align>` syntax is preserved on round-trip.",searchTerms:[`align`,`center`,`centered`,`div`],serialize:(e,t)=>{let n=e.attrs.props,r=n?.tag===`center`?`center`:`div`,i=typeof n?.align==`string`&&n.align?n.align:null,a=typeof n?.sourceAttrs==`string`?n.sourceAttrs:``,o=/(\balign\s*=\s*)(?:"[^"]*"|'[^']*'|[^\s"'<>]+)/i;return i!==null&&(r===`div`||i!==`center`)?a=o.test(a)?a.replace(o,`$1"${Mo(i)}"`):`${a} align="${Mo(i)}"`:(i===null||r===`center`&&i===`center`)&&(a=a.replace(RegExp(`\\s*${o.source}`,`i`),``)),{type:`mdxJsxFlowElement`,name:`HtmlAlignBlock`,attributes:[],children:t.all(e),data:{htmlBoundary:{opener:`<${r}${a}>`,closer:`</${r}>`}}}}},{name:`DollarMath`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:Co,icon:`Sigma`,category:`content`,displayName:`Dollar Math`,description:"Block math via `$$…$$` syntax — read-only compat. Preserves `$$…$$` form on round-trip; insert a fresh Math block for the full prop surface (id, language).",rendersAs:`Math`,translateProps:e=>e,serialize:e=>({type:`math`,value:e.attrs.props?.formula??``})},{name:`MathFence`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:wo,icon:`Sigma`,category:`content`,displayName:`Math Fence`,description:"Block math via ` ```math ` fenced code syntax — read-only compat. Preserves the fence form on round-trip; insert a fresh Math block for the full prop surface (id, language).",rendersAs:`Math`,translateProps:e=>e,serialize:e=>({type:`code`,lang:`math`,meta:null,value:e.attrs.props?.formula??``})}],Io={name:`*`,surface:`canonical`,hasChildren:!0,props:[],description:`Unregistered component — children editable as markdown`,serialize:(e,t)=>io(e.attrs.componentName||`*`,e,t)};function Lo(){let e=new Map;e.set(`*`,Io);for(let t of Fo)e.set(t.name,t);return{get(t){return e.get(t)},getOrWildcard(t){return e.get(t)??e.get(`*`)},set(t,n){e.set(t,n)},has(t){return e.has(t)},entries(){return e.entries()}}}var Ro=_e.create({name:`sourceLiteral`,priority:10,excludes:``,inclusive:!1,addAttributes(){return{sourceRaw:{default:``}}},parseHTML(){return[{tag:`span[data-source-literal]`}]},renderHTML({HTMLAttributes:e}){return[`span`,{"data-source-literal":``,...e},0]}});function zo(e,t){if(typeof e!=`string`||typeof t!=`string`||/[\x00-\x1F\x7F]/.test(e))return!1;let n=e.replaceAll(`\xA0`,` `),r=t.replaceAll(`\xA0`,` `);return n===r||Bo(n)===r?!0:ri(e)===t}function Bo(e){return e.replace(/\\([!-/:-@[-`{-~])/g,`$1`)}function Vo(e,t){let{target:n,anchor:r,alias:i}=e;if(!t.separatorCrossed)return e;if(r!==null){let e=Go(r);return{target:n,anchor:e.length>0?e:null,alias:i===null?null:Ko(i)}}return{target:Go(n),anchor:null,alias:i===null?null:Ko(i)}}function Ho(e,t,n){let r=e.trim();return r===t?!0:n===`alias`?Ko(r)===t:Go(r)===t}function Uo(e,t,n){return typeof e==`string`&&Ho(e,t,n)?e:t}function Wo(e){return Go(e.trim())===``}function Go(e){return e.endsWith(`\\`)?e.slice(0,-1):e}function Ko(e){return e.replace(/\\\|/g,`|`)}function qo(e){let t=``,n=0;for(let r of e)r===`\\`?n++:(r===`|`&&n%2==0&&(t+=`\\`),n=0),t+=r;return t}function Jo(e){return e.replace(/\|/g,`\\|`)}function Yo(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0||n===t.length-1?``:t.slice(n+1).toLowerCase()}function Xo(e){return e.includes("`")?`~`:"`"}function Zo(e,t,n=3){let r=RegExp(`^ {0,3}(\\${e}+)[ \\t]*$`),i=Math.max(3,n);for(let e of t.split(`
|
|
4
4
|
`)){let t=r.exec(e);t&&t[1].length>=i&&(i=t[1].length+1)}return i}var Qo=new Set([`break`,`delete`,`emphasis`,`footnoteReference`,`html`,`image`,`imageReference`,`inlineCode`,`link`,`linkReference`,`strong`,`text`]);function $o(e){let t=e.children;Array.isArray(t)&&t.forEach((e,n)=>{if(e.type===`break`){t[n]={type:`html`,value:`<br />`};return}$o(e)})}function es(e){let t=e.children;if(Array.isArray(t))for(let e of t)(e.type===`inlineCode`||e.type===`html`)&&(e.value.includes(`
|
|
5
5
|
`)&&(e.value=e.value.replace(/[ \t]*\n[ \t]*/g,` `)),e.type===`html`&&e.value.includes(`|`)&&(e.value=Jo(e.value))),es(e)}function ts(e){H(e,`tableCell`,e=>{e.children.some(e=>!Qo.has(e.type))&&(e.children=ns(e.children)),$o(e),es(e)})}function ns(e){let t=[],n=0,r=()=>{t.length>0&&(n+=1)},i=e=>{for(;n>0;)t.push({type:`break`}),--n;t.push(e)},a=e=>{e.split(`
|
|
@@ -167,4 +167,4 @@ Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#pl
|
|
|
167
167
|
Please provide a chat model before proceeding with creating an answer session.
|
|
168
168
|
Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#plugin-secure-proxy
|
|
169
169
|
`,ANSWER_SESSION_LAST_MESSAGE_IS_NOT_ASSISTANT:`The last message in the session is not an assistant message. Cannot regenerate non-assistant messages.`,PLUGIN_COMPONENT_CONFLICT:`The component "%s" is already defined. The plugin "%s" is trying to redefine it.`};function $(e,...t){let n=Error(WA(fj[e]??`Unsupported Orama Error code: ${e}`,...t));return n.code=e,`captureStackTrace`in Error.prototype&&Error.captureStackTrace(n),n}function pj(e){return{raw:Number(e),formatted:JA(e)}}function mj(e){if(e.id){if(typeof e.id!=`string`)throw $(`DOCUMENT_ID_MUST_BE_STRING`,typeof e.id);return e.id}return XA()}function hj(e,t){for(let[n,r]of Object.entries(t)){let t=e[n];if(t!==void 0&&!(r===`geopoint`&&typeof t==`object`&&typeof t.lon==`number`&&typeof t.lat==`number`)&&!(r===`enum`&&(typeof t==`string`||typeof t==`number`))){if(r===`enum[]`&&Array.isArray(t)){let e=t.length;for(let r=0;r<e;r++)if(typeof t[r]!=`string`&&typeof t[r]!=`number`)return n+`.`+r;continue}if(yj(r)){let e=Sj(r);if(!Array.isArray(t)||t.length!==e)throw $(`INVALID_INPUT_VECTOR`,n,e,t.length);continue}if(bj(r)){if(!Array.isArray(t))return n;let e=xj(r),i=t.length;for(let r=0;r<i;r++)if(typeof t[r]!==e)return n+`.`+r;continue}if(typeof r==`object`){if(!t||typeof t!=`object`)return n;let e=hj(t,r);if(e)return n+`.`+e;continue}if(typeof t!==r)return n}}}var gj={string:!1,number:!1,boolean:!1,enum:!1,geopoint:!1,"string[]":!0,"number[]":!0,"boolean[]":!0,"enum[]":!0},_j={"string[]":`string`,"number[]":`number`,"boolean[]":`boolean`,"enum[]":`enum`};function vj(e){return e===`geopoint`}function yj(e){return typeof e==`string`&&/^vector\[\d+\]$/.test(e)}function bj(e){return typeof e==`string`&&gj[e]}function xj(e){return _j[e]}function Sj(e){let t=Number(e.slice(7,-1));switch(!0){case isNaN(t):throw $(`INVALID_VECTOR_VALUE`,e);case t<=0:throw $(`INVALID_VECTOR_SIZE`,e);default:return t}}function Cj(){return{idToInternalId:new Map,internalIdToId:[],save:wj,load:Tj}}function wj(e){return{internalIdToId:e.internalIdToId}}function Tj(e,t){let{internalIdToId:n}=t;e.internalDocumentIDStore.idToInternalId.clear(),e.internalDocumentIDStore.internalIdToId=[];let r=n.length;for(let t=0;t<r;t++){let r=n[t];e.internalDocumentIDStore.idToInternalId.set(r,t+1),e.internalDocumentIDStore.internalIdToId.push(r)}}function Ej(e,t){if(typeof t==`string`){let n=e.idToInternalId.get(t);if(n)return n;let r=e.idToInternalId.size+1;return e.idToInternalId.set(t,r),e.internalIdToId.push(t),r}return t>e.internalIdToId.length?Ej(e,t.toString()):t}function Dj(e,t){if(e.internalIdToId.length<t)throw Error(`Invalid internalId ${t}`);return e.internalIdToId[t-1]}function Oj(e,t){return{sharedInternalDocumentStore:t,docs:{},count:0}}function kj(e,t){let n=Ej(e.sharedInternalDocumentStore,t);return e.docs[n]}function Aj(e,t){let n=t.length,r=Array.from({length:n});for(let i=0;i<n;i++){let n=Ej(e.sharedInternalDocumentStore,t[i]);r[i]=e.docs[n]}return r}function jj(e){return e.docs}function Mj(e,t,n,r){return e.docs[n]===void 0?(e.docs[n]=r,e.count++,!0):!1}function Nj(e,t){let n=Ej(e.sharedInternalDocumentStore,t);return e.docs[n]===void 0?!1:(delete e.docs[n],e.count--,!0)}function Pj(e){return e.count}function Fj(e,t){let n=t;return{docs:n.docs,count:n.count,sharedInternalDocumentStore:e}}function Ij(e){return{docs:e.docs,count:e.count}}function Lj(){return{create:Oj,get:kj,getMultiple:Aj,getAll:jj,store:Mj,remove:Nj,count:Pj,load:Fj,save:Ij}}var Rj=[`beforeInsert`,`afterInsert`,`beforeRemove`,`afterRemove`,`beforeUpdate`,`afterUpdate`,`beforeUpsert`,`afterUpsert`,`beforeSearch`,`afterSearch`,`beforeInsertMultiple`,`afterInsertMultiple`,`beforeRemoveMultiple`,`afterRemoveMultiple`,`beforeUpdateMultiple`,`afterUpdateMultiple`,`beforeUpsertMultiple`,`afterUpsertMultiple`,`beforeLoad`,`afterLoad`,`afterCreate`];function zj(e,t){let n=[],r=e.plugins?.length;if(!r)return n;for(let i=0;i<r;i++)try{let r=e.plugins[i];typeof r[t]==`function`&&n.push(r[t])}catch(e){throw console.error(`Caught error in getAllPluginsByHook:`,e),$(`PLUGIN_CRASHED`)}return n}var Bj=[`tokenizer`,`index`,`documentsStore`,`sorter`,`pinning`],Vj=[`validateSchema`,`getDocumentIndexId`,`getDocumentProperties`,`formatElapsedTime`];function Hj(e,t,n,r){if(e.some(aj))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function Uj(e,t,n){if(e.some(aj))return(async()=>{for(let r of e)await r(t,n)})();for(let r of e)r(t,n)}function Wj(e,t,n,r,i){if(e.some(aj))return(async()=>{for(let a of e)await a(t,n,r,i)})();for(let a of e)a(t,n,r,i)}function Gj(e,t,n,r){if(e.some(aj))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function Kj(e,t){if(e.some(aj))return(async()=>{for(let n of e)await n(t)})();for(let n of e)n(t)}var qj=class e{k;v;l=null;r=null;h=1;constructor(e,t){this.k=e,this.v=new Set(t)}updateHeight(){this.h=Math.max(e.getHeight(this.l),e.getHeight(this.r))+1}static getHeight(e){return e?e.h:0}getBalanceFactor(){return e.getHeight(this.l)-e.getHeight(this.r)}rotateLeft(){let e=this.r;return this.r=e.l,e.l=this,this.updateHeight(),e.updateHeight(),e}rotateRight(){let e=this.l;return this.l=e.r,e.r=this,this.updateHeight(),e.updateHeight(),e}toJSON(){return{k:this.k,v:Array.from(this.v),l:this.l?this.l.toJSON():null,r:this.r?this.r.toJSON():null,h:this.h}}static fromJSON(t){let n=new e(t.k,t.v);return n.l=t.l?e.fromJSON(t.l):null,n.r=t.r?e.fromJSON(t.r):null,n.h=t.h,n}},Jj=class e{root=null;insertCount=0;constructor(e,t){e!==void 0&&t!==void 0&&(this.root=new qj(e,t))}insert(e,t,n=1e3){this.root=this.insertNode(this.root,e,t,n)}insertMultiple(e,t,n=1e3){for(let r of t)this.insert(e,r,n)}rebalance(){this.root&&=this.rebalanceNode(this.root)}toJSON(){return{root:this.root?this.root.toJSON():null,insertCount:this.insertCount}}static fromJSON(t){let n=new e;return n.root=t.root?qj.fromJSON(t.root):null,n.insertCount=t.insertCount||0,n}insertNode(e,t,n,r){if(e===null)return new qj(t,[n]);let i=[],a=e,o=null;for(;a!==null;)if(i.push({parent:o,node:a}),t<a.k)if(a.l===null){a.l=new qj(t,[n]),i.push({parent:a,node:a.l});break}else o=a,a=a.l;else if(t>a.k)if(a.r===null){a.r=new qj(t,[n]),i.push({parent:a,node:a.r});break}else o=a,a=a.r;else return a.v.add(n),e;let s=!1;this.insertCount++%r===0&&(s=!0);for(let t=i.length-1;t>=0;t--){let{parent:n,node:r}=i[t];if(r.updateHeight(),s){let t=this.rebalanceNode(r);n?n.l===r?n.l=t:n.r===r&&(n.r=t):e=t}}return e}rebalanceNode(e){let t=e.getBalanceFactor();if(t>1){if(e.l&&e.l.getBalanceFactor()>=0)return e.rotateRight();if(e.l)return e.l=e.l.rotateLeft(),e.rotateRight()}if(t<-1){if(e.r&&e.r.getBalanceFactor()<=0)return e.rotateLeft();if(e.r)return e.r=e.r.rotateRight(),e.rotateLeft()}return e}find(e){let t=this.findNodeByKey(e);return t?t.v:null}contains(e){return this.find(e)!==null}getSize(){let e=0,t=[],n=this.root;for(;n||t.length>0;){for(;n;)t.push(n),n=n.l;n=t.pop(),e++,n=n.r}return e}isBalanced(){if(!this.root)return!0;let e=[this.root];for(;e.length>0;){let t=e.pop(),n=t.getBalanceFactor();if(Math.abs(n)>1)return!1;t.l&&e.push(t.l),t.r&&e.push(t.r)}return!0}remove(e){this.root=this.removeNode(this.root,e)}removeDocument(e,t){let n=this.findNodeByKey(e);n&&(n.v.size===1?this.root=this.removeNode(this.root,e):n.v=new Set([...n.v.values()].filter(e=>e!==t)))}findNodeByKey(e){let t=this.root;for(;t;)if(e<t.k)t=t.l;else if(e>t.k)t=t.r;else return t;return null}removeNode(e,t){if(e===null)return null;let n=[],r=e;for(;r!==null&&r.k!==t;)n.push(r),r=t<r.k?r.l:r.r;if(r===null)return e;if(r.l===null||r.r===null){let t=r.l?r.l:r.r;if(n.length===0)e=t;else{let e=n[n.length-1];e.l===r?e.l=t:e.r=t}}else{let e=r,t=r.r;for(;t.l!==null;)e=t,t=t.l;r.k=t.k,r.v=t.v,e.l===t?e.l=t.r:e.r=t.r,r=e}n.push(r);for(let t=n.length-1;t>=0;t--){let r=n[t];r.updateHeight();let i=this.rebalanceNode(r);if(t>0){let e=n[t-1];e.l===r?e.l=i:e.r===r&&(e.r=i)}else e=i}return e}rangeSearch(e,t){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),i.k>=e&&i.k<=t)for(let e of i.v)n.add(e);if(i.k>t)break;i=i.r}return n}greaterThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.r;if(i=r.pop(),t&&i.k>=e||!t&&i.k>e)for(let e of i.v)n.add(e);else if(i.k<=e)break;i=i.l}return n}lessThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),t&&i.k<=e||!t&&i.k<e)for(let e of i.v)n.add(e);else if(i.k>e)break;i=i.r}return n}},Yj=class e{numberToDocumentId;constructor(){this.numberToDocumentId=new Map}insert(e,t){this.numberToDocumentId.has(e)?this.numberToDocumentId.get(e).add(t):this.numberToDocumentId.set(e,new Set([t]))}find(e){let t=this.numberToDocumentId.get(e);return t?Array.from(t):null}remove(e){this.numberToDocumentId.delete(e)}removeDocument(e,t){let n=this.numberToDocumentId.get(t);n&&(n.delete(e),n.size===0&&this.numberToDocumentId.delete(t))}contains(e){return this.numberToDocumentId.has(e)}getSize(){let e=0;for(let t of this.numberToDocumentId.values())e+=t.size;return e}filter(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`eq`:{let t=e[n],r=this.numberToDocumentId.get(t);return r?Array.from(r):[]}case`in`:{let t=e[n],r=new Set;for(let e of t){let t=this.numberToDocumentId.get(e);if(t)for(let e of t)r.add(e)}return Array.from(r)}case`nin`:{let t=new Set(e[n]),r=new Set;for(let[e,n]of this.numberToDocumentId.entries())if(!t.has(e))for(let e of n)r.add(e);return Array.from(r)}default:throw Error(`Invalid operation`)}}filterArr(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`containsAll`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e].filter(e=>t.has(e))));return Array.from(r)}case`containsAny`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e,...t]));return Array.from(r)}default:throw Error(`Invalid operation`)}}static fromJSON(t){if(!t.numberToDocumentId)throw Error(`Invalid Flat Tree JSON`);let n=new e;for(let[e,r]of t.numberToDocumentId)n.numberToDocumentId.set(e,new Set(r));return n}toJSON(){return{numberToDocumentId:Array.from(this.numberToDocumentId.entries()).map(([e,t])=>[e,Array.from(t)])}}};function Xj(e,t,n){if(n<0)return-1;if(e===t)return 0;let r=e.length,i=t.length;if(r===0)return i<=n?i:-1;if(i===0)return r<=n?r:-1;let a=Math.abs(r-i);if(e.startsWith(t))return a<=n?a:-1;if(t.startsWith(e))return 0;if(a>n)return-1;let o=[];for(let e=0;e<=r;e++){o[e]=[e];for(let t=1;t<=i;t++)o[e][t]=e===0?t:0}for(let a=1;a<=r;a++){let r=1/0;for(let n=1;n<=i;n++)e[a-1]===t[n-1]?o[a][n]=o[a-1][n-1]:o[a][n]=Math.min(o[a-1][n]+1,o[a][n-1]+1,o[a-1][n-1]+1),r=Math.min(r,o[a][n]);if(r>n)return-1}return o[r][i]<=n?o[r][i]:-1}function Zj(e,t,n){let r=Xj(e,t,n);return{distance:r,isBounded:r>=0}}var Qj=class e{k;s;c=new Map;d=new Set;e;w=``;constructor(e,t,n){this.k=e,this.s=t,this.e=n}updateParent(e){this.w=e.w+this.s}addDocument(e){this.d.add(e)}removeDocument(e){return this.d.delete(e)}findAllWords(e,t,n,r){let i=[this];for(;i.length>0;){let a=i.pop();if(a.e){let{w:i,d:o}=a;if(n&&i!==t)continue;if(ZA(e,i)!==null)if(r)if(Math.abs(t.length-i.length)<=r&&Zj(t,i,r).isBounded)e[i]=[];else continue;else e[i]=[];if(ZA(e,i)!=null&&o.size>0){let t=e[i];for(let e of o)t.includes(e)||t.push(e)}}a.c.size>0&&i.push(...a.c.values())}return e}insert(t,n){let r=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=r.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c){if(r=s,i+=l,i===a){s.e||=!0,s.addDocument(n);return}continue}let u=o.slice(0,l),d=o.slice(l),f=t.slice(i+l),p=new e(u[0],u,!1);if(r.c.set(u[0],p),p.updateParent(r),s.s=d,s.k=d[0],p.c.set(d[0],s),s.updateParent(p),f){let t=new e(f[0],f,!0);t.addDocument(n),p.c.set(f[0],t),t.updateParent(p)}else p.e=!0,p.addDocument(n);return}else{let a=new e(o,t.slice(i),!0);a.addDocument(n),r.c.set(o,a),a.updateParent(r);return}}r.e||=!0,r.addDocument(n)}_findLevenshtein(e,t,n,r,i){let a=[{node:this,index:t,tolerance:n}];for(;a.length>0;){let{node:t,index:n,tolerance:o}=a.pop();if(t.w.startsWith(e)){t.findAllWords(i,e,!1,0);continue}if(o<0)continue;if(t.e){let{w:n,d:a}=t;if(n&&(Zj(e,n,r).isBounded&&(i[n]=[]),ZA(i,n)!==void 0&&a.size>0)){let e=new Set(i[n]);for(let t of a)e.add(t);i[n]=Array.from(e)}}if(n>=e.length)continue;let s=e[n];if(t.c.has(s)){let e=t.c.get(s);a.push({node:e,index:n+1,tolerance:o})}a.push({node:t,index:n+1,tolerance:o-1});for(let[e,r]of t.c)a.push({node:r,index:n,tolerance:o-1}),e!==s&&a.push({node:r,index:n+1,tolerance:o-1})}}find(e){let{term:t,exact:n,tolerance:r}=e;if(r&&!n){let e={};return this._findLevenshtein(t,0,r,r,e),e}else{let e=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=e.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c)e=s,i+=l;else if(i+l===a)if(l===a-i){if(n)return{};{let e={};return s.findAllWords(e,t,n,r),e}}else return{};else return{}}else return{}}let o={};return e.findAllWords(o,t,n,r),o}}contains(e){let t=this,n=0,r=e.length;for(;n<r;){let i=e[n],a=t.c.get(i);if(a){let i=a.s,o=i.length,s=0;for(;s<o&&n+s<r&&i[s]===e[n+s];)s++;if(s<o)return!1;n+=o,t=a}else return!1}return!0}removeWord(e){if(!e)return!1;let t=this,n=e.length,r=[];for(let i=0;i<n;i++){let n=e[i];if(t.c.has(n)){let e=t.c.get(n);r.push({parent:t,character:n}),i+=e.s.length-1,t=e}else return!1}for(t.d.clear(),t.e=!1;r.length>0&&t.c.size===0&&!t.e&&t.d.size===0;){let{parent:e,character:n}=r.pop();e.c.delete(n),t=e}return!0}removeDocumentByWord(e,t,n=!0){if(!e)return!0;let r=this,i=e.length;for(let a=0;a<i;a++){let i=e[a];if(r.c.has(i)){let o=r.c.get(i);a+=o.s.length-1,r=o,n&&r.w!==e||r.removeDocument(t)}else return!1}return!0}static getCommonPrefix(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return e.slice(0,r)}toJSON(){return{w:this.w,s:this.s,e:this.e,k:this.k,d:Array.from(this.d),c:Array.from(this.c?.entries())?.map(([e,t])=>[e,t.toJSON()])}}static fromJSON(t){let n=new e(t.k,t.s,t.e);return n.w=t.w,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([t,n])=>[t,e.fromJSON(n)])||[]),n}},$j=class e extends Qj{constructor(){super(``,``,!1)}static fromJSON(t){let n=new e;return n.w=t.w,n.s=t.s,n.e=t.e,n.k=t.k,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([e,t])=>[e,Qj.fromJSON(t)])||[]),n}toJSON(){return super.toJSON()}},eM=2,tM=6371e3,nM=class e{point;docIDs;left;right;parent;constructor(e,t){this.point=e,this.docIDs=new Set(t),this.left=null,this.right=null,this.parent=null}toJSON(){return{point:this.point,docIDs:Array.from(this.docIDs),left:this.left?this.left.toJSON():null,right:this.right?this.right.toJSON():null}}static fromJSON(t,n=null){let r=new e(t.point,t.docIDs);return r.parent=n,t.left&&(r.left=e.fromJSON(t.left,r)),t.right&&(r.right=e.fromJSON(t.right,r)),r}},rM=class e{root;nodeMap;constructor(){this.root=null,this.nodeMap=new Map}getPointKey(e){return`${e.lon},${e.lat}`}insert(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);if(r){t.forEach(e=>r.docIDs.add(e));return}let i=new nM(e,t);if(this.nodeMap.set(n,i),this.root==null){this.root=i;return}let a=this.root,o=0;for(;;){if(o%eM===0)if(e.lon<a.point.lon){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}else if(e.lat<a.point.lat){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}o++}}contains(e){let t=this.getPointKey(e);return this.nodeMap.has(t)}getDocIDsByCoordinates(e){let t=this.getPointKey(e),n=this.nodeMap.get(t);return n?Array.from(n.docIDs):null}removeDocByID(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);r&&(r.docIDs.delete(t),r.docIDs.size===0&&(this.nodeMap.delete(n),this.deleteNode(r)))}deleteNode(e){let t=e.parent,n=e.left?e.left:e.right;n&&(n.parent=t),t?t.left===e?t.left=n:t.right===e&&(t.right=n):(this.root=n,this.root&&(this.root.parent=null))}searchByRadius(t,n,r=!0,i=`asc`,a=!1){let o=a?e.vincentyDistance:e.haversineDistance,s=[{node:this.root,depth:0}],c=[];for(;s.length>0;){let{node:e,depth:i}=s.pop();if(e==null)continue;let a=o(t,e.point);(r?a<=n:a>n)&&c.push({point:e.point,docIDs:Array.from(e.docIDs)}),e.left!=null&&s.push({node:e.left,depth:i+1}),e.right!=null&&s.push({node:e.right,depth:i+1})}return i&&c.sort((e,n)=>{let r=o(t,e.point),a=o(t,n.point);return i.toLowerCase()===`asc`?r-a:a-r}),c}searchByPolygon(t,n=!0,r=null,i=!1){let a=[{node:this.root,depth:0}],o=[];for(;a.length>0;){let{node:r,depth:i}=a.pop();if(r==null)continue;r.left!=null&&a.push({node:r.left,depth:i+1}),r.right!=null&&a.push({node:r.right,depth:i+1});let s=e.isPointInPolygon(t,r.point);(s&&n||!s&&!n)&&o.push({point:r.point,docIDs:Array.from(r.docIDs)})}let s=e.calculatePolygonCentroid(t);if(r){let t=i?e.vincentyDistance:e.haversineDistance;o.sort((e,n)=>{let i=t(s,e.point),a=t(s,n.point);return r.toLowerCase()===`asc`?i-a:a-i})}return o}toJSON(){return{root:this.root?this.root.toJSON():null}}static fromJSON(t){let n=new e;return t.root&&(n.root=nM.fromJSON(t.root),n.buildNodeMap(n.root)),n}buildNodeMap(e){if(e==null)return;let t=this.getPointKey(e.point);this.nodeMap.set(t,e),e.left&&this.buildNodeMap(e.left),e.right&&this.buildNodeMap(e.right)}static calculatePolygonCentroid(e){let t=0,n=0,r=0,i=e.length;for(let a=0,o=i-1;a<i;o=a++){let i=e[a].lon,s=e[a].lat,c=e[o].lon,l=e[o].lat,u=i*l-c*s;t+=u,n+=(i+c)*u,r+=(s+l)*u}t/=2;let a=6*t;return n/=a,r/=a,{lon:n,lat:r}}static isPointInPolygon(e,t){let n=!1,r=t.lon,i=t.lat,a=e.length;for(let t=0,o=a-1;t<a;o=t++){let a=e[t].lon,s=e[t].lat,c=e[o].lon,l=e[o].lat;s>i!=l>i&&r<(c-a)*(i-s)/(l-s)+a&&(n=!n)}return n}static haversineDistance(e,t){let n=Math.PI/180,r=e.lat*n,i=t.lat*n,a=(t.lat-e.lat)*n,o=(t.lon-e.lon)*n,s=Math.sin(a/2)*Math.sin(a/2)+Math.cos(r)*Math.cos(i)*Math.sin(o/2)*Math.sin(o/2);return tM*(2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s)))}static vincentyDistance(e,t){let n=6378137,r=1/298.257223563,i=(1-r)*n,a=Math.PI/180,o=e.lat*a,s=t.lat*a,c=(t.lon-e.lon)*a,l=Math.atan((1-r)*Math.tan(o)),u=Math.atan((1-r)*Math.tan(s)),d=Math.sin(l),f=Math.cos(l),p=Math.sin(u),m=Math.cos(u),h=c,g,_=1e3,v,y,b,x,S,C;do{let e=Math.sin(h),t=Math.cos(h);if(v=Math.sqrt(m*e*(m*e)+(f*p-d*m*t)*(f*p-d*m*t)),v===0)return 0;y=d*p+f*m*t,b=Math.atan2(v,y),x=f*m*e/v,S=1-x*x,C=y-2*d*p/S,isNaN(C)&&(C=0);let n=r/16*S*(4+r*(4-3*S));g=h,h=c+(1-n)*r*x*(b+n*v*(C+n*y*(-1+2*C*C)))}while(Math.abs(h-g)>1e-12&&--_>0);if(_===0)return NaN;let w=S*(n*n-i*i)/(i*i),T=1+w/16384*(4096+w*(-768+w*(320-175*w))),ee=w/1024*(256+w*(-128+w*(74-47*w))),E=ee*v*(C+ee/4*(y*(-1+2*C*C)-ee/6*C*(-3+4*v*v)*(-3+4*C*C)));return i*T*(b-E)}},iM=class e{true;false;constructor(){this.true=new Set,this.false=new Set}insert(e,t){t?this.true.add(e):this.false.add(e)}delete(e,t){t?this.true.delete(e):this.false.delete(e)}getSize(){return this.true.size+this.false.size}toJSON(){return{true:Array.from(this.true),false:Array.from(this.false)}}static fromJSON(t){let n=new e;return n.true=new Set(t.true),n.false=new Set(t.false),n}};function aM(e,t,n,r,i,{k:a,b:o,d:s}){return Math.log(1+(n-t+.5)/(t+.5))*(s+e*(a+1))/(e+a*(1-o+o*r/i))}var oM=class e{size;vectors=new Map;constructor(e){this.size=e}add(e,t){t instanceof Float32Array||(t=new Float32Array(t));let n=sM(t,this.size);this.vectors.set(e,[n,t])}remove(e){this.vectors.delete(e)}find(e,t,n){return e instanceof Float32Array||(e=new Float32Array(e)),cM(e,n,this.vectors,this.size,t)}toJSON(){let e=[];for(let[t,[n,r]]of this.vectors)e.push([t,[n,Array.from(r)]]);return{size:this.size,vectors:e}}static fromJSON(t){let n=t,r=new e(n.size);for(let[e,[t,i]]of n.vectors)r.vectors.set(e,[t,new Float32Array(i)]);return r}};function sM(e,t){let n=0;for(let r=0;r<t;r++)n+=e[r]*e[r];return Math.sqrt(n)}function cM(e,t,n,r,i){let a=sM(e,r),o=[],s=t||n.keys();for(let t of s){let s=n.get(t);if(!s)continue;let c=s[0],l=s[1],u=0;for(let t=0;t<r;t++)u+=e[t]*l[t];let d=u/(a*c);d>=i&&o.push([t,d])}return o}function lM(e,t,n,r,i){let a=Ej(e.sharedInternalDocumentStore,n);e.avgFieldLength[t]=((e.avgFieldLength[t]??0)*(i-1)+r.length)/i,e.fieldLengths[t][a]=r.length,e.frequencies[t][a]={}}function uM(e,t,n,r,i){let a=0;for(let e of r)e===i&&a++;let o=Ej(e.sharedInternalDocumentStore,n),s=a/r.length;e.frequencies[t][o][i]=s,i in e.tokenOccurrences[t]||(e.tokenOccurrences[t][i]=0),e.tokenOccurrences[t][i]=(e.tokenOccurrences[t][i]??0)+1}function dM(e,t,n,r){let i=Ej(e.sharedInternalDocumentStore,n);r>1?e.avgFieldLength[t]=(e.avgFieldLength[t]*r-e.fieldLengths[t][i])/(r-1):e.avgFieldLength[t]=void 0,e.fieldLengths[t][i]=void 0,e.frequencies[t][i]=void 0}function fM(e,t,n){e.tokenOccurrences[t][n]--}function pM(e,t,n,r,i=``){r||={sharedInternalDocumentStore:t,indexes:{},vectorIndexes:{},searchableProperties:[],searchablePropertiesWithTypes:{},frequencies:{},tokenOccurrences:{},avgFieldLength:{},fieldLengths:{}};for(let[a,o]of Object.entries(n)){let n=`${i}${i?`.`:``}${a}`;if(typeof o==`object`&&!Array.isArray(o)){pM(e,t,o,r,n);continue}if(yj(o))r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o,r.vectorIndexes[n]={type:`Vector`,node:new oM(Sj(o)),isArray:!1};else{let e=/\[/.test(o);switch(o){case`boolean`:case`boolean[]`:r.indexes[n]={type:`Bool`,node:new iM,isArray:e};break;case`number`:case`number[]`:r.indexes[n]={type:`AVL`,node:new Jj(0,[]),isArray:e};break;case`string`:case`string[]`:r.indexes[n]={type:`Radix`,node:new $j,isArray:e},r.avgFieldLength[n]=0,r.frequencies[n]={},r.tokenOccurrences[n]={},r.fieldLengths[n]={};break;case`enum`:case`enum[]`:r.indexes[n]={type:`Flat`,node:new Yj,isArray:e};break;case`geopoint`:r.indexes[n]={type:`BKD`,node:new rM,isArray:e};break;default:throw $(`INVALID_SCHEMA_TYPE`,Array.isArray(o)?`array`:o,n)}r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o}}return r}function mM(e,t,n,r,i,a,o,s){return c=>{let{type:l,node:u}=t.indexes[n];switch(l){case`Bool`:u[c?`true`:`false`].add(r);break;case`AVL`:{let e=s?.avlRebalanceThreshold??1;u.insert(c,r,e);break}case`Radix`:{let s=a.tokenize(c,i,n,!1);e.insertDocumentScoreParameters(t,n,r,s,o);for(let i of s)e.insertTokenScoreParameters(t,n,r,s,i),u.insert(i,r);break}case`Flat`:u.insert(c,r);break;case`BKD`:u.insert(c,[r]);break}}}function hM(e,t,n,r,i,a,o,s,c,l,u){if(yj(o))return gM(t,n,a,r,i);let d=mM(e,t,n,i,s,c,l,u);if(!bj(o))return d(a);let f=a,p=f.length;for(let e=0;e<p;e++)d(f[e])}function gM(e,t,n,r,i){e.vectorIndexes[t].node.add(i,n)}function _M(e,t,n,r,i,a,o,s,c,l){if(yj(o))return t.vectorIndexes[n].node.remove(i),!0;let{type:u,node:d}=t.indexes[n];switch(u){case`AVL`:return d.removeDocument(a,i),!0;case`Bool`:return d[a?`true`:`false`].delete(i),!0;case`Radix`:{let o=c.tokenize(a,s,n);e.removeDocumentScoreParameters(t,n,r,l);for(let r of o)e.removeTokenScoreParameters(t,n,r),d.removeDocumentByWord(r,i);return!0}case`Flat`:return d.removeDocument(i,a),!0;case`BKD`:return d.removeDocByID(a,i),!1}}function vM(e,t,n,r,i,a,o,s,c,l){if(!bj(o))return _M(e,t,n,r,i,a,o,s,c,l);let u=xj(o),d=a,f=d.length;for(let a=0;a<f;a++)_M(e,t,n,r,i,d[a],u,s,c,l);return!0}function yM(e,t,n,r,i,a,o,s,c,l){let u=Array.from(r),d=e.avgFieldLength[t],f=e.fieldLengths[t],p=e.tokenOccurrences[t],m=e.frequencies[t],h=typeof p[n]==`number`?p[n]??0:0,g=u.length;for(let e=0;e<g;e++){let r=u[e];if(c&&!c.has(r))continue;l.has(r)||l.set(r,new Map);let p=l.get(r);p.set(t,(p.get(t)||0)+1);let g=aM(m?.[r]?.[n]??0,h,i,f[r],d,a);o.has(r)?o.set(r,o.get(r)+g*s):o.set(r,g*s)}}function bM(e,t,n,r,i,a,o,s,c,l,u,d=0){let f=n.tokenize(t,r),p=f.length||1,m=new Map,h=new Map,g=new Map;for(let n of i){if(!(n in e.indexes))continue;let r=e.indexes[n],{type:i}=r;if(i!==`Radix`)throw $(`WRONG_SEARCH_PROPERTY_TYPE`,n);let d=s[n]??1;if(d<=0)throw $(`INVALID_BOOST_VALUE`,d);f.length===0&&!t&&f.push(``);let p=f.length;for(let t=0;t<p;t++){let i=f[t],s=r.node.find({term:i,exact:a,tolerance:o}),p=Object.keys(s);p.length>0&&h.set(i,!0);let _=p.length;for(let t=0;t<_;t++){let r=p[t],i=s[r];yM(e,n,r,i,l,c,g,d,u,m)}}}let _=Array.from(g.entries()).map(([e,t])=>[e,t]).sort((e,t)=>t[1]-e[1]);if(_.length===0)return[];if(d===1)return _;if(d===0){if(p===1)return _;for(let e of f)if(!h.get(e))return[];return _.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1})}let v=_.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1});if(v.length>0){let e=_.filter(([e])=>!v.some(([t])=>t===e)),t=Math.ceil(e.length*d);return[...v,...e.slice(0,t)]}return _}function xM(e,t,n,r){if(`and`in n&&n.and&&Array.isArray(n.and)){let i=n.and;return i.length===0?new Set:sj(...i.map(n=>xM(e,t,n,r)))}if(`or`in n&&n.or&&Array.isArray(n.or)){let i=n.or;return i.length===0?new Set:i.map(n=>xM(e,t,n,r)).reduce((e,t)=>lj(e,t),new Set)}if(`not`in n&&n.not){let i=n.not,a=new Set,o=e.sharedInternalDocumentStore;for(let e=1;e<=o.internalIdToId.length;e++)a.add(e);return uj(a,xM(e,t,i,r))}let i=Object.keys(n),a=i.reduce((e,t)=>({[t]:new Set,...e}),{});for(let o of i){let i=n[o];if(e.indexes[o]===void 0)throw $(`UNKNOWN_FILTER_PROPERTY`,o);let{node:s,type:c,isArray:l}=e.indexes[o];if(c===`Bool`){let e=s,t=i?e.true:e.false;a[o]=lj(a[o],t);continue}if(c===`BKD`){let e;if(`radius`in i)e=`radius`;else if(`polygon`in i)e=`polygon`;else throw Error(`Invalid operation ${i}`);if(e===`radius`){let{value:t,coordinates:n,unit:r=`m`,inside:c=!0,highPrecision:l=!1}=i[e],u=rj(t,r),d=s.searchByRadius(n,u,c,void 0,l);a[o]=DM(a[o],d)}else{let{coordinates:t,inside:n=!0,highPrecision:r=!1}=i[e],c=s.searchByPolygon(t,n,void 0,r);a[o]=DM(a[o],c)}continue}if(c===`Radix`&&(typeof i==`string`||Array.isArray(i))){for(let e of[i].flat()){let n=t.tokenize(e,r,o);for(let e of n){let t=s.find({term:e,exact:!0});a[o]=jM(a[o],t)}}continue}let u=Object.keys(i);if(u.length>1)throw $(`INVALID_FILTER_OPERATION`,u.length);if(c===`Flat`){let e=new Set(l?s.filterArr(i):s.filter(i));a[o]=lj(a[o],e);continue}if(c===`AVL`){let e=u[0],t=i[e],n;switch(e){case`gt`:n=s.greaterThan(t,!1);break;case`gte`:n=s.greaterThan(t,!0);break;case`lt`:n=s.lessThan(t,!1);break;case`lte`:n=s.lessThan(t,!0);break;case`eq`:n=s.find(t)??new Set;break;case`between`:{let[e,r]=t;n=s.rangeSearch(e,r);break}default:throw $(`INVALID_FILTER_OPERATION`,e)}a[o]=lj(a[o],n)}}return sj(...Object.values(a))}function SM(e){return e.searchableProperties}function CM(e){return e.searchablePropertiesWithTypes}function wM(e,t){let{indexes:n,vectorIndexes:r,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}=t,u={},d={};for(let e of Object.keys(n)){let{node:t,type:r,isArray:i}=n[e];switch(r){case`Radix`:u[e]={type:`Radix`,node:$j.fromJSON(t),isArray:i};break;case`Flat`:u[e]={type:`Flat`,node:Yj.fromJSON(t),isArray:i};break;case`AVL`:u[e]={type:`AVL`,node:Jj.fromJSON(t),isArray:i};break;case`BKD`:u[e]={type:`BKD`,node:rM.fromJSON(t),isArray:i};break;case`Bool`:u[e]={type:`Bool`,node:iM.fromJSON(t),isArray:i};break;default:u[e]=n[e]}}for(let e of Object.keys(r))d[e]={type:`Vector`,isArray:!1,node:oM.fromJSON(r[e])};return{sharedInternalDocumentStore:e,indexes:u,vectorIndexes:d,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}}function TM(e){let{indexes:t,vectorIndexes:n,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}=e,l={};for(let e of Object.keys(n))l[e]=n[e].node.toJSON();let u={};for(let e of Object.keys(t)){let{type:n,node:r,isArray:i}=t[e];n===`Flat`||n===`Radix`||n===`AVL`||n===`BKD`||n===`Bool`?u[e]={type:n,node:r.toJSON(),isArray:i}:(u[e]=t[e],u[e].node=u[e].node.toJSON())}return{indexes:u,vectorIndexes:l,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}}function EM(){return{create:pM,insert:hM,remove:vM,insertDocumentScoreParameters:lM,insertTokenScoreParameters:uM,removeDocumentScoreParameters:dM,removeTokenScoreParameters:fM,calculateResultScores:yM,search:bM,searchByWhereClause:xM,getSearchableProperties:SM,getSearchablePropertiesWithTypes:CM,load:wM,save:TM}}function DM(e,t){e||=new Set;let n=t.length;for(let r=0;r<n;r++){let n=t[r].docIDs,i=n.length;for(let t=0;t<i;t++)e.add(n[t])}return e}function OM(e,t,n=!1){let r=n?rM.vincentyDistance:rM.haversineDistance,i=[],a=[];for(let{point:n}of e)a.push(r(t,n));let o=Math.max(...a),s=0;for(let{docIDs:t}of e){let e=o-a[s]+1;for(let n of t)i.push([n,e]);s++}return i.sort((e,t)=>t[1]-e[1]),i}function kM(e,t){let n=Object.keys(e);if(n.length!==1)return{isGeoOnly:!1};let r=n[0],i=e[r];if(t.indexes[r]===void 0)return{isGeoOnly:!1};let{type:a}=t.indexes[r];return a===`BKD`&&i&&(`radius`in i||`polygon`in i)?{isGeoOnly:!0,geoProperty:r,geoOperation:i}:{isGeoOnly:!1}}function AM(e,t){let n=e,r=kM(t,n);if(!r.isGeoOnly||!r.geoProperty||!r.geoOperation)return null;let{node:i}=n.indexes[r.geoProperty],a=r.geoOperation,o=i,s;if(`radius`in a){let{value:e,coordinates:t,unit:n=`m`,inside:r=!0,highPrecision:i=!1}=a.radius,c=t,l=rj(e,n);return s=o.searchByRadius(c,l,r,`asc`,i),OM(s,c,i)}else if(`polygon`in a){let{coordinates:e,inside:t=!0,highPrecision:n=!1}=a.polygon;s=o.searchByPolygon(e,t,`asc`,n);let r=rM.calculatePolygonCentroid(e);return OM(s,r,n)}return null}function jM(e,t){e||=new Set;let n=Object.keys(t),r=n.length;for(let i=0;i<r;i++){let r=t[n[i]],a=r.length;for(let t=0;t<a;t++)e.add(r[t])}return e}function MM(e,t,n,r,i){let a={language:e.tokenizer.language,sharedInternalDocumentStore:t,enabled:!0,isSorted:!0,sortableProperties:[],sortablePropertiesWithTypes:{},sorts:{}};for(let[o,s]of Object.entries(n)){let n=`${i}${i?`.`:``}${o}`;if(!r.includes(n)){if(typeof s==`object`&&!Array.isArray(s)){let i=MM(e,t,s,r,n);UA(a.sortableProperties,i.sortableProperties),a.sorts={...a.sorts,...i.sorts},a.sortablePropertiesWithTypes={...a.sortablePropertiesWithTypes,...i.sortablePropertiesWithTypes};continue}if(!yj(s))switch(s){case`boolean`:case`number`:case`string`:a.sortableProperties.push(n),a.sortablePropertiesWithTypes[n]=s,a.sorts[n]={docs:new Map,orderedDocsToRemove:new Map,orderedDocs:[],type:s};break;case`geopoint`:case`enum`:continue;case`enum[]`:case`boolean[]`:case`number[]`:case`string[]`:continue;default:throw $(`INVALID_SORT_SCHEMA_TYPE`,Array.isArray(s)?`array`:s,n)}}}return a}function NM(e,t,n,r){return r?.enabled===!1?{disabled:!0}:MM(e,t,n,(r||{}).unsortableProperties||[],``)}function PM(e,t,n,r){if(!e.enabled)return;e.isSorted=!1;let i=Ej(e.sharedInternalDocumentStore,n),a=e.sorts[t];a.orderedDocsToRemove.has(i)&&VM(e,t),a.docs.set(i,a.orderedDocs.length),a.orderedDocs.push([i,r])}function FM(e){if(e.isSorted||!e.enabled)return;let t=Object.keys(e.sorts);for(let n of t)zM(e,n);e.isSorted=!0}function IM(e,t,n){return t[1].localeCompare(n[1],IA(e))}function LM(e,t){return e[1]-t[1]}function RM(e,t){return t[1]?-1:1}function zM(e,t){let n=e.sorts[t],r;switch(n.type){case`string`:r=IM.bind(null,e.language);break;case`number`:r=LM.bind(null);break;case`boolean`:r=RM.bind(null);break}n.orderedDocs.sort(r);let i=n.orderedDocs.length;for(let e=0;e<i;e++){let t=n.orderedDocs[e][0];n.docs.set(t,e)}}function BM(e){let t=Object.keys(e.sorts);for(let n of t)VM(e,n)}function VM(e,t){let n=e.sorts[t];n.orderedDocsToRemove.size&&(n.orderedDocs=n.orderedDocs.filter(e=>!n.orderedDocsToRemove.has(e[0])),n.orderedDocsToRemove.clear())}function HM(e,t,n){if(!e.enabled)return;let r=e.sorts[t],i=Ej(e.sharedInternalDocumentStore,n);r.docs.get(i)&&(r.docs.delete(i),r.orderedDocsToRemove.set(i,!0))}function UM(e,t,n){if(!e.enabled)throw $(`SORT_DISABLED`);let r=n.property,i=n.order===`DESC`,a=e.sorts[r];if(!a)throw $(`UNABLE_TO_SORT_ON_UNKNOWN_FIELD`,r,e.sortableProperties.join(`, `));return VM(e,r),FM(e),t.sort((t,n)=>{let r=a.docs.get(Ej(e.sharedInternalDocumentStore,t[0])),o=a.docs.get(Ej(e.sharedInternalDocumentStore,n[0])),s=r!==void 0,c=o!==void 0;return!s&&!c?0:s?c?i?o-r:r-o:-1:1}),t}function WM(e){return e.enabled?e.sortableProperties:[]}function GM(e){return e.enabled?e.sortablePropertiesWithTypes:{}}function KM(e,t){let n=t;if(!n.enabled)return{enabled:!1};let r=Object.keys(n.sorts).reduce((e,t)=>{let{docs:r,orderedDocs:i,type:a}=n.sorts[t];return e[t]={docs:new Map(Object.entries(r).map(([e,t])=>[+e,t])),orderedDocsToRemove:new Map,orderedDocs:i,type:a},e},{});return{sharedInternalDocumentStore:e,language:n.language,sortableProperties:n.sortableProperties,sortablePropertiesWithTypes:n.sortablePropertiesWithTypes,sorts:r,enabled:!0,isSorted:n.isSorted}}function qM(e){if(!e.enabled)return{enabled:!1};BM(e),FM(e);let t=Object.keys(e.sorts).reduce((t,n)=>{let{docs:r,orderedDocs:i,type:a}=e.sorts[n];return t[n]={docs:Object.fromEntries(r.entries()),orderedDocs:i,type:a},t},{});return{language:e.language,sortableProperties:e.sortableProperties,sortablePropertiesWithTypes:e.sortablePropertiesWithTypes,sorts:t,enabled:e.enabled,isSorted:e.isSorted}}function JM(){return{create:NM,insert:PM,remove:HM,save:qM,load:KM,sortBy:UM,getSortableProperties:WM,getSortablePropertiesWithTypes:GM}}var YM=192,XM=383,ZM=[65,65,65,65,65,65,65,67,69,69,69,69,73,73,73,73,69,78,79,79,79,79,79,null,79,85,85,85,85,89,80,115,97,97,97,97,97,97,97,99,101,101,101,101,105,105,105,105,101,110,111,111,111,111,111,null,111,117,117,117,117,121,112,121,65,97,65,97,65,97,67,99,67,99,67,99,67,99,68,100,68,100,69,101,69,101,69,101,69,101,69,101,71,103,71,103,71,103,71,103,72,104,72,104,73,105,73,105,73,105,73,105,73,105,73,105,74,106,75,107,107,76,108,76,108,76,108,76,108,76,108,78,110,78,110,78,110,110,78,110,79,111,79,111,79,111,79,111,82,114,82,114,82,114,83,115,83,115,83,115,83,115,84,116,84,116,84,116,85,117,85,117,85,117,85,117,85,117,85,117,87,119,89,121,89,90,122,90,122,90,122,115];function QM(e){return e<YM||e>XM?e:ZM[e-YM]||e}function $M(e){let t=[];for(let n=0;n<e.length;n++)t[n]=QM(e.charCodeAt(n));return String.fromCharCode(...t)}var eN={ational:`ate`,tional:`tion`,enci:`ence`,anci:`ance`,izer:`ize`,bli:`ble`,alli:`al`,entli:`ent`,eli:`e`,ousli:`ous`,ization:`ize`,ation:`ate`,ator:`ate`,alism:`al`,iveness:`ive`,fulness:`ful`,ousness:`ous`,aliti:`al`,iviti:`ive`,biliti:`ble`,logi:`log`},tN={icate:`ic`,ative:``,alize:`al`,iciti:`ic`,ical:`ic`,ful:``,ness:``},nN=`[^aeiou]`,rN=`[aeiouy]`,iN=nN+`[^aeiouy]*`;rN+``;var aN=`^(`+iN+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,oN=`^(`+iN+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$`,sN=`^(`+iN+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,cN=`^(`+iN+`)?[aeiouy]`;function lN(e){let t,n,r,i,a,o;if(e.length<3)return e;let s=e.substring(0,1);if(s==`y`&&(e=s.toUpperCase()+e.substring(1)),r=/^(.+?)(ss|i)es$/,i=/^(.+?)([^s])s$/,r.test(e)?e=e.replace(r,`$1$2`):i.test(e)&&(e=e.replace(i,`$1$2`)),r=/^(.+?)eed$/,i=/^(.+?)(ed|ing)$/,r.test(e)){let t=r.exec(e);r=new RegExp(aN),r.test(t[1])&&(r=/.$/,e=e.replace(r,``))}else i.test(e)&&(t=i.exec(e)[1],i=new RegExp(cN),i.test(t)&&(e=t,i=/(at|bl|iz)$/,a=RegExp(`([^aeiouylsz])\\1$`),o=RegExp(`^`+iN+rN+`[^aeiouwxy]$`),i.test(e)?e+=`e`:a.test(e)?(r=/.$/,e=e.replace(r,``)):o.test(e)&&(e+=`e`)));if(r=/^(.+?)y$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(cN),t&&r.test(t)&&(e=t+`i`)),r=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(aN),t&&r.test(t)&&(e=t+eN[n])}if(r=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(aN),t&&r.test(t)&&(e=t+tN[n])}if(r=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,i=/^(.+?)(s|t)(ion)$/,r.test(e))t=r.exec(e)?.[1],r=new RegExp(sN),t&&r.test(t)&&(e=t);else if(i.test(e)){let n=i.exec(e);t=n?.[1]??``+n?.[2]??``,i=new RegExp(sN),i.test(t)&&(e=t)}return r=/^(.+?)e$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(sN),i=new RegExp(oN),a=RegExp(`^`+iN+rN+`[^aeiouwxy]$`),t&&(r.test(t)||i.test(t)&&!a.test(t))&&(e=t)),r=/ll$/,i=new RegExp(sN),r.test(e)&&i.test(e)&&(r=/.$/,e=e.replace(r,``)),s==`y`&&(e=s.toLowerCase()+e.substring(1)),e}function uN(e,t,n=!0){let r=`${this.language}:${e}:${t}`;return n&&this.normalizationCache.has(r)?this.normalizationCache.get(r):this.stopWords?.includes(t)?(n&&this.normalizationCache.set(r,``),``):(this.stemmer&&!this.stemmerSkipProperties.has(e)&&(t=this.stemmer(t)),t=$M(t),n&&this.normalizationCache.set(r,t),t)}function dN(e){for(;e[e.length-1]===``;)e.pop();for(;e[0]===``;)e.shift();return e}function fN(e,t,n,r=!0){if(t&&t!==this.language)throw $(`LANGUAGE_NOT_SUPPORTED`,t);if(typeof e!=`string`)return[e];let i=this.normalizeToken.bind(this,n??``),a;if(n&&this.tokenizeSkipProperties.has(n))a=[i(e,r)];else{let t=PA[this.language];a=e.toLowerCase().split(t).map(e=>i(e,r)).filter(Boolean)}let o=dN(a);return this.allowDuplicates?o:Array.from(new Set(o))}function pN(e={}){if(!e.language)e.language=`english`;else if(!FA.includes(e.language))throw $(`LANGUAGE_NOT_SUPPORTED`,e.language);let t;if(e.stemming||e.stemmer&&!(`stemming`in e))if(e.stemmer){if(typeof e.stemmer!=`function`)throw $(`INVALID_STEMMER_FUNCTION_TYPE`);t=e.stemmer}else if(e.language===`english`)t=lN;else throw $(`MISSING_STEMMER`,e.language);let n;if(e.stopWords!==!1){if(n=[],Array.isArray(e.stopWords))n=e.stopWords;else if(typeof e.stopWords==`function`)n=e.stopWords(n);else if(e.stopWords)throw $(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);if(!Array.isArray(n))throw $(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);for(let e of n)if(typeof e!=`string`)throw $(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`)}let r={tokenize:fN,language:e.language,stemmer:t,stemmerSkipProperties:new Set(e.stemmerSkipProperties?[e.stemmerSkipProperties].flat():[]),tokenizeSkipProperties:new Set(e.tokenizeSkipProperties?[e.tokenizeSkipProperties].flat():[]),stopWords:n,allowDuplicates:!!e.allowDuplicates,normalizeToken:uN,normalizationCache:new Map};return r.tokenize=fN.bind(r),r.normalizeToken=uN,r}function mN(e){return{sharedInternalDocumentStore:e,rules:new Map}}function hN(e,t){if(e.rules.has(t.id))throw Error(`PINNING_RULE_ALREADY_EXISTS: A pinning rule with id "${t.id}" already exists. Use updateRule to modify it.`);e.rules.set(t.id,t)}function gN(e,t){if(!e.rules.has(t.id))throw Error(`PINNING_RULE_NOT_FOUND: Cannot update pinning rule with id "${t.id}" because it does not exist. Use addRule to create it.`);e.rules.set(t.id,t)}function _N(e,t){return e.rules.delete(t)}function vN(e,t){return e.rules.get(t)}function yN(e){return Array.from(e.rules.values())}function bN(e,t){let n=e.toLowerCase().trim(),r=t.pattern.toLowerCase().trim();switch(t.anchoring){case`is`:return n===r;case`starts_with`:return n.startsWith(r);case`contains`:return n.includes(r);default:return!1}}function xN(e,t){return e?t.conditions.every(t=>bN(e,t)):!1}function SN(e,t){if(!t)return[];let n=[];for(let r of e.rules.values())xN(t,r)&&n.push(r);return n}function CN(e,t){return{sharedInternalDocumentStore:e,rules:new Map(t?.rules??[])}}function wN(e){return{rules:Array.from(e.rules.entries())}}function TN(){return{create:mN,addRule:hN,updateRule:gN,removeRule:_N,getRule:vN,getAllRules:yN,getMatchingRules:SN,load:CN,save:wN}}function EN(e){let t={formatElapsedTime:pj,getDocumentIndexId:mj,getDocumentProperties:ej,validateSchema:hj};for(let n of Vj){let r=n;if(e[r]){if(typeof e[r]!=`function`)throw $(`COMPONENT_MUST_BE_FUNCTION`,r)}else e[r]=t[r]}for(let t of Object.keys(e))if(!Bj.includes(t)&&!Vj.includes(t))throw $(`UNSUPPORTED_COMPONENT`,t)}function DN({schema:e,sort:t,language:n,components:r,id:i,plugins:a}){r||={};for(let t of a??[]){if(!(`getComponents`in t)||typeof t.getComponents!=`function`)continue;let n=t.getComponents(e),i=Object.keys(n);for(let e of i)if(r[e])throw $(`PLUGIN_COMPONENT_CONFLICT`,e,t.name);r={...r,...n}}i||=XA();let o=r.tokenizer,s=r.index,c=r.documentsStore,l=r.sorter,u=r.pinning;if(o=o?o.tokenize?o:pN(o):pN({language:n??`english`}),r.tokenizer&&n)throw $(`NO_LANGUAGE_WITH_CUSTOM_TOKENIZER`);let d=Cj();s||=EM(),l||=JM(),c||=Lj(),u||=TN(),EN(r);let{getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,formatElapsedTime:h}=r,g={data:{},caches:{},schema:e,tokenizer:o,index:s,sorter:l,documentsStore:c,pinning:u,internalDocumentIDStore:d,getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,beforeInsert:[],afterInsert:[],beforeRemove:[],afterRemove:[],beforeUpdate:[],afterUpdate:[],beforeUpsert:[],afterUpsert:[],beforeSearch:[],afterSearch:[],beforeInsertMultiple:[],afterInsertMultiple:[],beforeRemoveMultiple:[],afterRemoveMultiple:[],beforeUpdateMultiple:[],afterUpdateMultiple:[],beforeUpsertMultiple:[],afterUpsertMultiple:[],afterCreate:[],formatElapsedTime:h,id:i,plugins:a,version:ON()};g.data={index:g.index.create(g,d,e),docs:g.documentsStore.create(g,d),sorting:g.sorter.create(g,d,e,t),pinning:g.pinning.create(d)};for(let e of Rj)g[e]=(g[e]??[]).concat(zj(g,e));let _=g.afterCreate;return _&&Kj(_,g),g}function ON(){return`{{VERSION}}`}function kN(e){return e.documentsStore.count(e.data.docs)}function AN(e,t,n,r,i){let a=e.validateSchema(t,e.schema);if(a)throw $(`SCHEMA_VALIDATION_FAILURE`,a);return aj(e.beforeInsert)||aj(e.afterInsert)||aj(e.index.beforeInsert)||aj(e.index.insert)||aj(e.index.afterInsert)?NN(e,t,n,r,i):PN(e,t,n,r,i)}var jN=new Set([`enum`,`enum[]`]),MN=new Set([`string`,`number`]);async function NN(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw $(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=Ej(e.internalDocumentIDStore,s);if(r||await Hj(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw $(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];FN(n,r,e,t)}return await IN(e,s,u,f,l,n,t,i),r||await Hj(e.afterInsert,e,s,t),s}function PN(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw $(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=Ej(e.internalDocumentIDStore,s);if(r||Hj(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw $(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];FN(n,r,e,t)}return LN(e,s,u,f,l,n,t,i),r||Hj(e.afterInsert,e,s,t),s}function FN(e,t,n,r){if(!(vj(t)&&typeof r==`object`&&typeof r.lon==`number`&&typeof r.lat==`number`)&&!(yj(t)&&Array.isArray(r))&&!(bj(t)&&Array.isArray(r))&&!(jN.has(t)&&MN.has(e))&&e!==t)throw $(`INVALID_DOCUMENT_PROPERTY`,n,t,e)}async function IN(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o];await e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i);let l=e.internalDocumentIDStore.idToInternalId.get(t);await e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),await e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function LN(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o],l=Ej(e.internalDocumentIDStore,t);e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i),e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function RN(e,t,n,r,i,a){return aj(e.afterInsertMultiple)||aj(e.beforeInsertMultiple)||aj(e.index.beforeInsert)||aj(e.index.insert)||aj(e.index.afterInsert)?zN(e,t,n,r,i,a):BN(e,t,n,r,i,a)}async function zN(e,t,n=1e3,r,i,a=0){let o=[],s=async a=>{let s=Math.min(a+n,t.length),c=t.slice(a,s);for(let t of c){let n=await AN(e,t,r,i,{avlRebalanceThreshold:c.length});o.push(n)}return s};return await(async()=>{let e=0;for(;e<t.length;){let t=Date.now();if(e=await s(e),a>0){let e=a-(Date.now()-t);e>0&&dj(e)}}})(),i||await Uj(e.afterInsertMultiple,e,t),o}function BN(e,t,n=1e3,r,i,a=0){let o=[],s=0;function c(){let a=t.slice(s*n,(s+1)*n);if(a.length===0)return!1;for(let t of a){let n=AN(e,t,r,i,{avlRebalanceThreshold:a.length});o.push(n)}return s++,!0}function l(){let e=Date.now();for(;c();)if(a>0){let t=Date.now()-e;if(t>=a){let e=a-t%a;e>0&&dj(e)}}}return l(),i||Uj(e.afterInsertMultiple,e,t),o}function VN(e,t){return e[1]-t[1]}function HN(e,t){return t[1]-e[1]}function UN(e=`desc`){return e.toLowerCase()===`asc`?VN:HN}function WN(e,t,n){let r={},i=t.map(([e])=>e),a=e.documentsStore.getMultiple(e.data.docs,i),o=Object.keys(n),s=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e of o){let t;if(s[e]===`number`){let{ranges:r}=n[e],i=r.length,a=Array.from({length:i});for(let e=0;e<i;e++){let t=r[e];a[e]=[`${t.from}-${t.to}`,0]}t=Object.fromEntries(a)}r[e]={count:0,values:t??{}}}let c=a.length;for(let e=0;e<c;e++){let t=a[e];for(let e of o){let i=e.includes(`.`)?tj(t,e):t[e],a=s[e],o=r[e].values;switch(a){case`number`:{let t=n[e].ranges;GN(t,o)(i);break}case`number[]`:{let t=new Set,r=n[e].ranges,a=GN(r,o,t);for(let e of i)a(e);break}case`boolean`:case`enum`:case`string`:KN(o,a)(i);break;case`boolean[]`:case`enum[]`:case`string[]`:{let e=KN(o,a===`boolean[]`?`boolean`:`string`,new Set);for(let t of i)e(t);break}default:throw $(`FACET_NOT_SUPPORTED`,a)}}}for(let e of o){let t=r[e];if(t.count=Object.keys(t.values).length,s[e]===`string`){let r=n[e],i=UN(r.sort);t.values=Object.fromEntries(Object.entries(t.values).sort(i).slice(r.offset??0,r.limit??10))}}return r}function GN(e,t,n){return r=>{for(let i of e){let e=`${i.from}-${i.to}`;n?.has(e)||r>=i.from&&r<=i.to&&(t[e]===void 0?t[e]=1:(t[e]++,n?.add(e)))}}}function KN(e,t,n){let r=t===`boolean`?`false`:``;return t=>{let i=t?.toString()??r;n?.has(i)||(e[i]=(e[i]??0)+1,n?.add(i))}}var qN={reducer:(e,t,n,r)=>(t[r]=n,t),getInitialValue:e=>Array.from({length:e})},JN=[`string`,`number`,`boolean`];function YN(e,t,n){let r=n.properties,i=r.length,a=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e=0;e<i;e++){let t=r[e];if(a[t]===void 0)throw $(`UNKNOWN_GROUP_BY_PROPERTY`,t);if(!JN.includes(a[t]))throw $(`INVALID_GROUP_BY_PROPERTY`,t,JN.join(`, `),a[t])}let o=t.map(([t])=>Dj(e.internalDocumentIDStore,t)),s=e.documentsStore.getMultiple(e.data.docs,o),c=s.length,l=n.maxResult||2**53-1,u=[],d={};for(let e=0;e<i;e++){let t=r[e],n={property:t,perValue:{}},i=new Set;for(let e=0;e<c;e++){let r=s[e],a=tj(r,t);if(a===void 0)continue;let o=typeof a==`boolean`?``+a:a,c=n.perValue[o]??{indexes:[],count:0};c.count>=l||(c.indexes.push(e),c.count++,n.perValue[o]=c,i.add(a))}u.push(Array.from(i)),d[t]=n}let f=XN(u),p=f.length,m=[];for(let e=0;e<p;e++){let t=f[e],n=t.length,i={values:[],indexes:[]},a=[];for(let e=0;e<n;e++){let n=t[e],o=r[e];a.push(d[o].perValue[typeof n==`boolean`?``+n:n].indexes),i.values.push(n)}i.indexes=$A(a).sort((e,t)=>e-t),i.indexes.length!==0&&m.push(i)}let h=m.length,g=Array.from({length:h});for(let e=0;e<h;e++){let r=m[e],i=n.reduce||qN,a=r.indexes.map(e=>({id:o[e],score:t[e][1],document:s[e]})),c=i.reducer.bind(null,r.values),l=i.getInitialValue(r.indexes.length),u=a.reduce(c,l);g[e]={values:r.values,result:u}}return g}function XN(e,t=0){if(t+1===e.length)return e[t].map(e=>[e]);let n=e[t],r=XN(e,t+1),i=[];for(let e of n)for(let t of r){let n=[e];UA(n,t),i.push(n)}return i}function ZN(e,t,n,r){let i=SN(t,r);if(i.length===0)return n;let a=i.flatMap(e=>e.consequence.promote);a.sort((e,t)=>e.position-t.position);let o=new Set,s=new Map,c=new Set;for(let t of a){let n=Ej(e.internalDocumentIDStore,t.doc_id);if(n!==void 0){if(s.has(n)){let e=s.get(n);t.position<e&&s.set(n,t.position);continue}c.has(t.position)||(o.add(n),s.set(n,t.position),c.add(t.position))}}if(s.size===0)return n;let l=n.filter(([e])=>!o.has(e)),u=[];for(let[t,r]of s.entries())n.find(([e])=>e===t)?u.push([t,1e6-r]):e.documentsStore.get(e.data.docs,t)&&u.push([t,0]);u.sort((e,t)=>(s.get(e[0])??1/0)-(s.get(t[0])??1/0));let d=[],f=new Map;for(let e of u){let t=s.get(e[0]);f.set(t,e)}let p=0,m=0;for(;m<l.length+u.length;)if(f.has(m))d.push(f.get(m)),m++;else if(p<l.length)d.push(l[p]),p++,m++;else break;for(let[e,t]of f.entries())e>=d.length&&d.push(t);return d}function QN(e,t,n){let{term:r,properties:i}=t,a=e.data.index,o=e.caches.propertiesToSearch;if(!o){let t=e.index.getSearchablePropertiesWithTypes(a);o=e.index.getSearchableProperties(a),o=o.filter(e=>t[e].startsWith(`string`)),e.caches.propertiesToSearch=o}if(i&&i!==`*`){for(let e of i)if(!o.includes(e))throw $(`UNKNOWN_INDEX`,e,o.join(`, `));o=o.filter(e=>i.includes(e))}let s=Object.keys(t.where??{}).length>0,c;s&&(c=e.index.searchByWhereClause(a,e.tokenizer,t.where,n));let l,u=t.threshold!==void 0&&t.threshold!==null?t.threshold:1;if(r||i){let i=kN(e);if(l=e.index.search(a,r||``,e.tokenizer,n,o,t.exact||!1,t.tolerance||0,t.boost||{},rP(t.relevance),i,c,u),t.exact&&r){let t=r.trim().split(/\s+/);l=l.filter(([n])=>{let r=e.documentsStore.get(e.data.docs,n);if(!r)return!1;for(let e of o){let n=eP(r,e);if(typeof n==`string`&&t.every(e=>RegExp(`\\b${$N(e)}\\b`).test(n)))return!0}return!1})}}else l=s?AM(a,t.where)||(c?Array.from(c):[]).map(e=>[+e,0]):Object.keys(e.documentsStore.getAll(e.data.docs)).map(e=>[+e,0]);return l}function $N(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function eP(e,t){let n=t.split(`.`),r=e;for(let e of n)if(r&&typeof r==`object`&&e in r)r=r[e];else return;return r}function tP(e,t,n){let r=YA();function i(){let i=Object.keys(e.data.index.vectorIndexes),a=t.facets&&Object.keys(t.facets).length>0,{limit:o=10,offset:s=0,distinctOn:c,includeVectors:l=!1}=t,u=t.preflight===!0,d=QN(e,t,n);if(t.sortBy)if(typeof t.sortBy==`function`){let n=d.map(([e])=>e),r=e.documentsStore.getMultiple(e.data.docs,n).map((e,t)=>[d[t][0],d[t][1],e]);r.sort(t.sortBy),d=r.map(([e,t])=>[e,t])}else d=e.sorter.sortBy(e.data.sorting,d,t.sortBy).map(([t,n])=>[Ej(e.internalDocumentIDStore,t),n]);else d=d.sort(QA);d=ZN(e,e.data.pinning,d,t.term);let f;u||(f=c?hP(e,d,s,o,c):gP(e,d,s,o));let p={elapsed:{formatted:``,raw:0},hits:[],count:d.length};return f!==void 0&&(p.hits=f.filter(Boolean),l||ij(p,i)),a&&(p.facets=WN(e,d,t.facets)),t.groupBy&&(p.groups=YN(e,d,t.groupBy)),p.elapsed=e.formatElapsedTime(YA()-r),p}async function a(){e.beforeSearch&&await Gj(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await Wj(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}var nP={k:1.2,b:.75,d:.5};function rP(e){let t=e??{};return t.k=t.k??nP.k,t.b=t.b??nP.b,t.d=t.d??nP.d,t}function iP(e,t,n){let r=t.vector;if(r&&(!(`value`in r)||!(`property`in r)))throw $(`INVALID_VECTOR_INPUT`,Object.keys(r).join(`, `));let i=e.data.index.vectorIndexes[r.property];if(!i)throw $(`UNKNOWN_VECTOR_PROPERTY`,r.property);let a=i.node.size;if(r?.value.length!==a)throw r?.property===void 0||r?.value.length===void 0?$(`INVALID_INPUT_VECTOR`,`undefined`,a,`undefined`):$(`INVALID_INPUT_VECTOR`,r.property,a,r.value.length);let o=e.data.index,s;return Object.keys(t.where??{}).length>0&&(s=e.index.searchByWhereClause(o,e.tokenizer,t.where,n)),i.node.find(r.value,t.similarity??.8,s)}function aP(e,t,n=`english`){let r=YA();function i(){let i=iP(e,t,n).sort(QA);i=ZN(e,e.data.pinning,i,void 0);let a=[];t.facets&&Object.keys(t.facets).length>0&&(a=WN(e,i,t.facets));let o=t.vector.property,s=t.includeVectors??!1,c=t.limit??10,l=t.offset??0,u=Array.from({length:c});for(let t=0;t<c;t++){let n=i[t+l];if(!n)break;let r=e.data.docs.docs[n[0]];r&&(s||(r[o]=null),u[t]={id:Dj(e.internalDocumentIDStore,n[0]),score:n[1],document:r})}let d=[];t.groupBy&&(d=YN(e,i,t.groupBy));let f=YA()-r;return{count:i.length,hits:u.filter(Boolean),elapsed:{raw:Number(f),formatted:JA(f)},...a?{facets:a}:{},...d?{groups:d}:{}}}async function a(){e.beforeSearch&&await Gj(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await Wj(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function oP(e,t,n){let r=lP(QN(e,t,n)),i=iP(e,t,n),a=t.hybridWeights;return fP(r,i,t.term??``,a)}function sP(e,t,n){let r=YA();function i(){let i=oP(e,t,n);i=ZN(e,e.data.pinning,i,t.term);let a;t.facets&&Object.keys(t.facets).length>0&&(a=WN(e,i,t.facets));let o;t.groupBy&&(o=YN(e,i,t.groupBy));let s=t.offset??0,c=t.limit??10,l=gP(e,i,s,c).filter(Boolean),u=YA(),d={count:i.length,elapsed:{raw:Number(u-r),formatted:JA(u-r)},hits:l,...a?{facets:a}:{},...o?{groups:o}:{}};return(t.includeVectors??!1)||ij(d,Object.keys(e.data.index.vectorIndexes)),d}async function a(){e.beforeSearch&&await Gj(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await Wj(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function cP(e){return e[1]}function lP(e){let t=Math.max.apply(Math,e.map(cP));return e.map(([e,n])=>[e,n/t])}function uP(e,t){return e/t}function dP(e,t){return(n,r)=>n*e+r*t}function fP(e,t,n,r){let i=Math.max.apply(Math,e.map(cP)),a=Math.max.apply(Math,t.map(cP)),{text:o,vector:s}=r&&r.text&&r.vector?r:pP(n),c=new Map,l=e.length,u=dP(o,s);for(let t=0;t<l;t++){let[n,r]=e[t],a=u(uP(r,i),0);c.set(n,a)}let d=t.length;for(let e=0;e<d;e++){let[n,r]=t[e],i=uP(r,a),o=c.get(n)??0;c.set(n,o+u(0,i))}return[...c].sort((e,t)=>t[1]-e[1])}function pP(e){return{text:.5,vector:.5}}function mP(e,t,n){let r=t.mode??`fulltext`;if(r===`fulltext`)return tP(e,t,n);if(r===`vector`)return aP(e,t);if(r===`hybrid`)return sP(e,t);throw $(`INVALID_SEARCH_MODE`,r)}function hP(e,t,n,r,i){let a=e.data.docs,o=new Map,s=[],c=new Set,l=t.length,u=0;for(let d=0;d<l;d++){let l=t[d];if(l===void 0)continue;let[f,p]=l;if(c.has(f))continue;let m=e.documentsStore.get(a,f),h=tj(m,i);if(!(h===void 0||o.has(h))&&(o.set(h,!0),u++,!(u<=n)&&(s.push({id:Dj(e.internalDocumentIDStore,f),score:p,document:m}),c.add(f),u>=n+r)))break}return s}function gP(e,t,n,r){let i=e.data.docs,a=Array.from({length:r}),o=new Set;for(let s=n;s<r+n;s++){let n=t[s];if(n===void 0)break;let[r,c]=n;if(!o.has(r)){let t=e.documentsStore.get(i,r);a[s]={id:Dj(e.internalDocumentIDStore,r),score:c,document:t},o.add(r)}}return a}var _P=100,vP=500,yP=450,bP={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},xP=new WeakMap;function SP(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function CP(e){return e.trim().toLowerCase()}var wP=/\.(?:md|mdx)$/;function TP(e,t){if(t!==`page`)return e;let n=e.replace(wP,``);return n.length>0?n:e}function EP(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function DP(e){let t=EP(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0,i=e.path.split(`/`).filter(Boolean),a=new Set(i),o=[...new Set((e.aliases??[]).flatMap(e=>e.split(`/`).filter(Boolean)).filter(e=>!a.has(e)))];return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:[...i,...o].join(` `),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}var OP=/[^\P{L}a-zàèéìòóù]|[^\P{Nd}0-9]|\p{Nl}/iu,kP=(()=>{let e=globalThis.Intl.Segmenter;return e?new e(`en`,{granularity:`word`}):null})();function AP(){let e=pN({language:`english`}),t=e.tokenize.bind(e);return e.tokenize=(e,n,r,i)=>{let a=t(e,n,r,i);if(!kP||typeof e!=`string`||!OP.test(e))return a;let o=new Set(a);for(let{segment:t,isWordLike:n}of kP.segment(e)){if(!n||!OP.test(t))continue;let e=t.toLowerCase();o.has(e)||(o.add(e),a.push(e))}return a},e}function jP(e){let t=DN({schema:bP,components:{tokenizer:AP()}});return e.length>0&&RN(t,e),t}function MP(e){let t={documents:e};return xP.set(t,jP(e)),t}function NP(e){let t=xP.get(e);if(t)return t;let n=jP(e.documents);return xP.set(e,n),n}function PP(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function FP(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function IP(e,t){let n=CP(t);if(!n)return 0;let r=TP(n,e.kind),i=CP(e.title),a=CP(e.name),o=CP(e.path),s=o.split(`/`);return i===r||a===r?700:o===r?650:i.startsWith(r)||a.startsWith(r)?600:s.some(e=>e.startsWith(r))?550:i.includes(r)||a.includes(r)?500:o.includes(r)?450:-1}var LP=.5;function RP(e,t){let n=IP(e,t);return n<=0?n:Ke(e.path)?n*LP:n}function zP(e){return e===`file`?-60:0}var BP=1e3,VP=50,HP=1,UP=1;function WP(e,t,n,r,i){let a=i>0?t/i:0,o=n/VP,s=r===`file`?-.001:0,c=HP*a+UP*o+s;return e*BP+c}function GP(e,t,n,r){return e+t*20+n+zP(r)}function KP(e,t,n,r,i,a){return e===`relevance`?GP(t,n,r,i):WP(t,n,r,i,a)}function qP(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function JP(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function YP(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function XP(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function ZP(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}var QP=/[-ក- -〿-ゟ゠-ヿ㐀-䶿一-鿿\uf900--\u1100-\u11ff\u3130-\u318f\ua960-\ua97f\uac00-\ud7ff]/;function $P(e,t){let n=CP(t);return n.length<4||QP.test(n)?0:+(e===`full_text`)}function eF(e){let{lexical:t,fullText:n}=e.signals;return t>=vP?`lexical`:t===yP&&n<=0?`pathOnly`:`body`}function tF(e){let t=[],n=[],r=[];for(let i of e){let e=eF(i);e===`lexical`?t.length<_P&&t.push(i):e===`body`?n.length<6&&n.push(i):r.length<4&&r.push(i)}return[...t,...n,...r]}function nF(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=tF(e),i=[],a=0,o=0;for(let e of r){if(e.document.kind===`folder`){if(a>=3)continue;a+=1}else if(e.document.kind===`file`){if(o>=3)continue;o+=1}if(i.push(e),i.length>=n)break}return i}function rF(e,t,n={}){let r=n.intent??`omnibar`,i=qP(r,n.ranking),a=SP(n.limit),o=new Set(n.scopes??PP(r)),s=e.documents.filter(e=>FP(e,o)),c=CP(t);if(!c)return s.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,a).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let l=mP(NP(e),{term:c,properties:XP(r),boost:ZP(r),tolerance:$P(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>FP(e.document,o)).map(e=>[e.document.id,e.score])),d=YP(s),f=new Map;for(let e of s)RP(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)FP(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=JP(f.values(),u);return nF([...f.values()].map(t=>{let n=Math.max(0,RP(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:KP(i,n,r,a,t.kind,e),signals:{lexical:n,fullText:r,recency:a}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score),i,a)}return nF(aF({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function iF(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function aF(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,ranking:o,semantic:s}=e,c=s.rrfK??60,l=s.candidateLimit??64,u=s.similarityFloor??0,d=s.scores,f=new Map(t.map(e=>[e.id,e])),p=[...d.entries()].filter(([e,t])=>t>=u&&f.has(e)).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,l);for(let[e]of p)if(!n.has(e)){let t=f.get(e);t&&n.set(e,t)}let m=JP(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,RP(e,a)),n=r.get(e.id)??0,s=i.get(e.id)??0,c=d.get(e.id),l=c!==void 0&&c>=u;return{document:e,score:t>0?KP(o,t,n,s,e.kind,m):GP(t,n,s,e.kind),signals:l?{lexical:t,fullText:n,recency:s,vector:c}:{lexical:t,fullText:n,recency:s},lexical:t,fullText:n,recency:s,cosine:c}}),g=iF(h.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=iF(h.filter(e=>e.cosine!==void 0&&e.cosine>=u).sort((e,t)=>t.cosine-e.cosine||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),v=e=>{let t=0,n=g.get(e);n!==void 0&&(t+=1/(c+n));let r=_.get(e);return r!==void 0&&(t+=1/(c+r)),t};return h.sort((e,t)=>{let n=+(e.lexical>0),r=+(t.lexical>0);if(n!==r)return r-n;if(n===1)return e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score;let i=v(e.document.id),a=v(t.document.id);return i===a?e.recency===t.recency?e.document.path.localeCompare(t.document.path):t.recency-e.recency:a-i}).map(({document:e,score:t,signals:n})=>({document:e,score:t,signals:n}))}function oF(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=je(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v<o.pos&&y>=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function sF(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,`
|
|
170
|
-
`);return/\s/.test(n)}):!1}var cF=new k(`suggestion`);function lF({pluginKey:e=cF,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:m=()=>!0,findSuggestionMatch:h=oF,shouldShow:g,shouldResetDismissed:_}){let v,y=p?.(),b=r&&!i,x=()=>{let e=t.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=t.view.coordsAtPos(e);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}},S=(n,r)=>r?()=>{let r=e.getState(t.state)?.decorationId;return n.dom.querySelector(`[data-decoration-id="${r}"]`)?.getBoundingClientRect()||null}:x,C=({match:e,dismissedRange:n,state:r,transaction:i})=>_?.({editor:t,state:r,range:n,match:e,transaction:i,allowSpaces:b})?!1:b?e.range.from===n.from:e.range.from===n.from&&!sF(i);function w(n,r){var i;try{let r=e.getState(n.state),a=r?.decorationId?n.dom.querySelector(`[data-decoration-id="${r.decorationId}"]`):null,o={editor:t,range:r?.range||{from:0,to:0},query:r?.query||null,text:r?.text||null,items:[],command:e=>d({editor:t,range:r?.range||{from:0,to:0},props:e}),decorationNode:a,clientRect:S(n,a)};(i=y?.onExit)==null||i.call(y,o)}catch{}let a=n.state.tr.setMeta(r,{exit:!0});n.dispatch(a)}let T=new M({key:e,view(){return{update:async(e,n)=>{var r,i,a,o,s;let c=this.key?.getState(n),l=this.key?.getState(e.state),u=c.active&&l.active&&c.range.from!==l.range.from,p=!c.active&&l.active,m=c.active&&!l.active,h=!p&&!m&&c.query!==l.query,g=p||u&&h,_=h||u,b=m||u&&h;if(!g&&!_&&!b)return;let x=b&&!g?c:l,C=e.dom.querySelector(`[data-decoration-id="${x.decorationId}"]`);v={editor:t,range:x.range,query:x.query,text:x.text,items:[],command:e=>d({editor:t,range:x.range,props:e}),decorationNode:C,clientRect:S(e,C)},g&&((r=y?.onBeforeStart)==null||r.call(y,v)),_&&((i=y?.onBeforeUpdate)==null||i.call(y,v)),(_||g)&&(v.items=await f({editor:t,query:x.query})),b&&((a=y?.onExit)==null||a.call(y,v)),_&&((o=y?.onUpdate)==null||o.call(y,v)),g&&((s=y?.onStart)==null||s.call(y,v))},destroy:()=>{var e;v&&((e=y?.onExit)==null||e.call(y,v))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(s,c,l,u){let{isEditable:d}=t,{composing:f}=t.view,{selection:p}=s,{empty:_,from:v}=p,y={...c},b=s.getMeta(e);if(b&&b.exit)return y.active=!1,y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null,y.dismissedRange=c.active?{...c.range}:c.dismissedRange,y;if(y.composing=f,s.docChanged&&y.dismissedRange!==null&&(y.dismissedRange={from:s.mapping.map(y.dismissedRange.from),to:s.mapping.map(y.dismissedRange.to)}),d&&(_||t.view.composing)){(v<c.range.from||v>c.range.to)&&!f&&!c.composing&&(y.active=!1);let e=h({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:p.$from}),l=`id_${Math.floor(Math.random()*4294967295)}`;e&&m({editor:t,state:u,range:e.range,isActive:c.active})&&(!g||g({editor:t,range:e.range,query:e.query,text:e.text,transaction:s}))?(y.dismissedRange!==null&&!C({match:e,dismissedRange:y.dismissedRange,state:u,transaction:s})&&(y.dismissedRange=null),y.dismissedRange===null?(y.active=!0,y.decorationId=c.decorationId?c.decorationId:l,y.range=e.range,y.query=e.query,y.text=e.text):y.active=!1):(e||(y.dismissedRange=null),y.active=!1)}else y.active=!1;return y.active||(y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null),y}},props:{handleKeyDown(t,n){var r;let{active:i,range:a}=T.getState(t.state);if(!i)return!1;if(n.key===`Escape`||n.key===`Esc`){let i=T.getState(t.state);return(r=y?.onKeyDown)==null||r.call(y,{view:t,event:n,range:i.range}),w(t,e),!0}return(y?.onKeyDown)?.call(y,{view:t,event:n,range:a})||!1},decorations(e){let{active:t,range:n,decorationId:r,query:i}=T.getState(e);if(!t)return null;let a=!i?.length,o=[c];return a&&o.push(u),me.create(e.doc,[he.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return T}var uF=lF;function dF(e){switch(e){case`image`:return Kr;case`video`:return Gr;case`audio`:return qr;default:return Wr}}function fF(e){let t=e.lastIndexOf(`.`),n=t>e.lastIndexOf(`/`)+1?e.slice(t+1).toLowerCase():``;return n===``?{kind:`folder`}:n===`md`||n===`mdx`?{kind:`page`}:{kind:`asset`,assetExt:n}}function pF(e){return e.kind===`folder`?tt:e.kind===`asset`?e.mediaKind===void 0?e.assetExt?dF(mF(e.assetExt)):Wr:dF(e.mediaKind):Wr}function mF(e){let t=e.toLowerCase().replace(/^\./,``);return hF.has(t)?`image`:gF.has(t)?`video`:_F.has(t)?`audio`:null}var hF=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`svg`,`bmp`,`ico`]),gF=new Set([`mp4`,`webm`,`mov`,`m4v`,`mkv`,`avi`]),_F=new Set([`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`]);function vF(e){if(e.kind===`create`)return(0,U.jsx)(Ur,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`});let t=e.kind===`asset`?e.path.split(`.`).pop()??``:void 0;return(0,U.jsx)(pF({kind:e.kind,assetExt:t}),{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})}function yF(e){return e.kind===`asset`?e.target:e.kind===`anchor`?`${e.docName}#${e.slug}`:e.docName}function bF(e){if(e.kind===`anchor`){let{level:t,text:n}=e;return Ge._({id:`Ik-gP0`,values:{level:t,text:n}})}if(e.kind===`asset`){let{title:t}=e;return Ge._({id:`hXbSxc`,values:{title:t}})}return e.kind===`create`?e.actionLabel:e.title}function xF(e){let t=(0,Yr.c)(55),{items:n,query:r,selectedIndex:a,onSelect:o,loading:s,error:c,mode:l,pageTarget:u,anchorQuery:d,hasMore:f}=e,p=s===void 0?!1:s,m=c===void 0?null:c,h=l===void 0?`page`:l,g=u===void 0?``:u,_=d===void 0?``:d,v=f===void 0?!1:f,{_:y}=i(),b=(0,W.useRef)(null),x=(0,W.useId)(),S=a>=0&&a<n.length?`${x}-option-${a}`:void 0,C,w;t[0]===a?(C=t[1],w=t[2]):(C=()=>{let e=b.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(a);t&&t.scrollIntoView({block:`nearest`})},w=[a],t[0]=a,t[1]=C,t[2]=w),(0,W.useEffect)(C,w);let T=SF;if(p){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;t[4]!==y||t[5]!==h||t[6]!==g?(n=y(h===`anchor`?{id:`ONgEZF`,values:{pageTarget:g}}:{id:`q6-JVU`}),t[4]=y,t[5]=h,t[6]=g,t[7]=n):n=t[7];let r;return t[8]===n?r=t[9]:(r=(0,U.jsx)(`div`,{ref:b,role:`status`,"aria-live":`polite`,className:`w-80 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:e,onMouseDown:T,children:n}),t[8]=n,t[9]=r),r}if(n.length===0){let e;if(t[10]!==y||t[11]!==_||t[12]!==m||t[13]!==h||t[14]!==g||t[15]!==r){let n=_.trim(),i=r.trim();e=m??y(h===`anchor`?n?{id:`6O626z`,values:{trimmedAnchorQuery:n}}:{id:`ct2kv5`,values:{pageTarget:g}}:i?{id:`a9OzSn`,values:{trimmedQuery:i}}:{id:`Oo_WWc`}),t[10]=y,t[11]=_,t[12]=m,t[13]=h,t[14]=g,t[15]=r,t[16]=e}else e=t[16];let n=e,i;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(i={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[17]=i):i=t[17];let a;return t[18]===n?a=t[19]:(a=(0,U.jsx)(`div`,{ref:b,role:`status`,"aria-live":`polite`,className:`w-80 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:i,onMouseDown:T,children:n}),t[18]=n,t[19]=a),a}let ee=a>=0&&a<n.length?n[a]:null,E;t[20]!==y||t[21]!==h?(E=y(h===`anchor`?{id:`xDBki3`}:{id:`i1flq_`}),t[20]=y,t[21]=h,t[22]=E):E=t[22];let te;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(te={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[23]=te):te=t[23];let ne;t[24]===ee?ne=t[25]:(ne=ee?bF(ee):``,t[24]=ee,t[25]=ne);let re;t[26]===ne?re=t[27]:(re=(0,U.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:ne}),t[26]=ne,t[27]=re);let ie;t[28]===m?ie=t[29]:(ie=m&&(0,U.jsx)(`div`,{className:`rounded-md px-2 py-1.5 text-xs text-amber-700 dark:text-amber-300`,children:m}),t[28]=m,t[29]=ie);let D;t[30]!==h||t[31]!==g?(D=h===`anchor`&&(0,U.jsx)(`div`,{className:`px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:g}),t[30]=h,t[31]=g,t[32]=D):D=t[32];let O;if(t[33]!==n||t[34]!==x||t[35]!==o||t[36]!==a){let e;t[38]!==x||t[39]!==o||t[40]!==a?(e=(e,t)=>{let n=t===a,r=yF(e);return e.kind===`anchor`?(0,U.jsxs)(`button`,{id:`${x}-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`:``}`,style:{paddingLeft:`${(e.level-1)*10+8}px`},onMouseDown:t=>{t.preventDefault(),o(e)},children:[(0,U.jsxs)(`span`,{className:`w-6 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,U.jsx)(`span`,{className:`truncate font-medium`,children:e.text})]},r):(0,U.jsxs)(`button`,{id:`${x}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,className:`flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),o(e)},children:[(0,U.jsx)(`span`,{className:`mt-0.5`,children:vF(e)}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate font-medium`,children:e.kind===`create`?e.actionLabel:e.title}),e.kind===`page`&&e.title!==e.docName&&(0,U.jsx)(`span`,{className:`line-clamp-2 break-all text-xs text-muted-foreground`,children:e.docName}),e.kind===`asset`&&(0,U.jsx)(`span`,{className:`line-clamp-2 break-all text-xs text-muted-foreground`,children:e.path}),e.kind===`create`&&(0,U.jsxs)(`span`,{className:`line-clamp-2 break-all text-xs text-muted-foreground`,children:[e.docName,`.md`]})]})]},r)},t[38]=x,t[39]=o,t[40]=a,t[41]=e):e=t[41],O=n.map(e),t[33]=n,t[34]=x,t[35]=o,t[36]=a,t[37]=O}else O=t[37];let ae;t[42]!==y||t[43]!==v||t[44]!==n.length||t[45]!==h?(ae=v&&(0,U.jsx)(`div`,{"data-prop-suggestion-more-hint":``,className:`border-t border-border mt-1 px-2 py-1.5 text-xs text-muted-foreground`,children:y(h===`anchor`?{id:`ypw6My`,values:{0:n.length}}:{id:`3MnvrL`,values:{0:n.length}})}),t[42]=y,t[43]=v,t[44]=n.length,t[45]=h,t[46]=ae):ae=t[46];let oe;return t[47]!==S||t[48]!==re||t[49]!==ie||t[50]!==D||t[51]!==O||t[52]!==ae||t[53]!==E?(oe=(0,U.jsxs)(`div`,{ref:b,role:`listbox`,"aria-label":E,"aria-activedescendant":S,tabIndex:-1,onMouseDown:T,className:`w-80 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,style:te,children:[re,ie,D,O,ae]}),t[47]=S,t[48]=re,t[49]=ie,t[50]=D,t[51]=O,t[52]=ae,t[53]=E,t[54]=oe):oe=t[54],oe}function SF(e){return e.preventDefault()}var CF=[` `,` `],wF=[`@`,`@`],TF=[`/`,`/`];function EF(e){let t=e.map(je).join(``),n=RegExp(`[${t}][^\\s${t}]*`,`g`);return({allowedPrefixes:e,$position:t})=>{let r=t.nodeBefore?.isText?t.nodeBefore.text:void 0;if(!r)return null;let i=Array.from(r.matchAll(n)).pop();if(i===void 0)return null;let a=r.slice(Math.max(0,i.index-1),i.index);if(e!==null&&a!==``&&!e.includes(a))return null;let o=t.pos-r.length+i.index,s=o+i[0].length;return o>=t.pos||s<t.pos?null:{range:{from:o,to:s},query:i[0].slice(1),text:i[0]}}}function DF({editor:e,isActive:t}){return t===!0||!e.view.composing}var OF=new k(`suggestionCompositionEnd`),kF=P.create({name:`suggestionCompositionEnd`,addProseMirrorPlugins(){return[new M({key:OF,props:{handleDOMEvents:{compositionend(e){let t=e.state;return setTimeout(()=>{e.isDestroyed||e.composing||e.state!==t||e.dispatch(e.state.tr.setMeta(`addToHistory`,!1))},0),!1}}}})]}});function AF({editor:e,state:t,range:n,isActive:r}){return Na(e)||!DF({editor:e,isActive:r})?!1:!Ww(t,n.from,n.to)}var jF={mermaidDocEditor:`[data-mermaid-doc-editor]`,sourceEditor:`.source-editor`,textDocEditor:`[data-text-doc-editor]`},MF=`editor-doc-scroll`,NF=`.${MF}`,PF=[NF,`.conflict-view`,`${jF.mermaidDocEditor} .cm-scroller`,`${jF.textDocEditor} .cm-scroller`],FF={mermaidDocEditor:`${jF.mermaidDocEditor} .cm-scroller`,sourceEditor:NF,textDocEditor:`${jF.textDocEditor} .cm-scroller`},IF=PF.join(`, `);function LF(){return[...document.querySelectorAll(IF)]}function RF(e){let t=e.scrollHeight-e.clientHeight;return t>0&&e.scrollTop>=t-40}function zF(){return Qe()?0:56}function BF(e){return()=>{let t=HF(e),n={top:zF(),bottom:JF(qF)+JF(`--conflict-footer-height`)};return t?{boundary:t,padding:n}:{padding:n}}}function VF(e){let{boundary:t,padding:n}=BF(e)(),r=t?.getBoundingClientRect()??{top:0,bottom:window.innerHeight},i=r.top+n.top;return{top:i,bottom:Math.max(i,r.bottom-n.bottom)}}function HF(e){return Zr(e)?.dom.closest(NF)??null}var UF=8;function WF(e,{pendingOffsetPx:t=0}={}){let n=BF(e);return e=>{let{padding:r,...i}=n(),a=e.placement.split(`-`)[0],o=a===`top`?-t:a===`bottom`?t:0;return{...i,mainAxis:!0,crossAxis:!0,padding:{top:r.top-o,bottom:r.bottom+o,left:UF,right:UF}}}}function GF(e,{authorMaxWidth:t}={}){return()=>({apply({elements:n}){let r=KF(e);if(r===null){n.floating.style.maxWidth=``;return}n.floating.style.maxWidth=t?`min(${t}, ${r}px)`:`${r}px`}})}function KF(e){let t=HF(e);return t?Math.max(0,t.getBoundingClientRect().width-UF*2):null}var qF=`--ask-composer-height`;function JF(e){let t=Number.parseFloat(document.documentElement.style.getPropertyValue(e));return Number.isFinite(t)?t:0}var YF=4,XF=new WeakMap;function ZF(e,t){XF.set(e,t)}function QF(e){XF.delete(e)}function $F(e){return(XF.get(e)??0)>0}var eI=488;function tI(e,t){let n={apply({availableHeight:t}){e.isConnected&&e.style.setProperty(`--suggestion-menu-max-height`,`${Math.min(t,window.innerHeight*.4)}px`)}};if(!t)return[p(YF),u(),h({padding:8}),d(n)];let r=BF(t),i=GF(t);return[p(YF),u(r),d(()=>{let{apply:a}=i(),o=KF(t);return{...r(),apply(t){a(t),n.apply(t),nI(e,o)}}}),h(WF(t))]}function nI(e,t){!e.isConnected||t===null||e.toggleAttribute(`data-suggestion-narrow`,t<eI)}function rI(e,t,{clipToEditorPane:n=!1}={}){let r=document.createElement(`div`);r.dataset.suggestionPopup=t,n&&(r.dataset.suggestionClipped=``),r.style.position=`fixed`,r.style.zIndex=`70`,r.style.visibility=`hidden`,document.body.appendChild(r);let i={getBoundingClientRect:()=>e()?.clientRect?.()??new DOMRect,get contextElement(){return e()?.editor.view.dom}},a=!1,o=!1,s=()=>{r.isConnected&&(r.style.removeProperty(`--suggestion-menu-max-height`),f(i,r,{placement:`bottom-start`,middleware:tI(r,n?e()?.editor:void 0)}).then(({x:e,y:t})=>{r.isConnected&&(r.style.left=`${e}px`,r.style.top=`${t}px`,a&&!o&&(r.style.removeProperty(`visibility`),o=!0))}).catch(e=>{r.isConnected&&console.warn(`[${t}] computePosition failed`,e)}))};return{popup:r,doPosition:s,startAutoUpdate:()=>m(i,r,s),reveal:()=>{o||(a=!0,s())}}}function iI(e){e.stopAutoUpdate?.(),e.stopAutoUpdate=null,e.popup?.remove(),e.popup=null}var aI=new k(`wikiLinkSuggestion`),oI=8,sI={currentDocName:null,connectedDocNames:new Set},cI=new Set([`.agents`,`.claude`,`.cursor`]),lI=200,uI=100,dI=50;function fI(e){return e.split(`/`).some(e=>cI.has(e))}function pI(e,t){let n=0;return fI(e)&&(n-=lI),t.currentDocName!==null&&e===t.currentDocName?n+=dI:t.connectedDocNames.has(e)&&(n+=uI),n}var mI=2,hI=new Map,gI=null;function _I(e){let t=e.indexOf(`#`);return t>0?{mode:`anchor`,pageTarget:e.slice(0,t),anchorQuery:e.slice(t+1)}:{mode:`page`,pageTarget:``,anchorQuery:``}}function vI(e,t,n=sI){if(!t)return e.map((e,t)=>({page:e,index:t,boost:pI(e.docName,n)})).sort((e,t)=>t.boost-e.boost||e.index-t.index).slice(0,oI).map(e=>e.page);let r=bI(e);return rF(r.corpus,t,{intent:`autocomplete`,scopes:[`page`,`folder`,`file`],limit:100}).map(e=>({result:e,adjusted:e.score+pI(e.document.path,n)})).sort((e,t)=>t.adjusted-e.adjusted||e.result.document.path.localeCompare(t.result.document.path)).slice(0,oI).map(e=>r.byId.get(e.result.document.id)).filter(e=>!!e)}function yI(e){return e.kind===`folder`?`folder`:e.kind===`asset`?`file`:`page`}function bI(e){let t=e.map(e=>`${e.kind??`page`}\u0000${e.docName}\u0000${e.title}`).join(``),n=hI.get(t);if(n)return hI.delete(t),hI.set(t,n),n;let r={fingerprint:t,byId:new Map(e.map(e=>[`${yI(e)}:${e.docName}`,e])),corpus:MP(e.map(e=>DP({kind:yI(e),path:e.docName,title:e.title})))};for(hI.set(t,r);hI.size>mI;){let e=hI.keys().next().value;if(e===void 0)break;hI.delete(e)}return r}function xI(e){let t=e.map(e=>`${e.slug}\u0000${e.level}\u0000${e.text}`).join(``);return gI?.fingerprint===t||(gI={fingerprint:t,byId:new Map(e.map(e=>[`page:${e.slug}`,e])),corpus:MP(e.map(e=>DP({kind:`page`,path:e.slug,title:e.text})))}),gI}function SI(e,t){if(!t)return e.slice(0,oI);let n=xI(e);return rF(n.corpus,t,{intent:`autocomplete`,limit:oI}).map(e=>n.byId.get(e.document.id)).filter(e=>!!e)}function CI(e,t,n=sI){let r=vI(e,t,n).filter(e=>e.kind!==`folder`);if(r.length>0)return r.map(e=>e.kind===`asset`?{kind:`asset`,target:e.docName,path:e.docName.replace(/^\//,``),title:e.title}:{kind:`page`,docName:e.docName,title:e.title});let i=Jw(t);return i?[{kind:`create`,docName:i.target,title:t.trim(),actionLabel:`Insert unresolved link "${t.trim()}"`}]:[]}function wI(e,t,n){return SI(t,n).map(t=>({kind:`anchor`,docName:e,level:t.level,text:t.text,slug:t.slug}))}function TI(e){let{mode:t,pageTarget:n,anchorQuery:r}=_I(e);return t===`anchor`&&n?{target:n,alias:null,anchor:r.trim()||null}:Jw(e)}function EI(e){let{$position:t}=e,n=t.parent.textBetween(0,t.parentOffset,void 0,``),r=n.match(/\[\[([^\]]*)$/);if(!r)return null;let i=r[1];return{range:{from:t.start()+n.lastIndexOf(`[[`),to:t.pos},query:i,text:r[0]}}async function DI(e={}){let t=await fetch(`/api/pages`),n;try{n=await t.json()}catch(e){throw new Yw(`Pages response was not JSON`,{cause:e,status:t.status})}if(!t.ok){let e=qe.safeParse(n);throw Error(e.success?e.data.title:`/api/pages responded with ${t.status}`)}let r=Ze.safeParse(n);if(!r.success)return console.warn(`[wiki-link-suggestion] /api/pages response schema drift:`,r.error),[];let i=r.data.pages.map(e=>({kind:`page`,docName:e.docName,title:e.title})),a;try{let{ok:e,status:t,body:n}=await wr();if(!e)return console.warn(`[wiki-link-suggestion] /api/documents responded with`,t),i;if(a=n??{},!Array.isArray(a.documents))return i}catch(e){return console.warn(`[wiki-link-suggestion] Failed to fetch referenced assets:`,e),i}let o=a.documents.filter(e=>e.kind===`asset`&&typeof e.path==`string`&&e.path.length>0).map(e=>{let t=e.path.split(`/`).pop()??e.path;return{kind:`asset`,docName:`/${e.path}`,title:t}}),s=a.documents.filter(e=>e.kind===`file`&&typeof e.path==`string`&&e.path.length>0&&!Ke(e.path)).map(e=>{let t=e.path.split(`/`).pop()??e.path;return{kind:`asset`,docName:`/${e.path}`,title:t}});if(!e.includeFolders)return[...i,...o,...s];let c=a.documents.filter(e=>e.kind===`folder`&&typeof e.path==`string`&&e.path.length>0).map(e=>{let t=e.path.split(`/`).pop()??e.path;return{kind:`folder`,docName:e.path,title:t}});return[...i,...o,...s,...c]}async function OI(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new Yw(`Page headings response was not JSON`,{cause:e,status:t.status})}if(!t.ok){let e=qe.safeParse(n);throw Error(e.success?e.data.title:`/api/page-headings responded with ${t.status}`)}let r=Je.safeParse(n);return r.success?r.data.headings??[]:(console.warn(`[wiki-link-suggestion] /api/page-headings response schema drift:`,r.error),[])}async function kI(e){try{let t=await fetch(`/api/forward-links?docName=${encodeURIComponent(e)}`);if(!t.ok)return console.warn(`[wiki-link-suggestion] /api/forward-links responded`,t.status,e),[];let n=Xe.safeParse(await t.json());return n.success?n.data.forwardLinks.flatMap(e=>e.kind===`doc`?[e.docName]:[]):[]}catch(e){return console.warn(`[wiki-link-suggestion] Failed to fetch forward links:`,e),[]}}async function AI(e){try{let t=await fetch(`/api/backlinks?docName=${encodeURIComponent(e)}`);if(!t.ok)return console.warn(`[wiki-link-suggestion] /api/backlinks responded`,t.status,e),[];let n=Ye.safeParse(await t.json());return n.success?n.data.backlinks.map(e=>e.source):[]}catch(e){return console.warn(`[wiki-link-suggestion] Failed to fetch backlinks:`,e),[]}}async function jI(e){if(!e)return sI;let[t,n]=await Promise.all([kI(e),AI(e)]),r=new Set([...t,...n]);return r.delete(e),{currentDocName:e,connectedDocNames:r}}function MI(e){let t=[],n=!1,r=null,i=sI,a=null,o=new Map,s=null,c=null,l=null;return uF({editor:e,pluginKey:aI,char:`[[`,allowedPrefixes:null,findSuggestionMatch:EI,allow:AF,items:async({query:u})=>{let{mode:d,pageTarget:f,anchorQuery:p}=_I(u);if(d===`anchor`){if(!o.has(f)&&s!==f){s=f;try{let e=await OI(f);o.set(f,e),l=null}catch(e){console.error(`[wiki-link-suggestion] Failed to fetch headings:`,e),o.set(f,[]),l=`Failed to load headings for ${f}. Press Escape and type [[ again to retry.`}finally{s=null}}return wI(f,o.get(f)??[],p)}if(!n){r||=DI(),a||=jI(qw(e));let[o,s]=await Promise.allSettled([r,a]);o.status===`fulfilled`?(t=o.value,c=null):(console.error(`[wiki-link-suggestion] Failed to fetch pages:`,o.reason),c=`Failed to load pages. Press Escape and type [[ again to retry, or continue typing to insert an unresolved link.`,t=[]),s.status===`fulfilled`?i=s.value:(console.warn(`[wiki-link-suggestion] link context load rejected:`,s.reason),i=sI),n=!0,r=null,a=null}return CI(t,u,i)},command:({editor:e,range:t,props:n})=>{try{let r=null;if(n.kind===`page`?r={target:n.docName,alias:null,anchor:null}:n.kind===`asset`?r={target:n.target,alias:n.title,anchor:null}:n.kind===`anchor`?r={target:n.docName,alias:null,anchor:n.slug}:n.kind===`create`&&(r=Jw(n.title)),!r)return;e.chain().focus().deleteRange(t).insertContent({type:`wikiLink`,attrs:r}).run()}catch(e){console.error(`[wiki-link-suggestion] command failed`,{item:n,range:t},e)}},render:()=>{let e=null,u=null,d=0,f={popup:null,stopAutoUpdate:null},p=null,m=null,h=e=>{u?.command(e)};function g(e,t,r){let{mode:i,pageTarget:a,anchorQuery:s}=_I(e.query??``),u=t===null?i===`anchor`?!o.has(a):!n:t,f=e.items??[],p=f.length===1&&f[0]?.kind===`create`;return{items:f,query:e.query??``,selectedIndex:d,onSelect:r,loading:u,error:i===`page`?c:l,mode:i,pageTarget:a,anchorQuery:s,hasMore:!p&&f.length>=oI}}let _=t=>{!e||!u||e.updateProps(g(u,t,h))},v=()=>{if(!u)return;let{editor:e,range:t}=u,n=TI(u.query??``);if(n)try{e.chain().focus().deleteRange(t).insertContent({type:`wikiLink`,attrs:n}).run()}catch(e){console.error(`[wiki-link-suggestion] fallback insert error:`,e)}};return{onBeforeStart(t){u=t,d=0;let n=rI(()=>u,`wiki-link-suggestion`,{clipToEditorPane:!0});f.popup=n.popup,p=n.doPosition,m=n.reveal,e=new IE(xF,{props:g(t,!0,h),editor:t.editor}),n.popup.appendChild(e.element),f.stopAutoUpdate=n.startAutoUpdate()},onBeforeUpdate(e){let t=u?_I(u.query??``).mode:null,n=_I(e.query??``).mode;u=e,t!==n&&(d=0,_(!0))},onStart(e){u=e,d=0,_(null),m?.()},onUpdate(e){u=e,d=Math.min(d,Math.max(0,e.items.length-1)),_(null),p?.()},onKeyDown({event:e}){if(!u)return!1;let t=u.items;if(e.key===`ArrowDown`)return t.length===0?!1:(d=(d+1)%t.length,_(null),!0);if(e.key===`ArrowUp`)return t.length===0?!1:(d=(d-1+t.length)%t.length,_(null),!0);if(e.key===`Enter`||e.key===`Tab`){let e=t[d];return e?u.command(e):v(),!0}return e.key,!1},onExit(){iI(f),p=null,m=null,e?.destroy(),e=null,u=null,d=0,t=[],i=sI,o=new Map,c=null,l=null,n=!1,r=null,a=null,s=null}}}})}var NI=5e3,PI=null,FI=0,II=null,LI=null,RI=new WeakMap,zI={pages:new Set,pagesBySlug:new Map,pagesByBasename:new Map,assetPaths:new Set},BI=new Map,VI=new Map;async function HI(e){if(!e)return jI(null);let t=Date.now(),n=VI.get(e);if(n!==void 0&&t-n.time<NI)return n.context;let r=await jI(e);return VI.set(e,{context:r,time:t}),r}async function UI(){let e=Date.now();return PI&&e-FI<NI?PI:(PI=await DI({includeFolders:!0}),FI=e,II=JI(PI),LI=YI(PI),PI)}async function WI(e){let t=Date.now(),n=BI.get(e);if(n!==void 0&&t-n.time<NI)return n.headings;try{let n=await OI(e);return BI.set(e,{headings:n,time:t}),n}catch(n){return console.warn(`[wiki-link-source] /api/page-headings fetch failed:`,n),BI.set(e,{headings:[],time:t}),[]}}var GI=/\[\[[^\]]*?\]\]/g,KI=_n.mark({class:`cm-wiki-link`}),qI=_n.mark({class:`cm-wiki-link cm-wiki-link-broken`});function JI(e){let t=new Set;for(let n of e){if(n.kind===`asset`)continue;n.kind===`folder`&&t.add(n.docName.toLowerCase());let e=n.docName.split(`/`);e.pop();let r=``;for(let n of e)r=r?`${r}/${n}`:n,t.add(r.toLowerCase())}return t}function YI(e){let t=new Set,n=new Set;for(let r of e)r.kind===`asset`?n.add(r.docName.replace(/^\//,``)):r.kind!==`folder`&&t.add(r.docName);return{pages:t,assetPaths:n,assetTargetKeys:_t(n),pagesBySlug:dt(t,mt),pagesByBasename:ut(t,mt)}}function XI(e,t,n){let r=ct(e,t,n);return r?r.kind===`external`?{kind:`external`,url:r.url}:r.kind===`asset`?{kind:`hash`,href:at(ft(r.url,n.assetPaths??new Set)??r.url.replace(/^\//,``))}:{kind:`hash`,href:st(vt(r.docName,n)??r.docName,r.anchor)}:null}function ZI(e,t,n){if(t===null)return`cm-wiki-link`;let r=e.split(/[#|]/)[0].trim(),i=RI.get(t);i||(i=new Map,RI.set(t,i));let a=i.get(r);return r&&a===void 0&&(a=pt(r,t),i.set(r,a)),r&&!a&&!n?.has(r.toLowerCase())&&rT()?`cm-wiki-link cm-wiki-link-broken`:`cm-wiki-link`}function QI(e){let t=new dn,n=PI?II:null;for(let{from:r,to:i}of e.visibleRanges){let a=e.state.doc.sliceString(r,i);GI.lastIndex=0;let o=GI.exec(a);for(;o!==null;){let e=ZI(o[0].slice(2,-2),LI,n).includes(`cm-wiki-link-broken`)?qI:KI;t.add(r+o.index,r+o.index+o[0].length,e),o=GI.exec(a)}}return t.finish()}var $I=Sn.fromClass(class{decorations;cacheWarmAtBuild;validationVisibleAtBuild;unsubscribePolicy;constructor(e){this.cacheWarmAtBuild=PI!==null,this.validationVisibleAtBuild=rT(),this.decorations=QI(e),this.unsubscribePolicy=aT(()=>{try{e.dispatch({})}catch{}}),this.cacheWarmAtBuild||this.warmCache(e)}update(e){let t=PI!==null,n=rT();(e.docChanged||e.viewportChanged||!this.cacheWarmAtBuild&&t||this.validationVisibleAtBuild!==n)&&(this.cacheWarmAtBuild=t,this.validationVisibleAtBuild=n,this.decorations=QI(e.view))}warmCache(e){UI().then(()=>{try{e.dispatch({})}catch{}}).catch(e=>{console.warn(`[wiki-link-source] warmCache fetch failed:`,e)})}destroy(){this.unsubscribePolicy()}},{decorations:e=>e.decorations}),eL=/\[\[([^[\]|#]+?)(?:#([^\]|]+?))?(?:\|([^\]]+?))?\]\]/g,tL=gn.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);eL.lastIndex=0;let i=eL.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=i[1]?.trim(),n=i[2]?.trim()||null;if(t){let r=XI(t,n,LI??zI);if(!r)return!1;e.preventDefault(),r.kind===`external`?Vr(r.url):gA(e)?dA(r.href):window.location.hash=r.href}return!0}i=eL.exec(r.text)}return!1}});async function nL(e,t){let n=e.state.doc.sliceString(0,e.pos).match(/\[\[([^\]]*)$/);if(!n)return null;let r=n[1],i=e.pos-r.length,a=r.indexOf(`#`);if(a>0){let e=r.slice(0,a),t=r.slice(a+1),n=i+a+1,o=await WI(e);if(!o.length)return null;let s=SI(o,t);return s.length?{from:n,filter:!1,options:s.map(e=>({label:e.text,detail:`H${e.level}`,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.slug+a},selection:{anchor:r+e.slug.length+a.length}})}}))}:null}let[o,s]=await Promise.all([UI().catch(e=>(console.warn(`[wiki-link-source] Failed to fetch pages:`,e),[])),HI(t)]);return{from:i,filter:!1,options:vI(o.filter(e=>e.kind!==`folder`),r,s).map(e=>({label:e.title,detail:e.title===e.docName?void 0:e.docName,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`,o=e.kind===`asset`?`${e.docName}|${e.title}${a}`:e.docName+a;t.dispatch({changes:{from:r,to:i,insert:o},selection:{anchor:r+o.length}})}}))}}var rL=gn.theme({".cm-wiki-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-wiki-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function iL(e=null){return[$I,tL,rL,Rr.data.of({autocomplete:t=>nL(t,e)})]}var aL=Rn({dark:!0}),oL=Rn({dark:!1});function sL(e){let{themeCompartment:t,resolvedTheme:n,ydoc:r}=e,i=n===`dark`?aL:oL,a=e.wordWrap??!0?gn.lineWrapping:[];return[Lr({base:Rr,extensions:[Ir],codeLanguages:eA}),iL(e.currentDocName??null),MA(),...r?[aA(r)]:[],En.of([]),t.of(i),e.wordWrapCompartment?e.wordWrapCompartment.of(a):a,...e.extraKeymaps?[e.extraKeymaps]:[]]}function cL(e,t,n){let{state:r}=e,i=r.selection.main;if(!i.empty)return!1;if(t===`line`){let e=r.doc.lineAt(i.head);return n<0?e.from===0:e.to===r.doc.length}return n<0?i.head===0:i.head===r.doc.length}function lL(e){let{pmSel:t,nodePos:n,nodeSize:r,cmDocLen:i,cmSel:a,cmHasFocus:o}=e;if(t instanceof Pe&&t.from===n)return o?{kind:`noop`}:{kind:`focus`};let s=n+1,c=n+r-1;if(t.from>=s&&t.to<=c){let e=Math.max(0,Math.min(t.anchor-s,i)),n=Math.max(0,Math.min(t.head-s,i));return a.anchor===e&&a.head===n&&o?{kind:`noop`}:{kind:`selection`,anchor:e,head:n}}return{kind:`noop`}}function uL(e,t){let n=fT().parseWithFallback(e),r;try{r=t.nodeFromJSON(n)}catch(e){return console.warn(JSON.stringify({event:`raw-mdx-upgrade-failure`,reason:e instanceof Error?e.message:String(e)})),null}if(r.childCount===0)return null;let i=[];for(let e=0;e<r.childCount;e++){let t=r.child(e);if(t.type.name===`rawMdxFallback`)return null;i.push(t)}return i}function dL(e,t){if(e===t)return null;let n=0,r=e.length,i=t.length;for(;n<r&&e.charCodeAt(n)===t.charCodeAt(n);)n++;for(;r>n&&i>n&&e.charCodeAt(r-1)===t.charCodeAt(i-1);)r--,i--;return{from:n,to:r,text:t.slice(n,i)}}var fL=`Unregistered component:`;function pL(e){if(!e.startsWith(fL))return null;let t=e.slice(23).trim();return t.length>0?t:null}function mL(e){let t=(0,Yr.c)(61),{node:n,editor:r,getPos:o}=e,{_:s}=i(),c=(0,W.useRef)(null),l=(0,W.useRef)(null),u=(0,W.useRef)(!1),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=new fn,t[0]=d):d=t[0];let f=(0,W.useRef)(d),p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=new fn,t[1]=p):p=t[1];let m=(0,W.useRef)(p),{resolvedTheme:h}=a(),{merged:g}=$e(),_=g?.editor?.wordWrap??!0,v;t[2]!==s||t[3]!==n.attrs.reason?(v=n.attrs.reason||s({id:`xc4g25`}),t[2]=s,t[3]=n.attrs.reason,t[4]=v):v=t[4];let y=v,b;t[5]===y?b=t[6]:(b=Qk(y),t[5]=y,t[6]=b);let x=b,S=$k[x],C=x===`info`?pL(y):null,w;t[7]!==r||t[8]!==o?(w=e=>{let t=typeof o==`function`?o():void 0;if(t===void 0)return;let n=Zr(r);if(!n)return;let i=n.state.doc.nodeAt(t);if(!i||i.type.name!==`rawMdxFallback`)return;let a=t+1,s=t+i.nodeSize-1;u.current=!0;try{let t=n.state.tr;if(e.length===0)t.delete(a,s);else{let r=n.state.schema.text(e);t.replaceWith(a,s,r)}n.dispatch(t)}catch(e){let t=e;throw u.current=!1,t}u.current=!1},t[7]=r,t[8]=o,t[9]=w):w=t[9];let T=w,ee;t[10]!==r||t[11]!==T||t[12]!==o||t[13]!==n.textContent||t[14]!==h||t[15]!==_?(ee=()=>{let e=c.current;if(!e)return;let t=f.current,i=En.of([{key:`Mod-z`,run:()=>(r.commands.undo(),!0)},{key:`Mod-y`,run:()=>(r.commands.redo(),!0)},{key:`Mod-Shift-z`,run:()=>(r.commands.redo(),!0)}]),a=e=>{let t=typeof o==`function`?o():void 0;if(typeof t!=`number`)return!1;let n=Zr(r);if(!n)return!1;let i=n.state.doc.nodeAt(t);if(!i||i.type.name!==`rawMdxFallback`)return!1;let a=e<0?t:t+i.nodeSize,s=Ae.near(n.state.doc.resolve(a),e);return n.dispatch(n.state.tr.setSelection(s).scrollIntoView()),n.focus(),!0},s=En.of([{key:`ArrowUp`,run:e=>cL(e,`line`,-1)?a(-1):!1},{key:`ArrowLeft`,run:e=>cL(e,`char`,-1)?a(-1):!1},{key:`ArrowDown`,run:e=>cL(e,`line`,1)?a(1):!1},{key:`ArrowRight`,run:e=>cL(e,`char`,1)?a(1):!1}]),d=sL({themeCompartment:t,resolvedTheme:h,ydoc:Zk(r)??void 0,wordWrapCompartment:m.current,wordWrap:_,extraKeymaps:i});d.push(s),d.push(gn.updateListener.of(e=>{if(e.docChanged&&!u.current&&T(e.state.doc.toString()),e.focusChanged&&e.view.hasFocus&&!u.current){let e=typeof o==`function`?o():void 0;if(typeof e!=`number`)return;let t=Zr(r);if(!t)return;let n=t.state.selection;if(n instanceof Pe&&n.from===e)return;let i=t.state.doc.nodeAt(e);if(!i||i.type.name!==`rawMdxFallback`)return;u.current=!0;try{t.dispatch(t.state.tr.setSelection(Pe.create(t.state.doc,e)))}catch(e){let t=e;throw u.current=!1,t}u.current=!1}if(e.focusChanged&&!e.view.hasFocus&&!u.current){let t=typeof o==`function`?o():void 0;if(typeof t!=`number`)return;let n=Zr(r);if(!n)return;let i=n.state.doc.nodeAt(t);if(i?.type.name!==`rawMdxFallback`||!Ia(r))return;let a=e.view.state.doc.toString(),s=uL(a,n.state.schema);if(!s)return;let c=za(n.state.tr.replaceWith(t,t+i.nodeSize,s),i,a);u.current=!0;try{n.dispatch(c)}catch(e){let t=e;throw u.current=!1,t}u.current=!1}}));let p=new gn({doc:n.textContent,extensions:d,parent:e});l.current=p;let g=gL,v=p.contentDOM;v.addEventListener(`keydown`,g),v.addEventListener(`paste`,g),v.addEventListener(`drop`,g),v.addEventListener(`cut`,g);let y=()=>{v.removeEventListener(`keydown`,g),v.removeEventListener(`paste`,g),v.removeEventListener(`drop`,g),v.removeEventListener(`cut`,g)};return()=>{y(),p.destroy(),l.current=null}},t[10]=r,t[11]=T,t[12]=o,t[13]=n.textContent,t[14]=h,t[15]=_,t[16]=ee):ee=t[16];let E;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(E=[],t[17]=E):E=t[17],(0,W.useEffect)(ee,E);let te,ne;t[18]===h?(te=t[19],ne=t[20]):(te=()=>{let e=l.current;if(!e)return;let t=h===`dark`?aL:oL;e.dispatch({effects:f.current.reconfigure(t)})},ne=[h],t[18]=h,t[19]=te,t[20]=ne),(0,W.useEffect)(te,ne);let re,ie;t[21]===_?(re=t[22],ie=t[23]):(re=()=>{let e=l.current;e&&e.dispatch({effects:m.current.reconfigure(_?gn.lineWrapping:[])})},ie=[_],t[21]=_,t[22]=re,t[23]=ie),(0,W.useEffect)(re,ie);let D,O;t[24]!==r||t[25]!==o?(D=()=>{let e=()=>{let e=typeof o==`function`?o():void 0;if(typeof e!=`number`)return;let t=l.current;if(!t||u.current)return;let n=Zr(r);if(!n)return;let i=n.state.doc.nodeAt(e);if(!i)return;let a=lL({pmSel:n.state.selection,nodePos:e,nodeSize:i.nodeSize,cmDocLen:t.state.doc.length,cmSel:{anchor:t.state.selection.main.anchor,head:t.state.selection.main.head},cmHasFocus:t.hasFocus});if(a.kind!==`noop`){u.current=!0;try{a.kind===`selection`&&t.dispatch({selection:{anchor:a.anchor,head:a.head}}),t.hasFocus||t.focus()}catch(e){let t=e;throw u.current=!1,t}u.current=!1}};return r.on(`selectionUpdate`,e),()=>{r.off(`selectionUpdate`,e)}},O=[r,o],t[24]=r,t[25]=o,t[26]=D,t[27]=O):(D=t[26],O=t[27]),(0,W.useEffect)(D,O);let ae=n.textContent,oe,se;t[28]===ae?(oe=t[29],se=t[30]):(oe=()=>{let e=l.current;if(!e||u.current)return;let t=dL(e.state.doc.toString(),ae);if(t){u.current=!0;try{e.dispatch({changes:{from:t.from,to:t.to,insert:t.text}})}catch(e){let t=e;throw u.current=!1,t}u.current=!1}},se=[ae],t[28]=ae,t[29]=oe,t[30]=se),(0,W.useEffect)(oe,se);let ce;t[31]!==r||t[32]!==o?(ce=()=>{let e=typeof o==`function`?o():void 0;typeof e==`number`&&r.chain().focus().setNodeSelection(e).deleteSelection().run()},t[31]=r,t[32]=o,t[33]=ce):ce=t[33];let le=ce,ue=C?`raw-mdx-fallback-wrapper jsx-component-wrapper jsx-component-wrapper--unregistered relative my-2 py-2 rounded border border-dashed ${S.wrapperClass}`:`raw-mdx-fallback-wrapper relative my-2 py-2 rounded border border-dashed ${S.wrapperClass}`,de=C?{"data-jsx-component":``,role:`group`,"aria-label":s({id:`sJWhgo`,values:{unregisteredComponentName:C}})}:{},fe=`rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider ${S.badgeClass}`,pe;t[34]!==s||t[35]!==S.label?(pe=s(S.label),t[34]=s,t[35]=S.label,t[36]=pe):pe=t[36];let me;t[37]!==y||t[38]!==fe||t[39]!==pe?(me=(0,U.jsx)(`span`,{className:fe,title:y,children:pe}),t[37]=y,t[38]=fe,t[39]=pe,t[40]=me):me=t[40];let he;t[41]===s?he=t[42]:(he=s({id:`hHMv6l`}),t[41]=s,t[42]=he);let ge;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,U.jsx)(nt,{size:12}),t[43]=ge):ge=t[43];let _e;t[44]!==le||t[45]!==he?(_e=(0,U.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn jsx-chrome-btn--delete`,"aria-label":he,onClick:le,children:ge}),t[44]=le,t[45]=he,t[46]=_e):_e=t[46];let k;t[47]!==me||t[48]!==_e?(k=(0,U.jsxs)(`div`,{className:`absolute top-1 right-1 z-10 flex items-center gap-1.5`,contentEditable:!1,onMouseDown:hL,children:[me,_e]}),t[47]=me,t[48]=_e,t[49]=k):k=t[49];let ve;t[50]!==s||t[51]!==y?(ve=s({id:`aalx4E`,values:{reason:y}}),t[50]=s,t[51]=y,t[52]=ve):ve=t[52];let A;t[53]===ve?A=t[54]:(A=(0,U.jsx)(`div`,{ref:c,className:`raw-mdx-fallback-cm`,role:`group`,"aria-label":ve}),t[53]=ve,t[54]=A);let ye;return t[55]!==x||t[56]!==k||t[57]!==A||t[58]!==de||t[59]!==ue?(ye=(0,U.jsxs)(AE,{className:ue,contentEditable:!1,"data-drag-handle":``,draggable:`true`,"data-severity":x,...de,children:[k,A]}),t[55]=x,t[56]=k,t[57]=A,t[58]=de,t[59]=ue,t[60]=ye):ye=t[60],ye}function hL(e){return e.stopPropagation()}function gL(){}function _L(e){switch(e){case`html`:return Nr();case`json`:return Fr();case`yaml`:return zr();case`javascript`:return Pr({jsx:!0,typescript:!0});case`markdown`:return Lr();case`latex`:return Cn.define(Br);case`mermaid`:return Vk()}}var vL=kn.define([{tag:R.keyword,color:`var(--syntax-keyword)`,fontWeight:`600`},{tag:R.controlKeyword,color:`var(--syntax-keyword)`,fontWeight:`600`},{tag:R.modifier,color:`var(--syntax-keyword)`},{tag:R.tagName,color:`var(--syntax-tag)`},{tag:R.typeName,color:`var(--syntax-tag)`},{tag:R.className,color:`var(--syntax-tag)`},{tag:R.attributeName,color:`var(--syntax-attr)`},{tag:R.propertyName,color:`var(--syntax-attr)`},{tag:R.variableName,color:`var(--syntax-attr)`},{tag:R.string,color:`var(--syntax-string)`},{tag:R.number,color:`var(--syntax-number)`},{tag:R.bool,color:`var(--syntax-number)`},{tag:R.null,color:`var(--syntax-number)`},{tag:R.atom,color:`var(--syntax-atom)`},{tag:R.literal,color:`var(--syntax-number)`},{tag:R.operator,color:`var(--syntax-keyword)`},{tag:R.punctuation,color:`var(--foreground)`},{tag:R.bracket,color:`var(--foreground)`},{tag:R.brace,color:`var(--foreground)`},{tag:R.meta,color:`var(--muted-foreground)`},{tag:R.comment,color:`var(--muted-foreground)`,fontStyle:`italic`}]);function yL(e){let t=(0,Yr.c)(18),{value:n,language:r,onChange:i,id:a,ariaLabelledBy:o,autoFocus:s}=e,c=(0,W.useRef)(null),l=(0,W.useRef)(null),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=new fn,t[0]=u):u=t[0];let d=(0,W.useRef)(u),f=(0,W.useRef)(i),p,m;t[1]===i?(p=t[2],m=t[3]):(p=()=>{f.current=i},m=[i],t[1]=i,t[2]=p,t[3]=m),(0,W.useEffect)(p,m);let h=(0,W.useRef)(n),g=(0,W.useRef)(r),_=(0,W.useRef)(s),v=(0,W.useRef)(o),y,b;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{let e=c.current;if(!e)return;let t=[An(),Er(),pn(),Tn(),vn(wn,{fallback:!0}),vn(vL),En.of([Tr,...Or,...Dr]),gn.lineWrapping,gn.updateListener.of(e=>{if(!e.docChanged)return;let t=e.state.doc.toString();f.current(t)}),xn.tabSize.of(2),d.current.of(_L(g.current))],n=new gn({state:xn.create({doc:h.current,extensions:t}),parent:e});return l.current=n,v.current&&n.contentDOM.setAttribute(`aria-labelledby`,v.current),n.contentDOM.setAttribute(`aria-multiline`,`true`),_.current&&n.focus(),()=>{n.destroy(),l.current=null}},b=[],t[4]=y,t[5]=b):(y=t[4],b=t[5]),(0,W.useEffect)(y,b);let x,S;t[6]===o?(x=t[7],S=t[8]):(x=()=>{let e=l.current;e&&(o?e.contentDOM.setAttribute(`aria-labelledby`,o):e.contentDOM.removeAttribute(`aria-labelledby`))},S=[o],t[6]=o,t[7]=x,t[8]=S),(0,W.useEffect)(x,S);let C,w;t[9]===r?(C=t[10],w=t[11]):(C=()=>{let e=l.current;e&&e.dispatch({effects:d.current.reconfigure(_L(r))})},w=[r],t[9]=r,t[10]=C,t[11]=w),(0,W.useEffect)(C,w);let T,ee;t[12]===n?(T=t[13],ee=t[14]):(T=()=>{let e=l.current;if(!e)return;let t=dL(e.state.doc.toString(),n);t&&e.dispatch({changes:{from:t.from,to:t.to,insert:t.text}})},ee=[n],t[12]=n,t[13]=T,t[14]=ee),(0,W.useEffect)(T,ee);let E;return t[15]!==a||t[16]!==r?(E=(0,U.jsx)(`div`,{ref:c,id:a,className:`ok-prop-codemirror`,"data-prop-codemirror":``,"data-prop-language":r}),t[15]=a,t[16]=r,t[17]=E):E=t[17],E}export{gE as $,Ea as $n,e_ as $t,TF as A,os as An,oC as At,EP as B,Ya as Bn,jy as Bt,MF as C,ss as Cn,Vw as Ct,RF as D,ds as Dn,LC as Dt,LF as E,hs as En,GC as Et,fF as F,Zo as Fn,db as Ft,dA as G,Ra as Gn,Ey as Gt,bA as H,Ka as Hn,ky as Ht,uF as I,Yo as In,Mb as It,sA as J,Ma as Jn,s_ as Jt,pA as K,Fa as Kn,wy as Kt,MP as L,Lo as Ln,Iy as Lt,kF as M,ps as Mn,Z as Mt,DF as N,ts as Nn,Fb as Nt,AF as O,ms as On,BC as Ot,EF as P,Xo as Pn,Vb as Pt,Vk as Q,ka as Qn,n_ as Qt,DP as R,Fo as Rn,Py as Rt,zF as S,vs as Sn,Kw as St,FF as T,gs as Tn,zw as Tt,lA as U,Ia as Un,Oy as Ut,hA as V,qa as Vn,My as Vt,_A as W,Va as Wn,Dy as Wt,Yk as X,Da as Xn,i_ as Xt,Zk as Y,Oa as Yn,o_ as Yt,Xk as Z,Ta as Zn,t_ as Zt,qF as _,el as _n,Gr as _r,Zw as _t,aL as a,$u as an,_a as ar,EE as at,GF as b,_s as bn,Jw as bt,OI as c,Yu as cn,G as cr,fT as ct,aI as d,Hu as dn,la as dr,oT as dt,Qg as en,ki as er,kE as et,QF as f,Kc as fn,ii as fr,rT as ft,$F as g,Vu as gn,Kr as gr,Xw as gt,ZF as h,du as hn,qr as hr,eT as ht,sL as i,ed as in,sa as ir,IE as it,CF as j,fs as jn,Q as jt,wF as k,us as kn,zC as kt,DI as l,Ju as ln,xa as lr,sT as lt,iI as m,ru as mn,Zr as mr,aT as mt,vL as n,Fd as nn,ua as nr,mE as nt,oL as o,Gu as on,ga as or,wE as ot,rI as p,$c as pn,ti as pr,iT as pt,uA as q,Pa as qn,c_ as qt,mL as r,Dd as rn,va as rr,RE as rt,MI as s,qu as sn,Ti as sr,yE as st,yL as t,Ig as tn,aa as tr,AE as tt,vI as u,Uu as un,_i as ur,uT as ut,BF as v,au as vn,Wr as vr,Qw as vt,NF as w,cs as wn,Hw as wt,VF as x,ls as xn,qw as xt,WF as y,hu as yn,Ur as yr,Yw as yt,rF as z,eo as zn,Ny as zt};
|
|
170
|
+
`);return/\s/.test(n)}):!1}var cF=new k(`suggestion`);function lF({pluginKey:e=cF,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:m=()=>!0,findSuggestionMatch:h=oF,shouldShow:g,shouldResetDismissed:_}){let v,y=p?.(),b=r&&!i,x=()=>{let e=t.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=t.view.coordsAtPos(e);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}},S=(n,r)=>r?()=>{let r=e.getState(t.state)?.decorationId;return n.dom.querySelector(`[data-decoration-id="${r}"]`)?.getBoundingClientRect()||null}:x,C=({match:e,dismissedRange:n,state:r,transaction:i})=>_?.({editor:t,state:r,range:n,match:e,transaction:i,allowSpaces:b})?!1:b?e.range.from===n.from:e.range.from===n.from&&!sF(i);function w(n,r){var i;try{let r=e.getState(n.state),a=r?.decorationId?n.dom.querySelector(`[data-decoration-id="${r.decorationId}"]`):null,o={editor:t,range:r?.range||{from:0,to:0},query:r?.query||null,text:r?.text||null,items:[],command:e=>d({editor:t,range:r?.range||{from:0,to:0},props:e}),decorationNode:a,clientRect:S(n,a)};(i=y?.onExit)==null||i.call(y,o)}catch{}let a=n.state.tr.setMeta(r,{exit:!0});n.dispatch(a)}let T=new M({key:e,view(){return{update:async(e,n)=>{var r,i,a,o,s;let c=this.key?.getState(n),l=this.key?.getState(e.state),u=c.active&&l.active&&c.range.from!==l.range.from,p=!c.active&&l.active,m=c.active&&!l.active,h=!p&&!m&&c.query!==l.query,g=p||u&&h,_=h||u,b=m||u&&h;if(!g&&!_&&!b)return;let x=b&&!g?c:l,C=e.dom.querySelector(`[data-decoration-id="${x.decorationId}"]`);v={editor:t,range:x.range,query:x.query,text:x.text,items:[],command:e=>d({editor:t,range:x.range,props:e}),decorationNode:C,clientRect:S(e,C)},g&&((r=y?.onBeforeStart)==null||r.call(y,v)),_&&((i=y?.onBeforeUpdate)==null||i.call(y,v)),(_||g)&&(v.items=await f({editor:t,query:x.query})),b&&((a=y?.onExit)==null||a.call(y,v)),_&&((o=y?.onUpdate)==null||o.call(y,v)),g&&((s=y?.onStart)==null||s.call(y,v))},destroy:()=>{var e;v&&((e=y?.onExit)==null||e.call(y,v))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(s,c,l,u){let{isEditable:d}=t,{composing:f}=t.view,{selection:p}=s,{empty:_,from:v}=p,y={...c},b=s.getMeta(e);if(b&&b.exit)return y.active=!1,y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null,y.dismissedRange=c.active?{...c.range}:c.dismissedRange,y;if(y.composing=f,s.docChanged&&y.dismissedRange!==null&&(y.dismissedRange={from:s.mapping.map(y.dismissedRange.from),to:s.mapping.map(y.dismissedRange.to)}),d&&(_||t.view.composing)){(v<c.range.from||v>c.range.to)&&!f&&!c.composing&&(y.active=!1);let e=h({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:p.$from}),l=`id_${Math.floor(Math.random()*4294967295)}`;e&&m({editor:t,state:u,range:e.range,isActive:c.active})&&(!g||g({editor:t,range:e.range,query:e.query,text:e.text,transaction:s}))?(y.dismissedRange!==null&&!C({match:e,dismissedRange:y.dismissedRange,state:u,transaction:s})&&(y.dismissedRange=null),y.dismissedRange===null?(y.active=!0,y.decorationId=c.decorationId?c.decorationId:l,y.range=e.range,y.query=e.query,y.text=e.text):y.active=!1):(e||(y.dismissedRange=null),y.active=!1)}else y.active=!1;return y.active||(y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null),y}},props:{handleKeyDown(t,n){var r;let{active:i,range:a}=T.getState(t.state);if(!i)return!1;if(n.key===`Escape`||n.key===`Esc`){let i=T.getState(t.state);return(r=y?.onKeyDown)==null||r.call(y,{view:t,event:n,range:i.range}),w(t,e),!0}return(y?.onKeyDown)?.call(y,{view:t,event:n,range:a})||!1},decorations(e){let{active:t,range:n,decorationId:r,query:i}=T.getState(e);if(!t)return null;let a=!i?.length,o=[c];return a&&o.push(u),me.create(e.doc,[he.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return T}var uF=lF;function dF(e){switch(e){case`image`:return Kr;case`video`:return Gr;case`audio`:return qr;default:return Wr}}function fF(e){let t=e.lastIndexOf(`.`),n=t>e.lastIndexOf(`/`)+1?e.slice(t+1).toLowerCase():``;return n===``?{kind:`folder`}:n===`md`||n===`mdx`?{kind:`page`}:{kind:`asset`,assetExt:n}}function pF(e){return e.kind===`folder`?tt:e.kind===`asset`?e.mediaKind===void 0?e.assetExt?dF(mF(e.assetExt)):Wr:dF(e.mediaKind):Wr}function mF(e){let t=e.toLowerCase().replace(/^\./,``);return hF.has(t)?`image`:gF.has(t)?`video`:_F.has(t)?`audio`:null}var hF=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`svg`,`bmp`,`ico`]),gF=new Set([`mp4`,`webm`,`mov`,`m4v`,`mkv`,`avi`]),_F=new Set([`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`]);function vF(e){if(e.kind===`create`)return(0,U.jsx)(Ur,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`});let t=e.kind===`asset`?e.path.split(`.`).pop()??``:void 0;return(0,U.jsx)(pF({kind:e.kind,assetExt:t}),{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})}function yF(e){return e.kind===`asset`?e.target:e.kind===`anchor`?`${e.docName}#${e.slug}`:e.docName}function bF(e){if(e.kind===`anchor`){let{level:t,text:n}=e;return Ge._({id:`Ik-gP0`,values:{level:t,text:n}})}if(e.kind===`asset`){let{title:t}=e;return Ge._({id:`hXbSxc`,values:{title:t}})}return e.kind===`create`?e.actionLabel:e.title}function xF(e){let t=(0,Yr.c)(55),{items:n,query:r,selectedIndex:a,onSelect:o,loading:s,error:c,mode:l,pageTarget:u,anchorQuery:d,hasMore:f}=e,p=s===void 0?!1:s,m=c===void 0?null:c,h=l===void 0?`page`:l,g=u===void 0?``:u,_=d===void 0?``:d,v=f===void 0?!1:f,{_:y}=i(),b=(0,W.useRef)(null),x=(0,W.useId)(),S=a>=0&&a<n.length?`${x}-option-${a}`:void 0,C,w;t[0]===a?(C=t[1],w=t[2]):(C=()=>{let e=b.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(a);t&&t.scrollIntoView({block:`nearest`})},w=[a],t[0]=a,t[1]=C,t[2]=w),(0,W.useEffect)(C,w);let T=SF;if(p){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;t[4]!==y||t[5]!==h||t[6]!==g?(n=y(h===`anchor`?{id:`ONgEZF`,values:{pageTarget:g}}:{id:`q6-JVU`}),t[4]=y,t[5]=h,t[6]=g,t[7]=n):n=t[7];let r;return t[8]===n?r=t[9]:(r=(0,U.jsx)(`div`,{ref:b,role:`status`,"aria-live":`polite`,className:`w-80 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:e,onMouseDown:T,children:n}),t[8]=n,t[9]=r),r}if(n.length===0){let e;if(t[10]!==y||t[11]!==_||t[12]!==m||t[13]!==h||t[14]!==g||t[15]!==r){let n=_.trim(),i=r.trim();e=m??y(h===`anchor`?n?{id:`6O626z`,values:{trimmedAnchorQuery:n}}:{id:`ct2kv5`,values:{pageTarget:g}}:i?{id:`a9OzSn`,values:{trimmedQuery:i}}:{id:`Oo_WWc`}),t[10]=y,t[11]=_,t[12]=m,t[13]=h,t[14]=g,t[15]=r,t[16]=e}else e=t[16];let n=e,i;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(i={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[17]=i):i=t[17];let a;return t[18]===n?a=t[19]:(a=(0,U.jsx)(`div`,{ref:b,role:`status`,"aria-live":`polite`,className:`w-80 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:i,onMouseDown:T,children:n}),t[18]=n,t[19]=a),a}let ee=a>=0&&a<n.length?n[a]:null,E;t[20]!==y||t[21]!==h?(E=y(h===`anchor`?{id:`xDBki3`}:{id:`i1flq_`}),t[20]=y,t[21]=h,t[22]=E):E=t[22];let te;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(te={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[23]=te):te=t[23];let ne;t[24]===ee?ne=t[25]:(ne=ee?bF(ee):``,t[24]=ee,t[25]=ne);let re;t[26]===ne?re=t[27]:(re=(0,U.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:ne}),t[26]=ne,t[27]=re);let ie;t[28]===m?ie=t[29]:(ie=m&&(0,U.jsx)(`div`,{className:`rounded-md px-2 py-1.5 text-xs text-amber-700 dark:text-amber-300`,children:m}),t[28]=m,t[29]=ie);let D;t[30]!==h||t[31]!==g?(D=h===`anchor`&&(0,U.jsx)(`div`,{className:`px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:g}),t[30]=h,t[31]=g,t[32]=D):D=t[32];let O;if(t[33]!==n||t[34]!==x||t[35]!==o||t[36]!==a){let e;t[38]!==x||t[39]!==o||t[40]!==a?(e=(e,t)=>{let n=t===a,r=yF(e);return e.kind===`anchor`?(0,U.jsxs)(`button`,{id:`${x}-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`:``}`,style:{paddingLeft:`${(e.level-1)*10+8}px`},onMouseDown:t=>{t.preventDefault(),o(e)},children:[(0,U.jsxs)(`span`,{className:`w-6 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,U.jsx)(`span`,{className:`truncate font-medium`,children:e.text})]},r):(0,U.jsxs)(`button`,{id:`${x}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,className:`flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),o(e)},children:[(0,U.jsx)(`span`,{className:`mt-0.5`,children:vF(e)}),(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate font-medium`,children:e.kind===`create`?e.actionLabel:e.title}),e.kind===`page`&&e.title!==e.docName&&(0,U.jsx)(`span`,{className:`line-clamp-2 break-all text-xs text-muted-foreground`,children:e.docName}),e.kind===`asset`&&(0,U.jsx)(`span`,{className:`line-clamp-2 break-all text-xs text-muted-foreground`,children:e.path}),e.kind===`create`&&(0,U.jsxs)(`span`,{className:`line-clamp-2 break-all text-xs text-muted-foreground`,children:[e.docName,`.md`]})]})]},r)},t[38]=x,t[39]=o,t[40]=a,t[41]=e):e=t[41],O=n.map(e),t[33]=n,t[34]=x,t[35]=o,t[36]=a,t[37]=O}else O=t[37];let ae;t[42]!==y||t[43]!==v||t[44]!==n.length||t[45]!==h?(ae=v&&(0,U.jsx)(`div`,{"data-prop-suggestion-more-hint":``,className:`border-t border-border mt-1 px-2 py-1.5 text-xs text-muted-foreground`,children:y(h===`anchor`?{id:`ypw6My`,values:{0:n.length}}:{id:`3MnvrL`,values:{0:n.length}})}),t[42]=y,t[43]=v,t[44]=n.length,t[45]=h,t[46]=ae):ae=t[46];let oe;return t[47]!==S||t[48]!==re||t[49]!==ie||t[50]!==D||t[51]!==O||t[52]!==ae||t[53]!==E?(oe=(0,U.jsxs)(`div`,{ref:b,role:`listbox`,"aria-label":E,"aria-activedescendant":S,tabIndex:-1,onMouseDown:T,className:`w-80 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,style:te,children:[re,ie,D,O,ae]}),t[47]=S,t[48]=re,t[49]=ie,t[50]=D,t[51]=O,t[52]=ae,t[53]=E,t[54]=oe):oe=t[54],oe}function SF(e){return e.preventDefault()}var CF=[` `,` `],wF=[`@`,`@`],TF=[`/`,`/`];function EF(e){let t=e.map(je).join(``),n=RegExp(`[${t}][^\\s${t}]*`,`g`);return({allowedPrefixes:e,$position:t})=>{let r=t.nodeBefore?.isText?t.nodeBefore.text:void 0;if(!r)return null;let i=Array.from(r.matchAll(n)).pop();if(i===void 0)return null;let a=r.slice(Math.max(0,i.index-1),i.index);if(e!==null&&a!==``&&!e.includes(a))return null;let o=t.pos-r.length+i.index,s=o+i[0].length;return o>=t.pos||s<t.pos?null:{range:{from:o,to:s},query:i[0].slice(1),text:i[0]}}}function DF({editor:e,isActive:t}){return t===!0||!e.view.composing}var OF=new k(`suggestionCompositionEnd`),kF=P.create({name:`suggestionCompositionEnd`,addProseMirrorPlugins(){return[new M({key:OF,props:{handleDOMEvents:{compositionend(e){let t=e.state;return setTimeout(()=>{e.isDestroyed||e.composing||e.state!==t||e.dispatch(e.state.tr.setMeta(`addToHistory`,!1))},0),!1}}}})]}});function AF({editor:e,state:t,range:n,isActive:r}){return Na(e)||!DF({editor:e,isActive:r})?!1:!Ww(t,n.from,n.to)}var jF={mermaidDocEditor:`[data-mermaid-doc-editor]`,sourceEditor:`.source-editor`,textDocEditor:`[data-text-doc-editor]`},MF=`editor-doc-scroll`,NF=`.${MF}`,PF=`.conflict-view`,FF=[NF,PF,`${jF.mermaidDocEditor} .cm-scroller`,`${jF.textDocEditor} .cm-scroller`],IF={mermaidDocEditor:`${jF.mermaidDocEditor} .cm-scroller`,sourceEditor:NF,textDocEditor:`${jF.textDocEditor} .cm-scroller`},LF=FF.join(`, `);function RF(){return[...document.querySelectorAll(LF)]}function zF(e){let t=e.scrollHeight-e.clientHeight;return t>0&&e.scrollTop>=t-40}var BF=`--ask-composer-height`,VF=[NF,`${NF} :is(.ProseMirror, .cm-content)`,jF.mermaidDocEditor,`${jF.sourceEditor} .cm-content`,`${jF.textDocEditor} .cm-content`,PF,`${PF} diffs-container`],HF=null,UF=null;function WF(e){if(e!==HF){if(HF=e,e===null){UF?.remove(),UF=null;return}UF??=document.head.appendChild(document.createElement(`style`)),UF.textContent=`${VF.join(`, `)} { ${BF}: ${e}px; }`}}function GF(){return HF??0}function KF(){return Qe()?0:56}function qF(e){return()=>{let t=YF(e),n={top:KF(),bottom:GF()+eI(`--conflict-footer-height`)};return t?{boundary:t,padding:n}:{padding:n}}}function JF(e){let{boundary:t,padding:n}=qF(e)(),r=t?.getBoundingClientRect()??{top:0,bottom:window.innerHeight},i=r.top+n.top;return{top:i,bottom:Math.max(i,r.bottom-n.bottom)}}function YF(e){return Zr(e)?.dom.closest(NF)??null}var XF=8;function ZF(e,{pendingOffsetPx:t=0}={}){let n=qF(e);return e=>{let{padding:r,...i}=n(),a=e.placement.split(`-`)[0],o=a===`top`?-t:a===`bottom`?t:0;return{...i,mainAxis:!0,crossAxis:!0,padding:{top:r.top-o,bottom:r.bottom+o,left:XF,right:XF}}}}function QF(e,{authorMaxWidth:t}={}){return()=>({apply({elements:n}){let r=$F(e);if(r===null){n.floating.style.maxWidth=``;return}n.floating.style.maxWidth=t?`min(${t}, ${r}px)`:`${r}px`}})}function $F(e){let t=YF(e);return t?Math.max(0,t.getBoundingClientRect().width-XF*2):null}function eI(e){let t=Number.parseFloat(document.documentElement.style.getPropertyValue(e));return Number.isFinite(t)?t:0}var tI=4,nI=new WeakMap;function rI(e,t){nI.set(e,t)}function iI(e){nI.delete(e)}function aI(e){return(nI.get(e)??0)>0}var oI=488;function sI(e,t){let n={apply({availableHeight:t}){e.isConnected&&e.style.setProperty(`--suggestion-menu-max-height`,`${Math.min(t,window.innerHeight*.4)}px`)}};if(!t)return[p(tI),u(),h({padding:8}),d(n)];let r=qF(t),i=QF(t);return[p(tI),u(r),d(()=>{let{apply:a}=i(),o=$F(t);return{...r(),apply(t){a(t),n.apply(t),cI(e,o)}}}),h(ZF(t))]}function cI(e,t){!e.isConnected||t===null||e.toggleAttribute(`data-suggestion-narrow`,t<oI)}function lI(e,t,{clipToEditorPane:n=!1}={}){let r=document.createElement(`div`);r.dataset.suggestionPopup=t,n&&(r.dataset.suggestionClipped=``),r.style.position=`fixed`,r.style.zIndex=`70`,r.style.visibility=`hidden`,document.body.appendChild(r);let i={getBoundingClientRect:()=>e()?.clientRect?.()??new DOMRect,get contextElement(){return e()?.editor.view.dom}},a=!1,o=!1,s=()=>{r.isConnected&&(r.style.removeProperty(`--suggestion-menu-max-height`),f(i,r,{placement:`bottom-start`,middleware:sI(r,n?e()?.editor:void 0)}).then(({x:e,y:t})=>{r.isConnected&&(r.style.left=`${e}px`,r.style.top=`${t}px`,a&&!o&&(r.style.removeProperty(`visibility`),o=!0))}).catch(e=>{r.isConnected&&console.warn(`[${t}] computePosition failed`,e)}))};return{popup:r,doPosition:s,startAutoUpdate:()=>m(i,r,s),reveal:()=>{o||(a=!0,s())}}}function uI(e){e.stopAutoUpdate?.(),e.stopAutoUpdate=null,e.popup?.remove(),e.popup=null}var dI=new k(`wikiLinkSuggestion`),fI=8,pI={currentDocName:null,connectedDocNames:new Set},mI=new Set([`.agents`,`.claude`,`.cursor`]),hI=200,gI=100,_I=50;function vI(e){return e.split(`/`).some(e=>mI.has(e))}function yI(e,t){let n=0;return vI(e)&&(n-=hI),t.currentDocName!==null&&e===t.currentDocName?n+=_I:t.connectedDocNames.has(e)&&(n+=gI),n}var bI=2,xI=new Map,SI=null;function CI(e){let t=e.indexOf(`#`);return t>0?{mode:`anchor`,pageTarget:e.slice(0,t),anchorQuery:e.slice(t+1)}:{mode:`page`,pageTarget:``,anchorQuery:``}}function wI(e,t,n=pI){if(!t)return e.map((e,t)=>({page:e,index:t,boost:yI(e.docName,n)})).sort((e,t)=>t.boost-e.boost||e.index-t.index).slice(0,fI).map(e=>e.page);let r=EI(e);return rF(r.corpus,t,{intent:`autocomplete`,scopes:[`page`,`folder`,`file`],limit:100}).map(e=>({result:e,adjusted:e.score+yI(e.document.path,n)})).sort((e,t)=>t.adjusted-e.adjusted||e.result.document.path.localeCompare(t.result.document.path)).slice(0,fI).map(e=>r.byId.get(e.result.document.id)).filter(e=>!!e)}function TI(e){return e.kind===`folder`?`folder`:e.kind===`asset`?`file`:`page`}function EI(e){let t=e.map(e=>`${e.kind??`page`}\u0000${e.docName}\u0000${e.title}`).join(``),n=xI.get(t);if(n)return xI.delete(t),xI.set(t,n),n;let r={fingerprint:t,byId:new Map(e.map(e=>[`${TI(e)}:${e.docName}`,e])),corpus:MP(e.map(e=>DP({kind:TI(e),path:e.docName,title:e.title})))};for(xI.set(t,r);xI.size>bI;){let e=xI.keys().next().value;if(e===void 0)break;xI.delete(e)}return r}function DI(e){let t=e.map(e=>`${e.slug}\u0000${e.level}\u0000${e.text}`).join(``);return SI?.fingerprint===t||(SI={fingerprint:t,byId:new Map(e.map(e=>[`page:${e.slug}`,e])),corpus:MP(e.map(e=>DP({kind:`page`,path:e.slug,title:e.text})))}),SI}function OI(e,t){if(!t)return e.slice(0,fI);let n=DI(e);return rF(n.corpus,t,{intent:`autocomplete`,limit:fI}).map(e=>n.byId.get(e.document.id)).filter(e=>!!e)}function kI(e,t,n=pI){let r=wI(e,t,n).filter(e=>e.kind!==`folder`);if(r.length>0)return r.map(e=>e.kind===`asset`?{kind:`asset`,target:e.docName,path:e.docName.replace(/^\//,``),title:e.title}:{kind:`page`,docName:e.docName,title:e.title});let i=Jw(t);return i?[{kind:`create`,docName:i.target,title:t.trim(),actionLabel:`Insert unresolved link "${t.trim()}"`}]:[]}function AI(e,t,n){return OI(t,n).map(t=>({kind:`anchor`,docName:e,level:t.level,text:t.text,slug:t.slug}))}function jI(e){let{mode:t,pageTarget:n,anchorQuery:r}=CI(e);return t===`anchor`&&n?{target:n,alias:null,anchor:r.trim()||null}:Jw(e)}function MI(e){let{$position:t}=e,n=t.parent.textBetween(0,t.parentOffset,void 0,``),r=n.match(/\[\[([^\]]*)$/);if(!r)return null;let i=r[1];return{range:{from:t.start()+n.lastIndexOf(`[[`),to:t.pos},query:i,text:r[0]}}async function NI(e={}){let t=await fetch(`/api/pages`),n;try{n=await t.json()}catch(e){throw new Yw(`Pages response was not JSON`,{cause:e,status:t.status})}if(!t.ok){let e=qe.safeParse(n);throw Error(e.success?e.data.title:`/api/pages responded with ${t.status}`)}let r=Ze.safeParse(n);if(!r.success)return console.warn(`[wiki-link-suggestion] /api/pages response schema drift:`,r.error),[];let i=r.data.pages.map(e=>({kind:`page`,docName:e.docName,title:e.title})),a;try{let{ok:e,status:t,body:n}=await wr();if(!e)return console.warn(`[wiki-link-suggestion] /api/documents responded with`,t),i;if(a=n??{},!Array.isArray(a.documents))return i}catch(e){return console.warn(`[wiki-link-suggestion] Failed to fetch referenced assets:`,e),i}let o=a.documents.filter(e=>e.kind===`asset`&&typeof e.path==`string`&&e.path.length>0).map(e=>{let t=e.path.split(`/`).pop()??e.path;return{kind:`asset`,docName:`/${e.path}`,title:t}}),s=a.documents.filter(e=>e.kind===`file`&&typeof e.path==`string`&&e.path.length>0&&!Ke(e.path)).map(e=>{let t=e.path.split(`/`).pop()??e.path;return{kind:`asset`,docName:`/${e.path}`,title:t}});if(!e.includeFolders)return[...i,...o,...s];let c=a.documents.filter(e=>e.kind===`folder`&&typeof e.path==`string`&&e.path.length>0).map(e=>{let t=e.path.split(`/`).pop()??e.path;return{kind:`folder`,docName:e.path,title:t}});return[...i,...o,...s,...c]}async function PI(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new Yw(`Page headings response was not JSON`,{cause:e,status:t.status})}if(!t.ok){let e=qe.safeParse(n);throw Error(e.success?e.data.title:`/api/page-headings responded with ${t.status}`)}let r=Je.safeParse(n);return r.success?r.data.headings??[]:(console.warn(`[wiki-link-suggestion] /api/page-headings response schema drift:`,r.error),[])}async function FI(e){try{let t=await fetch(`/api/forward-links?docName=${encodeURIComponent(e)}`);if(!t.ok)return console.warn(`[wiki-link-suggestion] /api/forward-links responded`,t.status,e),[];let n=Xe.safeParse(await t.json());return n.success?n.data.forwardLinks.flatMap(e=>e.kind===`doc`?[e.docName]:[]):[]}catch(e){return console.warn(`[wiki-link-suggestion] Failed to fetch forward links:`,e),[]}}async function II(e){try{let t=await fetch(`/api/backlinks?docName=${encodeURIComponent(e)}`);if(!t.ok)return console.warn(`[wiki-link-suggestion] /api/backlinks responded`,t.status,e),[];let n=Ye.safeParse(await t.json());return n.success?n.data.backlinks.map(e=>e.source):[]}catch(e){return console.warn(`[wiki-link-suggestion] Failed to fetch backlinks:`,e),[]}}async function LI(e){if(!e)return pI;let[t,n]=await Promise.all([FI(e),II(e)]),r=new Set([...t,...n]);return r.delete(e),{currentDocName:e,connectedDocNames:r}}function RI(e){let t=[],n=!1,r=null,i=pI,a=null,o=new Map,s=null,c=null,l=null;return uF({editor:e,pluginKey:dI,char:`[[`,allowedPrefixes:null,findSuggestionMatch:MI,allow:AF,items:async({query:u})=>{let{mode:d,pageTarget:f,anchorQuery:p}=CI(u);if(d===`anchor`){if(!o.has(f)&&s!==f){s=f;try{let e=await PI(f);o.set(f,e),l=null}catch(e){console.error(`[wiki-link-suggestion] Failed to fetch headings:`,e),o.set(f,[]),l=`Failed to load headings for ${f}. Press Escape and type [[ again to retry.`}finally{s=null}}return AI(f,o.get(f)??[],p)}if(!n){r||=NI(),a||=LI(qw(e));let[o,s]=await Promise.allSettled([r,a]);o.status===`fulfilled`?(t=o.value,c=null):(console.error(`[wiki-link-suggestion] Failed to fetch pages:`,o.reason),c=`Failed to load pages. Press Escape and type [[ again to retry, or continue typing to insert an unresolved link.`,t=[]),s.status===`fulfilled`?i=s.value:(console.warn(`[wiki-link-suggestion] link context load rejected:`,s.reason),i=pI),n=!0,r=null,a=null}return kI(t,u,i)},command:({editor:e,range:t,props:n})=>{try{let r=null;if(n.kind===`page`?r={target:n.docName,alias:null,anchor:null}:n.kind===`asset`?r={target:n.target,alias:n.title,anchor:null}:n.kind===`anchor`?r={target:n.docName,alias:null,anchor:n.slug}:n.kind===`create`&&(r=Jw(n.title)),!r)return;e.chain().focus().deleteRange(t).insertContent({type:`wikiLink`,attrs:r}).run()}catch(e){console.error(`[wiki-link-suggestion] command failed`,{item:n,range:t},e)}},render:()=>{let e=null,u=null,d=0,f={popup:null,stopAutoUpdate:null},p=null,m=null,h=e=>{u?.command(e)};function g(e,t,r){let{mode:i,pageTarget:a,anchorQuery:s}=CI(e.query??``),u=t===null?i===`anchor`?!o.has(a):!n:t,f=e.items??[],p=f.length===1&&f[0]?.kind===`create`;return{items:f,query:e.query??``,selectedIndex:d,onSelect:r,loading:u,error:i===`page`?c:l,mode:i,pageTarget:a,anchorQuery:s,hasMore:!p&&f.length>=fI}}let _=t=>{!e||!u||e.updateProps(g(u,t,h))},v=()=>{if(!u)return;let{editor:e,range:t}=u,n=jI(u.query??``);if(n)try{e.chain().focus().deleteRange(t).insertContent({type:`wikiLink`,attrs:n}).run()}catch(e){console.error(`[wiki-link-suggestion] fallback insert error:`,e)}};return{onBeforeStart(t){u=t,d=0;let n=lI(()=>u,`wiki-link-suggestion`,{clipToEditorPane:!0});f.popup=n.popup,p=n.doPosition,m=n.reveal,e=new IE(xF,{props:g(t,!0,h),editor:t.editor}),n.popup.appendChild(e.element),f.stopAutoUpdate=n.startAutoUpdate()},onBeforeUpdate(e){let t=u?CI(u.query??``).mode:null,n=CI(e.query??``).mode;u=e,t!==n&&(d=0,_(!0))},onStart(e){u=e,d=0,_(null),m?.()},onUpdate(e){u=e,d=Math.min(d,Math.max(0,e.items.length-1)),_(null),p?.()},onKeyDown({event:e}){if(!u)return!1;let t=u.items;if(e.key===`ArrowDown`)return t.length===0?!1:(d=(d+1)%t.length,_(null),!0);if(e.key===`ArrowUp`)return t.length===0?!1:(d=(d-1+t.length)%t.length,_(null),!0);if(e.key===`Enter`||e.key===`Tab`){let e=t[d];return e?u.command(e):v(),!0}return e.key,!1},onExit(){uI(f),p=null,m=null,e?.destroy(),e=null,u=null,d=0,t=[],i=pI,o=new Map,c=null,l=null,n=!1,r=null,a=null,s=null}}}})}var zI=5e3,BI=null,VI=0,HI=null,UI=null,WI=new WeakMap,GI={pages:new Set,pagesBySlug:new Map,pagesByBasename:new Map,assetPaths:new Set},KI=new Map,qI=new Map;async function JI(e){if(!e)return LI(null);let t=Date.now(),n=qI.get(e);if(n!==void 0&&t-n.time<zI)return n.context;let r=await LI(e);return qI.set(e,{context:r,time:t}),r}async function YI(){let e=Date.now();return BI&&e-VI<zI?BI:(BI=await NI({includeFolders:!0}),VI=e,HI=eL(BI),UI=tL(BI),BI)}async function XI(e){let t=Date.now(),n=KI.get(e);if(n!==void 0&&t-n.time<zI)return n.headings;try{let n=await PI(e);return KI.set(e,{headings:n,time:t}),n}catch(n){return console.warn(`[wiki-link-source] /api/page-headings fetch failed:`,n),KI.set(e,{headings:[],time:t}),[]}}var ZI=/\[\[[^\]]*?\]\]/g,QI=_n.mark({class:`cm-wiki-link`}),$I=_n.mark({class:`cm-wiki-link cm-wiki-link-broken`});function eL(e){let t=new Set;for(let n of e){if(n.kind===`asset`)continue;n.kind===`folder`&&t.add(n.docName.toLowerCase());let e=n.docName.split(`/`);e.pop();let r=``;for(let n of e)r=r?`${r}/${n}`:n,t.add(r.toLowerCase())}return t}function tL(e){let t=new Set,n=new Set;for(let r of e)r.kind===`asset`?n.add(r.docName.replace(/^\//,``)):r.kind!==`folder`&&t.add(r.docName);return{pages:t,assetPaths:n,assetTargetKeys:_t(n),pagesBySlug:dt(t,mt),pagesByBasename:ut(t,mt)}}function nL(e,t,n){let r=ct(e,t,n);return r?r.kind===`external`?{kind:`external`,url:r.url}:r.kind===`asset`?{kind:`hash`,href:at(ft(r.url,n.assetPaths??new Set)??r.url.replace(/^\//,``))}:{kind:`hash`,href:st(vt(r.docName,n)??r.docName,r.anchor)}:null}function rL(e,t,n){if(t===null)return`cm-wiki-link`;let r=e.split(/[#|]/)[0].trim(),i=WI.get(t);i||(i=new Map,WI.set(t,i));let a=i.get(r);return r&&a===void 0&&(a=pt(r,t),i.set(r,a)),r&&!a&&!n?.has(r.toLowerCase())&&rT()?`cm-wiki-link cm-wiki-link-broken`:`cm-wiki-link`}function iL(e){let t=new dn,n=BI?HI:null;for(let{from:r,to:i}of e.visibleRanges){let a=e.state.doc.sliceString(r,i);ZI.lastIndex=0;let o=ZI.exec(a);for(;o!==null;){let e=rL(o[0].slice(2,-2),UI,n).includes(`cm-wiki-link-broken`)?$I:QI;t.add(r+o.index,r+o.index+o[0].length,e),o=ZI.exec(a)}}return t.finish()}var aL=Sn.fromClass(class{decorations;cacheWarmAtBuild;validationVisibleAtBuild;unsubscribePolicy;constructor(e){this.cacheWarmAtBuild=BI!==null,this.validationVisibleAtBuild=rT(),this.decorations=iL(e),this.unsubscribePolicy=aT(()=>{try{e.dispatch({})}catch{}}),this.cacheWarmAtBuild||this.warmCache(e)}update(e){let t=BI!==null,n=rT();(e.docChanged||e.viewportChanged||!this.cacheWarmAtBuild&&t||this.validationVisibleAtBuild!==n)&&(this.cacheWarmAtBuild=t,this.validationVisibleAtBuild=n,this.decorations=iL(e.view))}warmCache(e){YI().then(()=>{try{e.dispatch({})}catch{}}).catch(e=>{console.warn(`[wiki-link-source] warmCache fetch failed:`,e)})}destroy(){this.unsubscribePolicy()}},{decorations:e=>e.decorations}),oL=/\[\[([^[\]|#]+?)(?:#([^\]|]+?))?(?:\|([^\]]+?))?\]\]/g,sL=gn.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);oL.lastIndex=0;let i=oL.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=i[1]?.trim(),n=i[2]?.trim()||null;if(t){let r=nL(t,n,UI??GI);if(!r)return!1;e.preventDefault(),r.kind===`external`?Vr(r.url):gA(e)?dA(r.href):window.location.hash=r.href}return!0}i=oL.exec(r.text)}return!1}});async function cL(e,t){let n=e.state.doc.sliceString(0,e.pos).match(/\[\[([^\]]*)$/);if(!n)return null;let r=n[1],i=e.pos-r.length,a=r.indexOf(`#`);if(a>0){let e=r.slice(0,a),t=r.slice(a+1),n=i+a+1,o=await XI(e);if(!o.length)return null;let s=OI(o,t);return s.length?{from:n,filter:!1,options:s.map(e=>({label:e.text,detail:`H${e.level}`,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.slug+a},selection:{anchor:r+e.slug.length+a.length}})}}))}:null}let[o,s]=await Promise.all([YI().catch(e=>(console.warn(`[wiki-link-source] Failed to fetch pages:`,e),[])),JI(t)]);return{from:i,filter:!1,options:wI(o.filter(e=>e.kind!==`folder`),r,s).map(e=>({label:e.title,detail:e.title===e.docName?void 0:e.docName,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`,o=e.kind===`asset`?`${e.docName}|${e.title}${a}`:e.docName+a;t.dispatch({changes:{from:r,to:i,insert:o},selection:{anchor:r+o.length}})}}))}}var lL=gn.theme({".cm-wiki-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-wiki-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function uL(e=null){return[aL,sL,lL,Rr.data.of({autocomplete:t=>cL(t,e)})]}var dL=Rn({dark:!0}),fL=Rn({dark:!1});function pL(e){let{themeCompartment:t,resolvedTheme:n,ydoc:r}=e,i=n===`dark`?dL:fL,a=e.wordWrap??!0?gn.lineWrapping:[];return[Lr({base:Rr,extensions:[Ir],codeLanguages:eA}),uL(e.currentDocName??null),MA(),...r?[aA(r)]:[],En.of([]),t.of(i),e.wordWrapCompartment?e.wordWrapCompartment.of(a):a,...e.extraKeymaps?[e.extraKeymaps]:[]]}function mL(e,t,n){let{state:r}=e,i=r.selection.main;if(!i.empty)return!1;if(t===`line`){let e=r.doc.lineAt(i.head);return n<0?e.from===0:e.to===r.doc.length}return n<0?i.head===0:i.head===r.doc.length}function hL(e){let{pmSel:t,nodePos:n,nodeSize:r,cmDocLen:i,cmSel:a,cmHasFocus:o}=e;if(t instanceof Pe&&t.from===n)return o?{kind:`noop`}:{kind:`focus`};let s=n+1,c=n+r-1;if(t.from>=s&&t.to<=c){let e=Math.max(0,Math.min(t.anchor-s,i)),n=Math.max(0,Math.min(t.head-s,i));return a.anchor===e&&a.head===n&&o?{kind:`noop`}:{kind:`selection`,anchor:e,head:n}}return{kind:`noop`}}function gL(e,t){let n=fT().parseWithFallback(e),r;try{r=t.nodeFromJSON(n)}catch(e){return console.warn(JSON.stringify({event:`raw-mdx-upgrade-failure`,reason:e instanceof Error?e.message:String(e)})),null}if(r.childCount===0)return null;let i=[];for(let e=0;e<r.childCount;e++){let t=r.child(e);if(t.type.name===`rawMdxFallback`)return null;i.push(t)}return i}function _L(e,t){if(e===t)return null;let n=0,r=e.length,i=t.length;for(;n<r&&e.charCodeAt(n)===t.charCodeAt(n);)n++;for(;r>n&&i>n&&e.charCodeAt(r-1)===t.charCodeAt(i-1);)r--,i--;return{from:n,to:r,text:t.slice(n,i)}}var vL=`Unregistered component:`;function yL(e){if(!e.startsWith(vL))return null;let t=e.slice(23).trim();return t.length>0?t:null}function bL(e){let t=(0,Yr.c)(61),{node:n,editor:r,getPos:o}=e,{_:s}=i(),c=(0,W.useRef)(null),l=(0,W.useRef)(null),u=(0,W.useRef)(!1),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=new fn,t[0]=d):d=t[0];let f=(0,W.useRef)(d),p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=new fn,t[1]=p):p=t[1];let m=(0,W.useRef)(p),{resolvedTheme:h}=a(),{merged:g}=$e(),_=g?.editor?.wordWrap??!0,v;t[2]!==s||t[3]!==n.attrs.reason?(v=n.attrs.reason||s({id:`xc4g25`}),t[2]=s,t[3]=n.attrs.reason,t[4]=v):v=t[4];let y=v,b;t[5]===y?b=t[6]:(b=Qk(y),t[5]=y,t[6]=b);let x=b,S=$k[x],C=x===`info`?yL(y):null,w;t[7]!==r||t[8]!==o?(w=e=>{let t=typeof o==`function`?o():void 0;if(t===void 0)return;let n=Zr(r);if(!n)return;let i=n.state.doc.nodeAt(t);if(!i||i.type.name!==`rawMdxFallback`)return;let a=t+1,s=t+i.nodeSize-1;u.current=!0;try{let t=n.state.tr;if(e.length===0)t.delete(a,s);else{let r=n.state.schema.text(e);t.replaceWith(a,s,r)}n.dispatch(t)}catch(e){let t=e;throw u.current=!1,t}u.current=!1},t[7]=r,t[8]=o,t[9]=w):w=t[9];let T=w,ee;t[10]!==r||t[11]!==T||t[12]!==o||t[13]!==n.textContent||t[14]!==h||t[15]!==_?(ee=()=>{let e=c.current;if(!e)return;let t=f.current,i=En.of([{key:`Mod-z`,run:()=>(r.commands.undo(),!0)},{key:`Mod-y`,run:()=>(r.commands.redo(),!0)},{key:`Mod-Shift-z`,run:()=>(r.commands.redo(),!0)}]),a=e=>{let t=typeof o==`function`?o():void 0;if(typeof t!=`number`)return!1;let n=Zr(r);if(!n)return!1;let i=n.state.doc.nodeAt(t);if(!i||i.type.name!==`rawMdxFallback`)return!1;let a=e<0?t:t+i.nodeSize,s=Ae.near(n.state.doc.resolve(a),e);return n.dispatch(n.state.tr.setSelection(s).scrollIntoView()),n.focus(),!0},s=En.of([{key:`ArrowUp`,run:e=>mL(e,`line`,-1)?a(-1):!1},{key:`ArrowLeft`,run:e=>mL(e,`char`,-1)?a(-1):!1},{key:`ArrowDown`,run:e=>mL(e,`line`,1)?a(1):!1},{key:`ArrowRight`,run:e=>mL(e,`char`,1)?a(1):!1}]),d=pL({themeCompartment:t,resolvedTheme:h,ydoc:Zk(r)??void 0,wordWrapCompartment:m.current,wordWrap:_,extraKeymaps:i});d.push(s),d.push(gn.updateListener.of(e=>{if(e.docChanged&&!u.current&&T(e.state.doc.toString()),e.focusChanged&&e.view.hasFocus&&!u.current){let e=typeof o==`function`?o():void 0;if(typeof e!=`number`)return;let t=Zr(r);if(!t)return;let n=t.state.selection;if(n instanceof Pe&&n.from===e)return;let i=t.state.doc.nodeAt(e);if(!i||i.type.name!==`rawMdxFallback`)return;u.current=!0;try{t.dispatch(t.state.tr.setSelection(Pe.create(t.state.doc,e)))}catch(e){let t=e;throw u.current=!1,t}u.current=!1}if(e.focusChanged&&!e.view.hasFocus&&!u.current){let t=typeof o==`function`?o():void 0;if(typeof t!=`number`)return;let n=Zr(r);if(!n)return;let i=n.state.doc.nodeAt(t);if(i?.type.name!==`rawMdxFallback`||!Ia(r))return;let a=e.view.state.doc.toString(),s=gL(a,n.state.schema);if(!s)return;let c=za(n.state.tr.replaceWith(t,t+i.nodeSize,s),i,a);u.current=!0;try{n.dispatch(c)}catch(e){let t=e;throw u.current=!1,t}u.current=!1}}));let p=new gn({doc:n.textContent,extensions:d,parent:e});l.current=p;let g=SL,v=p.contentDOM;v.addEventListener(`keydown`,g),v.addEventListener(`paste`,g),v.addEventListener(`drop`,g),v.addEventListener(`cut`,g);let y=()=>{v.removeEventListener(`keydown`,g),v.removeEventListener(`paste`,g),v.removeEventListener(`drop`,g),v.removeEventListener(`cut`,g)};return()=>{y(),p.destroy(),l.current=null}},t[10]=r,t[11]=T,t[12]=o,t[13]=n.textContent,t[14]=h,t[15]=_,t[16]=ee):ee=t[16];let E;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(E=[],t[17]=E):E=t[17],(0,W.useEffect)(ee,E);let te,ne;t[18]===h?(te=t[19],ne=t[20]):(te=()=>{let e=l.current;if(!e)return;let t=h===`dark`?dL:fL;e.dispatch({effects:f.current.reconfigure(t)})},ne=[h],t[18]=h,t[19]=te,t[20]=ne),(0,W.useEffect)(te,ne);let re,ie;t[21]===_?(re=t[22],ie=t[23]):(re=()=>{let e=l.current;e&&e.dispatch({effects:m.current.reconfigure(_?gn.lineWrapping:[])})},ie=[_],t[21]=_,t[22]=re,t[23]=ie),(0,W.useEffect)(re,ie);let D,O;t[24]!==r||t[25]!==o?(D=()=>{let e=()=>{let e=typeof o==`function`?o():void 0;if(typeof e!=`number`)return;let t=l.current;if(!t||u.current)return;let n=Zr(r);if(!n)return;let i=n.state.doc.nodeAt(e);if(!i)return;let a=hL({pmSel:n.state.selection,nodePos:e,nodeSize:i.nodeSize,cmDocLen:t.state.doc.length,cmSel:{anchor:t.state.selection.main.anchor,head:t.state.selection.main.head},cmHasFocus:t.hasFocus});if(a.kind!==`noop`){u.current=!0;try{a.kind===`selection`&&t.dispatch({selection:{anchor:a.anchor,head:a.head}}),t.hasFocus||t.focus()}catch(e){let t=e;throw u.current=!1,t}u.current=!1}};return r.on(`selectionUpdate`,e),()=>{r.off(`selectionUpdate`,e)}},O=[r,o],t[24]=r,t[25]=o,t[26]=D,t[27]=O):(D=t[26],O=t[27]),(0,W.useEffect)(D,O);let ae=n.textContent,oe,se;t[28]===ae?(oe=t[29],se=t[30]):(oe=()=>{let e=l.current;if(!e||u.current)return;let t=_L(e.state.doc.toString(),ae);if(t){u.current=!0;try{e.dispatch({changes:{from:t.from,to:t.to,insert:t.text}})}catch(e){let t=e;throw u.current=!1,t}u.current=!1}},se=[ae],t[28]=ae,t[29]=oe,t[30]=se),(0,W.useEffect)(oe,se);let ce;t[31]!==r||t[32]!==o?(ce=()=>{let e=typeof o==`function`?o():void 0;typeof e==`number`&&r.chain().focus().setNodeSelection(e).deleteSelection().run()},t[31]=r,t[32]=o,t[33]=ce):ce=t[33];let le=ce,ue=C?`raw-mdx-fallback-wrapper jsx-component-wrapper jsx-component-wrapper--unregistered relative my-2 py-2 rounded border border-dashed ${S.wrapperClass}`:`raw-mdx-fallback-wrapper relative my-2 py-2 rounded border border-dashed ${S.wrapperClass}`,de=C?{"data-jsx-component":``,role:`group`,"aria-label":s({id:`sJWhgo`,values:{unregisteredComponentName:C}})}:{},fe=`rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider ${S.badgeClass}`,pe;t[34]!==s||t[35]!==S.label?(pe=s(S.label),t[34]=s,t[35]=S.label,t[36]=pe):pe=t[36];let me;t[37]!==y||t[38]!==fe||t[39]!==pe?(me=(0,U.jsx)(`span`,{className:fe,title:y,children:pe}),t[37]=y,t[38]=fe,t[39]=pe,t[40]=me):me=t[40];let he;t[41]===s?he=t[42]:(he=s({id:`hHMv6l`}),t[41]=s,t[42]=he);let ge;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,U.jsx)(nt,{size:12}),t[43]=ge):ge=t[43];let _e;t[44]!==le||t[45]!==he?(_e=(0,U.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn jsx-chrome-btn--delete`,"aria-label":he,onClick:le,children:ge}),t[44]=le,t[45]=he,t[46]=_e):_e=t[46];let k;t[47]!==me||t[48]!==_e?(k=(0,U.jsxs)(`div`,{className:`absolute top-1 right-1 z-10 flex items-center gap-1.5`,contentEditable:!1,onMouseDown:xL,children:[me,_e]}),t[47]=me,t[48]=_e,t[49]=k):k=t[49];let ve;t[50]!==s||t[51]!==y?(ve=s({id:`aalx4E`,values:{reason:y}}),t[50]=s,t[51]=y,t[52]=ve):ve=t[52];let A;t[53]===ve?A=t[54]:(A=(0,U.jsx)(`div`,{ref:c,className:`raw-mdx-fallback-cm`,role:`group`,"aria-label":ve}),t[53]=ve,t[54]=A);let ye;return t[55]!==x||t[56]!==k||t[57]!==A||t[58]!==de||t[59]!==ue?(ye=(0,U.jsxs)(AE,{className:ue,contentEditable:!1,"data-drag-handle":``,draggable:`true`,"data-severity":x,...de,children:[k,A]}),t[55]=x,t[56]=k,t[57]=A,t[58]=de,t[59]=ue,t[60]=ye):ye=t[60],ye}function xL(e){return e.stopPropagation()}function SL(){}function CL(e){switch(e){case`html`:return Nr();case`json`:return Fr();case`yaml`:return zr();case`javascript`:return Pr({jsx:!0,typescript:!0});case`markdown`:return Lr();case`latex`:return Cn.define(Br);case`mermaid`:return Vk()}}var wL=kn.define([{tag:R.keyword,color:`var(--syntax-keyword)`,fontWeight:`600`},{tag:R.controlKeyword,color:`var(--syntax-keyword)`,fontWeight:`600`},{tag:R.modifier,color:`var(--syntax-keyword)`},{tag:R.tagName,color:`var(--syntax-tag)`},{tag:R.typeName,color:`var(--syntax-tag)`},{tag:R.className,color:`var(--syntax-tag)`},{tag:R.attributeName,color:`var(--syntax-attr)`},{tag:R.propertyName,color:`var(--syntax-attr)`},{tag:R.variableName,color:`var(--syntax-attr)`},{tag:R.string,color:`var(--syntax-string)`},{tag:R.number,color:`var(--syntax-number)`},{tag:R.bool,color:`var(--syntax-number)`},{tag:R.null,color:`var(--syntax-number)`},{tag:R.atom,color:`var(--syntax-atom)`},{tag:R.literal,color:`var(--syntax-number)`},{tag:R.operator,color:`var(--syntax-keyword)`},{tag:R.punctuation,color:`var(--foreground)`},{tag:R.bracket,color:`var(--foreground)`},{tag:R.brace,color:`var(--foreground)`},{tag:R.meta,color:`var(--muted-foreground)`},{tag:R.comment,color:`var(--muted-foreground)`,fontStyle:`italic`}]);function TL(e){let t=(0,Yr.c)(18),{value:n,language:r,onChange:i,id:a,ariaLabelledBy:o,autoFocus:s}=e,c=(0,W.useRef)(null),l=(0,W.useRef)(null),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=new fn,t[0]=u):u=t[0];let d=(0,W.useRef)(u),f=(0,W.useRef)(i),p,m;t[1]===i?(p=t[2],m=t[3]):(p=()=>{f.current=i},m=[i],t[1]=i,t[2]=p,t[3]=m),(0,W.useEffect)(p,m);let h=(0,W.useRef)(n),g=(0,W.useRef)(r),_=(0,W.useRef)(s),v=(0,W.useRef)(o),y,b;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{let e=c.current;if(!e)return;let t=[An(),Er(),pn(),Tn(),vn(wn,{fallback:!0}),vn(wL),En.of([Tr,...Or,...Dr]),gn.lineWrapping,gn.updateListener.of(e=>{if(!e.docChanged)return;let t=e.state.doc.toString();f.current(t)}),xn.tabSize.of(2),d.current.of(CL(g.current))],n=new gn({state:xn.create({doc:h.current,extensions:t}),parent:e});return l.current=n,v.current&&n.contentDOM.setAttribute(`aria-labelledby`,v.current),n.contentDOM.setAttribute(`aria-multiline`,`true`),_.current&&n.focus(),()=>{n.destroy(),l.current=null}},b=[],t[4]=y,t[5]=b):(y=t[4],b=t[5]),(0,W.useEffect)(y,b);let x,S;t[6]===o?(x=t[7],S=t[8]):(x=()=>{let e=l.current;e&&(o?e.contentDOM.setAttribute(`aria-labelledby`,o):e.contentDOM.removeAttribute(`aria-labelledby`))},S=[o],t[6]=o,t[7]=x,t[8]=S),(0,W.useEffect)(x,S);let C,w;t[9]===r?(C=t[10],w=t[11]):(C=()=>{let e=l.current;e&&e.dispatch({effects:d.current.reconfigure(CL(r))})},w=[r],t[9]=r,t[10]=C,t[11]=w),(0,W.useEffect)(C,w);let T,ee;t[12]===n?(T=t[13],ee=t[14]):(T=()=>{let e=l.current;if(!e)return;let t=_L(e.state.doc.toString(),n);t&&e.dispatch({changes:{from:t.from,to:t.to,insert:t.text}})},ee=[n],t[12]=n,t[13]=T,t[14]=ee),(0,W.useEffect)(T,ee);let E;return t[15]!==a||t[16]!==r?(E=(0,U.jsx)(`div`,{ref:c,id:a,className:`ok-prop-codemirror`,"data-prop-codemirror":``,"data-prop-language":r}),t[15]=a,t[16]=r,t[17]=E):E=t[17],E}export{Vk as $,ka as $n,n_ as $t,wF as A,us as An,zC as At,rF as B,eo as Bn,Ny as Bt,WF as C,vs as Cn,Kw as Ct,RF as D,hs as Dn,GC as Dt,IF as E,gs as En,zw as Et,EF as F,Xo as Fn,Vb as Ft,_A as G,Va as Gn,Dy as Gt,hA as H,qa as Hn,My as Ht,fF as I,Zo as In,db as It,uA as J,Pa as Jn,c_ as Jt,dA as K,Ra as Kn,Ey as Kt,uF as L,Yo as Ln,Mb as Lt,CF as M,fs as Mn,Q as Mt,kF as N,ps as Nn,Z as Nt,zF as O,ds as On,LC as Ot,DF as P,ts as Pn,Fb as Pt,Xk as Q,Ta as Qn,t_ as Qt,MP as R,Lo as Rn,Iy as Rt,BF as S,ls as Sn,qw as St,NF as T,cs as Tn,Hw as Tt,bA as U,Ka as Un,ky as Ut,EP as V,Ya as Vn,jy as Vt,lA as W,Ia as Wn,Oy as Wt,Zk as X,Oa as Xn,o_ as Xt,sA as Y,Ma as Yn,s_ as Yt,Yk as Z,Da as Zn,i_ as Zt,qF as _,Vu as _n,Kr as _r,Xw as _t,dL as a,ed as an,sa as ar,IE as at,JF as b,hu as bn,Ur as br,Yw as bt,PI as c,qu as cn,Ti as cr,yE as ct,dI as d,Uu as dn,_i as dr,uT as dt,e_ as en,Ea as er,gE as et,iI as f,Hu as fn,la as fr,oT as ft,aI as g,du as gn,qr as gr,eT as gt,rI as h,ru as hn,Zr as hr,aT as ht,pL as i,Dd as in,va as ir,RE as it,TF as j,os as jn,oC as jt,AF as k,ms as kn,BC as kt,NI as l,Yu as ln,G as lr,fT as lt,uI as m,$c as mn,ti as mr,iT as mt,wL as n,Ig as nn,aa as nr,AE as nt,fL as o,$u as on,_a as or,EE as ot,lI as p,Kc as pn,ii as pr,rT as pt,pA as q,Fa as qn,wy as qt,bL as r,Fd as rn,ua as rr,mE as rt,RI as s,Gu as sn,ga as sr,wE as st,TL as t,Qg as tn,ki as tr,kE as tt,wI as u,Ju as un,xa as ur,sT as ut,ZF as v,el as vn,Gr as vr,Zw as vt,MF as w,ss as wn,Vw as wt,KF as x,_s as xn,Jw as xt,QF as y,au as yn,Wr as yr,Qw as yt,DP as z,Fo as zn,Py as zt};
|