@thebase/ui 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +49 -8
- package/bin/create-baseui-app.mjs +268 -0
- package/dist/baseui.esm.js +2 -2
- package/dist/baseui.min.css +1 -1
- package/dist/baseui.min.js +2 -2
- package/dist/baseui.registry.json +6 -7
- package/dist/icons/lucide.json +2 -2
- package/dist/runtime/marked/marked.min.js +69 -0
- package/dist/runtime/mermaid/mermaid.esm.min.mjs +3593 -0
- package/dist/runtime/milkdown/apl-2VCEVXBO.js +1 -0
- package/dist/runtime/milkdown/asciiarmor-ND4TKJ2V.js +1 -0
- package/dist/runtime/milkdown/asn1-5NCC72L6.js +1 -0
- package/dist/runtime/milkdown/asterisk-V3QQOGYS.js +1 -0
- package/dist/runtime/milkdown/block-B3H3PJID.js +1 -0
- package/dist/runtime/milkdown/brainfuck-SETQDLAI.js +1 -0
- package/dist/runtime/milkdown/chunk-23NN352E.js +1 -0
- package/dist/runtime/milkdown/chunk-373V6XMI.js +1 -0
- package/dist/runtime/milkdown/chunk-37CATSBM.js +1 -0
- package/dist/runtime/milkdown/chunk-3EORQGKQ.js +1 -0
- package/dist/runtime/milkdown/chunk-6HASM4ZR.js +1 -0
- package/dist/runtime/milkdown/chunk-6RGD2KUU.js +1 -0
- package/dist/runtime/milkdown/chunk-7CVS4AGG.js +3 -0
- package/dist/runtime/milkdown/chunk-BV6CAHIM.js +4 -0
- package/dist/runtime/milkdown/chunk-CS3PHHYU.js +0 -0
- package/dist/runtime/milkdown/chunk-E5R7FPWA.js +5 -0
- package/dist/runtime/milkdown/chunk-E6JE25ZM.js +0 -0
- package/dist/runtime/milkdown/chunk-FGZNEC46.js +1 -0
- package/dist/runtime/milkdown/chunk-FOZORPFE.js +1 -0
- package/dist/runtime/milkdown/chunk-GAWLLGNO.js +5 -0
- package/dist/runtime/milkdown/chunk-GHRUWTEV.js +1 -0
- package/dist/runtime/milkdown/chunk-GVZW4OO4.js +1 -0
- package/dist/runtime/milkdown/chunk-HDKYYBRG.js +0 -0
- package/dist/runtime/milkdown/chunk-KJCZ4UN6.js +1 -0
- package/dist/runtime/milkdown/chunk-KOCVWYBK.js +1 -0
- package/dist/runtime/milkdown/chunk-KXKDEYCC.js +1 -0
- package/dist/runtime/milkdown/chunk-LIY3GISO.js +13 -0
- package/dist/runtime/milkdown/chunk-MSEQNMGN.js +0 -0
- package/dist/runtime/milkdown/chunk-PSGXCQNW.js +1 -0
- package/dist/runtime/milkdown/chunk-Q5FF4VKZ.js +1 -0
- package/dist/runtime/milkdown/chunk-R7FZKCAV.js +1 -0
- package/dist/runtime/milkdown/chunk-SFCQEU26.js +1 -0
- package/dist/runtime/milkdown/chunk-SMRDMV2Q.js +1 -0
- package/dist/runtime/milkdown/chunk-TTCZLSO2.js +1 -0
- package/dist/runtime/milkdown/chunk-UBIXYWAI.js +13 -0
- package/dist/runtime/milkdown/chunk-UPNN5QP4.js +3 -0
- package/dist/runtime/milkdown/chunk-VBVMNS5A.js +3 -0
- package/dist/runtime/milkdown/chunk-VKELS2FZ.js +41 -0
- package/dist/runtime/milkdown/chunk-VPKKXG6L.js +1 -0
- package/dist/runtime/milkdown/chunk-VYL5RGSY.js +0 -0
- package/dist/runtime/milkdown/chunk-WGUKYDQQ.js +1 -0
- package/dist/runtime/milkdown/chunk-XOIKFU3P.js +4 -0
- package/dist/runtime/milkdown/chunk-XOU65PX7.js +1 -0
- package/dist/runtime/milkdown/clike-WKR6QU6G.js +1 -0
- package/dist/runtime/milkdown/clipboard-SGEGWVIL.js +1 -0
- package/dist/runtime/milkdown/clojure-7C5XMSLE.js +1 -0
- package/dist/runtime/milkdown/cmake-VX6UCCMV.js +1 -0
- package/dist/runtime/milkdown/cobol-IUBDOVSU.js +1 -0
- package/dist/runtime/milkdown/coffeescript-OEAM3K5M.js +1 -0
- package/dist/runtime/milkdown/commonlisp-LRFHKBQZ.js +1 -0
- package/dist/runtime/milkdown/commonmark-KYRQSFY7.js +1 -0
- package/dist/runtime/milkdown/core-SZ3VAN2E.js +1 -0
- package/dist/runtime/milkdown/crystal-7XKMI75H.js +1 -0
- package/dist/runtime/milkdown/css-DTJ74K4A.js +1 -0
- package/dist/runtime/milkdown/cursor-4RIJS7XF.js +1 -0
- package/dist/runtime/milkdown/cypher-Y7ZMLKQ4.js +1 -0
- package/dist/runtime/milkdown/d-NSEMXQMQ.js +1 -0
- package/dist/runtime/milkdown/diff-BO3JC62N.js +1 -0
- package/dist/runtime/milkdown/diff-WJOHA5PX.js +1 -0
- package/dist/runtime/milkdown/dist-5HJGMMBO.js +1 -0
- package/dist/runtime/milkdown/dist-63GMFB3D.js +1 -0
- package/dist/runtime/milkdown/dist-6JDVYEX3.js +1 -0
- package/dist/runtime/milkdown/dist-7277C2KF.js +1 -0
- package/dist/runtime/milkdown/dist-EG2OA4VS.js +7 -0
- package/dist/runtime/milkdown/dist-EHUNF6M5.js +1 -0
- package/dist/runtime/milkdown/dist-I3JGQGWS.js +3 -0
- package/dist/runtime/milkdown/dist-I3LMG6JF.js +1 -0
- package/dist/runtime/milkdown/dist-IIRHY5PY.js +6 -0
- package/dist/runtime/milkdown/dist-J2KSREXK.js +1 -0
- package/dist/runtime/milkdown/dist-KY7AL6FL.js +1 -0
- package/dist/runtime/milkdown/dist-QB3U2COU.js +1 -0
- package/dist/runtime/milkdown/dist-QMASZW6X.js +1 -0
- package/dist/runtime/milkdown/dist-RS6ERIZS.js +1 -0
- package/dist/runtime/milkdown/dist-TKSPPVS4.js +1 -0
- package/dist/runtime/milkdown/dist-U6ZG6DV6.js +1 -0
- package/dist/runtime/milkdown/dist-UHXLU77N.js +1 -0
- package/dist/runtime/milkdown/dist-WNQ5J4WR.js +2 -0
- package/dist/runtime/milkdown/dist-WWUPY2DM.js +1 -0
- package/dist/runtime/milkdown/dist-X2CT5LDV.js +1 -0
- package/dist/runtime/milkdown/dist-ZBCFN6O5.js +1 -0
- package/dist/runtime/milkdown/dockerfile-NAEEVAQU.js +1 -0
- package/dist/runtime/milkdown/dtd-3HSCMPBI.js +1 -0
- package/dist/runtime/milkdown/dylan-UCUZF6KU.js +1 -0
- package/dist/runtime/milkdown/ebnf-3LHOCFAJ.js +1 -0
- package/dist/runtime/milkdown/ecl-5R3NXF6N.js +1 -0
- package/dist/runtime/milkdown/eiffel-CQ4L5MSH.js +1 -0
- package/dist/runtime/milkdown/elm-6QYNGBQ3.js +1 -0
- package/dist/runtime/milkdown/erlang-6NH23EDV.js +1 -0
- package/dist/runtime/milkdown/esm-W3C6FIFD.js +997 -0
- package/dist/runtime/milkdown/factor-MYKNDQPQ.js +1 -0
- package/dist/runtime/milkdown/fcl-ACRUXLOI.js +1 -0
- package/dist/runtime/milkdown/forth-MGVKD22I.js +1 -0
- package/dist/runtime/milkdown/fortran-Y2LH5YJY.js +1 -0
- package/dist/runtime/milkdown/gas-DGW2BQT5.js +1 -0
- package/dist/runtime/milkdown/gfm-E3RPWLDM.js +1 -0
- package/dist/runtime/milkdown/gherkin-YE56IVZ5.js +1 -0
- package/dist/runtime/milkdown/groovy-ACMNYCLF.js +1 -0
- package/dist/runtime/milkdown/haskell-MIB6HZSL.js +1 -0
- package/dist/runtime/milkdown/haxe-TANQRBYK.js +1 -0
- package/dist/runtime/milkdown/history-MXXSC4BB.js +1 -0
- package/dist/runtime/milkdown/http-QUK2BL6J.js +1 -0
- package/dist/runtime/milkdown/idl-54U6ONEE.js +1 -0
- package/dist/runtime/milkdown/indent-DPZPSW7O.js +1 -0
- package/dist/runtime/milkdown/javascript-43PROIAY.js +1 -0
- package/dist/runtime/milkdown/julia-7E2ZIO2U.js +1 -0
- package/dist/runtime/milkdown/lib-OHEPSUTR.js +1 -0
- package/dist/runtime/milkdown/lib-ULUU3LBY.js +1 -0
- package/dist/runtime/milkdown/listener-YERMSFXE.js +1 -0
- package/dist/runtime/milkdown/livescript-SUEXR7PK.js +1 -0
- package/dist/runtime/milkdown/lua-QNGITPQK.js +1 -0
- package/dist/runtime/milkdown/mathematica-HJQQXVFC.js +1 -0
- package/dist/runtime/milkdown/mbox-F6SUCJVD.js +1 -0
- package/dist/runtime/milkdown/milkdown-editor.js +1 -0
- package/dist/runtime/milkdown/milkdown-text-editor.js +1 -0
- package/dist/runtime/milkdown/mirc-7S5H76VB.js +1 -0
- package/dist/runtime/milkdown/mllike-TTW7I7W4.js +1 -0
- package/dist/runtime/milkdown/model-YUHBWZ3A.js +1 -0
- package/dist/runtime/milkdown/modelica-3POMKZFY.js +1 -0
- package/dist/runtime/milkdown/mscgen-IKAT43RT.js +1 -0
- package/dist/runtime/milkdown/mumps-XZE3RMGJ.js +1 -0
- package/dist/runtime/milkdown/nginx-QCVWU6DV.js +1 -0
- package/dist/runtime/milkdown/nsis-2G5LLGBI.js +1 -0
- package/dist/runtime/milkdown/ntriples-T6AMEY2C.js +1 -0
- package/dist/runtime/milkdown/octave-64EAJHKR.js +1 -0
- package/dist/runtime/milkdown/oz-7QHCZG72.js +1 -0
- package/dist/runtime/milkdown/pascal-KWNZTZKE.js +1 -0
- package/dist/runtime/milkdown/perl-KX75FRG7.js +1 -0
- package/dist/runtime/milkdown/pig-YA2LFBUW.js +1 -0
- package/dist/runtime/milkdown/powershell-SONNWKJG.js +1 -0
- package/dist/runtime/milkdown/properties-MEUWSNZY.js +1 -0
- package/dist/runtime/milkdown/protobuf-RKCPHWGY.js +1 -0
- package/dist/runtime/milkdown/pug-VWTHDU4H.js +1 -0
- package/dist/runtime/milkdown/puppet-JMZDB2TG.js +1 -0
- package/dist/runtime/milkdown/python-GVEPBHD7.js +1 -0
- package/dist/runtime/milkdown/q-QBK3FAEX.js +1 -0
- package/dist/runtime/milkdown/r-QZYPZHNL.js +1 -0
- package/dist/runtime/milkdown/rpm-DU7TLFAI.js +1 -0
- package/dist/runtime/milkdown/ruby-DMEPZV6P.js +1 -0
- package/dist/runtime/milkdown/sas-UQCOIXSD.js +1 -0
- package/dist/runtime/milkdown/scheme-ABXYL6GU.js +1 -0
- package/dist/runtime/milkdown/shell-M3XELTMZ.js +1 -0
- package/dist/runtime/milkdown/sieve-MUKKCDBZ.js +1 -0
- package/dist/runtime/milkdown/slash-WRZAFLVA.js +1 -0
- package/dist/runtime/milkdown/smalltalk-P4FKOVAU.js +1 -0
- package/dist/runtime/milkdown/solr-HHKG4NNK.js +1 -0
- package/dist/runtime/milkdown/sparql-5YJAIBWN.js +1 -0
- package/dist/runtime/milkdown/spreadsheet-M3SEYOFV.js +1 -0
- package/dist/runtime/milkdown/sql-Z6C3KTS5.js +1 -0
- package/dist/runtime/milkdown/stex-MO67FBMF.js +1 -0
- package/dist/runtime/milkdown/streaming-ODT2C2AX.js +1 -0
- package/dist/runtime/milkdown/stylus-JEMVT3OU.js +1 -0
- package/dist/runtime/milkdown/swift-HP7RYRJA.js +1 -0
- package/dist/runtime/milkdown/tcl-WPHRLNQC.js +1 -0
- package/dist/runtime/milkdown/textile-3LZDM6IW.js +1 -0
- package/dist/runtime/milkdown/theme/common/@milkdown/kit/prose/gapcursor/style/gapcursor.css +25 -0
- package/dist/runtime/milkdown/theme/common/@milkdown/kit/prose/tables/style/tables.css +48 -0
- package/dist/runtime/milkdown/theme/common/@milkdown/kit/prose/view/style/prosemirror.css +54 -0
- package/dist/runtime/milkdown/theme/common/ai.css +446 -0
- package/dist/runtime/milkdown/theme/common/block-edit.css +131 -0
- package/dist/runtime/milkdown/theme/common/code-mirror.css +347 -0
- package/dist/runtime/milkdown/theme/common/cursor.css +22 -0
- package/dist/runtime/milkdown/theme/common/diff.css +177 -0
- package/dist/runtime/milkdown/theme/common/image-block.css +384 -0
- package/dist/runtime/milkdown/theme/common/latex.css +42 -0
- package/dist/runtime/milkdown/theme/common/link-tooltip.css +107 -0
- package/dist/runtime/milkdown/theme/common/list-item.css +50 -0
- package/dist/runtime/milkdown/theme/common/placeholder.css +11 -0
- package/dist/runtime/milkdown/theme/common/prosemirror-virtual-cursor/style/virtual-cursor.css +51 -0
- package/dist/runtime/milkdown/theme/common/prosemirror.css +1 -0
- package/dist/runtime/milkdown/theme/common/reset.css +289 -0
- package/dist/runtime/milkdown/theme/common/style.css +15 -0
- package/dist/runtime/milkdown/theme/common/table.css +219 -0
- package/dist/runtime/milkdown/theme/common/toolbar.css +50 -0
- package/dist/runtime/milkdown/theme/common/top-bar.css +152 -0
- package/dist/runtime/milkdown/tiddlywiki-LMGAXCWG.js +1 -0
- package/dist/runtime/milkdown/tiki-SC7NYLRG.js +1 -0
- package/dist/runtime/milkdown/toml-VBRI3ILD.js +1 -0
- package/dist/runtime/milkdown/tooltip-MQR7E3GN.js +1 -0
- package/dist/runtime/milkdown/troff-MZNIC3MS.js +1 -0
- package/dist/runtime/milkdown/ttcn-ZUOU74GM.js +1 -0
- package/dist/runtime/milkdown/ttcn-cfg-2JJUM5CY.js +1 -0
- package/dist/runtime/milkdown/turtle-SNBPEJHA.js +1 -0
- package/dist/runtime/milkdown/upload-4DLRUKG7.js +1 -0
- package/dist/runtime/milkdown/utils-RGFMAFOI.js +1 -0
- package/dist/runtime/milkdown/vb-U45Y75DV.js +1 -0
- package/dist/runtime/milkdown/vbscript-XTRRB36U.js +1 -0
- package/dist/runtime/milkdown/velocity-Y7TX26SP.js +1 -0
- package/dist/runtime/milkdown/verilog-IFT4S6MZ.js +1 -0
- package/dist/runtime/milkdown/vhdl-CK4X465M.js +1 -0
- package/dist/runtime/milkdown/webidl-N7XOMHHB.js +1 -0
- package/dist/runtime/milkdown/xquery-EPMIEXTW.js +1 -0
- package/dist/runtime/milkdown/y-webrtc-MVXVFPYO.js +2 -0
- package/dist/runtime/milkdown/yacas-A74LVH45.js +1 -0
- package/dist/runtime/milkdown/yjs-L4ZX4CJ5.js +1 -0
- package/dist/runtime/milkdown/z80-NVBCD5FV.js +1 -0
- package/docs/blocks.md +4 -2
- package/docs/components/markdown.md +2 -2
- package/docs/components/text-editor.md +37 -3
- package/docs/icons.md +4 -2
- package/docs/installation.md +36 -28
- package/docs/owl-components.md +7 -5
- package/docs/theming.md +2 -2
- package/docs/usage-guide.md +64 -60
- package/package.json +8 -2
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{e as Je}from"./chunk-23NN352E.js";var _=()=>new Map,Xe=e=>{let t=_();return e.forEach((n,r)=>{t.set(r,n)}),t},L=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Wr=(e,t)=>{let n=[];for(let[r,s]of e)n.push(t(s,r));return n},Zr=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1};var W=()=>new Set;var Pe=e=>e[e.length-1];var Qr=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},P=Array.from,Ke=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},ge=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1};var ts=(e,t)=>{let n=new Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n};var st=Array.isArray;var Ot=class{constructor(){this._observers=_()}on(t,n){return L(this._observers,t,W).add(n),n}once(t,n){let r=(...s)=>{this.off(t,r),n(...s)};this.on(t,r)}off(t,n){let r=this._observers.get(t);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(t))}emit(t,n){return P((this._observers.get(t)||_()).values()).forEach(r=>r(...n))}destroy(){this._observers=_()}},es=class{constructor(){this._observers=_()}on(t,n){L(this._observers,t,W).add(n)}once(t,n){let r=(...s)=>{this.off(t,r),n(...s)};this.on(t,r)}off(t,n){let r=this._observers.get(t);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(t))}emit(t,n){return P((this._observers.get(t)||_()).values()).forEach(r=>r(...n))}destroy(){this._observers=_()}};var O=Math.floor;var bt=Math.abs;var $l=Math.log10;var Ye=(e,t)=>e<t?e:t,it=(e,t)=>e>t?e:t,Fl=Number.isNaN;var We=e=>e!==0?e<0:1/e<0;var Nt=Number.MAX_SAFE_INTEGER,Hn=Number.MIN_SAFE_INTEGER,jl=1<<31;var ns=Number.isInteger||(e=>typeof e=="number"&&isFinite(e)&&O(e)===e),ql=Number.isNaN,Gl=Number.parseInt;var we=String.fromCharCode,to=String.fromCodePoint,zl=we(65535),eo=e=>e.toLowerCase(),no=/^\s*/g,ro=e=>e.replace(no,""),so=/([A-Z])/g,Xn=(e,t)=>ro(e.replace(so,n=>`${t}${eo(n)}`));var io=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=t.codePointAt(s);return r},Bt=typeof TextEncoder<"u"?new TextEncoder:null,oo=e=>Bt.encode(e),rs=Bt?oo:io;var Lt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Lt&&Lt.decode(new Uint8Array).length===1&&(Lt=null);var Ze=(e,t)=>ts(t,()=>e).join("");var kt=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},ut=()=>new kt,ls=e=>{let t=ut();return e(t),$(t)},co=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t};var $=e=>{let t=new Uint8Array(co(e)),n=0;for(let r=0;r<e.bufs.length;r++){let s=e.bufs[r];t.set(s,n),n+=s.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},lo=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(it(n,t)*2),e.cpos=0)},T=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t};var Ft=T;var g=(e,t)=>{for(;t>127;)T(e,128|127&t),t=O(t/128);T(e,127&t)},xe=(e,t)=>{let n=We(t);for(n&&(t=-t),T(e,(t>63?128:0)|(n?64:0)|63&t),t=O(t/64);t>0;)T(e,(t>127?128:0)|127&t),t=O(t/128)},Pn=new Uint8Array(3e4),ao=Pn.length/3,ho=(e,t)=>{if(t.length<ao){let n=Bt.encodeInto(t,Pn).written||0;g(e,n);for(let r=0;r<n;r++)T(e,Pn[r])}else F(e,rs(t))},uo=(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;g(e,r);for(let s=0;s<r;s++)T(e,n.codePointAt(s))},lt=Bt&&Bt.encodeInto?ho:uo;var as=(e,t)=>jt(e,$(t)),jt=(e,t)=>{let n=e.cbuf.length,r=e.cpos,s=Ye(n-r,t.length),i=t.length-s;e.cbuf.set(t.subarray(0,s),r),e.cpos+=s,i>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(it(n*2,i)),e.cbuf.set(t.subarray(s)),e.cpos=i)},F=(e,t)=>{g(e,t.byteLength),jt(e,t)},Kn=(e,t)=>{lo(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},fo=(e,t)=>Kn(e,4).setFloat32(0,t,!1),po=(e,t)=>Kn(e,8).setFloat64(0,t,!1),go=(e,t)=>Kn(e,8).setBigInt64(0,t,!1);var is=new DataView(new ArrayBuffer(4)),mo=e=>(is.setFloat32(0,e),is.getFloat32(0)===e),at=(e,t)=>{switch(typeof t){case"string":T(e,119),lt(e,t);break;case"number":ns(t)&&bt(t)<=2147483647?(T(e,125),xe(e,t)):mo(t)?(T(e,124),fo(e,t)):(T(e,123),po(e,t));break;case"bigint":T(e,122),go(e,t);break;case"object":if(t===null)T(e,126);else if(st(t)){T(e,117),g(e,t.length);for(let n=0;n<t.length;n++)at(e,t[n])}else if(t instanceof Uint8Array)T(e,116),F(e,t);else{T(e,118);let n=Object.keys(t);g(e,n.length);for(let r=0;r<n.length;r++){let s=n[r];lt(e,s),at(e,t[s])}}break;case"boolean":T(e,t?120:121);break;default:T(e,127)}},ye=class extends kt{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&g(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}};var os=e=>{e.count>0&&(xe(e.encoder,e.count===1?e.s:-e.s),e.count>1&&g(e.encoder,e.count-2))},St=class{constructor(){this.encoder=new kt,this.s=0,this.count=0}write(t){this.s===t?this.count++:(os(this),this.count=1,this.s=t)}toUint8Array(){return os(this),$(this.encoder)}};var cs=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);xe(e.encoder,t),e.count>1&&g(e.encoder,e.count-2)}},$t=class{constructor(){this.encoder=new kt,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(cs(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return cs(this),$(this.encoder)}},Qe=class{constructor(){this.sarr=[],this.s="",this.lensE=new St}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){let t=new kt;return this.sarr.push(this.s),this.s="",lt(t,this.sarr.join("")),jt(t,this.lensE.toUint8Array()),$(t)}};var G=e=>new Error(e),z=()=>{throw G("Method unimplemented")},D=()=>{throw G("Unexpected case")};var us=G("Unexpected end of array"),ds=G("Integer out of Range"),qt=class{constructor(t){this.arr=t,this.pos=0}},V=e=>new qt(e),Wn=e=>e.pos!==e.arr.length;var wo=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},j=e=>wo(e,w(e));var _t=e=>e.arr[e.pos++];var w=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let s=e.arr[e.pos++];if(t=t+(s&127)*n,n*=128,s<128)return t;if(t>Nt)throw ds}throw us},ke=e=>{let t=e.arr[e.pos++],n=t&63,r=64,s=(t&64)>0?-1:1;if((t&128)===0)return s*n;let i=e.arr.length;for(;e.pos<i;){if(t=e.arr[e.pos++],n=n+(t&127)*r,r*=128,t<128)return s*n;if(n>Nt)throw ds}throw us};var yo=e=>{let t=w(e);if(t===0)return"";{let n=String.fromCodePoint(_t(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(_t(e));else for(;t>0;){let r=t<1e4?t:1e4,s=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,s),t-=r}return decodeURIComponent(escape(n))}},xo=e=>Lt.decode(j(e)),dt=Lt?xo:yo;var Zn=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},bo=e=>Zn(e,4).getFloat32(0,!1),ko=e=>Zn(e,8).getFloat64(0,!1),So=e=>Zn(e,8).getBigInt64(0,!1);var _o=[e=>{},e=>null,ke,bo,ko,So,e=>!1,e=>!0,dt,e=>{let t=w(e),n={};for(let r=0;r<t;r++){let s=dt(e);n[s]=Gt(e)}return n},e=>{let t=w(e),n=[];for(let r=0;r<t;r++)n.push(Gt(e));return n},j],Gt=e=>_o[127-_t(e)](e),be=class extends qt{constructor(t,n){super(t),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Wn(this)?this.count=w(this)+1:this.count=-1),this.count--,this.s}};var Et=class extends qt{constructor(t){super(t),this.s=0,this.count=0}read(){if(this.count===0){this.s=ke(this);let t=We(this.s);this.count=1,t&&(this.s=-this.s,this.count=w(this)+2)}return this.count--,this.s}};var zt=class extends qt{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=ke(this),n=t&1;this.diff=O(t/2),this.count=1,n&&(this.count=w(this)+2)}return this.s+=this.diff,this.count--,this.s}},tn=class{constructor(t){this.decoder=new Et(t),this.str=dt(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),n=this.str.slice(this.spos,t);return this.spos=t,n}};var Xl=crypto.subtle,fs=crypto.getRandomValues.bind(crypto);var Uo=Math.random,Qn=()=>fs(new Uint32Array(1))[0];var Yl=e=>e[O(Uo()*e.length)],Co="10000000-1000-4000-8000"+-1e11,ps=()=>Co.replace(/[018]/g,e=>(e^Qn()&15>>e/4).toString(16));var Se=Date.now;var tr=e=>new Promise(e);var Wl=Promise.all.bind(Promise),Zl=e=>Promise.reject(e),Ql=e=>Promise.resolve(e);var er=e=>e===void 0?null:e;var nr=class{constructor(){this.map=new Map}setItem(t,n){this.map.set(t,n)}getItem(t){return this.map.get(t)}},ms=new nr,rr=!0;try{typeof localStorage<"u"&&localStorage&&(ms=localStorage,rr=!1)}catch{}var ws=ms,ta=e=>rr||addEventListener("storage",e),ea=e=>rr||removeEventListener("storage",e);var Ut=Symbol("Equality"),en=(e,t)=>e===t||!!e?.[Ut]?.(t)||!1;var ys=e=>typeof e=="object",xs=Object.assign,vo=Object.keys;var bs=(e,t)=>{for(let n in e)t(e[n],n)};var _e=e=>vo(e).length;var ks=e=>{for(let t in e)return!1;return!0},Ht=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Ee=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ir=(e,t)=>e===t||_e(e)===_e(t)&&Ht(e,(n,r)=>(n!==void 0||Ee(t,r))&&en(t[r],n)),Oo=Object.freeze,or=e=>{for(let t in e){let n=e[t];(typeof n=="object"||typeof n=="function")&&or(e[t])}return Oo(e)};var Ce=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Ce(e,t,n+1)}},Ss=()=>{};var lr=e=>e;var Ue=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Ut]!=null)return e[Ut](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:{if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break}case Set:{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break}case Map:{if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!Ue(e.get(n),t.get(n)))return!1;break}case void 0:case Object:if(_e(e)!==_e(t))return!1;for(let n in e)if(!Ee(e,n)||!Ue(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ue(e[n],t[n]))return!1;break;default:return!1}return!0},_s=(e,t)=>t.includes(e);var Jt=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",rn=typeof window<"u"&&typeof document<"u"&&!Jt,na=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,Z,Vo=[],No=()=>{if(Z===void 0)if(Jt){Z=_();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]==="-"?(t!==null&&Z.set(t,""),t=r):t!==null?(Z.set(t,r),t=null):Vo.push(r)}t!==null&&Z.set(t,"")}else typeof location=="object"?(Z=_(),(location.search||"?").slice(1).split("&").forEach(e=>{if(e.length!==0){let[t,n]=e.split("=");Z.set(`--${Xn(t,"-")}`,n),Z.set(`-${Xn(t,"-")}`,n)}})):Z=_();return Z},ar=e=>No().has(e);var Ct=e=>Jt?er(process.env[e.toUpperCase().replaceAll("-","_")]):er(ws.getItem(e));var Es=e=>ar("--"+e)||Ct(e)!==null,Us=Es("production"),Lo=Jt&&_s(process.env.FORCE_COLOR,["true","1","2"]),Cs=Lo||!ar("--no-colors")&&!Es("no-color")&&(!Jt||process.stdout.isTTY)&&(!Jt||ar("--color")||Ct("COLORTERM")!==null||(Ct("TERM")||"").includes("color"));var As=e=>new Uint8Array(e),Bo=(e,t,n)=>new Uint8Array(e,t,n),ra=e=>new Uint8Array(e),Mo=e=>{let t="";for(let n=0;n<e.byteLength;n++)t+=we(e[n]);return btoa(t)},Ro=e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"),$o=e=>{let t=atob(e),n=As(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n},Fo=e=>{let t=Buffer.from(e,"base64");return Bo(t.buffer,t.byteOffset,t.byteLength)},sa=rn?Mo:Ro,ia=rn?$o:Fo;var Is=e=>{let t=As(e.byteLength);return t.set(e),t},oa=e=>ls(t=>at(t,e));var hr=class{constructor(t,n){this.left=t,this.right=n}},Q=(e,t)=>new hr(e,t);var ur=e=>e.next()>=.5,sn=(e,t,n)=>O(e.next()*(n+1-t)+t);var dr=(e,t,n)=>O(e.next()*(n+1-t)+t);var fr=(e,t,n)=>dr(e,t,n);var Go=e=>we(fr(e,97,122)),Ts=(e,t=0,n=20)=>{let r=fr(e,t,n),s="";for(let i=0;i<r;i++)s+=Go(e);return s};var on=(e,t)=>t[fr(e,0,t.length-1)];var Ho=Symbol("0schema"),pr=class{constructor(){this._rerrs=[]}extend(t,n,r,s=null){this._rerrs.push({path:t,expected:n,has:r,message:s})}toString(){let t=[];for(let n=this._rerrs.length-1;n>0;n--){let r=this._rerrs[n];t.push(Ze(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return t.join(`
|
|
2
|
+
`)}},gr=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Ut]?en(e,t):st(e)?Ke(e,n=>ge(t,r=>gr(n,r))):ys(e)?Ht(e,(n,r)=>gr(n,t[r])):!1,v=class{extends(t){let[n,r]=[this.shape,t.shape];return this.constructor._dilutes&&([r,n]=[n,r]),gr(n,r)}equals(t){return this.constructor===t.constructor&&Ue(this.shape,t.shape)}[Ho](){return!0}[Ut](t){return this.equals(t)}validate(t){return this.check(t)}check(t,n){z()}get nullable(){return Zt(this,xn)}get optional(){return new cn(this)}cast(t){return Ds(t,this),t}expect(t){return Ds(t,this),t}};Je(v,"_dilutes",!1);var Ie=class extends v{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n=void 0){let r=t?.constructor===this.shape&&(this._c==null||this._c(t));return!r&&n?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}},U=(e,t=null)=>new Ie(e,t),la=U(Ie),Te=class extends v{constructor(t){super(),this.shape=t}check(t,n){let r=this.shape(t);return!r&&n?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),r}},I=e=>new Te(e),aa=U(Te),Yt=class extends v{constructor(t){super(),this.shape=t}check(t,n){let r=this.shape.some(s=>s===t);return!r&&n?.extend(null,this.shape.join(" | "),t.toString()),r}},wn=(...e)=>new Yt(e),vs=U(Yt),Jo=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),Os=e=>{if(Wt.check(e))return[Jo(e)];if(vs.check(e))return e.shape.map(t=>t+"");if(Ms.check(e))return["[+-]?\\d+.?\\d*"];if(Rs.check(e))return[".*"];if(pn.check(e))return e.shape.map(Os).flat(1);D()},mr=class extends v{constructor(t){super(),this.shape=t,this._r=new RegExp("^"+t.map(Os).map(n=>`(${n.join("|")})`).join("")+"$")}check(t,n){let r=this._r.exec(t)!=null;return!r&&n?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),r}};var ha=U(mr),Xo=Symbol("optional"),cn=class extends v{constructor(t){super(),this.shape=t}check(t,n){let r=t===void 0||this.shape.check(t);return!r&&n?.extend(null,"undefined (optional)","()"),r}get[Xo](){return!0}},Po=U(cn),ln=class extends v{check(t,n){return n?.extend(null,"never",typeof t),!1}},ua=new ln,da=U(ln),mn=class mn extends v{constructor(t,n=!1){super(),this.shape=t,this._isPartial=n}get partial(){return new mn(this.shape,!0)}check(t,n){return t==null?(n?.extend(null,"object","null"),!1):Ht(this.shape,(r,s)=>{let i=this._isPartial&&!Ee(t,s)||r.check(t[s],n);return!i&&n?.extend(s.toString(),r.toString(),typeof t[s],"Object property does not match"),i})}};Je(mn,"_dilutes",!0);var an=mn,Ko=e=>new an(e),Yo=U(an),Wo=I(e=>e!=null&&(e.constructor===Object||e.constructor==null)),hn=class extends v{constructor(t,n){super(),this.shape={keys:t,values:n}}check(t,n){return t!=null&&Ht(t,(r,s)=>{let i=this.shape.keys.check(s,n);return!i&&n?.extend(s+"","Record",typeof t,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(r,n)})}},Vs=(e,t)=>new hn(e,t),Zo=U(hn),un=class extends v{constructor(t){super(),this.shape=t}check(t,n){return t!=null&&Ht(this.shape,(r,s)=>{let i=r.check(t[s],n);return!i&&n?.extend(s.toString(),"Tuple",typeof r),i})}},Qo=(...e)=>new un(e),fa=U(un),dn=class extends v{constructor(t){super(),this.shape=t.length===1?t[0]:new Pt(t)}check(t,n){let r=st(t)&&Ke(t,s=>this.shape.check(s));return!r&&n?.extend(null,"Array",""),r}},Ns=(...e)=>new dn(e),tc=U(dn),ec=I(e=>st(e)),fn=class extends v{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n){let r=t instanceof this.shape&&(this._c==null||this._c(t));return!r&&n?.extend(null,this.shape.name,t?.constructor.name),r}},nc=(e,t=null)=>new fn(e,t),pa=U(fn),rc=nc(v),wr=class extends v{constructor(t){super(),this.len=t.length-1,this.args=Qo(...t.slice(-1)),this.res=t[this.len]}check(t,n){let r=t.constructor===Function&&t.length<=this.len;return!r&&n?.extend(null,"function",typeof t),r}};var sc=U(wr),ic=I(e=>typeof e=="function"),yr=class extends v{constructor(t){super(),this.shape=t}check(t,n){let r=Ke(this.shape,s=>s.check(t,n));return!r&&n?.extend(null,"Intersectinon",typeof t),r}};var ga=U(yr,e=>e.shape.length>0),Pt=class extends v{constructor(t){super(),this.shape=t}check(t,n){let r=ge(this.shape,s=>s.check(t,n));return n?.extend(null,"Union",typeof t),r}};Je(Pt,"_dilutes",!0);var Zt=(...e)=>e.findIndex(t=>pn.check(t))>=0?Zt(...e.map(t=>De(t)).map(t=>pn.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new Pt(e),pn=U(Pt),Ls=()=>!0,gn=I(Ls),oc=U(Te,e=>e.shape===Ls),br=I(e=>typeof e=="bigint"),cc=I(e=>e===br),Bs=I(e=>typeof e=="symbol"),ma=I(e=>e===Bs),Kt=I(e=>typeof e=="number"),Ms=I(e=>e===Kt),Wt=I(e=>typeof e=="string"),Rs=I(e=>e===Wt),yn=I(e=>typeof e=="boolean"),lc=I(e=>e===yn),$s=wn(void 0),wa=U(Yt,e=>e.shape.length===1&&e.shape[0]===void 0),ya=wn(void 0);var xn=wn(null),ac=U(Yt,e=>e.shape.length===1&&e.shape[0]===null),xa=U(Uint8Array),ba=U(Ie,e=>e.shape===Uint8Array),hc=Zt(Kt,Wt,xn,$s,br,yn,Bs),ka=(()=>{let e=Ns(gn),t=Vs(Wt,gn),n=Zt(Kt,Wt,xn,yn,e,t);return e.shape=n,t.shape.values=n,n})(),De=e=>{if(rc.check(e))return e;if(Wo.check(e)){let t={};for(let n in e)t[n]=De(e[n]);return Ko(t)}else{if(ec.check(e))return Zt(...e.map(De));if(hc.check(e))return wn(e);if(ic.check(e))return U(e)}D()},Ds=Us?()=>{}:(e,t)=>{let n=new pr;if(!t.check(e,n))throw G(`Expected value to be of type ${t.constructor.name}.
|
|
3
|
+
${n.toString()}`)},xr=class{constructor(t){this.patterns=[],this.$state=t}if(t,n){return this.patterns.push({if:De(t),h:n}),this}else(t){return this.if(gn,t)}done(){return(t,n)=>{for(let r=0;r<this.patterns.length;r++){let s=this.patterns[r];if(s.if.check(t))return s.h(t,n)}throw G("Unhandled pattern")}}},uc=e=>new xr(e),Fs=uc(gn).if(Ms,(e,t)=>sn(t,Hn,Nt)).if(Rs,(e,t)=>Ts(t)).if(lc,(e,t)=>ur(t)).if(cc,(e,t)=>BigInt(sn(t,Hn,Nt))).if(pn,(e,t)=>Xt(t,on(t,e.shape))).if(Yo,(e,t)=>{let n={};for(let r in e.shape){let s=e.shape[r];if(Po.check(s)){if(ur(t))continue;s=s.shape}n[r]=Fs(s,t)}return n}).if(tc,(e,t)=>{let n=[],r=dr(t,0,42);for(let s=0;s<r;s++)n.push(Xt(t,e.shape));return n}).if(vs,(e,t)=>on(t,e.shape)).if(ac,(e,t)=>null).if(sc,(e,t)=>{let n=Xt(t,e.res);return()=>n}).if(oc,(e,t)=>Xt(t,on(t,[Kt,Wt,xn,$s,br,yn,Ns(Kt),Vs(Zt("a","b","c"),Kt)]))).if(Zo,(e,t)=>{let n={},r=sn(t,0,3);for(let s=0;s<r;s++){let i=Xt(t,e.shape.keys),o=Xt(t,e.shape.values);n[i]=o}return n}).done(),Xt=(e,t)=>Fs(De(t),e);var At=typeof document<"u"?document:{};var _a=I(e=>e.nodeType===mc);var Ea=typeof DOMParser<"u"?new DOMParser:null;var Ua=I(e=>e.nodeType===fc);var Ca=I(e=>e.nodeType===pc);var js=e=>Wr(e,(t,n)=>`${n}:${t};`).join("");var fc=At.ELEMENT_NODE,pc=At.TEXT_NODE,Aa=At.CDATA_SECTION_NODE,Ia=At.COMMENT_NODE,gc=At.DOCUMENT_NODE,Ta=At.DOCUMENT_TYPE_NODE,mc=At.DOCUMENT_FRAGMENT_NODE,Da=I(e=>e.nodeType===gc);var qs=JSON.stringify;var bn=e=>class{constructor(n){this._=n}destroy(){e(this._)}},xc=bn(clearTimeout),Oa=(e,t)=>new xc(setTimeout(t,e)),Va=bn(clearInterval);var Na=bn(e=>typeof requestAnimationFrame<"u"&&cancelAnimationFrame(e));var La=bn(e=>typeof cancelIdleCallback<"u"&&cancelIdleCallback(e));var tt=Symbol;var ve=tt(),Oe=tt(),kn=tt(),Sr=tt(),Sn=tt(),Ve=tt(),_n=tt(),It=tt(),En=tt(),Hs=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let s=e[r];if(s===void 0)break;if(s.constructor===String||s.constructor===Number)t.push(s);else if(s.constructor===Object)break}for(r>0&&n.push(t.join(""));r<e.length;r++){let s=e[r];s instanceof Symbol||n.push(s)}return n},Gs=[Sn,_n,It,kn],kr=0,zs=Se(),Js=(e,t)=>{let n=Gs[kr],r=Ct("log"),s=r!==null&&(r==="*"||r==="true"||new RegExp(r,"gi").test(t));return kr=(kr+1)%Gs.length,t+=": ",s?(...i)=>{i.length===1&&i[0]?.constructor===Function&&(i=i[0]());let o=Se(),c=o-zs;zs=o,e(n,t,En,...i.map(l=>{switch(l!=null&&l.constructor===Uint8Array&&(l=Array.from(l)),typeof l){case"string":case"symbol":return l;default:return qs(l)}}),n," +"+c+"ms")}:Ss};var Sc={[ve]:Q("font-weight","bold"),[Oe]:Q("font-weight","normal"),[kn]:Q("color","blue"),[Sn]:Q("color","green"),[Sr]:Q("color","grey"),[Ve]:Q("color","red"),[_n]:Q("color","purple"),[It]:Q("color","orange"),[En]:Q("color","black")},_c=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=_(),s=[],i=0;for(;i<e.length;i++){let o=e[i],c=Sc[o];if(c!==void 0)r.set(c.left,c.right);else{if(o===void 0)break;if(o.constructor===String||o.constructor===Number){let l=js(r);i>0||l.length>0?(t.push("%c"+o),n.push(l)):t.push(o)}else break}}for(i>0&&(s=n,s.unshift(t.join("")));i<e.length;i++){let o=e[i];o instanceof Symbol||s.push(o)}return s},Xs=Cs?_c:Hs,Ne=(...e)=>{console.log(...Xs(e)),Ps.forEach(t=>t.print(e))},_r=(...e)=>{console.warn(...Xs(e)),e.unshift(It),Ps.forEach(t=>t.print(e))};var Ps=W();var ja=e=>Js(Ne,e);var Ks=e=>({[Symbol.iterator](){return this},next:e}),Ys=(e,t)=>Ks(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),Un=(e,t)=>Ks(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});var Qs=class extends Ot{constructor(t,n){super(),this.doc=t,this.awareness=n}},ee=class{constructor(t,n){this.clock=t,this.len=n}},wt=class{constructor(){this.clients=new Map}},ne=(e,t,n)=>t.clients.forEach((r,s)=>{let i=e.doc.store.clients.get(s);if(i!=null){let o=i[i.length-1],c=o.id.clock+o.length;for(let l=0,h=r[l];l<r.length&&h.clock<c;h=r[++l])Ai(e,i,h.clock,h.len,n)}}),Ic=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let s=O((n+r)/2),i=e[s],o=i.clock;if(o<=t){if(t<o+i.len)return s;n=s+1}else r=s-1}return null},de=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&Ic(n,t.clock)!==null},$r=e=>{e.clients.forEach(t=>{t.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<t.length;n++){let s=t[r-1],i=t[n];s.clock+s.len>=i.clock?t[r-1]=new ee(s.clock,it(s.len,i.clock+i.len-s.clock)):(r<n&&(t[r]=i),r++)}t.length=r})},re=e=>{let t=new wt;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,s)=>{if(!t.clients.has(s)){let i=r.slice();for(let o=n+1;o<e.length;o++)Qr(i,e[o].clients.get(s)||[]);t.clients.set(s,i)}});return $r(t),t},Be=(e,t,n,r)=>{L(e.clients,t,()=>[]).push(new ee(n,r))},Fr=()=>new wt,yi=e=>{let t=Fr();return e.clients.forEach((n,r)=>{let s=[];for(let i=0;i<n.length;i++){let o=n[i];if(o.deleted){let c=o.id.clock,l=o.length;if(i+1<n.length)for(let h=n[i+1];i+1<n.length&&h.deleted;h=n[++i+1])l+=h.length;s.push(new ee(c,l))}}s.length>0&&t.clients.set(r,s)}),t},et=(e,t)=>{g(e.restEncoder,t.clients.size),P(t.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{e.resetDsCurVal(),g(e.restEncoder,n);let s=r.length;g(e.restEncoder,s);for(let i=0;i<s;i++){let o=r[i];e.writeDsClock(o.clock),e.writeDsLen(o.len)}})},ot=e=>{let t=new wt,n=w(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let s=w(e.restDecoder),i=w(e.restDecoder);if(i>0){let o=L(t.clients,s,()=>[]);for(let c=0;c<i;c++)o.push(new ee(e.readDsClock(),e.readDsLen()))}}return t},ti=(e,t,n)=>{let r=new wt,s=w(e.restDecoder);for(let i=0;i<s;i++){e.resetDsCurVal();let o=w(e.restDecoder),c=w(e.restDecoder),l=n.clients.get(o)||[],h=E(n,o);for(let a=0;a<c;a++){let u=e.readDsClock(),d=u+e.readDsLen();if(u<h){h<d&&Be(r,o,h,d-h);let f=K(l,u),p=l[f];for(!p.deleted&&p.id.clock<u&&(l.splice(f+1,0,Fn(t,p,u-p.id.clock)),f++);f<l.length&&(p=l[f++],p.id.clock<d);)p.deleted||(d<p.id.clock+p.length&&l.splice(f,0,Fn(t,p,d-p.id.clock)),p.delete(t))}else Be(r,o,u,d-u)}}if(r.clients.size>0){let i=new X;return g(i.restEncoder,0),et(i,r),i.toUint8Array()}return null},Tc=(e,t)=>{if(e.clients.size!==t.clients.size)return!1;for(let[n,r]of e.clients.entries()){let s=t.clients.get(n);if(s===void 0||r.length!==s.length)return!1;for(let i=0;i<r.length;i++){let o=r[i],c=s[i];if(o.clock!==c.clock||o.len!==c.len)return!1}}return!0},xi=Qn,Tt=class e extends Ot{constructor({guid:t=ps(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=xi(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new Nn,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=tr(h=>{this.on("load",()=>{this.isLoaded=!0,h(this)})});let l=()=>tr(h=>{let a=u=>{(u===void 0||u===!0)&&(this.off("sync",a),h())};this.on("sync",a)});this.on("sync",h=>{h===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=h===void 0||h===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){let t=this._item;t!==null&&!this.shouldLoad&&x(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(P(this.subdocs).map(t=>t.guid))}transact(t,n=null){return x(this,t,n)}get(t,n=C){let r=L(this.share,t,()=>{let i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==C&&s!==n)if(s===C){let i=new n;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(t,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,oe)}getText(t=""){return this.get(t,qe)}getMap(t=""){return this.get(t,ce)}getXmlElement(t=""){return this.get(t,ae)}getXmlFragment(t=""){return this.get(t,le)}toJSON(){let t={};return this.share.forEach((n,r)=>{t[r]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,P(this.subdocs).forEach(n=>n.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,x(t.parent.doc,r=>{let s=n.doc;t.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},Dt=class{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return w(this.restDecoder)}readDsLen(){return w(this.restDecoder)}},H=class extends Dt{readLeftID(){return m(w(this.restDecoder),w(this.restDecoder))}readRightID(){return m(w(this.restDecoder),w(this.restDecoder))}readClient(){return w(this.restDecoder)}readInfo(){return _t(this.restDecoder)}readString(){return dt(this.restDecoder)}readParentInfo(){return w(this.restDecoder)===1}readTypeRef(){return w(this.restDecoder)}readLen(){return w(this.restDecoder)}readAny(){return Gt(this.restDecoder)}readBuf(){return Is(j(this.restDecoder))}readJSON(){return JSON.parse(dt(this.restDecoder))}readKey(){return dt(this.restDecoder)}},vn=class{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=w(this.restDecoder),this.dsCurrVal}readDsLen(){let t=w(this.restDecoder)+1;return this.dsCurrVal+=t,t}},q=class extends vn{constructor(t){super(t),this.keys=[],w(t),this.keyClockDecoder=new zt(j(t)),this.clientDecoder=new Et(j(t)),this.leftClockDecoder=new zt(j(t)),this.rightClockDecoder=new zt(j(t)),this.infoDecoder=new be(j(t),_t),this.stringDecoder=new tn(j(t)),this.parentInfoDecoder=new be(j(t),_t),this.typeRefDecoder=new Et(j(t)),this.lenDecoder=new Et(j(t))}readLeftID(){return new mt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new mt(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Gt(this.restDecoder)}readBuf(){return j(this.restDecoder)}readJSON(){return Gt(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{let n=this.stringDecoder.read();return this.keys.push(n),n}}},yt=class{constructor(){this.restEncoder=ut()}toUint8Array(){return $(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){g(this.restEncoder,t)}writeDsLen(t){g(this.restEncoder,t)}},ct=class extends yt{writeLeftID(t){g(this.restEncoder,t.client),g(this.restEncoder,t.clock)}writeRightID(t){g(this.restEncoder,t.client),g(this.restEncoder,t.clock)}writeClient(t){g(this.restEncoder,t)}writeInfo(t){Ft(this.restEncoder,t)}writeString(t){lt(this.restEncoder,t)}writeParentInfo(t){g(this.restEncoder,t?1:0)}writeTypeRef(t){g(this.restEncoder,t)}writeLen(t){g(this.restEncoder,t)}writeAny(t){at(this.restEncoder,t)}writeBuf(t){F(this.restEncoder,t)}writeJSON(t){lt(this.restEncoder,JSON.stringify(t))}writeKey(t){lt(this.restEncoder,t)}},se=class{constructor(){this.restEncoder=ut(),this.dsCurrVal=0}toUint8Array(){return $(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let n=t-this.dsCurrVal;this.dsCurrVal=t,g(this.restEncoder,n)}writeDsLen(t){t===0&&D(),g(this.restEncoder,t-1),this.dsCurrVal+=t}},X=class extends se{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new $t,this.clientEncoder=new St,this.leftClockEncoder=new $t,this.rightClockEncoder=new $t,this.infoEncoder=new ye(Ft),this.stringEncoder=new Qe,this.parentInfoEncoder=new ye(Ft),this.typeRefEncoder=new St,this.lenEncoder=new St}toUint8Array(){let t=ut();return g(t,0),F(t,this.keyClockEncoder.toUint8Array()),F(t,this.clientEncoder.toUint8Array()),F(t,this.leftClockEncoder.toUint8Array()),F(t,this.rightClockEncoder.toUint8Array()),F(t,$(this.infoEncoder)),F(t,this.stringEncoder.toUint8Array()),F(t,$(this.parentInfoEncoder)),F(t,this.typeRefEncoder.toUint8Array()),F(t,this.lenEncoder.toUint8Array()),jt(t,$(this.restEncoder)),$(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){at(this.restEncoder,t)}writeBuf(t){F(this.restEncoder,t)}writeJSON(t){at(this.restEncoder,t)}writeKey(t){let n=this.keyMap.get(t);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(n)}},Dc=(e,t,n,r)=>{r=it(r,t[0].id.clock);let s=K(t,r);g(e.restEncoder,t.length-s),e.writeClient(n),g(e.restEncoder,r);let i=t[s];i.write(e,r-i.id.clock);for(let o=s+1;o<t.length;o++)t[o].write(e,0)},jr=(e,t,n)=>{let r=new Map;n.forEach((s,i)=>{E(t,i)>s&&r.set(i,s)}),He(t).forEach((s,i)=>{n.has(i)||r.set(i,0)}),g(e.restEncoder,r.size),P(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{Dc(e,t.clients.get(s),s,i)})},vc=(e,t)=>{let n=_(),r=w(e.restDecoder);for(let s=0;s<r;s++){let i=w(e.restDecoder),o=new Array(i),c=e.readClient(),l=w(e.restDecoder);n.set(c,{i:0,refs:o});for(let h=0;h<i;h++){let a=e.readInfo();switch(31&a){case 0:{let u=e.readLen();o[h]=new R(m(c,l),u),l+=u;break}case 10:{let u=w(e.restDecoder);o[h]=new B(m(c,l),u),l+=u;break}default:{let u=(a&192)===0,d=new b(m(c,l),null,(a&128)===128?e.readLeftID():null,null,(a&64)===64?e.readRightID():null,u?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,u&&(a&32)===32?e.readString():null,Wi(e,a));o[h]=d,l+=d.length}}}}return n},Oc=(e,t,n)=>{let r=[],s=P(n.keys()).sort((f,p)=>f-p);if(s.length===0)return null;let i=()=>{if(s.length===0)return null;let f=n.get(s[s.length-1]);for(;f.refs.length===f.i;)if(s.pop(),s.length>0)f=n.get(s[s.length-1]);else return null;return f},o=i();if(o===null)return null;let c=new Nn,l=new Map,h=(f,p)=>{let y=l.get(f);(y==null||y>p)&&l.set(f,p)},a=o.refs[o.i++],u=new Map,d=()=>{for(let f of r){let p=f.id.client,y=n.get(p);y?(y.i--,c.clients.set(p,y.refs.slice(y.i)),n.delete(p),y.i=0,y.refs=[]):c.clients.set(p,[f]),s=s.filter(k=>k!==p)}r.length=0};for(;;){if(a.constructor!==B){let p=L(u,a.id.client,()=>E(t,a.id.client))-a.id.clock;if(p<0)r.push(a),h(a.id.client,a.id.clock-1),d();else{let y=a.getMissing(e,t);if(y!==null){r.push(a);let k=n.get(y)||{refs:[],i:0};if(k.refs.length===k.i)h(y,E(t,y)),d();else{a=k.refs[k.i++];continue}}else(p===0||p<a.length)&&(a.integrate(e,p),u.set(a.id.client,a.id.clock+a.length))}}if(r.length>0)a=r.pop();else if(o!==null&&o.i<o.refs.length)a=o.refs[o.i++];else{if(o=i(),o===null)break;a=o.refs[o.i++]}}if(c.clients.size>0){let f=new X;return jr(f,c,new Map),g(f.restEncoder,0),{missing:l,update:f.toUint8Array()}}return null},Vc=(e,t)=>jr(e,t.doc.store,t.beforeState),bi=(e,t,n,r=new q(e))=>x(t,s=>{s.local=!1;let i=!1,o=s.doc,c=o.store,l=vc(r,o),h=Oc(s,c,l),a=c.pendingStructs;if(a){for(let[d,f]of a.missing)if(f<E(c,d)){i=!0;break}if(h){for(let[d,f]of h.missing){let p=a.missing.get(d);(p==null||p>f)&&a.missing.set(d,f)}a.update=Ln([a.update,h.update])}}else c.pendingStructs=h;let u=ti(r,s,c);if(c.pendingDs){let d=new q(V(c.pendingDs));w(d.restDecoder);let f=ti(d,s,c);u&&f?c.pendingDs=Ln([u,f]):c.pendingDs=u||f}else c.pendingDs=u;if(i){let d=c.pendingStructs.update;c.pendingStructs=null,qr(s.doc,d)}},n,!1),Ha=(e,t,n)=>bi(e,t,n,new H(e)),qr=(e,t,n,r=q)=>{let s=V(t);bi(s,e,n,new r(s))},Ja=(e,t,n)=>qr(e,t,n,H),Nc=(e,t,n=new Map)=>{jr(e,t.store,n),et(e,yi(t.store))},Lc=(e,t=new Uint8Array([0]),n=new X)=>{let r=Si(t);Nc(n,e,r);let s=[n.toUint8Array()];if(e.store.pendingDs&&s.push(e.store.pendingDs),e.store.pendingStructs&&s.push(vi(e.store.pendingStructs.update,t)),s.length>1){if(n.constructor===ct)return Yc(s.map((i,o)=>o===0?i:tl(i)));if(n.constructor===X)return Ln(s)}return s[0]},Xa=(e,t)=>Lc(e,t,new ct),ki=e=>{let t=new Map,n=w(e.restDecoder);for(let r=0;r<n;r++){let s=w(e.restDecoder),i=w(e.restDecoder);t.set(s,i)}return t},Si=e=>ki(new Dt(V(e))),Gr=(e,t)=>(g(e.restEncoder,t.size),P(t.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{g(e.restEncoder,n),g(e.restEncoder,r)}),e),Bc=(e,t)=>Gr(e,He(t.store)),Mc=(e,t=new se)=>(e instanceof Map?Gr(t,e):Bc(t,e),t.toUint8Array()),Pa=e=>Mc(e,new yt),Ur=class{constructor(){this.l=[]}},ei=()=>new Ur,ni=(e,t)=>e.l.push(t),ri=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(s=>t!==s),r===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},_i=(e,t,n)=>Ce(e.l,[t,n]),mt=class{constructor(t,n){this.client=t,this.clock=n}},Qt=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,m=(e,t)=>new mt(e,t),si=(e,t)=>{g(e,t.client),g(e,t.clock)},ii=e=>m(w(e),w(e)),Ei=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw D()},On=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},Ka=e=>{let t=[],n=e._start;for(;n;)t.push(n),n=n.right;console.log("Children: ",t),console.log("Children content: ",t.filter(r=>!r.deleted).map(r=>r.content))},oi=class{constructor(t,n=t.getMap("users")){let r=new Map;this.yusers=n,this.doc=t,this.clients=new Map,this.dss=r;let s=(i,o)=>{let c=i.get("ds"),l=i.get("ids"),h=a=>this.clients.set(a,o);c.observe(a=>{a.changes.added.forEach(u=>{u.content.getContent().forEach(d=>{d instanceof Uint8Array&&this.dss.set(o,re([this.dss.get(o)||Fr(),ot(new Dt(V(d)))]))})})}),this.dss.set(o,re(c.map(a=>ot(new Dt(V(a)))))),l.observe(a=>a.changes.added.forEach(u=>u.content.getContent().forEach(h))),l.forEach(h)};n.observe(i=>{i.keysChanged.forEach(o=>s(n.get(o),o))}),n.forEach(s)}setUserMapping(t,n,r,{filter:s=()=>!0}={}){let i=this.yusers,o=i.get(r);o||(o=new ce,o.set("ids",new oe),o.set("ds",new oe),i.set(r,o)),o.get("ids").push([n]),i.observe(c=>{setTimeout(()=>{let l=i.get(r);if(l!==o){o=l,this.clients.forEach((u,d)=>{r===u&&o.get("ids").push([d])});let h=new yt,a=this.dss.get(r);a&&(et(h,a),o.get("ds").push([h.toUint8Array()]))}},0)}),t.on("afterTransaction",c=>{setTimeout(()=>{let l=o.get("ds"),h=c.deleteSet;if(c.local&&h.clients.size>0&&s(c,h)){let a=new yt;et(a,h),l.push([a.toUint8Array()])}})})}getUserByClientId(t){return this.clients.get(t)||null}getUserByDeletedId(t){for(let[n,r]of this.dss.entries())if(de(r,t))return n;return null}},Me=class{constructor(t,n,r,s=0){this.type=t,this.tname=n,this.item=r,this.assoc=s}},Ya=e=>{let t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},Wa=e=>new Me(e.type==null?null:m(e.type.client,e.type.clock),e.tname??null,e.item==null?null:m(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),Cr=class{constructor(t,n,r=0){this.type=t,this.index=n,this.assoc=r}},Rc=(e,t,n=0)=>new Cr(e,t,n),Cn=(e,t,n)=>{let r=null,s=null;return e._item===null?s=Ei(e):r=m(e._item.id.client,e._item.id.clock),new Me(r,s,t,n)},Za=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Cn(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return Cn(e,m(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Cn(e,r.lastId,n);r=r.right}return Cn(e,null,n)},$c=(e,t)=>{let{type:n,tname:r,item:s,assoc:i}=t;if(s!==null)g(e,0),si(e,s);else if(r!==null)Ft(e,1),lt(e,r);else if(n!==null)Ft(e,2),si(e,n);else throw D();return xe(e,i),e},Qa=e=>{let t=ut();return $c(t,e),$(t)},Fc=e=>{let t=null,n=null,r=null;switch(w(e)){case 0:r=ii(e);break;case 1:n=dt(e);break;case 2:t=ii(e)}let s=Wn(e)?ke(e):0;return new Me(t,n,r,s)},th=e=>Fc(V(e)),jc=(e,t)=>{let n=te(e,t),r=t.clock-n.id.clock;return{item:n,diff:r}},eh=(e,t,n=!0)=>{let r=t.store,s=e.item,i=e.type,o=e.tname,c=e.assoc,l=null,h=0;if(s!==null){if(E(r,s.client)<=s.clock)return null;let a=n?Mr(r,s):jc(r,s),u=a.item;if(!(u instanceof b))return null;if(l=u.parent,l._item===null||!l._item.deleted){h=u.deleted||!u.countable?0:a.diff+(c>=0?0:1);let d=u.left;for(;d!==null;)!d.deleted&&d.countable&&(h+=d.length),d=d.left}}else{if(o!==null)l=t.get(o);else if(i!==null){if(E(r,i.client)<=i.clock)return null;let{item:a}=n?Mr(r,i):{item:te(r,i)};if(a instanceof b&&a.content instanceof Y)l=a.content.type;else return null}else throw D();c>=0?h=l._length:h=0}return Rc(l,h,e.assoc)},nh=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Qt(e.item,t.item)&&Qt(e.type,t.type)&&e.assoc===t.assoc,Vn=class{constructor(t,n){this.ds=t,this.sv=n}},rh=(e,t)=>{let n=e.ds.clients,r=t.ds.clients,s=e.sv,i=t.sv;if(s.size!==i.size||n.size!==r.size)return!1;for(let[o,c]of s.entries())if(i.get(o)!==c)return!1;for(let[o,c]of n.entries()){let l=r.get(o)||[];if(c.length!==l.length)return!1;for(let h=0;h<c.length;h++){let a=c[h],u=l[h];if(a.clock!==u.clock||a.len!==u.len)return!1}}return!0},qc=(e,t=new se)=>(et(t,e.ds),Gr(t,e.sv),t.toUint8Array()),sh=e=>qc(e,new yt),Gc=(e,t=new vn(V(e)))=>new Vn(ot(t),ki(t)),ih=e=>Gc(e,new Dt(V(e))),Ui=(e,t)=>new Vn(e,t),oh=Ui(Fr(),new Map),ch=e=>Ui(yi(e.store),He(e.store)),ft=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!de(t.ds,e.id),Ar=(e,t)=>{let n=L(e.meta,Ar,W),r=e.doc.store;n.has(t)||(t.sv.forEach((s,i)=>{s<E(r,i)&&M(e,m(i,s))}),ne(e,t.ds,s=>{}),n.add(t))},lh=(e,t,n=new Tt)=>{if(e.gc)throw new Error("Garbage-collection must be disabled in `originDoc`!");let{sv:r,ds:s}=t,i=new X;return e.transact(o=>{let c=0;r.forEach(l=>{l>0&&c++}),g(i.restEncoder,c);for(let[l,h]of r){if(h===0)continue;h<E(e.store,l)&&M(o,m(l,h));let a=e.store.clients.get(l)||[],u=K(a,h-1);g(i.restEncoder,u+1),i.writeClient(l),g(i.restEncoder,0);for(let d=0;d<=u;d++)a[d].write(i,0)}et(i,s)}),qr(n,i.toUint8Array(),"snapshot"),n},zc=(e,t,n=q)=>{let r=new n(V(t)),s=new nt(r,!1);for(let o=s.curr;o!==null;o=s.next())if((e.sv.get(o.id.client)||0)<o.id.clock+o.length)return!1;let i=re([e.ds,ot(r)]);return Tc(e.ds,i)},ah=(e,t)=>zc(e,t,H),Nn=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},He=e=>{let t=new Map;return e.clients.forEach((n,r)=>{let s=n[n.length-1];t.set(r,s.id.clock+s.length)}),t},E=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},Ci=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let r=n[n.length-1];if(r.id.clock+r.length!==t.id.clock)throw D()}n.push(t)},K=(e,t)=>{let n=0,r=e.length-1,s=e[r],i=s.id.clock;if(i===t)return r;let o=O(t/(i+s.length-1)*r);for(;n<=r;){if(s=e[o],i=s.id.clock,i<=t){if(t<i+s.length)return o;n=o+1}else r=o-1;o=O((n+r)/2)}throw D()},Hc=(e,t)=>{let n=e.clients.get(t.client);return n[K(n,t.clock)]},te=Hc,Ir=(e,t,n)=>{let r=K(t,n),s=t[r];return s.id.clock<n&&s instanceof b?(t.splice(r+1,0,Fn(e,s,n-s.id.clock)),r+1):r},M=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Ir(e,n,t.clock)]},ci=(e,t,n)=>{let r=t.clients.get(n.client),s=K(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==R&&r.splice(s+1,0,Fn(e,i,n.clock-i.id.clock+1)),i},Jc=(e,t,n)=>{let r=e.clients.get(t.id.client);r[K(r,t.id.clock)]=n},Ai=(e,t,n,r,s)=>{if(r===0)return;let i=n+r,o=Ir(e,t,n),c;do c=t[o++],i<c.id.clock+c.length&&Ir(e,t,i),s(c);while(o<t.length&&t[o].id.clock<i)},Tr=class{constructor(t,n,r){this.doc=t,this.deleteSet=new wt,this.beforeState=He(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},li=(e,t)=>t.deleteSet.clients.size===0&&!Zr(t.afterState,(n,r)=>t.beforeState.get(r)!==n)?!1:($r(t.deleteSet),Vc(e,t),et(e,t.deleteSet),!0),ai=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&L(e.changed,t,W).add(n)},Tn=(e,t)=>{let n=e[t],r=e[t-1],s=t;for(;s>0;n=r,r=e[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof b&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let i=t-s;return i&&e.splice(t+1-i,i),i},Ii=(e,t,n)=>{for(let[r,s]of e.clients.entries()){let i=t.clients.get(r);for(let o=s.length-1;o>=0;o--){let c=s[o],l=c.clock+c.len;for(let h=K(i,c.clock),a=i[h];h<i.length&&a.id.clock<l;a=i[++h]){let u=i[h];if(c.clock+c.len<=u.id.clock)break;u instanceof b&&u.deleted&&!u.keep&&n(u)&&u.gc(t,!1)}}}},Ti=(e,t)=>{e.clients.forEach((n,r)=>{let s=t.clients.get(r);for(let i=n.length-1;i>=0;i--){let o=n[i],c=Ye(s.length-1,1+K(s,o.clock+o.len-1));for(let l=c,h=s[l];l>0&&h.id.clock>=o.clock;h=s[l])l-=1+Tn(s,l)}})},hh=(e,t,n)=>{Ii(e,t,n),Ti(e,t)},Di=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{$r(i),n.afterState=He(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let c=[];n.changed.forEach((l,h)=>c.push(()=>{(h._item===null||!h._item.deleted)&&h._callObserver(n,l)})),c.push(()=>{n.changedParentTypes.forEach((l,h)=>{h._dEH.l.length>0&&(h._item===null||!h._item.deleted)&&(l=l.filter(a=>a.target._item===null||!a.target._item.deleted),l.forEach(a=>{a.currentTarget=h,a._path=null}),l.sort((a,u)=>a.path.length-u.path.length),c.push(()=>{_i(h._dEH,l,n)}))}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{n._needFormattingCleanup&&ul(n)})}),Ce(c,[])}finally{r.gc&&Ii(i,s,r.gcFilter),Ti(i,s),n.afterState.forEach((a,u)=>{let d=n.beforeState.get(u)||0;if(d!==a){let f=s.clients.get(u),p=it(K(f,d),1);for(let y=f.length-1;y>=p;)y-=1+Tn(f,y)}});for(let a=o.length-1;a>=0;a--){let{client:u,clock:d}=o[a].id,f=s.clients.get(u),p=K(f,d);p+1<f.length&&Tn(f,p+1)>1||p>0&&Tn(f,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(Ne(It,ve,"[yjs] ",Oe,Ve,"Changed the client-id because another client seems to be using it."),r.clientID=xi()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let a=new ct;li(a,n)&&r.emit("update",[a.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let a=new X;li(a,n)&&r.emit("updateV2",[a.toUint8Array(),n.origin,r,n])}let{subdocsAdded:c,subdocsLoaded:l,subdocsRemoved:h}=n;(c.size>0||h.size>0||l.size>0)&&(c.forEach(a=>{a.clientID=r.clientID,a.collectionid==null&&(a.collectionid=r.collectionid),r.subdocs.add(a)}),h.forEach(a=>r.subdocs.delete(a)),r.emit("subdocs",[{loaded:l,added:c,removed:h},r,n]),h.forEach(a=>a.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e])):Di(e,t+1)}}},x=(e,t,n=null,r=!0)=>{let s=e._transactionCleanups,i=!1,o=null;e._transaction===null&&(i=!0,e._transaction=new Tr(e,n,r),s.push(e._transaction),s.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{o=t(e._transaction)}finally{if(i){let c=e._transaction===s[0];e._transaction=null,c&&Di(s,0)}}return o},Dr=class{constructor(t,n){this.insertions=n,this.deletions=t,this.meta=new Map}},hi=(e,t,n)=>{ne(e,n.deletions,r=>{r instanceof b&&t.scope.some(s=>s===e.doc||On(s,r))&&Pr(r,!1)})},ui=(e,t,n)=>{let r=null,s=e.doc,i=e.scope;x(s,c=>{for(;t.length>0&&e.currStackItem===null;){let l=s.store,h=t.pop(),a=new Set,u=[],d=!1;ne(c,h.insertions,f=>{if(f instanceof b){if(f.redone!==null){let{item:p,diff:y}=Mr(l,f.id);y>0&&(p=M(c,m(p.id.client,p.id.clock+y))),f=p}!f.deleted&&i.some(p=>p===c.doc||On(p,f))&&u.push(f)}}),ne(c,h.deletions,f=>{f instanceof b&&i.some(p=>p===c.doc||On(p,f))&&!de(h.insertions,f.id)&&a.add(f)}),a.forEach(f=>{d=Yi(c,f,a,h.insertions,e.ignoreRemoteMapChanges,e)!==null||d});for(let f=u.length-1;f>=0;f--){let p=u[f];e.deleteFilter(p)&&(p.delete(c),d=!0)}e.currStackItem=d?h:null}c.changed.forEach((l,h)=>{l.has(null)&&h._searchMarker&&(h._searchMarker.length=0)}),r=c},e);let o=e.currStackItem;if(o!=null){let c=r.changedParentTypes;e.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:c,origin:e},e]),e.currStackItem=null}return o},di=class extends Ot{constructor(t,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:c=st(t)?t[0].doc:t instanceof Tt?t:t.doc}={}){super(),this.scope=[],this.doc=c,this.addToScope(t),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(k=>l.changedParentTypes.has(k)||k===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;let h=this.undoing,a=this.redoing,u=h?this.redoStack:this.undoStack;h?this.stopCapturing():a||this.clear(!1,!0);let d=new wt;l.afterState.forEach((k,S)=>{let Kr=l.beforeState.get(S)||0,Yr=k-Kr;Yr>0&&Be(d,S,Kr,Yr)});let f=Se(),p=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&u.length>0&&!h&&!a){let k=u[u.length-1];k.deletions=re([k.deletions,l.deleteSet]),k.insertions=re([k.insertions,d])}else u.push(new Dr(l.deleteSet,d)),p=!0;!h&&!a&&(this.lastChange=f),ne(l,l.deleteSet,k=>{k instanceof b&&this.scope.some(S=>S===l.doc||On(S,k))&&Pr(k,!0)});let y=[{stackItem:u[u.length-1],origin:l.origin,type:h?"redo":"undo",changedParentTypes:l.changedParentTypes},this];p?this.emit("stack-item-added",y):this.emit("stack-item-updated",y)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(t){let n=new Set(this.scope);t=st(t)?t:[t],t.forEach(r=>{n.has(r)||(n.add(r),(r instanceof C?r.doc!==this.doc:r!==this.doc)&&_r("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,n=!0){(t&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{t&&(this.undoStack.forEach(s=>hi(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>hi(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=ui(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=ui(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}};function*Xc(e){let t=w(e.restDecoder);for(let n=0;n<t;n++){let r=w(e.restDecoder),s=e.readClient(),i=w(e.restDecoder);for(let o=0;o<r;o++){let c=e.readInfo();if(c===10){let l=w(e.restDecoder);yield new B(m(s,i),l),i+=l}else if((31&c)!==0){let l=(c&192)===0,h=new b(m(s,i),null,(c&128)===128?e.readLeftID():null,null,(c&64)===64?e.readRightID():null,l?e.readParentInfo()?e.readString():e.readLeftID():null,l&&(c&32)===32?e.readString():null,Wi(e,c));yield h,i+=h.length}else{let l=e.readLen();yield new R(m(s,i),l),i+=l}}}}var nt=class{constructor(t,n){this.gen=Xc(t),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===B);return this.curr}},uh=e=>Pc(e,H),Pc=(e,t=q)=>{let n=[],r=new t(V(e)),s=new nt(r,!1);for(let o=s.curr;o!==null;o=s.next())n.push(o);Ne("Structs: ",n);let i=ot(r);Ne("DeleteSet: ",i)},dh=e=>Kc(e,H),Kc=(e,t=q)=>{let n=[],r=new t(V(e)),s=new nt(r,!1);for(let i=s.curr;i!==null;i=s.next())n.push(i);return{structs:n,ds:ot(r)}},Re=class{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}},Yc=e=>Ln(e,H,ct),Wc=(e,t=se,n=q)=>{let r=new t,s=new nt(new n(V(e)),!1),i=s.curr;if(i!==null){let o=0,c=i.id.client,l=i.id.clock!==0,h=l?0:i.id.clock+i.length;for(;i!==null;i=s.next())c!==i.id.client&&(h!==0&&(o++,g(r.restEncoder,c),g(r.restEncoder,h)),c=i.id.client,h=0,l=i.id.clock!==0),i.constructor===B&&(l=!0),l||(h=i.id.clock+i.length);h!==0&&(o++,g(r.restEncoder,c),g(r.restEncoder,h));let a=ut();return g(a,o),as(a,r.restEncoder),r.restEncoder=a,r.toUint8Array()}else return g(r.restEncoder,0),r.toUint8Array()},fh=e=>Wc(e,yt,H),Zc=(e,t=q)=>{let n=new Map,r=new Map,s=new nt(new t(V(e)),!1),i=s.curr;if(i!==null){let o=i.id.client,c=i.id.clock;for(n.set(o,c);i!==null;i=s.next())o!==i.id.client&&(r.set(o,c),n.set(i.id.client,i.id.clock),o=i.id.client),c=i.id.clock+i.length;r.set(o,c)}return{from:n,to:r}},ph=e=>Zc(e,H),Qc=(e,t)=>{if(e.constructor===R){let{client:n,clock:r}=e.id;return new R(m(n,r+t),e.length-t)}else if(e.constructor===B){let{client:n,clock:r}=e.id;return new B(m(n,r+t),e.length-t)}else{let n=e,{client:r,clock:s}=n.id;return new b(m(r,s+t),null,m(r,s+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Ln=(e,t=q,n=X)=>{if(e.length===1)return e[0];let r=e.map(a=>new t(V(a))),s=r.map(a=>new nt(a,!0)),i=null,o=new n,c=new Re(o);for(;s=s.filter(d=>d.curr!==null),s.sort((d,f)=>{if(d.curr.id.client===f.curr.id.client){let p=d.curr.id.clock-f.curr.id.clock;return p===0?d.curr.constructor===f.curr.constructor?0:d.curr.constructor===B?1:-1:p}else return f.curr.id.client-d.curr.id.client}),s.length!==0;){let a=s[0],u=a.curr.id.client;if(i!==null){let d=a.curr,f=!1;for(;d!==null&&d.id.clock+d.length<=i.struct.id.clock+i.struct.length&&d.id.client>=i.struct.id.client;)d=a.next(),f=!0;if(d===null||d.id.client!==u||f&&d.id.clock>i.struct.id.clock+i.struct.length)continue;if(u!==i.struct.id.client)pt(c,i.struct,i.offset),i={struct:d,offset:0},a.next();else if(i.struct.id.clock+i.struct.length<d.id.clock)if(i.struct.constructor===B)i.struct.length=d.id.clock+d.length-i.struct.id.clock;else{pt(c,i.struct,i.offset);let p=d.id.clock-i.struct.id.clock-i.struct.length;i={struct:new B(m(u,i.struct.id.clock+i.struct.length),p),offset:0}}else{let p=i.struct.id.clock+i.struct.length-d.id.clock;p>0&&(i.struct.constructor===B?i.struct.length-=p:d=Qc(d,p)),i.struct.mergeWith(d)||(pt(c,i.struct,i.offset),i={struct:d,offset:0},a.next())}}else i={struct:a.curr,offset:0},a.next();for(let d=a.curr;d!==null&&d.id.client===u&&d.id.clock===i.struct.id.clock+i.struct.length&&d.constructor!==B;d=a.next())pt(c,i.struct,i.offset),i={struct:d,offset:0}}i!==null&&(pt(c,i.struct,i.offset),i=null),zr(c);let l=r.map(a=>ot(a)),h=re(l);return et(o,h),o.toUint8Array()},vi=(e,t,n=q,r=X)=>{let s=Si(t),i=new r,o=new Re(i),c=new n(V(e)),l=new nt(c,!1);for(;l.curr;){let a=l.curr,u=a.id.client,d=s.get(u)||0;if(l.curr.constructor===B){l.next();continue}if(a.id.clock+a.length>d)for(pt(o,a,it(d-a.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)pt(o,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===u&&l.curr.id.clock+l.curr.length<=d;)l.next()}zr(o);let h=ot(c);return et(i,h),i.toUint8Array()},gh=(e,t)=>vi(e,t,H,ct),Oi=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:$(e.encoder.restEncoder)}),e.encoder.restEncoder=ut(),e.written=0)},pt=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Oi(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),g(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},zr=e=>{Oi(e);let t=e.encoder.restEncoder;g(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];g(t,r.written),jt(t,r.restEncoder)}},jn=(e,t,n,r)=>{let s=new n(V(e)),i=new nt(s,!1),o=new r,c=new Re(o);for(let h=i.curr;h!==null;h=i.next())pt(c,t(h),0);zr(c);let l=ot(s);return et(o,l),o.toUint8Array()},Vi=({formatting:e=!0,subdocs:t=!0,yxml:n=!0}={})=>{let r=0,s=_(),i=_(),o=_(),c=_();return c.set(null,null),l=>{switch(l.constructor){case R:case B:return l;case b:{let h=l,a=h.content;switch(a.constructor){case ze:break;case Y:{if(n){let u=a.type;u instanceof ae&&(u.nodeName=L(i,u.nodeName,()=>"node-"+r)),u instanceof Rn&&(u.hookName=L(i,u.hookName,()=>"hook-"+r))}break}case vt:{let u=a;u.arr=u.arr.map(()=>r);break}case he:{let u=a;u.content=new Uint8Array([r]);break}case ue:{let u=a;t&&(u.opts={},u.doc.guid=r+"");break}case xt:{let u=a;u.embed={};break}case A:{let u=a;e&&(u.key=L(o,u.key,()=>r+""),u.value=L(c,u.value,()=>({i:r})));break}case $n:{let u=a;u.arr=u.arr.map(()=>r);break}case rt:{let u=a;u.str=Ze(r%10+"",u.str.length);break}default:D()}return h.parentSub&&(h.parentSub=L(s,h.parentSub,()=>r+"")),r++,l}default:D()}}},mh=(e,t)=>jn(e,Vi(t),H,ct),wh=(e,t)=>jn(e,Vi(t),q,X),yh=e=>jn(e,lr,H,X),tl=e=>jn(e,lr,q,ct),fi="You must not compute changes after the event-handler fired.",ie=class{constructor(t,n){this.target=t,this.currentTarget=t,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=el(this.currentTarget,this.target))}deletes(t){return de(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw G(fi);let t=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){let i=n._map.get(s),o,c;if(this.adds(i)){let l=i.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",c=Pe(l.content.getContent());else return;else l!==null&&this.deletes(l)?(o="update",c=Pe(l.content.getContent())):(o="add",c=void 0)}else if(this.deletes(i))o="delete",c=Pe(i.content.getContent());else return;t.set(s,{action:o,oldValue:c})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw G(fi);let n=this.target,r=W(),s=W(),i=[];if(t={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let c=null,l=()=>{c&&i.push(c)};for(let h=n._start;h!==null;h=h.right)h.deleted?this.deletes(h)&&!this.adds(h)&&((c===null||c.delete===void 0)&&(l(),c={delete:0}),c.delete+=h.length,s.add(h)):this.adds(h)?((c===null||c.insert===void 0)&&(l(),c={insert:[]}),c.insert=c.insert.concat(h.content.getContent()),r.add(h)):((c===null||c.retain===void 0)&&(l(),c={retain:0}),c.retain+=h.length);c!==null&&c.retain===void 0&&l()}this._changes=t}return t}},el=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let r=0,s=t._item.parent._start;for(;s!==t._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}t=t._item.parent}return n},N=()=>{_r("Invalid access: Add Yjs type to a document before reading data.")},Ni=80,Hr=0,vr=class{constructor(t,n){t.marker=!0,this.p=t,this.index=n,this.timestamp=Hr++}},nl=e=>{e.timestamp=Hr++},Li=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Hr++},rl=(e,t,n)=>{if(e.length>=Ni){let r=e.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return Li(r,t,n),r}else{let r=new vr(t,n);return e.push(r),r}},qn=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((i,o)=>bt(t-i.index)<bt(t-o.index)?i:o),r=e._start,s=0;for(n!==null&&(r=n.p,s=n.index,nl(n));r.right!==null&&s<t;){if(!r.deleted&&r.countable){if(t<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>t;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return n!==null&&bt(n.index-s)<r.parent.length/Ni?(Li(n,r,s),n):rl(e._searchMarker,r,s)},$e=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let s=e[r];if(n>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){e.splice(r,1);continue}s.p=i,i.marker=!0}(t<s.index||n>0&&t===s.index)&&(s.index=it(t,s.index+n))}},xh=e=>{e.doc??N();let t=e._start,n=[];for(;t;)n.push(t),t=t.right;return n},Gn=(e,t,n)=>{let r=e,s=t.changedParentTypes;for(;L(s,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;_i(r._eH,n,t)},C=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=ei(),this._dEH=ei(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,n){this.doc=t,this._item=n}_copy(){throw z()}clone(){throw z()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,n){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){ni(this._eH,t)}observeDeep(t){ni(this._dEH,t)}unobserve(t){ri(this._eH,t)}unobserveDeep(t){ri(this._dEH,t)}toJSON(){}},Bi=(e,t,n)=>{e.doc??N(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,s=[],i=e._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){let o=i.content.getContent();if(o.length<=t)t-=o.length;else{for(let c=t;c<o.length&&r>0;c++)s.push(o[c]),r--;t=0}}i=i.right}return s},Mi=e=>{e.doc??N();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let r=n.content.getContent();for(let s=0;s<r.length;s++)t.push(r[s])}n=n.right}return t},bh=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&ft(r,t)){let s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},Fe=(e,t)=>{let n=0,r=e._start;for(e.doc??N();r!==null;){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let i=0;i<s.length;i++)t(s[i],n++,e)}r=r.right}},Ri=(e,t)=>{let n=[];return Fe(e,(r,s)=>{n.push(t(r,s,e))}),n},sl=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},$i=(e,t)=>{e.doc??N();let n=qn(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},Bn=(e,t,n,r)=>{let s=n,i=e.doc,o=i.clientID,c=i.store,l=n===null?t._start:n.right,h=[],a=()=>{h.length>0&&(s=new b(m(o,E(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new vt(h)),s.integrate(e,0),h=[])};r.forEach(u=>{if(u===null)h.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:h.push(u);break;default:switch(a(),u.constructor){case Uint8Array:case ArrayBuffer:s=new b(m(o,E(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new he(new Uint8Array(u))),s.integrate(e,0);break;case Tt:s=new b(m(o,E(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new ue(u)),s.integrate(e,0);break;default:if(u instanceof C)s=new b(m(o,E(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new Y(u)),s.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),a()},Fi=()=>G("Length exceeded!"),ji=(e,t,n,r)=>{if(n>t._length)throw Fi();if(n===0)return t._searchMarker&&$e(t._searchMarker,n,r.length),Bn(e,t,null,r);let s=n,i=qn(t,n),o=t._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&M(e,m(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&$e(t._searchMarker,s,r.length),Bn(e,t,o,r)},il=(e,t,n)=>{let s=(t._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:t._start}).p;if(s)for(;s.right;)s=s.right;return Bn(e,t,s,n)},qi=(e,t,n,r)=>{if(r===0)return;let s=n,i=r,o=qn(t,n),c=t._start;for(o!==null&&(c=o.p,n-=o.index);c!==null&&n>0;c=c.right)!c.deleted&&c.countable&&(n<c.length&&M(e,m(c.id.client,c.id.clock+n)),n-=c.length);for(;r>0&&c!==null;)c.deleted||(r<c.length&&M(e,m(c.id.client,c.id.clock+r)),c.delete(e),r-=c.length),c=c.right;if(r>0)throw Fi();t._searchMarker&&$e(t._searchMarker,s,-i+r)},Mn=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Jr=(e,t,n,r)=>{let s=t._map.get(n)||null,i=e.doc,o=i.clientID,c;if(r==null)c=new vt([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new vt([r]);break;case Uint8Array:c=new he(r);break;case Tt:c=new ue(r);break;default:if(r instanceof C)c=new Y(r);else throw new Error("Unexpected content type")}new b(m(o,E(i.store,o)),s,s&&s.lastId,null,null,t,n,c).integrate(e,0)},Xr=(e,t)=>{e.doc??N();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Gi=e=>{let t={};return e.doc??N(),e._map.forEach((n,r)=>{n.deleted||(t[r]=n.content.getContent()[n.length-1])}),t},zi=(e,t)=>{e.doc??N();let n=e._map.get(t);return n!==void 0&&!n.deleted},kh=(e,t,n)=>{let r=e._map.get(t)||null;for(;r!==null&&(!n.sv.has(r.id.client)||r.id.clock>=(n.sv.get(r.id.client)||0));)r=r.left;return r!==null&&ft(r,n)?r.content.getContent()[r.length-1]:void 0},ol=(e,t)=>{let n={};return e._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&ft(i,t)&&(n[s]=i.content.getContent()[i.length-1])}),n},An=e=>(e.doc??N(),Ys(e._map.entries(),t=>!t[1].deleted)),Or=class extends ie{},oe=class e extends C{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(n=>n instanceof C?n.clone():n)),t}get length(){return this.doc??N(),this._length}_callObserver(t,n){super._callObserver(t,n),Gn(this,t,new Or(this,t))}insert(t,n){this.doc!==null?x(this.doc,r=>{ji(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?x(this.doc,n=>{il(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?x(this.doc,r=>{qi(r,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return $i(this,t)}toArray(){return Mi(this)}slice(t=0,n=this.length){return Bi(this,t,n)}toJSON(){return this.map(t=>t instanceof C?t.toJSON():t)}map(t){return Ri(this,t)}forEach(t){Fe(this,t)}[Symbol.iterator](){return sl(this)}_write(t){t.writeTypeRef(Il)}},cl=e=>new oe,Vr=class extends ie{constructor(t,n,r){super(t,n),this.keysChanged=r}},ce=class e extends C{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,n){super._integrate(t,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((n,r)=>{t.set(r,n instanceof C?n.clone():n)}),t}_callObserver(t,n){Gn(this,t,new Vr(this,t,n))}toJSON(){this.doc??N();let t={};return this._map.forEach((n,r)=>{if(!n.deleted){let s=n.content.getContent()[n.length-1];t[r]=s instanceof C?s.toJSON():s}}),t}get size(){return[...An(this)].length}keys(){return Un(An(this),t=>t[0])}values(){return Un(An(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return Un(An(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??N(),this._map.forEach((n,r)=>{n.deleted||t(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?x(this.doc,n=>{Mn(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?x(this.doc,r=>{Jr(r,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return Xr(this,t)}has(t){return zi(this,t)}clear(){this.doc!==null?x(this.doc,t=>{this.forEach(function(n,r,s){Mn(t,s,r)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(Tl)}},ll=e=>new ce,gt=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&ir(e,t),je=class{constructor(t,n,r,s){this.left=t,this.right=n,this.index=r,this.currentAttributes=s}forward(){this.right===null&&D(),this.right.content.constructor===A?this.right.deleted||fe(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},pi=(e,t,n)=>{for(;t.right!==null&&n>0;)t.right.content.constructor===A?t.right.deleted||fe(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&M(e,m(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length),t.left=t.right,t.right=t.right.right;return t},In=(e,t,n,r)=>{let s=new Map,i=r?qn(t,n):null;if(i){let o=new je(i.p.left,i.p,i.index,s);return pi(e,o,n-i.index)}else{let o=new je(null,t._start,0,s);return pi(e,o,n)}},Hi=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===A&>(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let s=e.doc,i=s.clientID;r.forEach((o,c)=>{let l=n.left,h=n.right,a=new b(m(i,E(s.store,i)),l,l&&l.lastId,h,h&&h.id,t,null,new A(c,o));a.integrate(e,0),n.right=a,n.forward()})},fe=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Ji=(e,t)=>{for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===A&>(t[e.right.content.key]??null,e.right.content.value)))break;e.forward()}},Xi=(e,t,n,r)=>{let s=e.doc,i=s.clientID,o=new Map;for(let c in r){let l=r[c],h=n.currentAttributes.get(c)??null;if(!gt(h,l)){o.set(c,h);let{left:a,right:u}=n;n.right=new b(m(i,E(s.store,i)),a,a&&a.lastId,u,u&&u.id,t,null,new A(c,l)),n.right.integrate(e,0),n.forward()}}return o},Er=(e,t,n,r,s)=>{n.currentAttributes.forEach((d,f)=>{s[f]===void 0&&(s[f]=null)});let i=e.doc,o=i.clientID;Ji(n,s);let c=Xi(e,t,n,s),l=r.constructor===String?new rt(r):r instanceof C?new Y(r):new xt(r),{left:h,right:a,index:u}=n;t._searchMarker&&$e(t._searchMarker,n.index,l.getLength()),a=new b(m(o,E(i.store,o)),h,h&&h.lastId,a,a&&a.id,t,null,l),a.integrate(e,0),n.right=a,n.index=u,n.forward(),Hi(e,t,n,c)},gi=(e,t,n,r,s)=>{let i=e.doc,o=i.clientID;Ji(n,s);let c=Xi(e,t,n,s);t:for(;n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===A));){if(!n.right.deleted)switch(n.right.content.constructor){case A:{let{key:l,value:h}=n.right.content,a=s[l];if(a!==void 0){if(gt(a,h))c.delete(l);else{if(r===0)break t;c.set(l,h)}n.right.delete(e)}else n.currentAttributes.set(l,h);break}default:r<n.right.length&&M(e,m(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
|
4
|
+
`;n.right=new b(m(o,E(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new rt(l)),n.right.integrate(e,0),n.forward()}Hi(e,t,n,c)},Pi=(e,t,n,r,s)=>{let i=t,o=_();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===A){let h=i.content;o.set(h.key,h)}i=i.right}let c=0,l=!1;for(;t!==i;){if(n===t&&(l=!0),!t.deleted){let h=t.content;if(h.constructor===A){let{key:a,value:u}=h,d=r.get(a)??null;(o.get(a)!==h||d===u)&&(t.delete(e),c++,!l&&(s.get(a)??null)===u&&d!==u&&(d===null?s.delete(a):s.set(a,d))),!l&&!t.deleted&&fe(s,h)}}t=t.right}return c},al=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===A){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},hl=e=>{let t=0;return x(e.doc,n=>{let r=e._start,s=e._start,i=_(),o=Xe(i);for(;s;)s.deleted===!1&&(s.content.constructor===A?fe(o,s.content):(t+=Pi(n,r,s,i,o),i=Xe(o),r=s)),s=s.right}),t},ul=e=>{let t=new Set,n=e.doc;for(let[r,s]of e.afterState.entries()){let i=e.beforeState.get(r)||0;s!==i&&Ai(e,n.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===A&&o.constructor!==R&&t.add(o.parent)})}x(n,r=>{ne(e,e.deleteSet,s=>{if(s instanceof R||!s.parent._hasFormatting||t.has(s.parent))return;let i=s.parent;s.content.constructor===A?t.add(i):al(r,s)});for(let s of t)hl(s)})},mi=(e,t,n)=>{let r=n,s=Xe(t.currentAttributes),i=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Y:case xt:case rt:n<t.right.length&&M(e,m(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}i&&Pi(e,i,t.right,s,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&$e(o._searchMarker,t.index,-r+n),t},Nr=class extends ie{constructor(t,n,r){super(t,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){let t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){let t=this.target.doc,n=[];x(t,r=>{let s=new Map,i=new Map,o=this.target._start,c=null,l={},h="",a=0,u=0,d=()=>{if(c!==null){let f=null;switch(c){case"delete":u>0&&(f={delete:u}),u=0;break;case"insert":(typeof h=="object"||h.length>0)&&(f={insert:h},s.size>0&&(f.attributes={},s.forEach((p,y)=>{p!==null&&(f.attributes[y]=p)}))),h="";break;case"retain":a>0&&(f={retain:a},ks(l)||(f.attributes=xs({},l))),a=0;break}f&&n.push(f),c=null}};for(;o!==null;){switch(o.content.constructor){case Y:case xt:this.adds(o)?this.deletes(o)||(d(),c="insert",h=o.content.getContent()[0],d()):this.deletes(o)?(c!=="delete"&&(d(),c="delete"),u+=1):o.deleted||(c!=="retain"&&(d(),c="retain"),a+=1);break;case rt:this.adds(o)?this.deletes(o)||(c!=="insert"&&(d(),c="insert"),h+=o.content.str):this.deletes(o)?(c!=="delete"&&(d(),c="delete"),u+=o.length):o.deleted||(c!=="retain"&&(d(),c="retain"),a+=o.length);break;case A:{let{key:f,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){let y=s.get(f)??null;gt(y,p)?p!==null&&o.delete(r):(c==="retain"&&d(),gt(p,i.get(f)??null)?delete l[f]:l[f]=p)}}else if(this.deletes(o)){i.set(f,p);let y=s.get(f)??null;gt(y,p)||(c==="retain"&&d(),l[f]=y)}else if(!o.deleted){i.set(f,p);let y=l[f];y!==void 0&&(gt(y,p)?y!==null&&o.delete(r):(c==="retain"&&d(),p===null?delete l[f]:l[f]=p))}o.deleted||(c==="insert"&&d(),fe(s,o.content));break}}o=o.right}for(d();n.length>0;){let f=n[n.length-1];if(f.retain!==void 0&&f.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}},qe=class e extends C{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??N(),this._length}_integrate(t,n){super._integrate(t,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(t,n){super._callObserver(t,n);let r=new Nr(this,t,n);Gn(this,t,r),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??N();let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===rt&&(t+=n.content.str),n=n.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:n=!0}={}){this.doc!==null?x(this.doc,r=>{let s=new je(null,this._start,0,new Map);for(let i=0;i<t.length;i++){let o=t[i];if(o.insert!==void 0){let c=!n&&typeof o.insert=="string"&&i===t.length-1&&s.right===null&&o.insert.slice(-1)===`
|
|
5
|
+
`?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&Er(r,this,s,c,o.attributes||{})}else o.retain!==void 0?gi(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&mi(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){this.doc??N();let s=[],i=new Map,o=this.doc,c="",l=this._start;function h(){if(c.length>0){let u={},d=!1;i.forEach((p,y)=>{d=!0,u[y]=p});let f={insert:c};d&&(f.attributes=u),s.push(f),c=""}}let a=()=>{for(;l!==null;){if(ft(l,t)||n!==void 0&&ft(l,n))switch(l.content.constructor){case rt:{let u=i.get("ychange");t!==void 0&&!ft(l,t)?(u===void 0||u.user!==l.id.client||u.type!=="removed")&&(h(),i.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!ft(l,n)?(u===void 0||u.user!==l.id.client||u.type!=="added")&&(h(),i.set("ychange",r?r("added",l.id):{type:"added"})):u!==void 0&&(h(),i.delete("ychange")),c+=l.content.str;break}case Y:case xt:{h();let u={insert:l.content.getContent()[0]};if(i.size>0){let d={};u.attributes=d,i.forEach((f,p)=>{d[p]=f})}s.push(u);break}case A:ft(l,t)&&(h(),fe(i,l.content));break}l=l.right}h()};return t||n?x(o,u=>{t&&Ar(u,t),n&&Ar(u,n),a()},"cleanup"):a(),s}insert(t,n,r){if(n.length<=0)return;let s=this.doc;s!==null?x(s,i=>{let o=In(i,this,t,!r);r||(r={},o.currentAttributes.forEach((c,l)=>{r[l]=c})),Er(i,this,o,n,r)}):this._pending.push(()=>this.insert(t,n,r))}insertEmbed(t,n,r){let s=this.doc;s!==null?x(s,i=>{let o=In(i,this,t,!r);Er(i,this,o,n,r||{})}):this._pending.push(()=>this.insertEmbed(t,n,r||{}))}delete(t,n){if(n===0)return;let r=this.doc;r!==null?x(r,s=>{mi(s,In(s,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,r){if(n===0)return;let s=this.doc;s!==null?x(s,i=>{let o=In(i,this,t,!1);o.right!==null&&gi(i,this,o,n,r)}):this._pending.push(()=>this.format(t,n,r))}removeAttribute(t){this.doc!==null?x(this.doc,n=>{Mn(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?x(this.doc,r=>{Jr(r,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return Xr(this,t)}getAttributes(){return Gi(this)}_write(t){t.writeTypeRef(Dl)}},dl=e=>new qe,Le=class{constructor(t,n=()=>!0){this._filter=n,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??N()}[Symbol.iterator](){return this}next(){let t=this._currentNode,n=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(n)))do if(n=t.content.type,!t.deleted&&(n.constructor===ae||n.constructor===le)&&n._start!==null)t=n._start;else for(;t!==null;){let r=t.next;if(r!==null){t=r;break}else t.parent===this._root?t=null:t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}},le=class e extends C{constructor(){super(),this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(n=>n instanceof C?n.clone():n)),t}get length(){return this.doc??N(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new Le(this,t)}querySelector(t){t=t.toUpperCase();let r=new Le(this,s=>s.nodeName&&s.nodeName.toUpperCase()===t).next();return r.done?null:r.value}querySelectorAll(t){return t=t.toUpperCase(),P(new Le(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){Gn(this,t,new Lr(this,n,t))}toString(){return Ri(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},r){let s=t.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),Fe(this,i=>{s.insertBefore(i.toDOM(t,n,r),null)}),s}insert(t,n){this.doc!==null?x(this.doc,r=>{ji(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)x(this.doc,r=>{let s=t&&t instanceof C?t._item:t;Bn(r,this,s,n)});else{let r=this._prelimContent,s=t===null?0:r.findIndex(i=>i===t)+1;if(s===0&&t!==null)throw G("Reference item not found");r.splice(s,0,...n)}}delete(t,n=1){this.doc!==null?x(this.doc,r=>{qi(r,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return Mi(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return $i(this,t)}slice(t=0,n=this.length){return Bi(this,t,n)}forEach(t){Fe(this,t)}_write(t){t.writeTypeRef(Ol)}},fl=e=>new le,ae=class e extends le{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,n){super._integrate(t,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName),n=this.getAttributes();return bs(n,(r,s)=>{t.setAttribute(s,r)}),t.insert(0,this.toArray().map(r=>r instanceof C?r.clone():r)),t}toString(){let t=this.getAttributes(),n=[],r=[];for(let c in t)r.push(c);r.sort();let s=r.length;for(let c=0;c<s;c++){let l=r[c];n.push(l+'="'+t[l]+'"')}let i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){this.doc!==null?x(this.doc,n=>{Mn(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?x(this.doc,r=>{Jr(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return Xr(this,t)}hasAttribute(t){return zi(this,t)}getAttributes(t){return t?ol(this,t):Gi(this)}toDOM(t=document,n={},r){let s=t.createElement(this.nodeName),i=this.getAttributes();for(let o in i){let c=i[o];typeof c=="string"&&s.setAttribute(o,c)}return Fe(this,o=>{s.appendChild(o.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(t){t.writeTypeRef(vl),t.writeKey(this.nodeName)}},pl=e=>new ae(e.readKey()),Lr=class extends ie{constructor(t,n,r){super(t,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}},Rn=class e extends ce{constructor(t){super(),this.hookName=t}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((n,r)=>{t.set(r,n)}),t}toDOM(t=document,n={},r){let s=n[this.hookName],i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(t){t.writeTypeRef(Vl),t.writeKey(this.hookName)}},gl=e=>new Rn(e.readKey()),Br=class e extends qe{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,r){let s=t.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(t=>{let n=[];for(let s in t.attributes){let i=[];for(let o in t.attributes[s])i.push({key:o,value:t.attributes[s][o]});i.sort((o,c)=>o.key<c.key?-1:1),n.push({nodeName:s,attrs:i})}n.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){let i=n[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){let c=i.attrs[o];r+=` ${c.key}="${c.value}"`}r+=">"}r+=t.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Nl)}},ml=e=>new Br,Ge=class{constructor(t,n){this.id=t,this.length=n}get deleted(){throw z()}mergeWith(t){return!1}write(t,n,r){throw z()}integrate(t,n){throw z()}},wl=0,R=class extends Ge{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){n>0&&(this.id.clock+=n,this.length-=n),Ci(t.doc.store,this)}write(t,n){t.writeInfo(wl),t.writeLen(this.length-n)}getMissing(t,n){return null}},he=class e{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(t){throw z()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}},yl=e=>new he(e.readBuf()),ze=class e{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){Be(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}},xl=e=>new ze(e.readLen()),Ki=(e,t)=>new Tt({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),ue=class e{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;let n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(Ki(this.doc.guid,this.opts))}splice(t){throw z()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}},bl=e=>new ue(Ki(e.readString(),e.readAny())),xt=class e{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(t){throw z()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}},kl=e=>new xt(e.readJSON()),A=class e{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(t){throw z()}mergeWith(t){return!1}integrate(t,n){let r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}},Sl=e=>new A(e.readKey(),e.readJSON()),$n=class e{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){let r=this.arr.length;t.writeLen(r-n);for(let s=n;s<r;s++){let i=this.arr[s];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}},_l=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let s=e.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new $n(n)},El=Ct("node_env")==="development",vt=class e{constructor(t){this.arr=t,El&&or(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){let r=this.arr.length;t.writeLen(r-n);for(let s=n;s<r;s++){let i=this.arr[s];t.writeAny(i)}}getRef(){return 8}},Ul=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new vt(n)},rt=class e{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+"\uFFFD",n.str="\uFFFD"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}},Cl=e=>new rt(e.readString()),Al=[cl,ll,dl,pl,fl,gl,ml],Il=0,Tl=1,Dl=2,vl=3,Ol=4,Vl=5,Nl=6,Y=class e{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(t){throw z()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(t.beforeState.get(r.id.client)||0)&&t._mergeStructs.push(r):r.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}},Ll=e=>new Y(Al[e.readTypeRef()](e)),Mr=(e,t)=>{let n=t,r=0,s;do r>0&&(n=m(n.client,n.clock+r)),s=te(e,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof b);return{item:s,diff:r}},Pr=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Fn=(e,t,n)=>{let{client:r,clock:s}=t.id,i=new b(m(r,s+n),t,m(r,s+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&i.markDeleted(),t.keep&&(i.keep=!0),t.redone!==null&&(i.redone=m(t.redone.client,t.redone.clock+n)),t.right=i,i.right!==null&&(i.right.left=i),e._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),t.length=n,i},wi=(e,t)=>ge(e,n=>de(n.deletions,t)),Yi=(e,t,n,r,s,i)=>{let o=e.doc,c=o.store,l=o.clientID,h=t.redone;if(h!==null)return M(e,h);let a=t.parent._item,u=null,d;if(a!==null&&a.deleted===!0){if(a.redone===null&&(!n.has(a)||Yi(e,a,n,r,s,i)===null))return null;for(;a.redone!==null;)a=M(e,a.redone)}let f=a===null?t.parent:a.content.type;if(t.parentSub===null){for(u=t.left,d=t;u!==null;){let S=u;for(;S!==null&&S.parent._item!==a;)S=S.redone===null?null:M(e,S.redone);if(S!==null&&S.parent._item===a){u=S;break}u=u.left}for(;d!==null;){let S=d;for(;S!==null&&S.parent._item!==a;)S=S.redone===null?null:M(e,S.redone);if(S!==null&&S.parent._item===a){d=S;break}d=d.right}}else{if(d=null,t.right&&!s){for(u=t;u!==null&&u.right!==null&&(u.right.redone||de(r,u.right.id)||wi(i.undoStack,u.right.id)||wi(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=M(e,u.redone);if(u&&u.right!==null)return null}else u=f._map.get(t.parentSub)||null;u!==null&&u.parent._item!==a&&(u=f._map.get(t.parentSub)||null)}let p=E(c,l),y=m(l,p),k=new b(y,u,u&&u.lastId,d,d&&d.id,f,t.parentSub,t.content.copy());return t.redone=y,Pr(k,!0),k.integrate(e,0),k},b=class e extends Ge{constructor(t,n,r,s,i,o,c,l){super(t,l.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?2:0}set marker(t){(this.info&8)>0!==t&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(t){this.keep!==t&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(t){this.deleted!==t&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=E(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=E(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===mt&&this.id.client!==this.parent.client&&this.parent.clock>=E(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=ci(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=M(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===R||this.right&&this.right.constructor===R)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===mt){let r=te(n,this.parent);r.constructor===R?this.parent=null:this.parent=r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=ci(t,t.doc.store,m(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;let i=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),i.add(s),Qt(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(Qt(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(te(t.doc.store,s.origin)))i.has(te(t.doc.store,s.origin))||(r=s,i.clear());else break;s=s.right}this.left=r}if(this.left!==null){let r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Ci(t.doc.store,this),this.content.integrate(t,this),ai(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new R(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:m(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Qt(t.origin,this.lastId)&&this.right===t&&Qt(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===t&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Be(t.deleteSet,this.id.client,this.id.clock,this.length),ai(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw D();this.content.gc(t),n?Jc(t,this,new R(this.id,this.length)):this.content=new ze(this.length)}write(t,n){let r=n>0?m(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&31|(r===null?0:128)|(s===null?0:64)|(i===null?0:32);if(t.writeInfo(o),r!==null&&t.writeLeftID(r),s!==null&&t.writeRightID(s),r===null&&s===null){let c=this.parent;if(c._item!==void 0){let l=c._item;if(l===null){let h=Ei(c);t.writeParentInfo(!0),t.writeString(h)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else c.constructor===String?(t.writeParentInfo(!0),t.writeString(c)):c.constructor===mt?(t.writeParentInfo(!1),t.writeLeftID(c)):D();i!==null&&t.writeString(i)}this.content.write(t,n)}},Wi=(e,t)=>Bl[t&31](e),Bl=[()=>{D()},xl,_l,yl,Cl,kl,Sl,Ll,Ul,bl,()=>{D()}],Ml=10,B=class extends Ge{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){D()}write(t,n){t.writeInfo(Ml),g(t.restEncoder,this.length-n)}getMissing(t,n){return null}},Zi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Qi="__ $YJS$ __";Zi[Qi]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Zi[Qi]=!0;export{_ as a,L as b,W as c,Ot as d,es as e,O as f,$l as g,Ye as h,it as i,rs as j,ut as k,$ as l,Ft as m,g as n,lt as o,F as p,at as q,G as r,z as s,D as t,V as u,j as v,_t as w,w as x,dt as y,Gt as z,Uo as A,Yl as B,ps as C,Se as D,Zl as E,Ql as F,ws as G,ta as H,ea as I,vo as J,Ht as K,Ue as L,rn as M,ra as N,sa as O,ia as P,oa as Q,At as R,Oa as S,ve as T,Oe as U,Sr as V,En as W,ja as X,Qs as Y,ne as Z,de as _,re as $,Fr as aa,yi as ba,Tc as ca,Tt as da,H as ea,q as fa,ct as ga,X as ha,bi as ia,Ha as ja,qr as ka,Ja as la,Lc as ma,Xa as na,Si as oa,Pa as pa,mt as qa,Qt as ra,m as sa,Ei as ta,On as ua,Ka as va,oi as wa,Me as xa,Ya as ya,Wa as za,Cr as Aa,Za as Ba,Qa as Ca,th as Da,eh as Ea,nh as Fa,Vn as Ga,rh as Ha,qc as Ia,sh as Ja,Gc as Ka,ih as La,Ui as Ma,oh as Na,ch as Oa,lh as Pa,ah as Qa,E as Ra,K as Sa,te as Ta,M as Ua,ci as Va,Tr as Wa,hh as Xa,x as Ya,di as Za,uh as _a,Pc as $a,dh as ab,Kc as bb,Yc as cb,Wc as db,fh as eb,Zc as fb,ph as gb,Ln as hb,vi as ib,gh as jb,mh as kb,wh as lb,yh as mb,tl as nb,ie as ob,xh as pb,C as qb,bh as rb,kh as sb,ol as tb,Or as ub,oe as vb,Vr as wb,ce as xb,hl as yb,Nr as zb,qe as Ab,le as Bb,ae as Cb,Lr as Db,Rn as Eb,Br as Fb,Ge as Gb,R as Hb,he as Ib,ze as Jb,ue as Kb,xt as Lb,A as Mb,$n as Nb,vt as Ob,rt as Pb,Y as Qb,b as Rb,B as Sb};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D as g,L as U,e as V,f as y,k,l as x,n as f,o as v,u as L,x as m,y as M}from"./chunk-E5R7FPWA.js";var J=()=>{let t=!0;return(o,e)=>{if(t){t=!1;try{o()}finally{t=!0}}else e!==void 0&&e()}};var S=3e4,A=class extends V{constructor(o){super(),this.doc=o,this.clientID=o.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=g();this.getLocalState()!==null&&S/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let i=[];this.meta.forEach((s,n)=>{n!==this.clientID&&S<=e-s.lastUpdated&&this.states.has(n)&&i.push(n)}),i.length>0&&T(this,i,"timeout")},y(S/10)),o.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(o){let e=this.clientID,i=this.meta.get(e),s=i===void 0?0:i.clock+1,n=this.states.get(e);o===null?this.states.delete(e):this.states.set(e,o),this.meta.set(e,{clock:s,lastUpdated:g()});let c=[],a=[],d=[],h=[];o===null?h.push(e):n==null?o!=null&&c.push(e):(a.push(e),U(n,o)||d.push(e)),(c.length>0||d.length>0||h.length>0)&&this.emit("change",[{added:c,updated:d,removed:h},"local"]),this.emit("update",[{added:c,updated:a,removed:h},"local"])}setLocalStateField(o,e){let i=this.getLocalState();i!==null&&this.setLocalState({...i,[o]:e})}getStates(){return this.states}},T=(t,o,e)=>{let i=[];for(let s=0;s<o.length;s++){let n=o[s];if(t.states.has(n)){if(t.states.delete(n),n===t.clientID){let c=t.meta.get(n);t.meta.set(n,{clock:c.clock+1,lastUpdated:g()})}i.push(n)}}i.length>0&&(t.emit("change",[{added:[],updated:[],removed:i},e]),t.emit("update",[{added:[],updated:[],removed:i},e]))},Y=(t,o,e=t.states)=>{let i=o.length,s=k();f(s,i);for(let n=0;n<i;n++){let c=o[n],a=e.get(c)||null,d=t.meta.get(c).clock;f(s,c),f(s,d),v(s,JSON.stringify(a))}return x(s)};var j=(t,o,e)=>{let i=L(o),s=g(),n=[],c=[],a=[],d=[],h=m(i);for(let D=0;D<h;D++){let l=m(i),u=m(i),r=JSON.parse(M(i)),p=t.meta.get(l),O=t.states.get(l),I=p===void 0?0:p.clock;(I<u||I===u&&r===null&&t.states.has(l))&&(r===null?l===t.clientID&&t.getLocalState()!=null?u++:t.states.delete(l):t.states.set(l,r),t.meta.set(l,{clock:u,lastUpdated:s}),p===void 0&&r!==null?n.push(l):p!==void 0&&r===null?d.push(l):r!==null&&(U(r,O)||a.push(l),c.push(l)))}(n.length>0||a.length>0||d.length>0)&&t.emit("change",[{added:n,updated:a,removed:d},e]),(n.length>0||c.length>0||d.length>0)&&t.emit("update",[{added:n,updated:c,removed:d},e])};export{J as a,A as b,T as c,Y as d,j as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function Ve(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var K=Ve;function Xe(t){return t}var k=Xe;var gt=Math.max;function Je(t,e,r){return e=gt(e===void 0?t.length-1:e,0),function(){for(var o=arguments,f=-1,i=gt(o.length-e,0),p=Array(i);++f<i;)p[f]=o[e+f];f=-1;for(var a=Array(e+1);++f<e;)a[f]=o[f];return a[e]=r(p),K(t,this,a)}}var yt=Je;function Ye(t){return function(){return t}}var bt=Ye;var Ze=typeof global=="object"&&global&&global.Object===Object&&global,$=Ze;var Qe=typeof self=="object"&&self&&self.Object===Object&&self,tr=$||Qe||Function("return this")(),x=tr;var er=x.Symbol,I=er;var vt=Object.prototype,rr=vt.hasOwnProperty,or=vt.toString,W=I?I.toStringTag:void 0;function ar(t){var e=rr.call(t,W),r=t[W];try{t[W]=void 0;var o=!0}catch{}var f=or.call(t);return o&&(e?t[W]=r:delete t[W]),f}var _t=ar;var fr=Object.prototype,ir=fr.toString;function nr(t){return ir.call(t)}var Ot=nr;var pr="[object Null]",sr="[object Undefined]",Tt=I?I.toStringTag:void 0;function ur(t){return t==null?t===void 0?sr:pr:Tt&&Tt in Object(t)?_t(t):Ot(t)}var g=ur;function mr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var u=mr;var lr="[object AsyncFunction]",dr="[object Function]",xr="[object GeneratorFunction]",cr="[object Proxy]";function hr(t){if(!u(t))return!1;var e=g(t);return e==dr||e==xr||e==lr||e==cr}var S=hr;var gr=x["__core-js_shared__"],V=gr;var jt=(function(){var t=/[^.]+$/.exec(V&&V.keys&&V.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function yr(t){return!!jt&&jt in t}var At=yr;var br=Function.prototype,vr=br.toString;function _r(t){if(t!=null){try{return vr.call(t)}catch{}try{return t+""}catch{}}return""}var It=_r;var Or=/[\\^$.*+?()[\]{}|]/g,Tr=/^\[object .+?Constructor\]$/,jr=Function.prototype,Ar=Object.prototype,Ir=jr.toString,Sr=Ar.hasOwnProperty,wr=RegExp("^"+Ir.call(Sr).replace(Or,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Cr(t){if(!u(t)||At(t))return!1;var e=S(t)?wr:Tr;return e.test(It(t))}var St=Cr;function Pr(t,e){return t?.[e]}var wt=Pr;function Er(t,e){var r=wt(t,e);return St(r)?r:void 0}var w=Er;var Mr=(function(){try{var t=w(Object,"defineProperty");return t({},"",{}),t}catch{}})(),C=Mr;var Lr=C?function(t,e){return C(t,"toString",{configurable:!0,enumerable:!1,value:bt(e),writable:!0})}:k,Ct=Lr;var Br=800,Rr=16,Dr=Date.now;function Wr(t){var e=0,r=0;return function(){var o=Dr(),f=Rr-(o-r);if(r=o,f>0){if(++e>=Br)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var Pt=Wr;var Nr=Pt(Ct),Et=Nr;function Fr(t,e){return Et(yt(t,e,k),t+"")}var X=Fr;function zr(){this.__data__=[],this.size=0}var Mt=zr;function Gr(t,e){return t===e||t!==t&&e!==e}var v=Gr;function Ur(t,e){for(var r=t.length;r--;)if(v(t[r][0],e))return r;return-1}var _=Ur;var Hr=Array.prototype,qr=Hr.splice;function Kr(t){var e=this.__data__,r=_(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():qr.call(e,r,1),--this.size,!0}var Lt=Kr;function kr(t){var e=this.__data__,r=_(e,t);return r<0?void 0:e[r][1]}var Bt=kr;function $r(t){return _(this.__data__,t)>-1}var Rt=$r;function Vr(t,e){var r=this.__data__,o=_(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Dt=Vr;function P(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}P.prototype.clear=Mt;P.prototype.delete=Lt;P.prototype.get=Bt;P.prototype.has=Rt;P.prototype.set=Dt;var O=P;function Xr(){this.__data__=new O,this.size=0}var Wt=Xr;function Jr(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var Nt=Jr;function Yr(t){return this.__data__.get(t)}var Ft=Yr;function Zr(t){return this.__data__.has(t)}var zt=Zr;var Qr=w(x,"Map"),J=Qr;var to=w(Object,"create"),y=to;function eo(){this.__data__=y?y(null):{},this.size=0}var Gt=eo;function ro(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Ut=ro;var oo="__lodash_hash_undefined__",ao=Object.prototype,fo=ao.hasOwnProperty;function io(t){var e=this.__data__;if(y){var r=e[t];return r===oo?void 0:r}return fo.call(e,t)?e[t]:void 0}var Ht=io;var no=Object.prototype,po=no.hasOwnProperty;function so(t){var e=this.__data__;return y?e[t]!==void 0:po.call(e,t)}var qt=so;var uo="__lodash_hash_undefined__";function mo(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=y&&e===void 0?uo:e,this}var Kt=mo;function E(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}E.prototype.clear=Gt;E.prototype.delete=Ut;E.prototype.get=Ht;E.prototype.has=qt;E.prototype.set=Kt;var nt=E;function lo(){this.size=0,this.__data__={hash:new nt,map:new(J||O),string:new nt}}var kt=lo;function xo(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $t=xo;function co(t,e){var r=t.__data__;return $t(e)?r[typeof e=="string"?"string":"hash"]:r.map}var T=co;function ho(t){var e=T(this,t).delete(t);return this.size-=e?1:0,e}var Vt=ho;function go(t){return T(this,t).get(t)}var Xt=go;function yo(t){return T(this,t).has(t)}var Jt=yo;function bo(t,e){var r=T(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Yt=bo;function M(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}M.prototype.clear=kt;M.prototype.delete=Vt;M.prototype.get=Xt;M.prototype.has=Jt;M.prototype.set=Yt;var Zt=M;var vo=200;function _o(t,e){var r=this.__data__;if(r instanceof O){var o=r.__data__;if(!J||o.length<vo-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new Zt(o)}return r.set(t,e),this.size=r.size,this}var Qt=_o;function L(t){var e=this.__data__=new O(t);this.size=e.size}L.prototype.clear=Wt;L.prototype.delete=Nt;L.prototype.get=Ft;L.prototype.has=zt;L.prototype.set=Qt;var te=L;function Oo(t,e,r){e=="__proto__"&&C?C(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var B=Oo;function To(t,e,r){(r!==void 0&&!v(t[e],r)||r===void 0&&!(e in t))&&B(t,e,r)}var N=To;function jo(t){return function(e,r,o){for(var f=-1,i=Object(e),p=o(e),a=p.length;a--;){var n=p[t?a:++f];if(r(i[n],n,i)===!1)break}return e}}var ee=jo;var Ao=ee(),re=Ao;var ie=typeof exports=="object"&&exports&&!exports.nodeType&&exports,oe=ie&&typeof module=="object"&&module&&!module.nodeType&&module,Io=oe&&oe.exports===ie,ae=Io?x.Buffer:void 0,fe=ae?ae.allocUnsafe:void 0;function So(t,e){if(e)return t.slice();var r=t.length,o=fe?fe(r):new t.constructor(r);return t.copy(o),o}var ne=So;var wo=x.Uint8Array,pt=wo;function Co(t){var e=new t.constructor(t.byteLength);return new pt(e).set(new pt(t)),e}var pe=Co;function Po(t,e){var r=e?pe(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var se=Po;function Eo(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var ue=Eo;var me=Object.create,Mo=(function(){function t(){}return function(e){if(!u(e))return{};if(me)return me(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}})(),le=Mo;function Lo(t,e){return function(r){return t(e(r))}}var de=Lo;var Bo=de(Object.getPrototypeOf,Object),Y=Bo;var Ro=Object.prototype;function Do(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Ro;return t===r}var Z=Do;function Wo(t){return typeof t.constructor=="function"&&!Z(t)?le(Y(t)):{}}var xe=Wo;function No(t){return t!=null&&typeof t=="object"}var c=No;var Fo="[object Arguments]";function zo(t){return c(t)&&g(t)==Fo}var st=zo;var ce=Object.prototype,Go=ce.hasOwnProperty,Uo=ce.propertyIsEnumerable,Ho=st((function(){return arguments})())?st:function(t){return c(t)&&Go.call(t,"callee")&&!Uo.call(t,"callee")},F=Ho;var qo=Array.isArray,z=qo;var Ko=9007199254740991;function ko(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ko}var Q=ko;function $o(t){return t!=null&&Q(t.length)&&!S(t)}var R=$o;function Vo(t){return c(t)&&R(t)}var he=Vo;function Xo(){return!1}var ge=Xo;var ve=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ye=ve&&typeof module=="object"&&module&&!module.nodeType&&module,Jo=ye&&ye.exports===ve,be=Jo?x.Buffer:void 0,Yo=be?be.isBuffer:void 0,Zo=Yo||ge,tt=Zo;var Qo="[object Object]",ta=Function.prototype,ea=Object.prototype,_e=ta.toString,ra=ea.hasOwnProperty,oa=_e.call(Object);function aa(t){if(!c(t)||g(t)!=Qo)return!1;var e=Y(t);if(e===null)return!0;var r=ra.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&_e.call(r)==oa}var Oe=aa;var fa="[object Arguments]",ia="[object Array]",na="[object Boolean]",pa="[object Date]",sa="[object Error]",ua="[object Function]",ma="[object Map]",la="[object Number]",da="[object Object]",xa="[object RegExp]",ca="[object Set]",ha="[object String]",ga="[object WeakMap]",ya="[object ArrayBuffer]",ba="[object DataView]",va="[object Float32Array]",_a="[object Float64Array]",Oa="[object Int8Array]",Ta="[object Int16Array]",ja="[object Int32Array]",Aa="[object Uint8Array]",Ia="[object Uint8ClampedArray]",Sa="[object Uint16Array]",wa="[object Uint32Array]",s={};s[va]=s[_a]=s[Oa]=s[Ta]=s[ja]=s[Aa]=s[Ia]=s[Sa]=s[wa]=!0;s[fa]=s[ia]=s[ya]=s[na]=s[ba]=s[pa]=s[sa]=s[ua]=s[ma]=s[la]=s[da]=s[xa]=s[ca]=s[ha]=s[ga]=!1;function Ca(t){return c(t)&&Q(t.length)&&!!s[g(t)]}var Te=Ca;function Pa(t){return function(e){return t(e)}}var je=Pa;var Ae=typeof exports=="object"&&exports&&!exports.nodeType&&exports,G=Ae&&typeof module=="object"&&module&&!module.nodeType&&module,Ea=G&&G.exports===Ae,ut=Ea&&$.process,Ma=(function(){try{var t=G&&G.require&&G.require("util").types;return t||ut&&ut.binding&&ut.binding("util")}catch{}})(),mt=Ma;var Ie=mt&&mt.isTypedArray,La=Ie?je(Ie):Te,et=La;function Ba(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var U=Ba;var Ra=Object.prototype,Da=Ra.hasOwnProperty;function Wa(t,e,r){var o=t[e];(!(Da.call(t,e)&&v(o,r))||r===void 0&&!(e in t))&&B(t,e,r)}var Se=Wa;function Na(t,e,r,o){var f=!r;r||(r={});for(var i=-1,p=e.length;++i<p;){var a=e[i],n=o?o(r[a],t[a],a,r,t):void 0;n===void 0&&(n=t[a]),f?B(r,a,n):Se(r,a,n)}return r}var we=Na;function Fa(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Ce=Fa;var za=9007199254740991,Ga=/^(?:0|[1-9]\d*)$/;function Ua(t,e){var r=typeof t;return e=e??za,!!e&&(r=="number"||r!="symbol"&&Ga.test(t))&&t>-1&&t%1==0&&t<e}var rt=Ua;var Ha=Object.prototype,qa=Ha.hasOwnProperty;function Ka(t,e){var r=z(t),o=!r&&F(t),f=!r&&!o&&tt(t),i=!r&&!o&&!f&&et(t),p=r||o||f||i,a=p?Ce(t.length,String):[],n=a.length;for(var l in t)(e||qa.call(t,l))&&!(p&&(l=="length"||f&&(l=="offset"||l=="parent")||i&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||rt(l,n)))&&a.push(l);return a}var Pe=Ka;function ka(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ee=ka;var $a=Object.prototype,Va=$a.hasOwnProperty;function Xa(t){if(!u(t))return Ee(t);var e=Z(t),r=[];for(var o in t)o=="constructor"&&(e||!Va.call(t,o))||r.push(o);return r}var Me=Xa;function Ja(t){return R(t)?Pe(t,!0):Me(t)}var ot=Ja;function Ya(t){return we(t,ot(t))}var Le=Ya;function Za(t,e,r,o,f,i,p){var a=U(t,r),n=U(e,r),l=p.get(n);if(l){N(t,r,l);return}var d=i?i(a,n,r+"",t,e,p):void 0,h=d===void 0;if(h){var j=z(n),A=!j&&tt(n),H=!j&&!A&&et(n);d=n,j||A||H?z(a)?d=a:he(a)?d=ue(a):A?(h=!1,d=ne(n,!0)):H?(h=!1,d=se(n,!0)):d=[]:Oe(n)||F(n)?(d=a,F(a)?d=Le(a):(!u(a)||S(a))&&(d=xe(n))):h=!1}h&&(p.set(n,d),f(d,n,o,i,p),p.delete(n)),N(t,r,d)}var Be=Za;function Re(t,e,r,o,f){t!==e&&re(e,function(i,p){if(f||(f=new te),u(i))Be(t,e,p,r,Re,o,f);else{var a=o?o(U(t,p),i,p+"",t,e,f):void 0;a===void 0&&(a=i),N(t,p,a)}},ot)}var at=Re;function De(t,e,r,o,f,i){return u(t)&&u(e)&&(i.set(e,t),at(t,e,void 0,De,i),i.delete(e)),t}var We=De;function Qa(t,e,r){if(!u(r))return!1;var o=typeof e;return(o=="number"?R(r)&&rt(e,r.length):o=="string"&&e in r)?v(r[e],t):!1}var Ne=Qa;function tf(t){return X(function(e,r){var o=-1,f=r.length,i=f>1?r[f-1]:void 0,p=f>2?r[2]:void 0;for(i=t.length>3&&typeof i=="function"?(f--,i):void 0,p&&Ne(r[0],r[1],p)&&(i=f<3?void 0:i,f=1),e=Object(e);++o<f;){var a=r[o];a&&t(e,a,o,i)}return e})}var Fe=tf;var ef=Fe(function(t,e,r,o){at(t,e,r,o)}),ze=ef;var rf=X(function(t){return t.push(void 0,We),K(ze,void 0,t)}),of=rf;var af="[object Symbol]";function ff(t){return typeof t=="symbol"||c(t)&&g(t)==af}var Ge=ff;var nf=/\s/;function pf(t){for(var e=t.length;e--&&nf.test(t.charAt(e)););return e}var Ue=pf;var sf=/^\s+/;function uf(t){return t&&t.slice(0,Ue(t)+1).replace(sf,"")}var He=uf;var qe=NaN,mf=/^[-+]0x[0-9a-f]+$/i,lf=/^0b[01]+$/i,df=/^0o[0-7]+$/i,xf=parseInt;function cf(t){if(typeof t=="number")return t;if(Ge(t))return qe;if(u(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=u(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=He(t);var r=lf.test(t);return r||df.test(t)?xf(t.slice(2),r?2:8):mf.test(t)?qe:+t}var lt=cf;var hf=function(){return x.Date.now()},ft=hf;var gf="Expected a function",yf=Math.max,bf=Math.min;function vf(t,e,r){var o,f,i,p,a,n,l=0,d=!1,h=!1,j=!0;if(typeof t!="function")throw new TypeError(gf);e=lt(e)||0,u(r)&&(d=!!r.leading,h="maxWait"in r,i=h?yf(lt(r.maxWait)||0,e):i,j="trailing"in r?!!r.trailing:j);function A(m){var b=o,D=f;return o=f=void 0,l=m,p=t.apply(D,b),p}function H(m){return l=m,a=setTimeout(q,e),d?A(m):p}function Ke(m){var b=m-n,D=m-l,ht=e-b;return h?bf(ht,i-D):ht}function xt(m){var b=m-n,D=m-l;return n===void 0||b>=e||b<0||h&&D>=i}function q(){var m=ft();if(xt(m))return ct(m);a=setTimeout(q,Ke(m))}function ct(m){return a=void 0,j&&o?A(m):(o=f=void 0,p)}function ke(){a!==void 0&&clearTimeout(a),l=0,o=n=f=a=void 0}function $e(){return a===void 0?p:ct(ft())}function it(){var m=ft(),b=xt(m);if(o=arguments,f=this,n=m,b){if(a===void 0)return H(n);if(h)return clearTimeout(a),a=setTimeout(q,e),A(n)}return a===void 0&&(a=setTimeout(q,e)),p}return it.cancel=ke,it.flush=$e,it}var dt=vf;var _f="Expected a function";function Of(t,e,r){var o=!0,f=!0;if(typeof t!="function")throw new TypeError(_f);return u(r)&&(o="leading"in r?!!r.leading:o,f="trailing"in r?!!r.trailing:f),dt(t,e,{leading:o,maxWait:e,trailing:f})}var Tf=Of;export{dt as a,of as b,Tf as c};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as Zt}from"./chunk-PSGXCQNW.js";import{pa as Yt,y as Se}from"./chunk-7CVS4AGG.js";import{A as Jt,e as M,g as xe,i as qt,o as pe,v as q,w as Ut,x as Pe,z as Xt}from"./chunk-GHRUWTEV.js";import{D as ye,M as $t,N as D,O as Ht,P,Q as Bt,Qa as de,T as Z,U as G,Z as jt,_ as Ee,a as be,ca as Wt,fa as _e,ia as Kt,j as ke,k as Et,ka as Vt,l as J,m as te,n as Ce,o as _t,p as Y,pa as Gt,q as T,qa as ne,r as K,ra as oe,s as fe,t as V,u as I,v as Ie,w as Pt,x as Ot}from"./chunk-VKELS2FZ.js";import{a as v,d as N}from"./chunk-BV6CAHIM.js";var $e,He;if(typeof WeakMap<"u"){let e=new WeakMap;$e=t=>e.get(t),He=(t,n)=>(e.set(t,n),n)}else{let e=[],n=0;$e=o=>{for(let r=0;r<e.length;r+=2)if(e[r]==o)return e[r+1]},He=(o,r)=>(n==10&&(n=0),e[n++]=o,e[n++]=r)}var y=class{constructor(e,t,n,o){this.width=e,this.height=t,this.map=n,this.problems=o}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let o=t%this.width,r=t/this.width|0,i=o+1,l=r+1;for(let s=1;i<this.width&&this.map[t+s]==n;s++)i++;for(let s=1;l<this.height&&this.map[t+this.width*s]==n;s++)l++;return{left:o,top:r,right:i,bottom:l}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:o,right:r,top:i,bottom:l}=this.findCell(e);return t=="horiz"?(n<0?o==0:r==this.width)?null:this.map[i*this.width+(n<0?o-1:r)]:(n<0?i==0:l==this.height)?null:this.map[o+this.width*(n<0?i-1:l)]}rectBetween(e,t){let{left:n,right:o,top:r,bottom:i}=this.findCell(e),{left:l,right:s,top:a,bottom:u}=this.findCell(t);return{left:Math.min(n,l),top:Math.min(r,a),right:Math.max(o,s),bottom:Math.max(i,u)}}cellsInRect(e){let t=[],n={};for(let o=e.top;o<e.bottom;o++)for(let r=e.left;r<e.right;r++){let i=o*this.width+r,l=this.map[i];n[l]||(n[l]=!0,!(r==e.left&&r&&this.map[i-1]==l||o==e.top&&o&&this.map[i-this.width]==l)&&t.push(l))}return t}positionAt(e,t,n){for(let o=0,r=0;;o++){let i=r+n.child(o).nodeSize;if(o==e){let l=t+e*this.width,s=(e+1)*this.width;for(;l<s&&this.map[l]<r;)l++;return l==s?i-1:this.map[l]}r=i}}static get(e){return $e(e)||He(e,Ro(e))}};function Ro(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);let t=To(e),n=e.childCount,o=[],r=0,i=null,l=[];for(let u=0,f=t*n;u<f;u++)o[u]=0;for(let u=0,f=0;u<n;u++){let c=e.child(u);f++;for(let p=0;;p++){for(;r<o.length&&o[r]!=0;)r++;if(p==c.childCount)break;let g=c.child(p),{colspan:b,rowspan:w,colwidth:C}=g.attrs;for(let x=0;x<w;x++){if(x+u>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:f,n:w-x});break}let R=r+x*t;for(let A=0;A<b;A++){o[R+A]==0?o[R+A]=f:(i||(i=[])).push({type:"collision",row:u,pos:f,n:b-A});let E=C&&C[A];if(E){let _=(R+A)%t*2,W=l[_];W==null||W!=E&&l[_+1]==1?(l[_]=E,l[_+1]=1):W==E&&l[_+1]++}}}r+=b,f+=g.nodeSize}let d=(u+1)*t,h=0;for(;r<d;)o[r++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:u,n:h}),f++}(t===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});let s=new y(t,n,o,i),a=!1;for(let u=0;!a&&u<l.length;u+=2)l[u]!=null&&l[u+1]<n&&(a=!0);return a&&vo(s,l,e),s}function To(e){let t=-1,n=!1;for(let o=0;o<e.childCount;o++){let r=e.child(o),i=0;if(n)for(let l=0;l<o;l++){let s=e.child(l);for(let a=0;a<s.childCount;a++){let u=s.child(a);l+u.attrs.rowspan>o&&(i+=u.attrs.colspan)}}for(let l=0;l<r.childCount;l++){let s=r.child(l);i+=s.attrs.colspan,s.attrs.rowspan>1&&(n=!0)}t==-1?t=i:t!=i&&(t=Math.max(t,i))}return t}function vo(e,t,n){e.problems||(e.problems=[]);let o={};for(let r=0;r<e.map.length;r++){let i=e.map[r];if(o[i])continue;o[i]=!0;let l=n.nodeAt(i);if(!l)throw new RangeError(`No cell with offset ${i} found`);let s=null,a=l.attrs;for(let u=0;u<a.colspan;u++){let f=t[(r+u)%e.width*2];f!=null&&(!a.colwidth||a.colwidth[u]!=f)&&((s||(s=Mo(a)))[u]=f)}s&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:s})}}function Mo(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Qt(e,t){if(typeof e=="string")return{};let n=e.getAttribute("data-colwidth"),o=n&&/^\d+(,\d+)*$/.test(n)?n.split(",").map(l=>Number(l)):null,r=Number(e.getAttribute("colspan")||1),i={colspan:r,rowspan:Number(e.getAttribute("rowspan")||1),colwidth:o&&o.length==r?o:null};for(let l in t){let s=t[l].getFromDOM,a=s&&s(e);a!=null&&(i[l]=a)}return i}function en(e,t){let n={};e.attrs.colspan!=1&&(n.colspan=e.attrs.colspan),e.attrs.rowspan!=1&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n["data-colwidth"]=e.attrs.colwidth.join(","));for(let o in t){let r=t[o].setDOMAttr;r&&r(e.attrs[o],n)}return n}function No(e){if(e!==null){if(!Array.isArray(e))throw new TypeError("colwidth must be null or an array");for(let t of e)if(typeof t!="number")throw new TypeError("colwidth must be null or an array of numbers")}}function pn(e){let t=e.cellAttributes||{},n={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:No}};for(let o in t)n[o]={default:t[o].default,validate:t[o].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:e.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:e.cellContent,attrs:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:o=>Qt(o,t)}],toDOM(o){return["td",en(o,t),0]}},table_header:{content:e.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:o=>Qt(o,t)}],toDOM(o){return["th",en(o,t),0]}}}}function z(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let o=e.nodes[n],r=o.spec.tableRole;r&&(t[r]=o)}}return t}var U=new G("selectingCells");function ie(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}function L(e){let t=e.selection.$head;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="row")return!0;return!1}function Ne(e){let t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;let n=ie(t.$head)||Do(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function Do(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let o=t.type.spec.tableRole;if(o=="cell"||o=="header_cell")return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let o=t.type.spec.tableRole;if(o=="cell"||o=="header_cell")return e.doc.resolve(n-t.nodeSize)}}function Be(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function Fo(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Ke(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function hn(e,t,n){let o=e.node(-1),r=y.get(o),i=e.start(-1),l=r.nextCell(e.pos-i,t,n);return l==null?null:e.node(0).resolve(i+l)}function Q(e,t,n=1){let o={...e,colspan:e.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(t,n),o.colwidth.some(r=>r>0)||(o.colwidth=null)),o}function Lo(e,t,n=1){let o={...e,colspan:e.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let r=0;r<n;r++)o.colwidth.splice(t,0,0)}return o}function zo(e,t,n){let o=z(t.type.schema).header_cell;for(let r=0;r<e.height;r++)if(t.nodeAt(e.map[n+r*e.width]).type!=o)return!1;return!0}var S=class $ extends D{constructor(t,n=t){let o=t.node(-1),r=y.get(o),i=t.start(-1),l=r.rectBetween(t.pos-i,n.pos-i),s=t.node(0),a=r.cellsInRect(l).filter(f=>f!=n.pos-i);a.unshift(n.pos-i);let u=a.map(f=>{let c=o.nodeAt(f);if(!c)throw new RangeError(`No cell with offset ${f} found`);let d=i+f+1;return new Ht(s.resolve(d),s.resolve(d+c.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=t,this.$headCell=n}map(t,n){let o=t.resolve(n.map(this.$anchorCell.pos)),r=t.resolve(n.map(this.$headCell.pos));if(Be(o)&&Be(r)&&Ke(o,r)){let i=this.$anchorCell.node(-1)!=o.node(-1);return i&&this.isRowSelection()?$.rowSelection(o,r):i&&this.isColSelection()?$.colSelection(o,r):new $(o,r)}return P.between(o,r)}content(){let t=this.$anchorCell.node(-1),n=y.get(t),o=this.$anchorCell.start(-1),r=n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),i={},l=[];for(let a=r.top;a<r.bottom;a++){let u=[];for(let f=a*n.width+r.left,c=r.left;c<r.right;c++,f++){let d=n.map[f];if(i[d])continue;i[d]=!0;let h=n.findCell(d),p=t.nodeAt(d);if(!p)throw new RangeError(`No cell with offset ${d} found`);let g=r.left-h.left,b=h.right-r.right;if(g>0||b>0){let w=p.attrs;if(g>0&&(w=Q(w,0,g)),b>0&&(w=Q(w,w.colspan-b,b)),h.left<r.left){if(p=p.type.createAndFill(w),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(w)}`)}else p=p.type.create(w,p.content)}if(h.top<r.top||h.bottom>r.bottom){let w={...p.attrs,rowspan:Math.min(h.bottom,r.bottom)-Math.max(h.top,r.top)};h.top<r.top?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}u.push(p)}l.push(t.child(a).copy(v.from(u)))}let s=this.isColSelection()&&this.isRowSelection()?t:l;return new N(v.from(s),1,1)}replace(t,n=N.empty){let o=t.steps.length,r=this.ranges;for(let l=0;l<r.length;l++){let{$from:s,$to:a}=r[l],u=t.mapping.slice(o);t.replace(u.map(s.pos),u.map(a.pos),l?N.empty:n)}let i=D.findFrom(t.doc.resolve(t.mapping.slice(o).map(this.to)),-1);i&&t.setSelection(i)}replaceWith(t,n){this.replace(t,new N(v.from(n),0,0))}forEachCell(t){let n=this.$anchorCell.node(-1),o=y.get(n),r=this.$anchorCell.start(-1),i=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let l=0;l<i.length;l++)t(n.nodeAt(i[l]),r+i[l])}isColSelection(){let t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;let o=t+this.$anchorCell.nodeAfter.attrs.rowspan,r=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let o=t.node(-1),r=y.get(o),i=t.start(-1),l=r.findCell(t.pos-i),s=r.findCell(n.pos-i),a=t.node(0);return l.top<=s.top?(l.top>0&&(t=a.resolve(i+r.map[l.left])),s.bottom<r.height&&(n=a.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))):(s.top>0&&(n=a.resolve(i+r.map[s.left])),l.bottom<r.height&&(t=a.resolve(i+r.map[r.width*(r.height-1)+l.right-1]))),new $(t,n)}isRowSelection(){let t=this.$anchorCell.node(-1),n=y.get(t),o=this.$anchorCell.start(-1),r=n.colCount(this.$anchorCell.pos-o),i=n.colCount(this.$headCell.pos-o);if(Math.min(r,i)>0)return!1;let l=r+this.$anchorCell.nodeAfter.attrs.colspan,s=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,s)==n.width}eq(t){return t instanceof $&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let o=t.node(-1),r=y.get(o),i=t.start(-1),l=r.findCell(t.pos-i),s=r.findCell(n.pos-i),a=t.node(0);return l.left<=s.left?(l.left>0&&(t=a.resolve(i+r.map[l.top*r.width])),s.right<r.width&&(n=a.resolve(i+r.map[r.width*(s.top+1)-1]))):(s.left>0&&(n=a.resolve(i+r.map[s.top*r.width])),l.right<r.width&&(t=a.resolve(i+r.map[r.width*(l.top+1)-1]))),new $(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new $(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,o=n){return new $(t.resolve(n),t.resolve(o))}getBookmark(){return new Io(this.$anchorCell.pos,this.$headCell.pos)}};S.prototype.visible=!1;D.jsonID("cell",S);var Io=class mn{constructor(t,n){this.anchor=t,this.head=n}map(t){return new mn(t.map(this.anchor),t.map(this.head))}resolve(t){let n=t.resolve(this.anchor),o=t.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&o.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&o.index()<o.parent.childCount&&Ke(n,o)?new S(n,o):D.near(o,1)}};function Eo(e){if(!(e.selection instanceof S))return null;let t=[];return e.selection.forEachCell((n,o)=>{t.push(ne.node(o,o+n.nodeSize,{class:"selectedCell"}))}),oe.create(e.doc,t)}function _o({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,o=t.pos,r=e.depth;for(;r>=0&&!(e.after(r+1)<e.end(r));r--,n++);for(let i=t.depth;i>=0&&!(t.before(i+1)>t.start(i));i--,o--);return n==o&&/row|table/.test(e.node(r).type.spec.tableRole)}function Po({$from:e,$to:t}){let n,o;for(let r=e.depth;r>0;r--){let i=e.node(r);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let r=t.depth;r>0;r--){let i=t.node(r);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){o=i;break}}return n!==o&&t.parentOffset===0}function Oo(e,t,n){let o=(t||e).selection,r=(t||e).doc,i,l;if(o instanceof Bt&&(l=o.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")i=S.create(r,o.from);else if(l=="row"){let s=r.resolve(o.from+1);i=S.rowSelection(s,s)}else if(!n){let s=y.get(o.node),a=o.from+1,u=a+s.map[s.width*s.height-1];i=S.create(r,a+1,u)}}else o instanceof P&&_o(o)?i=P.create(r,o.from):o instanceof P&&Po(o)&&(i=P.create(r,o.$from.start(),o.$from.end()));return i&&(t||(t=e.tr)).setSelection(i),t}var $o=new G("fix-tables");function gn(e,t,n,o){let r=e.childCount,i=t.childCount;e:for(let l=0,s=0;l<i;l++){let a=t.child(l);for(let u=s,f=Math.min(r,l+3);u<f;u++)if(e.child(u)==a){s=u+1,n+=a.nodeSize;continue e}o(a,n),s<r&&e.child(s).sameMarkup(a)?gn(e.child(s),a,n+1,o):a.nodesBetween(0,a.content.size,o,n+1),n+=a.nodeSize}}function Ho(e,t){let n,o=(r,i)=>{r.type.spec.tableRole=="table"&&(n=Bo(e,r,i,n))};return t?t.doc!=e.doc&&gn(t.doc,e.doc,0,o):e.doc.descendants(o),n}function Bo(e,t,n,o){let r=y.get(t);if(!r.problems)return o;o||(o=e.tr);let i=[];for(let a=0;a<r.height;a++)i.push(0);for(let a=0;a<r.problems.length;a++){let u=r.problems[a];if(u.type=="collision"){let f=t.nodeAt(u.pos);if(!f)continue;let c=f.attrs;for(let d=0;d<c.rowspan;d++)i[u.row+d]+=u.n;o.setNodeMarkup(o.mapping.map(n+1+u.pos),null,Q(c,c.colspan-u.n,u.n))}else if(u.type=="missing")i[u.row]+=u.n;else if(u.type=="overlong_rowspan"){let f=t.nodeAt(u.pos);if(!f)continue;o.setNodeMarkup(o.mapping.map(n+1+u.pos),null,{...f.attrs,rowspan:f.attrs.rowspan-u.n})}else if(u.type=="colwidth mismatch"){let f=t.nodeAt(u.pos);if(!f)continue;o.setNodeMarkup(o.mapping.map(n+1+u.pos),null,{...f.attrs,colwidth:u.colwidth})}else if(u.type=="zero_sized"){let f=o.mapping.map(n);o.delete(f,f+t.nodeSize)}}let l,s;for(let a=0;a<i.length;a++)i[a]&&(l==null&&(l=a),s=a);for(let a=0,u=n+1;a<r.height;a++){let f=t.child(a),c=u+f.nodeSize,d=i[a];if(d>0){let h="cell";f.firstChild&&(h=f.firstChild.type.spec.tableRole);let p=[];for(let b=0;b<d;b++){let w=z(e.schema)[h].createAndFill();w&&p.push(w)}let g=(a==0||l==a-1)&&s==a?u+1:c-1;o.insert(o.mapping.map(g),p)}u=c}return o.setMeta($o,{fixTables:!0})}function wn(e){let t=y.get(e),n=[],o=t.height,r=t.width;for(let i=0;i<o;i++){let l=[];for(let s=0;s<r;s++){let a=i*r+s,u=t.map[a];if(i>0){let f=a-r;if(u===t.map[f]){l.push(null);continue}}if(s>0){let f=a-1;if(u===t.map[f]){l.push(null);continue}}l.push(e.nodeAt(u))}n.push(l)}return n}function bn(e,t){let n=[],o=y.get(e),r=o.height,i=o.width;for(let l=0;l<r;l++){let s=e.child(l),a=[];for(let f=0;f<i;f++){let c=t[l][f];if(!c)continue;let d=o.map[l*o.width+f],h=e.nodeAt(d);if(!h)continue;let p=h.type.createChecked(c.attrs,c.content,c.marks);a.push(p)}let u=s.type.createChecked(s.attrs,a,s.marks);n.push(u)}return e.type.createChecked(e.attrs,n,e.marks)}function kn(e,t,n,o){let r=t[0]>n[0]?-1:1,i=e.splice(t[0],t.length),l=i.length%2===0?1:0,s;return o===-1&&r===1?s=n[0]-1:o===1&&r===-1?s=n[n.length-1]-l+1:s=r===-1?n[0]:n[n.length-1]-l,e.splice(s,0,...i),e}function X(e){return jo(t=>t.type.spec.tableRole==="table",e)}function jo(e,t){for(let n=t.depth;n>=0;n-=1){let o=t.node(n);if(e(o))return{node:o,pos:n===0?0:t.before(n),start:t.start(n),depth:n}}return null}function re(e,t){let n=X(t.$from);if(!n)return;let o=y.get(n.node);if(!(e<0||e>o.width-1))return o.cellsInRect({left:e,right:e+1,top:0,bottom:o.height}).map(r=>{let i=n.node.nodeAt(r),l=r+n.start;return{pos:l,start:l+1,node:i,depth:n.depth+2}})}function le(e,t){let n=X(t.$from);if(!n)return;let o=y.get(n.node);if(!(e<0||e>o.height-1))return o.cellsInRect({left:0,right:o.width,top:e,bottom:e+1}).map(r=>{let i=n.node.nodeAt(r),l=r+n.start;return{pos:l,start:l+1,node:i,depth:n.depth+2}})}function tn(e,t,n=t){let o=t,r=n;for(let f=t;f>=0;f--){let c=re(f,e.selection);c&&c.forEach(d=>{let h=d.node.attrs.colspan+f-1;h>=o&&(o=f),h>r&&(r=h)})}for(let f=t;f<=r;f++){let c=re(f,e.selection);c&&c.forEach(d=>{let h=d.node.attrs.colspan+f-1;d.node.attrs.colspan>1&&h>r&&(r=h)})}let i=[];for(let f=o;f<=r;f++){let c=re(f,e.selection);c&&c.length>0&&i.push(f)}o=i[0],r=i[i.length-1];let l=re(o,e.selection),s=le(0,e.selection);if(!l||!s)return;let a=e.doc.resolve(l[l.length-1].pos),u;for(let f=r;f>=o;f--){let c=re(f,e.selection);if(c&&c.length>0){for(let d=s.length-1;d>=0;d--)if(s[d].pos===c[0].pos){u=c[0];break}if(u)break}}if(u)return{$anchor:a,$head:e.doc.resolve(u.pos),indexes:i}}function nn(e,t,n=t){let o=t,r=n;for(let f=t;f>=0;f--){let c=le(f,e.selection);c&&c.forEach(d=>{let h=d.node.attrs.rowspan+f-1;h>=o&&(o=f),h>r&&(r=h)})}for(let f=t;f<=r;f++){let c=le(f,e.selection);c&&c.forEach(d=>{let h=d.node.attrs.rowspan+f-1;d.node.attrs.rowspan>1&&h>r&&(r=h)})}let i=[];for(let f=o;f<=r;f++){let c=le(f,e.selection);c&&c.length>0&&i.push(f)}o=i[0],r=i[i.length-1];let l=le(o,e.selection),s=re(0,e.selection);if(!l||!s)return;let a=e.doc.resolve(l[l.length-1].pos),u;for(let f=r;f>=o;f--){let c=le(f,e.selection);if(c&&c.length>0){for(let d=s.length-1;d>=0;d--)if(s[d].pos===c[0].pos){u=c[0];break}if(u)break}}if(u)return{$anchor:a,$head:e.doc.resolve(u.pos),indexes:i}}function on(e){return e[0].map((t,n)=>e.map(o=>o[n]))}function Wo(e){var t,n;let{tr:o,originIndex:r,targetIndex:i,select:l,pos:s}=e,a=X(o.doc.resolve(s));if(!a)return!1;let u=(t=tn(o,r))===null||t===void 0?void 0:t.indexes,f=(n=tn(o,i))===null||n===void 0?void 0:n.indexes;if(!u||!f||u.includes(i))return!1;let c=Ko(a.node,u,f,0);if(o.replaceWith(a.pos,a.pos+a.node.nodeSize,c),!l)return!0;let d=y.get(c),h=a.start,p=i,g=d.positionAt(d.height-1,p,c),b=o.doc.resolve(h+g),w=d.positionAt(0,p,c),C=o.doc.resolve(h+w);return o.setSelection(S.colSelection(b,C)),!0}function Ko(e,t,n,o){let r=on(wn(e));return r=kn(r,t,n,o),r=on(r),bn(e,r)}function Vo(e){var t,n;let{tr:o,originIndex:r,targetIndex:i,select:l,pos:s}=e,a=X(o.doc.resolve(s));if(!a)return!1;let u=(t=nn(o,r))===null||t===void 0?void 0:t.indexes,f=(n=nn(o,i))===null||n===void 0?void 0:n.indexes;if(!u||!f||u.includes(i))return!1;let c=Go(a.node,u,f,0);if(o.replaceWith(a.pos,a.pos+a.node.nodeSize,c),!l)return!0;let d=y.get(c),h=a.start,p=i,g=d.positionAt(p,d.width-1,c),b=o.doc.resolve(h+g),w=d.positionAt(p,0,c),C=o.doc.resolve(h+w);return o.setSelection(S.rowSelection(b,C)),!0}function Go(e,t,n,o){let r=wn(e);return r=kn(r,t,n,o),bn(e,r)}function H(e){let t=e.selection,n=Ne(e),o=n.node(-1),r=n.start(-1),i=y.get(o);return{...t instanceof S?i.rectBetween(t.$anchorCell.pos-r,t.$headCell.pos-r):i.findCell(n.pos-r),tableStart:r,map:i,table:o}}function Cn(e,{map:t,tableStart:n,table:o},r){let i=r>0?-1:0;zo(t,o,r+i)&&(i=r==0||r==t.width?null:0);for(let l=0;l<t.height;l++){let s=l*t.width+r;if(r>0&&r<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],u=o.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,Lo(u.attrs,r-t.colCount(a))),l+=u.attrs.rowspan-1}else{let a=i==null?z(o.type.schema).cell:o.nodeAt(t.map[s+i]).type,u=t.positionAt(l,r,o);e.insert(e.mapping.map(n+u),a.createAndFill())}}return e}function yn(e,t){if(!L(e))return!1;if(t){let n=H(e);t(Cn(e.tr,n,n.left))}return!0}function xn(e,t){if(!L(e))return!1;if(t){let n=H(e);t(Cn(e.tr,n,n.right))}return!0}function qo(e,{map:t,table:n,tableStart:o},r){let i=e.mapping.maps.length;for(let l=0;l<t.height;){let s=l*t.width+r,a=t.map[s],u=n.nodeAt(a),f=u.attrs;if(r>0&&t.map[s-1]==a||r<t.width-1&&t.map[s+1]==a)e.setNodeMarkup(e.mapping.slice(i).map(o+a),null,Q(f,r-t.colCount(a)));else{let c=e.mapping.slice(i).map(o+a);e.delete(c,c+u.nodeSize)}l+=f.rowspan}}function Sn(e,t){if(!L(e))return!1;if(t){let n=H(e),o=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let r=n.right-1;qo(o,n,r),r!=n.left;r--){let i=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=y.get(i)}t(o)}return!0}function Uo(e,{map:t,table:n,tableStart:o},r){let i=0;for(let u=0;u<r;u++)i+=n.child(u).nodeSize;let l=i+n.child(r).nodeSize,s=e.mapping.maps.length;e.delete(i+o,l+o);let a=new Set;for(let u=0,f=r*t.width;u<t.width;u++,f++){let c=t.map[f];if(!a.has(c)){if(a.add(c),r>0&&c==t.map[f-t.width]){let d=n.nodeAt(c).attrs;e.setNodeMarkup(e.mapping.slice(s).map(c+o),null,{...d,rowspan:d.rowspan-1}),u+=d.colspan-1}else if(r<t.height&&c==t.map[f+t.width]){let d=n.nodeAt(c),h=d.attrs,p=d.type.create({...h,rowspan:d.attrs.rowspan-1},d.content),g=t.positionAt(r+1,u,n);e.insert(e.mapping.slice(s).map(o+g),p),u+=h.colspan-1}}}}function An(e,t){if(!L(e))return!1;if(t){let n=H(e),o=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let r=n.bottom-1;Uo(o,n,r),r!=n.top;r--){let i=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=y.get(n.table)}t(o)}return!0}function Rn(e,t){return function(n,o){if(!L(n))return!1;let r=Ne(n);if(r.nodeAfter.attrs[e]===t)return!1;if(o){let i=n.tr;n.selection instanceof S?n.selection.forEachCell((l,s)=>{l.attrs[e]!==t&&i.setNodeMarkup(s,null,{...l.attrs,[e]:t})}):i.setNodeMarkup(r.pos,null,{...r.nodeAfter.attrs,[e]:t}),o(i)}return!0}}function Xo(e){return function(t,n){if(!L(t))return!1;if(n){let o=z(t.schema),r=H(t),i=t.tr,l=r.map.cellsInRect(e=="column"?{left:r.left,top:0,right:r.right,bottom:r.map.height}:e=="row"?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),s=l.map(a=>r.table.nodeAt(a));for(let a=0;a<l.length;a++)s[a].type==o.header_cell&&i.setNodeMarkup(r.tableStart+l[a],o.cell,s[a].attrs);if(i.steps.length===0)for(let a=0;a<l.length;a++)i.setNodeMarkup(r.tableStart+l[a],o.header_cell,s[a].attrs);n(i)}return!0}}function rn(e,t,n){let o=t.map.cellsInRect({left:0,top:0,right:e=="row"?t.map.width:1,bottom:e=="column"?t.map.height:1});for(let r=0;r<o.length;r++){let i=t.table.nodeAt(o[r]);if(i&&i.type!==n.header_cell)return!1}return!0}function Ve(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?Xo(e):function(n,o){if(!L(n))return!1;if(o){let r=z(n.schema),i=H(n),l=n.tr,s=rn("row",i,r),a=rn("column",i,r),u=(e==="column"?s:e==="row"&&a)?1:0,f=e=="column"?{left:0,top:u,right:1,bottom:i.map.height}:e=="row"?{left:u,top:0,right:i.map.width,bottom:1}:i,c=e=="column"?a?r.cell:r.header_cell:e=="row"?s?r.cell:r.header_cell:r.cell;i.map.cellsInRect(f).forEach(d=>{let h=d+i.tableStart,p=l.doc.nodeAt(h);p&&l.setNodeMarkup(h,c,p.attrs)}),o(l)}return!0}}var ql=Ve("row",{useDeprecatedLogic:!0}),Ul=Ve("column",{useDeprecatedLogic:!0}),Xl=Ve("cell",{useDeprecatedLogic:!0});function Jo(e,t){if(t<0){let n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(let o=e.index(-1)-1,r=e.before();o>=0;o--){let i=e.node(-1).child(o),l=i.lastChild;if(l)return r-1-l.nodeSize;r-=i.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let n=e.node(-1);for(let o=e.indexAfter(-1),r=e.after();o<n.childCount;o++){let i=n.child(o);if(i.childCount)return r+1;r+=i.nodeSize}}return null}function Ge(e){return function(t,n){if(!L(t))return!1;let o=Jo(Ne(t),e);if(o==null)return!1;if(n){let r=t.doc.resolve(o);n(t.tr.setSelection(P.between(r,Fo(r))).scrollIntoView())}return!0}}function Tn(e,t){let n=e.selection.$anchor;for(let o=n.depth;o>0;o--)if(n.node(o).type.spec.tableRole=="table")return t&&t(e.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0;return!1}function Ae(e,t){let n=e.selection;if(!(n instanceof S))return!1;if(t){let o=e.tr,r=z(e.schema).cell.createAndFill().content;n.forEachCell((i,l)=>{i.content.eq(r)||o.replace(o.mapping.map(l+1),o.mapping.map(l+i.nodeSize-1),new N(r,0,0))}),o.docChanged&&t(o)}return!0}function vn(e){return(t,n)=>{let{from:o,to:r,select:i=!0,pos:l=t.selection.from}=e,s=t.tr;return Vo({tr:s,originIndex:o,targetIndex:r,select:i,pos:l})?(n?.(s),!0):!1}}function Mn(e){return(t,n)=>{let{from:o,to:r,select:i=!0,pos:l=t.selection.from}=e,s=t.tr;return Wo({tr:s,originIndex:o,targetIndex:r,select:i,pos:l})?(n?.(s),!0):!1}}function Yo(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:o}=e;for(;t.childCount==1&&(n>0&&o>0||t.child(0).type.spec.tableRole=="table");)n--,o--,t=t.child(0).content;let r=t.child(0),i=r.type.spec.tableRole,l=r.type.schema,s=[];if(i=="row")for(let a=0;a<t.childCount;a++){let u=t.child(a).content,f=a?0:Math.max(0,n-1),c=a<t.childCount-1?0:Math.max(0,o-1);(f||c)&&(u=je(z(l).row,new N(u,f,c)).content),s.push(u)}else if(i=="cell"||i=="header_cell")s.push(n||o?je(z(l).row,new N(t,n,o)).content:t);else return null;return Zo(l,s)}function Zo(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r];for(let l=i.childCount-1;l>=0;l--){let{rowspan:s,colspan:a}=i.child(l).attrs;for(let u=r;u<r+s;u++)n[u]=(n[u]||0)+a}}let o=0;for(let r=0;r<n.length;r++)o=Math.max(o,n[r]);for(let r=0;r<n.length;r++)if(r>=t.length&&t.push(v.empty),n[r]<o){let i=z(e).cell.createAndFill(),l=[];for(let s=n[r];s<o;s++)l.push(i);t[r]=t[r].append(v.from(l))}return{height:t.length,width:o,rows:t}}function je(e,t){let n=e.createAndFill();return new $t(n).replace(0,n.content.size,t).doc}function Qo({width:e,height:t,rows:n},o,r){if(e!=o){let i=[],l=[];for(let s=0;s<n.length;s++){let a=n[s],u=[];for(let f=i[s]||0,c=0;f<o;c++){let d=a.child(c%a.childCount);f+d.attrs.colspan>o&&(d=d.type.createChecked(Q(d.attrs,d.attrs.colspan,f+d.attrs.colspan-o),d.content)),u.push(d),f+=d.attrs.colspan;for(let h=1;h<d.attrs.rowspan;h++)i[s+h]=(i[s+h]||0)+d.attrs.colspan}l.push(v.from(u))}n=l,e=o}if(t!=r){let i=[];for(let l=0,s=0;l<r;l++,s++){let a=[],u=n[s%t];for(let f=0;f<u.childCount;f++){let c=u.child(f);l+c.attrs.rowspan>r&&(c=c.type.create({...c.attrs,rowspan:Math.max(1,r-c.attrs.rowspan)},c.content)),a.push(c)}i.push(v.from(a))}n=i,t=r}return{width:e,height:t,rows:n}}function er(e,t,n,o,r,i,l){let s=e.doc.type.schema,a=z(s),u,f;if(r>t.width)for(let c=0,d=0;c<t.height;c++){let h=n.child(c);d+=h.nodeSize;let p=[],g;h.lastChild==null||h.lastChild.type==a.cell?g=u||(u=a.cell.createAndFill()):g=f||(f=a.header_cell.createAndFill());for(let b=t.width;b<r;b++)p.push(g);e.insert(e.mapping.slice(l).map(d-1+o),p)}if(i>t.height){let c=[];for(let p=0,g=(t.height-1)*t.width;p<Math.max(t.width,r);p++){let b=p>=t.width?!1:n.nodeAt(t.map[g+p]).type==a.header_cell;c.push(b?f||(f=a.header_cell.createAndFill()):u||(u=a.cell.createAndFill()))}let d=a.row.create(null,v.from(c)),h=[];for(let p=t.height;p<i;p++)h.push(d);e.insert(e.mapping.slice(l).map(o+n.nodeSize-2),h)}return!!(u||f)}function ln(e,t,n,o,r,i,l,s){if(l==0||l==t.height)return!1;let a=!1;for(let u=r;u<i;u++){let f=l*t.width+u,c=t.map[f];if(t.map[f-t.width]==c){a=!0;let d=n.nodeAt(c),{top:h,left:p}=t.findCell(c);e.setNodeMarkup(e.mapping.slice(s).map(c+o),null,{...d.attrs,rowspan:l-h}),e.insert(e.mapping.slice(s).map(t.positionAt(l,p,n)),d.type.createAndFill({...d.attrs,rowspan:h+d.attrs.rowspan-l})),u+=d.attrs.colspan-1}}return a}function an(e,t,n,o,r,i,l,s){if(l==0||l==t.width)return!1;let a=!1;for(let u=r;u<i;u++){let f=u*t.width+l,c=t.map[f];if(t.map[f-1]==c){a=!0;let d=n.nodeAt(c),h=t.colCount(c),p=e.mapping.slice(s).map(c+o);e.setNodeMarkup(p,null,Q(d.attrs,l-h,d.attrs.colspan-(l-h))),e.insert(p+d.nodeSize,d.type.createAndFill(Q(d.attrs,0,l-h))),u+=d.attrs.rowspan-1}}return a}function sn(e,t,n,o,r){let i=n?e.doc.nodeAt(n-1):e.doc;if(!i)throw new Error("No table found");let l=y.get(i),{top:s,left:a}=o,u=a+r.width,f=s+r.height,c=e.tr,d=0;function h(){if(i=n?c.doc.nodeAt(n-1):c.doc,!i)throw new Error("No table found");l=y.get(i),d=c.mapping.maps.length}er(c,l,i,n,u,f,d)&&h(),ln(c,l,i,n,a,u,s,d)&&h(),ln(c,l,i,n,a,u,f,d)&&h(),an(c,l,i,n,s,f,a,d)&&h(),an(c,l,i,n,s,f,u,d)&&h();for(let p=s;p<f;p++){let g=l.positionAt(p,a,i),b=l.positionAt(p,u,i);c.replace(c.mapping.slice(d).map(g+n),c.mapping.slice(d).map(b+n),new N(r.rows[p-s],0,0))}h(),c.setSelection(new S(c.doc.resolve(n+l.positionAt(s,a,i)),c.doc.resolve(n+l.positionAt(f-1,u-1,i)))),t(c)}var tr=Gt({ArrowLeft:Re("horiz",-1),ArrowRight:Re("horiz",1),ArrowUp:Re("vert",-1),ArrowDown:Re("vert",1),"Shift-ArrowLeft":Te("horiz",-1),"Shift-ArrowRight":Te("horiz",1),"Shift-ArrowUp":Te("vert",-1),"Shift-ArrowDown":Te("vert",1),Backspace:Ae,"Mod-Backspace":Ae,Delete:Ae,"Mod-Delete":Ae});function ve(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function Re(e,t){return(n,o,r)=>{if(!r)return!1;let i=n.selection;if(i instanceof S)return ve(n,o,D.near(i.$headCell,t));if(e!="horiz"&&!i.empty)return!1;let l=Nn(r,e,t);if(l==null)return!1;if(e=="horiz")return ve(n,o,D.near(n.doc.resolve(i.head+t),t));{let s=n.doc.resolve(l),a=hn(s,e,t),u;return a?u=D.near(a,1):t<0?u=D.near(n.doc.resolve(s.before(-1)),-1):u=D.near(n.doc.resolve(s.after(-1)),1),ve(n,o,u)}}}function Te(e,t){return(n,o,r)=>{if(!r)return!1;let i=n.selection,l;if(i instanceof S)l=i;else{let a=Nn(r,e,t);if(a==null)return!1;l=new S(n.doc.resolve(a))}let s=hn(l.$headCell,e,t);return s?ve(n,o,new S(l.$anchorCell,s)):!1}}function nr(e,t){let n=e.state.doc,o=ie(n.resolve(t));return o?(e.dispatch(e.state.tr.setSelection(new S(o))),!0):!1}function or(e,t,n){if(!L(e.state))return!1;let o=Yo(n),r=e.state.selection;if(r instanceof S){o||(o={width:1,height:1,rows:[v.from(je(z(e.state.schema).cell,n))]});let i=r.$anchorCell.node(-1),l=r.$anchorCell.start(-1),s=y.get(i).rectBetween(r.$anchorCell.pos-l,r.$headCell.pos-l);return o=Qo(o,s.right-s.left,s.bottom-s.top),sn(e.state,e.dispatch,l,s,o),!0}else if(o){let i=Ne(e.state),l=i.start(-1);return sn(e.state,e.dispatch,l,y.get(i.node(-1)).findCell(i.pos-l),o),!0}else return!1}function rr(e,t){var n;if(t.button!=0||t.ctrlKey||t.metaKey)return;let o=cn(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof S)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&o&&(r=ie(e.state.selection.$anchor))!=null&&((n=Oe(e,t))===null||n===void 0?void 0:n.pos)!=r.pos)i(r,t),t.preventDefault();else if(!o)return;function i(a,u){let f=Oe(e,u),c=U.getState(e.state)==null;if(!f||!Ke(a,f))if(c)f=a;else return;let d=new S(a,f);if(c||!e.state.selection.eq(d)){let h=e.state.tr.setSelection(d);c&&h.setMeta(U,a.pos),e.dispatch(h)}}function l(){e.root.removeEventListener("mouseup",l),e.root.removeEventListener("dragstart",l),e.root.removeEventListener("mousemove",s),U.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(U,-1))}function s(a){let u=a,f=U.getState(e.state),c;if(f!=null)c=e.state.doc.resolve(f);else if(cn(e,u.target)!=o&&(c=Oe(e,t),!c))return l();c&&i(c,u)}e.root.addEventListener("mouseup",l),e.root.addEventListener("dragstart",l),e.root.addEventListener("mousemove",s)}function Nn(e,t,n){if(!(e.state.selection instanceof P))return null;let{$head:o}=e.state.selection;for(let r=o.depth-1;r>=0;r--){let i=o.node(r);if((n<0?o.index(r):o.indexAfter(r))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let l=o.before(r),s=t=="vert"?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(s)?l:null}}return null}function cn(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function Oe(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:o,pos:r}=n;return o>=0&&ie(e.state.doc.resolve(o))||ie(e.state.doc.resolve(r))}var lr=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),We(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,We(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function We(e,t,n,o,r,i){let l=0,s=!0,a=t.firstChild,u=e.firstChild;if(u){for(let c=0,d=0;c<u.childCount;c++){let{colspan:h,colwidth:p}=u.child(c).attrs;for(let g=0;g<h;g++,d++){let b=r==d?i:p&&p[g],w=b?b+"px":"";if(l+=b||o,b||(s=!1),a)a.style.width!=w&&(a.style.width=w),a=a.nextSibling;else{let C=document.createElement("col");C.style.width=w,t.appendChild(C)}}}for(;a;){var f;let c=a.nextSibling;(f=a.parentNode)===null||f===void 0||f.removeChild(a),a=c}s?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var F=new G("tableColumnResizing");function Dn({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:o=lr,lastColumnResizable:r=!0}={}){let i=new Z({key:F,state:{init(l,s){var a;let u=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,f=z(s.schema).table.name;return o&&u&&(u[f]=(c,d)=>new o(c,n,d)),new ir(-1,!1)},apply(l,s){return s.apply(l)}},props:{attributes:l=>{let s=F.getState(l);return s&&s.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,s)=>{ar(l,s,e,r)},mouseleave:l=>{sr(l)},mousedown:(l,s)=>{cr(l,s,t,n)}},decorations:l=>{let s=F.getState(l);if(s&&s.activeHandle>-1)return hr(l,s.activeHandle)},nodeViews:{}}});return i}var ir=class Me{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){let n=this,o=t.getMeta(F);if(o&&o.setHandle!=null)return new Me(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new Me(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return Be(t.doc.resolve(r))||(r=-1),new Me(r,n.dragging)}return n}};function ar(e,t,n,o){if(!e.editable)return;let r=F.getState(e.state);if(r&&!r.dragging){let i=fr(t.target),l=-1;if(i){let{left:s,right:a}=i.getBoundingClientRect();t.clientX-s<=n?l=un(e,t,"left",n):a-t.clientX<=n&&(l=un(e,t,"right",n))}if(l!=r.activeHandle){if(!o&&l!==-1){let s=e.state.doc.resolve(l),a=s.node(-1),u=y.get(a),f=s.start(-1);if(u.colCount(s.pos-f)+s.nodeAfter.attrs.colspan-1==u.width-1)return}Fn(e,l)}}}function sr(e){if(!e.editable)return;let t=F.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Fn(e,-1)}function cr(e,t,n,o){var r;if(!e.editable)return!1;let i=(r=e.dom.ownerDocument.defaultView)!==null&&r!==void 0?r:window,l=F.getState(e.state);if(!l||l.activeHandle==-1||l.dragging)return!1;let s=e.state.doc.nodeAt(l.activeHandle),a=ur(e,l.activeHandle,s.attrs);e.dispatch(e.state.tr.setMeta(F,{setDragging:{startX:t.clientX,startWidth:a}}));function u(c){i.removeEventListener("mouseup",u),i.removeEventListener("mousemove",f);let d=F.getState(e.state);d?.dragging&&(dr(e,d.activeHandle,fn(d.dragging,c,n)),e.dispatch(e.state.tr.setMeta(F,{setDragging:null})))}function f(c){if(!c.which)return u(c);let d=F.getState(e.state);if(d&&d.dragging){let h=fn(d.dragging,c,n);dn(e,d.activeHandle,h,o)}}return dn(e,l.activeHandle,a,o),i.addEventListener("mouseup",u),i.addEventListener("mousemove",f),t.preventDefault(),!0}function ur(e,t,{colspan:n,colwidth:o}){let r=o&&o[o.length-1];if(r)return r;let i=e.domAtPos(t),l=i.node.childNodes[i.offset].offsetWidth,s=n;if(o)for(let a=0;a<n;a++)o[a]&&(l-=o[a],s--);return l/s}function fr(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function un(e,t,n,o){let r=n=="right"?-o:o,i=e.posAtCoords({left:t.clientX+r,top:t.clientY});if(!i)return-1;let{pos:l}=i,s=ie(e.state.doc.resolve(l));if(!s)return-1;if(n=="right")return s.pos;let a=y.get(s.node(-1)),u=s.start(-1),f=a.map.indexOf(s.pos-u);return f%a.width==0?-1:u+a.map[f-1]}function fn(e,t,n){let o=t.clientX-e.startX;return Math.max(n,e.startWidth+o)}function Fn(e,t){e.dispatch(e.state.tr.setMeta(F,{setHandle:t}))}function dr(e,t,n){let o=e.state.doc.resolve(t),r=o.node(-1),i=y.get(r),l=o.start(-1),s=i.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1,a=e.state.tr;for(let u=0;u<i.height;u++){let f=u*i.width+s;if(u&&i.map[f]==i.map[f-i.width])continue;let c=i.map[f],d=r.nodeAt(c).attrs,h=d.colspan==1?0:s-i.colCount(c);if(d.colwidth&&d.colwidth[h]==n)continue;let p=d.colwidth?d.colwidth.slice():pr(d.colspan);p[h]=n,a.setNodeMarkup(l+c,null,{...d,colwidth:p})}a.docChanged&&e.dispatch(a)}function dn(e,t,n,o){let r=e.state.doc.resolve(t),i=r.node(-1),l=r.start(-1),s=y.get(i).colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1,a=e.domAtPos(r.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&We(i,a.firstChild,a,o,s,n)}function pr(e){return Array(e).fill(0)}function hr(e,t){let n=[],o=e.doc.resolve(t),r=o.node(-1);if(!r)return oe.empty;let i=y.get(r),l=o.start(-1),s=i.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let u=0;u<i.height;u++){let f=s+u*i.width;if((s==i.width-1||i.map[f]!=i.map[f+1])&&(u==0||i.map[f]!=i.map[f-i.width])){var a;let c=i.map[f],d=l+c+r.nodeAt(c).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((a=F.getState(e))===null||a===void 0)&&a.dragging&&n.push(ne.node(l+c,l+c+r.nodeAt(c).nodeSize,{class:"column-resize-dragging"})),n.push(ne.widget(d,h))}}return oe.create(e.doc,n)}function Ln({allowTableNodeSelection:e=!1}={}){return new Z({key:U,state:{init(){return null},apply(t,n){let o=t.getMeta(U);if(o!=null)return o==-1?null:o;if(n==null||!t.docChanged)return n;let{deleted:r,pos:i}=t.mapping.mapResult(n);return r?null:i}},props:{decorations:Eo,handleDOMEvents:{mousedown:rr},createSelectionBetween(t){return U.getState(t.state)!=null?t.state.selection:null},handleTripleClick:nr,handleKeyDown:tr,handlePaste:or},appendTransaction(t,n,o){return Oo(o,Ho(o,n),e)}})}var De=typeof navigator<"u"?navigator:null,Ue=De&&De.userAgent||"",mr=/Edge\/(\d+)/.exec(Ue),gr=/MSIE \d/.exec(Ue),wr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ue),br=!!(gr||wr||mr),kr=!br&&!!De&&/Apple Computer/.test(De.vendor),zn=new G("safari-ime-span"),qe=!1,Cr={key:zn,props:{decorations:yr,handleDOMEvents:{compositionstart:()=>{qe=!0},compositionend:()=>{qe=!1}}}};function yr(e){let{$from:t,$to:n,to:o}=e.selection;if(qe&&t.sameParent(n)){let r=ne.widget(o,xr,{ignoreSelection:!0,key:"safari-ime-span"});return oe.create(e.doc,[r])}}function xr(e){let t=e.dom.ownerDocument.createElement("span");return t.className="ProseMirror-safari-ime-span",t}var In=new Z(kr?Cr:{key:zn});function Xe(e,t){let n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let o=0,r=n.indexOf(t);for(;r!==-1;)o++,r=n.indexOf(t,r+t.length);return o}var Je="phrasing",Ye=["autolink","link","image","label"];function Qe(){return{transforms:[Mr],enter:{literalAutolink:Sr,literalAutolinkEmail:Ze,literalAutolinkHttp:Ze,literalAutolinkWww:Ze},exit:{literalAutolink:vr,literalAutolinkEmail:Tr,literalAutolinkHttp:Ar,literalAutolinkWww:Rr}}}function et(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Je,notInConstruct:Ye},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Je,notInConstruct:Ye},{character:":",before:"[ps]",after:"\\/",inConstruct:Je,notInConstruct:Ye}]}}function Sr(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Ze(e){this.config.enter.autolinkProtocol.call(this,e)}function Ar(e){this.config.exit.autolinkProtocol.call(this,e)}function Rr(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function Tr(e){this.config.exit.autolinkEmail.call(this,e)}function vr(e){this.exit(e)}function Mr(e){Zt(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Nr],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Dr]],{ignore:["link","linkReference"]})}function Nr(e,t,n,o,r){let i="";if(!En(r)||(/^w/i.test(t)&&(n=t+n,t="",i="http://"),!Fr(n)))return!1;let l=Lr(n+o);if(!l[0])return!1;let s={type:"link",title:null,url:i+t+l[0],children:[{type:"text",value:t+l[0]}]};return l[1]?[s,{type:"text",value:l[1]}]:s}function Dr(e,t,n,o){return!En(o,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Fr(e){let t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function Lr(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],o=n.indexOf(")"),r=Xe(e,"("),i=Xe(e,")");for(;o!==-1&&r>i;)e+=n.slice(0,o+1),n=n.slice(o+1),o=n.indexOf(")"),i++;return[e,n]}function En(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||V(n)||fe(n))&&(!t||n!==47)}_n.peek=Br;function zr(){this.buffer()}function Ir(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Er(){this.buffer()}function _r(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Pr(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=J(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Or(e){this.exit(e)}function $r(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=J(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Hr(e){this.exit(e)}function Br(){return"["}function _n(e,t,n,o){let r=n.createTracker(o),i=r.move("[^"),l=n.enter("footnoteReference"),s=n.enter("reference");return i+=r.move(n.safe(n.associationId(e),{after:"]",before:i})),s(),l(),i+=r.move("]"),i}function tt(){return{enter:{gfmFootnoteCallString:zr,gfmFootnoteCall:Ir,gfmFootnoteDefinitionLabelString:Er,gfmFootnoteDefinition:_r},exit:{gfmFootnoteCallString:Pr,gfmFootnoteCall:Or,gfmFootnoteDefinitionLabelString:$r,gfmFootnoteDefinition:Hr}}}function nt(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:_n},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(o,r,i,l){let s=i.createTracker(l),a=s.move("[^"),u=i.enter("footnoteDefinition"),f=i.enter("label");return a+=s.move(i.safe(i.associationId(o),{before:a,after:"]"})),f(),a+=s.move("]:"),o.children&&o.children.length>0&&(s.shift(4),a+=s.move((t?`
|
|
2
|
+
`:" ")+i.indentLines(i.containerFlow(o,s.current()),t?Pn:jr))),u(),a}}function jr(e,t,n){return t===0?e:Pn(e,t,n)}function Pn(e,t,n){return(n?"":" ")+e}var Wr=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];On.peek=Gr;function ot(){return{canContainEols:["delete"],enter:{strikethrough:Kr},exit:{strikethrough:Vr}}}function rt(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Wr}],handlers:{delete:On}}}function Kr(e){this.enter({type:"delete",children:[]},e)}function Vr(e){this.exit(e)}function On(e,t,n,o){let r=n.createTracker(o),i=n.enter("strikethrough"),l=r.move("~~");return l+=n.containerPhrasing(e,{...r.current(),before:l,after:"~"}),l+=r.move("~~"),i(),l}function Gr(){return"~"}function qr(e){return e.length}function Hn(e,t){let n=t||{},o=(n.align||[]).concat(),r=n.stringLength||qr,i=[],l=[],s=[],a=[],u=0,f=-1;for(;++f<e.length;){let g=[],b=[],w=-1;for(e[f].length>u&&(u=e[f].length);++w<e[f].length;){let C=Ur(e[f][w]);if(n.alignDelimiters!==!1){let x=r(C);b[w]=x,(a[w]===void 0||x>a[w])&&(a[w]=x)}g.push(C)}l[f]=g,s[f]=b}let c=-1;if(typeof o=="object"&&"length"in o)for(;++c<u;)i[c]=$n(o[c]);else{let g=$n(o);for(;++c<u;)i[c]=g}c=-1;let d=[],h=[];for(;++c<u;){let g=i[c],b="",w="";g===99?(b=":",w=":"):g===108?b=":":g===114&&(w=":");let C=n.alignDelimiters===!1?1:Math.max(1,a[c]-b.length-w.length),x=b+"-".repeat(C)+w;n.alignDelimiters!==!1&&(C=b.length+C+w.length,C>a[c]&&(a[c]=C),h[c]=C),d[c]=x}l.splice(1,0,d),s.splice(1,0,h),f=-1;let p=[];for(;++f<l.length;){let g=l[f],b=s[f];c=-1;let w=[];for(;++c<u;){let C=g[c]||"",x="",R="";if(n.alignDelimiters!==!1){let A=a[c]-(b[c]||0),E=i[c];E===114?x=" ".repeat(A):E===99?A%2?(x=" ".repeat(A/2+.5),R=" ".repeat(A/2-.5)):(x=" ".repeat(A/2),R=x):R=" ".repeat(A)}n.delimiterStart!==!1&&!c&&w.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&C==="")&&(n.delimiterStart!==!1||c)&&w.push(" "),n.alignDelimiters!==!1&&w.push(x),w.push(C),n.alignDelimiters!==!1&&w.push(R),n.padding!==!1&&w.push(" "),(n.delimiterEnd!==!1||c!==u-1)&&w.push("|")}p.push(n.delimiterEnd===!1?w.join("").replace(/ +$/,""):w.join(""))}return p.join(`
|
|
3
|
+
`)}function Ur(e){return e==null?"":String(e)}function $n(e){let t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function it(){return{enter:{table:Xr,tableData:Bn,tableHeader:Bn,tableRow:Yr},exit:{codeText:Zr,table:Jr,tableData:lt,tableHeader:lt,tableRow:lt}}}function Xr(e){let t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function Jr(e){this.exit(e),this.data.inTable=void 0}function Yr(e){this.enter({type:"tableRow",children:[]},e)}function lt(e){this.exit(e)}function Bn(e){this.enter({type:"tableCell",children:[]},e)}function Zr(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Qr));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Qr(e,t){return t==="|"?t:e}function at(e){let t=e||{},n=t.tableCellPadding,o=t.tablePipeAlign,r=t.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
4
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:d,table:l,tableCell:a,tableRow:s}};function l(h,p,g,b){return u(f(h,g,b),h.align)}function s(h,p,g,b){let w=c(h,g,b),C=u([w]);return C.slice(0,C.indexOf(`
|
|
5
|
+
`))}function a(h,p,g,b){let w=g.enter("tableCell"),C=g.enter("phrasing"),x=g.containerPhrasing(h,{...b,before:i,after:i});return C(),w(),x}function u(h,p){return Hn(h,{align:p,alignDelimiters:o,padding:n,stringLength:r})}function f(h,p,g){let b=h.children,w=-1,C=[],x=p.enter("table");for(;++w<b.length;)C[w]=c(b[w],p,g);return x(),C}function c(h,p,g){let b=h.children,w=-1,C=[],x=p.enter("tableRow");for(;++w<b.length;)C[w]=a(b[w],h,p,g);return x(),C}function d(h,p,g){let b=ye.inlineCode(h,p,g);return g.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function st(){return{exit:{taskListCheckValueChecked:jn,taskListCheckValueUnchecked:jn,paragraph:el}}}function ct(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:tl}}}function jn(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function el(e){let t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){let n=this.stack[this.stack.length-1];n.type;let o=n.children[0];if(o&&o.type==="text"){let r=t.children,i=-1,l;for(;++i<r.length;){let s=r[i];if(s.type==="paragraph"){l=s;break}}l===n&&(o.value=o.value.slice(1),o.value.length===0?n.children.shift():n.position&&o.position&&typeof o.position.start.offset=="number"&&(o.position.start.column++,o.position.start.offset++,n.position.start=Object.assign({},o.position.start)))}}this.exit(e)}function tl(e,t,n,o){let r=e.children[0],i=typeof e.checked=="boolean"&&r&&r.type==="paragraph",l="["+(e.checked?"x":" ")+"] ",s=n.createTracker(o);i&&s.move(l);let a=ye.listItem(e,t,n,{...o,...s.current()});return i&&(a=a.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),a;function u(f){return f+l}}function ut(){return[Qe(),tt(),ot(),it(),st()]}function ft(e){return{extensions:[et(),nt(e),rt(),at(e),ct()]}}var nl={tokenize:al,partial:!0},Wn={tokenize:sl,partial:!0},Kn={tokenize:cl,partial:!0},Vn={tokenize:ul,partial:!0},ol={tokenize:fl,partial:!0},Gn={name:"wwwAutolink",tokenize:ll,previous:Un},qn={name:"protocolAutolink",tokenize:il,previous:Xn},B={name:"emailAutolink",tokenize:rl,previous:Jn},O={};function pt(){return{text:O}}var ee=48;for(;ee<123;)O[ee]=B,ee++,ee===58?ee=65:ee===91&&(ee=97);O[43]=B;O[45]=B;O[46]=B;O[95]=B;O[72]=[B,qn];O[104]=[B,qn];O[87]=[B,Gn];O[119]=[B,Gn];function rl(e,t,n){let o=this,r,i;return l;function l(c){return!dt(c)||!Jn.call(o,o.previous)||ht(o.events)?n(c):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(c))}function s(c){return dt(c)?(e.consume(c),s):c===64?(e.consume(c),a):n(c)}function a(c){return c===46?e.check(ol,f,u)(c):c===45||c===95||Ce(c)?(i=!0,e.consume(c),a):f(c)}function u(c){return e.consume(c),r=!0,a}function f(c){return i&&r&&te(o.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(c)):n(c)}}function ll(e,t,n){let o=this;return r;function r(l){return l!==87&&l!==119||!Un.call(o,o.previous)||ht(o.events)?n(l):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(nl,e.attempt(Wn,e.attempt(Kn,i),n),n)(l))}function i(l){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(l)}}function il(e,t,n){let o=this,r="",i=!1;return l;function l(c){return(c===72||c===104)&&Xn.call(o,o.previous)&&!ht(o.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),r+=String.fromCodePoint(c),e.consume(c),s):n(c)}function s(c){if(te(c)&&r.length<5)return r+=String.fromCodePoint(c),e.consume(c),s;if(c===58){let d=r.toLowerCase();if(d==="http"||d==="https")return e.consume(c),a}return n(c)}function a(c){return c===47?(e.consume(c),i?u:(i=!0,a)):n(c)}function u(c){return c===null||_t(c)||T(c)||V(c)||fe(c)?n(c):e.attempt(Wn,e.attempt(Kn,f),n)(c)}function f(c){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(c)}}function al(e,t,n){let o=0;return r;function r(l){return(l===87||l===119)&&o<3?(o++,e.consume(l),r):l===46&&o===3?(e.consume(l),i):n(l)}function i(l){return l===null?n(l):t(l)}}function sl(e,t,n){let o,r,i;return l;function l(u){return u===46||u===95?e.check(Vn,a,s)(u):u===null||T(u)||V(u)||u!==45&&fe(u)?a(u):(i=!0,e.consume(u),l)}function s(u){return u===95?o=!0:(r=o,o=void 0),e.consume(u),l}function a(u){return r||o||!i?n(u):t(u)}}function cl(e,t){let n=0,o=0;return r;function r(l){return l===40?(n++,e.consume(l),r):l===41&&o<n?i(l):l===33||l===34||l===38||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===60||l===63||l===93||l===95||l===126?e.check(Vn,t,i)(l):l===null||T(l)||V(l)?t(l):(e.consume(l),r)}function i(l){return l===41&&o++,e.consume(l),r}}function ul(e,t,n){return o;function o(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),o):s===38?(e.consume(s),i):s===93?(e.consume(s),r):s===60||s===null||T(s)||V(s)?t(s):n(s)}function r(s){return s===null||s===40||s===91||T(s)||V(s)?t(s):o(s)}function i(s){return te(s)?l(s):n(s)}function l(s){return s===59?(e.consume(s),o):te(s)?(e.consume(s),l):n(s)}}function fl(e,t,n){return o;function o(i){return e.consume(i),r}function r(i){return Ce(i)?n(i):t(i)}}function Un(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||T(e)}function Xn(e){return!te(e)}function Jn(e){return!(e===47||dt(e))}function dt(e){return e===43||e===45||e===46||e===95||Ce(e)}function ht(e){let t=e.length,n=!1;for(;t--;){let o=e[t][1];if((o.type==="labelLink"||o.type==="labelImage")&&!o._balanced){n=!0;break}if(o._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var dl={tokenize:kl,partial:!0};function mt(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:gl,continuation:{tokenize:wl},exit:bl}},text:{91:{name:"gfmFootnoteCall",tokenize:ml},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:pl,resolveTo:hl}}}}function pl(e,t,n){let o=this,r=o.events.length,i=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),l;for(;r--;){let a=o.events[r][1];if(a.type==="labelImage"){l=a;break}if(a.type==="gfmFootnoteCall"||a.type==="labelLink"||a.type==="label"||a.type==="image"||a.type==="link")break}return s;function s(a){if(!l||!l._balanced)return n(a);let u=J(o.sliceSerialize({start:l.end,end:o.now()}));return u.codePointAt(0)!==94||!i.includes(u.slice(1))?n(a):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(a),e.exit("gfmFootnoteCallLabelMarker"),t(a))}}function hl(e,t){let n=e.length,o;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){o=e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";let r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let l={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},l.start),end:Object.assign({},l.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",l,t],["enter",s,t],["exit",s,t],["exit",l,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function ml(e,t,n){let o=this,r=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),i=0,l;return s;function s(c){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),a}function a(c){return c!==94?n(c):(e.enter("gfmFootnoteCallMarker"),e.consume(c),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(c){if(i>999||c===93&&!l||c===null||c===91||T(c))return n(c);if(c===93){e.exit("chunkString");let d=e.exit("gfmFootnoteCallString");return r.includes(J(o.sliceSerialize(d)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(c)}return T(c)||(l=!0),i++,e.consume(c),c===92?f:u}function f(c){return c===91||c===92||c===93?(e.consume(c),i++,u):u(c)}}function gl(e,t,n){let o=this,r=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),i,l=0,s;return a;function a(p){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(p),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(p){return p===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(p),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):n(p)}function f(p){if(l>999||p===93&&!s||p===null||p===91||T(p))return n(p);if(p===93){e.exit("chunkString");let g=e.exit("gfmFootnoteDefinitionLabelString");return i=J(o.sliceSerialize(g)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(p),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return T(p)||(s=!0),l++,e.consume(p),p===92?c:f}function c(p){return p===91||p===92||p===93?(e.consume(p),l++,f):f(p)}function d(p){return p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),r.includes(i)||r.push(i),I(e,h,"gfmFootnoteDefinitionWhitespace")):n(p)}function h(p){return t(p)}}function wl(e,t,n){return e.check(Ot,t,e.attempt(dl,t,n))}function bl(e){e.exit("gfmFootnoteDefinition")}function kl(e,t,n){let o=this;return I(e,r,"gfmFootnoteDefinitionIndent",5);function r(i){let l=o.events[o.events.length-1];return l&&l[1].type==="gfmFootnoteDefinitionIndent"&&l[2].sliceSerialize(l[1],!0).length===4?t(i):n(i)}}function gt(e){let n=(e||{}).singleTilde,o={name:"strikethrough",tokenize:i,resolveAll:r};return n==null&&(n=!0),{text:{126:o},insideSpan:{null:[o]},attentionMarkers:{null:[126]}};function r(l,s){let a=-1;for(;++a<l.length;)if(l[a][0]==="enter"&&l[a][1].type==="strikethroughSequenceTemporary"&&l[a][1]._close){let u=a;for(;u--;)if(l[u][0]==="exit"&&l[u][1].type==="strikethroughSequenceTemporary"&&l[u][1]._open&&l[a][1].end.offset-l[a][1].start.offset===l[u][1].end.offset-l[u][1].start.offset){l[a][1].type="strikethroughSequence",l[u][1].type="strikethroughSequence";let f={type:"strikethrough",start:Object.assign({},l[u][1].start),end:Object.assign({},l[a][1].end)},c={type:"strikethroughText",start:Object.assign({},l[u][1].end),end:Object.assign({},l[a][1].start)},d=[["enter",f,s],["enter",l[u][1],s],["exit",l[u][1],s],["enter",c,s]],h=s.parser.constructs.insideSpan.null;h&&ke(d,d.length,0,Pt(h,l.slice(u+1,a),s)),ke(d,d.length,0,[["exit",c,s],["enter",l[a][1],s],["exit",l[a][1],s],["exit",f,s]]),ke(l,u-1,a-u+3,d),a=u+d.length-2;break}}for(a=-1;++a<l.length;)l[a][1].type==="strikethroughSequenceTemporary"&&(l[a][1].type="data");return l}function i(l,s,a){let u=this.previous,f=this.events,c=0;return d;function d(p){return u===126&&f[f.length-1][1].type!=="characterEscape"?a(p):(l.enter("strikethroughSequenceTemporary"),h(p))}function h(p){let g=Ie(u);if(p===126)return c>1?a(p):(l.consume(p),c++,h);if(c<2&&!n)return a(p);let b=l.exit("strikethroughSequenceTemporary"),w=Ie(p);return b._open=!w||w===2&&!!g,b._close=!g||g===2&&!!w,s(p)}}}var Fe=class{constructor(){this.map=[]}add(t,n,o){Cl(this,t,n,o)}consume(t){if(this.map.sort(function(i,l){return i[0]-l[0]}),this.map.length===0)return;let n=this.map.length,o=[];for(;n>0;)n-=1,o.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];o.push(t.slice()),t.length=0;let r=o.pop();for(;r;){for(let i of r)t.push(i);r=o.pop()}this.map.length=0}};function Cl(e,t,n,o){let r=0;if(!(n===0&&o.length===0)){for(;r<e.map.length;){if(e.map[r][0]===t){e.map[r][1]+=n,e.map[r][2].push(...o);return}r+=1}e.map.push([t,n,o])}}function Yn(e,t){let n=!1,o=[];for(;t<e.length;){let r=e[t];if(n){if(r[0]==="enter")r[1].type==="tableContent"&&o.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(r[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){let i=o.length-1;o[i]=o[i]==="left"?"center":"right"}}else if(r[1].type==="tableDelimiterRow")break}else r[0]==="enter"&&r[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return o}function wt(){return{flow:{null:{name:"table",tokenize:yl,resolveAll:xl}}}}function yl(e,t,n){let o=this,r=0,i=0,l;return s;function s(m){let ue=o.events.length-1;for(;ue>-1;){let It=o.events[ue][1].type;if(It==="lineEnding"||It==="linePrefix")ue--;else break}let Lt=ue>-1?o.events[ue][1].type:null,zt=Lt==="tableHead"||Lt==="tableRow"?E:a;return zt===E&&o.parser.lazy[o.now().line]?n(m):zt(m)}function a(m){return e.enter("tableHead"),e.enter("tableRow"),u(m)}function u(m){return m===124||(l=!0,i+=1),f(m)}function f(m){return m===null?n(m):Y(m)?i>1?(i=0,o.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),h):n(m):K(m)?I(e,f,"whitespace")(m):(i+=1,l&&(l=!1,r+=1),m===124?(e.enter("tableCellDivider"),e.consume(m),e.exit("tableCellDivider"),l=!0,f):(e.enter("data"),c(m)))}function c(m){return m===null||m===124||T(m)?(e.exit("data"),f(m)):(e.consume(m),m===92?d:c)}function d(m){return m===92||m===124?(e.consume(m),c):c(m)}function h(m){return o.interrupt=!1,o.parser.lazy[o.now().line]?n(m):(e.enter("tableDelimiterRow"),l=!1,K(m)?I(e,p,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):p(m))}function p(m){return m===45||m===58?b(m):m===124?(l=!0,e.enter("tableCellDivider"),e.consume(m),e.exit("tableCellDivider"),g):A(m)}function g(m){return K(m)?I(e,b,"whitespace")(m):b(m)}function b(m){return m===58?(i+=1,l=!0,e.enter("tableDelimiterMarker"),e.consume(m),e.exit("tableDelimiterMarker"),w):m===45?(i+=1,w(m)):m===null||Y(m)?R(m):A(m)}function w(m){return m===45?(e.enter("tableDelimiterFiller"),C(m)):A(m)}function C(m){return m===45?(e.consume(m),C):m===58?(l=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(m),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(m))}function x(m){return K(m)?I(e,R,"whitespace")(m):R(m)}function R(m){return m===124?p(m):m===null||Y(m)?!l||r!==i?A(m):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(m)):A(m)}function A(m){return n(m)}function E(m){return e.enter("tableRow"),_(m)}function _(m){return m===124?(e.enter("tableCellDivider"),e.consume(m),e.exit("tableCellDivider"),_):m===null||Y(m)?(e.exit("tableRow"),t(m)):K(m)?I(e,_,"whitespace")(m):(e.enter("data"),W(m))}function W(m){return m===null||m===124||T(m)?(e.exit("data"),_(m)):(e.consume(m),m===92?Ao:W)}function Ao(m){return m===92||m===124?(e.consume(m),W):W(m)}}function xl(e,t){let n=-1,o=!0,r=0,i=[0,0,0,0],l=[0,0,0,0],s=!1,a=0,u,f,c,d=new Fe;for(;++n<e.length;){let h=e[n],p=h[1];h[0]==="enter"?p.type==="tableHead"?(s=!1,a!==0&&(Zn(d,t,a,u,f),f=void 0,a=0),u={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},d.add(n,0,[["enter",u,t]])):p.type==="tableRow"||p.type==="tableDelimiterRow"?(o=!0,c=void 0,i=[0,0,0,0],l=[0,n+1,0,0],s&&(s=!1,f={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},d.add(n,0,[["enter",f,t]])),r=p.type==="tableDelimiterRow"?2:f?3:1):r&&(p.type==="data"||p.type==="tableDelimiterMarker"||p.type==="tableDelimiterFiller")?(o=!1,l[2]===0&&(i[1]!==0&&(l[0]=l[1],c=Le(d,t,i,r,void 0,c),i=[0,0,0,0]),l[2]=n)):p.type==="tableCellDivider"&&(o?o=!1:(i[1]!==0&&(l[0]=l[1],c=Le(d,t,i,r,void 0,c)),i=l,l=[i[1],n,0,0])):p.type==="tableHead"?(s=!0,a=n):p.type==="tableRow"||p.type==="tableDelimiterRow"?(a=n,i[1]!==0?(l[0]=l[1],c=Le(d,t,i,r,n,c)):l[1]!==0&&(c=Le(d,t,l,r,n,c)),r=0):r&&(p.type==="data"||p.type==="tableDelimiterMarker"||p.type==="tableDelimiterFiller")&&(l[3]=n)}for(a!==0&&Zn(d,t,a,u,f),d.consume(t.events),n=-1;++n<t.events.length;){let h=t.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=Yn(t.events,n))}return e}function Le(e,t,n,o,r,i){let l=o===1?"tableHeader":o===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(i.end=Object.assign({},ae(t.events,n[0])),e.add(n[0],0,[["exit",i,t]]));let a=ae(t.events,n[1]);if(i={type:l,start:Object.assign({},a),end:Object.assign({},a)},e.add(n[1],0,[["enter",i,t]]),n[2]!==0){let u=ae(t.events,n[2]),f=ae(t.events,n[3]),c={type:s,start:Object.assign({},u),end:Object.assign({},f)};if(e.add(n[2],0,[["enter",c,t]]),o!==2){let d=t.events[n[2]],h=t.events[n[3]];if(d[1].end=Object.assign({},h[1].end),d[1].type="chunkText",d[1].contentType="text",n[3]>n[2]+1){let p=n[2]+1,g=n[3]-n[2]-1;e.add(p,g,[])}}e.add(n[3]+1,0,[["exit",c,t]])}return r!==void 0&&(i.end=Object.assign({},ae(t.events,r)),e.add(r,0,[["exit",i,t]]),i=void 0),i}function Zn(e,t,n,o,r){let i=[],l=ae(t.events,n);r&&(r.end=Object.assign({},l),i.push(["exit",r,t])),o.end=Object.assign({},l),i.push(["exit",o,t]),e.add(n+1,0,i)}function ae(e,t){let n=e[t],o=n[0]==="enter"?"start":"end";return n[1][o]}var Sl={name:"tasklistCheck",tokenize:Al};function bt(){return{text:{91:Sl}}}function Al(e,t,n){let o=this;return r;function r(a){return o.previous!==null||!o._gfmTasklistFirstContentOfListItem?n(a):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(a),e.exit("taskListCheckMarker"),i)}function i(a){return T(a)?(e.enter("taskListCheckValueUnchecked"),e.consume(a),e.exit("taskListCheckValueUnchecked"),l):a===88||a===120?(e.enter("taskListCheckValueChecked"),e.consume(a),e.exit("taskListCheckValueChecked"),l):n(a)}function l(a){return a===93?(e.enter("taskListCheckMarker"),e.consume(a),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(a)}function s(a){return Y(a)?t(a):K(a)?e.check({tokenize:Rl},t,n)(a):n(a)}}function Rl(e,t,n){return I(e,o,"whitespace");function o(r){return r===null?n(r):t(r)}}function Qn(e){return Et([pt(),mt(),gt(e),wt(),bt()])}var Tl={};function ze(e){let t=this,n=e||Tl,o=t.data(),r=o.micromarkExtensions||(o.micromarkExtensions=[]),i=o.fromMarkdownExtensions||(o.fromMarkdownExtensions=[]),l=o.toMarkdownExtensions||(o.toMarkdownExtensions=[]);r.push(Qn(n)),i.push(ut()),l.push(ft(n))}function k(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-gfm",...t}}),e}var yt=Xt("strike_through");k(yt,{displayName:"Attr<strikethrough>",group:"Strikethrough"});var he=Ut("strike_through",e=>({parseDOM:[{tag:"del"},{style:"text-decoration",getAttrs:t=>t==="line-through"}],toDOM:t=>["del",e.get(yt.key)(t)],parseMarkdown:{match:t=>t.type==="delete",runner:(t,n,o)=>{t.openMark(o),t.next(n.children),t.closeMark(o)}},toMarkdown:{match:t=>t.type.name==="strike_through",runner:(t,n)=>{t.withMark(n,"delete")}}}));k(he.mark,{displayName:"MarkSchema<strikethrough>",group:"Strikethrough"});k(he.ctx,{displayName:"MarkSchemaCtx<strikethrough>",group:"Strikethrough"});var xt=M("ToggleStrikeThrough",e=>()=>jt(he.type(e)));k(xt,{displayName:"Command<ToggleStrikethrough>",group:"Strikethrough"});var to=xe(e=>Wt(/(?<![\w:/])(~{1,2})(.+?)\1(?!\w|\/)$/,he.type(e)));k(to,{displayName:"InputRule<strikethrough>",group:"Strikethrough"});var St=Pe("strikeThroughKeymap",{ToggleStrikethrough:{shortcuts:"Mod-Alt-x",command:e=>{let t=e.get(de);return()=>t.call(xt.key)}}});k(St.ctx,{displayName:"KeymapCtx<strikethrough>",group:"Strikethrough"});k(St.shortcuts,{displayName:"Keymap<strikethrough>",group:"Strikethrough"});var me=pn({tableGroup:"block",cellContent:"paragraph",cellAttributes:{alignment:{default:"left",getFromDOM:e=>e.style.textAlign||"left",setDOMAttr:(e,t)=>{t.style=`text-align: ${e||"left"}`}}}}),j=q("table",()=>({...me.table,content:"table_header_row table_row+",disableDropCursor:!0,parseMarkdown:{match:e=>e.type==="table",runner:(e,t,n)=>{let o=t.align,r=t.children.map((i,l)=>({...i,align:o,isHeader:l===0}));e.openNode(n),e.next(r),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="table",runner:(e,t)=>{let n=t.content.firstChild?.content;if(!n)return;let o=[];n.forEach(r=>{o.push(r.attrs.alignment)}),e.openNode("table",void 0,{align:o}),e.next(t.content),e.closeNode()}}}));k(j.node,{displayName:"NodeSchema<table>",group:"Table"});k(j.ctx,{displayName:"NodeSchemaCtx<table>",group:"Table"});var ge=q("table_header_row",()=>({...me.table_row,disableDropCursor:!0,content:"(table_header)*",parseDOM:[{tag:"tr[data-is-header]"},{tag:"tr",getAttrs:e=>e instanceof HTMLElement&&e.querySelector("th")?{}:!1}],toDOM(){return["tr",{"data-is-header":!0},0]},parseMarkdown:{match:e=>!!(e.type==="tableRow"&&e.isHeader),runner:(e,t,n)=>{let o=t.align,r=t.children.map((i,l)=>({...i,align:o[l],isHeader:t.isHeader}));e.openNode(n),e.next(r),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="table_header_row",runner:(e,t)=>{t.content.size!==0&&(e.openNode("tableRow",void 0,{isHeader:!0}),e.next(t.content),e.closeNode())}}}));k(ge.node,{displayName:"NodeSchema<tableHeaderRow>",group:"Table"});k(ge.ctx,{displayName:"NodeSchemaCtx<tableHeaderRow>",group:"Table"});var ce=q("table_row",()=>({...me.table_row,disableDropCursor:!0,content:"(table_cell)*",parseMarkdown:{match:e=>e.type==="tableRow",runner:(e,t,n)=>{let o=t.align,r=t.children.map((i,l)=>({...i,align:o[l]}));e.openNode(n),e.next(r),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="table_row",runner:(e,t)=>{t.content.size!==0&&(e.openNode("tableRow"),e.next(t.content),e.closeNode())}}}));k(ce.node,{displayName:"NodeSchema<tableRow>",group:"Table"});k(ce.ctx,{displayName:"NodeSchemaCtx<tableRow>",group:"Table"});var we=q("table_cell",()=>({...me.table_cell,disableDropCursor:!0,parseMarkdown:{match:e=>e.type==="tableCell"&&!e.isHeader,runner:(e,t,n)=>{let o=t.align;e.openNode(n,{alignment:o}).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode()}},toMarkdown:{match:e=>e.type.name==="table_cell",runner:(e,t)=>{e.openNode("tableCell").next(t.content).closeNode()}}}));k(we.node,{displayName:"NodeSchema<tableCell>",group:"Table"});k(we.ctx,{displayName:"NodeSchemaCtx<tableCell>",group:"Table"});var se=q("table_header",()=>({...me.table_header,disableDropCursor:!0,parseMarkdown:{match:e=>e.type==="tableCell"&&!!e.isHeader,runner:(e,t,n)=>{let o=t.align;e.openNode(n,{alignment:o}),e.openNode(e.schema.nodes.paragraph),e.next(t.children),e.closeNode(),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="table_header",runner:(e,t)=>{e.openNode("tableCell"),e.next(t.content),e.closeNode()}}}));k(se.node,{displayName:"NodeSchema<tableHeader>",group:"Table"});k(se.ctx,{displayName:"NodeSchemaCtx<tableHeader>",group:"Table"});function no(e,t=3,n=3){let o=Array(n).fill(0).map(()=>we.type(e).createAndFill()),r=Array(n).fill(0).map(()=>se.type(e).createAndFill()),i=Array(t).fill(0).map((l,s)=>s===0?ge.type(e).create(null,r):ce.type(e).create(null,o));return j.type(e).create(null,i)}function Ba(e,t){let n=X(t.$from);if(!n)return;let o=y.get(n.node);return(Array.isArray(e)?e:[e]).filter(r=>r>=0&&r<=o.width-1).flatMap(r=>o.cellsInRect({left:r,right:r+1,top:0,bottom:o.height}).map(i=>{let l=n.node.nodeAt(i),s=i+n.start;return{pos:s,start:s+1,node:l,depth:n.depth+2}}))}function ja(e,t){let n=X(t.$from);if(!n)return;let o=y.get(n.node);return(Array.isArray(e)?e:[e]).filter(r=>r>=0&&r<=o.height-1).flatMap(r=>o.cellsInRect({left:0,right:o.width,top:r,bottom:r+1}).map(i=>{let l=n.node.nodeAt(i),s=i+n.start;return{pos:s,start:s+1,node:l,depth:n.depth+2}}))}function oo(e){return(t,n)=>o=>{n=n??o.selection.from;let r=o.doc.resolve(n),i=Vt(a=>a.type.name==="table")(r),l=i?{node:i.node,from:i.start}:void 0,s=e==="row";if(l){let a=y.get(l.node);if(t>=0&&t<(s?a.height:a.width)){let u=a.positionAt(s?t:a.height-1,s?a.width-1:t,l.node),f=o.doc.resolve(l.from+u),c=s?S.rowSelection:S.colSelection,d=a.positionAt(s?t:0,s?0:t,l.node),h=o.doc.resolve(l.from+d);return _e(o.setSelection(c(f,h)))}}return o}}var vl=oo("row"),Ml=oo("col");function ro(e,t,{map:n,tableStart:o,table:r},i){let l=Array(i).fill(0).reduce((a,u,f)=>a+r.child(f).nodeSize,o),s=Array(n.width).fill(0).map((a,u)=>{let f=r.nodeAt(n.map[u]);return we.type(e).createAndFill({alignment:f?.attrs.alignment})});return t.insert(l,ce.type(e).create(null,s)),t}function Nl(e){let t=X(e.$from);if(!t)return;let n=y.get(t.node);return n.cellsInRect({left:0,right:n.width,top:0,bottom:n.height}).map(o=>{let r=t.node.nodeAt(o),i=o+t.start;return{pos:i,start:i+1,node:r}})}function Dl(e){let t=Nl(e.selection);if(t&&t[0]){let n=e.doc.resolve(t[0].pos),o=t[t.length-1];if(o){let r=e.doc.resolve(o.pos);return _e(e.setSelection(new S(r,n)))}}return e}var At=M("GoToPrevTableCell",()=>()=>Ge(-1));k(At,{displayName:"Command<goToPrevTableCellCommand>",group:"Table"});var Rt=M("GoToNextTableCell",()=>()=>Ge(1));k(Rt,{displayName:"Command<goToNextTableCellCommand>",group:"Table"});var Tt=M("ExitTable",e=>()=>(t,n)=>{if(!L(t))return!1;let{$head:o}=t.selection,r=Kt(o,j.type(e));if(!r)return!1;let{to:i}=r,l=t.tr.replaceWith(i,i,Se.type(e).createAndFill());return l.setSelection(D.near(l.doc.resolve(i),1)).scrollIntoView(),n?.(l),!0});k(Tt,{displayName:"Command<breakTableCommand>",group:"Table"});var lo=M("InsertTable",e=>({row:t,col:n}={})=>(o,r)=>{let{selection:i,tr:l}=o,{from:s}=i,a=no(e,t,n),u=l.replaceSelectionWith(a),f=D.findFrom(u.doc.resolve(s),1,!0);return f&&u.setSelection(f),r?.(u),!0});k(lo,{displayName:"Command<insertTableCommand>",group:"Table"});var io=M("MoveRow",()=>({from:e,to:t,pos:n}={})=>vn({from:e??0,to:t??0,pos:n}));k(io,{displayName:"Command<moveRowCommand>",group:"Table"});var ao=M("MoveCol",()=>({from:e,to:t,pos:n}={})=>Mn({from:e??0,to:t??0,pos:n}));k(ao,{displayName:"Command<moveColCommand>",group:"Table"});var so=M("SelectRow",()=>(e={index:0})=>(t,n)=>{let{tr:o}=t;return!!n?.(vl(e.index,e.pos)(o))});k(so,{displayName:"Command<selectRowCommand>",group:"Table"});var co=M("SelectCol",()=>(e={index:0})=>(t,n)=>{let{tr:o}=t;return!!n?.(Ml(e.index,e.pos)(o))});k(co,{displayName:"Command<selectColCommand>",group:"Table"});var uo=M("SelectTable",()=>()=>(e,t)=>{let{tr:n}=e;return!!t?.(Dl(n))});k(uo,{displayName:"Command<selectTableCommand>",group:"Table"});var fo=M("DeleteSelectedCells",()=>()=>(e,t)=>{let{selection:n}=e;if(!(n instanceof S))return!1;let o=n.isRowSelection(),r=n.isColSelection();return o&&r?Tn(e,t):r?Sn(e,t):An(e,t)});k(fo,{displayName:"Command<deleteSelectedCellsCommand>",group:"Table"});var po=M("AddColBefore",()=>()=>yn);k(po,{displayName:"Command<addColBeforeCommand>",group:"Table"});var ho=M("AddColAfter",()=>()=>xn);k(ho,{displayName:"Command<addColAfterCommand>",group:"Table"});var mo=M("AddRowBefore",e=>()=>(t,n)=>{if(!L(t))return!1;if(n){let o=H(t);n(ro(e,t.tr,o,o.top))}return!0});k(mo,{displayName:"Command<addRowBeforeCommand>",group:"Table"});var go=M("AddRowAfter",e=>()=>(t,n)=>{if(!L(t))return!1;if(n){let o=H(t);n(ro(e,t.tr,o,o.bottom))}return!0});k(go,{displayName:"Command<addRowAfterCommand>",group:"Table"});var wo=M("SetAlign",()=>(e="left")=>Rn("alignment",e));k(wo,{displayName:"Command<setAlignCommand>",group:"Table"});var bo=xe(e=>new Ee(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(t,n,o,r)=>{let i=t.doc.resolve(o);if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),j.type(e)))return null;let l=no(e,Math.max(Number(n.groups?.row??0),2),Number(n.groups?.col)),s=t.tr.replaceRangeWith(o,r,l);return s.setSelection(P.create(s.doc,o+3)).scrollIntoView()}));k(bo,{displayName:"InputRule<insertTableInputRule>",group:"Table"});var ko=qt(e=>({run:(t,n,o)=>{if(o)return t;function r(u){let f=u.childCount,c=u.lastChild?.childCount??0;if(f===0||c===0)return Se.type(e).create();let d=u.firstChild;if(!(c>0&&d&&d.childCount===0))return u;if(f>=3){let b=u.child(1),w=[];for(let R=0;R<b.childCount;R++){let A=b.child(R);w.push(se.type(e).create(A.attrs,A.content,A.marks))}let C=d.type.create(d.attrs,w),x=[];for(let R=2;R<f;R++)x.push(u.child(R));return u.type.create(u.attrs,[C,...x])}let h=Array(c).fill(0).map(()=>se.type(e).createAndFill()),p=new N(v.from(h),0,0),g=d.replace(0,0,p);return u.replace(0,d.nodeSize,new N(v.from(g),0,0))}function i(u){let f=ce.type(e),c=[],d=[],h=!1;function p(){if(d.length===0)return;let g=ge.type(e).createAndFill(),b=j.type(e).create(null,[g,...d]);c.push(r(b)),d=[]}return u.forEach(g=>{g.type===f?(h=!0,d.push(g)):(p(),c.push(g))}),p(),h?v.from(c):u}function l(u){let f=i(u),c=f!==u,d=[];return f.forEach(h=>{if(h.type===j.type(e)){let p=r(h);p!==h&&(c=!0),d.push(p)}else if(h.childCount>0){let p=l(h.content);p!==h.content?(c=!0,d.push(h.copy(p))):d.push(h)}else d.push(h)}),c?v.from(d):u}function s(u){let f=[],c=[];u.forEach(d=>c.push(d));for(let d=0;d<c.length;d++){let h=c[d],p=c[d+1];h.type===Se.type(e)&&h.content.size===0&&p&&p.type===j.type(e)||f.push(h)}return f.length<c.length?v.from(f):u}let a=l(t.content);return a=s(a),new N(v.from(a),t.openStart,t.openEnd)}}));k(ko,{displayName:"PasteRule<table>",group:"Table"});var vt=Pe("tableKeymap",{NextCell:{priority:100,shortcuts:["Mod-]","Tab"],command:e=>{let t=e.get(de);return()=>t.call(Rt.key)}},PrevCell:{shortcuts:["Mod-[","Shift-Tab"],command:e=>{let t=e.get(de);return()=>t.call(At.key)}},ExitTable:{shortcuts:["Mod-Enter","Enter"],command:e=>{let t=e.get(de);return()=>t.call(Tt.key)}}});k(vt.ctx,{displayName:"KeymapCtx<table>",group:"Table"});k(vt.shortcuts,{displayName:"Keymap<table>",group:"Table"});var kt="footnote_definition",eo="footnoteDefinition",Mt=q("footnote_definition",()=>({group:"block",content:"block+",defining:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`dl[data-type="${kt}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw be(e);return{label:e.dataset.label}},contentElement:"dd"}],toDOM:e=>{let t=e.attrs.label;return["dl",{"data-label":t,"data-type":kt},["dt",t],["dd",0]]},parseMarkdown:{match:({type:e})=>e===eo,runner:(e,t,n)=>{e.openNode(n,{label:t.label}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===kt,runner:(e,t)=>{e.openNode(eo,void 0,{label:t.attrs.label,identifier:t.attrs.label}).next(t.content).closeNode()}}}));k(Mt.ctx,{displayName:"NodeSchemaCtx<footnodeDef>",group:"footnote"});k(Mt.node,{displayName:"NodeSchema<footnodeDef>",group:"footnote"});var Ct="footnote_reference",Nt=q("footnote_reference",()=>({group:"inline",inline:!0,atom:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`sup[data-type="${Ct}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw be(e);return{label:e.dataset.label}}}],toDOM:e=>{let t=e.attrs.label;return["sup",{"data-label":t,"data-type":Ct},t]},parseMarkdown:{match:({type:e})=>e==="footnoteReference",runner:(e,t,n)=>{e.addNode(n,{label:t.label})}},toMarkdown:{match:e=>e.type.name===Ct,runner:(e,t)=>{e.addNode("footnoteReference",void 0,void 0,{label:t.attrs.label,identifier:t.attrs.label})}}}));k(Nt.ctx,{displayName:"NodeSchemaCtx<footnodeRef>",group:"footnote"});k(Nt.node,{displayName:"NodeSchema<footnodeRef>",group:"footnote"});var Dt=Yt.extendSchema(e=>t=>{let n=e(t);return{...n,attrs:{...n.attrs,checked:{default:null,validate:"boolean|null"}},parseDOM:[{tag:'li[data-item-type="task"]',getAttrs:o=>{if(!(o instanceof HTMLElement))throw be(o);return{label:o.dataset.label,listType:o.dataset.listType,spread:o.dataset.spread==="true",checked:o.dataset.checked?o.dataset.checked==="true":null}}},...n?.parseDOM||[]],toDOM:o=>n.toDOM&&o.attrs.checked==null?n.toDOM(o):["li",{"data-item-type":"task","data-label":o.attrs.label,"data-list-type":o.attrs.listType,"data-spread":o.attrs.spread,"data-checked":o.attrs.checked},0],parseMarkdown:{match:({type:o})=>o==="listItem",runner:(o,r,i)=>{if(r.checked==null){n.parseMarkdown.runner(o,r,i);return}let l=r.label!=null?`${r.label}.`:"\u2022",s=r.checked!=null?!!r.checked:null,a=r.label!=null?"ordered":"bullet",u=r.spread??!0;o.openNode(i,{label:l,listType:a,spread:u,checked:s}),o.next(r.children),o.closeNode()}},toMarkdown:{match:o=>o.type.name==="list_item",runner:(o,r)=>{if(r.attrs.checked==null){n.toMarkdown.runner(o,r);return}let i=r.attrs.label,l=r.attrs.listType,s=r.attrs.spread,a=r.attrs.checked;o.openNode("listItem",void 0,{label:i,listType:l,spread:s,checked:a}),o.next(r.content),o.closeNode()}}}});k(Dt.node,{displayName:"NodeSchema<taskListItem>",group:"ListItem"});k(Dt.ctx,{displayName:"NodeSchemaCtx<taskListItem>",group:"ListItem"});var Co=xe(()=>new Ee(/^\[(?<checked>\s|x)\]\s$/,(e,t,n,o)=>{let r=e.doc.resolve(n),i=0,l=r.node(i);for(;l&&l.type.name!=="list_item";)i--,l=r.node(i);if(!l||l.attrs.checked!=null)return null;let s=t.groups?.checked==="x",a=r.before(i),u=e.tr;return u.deleteRange(n,o).setNodeMarkup(a,void 0,{...l.attrs,checked:s}),u}));k(Co,{displayName:"InputRule<wrapInTaskListInputRule>",group:"ListItem"});var Fl=[St,vt].flat(),Ll=[bo,Co],zl=[to],Il=[ko],yo=pe(()=>In);k(yo,{displayName:"Prose<autoInsertSpanPlugin>",group:"Prose"});var El=pe(()=>Dn({}));k(El,{displayName:"Prose<columnResizingPlugin>",group:"Prose"});var xo=pe(()=>Ln({allowTableNodeSelection:!0}));k(xo,{displayName:"Prose<tableEditingPlugin>",group:"Prose"});var Ft=Jt("remarkGFM",()=>ze);k(Ft.plugin,{displayName:"Remark<remarkGFMPlugin>",group:"Remark"});k(Ft.options,{displayName:"RemarkConfig<remarkGFMPlugin>",group:"Remark"});var _l=new G("MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN");function Pl(e,t){let n=0;return t.forEach((o,r,i)=>{o===e&&(n=i)}),n}function Ol(e,t){let n=e.content.findDiffStart(t.content);if(n==null)return null;let o=e.content.findDiffEnd(t.content);return o?{from:n,to:Math.max(o.b,n)}:null}var So=pe(()=>new Z({key:_l,appendTransaction:(e,t,n)=>{if(t.doc===n.doc)return;let o=Ol(t.doc,n.doc);if(!o)return;let r,i=(l,s)=>{if(l.type.name!=="table_cell")return;let a=n.doc.resolve(s),u=a.node(a.depth),f=a.node(a.depth-1).firstChild;if(!f)return;let c=Pl(l,u),d=f.maybeChild(c);if(!d)return;let h=d.attrs.alignment;h!==l.attrs.alignment&&(r||(r=n.tr),r.setNodeMarkup(s,void 0,{...l.attrs,alignment:h}))};return n.doc.nodesBetween(o.from,o.to,(l,s)=>l.type.name!=="table"?!0:(n.doc.nodesBetween(s,s+l.nodeSize,i),!1)),r}}));k(So,{displayName:"Prose<keepTableAlignPlugin>",group:"Prose"});var $l=[So,yo,Ft,xo].flat(),Hl=[Dt,j,ge,ce,se,we,Mt,Nt,yt,he].flat(),Bl=[Rt,At,Tt,lo,io,ao,so,co,uo,fo,mo,go,po,ho,wo,xt],Wa=[Hl,Ll,Il,zl,Fl,Bl,$l].flat();export{S as a,X as b,yt as c,he as d,xt as e,to as f,St as g,j as h,ge as i,ce as j,we as k,se as l,no as m,Ba as n,ja as o,oo as p,vl as q,Ml as r,ro as s,Nl as t,Dl as u,At as v,Rt as w,Tt as x,lo as y,io as z,ao as A,so as B,co as C,uo as D,fo as E,po as F,ho as G,mo as H,go as I,wo as J,bo as K,ko as L,vt as M,Mt as N,Nt as O,Dt as P,Co as Q,Fl as R,Ll as S,zl as T,Il as U,yo as V,El as W,xo as X,Ft as Y,So as Z,$l as _,Hl as $,Bl as aa,Wa as ba};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Aa as S,Ba as v,Ga as q,Ia as m,Ja as V,Ka as p,La as C,Ma as $,Pa as I,Qa as d,Ra as z,S as L,Sa as N,Va as D,Xa as F,_a as R,b as M,c as j,db as G,ga as W,gb as J,h as B,hb as O,i as H,lb as A,mb as Q,qb as X,ta as l,xa as k,ya as g,za as K}from"./chunk-VKELS2FZ.js";import{d as P,i as h,l as E,m as T}from"./chunk-BV6CAHIM.js";var ee=n=>crypto.getRandomValues(new Uint8Array(n)),te=(n,a,r)=>{let e=256-256%n.length;if(e===256){let o=n.length-1;return(s=a)=>{if(!s)return"";let i="";for(;;){let c=r(s),u=s;for(;u--;)if(i+=n[c[u]&o],i.length>=s)return i}}}let t=Math.ceil(1.6*256*a/e);return(o=a)=>{if(!o)return"";let s="";for(;;){let i=r(t),c=t;for(;c--;)if(i[c]<e&&(s+=n[i[c]%n.length],s.length>=o))return s}}},Y=(n,a=21)=>te(n,a|0,ee);var ne=Y("abcedfghicklmn",10);function b(n,a,r){let e=n.findIndex(([o])=>o===a);if(e===-1)return[...n,r];let t=n.slice();return t[e]=r,t}function f(n,a,r){let e=H(r||ne()),t=!1,o=s=>(s.record(e),s.update(a,i=>i.concat(e)),async()=>{let c=await n(s,o,()=>{s.done(e),t=!0});return t||s.done(e),()=>{if(s.update(a,u=>u.filter(y=>y!==e)),s.clearTimer(e),c){let u=c();u&&"then"in u&&u.catch(console.error)}}});return o.timer=e,o}function ge(n,a){let r=I(n),e=t=>async()=>{e.key=r,await t.wait(N);let o=a(t);return t.get(d).create(r,o),e.run=s=>t.get(d).call(n,s),()=>{t.get(d).remove(r)}};return e}function we(n,a,r){let e=I(n);return f(async(t,o)=>{await t.wait(N);let s=await a(t);return t.get(d).create(e,s),o.run=i=>t.get(d).call(n,i),o.key=e,()=>{t.get(d).remove(e)}},z,r)}function he(n){let a=r=>async()=>{await r.wait(m);let e=n(r);return r.update(k,t=>[...t,e]),a.inputRule=e,()=>{r.update(k,t=>t.filter(o=>o!==e))}};return a}function ke(n,a){return f(async(r,e)=>{await r.wait(m);let t=await n(r);return r.update(k,o=>[...o,t]),e.inputRule=t,()=>{r.update(k,o=>o.filter(s=>s!==t))}},O,a)}function Se(n){let a=r=>async()=>{await r.wait(m);let e=n(r);return r.update(A,t=>[...t,e]),a.pasteRule=e,()=>{r.update(A,t=>t.filter(o=>o!==e))}};return a}function ve(n,a){return f(async(r,e)=>{await r.wait(m);let t=await n(r);return r.update(A,o=>[...o,t]),e.pasteRule=t,()=>{r.update(A,o=>o.filter(s=>s!==t))}},Q,a)}function re(n,a){let r=e=>async()=>{let t=a(e);return e.update($,o=>b(o,n,[n,t])),r.id=n,r.schema=t,()=>{e.update($,o=>o.filter(([s])=>s!==n))}};return r.type=e=>{let t=e.get(p).marks[n];if(!t)throw j(n);return t},r}function Ce(n,a,r){let e=f(async(t,o,s)=>{let i=await a(t);return t.update($,c=>b(c,n,[n,i])),o.id=n,o.schema=i,s(),()=>{t.update($,c=>c.filter(([u])=>u!==n))}},V,r);return e.type=t=>{let o=t.get(p).marks[n];if(!o)throw j(n);return o},e}function oe(n,a){let r=e=>async()=>{let t=a(e);return e.update(C,o=>b(o,n,[n,t])),r.id=n,r.schema=t,()=>{e.update(C,o=>o.filter(([s])=>s!==n))}};return r.type=e=>{let t=e.get(p).nodes[n];if(!t)throw M(n);return t},r}function $e(n,a,r){let e=f(async(t,o,s)=>{let i=await a(t);return t.update(C,c=>b(c,n,[n,i])),o.id=n,o.schema=i,s(),()=>{t.update(C,c=>c.filter(([u])=>u!==n))}},V,r);return e.type=t=>{let o=t.get(p).nodes[n];if(!o)throw M(n);return o},e}function Ae(n){let a,r=e=>async()=>(await e.wait(m),a=n(e),e.update(g,t=>[...t,a]),()=>{e.update(g,t=>t.filter(o=>o!==a))});return r.plugin=()=>a,r.key=()=>a.spec.key,r}function Te(n,a){let r,e=f(async t=>(await t.wait(m),r=await n(t),t.update(g,o=>[...o,r]),()=>{t.update(g,o=>o.filter(s=>s!==r))}),O,a);return e.plugin=()=>r,e.key=()=>r.spec.key,e}function ae(n){let a=r=>async()=>{await r.wait(F);let e=r.get(D),t=n(r),o=e.addObjectKeymap(t);return a.keymap=t,()=>{o()}};return a}function Re(n,a){return f(async(r,e)=>{await r.wait(F);let t=r.get(D),o=await n(r),s=t.addObjectKeymap(o);return e.keymap=o,()=>{s()}},O,a)}function Oe(n,a){let r=e=>async()=>{await e.wait(m);let t=a(e);return n.type(e)instanceof h?e.update(S,o=>[...o,[n.id,t]]):e.update(v,o=>[...o,[n.id,t]]),r.view=t,r.type=n,()=>{n.type(e)instanceof h?e.update(S,o=>o.filter(s=>s[0]!==n.id)):e.update(v,o=>o.filter(s=>s[0]!==n.id))}};return r}function be(n,a,r){return f(async(e,t)=>{await e.wait(m);let o=await a(e);return n.type(e)instanceof h?e.update(S,s=>[...s,[n.id,o]]):e.update(v,s=>[...s,[n.id,o]]),t.view=o,t.type=n,()=>{n.type(e)instanceof h?e.update(S,s=>s.filter(i=>i[0]!==n.id)):e.update(v,s=>s.filter(i=>i[0]!==n.id))}},X,r)}function w(n,a){let r=B(n,a),e=t=>(t.inject(r),()=>()=>{t.remove(r)});return e.key=r,e}function se(n,a){let r=w(a,n),e=oe(n,o=>o.get(r.key)(o)),t=[r,e];return t.id=e.id,t.node=e,t.type=o=>e.type(o),t.ctx=r,t.key=r.key,t.extendSchema=o=>se(n,o(a)),t}function ie(n,a){let r=w(a,n),e=re(n,o=>o.get(r.key)(o)),t=[r,e];return t.id=e.id,t.mark=e,t.type=o=>e.type(o),t.ctx=r,t.key=r.key,t.extendSchema=o=>ie(n,o(a)),t}function Me(n,a){let r=w(Object.fromEntries(Object.entries(a).map(([o,{shortcuts:s,priority:i}])=>[o,{shortcuts:s,priority:i}])),`${n}Keymap`),e=ae(o=>{let s=o.get(r.key),i=Object.entries(a).flatMap(([c,{command:u}])=>{let y=s[c],_=[y.shortcuts].flat(),x=y.priority;return _.map(U=>[U,{key:U,onRun:u,priority:x}])});return Object.fromEntries(i)}),t=[r,e];return t.ctx=r,t.shortcuts=e,t.key=r.key,t.keymap=e.keymap,t}var je=(n,a=()=>({}))=>w(a,`${n}Attr`),Pe=(n,a=()=>({}))=>w(a,`${n}Attr`);function Ee(n,a,r){let e=w(r??{},n),t=s=>async()=>{await s.wait(q);let i={plugin:a(s),options:s.get(e.key)};return s.update(K,c=>[...c,i]),()=>{s.update(K,c=>c.filter(u=>u!==i))}},o=[e,t];return o.id=n,o.plugin=t,o.options=e,o}function Ke(n,a){return r=>r.get(d).call(n,a)}function Ve(){return n=>{let a=n.get(l),{tr:r}=a.state,e=Object.assign(Object.create(r),r).setTime(Date.now());return a.dispatch(e)}}function Ie(){return n=>{let a=document.createElement("div"),r=n.get(p),e=n.get(l),t=T.fromSchema(r).serializeFragment(e.state.doc.content);return a.appendChild(t),a.innerHTML}}function Ne(n){return a=>{let r=a.get(l),e=a.get(p),t=a.get(G);if(!n)return t(r.state.doc);let o=r.state.doc.slice(n.from,n.to,!0),s=e.topNodeType.createAndFill(null,o.content);return s?t(s):(console.error("No document found"),"")}}function De(n,a=!1){return r=>{let e=r.get(l),t=r.get(R)(n);if(!t)return;if(!a){let u=e.state.selection.content();return e.dispatch(e.state.tr.replaceSelection(new P(t.content,u.openStart,u.openEnd)).scrollIntoView())}let o=r.get(p),s=T.fromSchema(o).serializeFragment(t.content),i=E.fromSchema(o).parseSlice(s),c=W(i);if(c){e.dispatch(e.state.tr.replaceSelectionWith(c,!0));return}e.dispatch(e.state.tr.replaceSelection(i))}}function Fe(){return n=>{let a=n.get(l),r=[];return a.state.doc.descendants(e=>{e.type.name==="heading"&&e.attrs.level&&r.push({text:e.textContent,level:e.attrs.level,id:e.attrs.id})}),r}}function Ue(n,a=!1){return r=>{let e=r.get(l),t=r.get(R)(n);if(!t)return;if(!a){let{state:c}=e;return e.dispatch(c.tr.replace(0,c.doc.content.size,new P(t.content,0,0)))}let o=r.get(p),s=r.get(J)({schema:o,doc:t,plugins:r.get(g)}),i=L.create(s);e.updateState(i)}}function Be(n,a){return r=>{let e=r.get(l),{tr:t}=e.state,o=t.doc.nodeAt(n);if(!o)return;let s=a(o.attrs);return e.dispatch(t.setNodeMarkup(n,void 0,s))}}function Z(n){return a=>{let r=a.get(R)(n),e=a.get(p),t=T.fromSchema(e).serializeFragment(r.content);return E.fromSchema(e).parseSlice(t)}}function He(n,a,r=!1){return e=>{let t=Z(n)(e),o=e.get(l),s=o.state.doc.resolve(a),i=0,c=o.state.doc.content.size,u=r?s.pos:s.after(s.depth-1),y=Math.min(Math.max(u,i),c);o.dispatch(o.state.tr.replace(u,y,t))}}function Le(n,a){return r=>{let e=r.get(l),t=Z(n)(r);e.dispatch(e.state.tr.replace(a.from,a.to,t))}}var We=(...n)=>{let a=n.length,r=a;for(;r--;)if(typeof n[r]!="function")throw new TypeError("Expected a function");return(...e)=>{let t=0,o=a?n[t](...e):e[0];for(;++t<a;)o=n[t](o);return o}};export{Y as a,ne as b,b as c,f as d,ge as e,we as f,he as g,ke as h,Se as i,ve as j,re as k,Ce as l,oe as m,$e as n,Ae as o,Te as p,ae as q,Re as r,Oe as s,be as t,w as u,se as v,ie as w,Me as x,je as y,Pe as z,Ee as A,Ke as B,Ve as C,Ie as D,Ne as E,De as F,Fe as G,Ue as H,Be as I,Z as J,He as K,Le as L,We as M};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as b}from"./chunk-FOZORPFE.js";import{Ga as L,T as p,U as c,bb as m,db as w,h,pb as y,ya as f}from"./chunk-VKELS2FZ.js";var k=class{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.selectionUpdatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=e=>(this.beforeMountedListeners.push(e),this),this.mounted=e=>(this.mountedListeners.push(e),this),this.updated=e=>(this.updatedListeners.push(e),this)}get listeners(){return{beforeMount:this.beforeMountedListeners,mounted:this.mountedListeners,updated:this.updatedListeners,markdownUpdated:this.markdownUpdatedListeners,blur:this.blurListeners,focus:this.focusListeners,destroy:this.destroyListeners,selectionUpdated:this.selectionUpdatedListeners}}markdownUpdated(e){return this.markdownUpdatedListeners.push(e),this}blur(e){return this.blurListeners.push(e),this}focus(e){return this.focusListeners.push(e),this}destroy(e){return this.destroyListeners.push(e),this}selectionUpdated(e){return this.selectionUpdatedListeners.push(e),this}},g=h(new k,"listener"),E=new c("MILKDOWN_LISTENER"),M=e=>(e.inject(g,new k),async()=>{await e.wait(L);let{listeners:r}=e.get(g);r.beforeMount.forEach(t=>t(e)),await e.wait(m);let u=e.get(w),n=null,d=null,i=null,o=null,l=b(()=>{if(!o)return;let{doc:t}=o;if(r.updated.length>0&&n&&!n.eq(t)&&r.updated.forEach(s=>{s(e,t,n)}),r.markdownUpdated.length>0&&n&&!n.eq(t)){let s=u(t);r.markdownUpdated.forEach(a=>{a(e,s,d)}),d=s}n=t,o=null},200),U=new p({key:E,view:()=>({destroy:()=>{l.cancel(),r.destroy.forEach(t=>t(e))}}),props:{handleDOMEvents:{focus:()=>(r.focus.forEach(t=>t(e)),!1),blur:()=>(r.blur.forEach(t=>t(e)),!1)}},state:{init:(t,s)=>{n=s.doc,d=u(s.doc)},apply:t=>{let s=t.selection;(!i&&s||i&&!s.eq(i))&&(r.selectionUpdated.forEach(a=>{a(e,s,i)}),i=s),!(!(t.docChanged||t.storedMarksSet)||t.getMeta("addToHistory")===!1)&&(o=t,l())}}});e.update(f,t=>t.concat(U)),await e.wait(y),r.mounted.forEach(t=>t(e))});M.meta={package:"@milkdown/plugin-listener",displayName:"Listener"};export{k as a,g as b,E as c,M as d};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},i={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},n=typeof navigator<"u"&&/Mac/.test(navigator.platform),y=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(r=0;r<10;r++)t[48+r]=t[96+r]=String(r);var r;for(r=1;r<=24;r++)t[r+111]="F"+r;var r;for(r=65;r<=90;r++)t[r]=String.fromCharCode(r+32),i[r]=String.fromCharCode(r);var r;for(a in t)i.hasOwnProperty(a)||(i[a]=t[a]);var a;function g(o){var f=n&&o.metaKey&&o.shiftKey&&!o.ctrlKey&&!o.altKey||y&&o.shiftKey&&o.key&&o.key.length==1||o.key=="Unidentified",e=!f&&o.key||(o.shiftKey?i:t)[o.keyCode]||o.key||"Unidentified";return e=="Esc"&&(e="Escape"),e=="Del"&&(e="Delete"),e=="Left"&&(e="ArrowLeft"),e=="Up"&&(e="ArrowUp"),e=="Right"&&(e="ArrowRight"),e=="Down"&&(e="ArrowDown"),e}export{t as a,i as b,g as c};
|