@i14ks/ccv 0.48.0 → 0.50.0
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/bundle/ccv.mjs +403 -563
- package/package.json +1 -1
- package/web/assets/MarkdownTextEditor-DoP0b52_.js +60 -0
- package/web/assets/{abnfDiagram-S7VZAUFO-DJLBYC4E.js → abnfDiagram-S7VZAUFO-CApqnaGR.js} +1 -1
- package/web/assets/{architectureDiagram-YGSQEFNW-CjOULv4y.js → architectureDiagram-YGSQEFNW-jwCcwggk.js} +1 -1
- package/web/assets/{blockDiagram-APKKGZFW-BxtAGaqL.js → blockDiagram-APKKGZFW-Bji4PkTF.js} +1 -1
- package/web/assets/{c4Diagram-KJ2TOQU5-DixwjD35.js → c4Diagram-KJ2TOQU5-BFRf3dTO.js} +1 -1
- package/web/assets/{chunk-2Q5K7J3B-D5RSYb7c.js → chunk-2Q5K7J3B-DUFwqu3B.js} +1 -1
- package/web/assets/{chunk-5VM5RSS4-Zw9KRmHP.js → chunk-5VM5RSS4-BNCdpRtw.js} +1 -1
- package/web/assets/{chunk-HFQBQIA3-Dz3Jqjvc.js → chunk-HFQBQIA3-D8sImu8E.js} +1 -1
- package/web/assets/{chunk-JWPE2WC7-CYC8lXvq.js → chunk-JWPE2WC7-BhL2yBgo.js} +1 -1
- package/web/assets/{chunk-KQLB2F66-BpsntY2B.js → chunk-KQLB2F66-pFBglgtP.js} +2 -2
- package/web/assets/{chunk-KS47KZWR-CIw-CgK1.js → chunk-KS47KZWR-BrLOmWWS.js} +1 -1
- package/web/assets/{chunk-OY52VR5R-DyNxKUIK.js → chunk-OY52VR5R-Cgk3JXPf.js} +1 -1
- package/web/assets/{chunk-TU62E6Q5-CHgxHE0R.js → chunk-TU62E6Q5-e2yCDokg.js} +1 -1
- package/web/assets/{chunk-XXDRQBXY-CQ0zLLMg.js → chunk-XXDRQBXY-DU6jFvHG.js} +1 -1
- package/web/assets/{classDiagram-v2-L25IHNXF-DyN77x6F.js → classDiagram-v2-L25IHNXF-Bt1zi6CS.js} +1 -1
- package/web/assets/{codemirror-Dh-4cMdO.js → codemirror-CNxAt-Eg.js} +1 -1
- package/web/assets/{codemirrorImages-BHHbVBQN.js → codemirrorImages-C30a2wIG.js} +1 -1
- package/web/assets/{cose-bilkent-JH36ORCC-D1H3X9ot.js → cose-bilkent-JH36ORCC-CYITjt4m.js} +1 -1
- package/web/assets/{cynefin-EF2NZ3EQ-B4SsJI8I.js → cynefin-EF2NZ3EQ-BiYmPyip.js} +1 -1
- package/web/assets/{cynefinDiagram-L36ESFBY-D543PDJ4.js → cynefinDiagram-L36ESFBY-DiITK0W-.js} +1 -1
- package/web/assets/{dagre-SPEB5RXH-CksMpjx8.js → dagre-SPEB5RXH-BnOvnJrY.js} +1 -1
- package/web/assets/{diagram-3B7GL73J-DywKf_aW.js → diagram-3B7GL73J-DnFw5yRA.js} +1 -1
- package/web/assets/{diagram-DNEMPZML-QaEKUl5W.js → diagram-DNEMPZML-CLe-W-8E.js} +1 -1
- package/web/assets/{diagram-L3MUGCDN-51y_ny8R.js → diagram-L3MUGCDN-xhFV1YT8.js} +1 -1
- package/web/assets/{diagram-LA4NIPWU-Cg_nbBL_.js → diagram-LA4NIPWU-S58Cgi0K.js} +1 -1
- package/web/assets/{diagram-MHCOC4E2-DFHCPZYb.js → diagram-MHCOC4E2-fbSbD-Tu.js} +1 -1
- package/web/assets/{diagram-XPFHEONP-dBKRRNZa.js → diagram-XPFHEONP-C3K_xR1q.js} +1 -1
- package/web/assets/{ebnfDiagram-UZSYDL2S-BwTgNIAm.js → ebnfDiagram-UZSYDL2S-BG_udZa4.js} +1 -1
- package/web/assets/{elk-XV6XMXQE-BR-xb3ob.js → elk-XV6XMXQE-DE6K1qve.js} +1 -1
- package/web/assets/{erDiagram-EYBAPDEH-BB1wg_fV.js → erDiagram-EYBAPDEH-xkeusKpC.js} +1 -1
- package/web/assets/{flowDiagram-MALGAFMO-CRDw4nX3.js → flowDiagram-MALGAFMO-OisK-T0f.js} +1 -1
- package/web/assets/{ganttDiagram-23REXITY-MYQEYJ-I.js → ganttDiagram-23REXITY-DmQVS3ZV.js} +1 -1
- package/web/assets/{gitGraphDiagram-STJD7YCW-Dhn0_pRI.js → gitGraphDiagram-STJD7YCW-Cll-SkVb.js} +1 -1
- package/web/assets/{index-DRJgyVu5.js → index-B2l2owfY.js} +1 -1
- package/web/assets/{index-BJdwUs7I.js → index-BTQSusTZ.js} +1 -1
- package/web/assets/{index-Bod45-bM.js → index-B_jwjnO_.js} +1 -1
- package/web/assets/{index-v-BrSiuM.js → index-Bta4Smbo.js} +1 -1
- package/web/assets/{index-CaL1Ugw4.js → index-BzBiXh1K.js} +1 -1
- package/web/assets/index-C0GRVSmD.css +1 -0
- package/web/assets/{index-7ivf0ID5.js → index-CJzQgsOc.js} +1 -1
- package/web/assets/index-CM1F7OtV.js +172 -0
- package/web/assets/{index-BJHr8-zK.js → index-CUm9rUfI.js} +1 -1
- package/web/assets/{index-DIouQVG8.js → index-CXbAKkq5.js} +1 -1
- package/web/assets/{index-DaBTH0ea.js → index-CYTyvY7n.js} +1 -1
- package/web/assets/{index-DqLAItfN.js → index-CcKihMD9.js} +1 -1
- package/web/assets/{index-DtR2v4RD.js → index-CkV2xkfY.js} +1 -1
- package/web/assets/{index-BLLxsupM.js → index-CkpIGiUh.js} +1 -1
- package/web/assets/{index-BK9FAkRg.js → index-D5xJiVmD.js} +1 -1
- package/web/assets/{index-Cbs1XkJa.js → index-DM3T56Jf.js} +1 -1
- package/web/assets/{index-C13EW7hw.js → index-DXCiYt0O.js} +1 -1
- package/web/assets/{index-DtwnaAnT.js → index-Zq9V5ZB9.js} +1 -1
- package/web/assets/{index-DqxhStF7.js → index-cu8Fcww3.js} +1 -1
- package/web/assets/{index-CE1Pd4z7.js → index-fF3dLvWP.js} +1 -1
- package/web/assets/{index-DlMbLAnE.js → index-qOoKNKZw.js} +1 -1
- package/web/assets/{infoDiagram-KBXO4MBG-By-j1Q2z.js → infoDiagram-KBXO4MBG-CFnvxUDW.js} +1 -1
- package/web/assets/{ishikawaDiagram-M35NCXHK-Cj7pfKCW.js → ishikawaDiagram-M35NCXHK-CjJXkiZb.js} +1 -1
- package/web/assets/{journeyDiagram-OPLOXDXO-B7acuJLi.js → journeyDiagram-OPLOXDXO-CYBHLPC5.js} +1 -1
- package/web/assets/{kanban-definition-BZKZHSQY-B0N1FM8N.js → kanban-definition-BZKZHSQY-BzNwzCFX.js} +1 -1
- package/web/assets/{mermaid.core-Rt-JZroF.js → mermaid.core-CFBl9TP8.js} +4 -4
- package/web/assets/{mindmap-definition-I2QAS2VK-Du6Bq1D4.js → mindmap-definition-I2QAS2VK-X8WzviFV.js} +1 -1
- package/web/assets/{pegDiagram-FD4XPPHP-Cx3y_VAW.js → pegDiagram-FD4XPPHP-kvO-a_98.js} +1 -1
- package/web/assets/{pieDiagram-J4AKIIQI-DrpfcCiI.js → pieDiagram-J4AKIIQI-BEiN8l-e.js} +1 -1
- package/web/assets/{quadrantDiagram-XTYBLID2-BbJ2d8x8.js → quadrantDiagram-XTYBLID2-Cf-t2xpS.js} +1 -1
- package/web/assets/{railroadDiagram-MRQ6NCDL-C8B9eHMq.js → railroadDiagram-MRQ6NCDL-Bou3xfYm.js} +1 -1
- package/web/assets/{requirementDiagram-Y7LWUY3S--8FcyGsP.js → requirementDiagram-Y7LWUY3S-Ch1ghejU.js} +1 -1
- package/web/assets/{sankeyDiagram-WGJFYUXA-CYq-mQmD.js → sankeyDiagram-WGJFYUXA-DCjH5hxL.js} +1 -1
- package/web/assets/{sequenceDiagram-5NDRBG5M-C-Llg4wI.js → sequenceDiagram-5NDRBG5M-DrspJAAy.js} +1 -1
- package/web/assets/{sizeCapture-INFHLROL-80lnJyWe.js → sizeCapture-INFHLROL-BpOJNwe1.js} +1 -1
- package/web/assets/{stateDiagram-v2-FJ4FJNEA-QZyfUycB.js → stateDiagram-v2-FJ4FJNEA-RkYUtnsy.js} +1 -1
- package/web/assets/{swimlanes-UMQ2AFYF-BxT8Ql8H.js → swimlanes-UMQ2AFYF-BR4cicEg.js} +1 -1
- package/web/assets/swimlanesDiagram-OMPLPG4O-DGwvhioW.js +8 -0
- package/web/assets/{timeline-definition-SEUHKTQE-DWywP4r0.js → timeline-definition-SEUHKTQE-Bq2VoDLH.js} +1 -1
- package/web/assets/{usecaseDiagram-AFA6YXN4-BgmSQD90.js → usecaseDiagram-AFA6YXN4-BsB6aBKf.js} +1 -1
- package/web/assets/{vennDiagram-NNMJR3RB-B9ikZp8F.js → vennDiagram-NNMJR3RB-8pOZirDr.js} +1 -1
- package/web/assets/{wardleyDiagram-S7YFUSEH-CptNVfVi.js → wardleyDiagram-S7YFUSEH-Dx-je9ls.js} +1 -1
- package/web/assets/{xychartDiagram-GGNKY7IX-DV4TDhUT.js → xychartDiagram-GGNKY7IX-mpETY7ui.js} +1 -1
- package/web/index.html +2 -2
- package/web/assets/MarkdownTextEditor-B3B8_rFw.js +0 -60
- package/web/assets/index-eIS20v-m.css +0 -1
- package/web/assets/index-gy3hTMSD.js +0 -167
- package/web/assets/swimlanesDiagram-OMPLPG4O-BZDLC88s.js +0 -8
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
var hu=t=>{throw TypeError(t)};var du=(t,e,n)=>e.has(t)||hu("Cannot "+n);var x=(t,e,n)=>(du(t,e,"read from private field"),n?n.call(t):e.get(t)),B=(t,e,n)=>e.has(t)?hu("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),v=(t,e,n,r)=>(du(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n);import{m as Je,n as zg,o as J,p as Pg,q as pu,u as Bg,v as Lg,r as Fg,i as _g}from"./index-gy3hTMSD.js";import{k as $g,b as Vg}from"./index-Vcq4gwWv.js";import{g as jg}from"./_commonjsHelpers-CqkleIqs.js";var Ze=(function(t){return t.docTypeError="docTypeError",t.contextNotFound="contextNotFound",t.timerNotFound="timerNotFound",t.ctxCallOutOfScope="ctxCallOutOfScope",t.createNodeInParserFail="createNodeInParserFail",t.stackOverFlow="stackOverFlow",t.parserMatchError="parserMatchError",t.serializerMatchError="serializerMatchError",t.getAtomFromSchemaFail="getAtomFromSchemaFail",t.expectDomTypeError="expectDomTypeError",t.callCommandBeforeEditorView="callCommandBeforeEditorView",t.missingRootElement="missingRootElement",t.missingNodeInSchema="missingNodeInSchema",t.missingMarkInSchema="missingMarkInSchema",t.ctxNotBind="ctxNotBind",t.missingYjsDoc="missingYjsDoc",t.aiProviderError="aiProviderError",t.aiBuildContextError="aiBuildContextError",t})({}),et=class extends Error{constructor(t,e,n){super(e,n),this.name="MilkdownError",this.code=t,(n==null?void 0:n.cause)!==void 0&&(this.cause=n.cause)}},Hg=(t,e)=>typeof e=="function"?"[Function]":e,xs=t=>JSON.stringify(t,Hg);function qg(t){return new et(Ze.docTypeError,`Doc type error, unsupported type: ${xs(t)}`)}function Wg(t){return new et(Ze.contextNotFound,`Context "${t}" not found, do you forget to inject it?`)}function Kg(t){return new et(Ze.timerNotFound,`Timer "${t}" not found, do you forget to record it?`)}function ws(){return new et(Ze.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function Jg(t,e,n){const r=`Cannot create node for ${"name"in t?t.name:t}`,i=s=>{if(s==null)return"null";if(Array.isArray(s))return`[${s.map(i).join(", ")}]`;if(typeof s=="object")return"toJSON"in s&&typeof s.toJSON=="function"?JSON.stringify(s.toJSON()):"spec"in s?JSON.stringify(s.spec):JSON.stringify(s);if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return JSON.stringify(s);if(typeof s=="function")return`[Function: ${s.name||"anonymous"}]`;try{return String(s)}catch{return"[Unserializable]"}},o=[["[Description]",r],["[Attributes]",e],["[Content]",(n??[]).map(s=>s?typeof s=="object"&&"type"in s?`${s}`:i(s):"null")]].reduce((s,[l,a])=>{const c=`${l}: ${i(a)}.`;return s.concat(c)},[]);return new et(Ze.createNodeInParserFail,o.join(`
|
|
2
|
-
`))}function Nh(){return new et(Ze.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function Ug(t){return new et(Ze.parserMatchError,`Cannot match target parser for node: ${xs(t)}.`)}function Gg(t){return new et(Ze.serializerMatchError,`Cannot match target serializer for node: ${xs(t)}.`)}function Yg(t,e){return new et(Ze.getAtomFromSchemaFail,`Cannot get ${t}: ${e} from schema.`)}function Et(t){return new et(Ze.expectDomTypeError,`Expect to be a dom, but get: ${xs(t)}.`)}function Js(){return new et(Ze.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}function Qg(t){return new et(Ze.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${t}" in schema.`)}function Xg(t){return new et(Ze.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${t}" in schema.`)}var Th=class{constructor(){this.sliceMap=new Map,this.get=t=>{const e=typeof t=="string"?[...this.sliceMap.values()].find(n=>n.type.name===t):this.sliceMap.get(t.id);if(!e){const n=typeof t=="string"?t:t.name;throw Wg(n)}return e},this.remove=t=>{const e=typeof t=="string"?[...this.sliceMap.values()].find(n=>n.type.name===t):this.sliceMap.get(t.id);e&&this.sliceMap.delete(e.type.id)},this.has=t=>typeof t=="string"?[...this.sliceMap.values()].some(e=>e.type.name===t):this.sliceMap.has(t.id)}},ht,$t,Mr,xh,Zg=(xh=class{constructor(e,n,r){B(this,ht);B(this,$t);B(this,Mr);v(this,ht,[]),v(this,Mr,()=>{x(this,ht).forEach(i=>i(x(this,$t)))}),this.set=i=>{v(this,$t,i),x(this,Mr).call(this)},this.get=()=>x(this,$t),this.update=i=>{v(this,$t,i(x(this,$t))),x(this,Mr).call(this)},this.type=r,v(this,$t,n),e.set(r.id,this)}on(e){return x(this,ht).push(e),()=>{v(this,ht,x(this,ht).filter(n=>n!==e))}}once(e){const n=this.on(r=>{e(r),n()});return n}off(e){v(this,ht,x(this,ht).filter(n=>n!==e))}offAll(){v(this,ht,[])}},ht=new WeakMap,$t=new WeakMap,Mr=new WeakMap,xh),ey=class{constructor(t,e){this.id=Symbol(`Context-${e}`),this.name=e,this._defaultValue=t,this._typeInfo=()=>{throw ws()}}create(t,e=this._defaultValue){return new Zg(t,e,this)}},te=(t,e)=>new ey(t,e),Ki,Ji,Ui,Dn,Nr,pn,Tr,Ir,Ar,wh,ty=(wh=class{constructor(t,e,n){B(this,Ki);B(this,Ji);B(this,Ui);B(this,Dn);B(this,Nr);B(this,pn);B(this,Tr);B(this,Ir);B(this,Ar);v(this,Dn,new Set),v(this,Nr,new Set),v(this,pn,new Map),v(this,Tr,new Map),this.read=()=>({metadata:x(this,Ki),injectedSlices:[...x(this,Dn)].map(r=>({name:typeof r=="string"?r:r.name,value:x(this,Ir).call(this,r)})),consumedSlices:[...x(this,Nr)].map(r=>({name:typeof r=="string"?r:r.name,value:x(this,Ir).call(this,r)})),recordedTimers:[...x(this,pn)].map(([r,{duration:i}])=>({name:r.name,duration:i,status:x(this,Ar).call(this,r)})),waitTimers:[...x(this,Tr)].map(([r,{duration:i}])=>({name:r.name,duration:i,status:x(this,Ar).call(this,r)}))}),this.onRecord=r=>{x(this,pn).set(r,{start:Date.now(),duration:0})},this.onClear=r=>{x(this,pn).delete(r)},this.onDone=r=>{const i=x(this,pn).get(r);i&&(i.duration=Date.now()-i.start)},this.onWait=(r,i)=>{const o=Date.now();i.finally(()=>{x(this,Tr).set(r,{duration:Date.now()-o})}).catch(console.error)},this.onInject=r=>{x(this,Dn).add(r)},this.onRemove=r=>{x(this,Dn).delete(r)},this.onUse=r=>{x(this,Nr).add(r)},v(this,Ir,r=>x(this,Ji).get(r).get()),v(this,Ar,r=>x(this,Ui).get(r).status),v(this,Ji,t),v(this,Ui,e),v(this,Ki,n)}},Ki=new WeakMap,Ji=new WeakMap,Ui=new WeakMap,Dn=new WeakMap,Nr=new WeakMap,pn=new WeakMap,Tr=new WeakMap,Ir=new WeakMap,Ar=new WeakMap,wh),Vt,jt,Gi,nt,Er,ny=(Er=class{constructor(e,n,r){B(this,Vt);B(this,jt);B(this,Gi);B(this,nt);this.produce=i=>i&&Object.keys(i).length?new Er(x(this,Vt),x(this,jt),{...i}):this,this.inject=(i,o)=>{var l;const s=i.create(x(this,Vt).sliceMap);return o!=null&&s.set(o),(l=x(this,nt))==null||l.onInject(i),this},this.remove=i=>{var o;return x(this,Vt).remove(i),(o=x(this,nt))==null||o.onRemove(i),this},this.record=i=>{var o;return i.create(x(this,jt).store),(o=x(this,nt))==null||o.onRecord(i),this},this.clearTimer=i=>{var o;return x(this,jt).remove(i),(o=x(this,nt))==null||o.onClear(i),this},this.isInjected=i=>x(this,Vt).has(i),this.isRecorded=i=>x(this,jt).has(i),this.use=i=>{var o;return(o=x(this,nt))==null||o.onUse(i),x(this,Vt).get(i)},this.get=i=>this.use(i).get(),this.set=(i,o)=>this.use(i).set(o),this.update=(i,o)=>this.use(i).update(o),this.timer=i=>x(this,jt).get(i),this.done=i=>{var o;this.timer(i).done(),(o=x(this,nt))==null||o.onDone(i)},this.wait=i=>{var s;const o=this.timer(i).start();return(s=x(this,nt))==null||s.onWait(i,o),o},this.waitTimers=async i=>{await Promise.all(this.get(i).map(o=>this.wait(o)))},v(this,Vt,e),v(this,jt,n),v(this,Gi,r),r&&v(this,nt,new ty(e,n,r))}get meta(){return x(this,Gi)}get inspector(){return x(this,nt)}},Vt=new WeakMap,jt=new WeakMap,Gi=new WeakMap,nt=new WeakMap,Er),ry=class{constructor(){this.store=new Map,this.get=t=>{const e=this.store.get(t.id);if(!e)throw Kg(t.name);return e},this.remove=t=>{this.store.delete(t.id)},this.has=t=>this.store.has(t.id)}},vr,mn,Or,Ht,qt,Dr,Yi,Ch,iy=(Ch=class{constructor(t,e){B(this,vr);B(this,mn);B(this,Or);B(this,Ht);B(this,qt);B(this,Dr);B(this,Yi);v(this,vr,null),v(this,mn,null),v(this,Ht,"pending"),v(this,qt,null),this.start=()=>(x(this,vr)??v(this,vr,new Promise((n,r)=>{v(this,mn,i=>{i instanceof CustomEvent&&i.detail.id===x(this,Or)&&(v(this,Ht,"resolved"),x(this,Dr).call(this),i.stopImmediatePropagation(),n())}),x(this,Yi).call(this,()=>{x(this,Ht)==="pending"&&v(this,Ht,"rejected"),x(this,Dr).call(this),r(new Error(`Timing ${this.type.name} timeout.`))}),v(this,Ht,"pending"),addEventListener(this.type.name,x(this,mn))})),x(this,vr)),this.done=()=>{const n=new CustomEvent(this.type.name,{detail:{id:x(this,Or)}});dispatchEvent(n)},v(this,Dr,()=>{x(this,qt)!==null&&(clearTimeout(x(this,qt)),v(this,qt,null)),x(this,mn)&&removeEventListener(this.type.name,x(this,mn))}),v(this,Yi,n=>{v(this,qt,setTimeout(()=>{v(this,qt,null),n()},this.type.timeout))}),v(this,Or,Symbol(e.name)),this.type=e,t.set(e.id,this)}get status(){return x(this,Ht)}},vr=new WeakMap,mn=new WeakMap,Or=new WeakMap,Ht=new WeakMap,qt=new WeakMap,Dr=new WeakMap,Yi=new WeakMap,Ch),oy=class{constructor(t,e=3e3){this.create=n=>new iy(n,this),this.id=Symbol(`Timer-${t}`),this.name=t,this.timeout=e}},vt=(t,e=3e3)=>new oy(t,e);const sy={};function Cs(t,e){const n=sy,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Ih(t,r,i)}function Ih(t,e,n){if(ly(t)){if("value"in t)return t.type==="html"&&!n?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return mu(t.children,e,n)}return Array.isArray(t)?mu(t,e,n):""}function mu(t,e,n){const r=[];let i=-1;for(;++i<t.length;)r[i]=Ih(t[i],e,n);return r.join("")}function ly(t){return!!(t&&typeof t=="object")}const gu=document.createElement("i");function Na(t){const e="&"+t+";";gu.innerHTML=e;const n=gu.textContent;return n.charCodeAt(n.length-1)===59&&t!=="semi"||n===e?!1:n}function mt(t,e,n,r){const i=t.length;let o=0,s;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(e,n),t.splice(...s);else for(n&&t.splice(e,n);o<r.length;)s=r.slice(o,o+1e4),s.unshift(e,0),t.splice(...s),o+=1e4,e+=1e4}function ot(t,e){return t.length>0?(mt(t,t.length,0,e),t):e}const yu={}.hasOwnProperty;function Ah(t){const e={};let n=-1;for(;++n<t.length;)ay(e,t[n]);return e}function ay(t,e){let n;for(n in e){const i=(yu.call(t,n)?t[n]:void 0)||(t[n]={}),o=e[n];let s;if(o)for(s in o){yu.call(i,s)||(i[s]=[]);const l=o[s];cy(i[s],Array.isArray(l)?l:l?[l]:[])}}}function cy(t,e){let n=-1;const r=[];for(;++n<e.length;)(e[n].add==="after"?t:r).push(e[n]);mt(t,0,0,r)}function Eh(t,e){const n=Number.parseInt(t,e);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function gt(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ce=Mn(/[A-Za-z]/),Re=Mn(/[\dA-Za-z]/),uy=Mn(/[#-'*+\--9=?A-Z^-~]/);function ts(t){return t!==null&&(t<32||t===127)}const Fl=Mn(/\d/),fy=Mn(/[\dA-Fa-f]/),vh=Mn(/[!-/:-@[-`{-~]/);function j(t){return t!==null&&t<-2}function se(t){return t!==null&&(t<0||t===32)}function X(t){return t===-2||t===-1||t===32}const fo=Mn(new RegExp("\\p{P}|\\p{S}","u")),Gn=Mn(/\s/);function Mn(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function ie(t,e,n,r){const i=r?r-1:1/0;let o=0;return s;function s(a){return X(a)?(t.enter(n),l(a)):e(a)}function l(a){return X(a)&&o++<i?(t.consume(a),l):(t.exit(n),e(a))}}function Oh(t,e,n,r,i,o){let s=0;return l;function l(u){return X(u)?(t.enter(r),a(u)):c(u)}function a(u){return X(u)&&s<o?(t.consume(u),s++,a):(t.exit(r),c(u))}function c(u){return s>=i?e(u):n(u)}}const hy={tokenize:dy};function dy(t){const e=t.attempt(this.parser.constructs.contentInitial,r,i);let n;return e;function r(l){if(l===null){t.consume(l);return}return t.enter("lineEnding"),t.consume(l),t.exit("lineEnding"),ie(t,e,"linePrefix")}function i(l){return t.enter("paragraph"),o(l)}function o(l){const a=t.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=a),n=a,s(l)}function s(l){if(l===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(l);return}return j(l)?(t.consume(l),t.exit("chunkText"),o):(t.consume(l),s)}}let ns=class{constructor(){this.index=new Map,this.map=[]}add(e,n,r){ku(this,e,n,r,!1)}addBefore(e,n,r){ku(this,e,n,r,!0)}consume(e){if(this.map.sort(function(o,s){return o[0]-s[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const o of i)e.push(o);i=r.pop()}this.map.length=0,this.index.clear()}};function ku(t,e,n,r,i){if(n===0&&r.length===0)return;const o=t.index.get(e);if(o){o[1]+=n,i?(r.push(...o[2]),o[2]=r):o[2].push(...r);return}const s=[e,n,r];t.map.push(s),t.index.set(e,s)}const py={tokenize:my},bu={tokenize:gy};function my(t){const e=this,n=[];let r=0,i,o,s;return l;function l(w){if(r<n.length){const E=n[r];return e.containerState=E[1],t.attempt(E[0].continuation,a,c)(w)}return c(w)}function a(w){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&C();const E=e.events.length;let P=E,S;for(;P--;)if(e.events[P][0]==="exit"&&e.events[P][1].type==="chunkFlow"){S=e.events[P][1].end;break}g(r);let D=E;for(;D<e.events.length;)e.events[D][1].end={...S},D++;const F=new ns;return F.add(P+1,0,e.events.slice(E)),F.add(E,D-E,[]),F.consume(e.events),c(w)}return l(w)}function c(w){if(r===n.length){if(!i)return d(w);if(i.currentConstruct&&i.currentConstruct.concrete)return p(w);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(bu,u,f)(w)}function u(w){return i&&C(),g(r),d(w)}function f(w){return e.parser.lazy[e.now().line]=r!==n.length,s=e.now().offset,p(w)}function d(w){return e.containerState={},t.attempt(bu,h,p)(w)}function h(w){return r++,n.push([e.currentConstruct,e.containerState]),d(w)}function p(w){if(w===null){i&&C(),g(0),t.consume(w);return}return i=i||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),m(w)}function m(w){if(w===null){y(t.exit("chunkFlow"),!0),g(0),t.consume(w);return}return j(w)?(t.consume(w),y(t.exit("chunkFlow")),r=0,e.interrupt=void 0,l):(t.consume(w),m)}function y(w,E){const P=e.sliceStream(w);if(E&&P.push(null),w.previous=o,o&&(o.next=w),o=w,i.defineSkip(w.start),i.write(P),e.parser.lazy[w.start.line]){let S=i.events.length;for(;S--;)if(i.events[S][1].start.offset<s&&(!i.events[S][1].end||i.events[S][1].end.offset>s))return;const D=e.events.length;let F=D,Z,M;for(;F--;)if(e.events[F][0]==="exit"&&e.events[F][1].type==="chunkFlow"){if(Z){M=e.events[F][1].end;break}Z=!0}for(g(r),S=D;S<e.events.length;)e.events[S][1].end={...M},S++;const R=new ns;R.add(F+1,0,e.events.slice(D)),R.add(D,S-D,[]),R.consume(e.events)}}function g(w){let E=n.length;for(;E-- >w;){const P=n[E];e.containerState=P[1],P[0].exit.call(e,t)}n.length=w}function C(){i.write([null]),o=void 0,i=void 0,e.containerState._closeFlow=void 0}}function gy(t,e,n){return ie(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Tt(t){if(t===null||se(t)||Gn(t))return 1;if(fo(t))return 2}function Ss(t,e,n){const r=[];let i=-1;for(;++i<t.length;){const o=t[i].resolveAll;o&&!r.includes(o)&&(e=o(e,n),r.push(o))}return e}const _l={name:"attention",resolveAll:yy,tokenize:ky};function yy(t,e){let n=-1,r;for(;++n<t.length;)if(t[n][0]==="enter"&&t[n][1].type==="attentionSequence"&&t[n][1]._close){let i=n;for(;i--;)if(t[i][0]==="exit"&&t[i][1].type==="attentionSequence"&&t[i][1]._open&&e.sliceSerialize(t[i][1]).charCodeAt(0)===e.sliceSerialize(t[n][1]).charCodeAt(0)){if((t[i][1]._close||t[n][1]._open)&&(t[n][1].end.offset-t[n][1].start.offset)%3&&!((t[i][1].end.offset-t[i][1].start.offset+t[n][1].end.offset-t[n][1].start.offset)%3))continue;const o=t[i][1].end.offset-t[i][1].start.offset>1&&t[n][1].end.offset-t[n][1].start.offset>1?2:1,s={...t[i][1].end},l={...t[n][1].start};xu(s,-o),xu(l,o);const a={type:o>1?"strongSequence":"emphasisSequence",start:s,end:{...t[i][1].end}},c={type:o>1?"strongSequence":"emphasisSequence",start:{...t[n][1].start},end:l},u={type:o>1?"strongText":"emphasisText",start:{...t[i][1].end},end:{...t[n][1].start}},f={type:o>1?"strong":"emphasis",start:{...a.start},end:{...c.end}};t[i][1].end={...a.start},t[n][1].start={...c.end},r=[],t[i][1].end.offset-t[i][1].start.offset&&(r=ot(r,[["enter",t[i][1],e],["exit",t[i][1],e]])),r=ot(r,[["enter",f,e],["enter",a,e],["exit",a,e],["enter",u,e]]),r=ot(r,Ss(e.parser.constructs.insideSpan.null,t.slice(i+1,n),e)),r=ot(r,[["exit",u,e],["enter",c,e],["exit",c,e],["exit",f,e]]);let d=0;t[n][1].end.offset-t[n][1].start.offset&&(d=2,r=ot(r,[["enter",t[n][1],e],["exit",t[n][1],e]])),mt(t,i-1,n-i+3,r),n=i+r.length-d-2;break}}for(n=-1;++n<t.length;)t[n][1].type==="attentionSequence"&&(t[n][1].type="data");return t}function ky(t,e){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Tt(r);let o;return s;function s(a){return o=a,t.enter("attentionSequence"),l(a)}function l(a){if(a===o)return t.consume(a),l;const c=t.exit("attentionSequence"),u=Tt(a),f=!u||u===2&&i||n.includes(a)&&a!==42&&a!==95,d=!i||i===2&&u||n.includes(r)&&r!==42&&r!==95;return c._open=!!(o===42?f:f&&(i||!d)),c._close=!!(o===42?d:d&&(u||!f)),e(a)}}function xu(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const by={name:"autolink",tokenize:xy};function xy(t,e,n){let r=0;return i;function i(h){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(h),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),o}function o(h){return Ce(h)?(t.consume(h),s):h===64?n(h):c(h)}function s(h){return h===43||h===45||h===46||Re(h)?(r=1,l(h)):c(h)}function l(h){return h===58?(t.consume(h),r=0,a):(h===43||h===45||h===46||Re(h))&&r++<32?(t.consume(h),l):(r=0,c(h))}function a(h){return h===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(h),t.exit("autolinkMarker"),t.exit("autolink"),e):h===null||h===32||h===60||ts(h)?n(h):(t.consume(h),a)}function c(h){return h===64?(t.consume(h),u):uy(h)?(t.consume(h),c):n(h)}function u(h){return Re(h)?f(h):n(h)}function f(h){return h===46?(t.consume(h),r=0,u):h===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(h),t.exit("autolinkMarker"),t.exit("autolink"),e):d(h)}function d(h){if((h===45||Re(h))&&r++<63){const p=h===45?d:f;return t.consume(h),p}return n(h)}}const ho={partial:!0,tokenize:wy};function wy(t,e,n){return r;function r(o){return X(o)?ie(t,i,"linePrefix")(o):i(o)}function i(o){return o===null||j(o)?e(o):n(o)}}const Dh={continuation:{tokenize:Sy},exit:My,name:"blockQuote",tokenize:Cy};function Cy(t,e,n){const r=this;return i;function i(s){if(s===62){const l=r.containerState;return l.open||(t.enter("blockQuote",{_container:!0}),l.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(s),t.exit("blockQuoteMarker"),o}return n(s)}function o(s){return X(s)?(t.enter("blockQuotePrefixWhitespace"),t.consume(s),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(s))}}function Sy(t,e,n){const r=this;return i;function i(s){return X(s)?ie(t,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):o(s)}function o(s){return t.attempt(Dh,e,n)(s)}}function My(t){t.exit("blockQuote")}const Rh={name:"characterEscape",tokenize:Ny};function Ny(t,e,n){return r;function r(o){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(o),t.exit("escapeMarker"),i}function i(o){return vh(o)?(t.enter("characterEscapeValue"),t.consume(o),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(o)}}const zh={name:"characterReference",tokenize:Ty};function Ty(t,e,n){const r=this;let i=0,o,s;return l;function l(f){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(f),t.exit("characterReferenceMarker"),a}function a(f){return f===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(f),t.exit("characterReferenceMarkerNumeric"),c):(t.enter("characterReferenceValue"),o=31,s=Re,u(f))}function c(f){return f===88||f===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(f),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),o=6,s=fy,u):(t.enter("characterReferenceValue"),o=7,s=Fl,u(f))}function u(f){if(f===59&&i){const d=t.exit("characterReferenceValue");return s===Re&&!Na(r.sliceSerialize(d))?n(f):(t.enter("characterReferenceMarker"),t.consume(f),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return s(f)&&i++<o?(t.consume(f),u):n(f)}}const $l={partial:!0,tokenize:Iy};function Iy(t,e,n){const r=this;return i;function i(s){return s===null?n(s):(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),o)}function o(s){return r.parser.lazy[r.now().line]?n(s):e(s)}}const wu={concrete:!0,name:"codeFenced",tokenize:Ay};function Ay(t,e,n){const r=this,i={partial:!0,tokenize:P};let o=0,s=0,l;return a;function a(S){return c(S)}function c(S){const D=r.events[r.events.length-1];return o=D&&D[1].type==="linePrefix"?D[2].sliceSerialize(D[1],!0).length:0,l=S,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),u(S)}function u(S){return S===l?(s++,t.consume(S),u):s<3?n(S):(t.exit("codeFencedFenceSequence"),X(S)?ie(t,f,"whitespace")(S):f(S))}function f(S){return S===null||j(S)?(t.exit("codeFencedFence"),r.interrupt?e(S):t.check($l,m,E)(S)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),d(S))}function d(S){return S===null||j(S)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),f(S)):X(S)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),ie(t,h,"whitespace")(S)):S===96&&S===l?n(S):(t.consume(S),d)}function h(S){return S===null||j(S)?f(S):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),p(S))}function p(S){return S===null||j(S)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),f(S)):S===96&&S===l?n(S):(t.consume(S),p)}function m(S){return t.attempt(i,E,y)(S)}function y(S){return t.enter("lineEnding"),t.consume(S),t.exit("lineEnding"),g}function g(S){return o>0&&X(S)?ie(t,C,"linePrefix",o+1)(S):C(S)}function C(S){return S===null||j(S)?t.check($l,m,E)(S):(t.enter("codeFlowValue"),w(S))}function w(S){return S===null||j(S)?(t.exit("codeFlowValue"),C(S)):(t.consume(S),w)}function E(S){return t.exit("codeFenced"),e(S)}function P(S,D,F){let Z=0;return M;function M(_){return S.enter("lineEnding"),S.consume(_),S.exit("lineEnding"),R}function R(_){return S.enter("codeFencedFence"),X(_)?ie(S,A,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):A(_)}function A(_){return _===l?(S.enter("codeFencedFenceSequence"),L(_)):F(_)}function L(_){return _===l?(Z++,S.consume(_),L):Z>=s?(S.exit("codeFencedFenceSequence"),X(_)?ie(S,V,"whitespace")(_):V(_)):F(_)}function V(_){return _===null||j(_)?(S.exit("codeFencedFence"),D(_)):F(_)}}}const Us={name:"codeIndented",tokenize:vy},Ey={partial:!0,tokenize:Oy};function vy(t,e,n){return r;function r(l){return t.enter("codeIndented"),Oh(t,i,n,"linePrefix",4,4)(l)}function i(l){return l===null?s(l):j(l)?t.attempt(Ey,i,s)(l):(t.enter("codeFlowValue"),o(l))}function o(l){return l===null||j(l)?(t.exit("codeFlowValue"),i(l)):(t.consume(l),o)}function s(l){return t.exit("codeIndented"),e(l)}}function Oy(t,e,n){const r=this;return i;function i(s){return r.parser.lazy[r.now().line]?n(s):j(s)?(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),i):Oh(t,e,o,"linePrefix",4,4)(s)}function o(s){return j(s)?i(s):n(s)}}const Dy={name:"codeText",previous:zy,resolve:Ry,tokenize:Py};function Ry(t){let e=t.length-4,n=3,r,i;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(r=n;++r<e;)if(t[r][1].type==="codeTextData"){t[n][1].type="codeTextPadding",t[e][1].type="codeTextPadding",n+=2,e-=2;break}}for(r=n-1,e++;++r<=e;)i===void 0?r!==e&&t[r][1].type!=="lineEnding"&&(i=r):(r===e||t[r][1].type==="lineEnding")&&(t[i][1].type="codeTextData",r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),e-=r-i-2,r=i+2),i=void 0);return t}function zy(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Py(t,e,n){let r=0,i,o;return s;function s(f){return t.enter("codeText"),t.enter("codeTextSequence"),l(f)}function l(f){return f===96?(t.consume(f),r++,l):(t.exit("codeTextSequence"),a(f))}function a(f){return f===null?n(f):f===32?(t.enter("space"),t.consume(f),t.exit("space"),a):f===96?(o=t.enter("codeTextSequence"),i=0,u(f)):j(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),a):(t.enter("codeTextData"),c(f))}function c(f){return f===null||f===32||f===96||j(f)?(t.exit("codeTextData"),a(f)):(t.consume(f),c)}function u(f){return f===96?(t.consume(f),i++,u):i===r?(t.exit("codeTextSequence"),t.exit("codeText"),e(f)):(o.type="codeTextData",c(f))}}class By{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,n,r){const i=n||0;this.setCursor(Math.trunc(e));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&ui(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),ui(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),ui(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const n=this.left.splice(e,Number.POSITIVE_INFINITY);ui(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);ui(this.left,n.reverse())}}}function ui(t,e){let n=0;if(e.length<1e4)t.push(...e);else for(;n<e.length;)t.push(...e.slice(n,n+1e4)),n+=1e4}function Ph(t){const e={};let n=-1,r,i,o,s,l,a,c;const u=new By(t);for(;++n<u.length;){for(;n in e;)n=e[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.get(n-1)[1].type==="listItemPrefix"&&(a=r[1]._tokenizer.events,o=0,o<a.length&&a[o][1].type==="lineEndingBlank"&&(o+=2),o<a.length&&a[o][1].type==="content"))for(;++o<a.length&&a[o][1].type!=="content";)a[o][1].type==="chunkText"&&(a[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(e,Ly(u,n)),n=e[n],c=!0);else if(r[1]._container){for(o=n,i=void 0;o--;)if(s=u.get(o),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),s[1].type="lineEnding",i=o);else if(!(s[1].type==="linePrefix"||s[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},l=u.slice(i,n),l.unshift(r),u.splice(i,n-i+1,l))}}return mt(t,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function Ly(t,e){const n=t.get(e)[1],r=t.get(e)[2];let i=e-1;const o=[];let s=n._tokenizer;s||(s=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));const l=s.events,a=[],c={};let u,f,d=-1,h=n,p=0,m=0;const y=[m];for(;h;){for(;t.get(++i)[1]!==h;);o.push(i),h._tokenizer||(u=r.sliceStream(h),h.next||u.push(null),f&&s.defineSkip(h.start),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(u),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++d<l.length;)l[d][0]==="exit"&&l[d-1][0]==="enter"&&l[d][1].type===l[d-1][1].type&&l[d][1].start.line!==l[d][1].end.line&&(m=d+1,y.push(m),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(s.events=[],h?(h._tokenizer=void 0,h.previous=void 0):y.pop(),d=y.length;d--;){const g=l.slice(y[d],y[d+1]),C=o.pop();a.push([C,C+g.length-1]),t.splice(C,2,g)}for(a.reverse(),d=-1;++d<a.length;)c[p+a[d][0]]=p+a[d][1],p+=a[d][1]-a[d][0]-1;return c}const Fy={resolve:$y,tokenize:Vy},_y={partial:!0,tokenize:jy};function $y(t){return Ph(t),t}function Vy(t,e){let n;return r;function r(l){return t.enter("content"),n=t.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?o(l):j(l)?t.check(_y,s,o)(l):(t.consume(l),i)}function o(l){return t.exit("chunkContent"),t.exit("content"),e(l)}function s(l){return t.consume(l),t.exit("chunkContent"),n.next=t.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function jy(t,e,n){const r=this;return i;function i(s){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),ie(t,o,"linePrefix")}function o(s){if(s===null||j(s))return n(s);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?e(s):t.interrupt(r.parser.constructs.flow,n,e)(s)}}function Bh(t,e,n,r,i,o,s,l,a){const c=a||Number.POSITIVE_INFINITY;let u=0;return f;function f(g){return g===60?(t.enter(r),t.enter(i),t.enter(o),t.consume(g),t.exit(o),d):g===null||g===32||g===41||ts(g)?n(g):(t.enter(r),t.enter(s),t.enter(l),t.enter("chunkString",{contentType:"string"}),m(g))}function d(g){return g===62?(t.enter(o),t.consume(g),t.exit(o),t.exit(i),t.exit(r),e):(t.enter(l),t.enter("chunkString",{contentType:"string"}),h(g))}function h(g){return g===62?(t.exit("chunkString"),t.exit(l),d(g)):g===null||g===60||j(g)?n(g):(t.consume(g),g===92?p:h)}function p(g){return g===60||g===62||g===92?(t.consume(g),h):h(g)}function m(g){return!u&&(g===null||g===41||se(g))?(t.exit("chunkString"),t.exit(l),t.exit(s),t.exit(r),e(g)):u<c&&g===40?(t.consume(g),u++,m):g===41?(t.consume(g),u--,m):g===null||g===32||g===40||ts(g)?n(g):(t.consume(g),g===92?y:m)}function y(g){return g===40||g===41||g===92?(t.consume(g),m):m(g)}}function Lh(t,e,n,r,i,o){const s=this;let l=0,a;return c;function c(h){return t.enter(r),t.enter(i),t.consume(h),t.exit(i),t.enter(o),u}function u(h){return l>999||h===null||h===91||h===93&&!a||h===94&&!l&&"_hiddenFootnoteSupport"in s.parser.constructs?n(h):h===93?(t.exit(o),t.enter(i),t.consume(h),t.exit(i),t.exit(r),e):j(h)?(t.enter("lineEnding"),t.consume(h),t.exit("lineEnding"),u):(t.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||j(h)||l++>999?(t.exit("chunkString"),u(h)):(t.consume(h),a||(a=!X(h)),h===92?d:f)}function d(h){return h===91||h===92||h===93?(t.consume(h),l++,f):f(h)}}function Fh(t,e,n,r,i,o){let s;return l;function l(d){return d===34||d===39||d===40?(t.enter(r),t.enter(i),t.consume(d),t.exit(i),s=d===40?41:d,a):n(d)}function a(d){return d===s?(t.enter(i),t.consume(d),t.exit(i),t.exit(r),e):(t.enter(o),c(d))}function c(d){return d===s?(t.exit(o),a(s)):d===null?n(d):j(d)?(t.enter("lineEnding"),t.consume(d),t.exit("lineEnding"),ie(t,c,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),u(d))}function u(d){return d===s||d===null||j(d)?(t.exit("chunkString"),c(d)):(t.consume(d),d===92?f:u)}function f(d){return d===s||d===92?(t.consume(d),u):u(d)}}function yi(t,e){let n;return r;function r(i){return j(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),n=!0,r):X(i)?ie(t,r,n?"linePrefix":"lineSuffix")(i):e(i)}}const Hy={name:"definition",tokenize:Wy},qy={partial:!0,tokenize:Ky};function Wy(t,e,n){const r=this;let i;return o;function o(h){return t.enter("definition"),s(h)}function s(h){return Lh.call(r,t,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return i=gt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),a):n(h)}function a(h){return se(h)?yi(t,c)(h):c(h)}function c(h){return Bh(t,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function u(h){return t.attempt(qy,f,f)(h)}function f(h){return X(h)?ie(t,d,"whitespace")(h):d(h)}function d(h){return h===null||j(h)?(t.exit("definition"),r.parser.defined.push(i),e(h)):n(h)}}function Ky(t,e,n){return r;function r(l){return se(l)?yi(t,i)(l):n(l)}function i(l){return Fh(t,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return X(l)?ie(t,s,"whitespace")(l):s(l)}function s(l){return l===null||j(l)?e(l):n(l)}}const Jy={name:"hardBreakEscape",tokenize:Uy};function Uy(t,e,n){return r;function r(o){return t.enter("hardBreakEscape"),t.consume(o),i}function i(o){return j(o)?(t.exit("hardBreakEscape"),e(o)):n(o)}}const Gy={name:"headingAtx",resolve:Yy,tokenize:Qy};function Yy(t,e){let n=t.length-2,r=3;if(t[r][1].type==="whitespace"&&(r+=2),n-2>r&&t[n][1].type==="whitespace"&&(n-=2),t[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&t[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r){const i={type:"atxHeadingText",start:t[r][1].start,end:t[n][1].end},o={type:"chunkText",start:t[r][1].start,end:t[n][1].end,contentType:"text"};mt(t,r,n-r+1,[["enter",i,e],["enter",o,e],["exit",o,e],["exit",i,e]])}return t}function Qy(t,e,n){let r=0;return i;function i(u){return t.enter("atxHeading"),o(u)}function o(u){return t.enter("atxHeadingSequence"),s(u)}function s(u){return u===35&&r++<6?(t.consume(u),s):u===null||se(u)?(t.exit("atxHeadingSequence"),l(u)):n(u)}function l(u){return u===35?(t.enter("atxHeadingSequence"),a(u)):u===null||j(u)?(t.exit("atxHeading"),e(u)):X(u)?ie(t,l,"whitespace")(u):(t.enter("atxHeadingText"),c(u))}function a(u){return u===35?(t.consume(u),a):(t.exit("atxHeadingSequence"),l(u))}function c(u){return u===null||u===35||se(u)?(t.exit("atxHeadingText"),l(u)):(t.consume(u),c)}}const _h=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Vl=["pre","script","style","textarea"],Xy={concrete:!0,name:"htmlFlow",resolveTo:ek,tokenize:tk},Zy={partial:!0,tokenize:nk};function ek(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function tk(t,e,n){const r=this;let i,o,s,l,a;return c;function c(b){return u(b)}function u(b){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(b),f}function f(b){return b===33?(t.consume(b),d):b===47?(t.consume(b),o=!0,m):b===63?(t.consume(b),i=3,r.interrupt?e:k):Ce(b)?(t.consume(b),s=String.fromCharCode(b),y):n(b)}function d(b){return b===45?(t.consume(b),i=2,h):b===91?(t.consume(b),i=5,l=0,p):Ce(b)?(t.consume(b),i=4,r.interrupt?e:k):n(b)}function h(b){return b===45?(t.consume(b),r.interrupt?e:k):n(b)}function p(b){const ft="CDATA[";return b===ft.charCodeAt(l++)?(t.consume(b),l===ft.length?r.interrupt?e:A:p):n(b)}function m(b){return Ce(b)?(t.consume(b),s=String.fromCharCode(b),y):n(b)}function y(b){if(b===null||b===47||b===62||se(b)){const ft=b===47,ar=s.toLowerCase();return!ft&&!o&&Vl.includes(ar)?(i=1,r.interrupt?e(b):A(b)):_h.includes(s.toLowerCase())?(i=6,ft?(t.consume(b),g):r.interrupt?e(b):A(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(b):o?C(b):w(b))}return b===45||Re(b)?(t.consume(b),s+=String.fromCharCode(b),y):n(b)}function g(b){return b===62?(t.consume(b),r.interrupt?e:A):n(b)}function C(b){return X(b)?(t.consume(b),C):M(b)}function w(b){return b===47?(t.consume(b),M):b===58||b===95||Ce(b)?(t.consume(b),E):X(b)?(t.consume(b),w):M(b)}function E(b){return b===45||b===46||b===58||b===95||Re(b)?(t.consume(b),E):P(b)}function P(b){return b===61?(t.consume(b),S):X(b)?(t.consume(b),P):w(b)}function S(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(t.consume(b),a=b,D):X(b)?(t.consume(b),S):F(b)}function D(b){return b===a?(t.consume(b),a=null,Z):b===null||j(b)?n(b):(t.consume(b),D)}function F(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||se(b)?P(b):(t.consume(b),F)}function Z(b){return b===47||b===62||X(b)?w(b):n(b)}function M(b){return b===62?(t.consume(b),R):n(b)}function R(b){return b===null||j(b)?A(b):X(b)?(t.consume(b),R):n(b)}function A(b){return b===45&&i===2?(t.consume(b),Y):b===60&&i===1?(t.consume(b),ne):b===62&&i===4?(t.consume(b),Oe):b===63&&i===3?(t.consume(b),k):b===93&&i===5?(t.consume(b),be):j(b)&&(i===6||i===7)?(t.exit("htmlFlowData"),t.check(Zy,fe,L)(b)):b===null||j(b)?(t.exit("htmlFlowData"),L(b)):(t.consume(b),A)}function L(b){return t.check($l,V,fe)(b)}function V(b){return t.enter("lineEnding"),t.consume(b),t.exit("lineEnding"),_}function _(b){return b===null||j(b)?L(b):(t.enter("htmlFlowData"),A(b))}function Y(b){return b===45?(t.consume(b),k):A(b)}function ne(b){return b===47?(t.consume(b),s="",ce):A(b)}function ce(b){if(b===62){const ft=s.toLowerCase();return Vl.includes(ft)?(t.consume(b),Oe):A(b)}return Ce(b)&&s.length<8?(t.consume(b),s+=String.fromCharCode(b),ce):A(b)}function be(b){return b===93?(t.consume(b),k):A(b)}function k(b){return b===62?(t.consume(b),Oe):b===45&&i===2?(t.consume(b),k):A(b)}function Oe(b){return b===null||j(b)?(t.exit("htmlFlowData"),fe(b)):(t.consume(b),Oe)}function fe(b){return t.exit("htmlFlow"),e(b)}}function nk(t,e,n){return r;function r(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),t.attempt(ho,e,n)}}const rk={name:"htmlText",tokenize:ik};function ik(t,e,n){const r=this;let i,o,s;return l;function l(k){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(k),a}function a(k){return k===33?(t.consume(k),c):k===47?(t.consume(k),P):k===63?(t.consume(k),w):Ce(k)?(t.consume(k),F):n(k)}function c(k){return k===45?(t.consume(k),u):k===91?(t.consume(k),o=0,p):Ce(k)?(t.consume(k),C):n(k)}function u(k){return k===45?(t.consume(k),h):n(k)}function f(k){return k===null?n(k):k===45?(t.consume(k),d):j(k)?(s=f,ne(k)):(t.consume(k),f)}function d(k){return k===45?(t.consume(k),h):f(k)}function h(k){return k===62?Y(k):k===45?d(k):f(k)}function p(k){const Oe="CDATA[";return k===Oe.charCodeAt(o++)?(t.consume(k),o===Oe.length?m:p):n(k)}function m(k){return k===null?n(k):k===93?(t.consume(k),y):j(k)?(s=m,ne(k)):(t.consume(k),m)}function y(k){return k===93?(t.consume(k),g):m(k)}function g(k){return k===62?Y(k):k===93?(t.consume(k),g):m(k)}function C(k){return k===null||k===62?Y(k):j(k)?(s=C,ne(k)):(t.consume(k),C)}function w(k){return k===null?n(k):k===63?(t.consume(k),E):j(k)?(s=w,ne(k)):(t.consume(k),w)}function E(k){return k===62?Y(k):w(k)}function P(k){return Ce(k)?(t.consume(k),S):n(k)}function S(k){return k===45||Re(k)?(t.consume(k),S):D(k)}function D(k){return j(k)?(s=D,ne(k)):X(k)?(t.consume(k),D):Y(k)}function F(k){return k===45||Re(k)?(t.consume(k),F):k===47||k===62||se(k)?Z(k):n(k)}function Z(k){return k===47?(t.consume(k),Y):k===58||k===95||Ce(k)?(t.consume(k),M):j(k)?(s=Z,ne(k)):X(k)?(t.consume(k),Z):Y(k)}function M(k){return k===45||k===46||k===58||k===95||Re(k)?(t.consume(k),M):R(k)}function R(k){return k===61?(t.consume(k),A):j(k)?(s=R,ne(k)):X(k)?(t.consume(k),R):Z(k)}function A(k){return k===null||k===60||k===61||k===62||k===96?n(k):k===34||k===39?(t.consume(k),i=k,L):j(k)?(s=A,ne(k)):X(k)?(t.consume(k),A):(t.consume(k),V)}function L(k){return k===i?(t.consume(k),i=void 0,_):k===null?n(k):j(k)?(s=L,ne(k)):(t.consume(k),L)}function V(k){return k===null||k===34||k===39||k===60||k===61||k===96?n(k):k===47||k===62||se(k)?Z(k):(t.consume(k),V)}function _(k){return k===47||k===62||se(k)?Z(k):n(k)}function Y(k){return k===62?(t.consume(k),t.exit("htmlTextData"),t.exit("htmlText"),e):n(k)}function ne(k){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(k),t.exit("lineEnding"),ce}function ce(k){return X(k)?ie(t,be,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):be(k)}function be(k){return t.enter("htmlTextData"),s(k)}}const Ta={name:"labelEnd",resolveAll:ak,resolveTo:ck,tokenize:uk},ok={tokenize:fk},sk={tokenize:hk},lk={tokenize:dk};function ak(t){let e=-1;const n=[];for(;++e<t.length;){const r=t[e][1];if(n.push(t[e]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",e+=i}}return t.length!==n.length&&mt(t,0,t.length,n),t}function ck(t,e){let n=t.length,r=0,i,o,s;for(;n--;){const u=t[n][1];if(i){if(u.type==="link"||u.type==="labelLink"&&u._inactive)break;t[n][0]==="enter"&&u.type==="labelLink"&&(u._inactive=!0)}else if(o){if(t[n][0]==="enter"&&(u.type==="labelImage"||u.type==="labelLink")&&!u._balanced&&(i=n,u.type!=="labelLink")){r=2;break}}else u.type==="labelEnd"&&(o=n)}const l={type:t[i][1].type==="labelLink"?"link":"image",start:{...t[i][1].start},end:{...t[t.length-1][1].end}},a={type:"label",start:{...t[i][1].start},end:{...t[o][1].end}},c={type:"labelText",start:{...t[i+r+2][1].end},end:{...t[o-2][1].start}};return s=[["enter",l,e],["enter",a,e]],s=ot(s,t.slice(i+1,i+r+3)),s=ot(s,[["enter",c,e]]),s=ot(s,Ss(e.parser.constructs.insideSpan.null,t.slice(i+r+4,o-3),e)),s=ot(s,[["exit",c,e],t[o-2],t[o-1],["exit",a,e]]),s=ot(s,t.slice(o+1)),s=ot(s,[["exit",l,e]]),mt(t,i,t.length,s),t}function uk(t,e,n){const r=this,i=r._labelStarts;let o,s;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();o=i[i.length-1]}return l;function l(d){return o?o._inactive?f(d):(s=r.parser.defined.includes(gt(r.sliceSerialize({start:o.end,end:r.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(d),t.exit("labelMarker"),t.exit("labelEnd"),a):n(d)}function a(d){return d===40?t.attempt(ok,u,s?u:f)(d):d===91?t.attempt(sk,u,s?c:f)(d):s?u(d):f(d)}function c(d){return t.attempt(lk,u,f)(d)}function u(d){return i.pop(),e(d)}function f(d){return o._balanced=!0,n(d)}}function fk(t,e,n){return r;function r(f){return t.enter("resource"),t.enter("resourceMarker"),t.consume(f),t.exit("resourceMarker"),i}function i(f){return se(f)?yi(t,o)(f):o(f)}function o(f){return f===41?u(f):Bh(t,s,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function s(f){return se(f)?yi(t,a)(f):u(f)}function l(f){return n(f)}function a(f){return f===34||f===39||f===40?Fh(t,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):u(f)}function c(f){return se(f)?yi(t,u)(f):u(f)}function u(f){return f===41?(t.enter("resourceMarker"),t.consume(f),t.exit("resourceMarker"),t.exit("resource"),e):n(f)}}function hk(t,e,n){const r=this;return i;function i(l){return Lh.call(r,t,o,s,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(gt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(l):n(l)}function s(l){return n(l)}}function dk(t,e,n){return r;function r(o){return t.enter("reference"),t.enter("referenceMarker"),t.consume(o),t.exit("referenceMarker"),i}function i(o){return o===93?(t.enter("referenceMarker"),t.consume(o),t.exit("referenceMarker"),t.exit("reference"),e):n(o)}}const pk={name:"labelStartImage",resolveAll:Ta.resolveAll,tokenize:mk};function mk(t,e,n){const r=this;let i;return o;function o(a){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(a),t.exit("labelImageMarker"),s}function s(a){return a===91?(t.enter("labelMarker"),t.consume(a),t.exit("labelMarker"),i=t.exit("labelImage"),l):n(a)}function l(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),e(a))}}const gk={name:"labelStartLink",resolveAll:Ta.resolveAll,tokenize:yk};function yk(t,e,n){const r=this;let i;return o;function o(l){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(l),t.exit("labelMarker"),i=t.exit("labelLink"),s}function s(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),e(l))}}const Gs={name:"lineEnding",tokenize:kk};function kk(t,e){return n;function n(r){return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),ie(t,e,"linePrefix")}}const Vo={name:"thematicBreak",tokenize:bk};function bk(t,e,n){let r=0,i;return o;function o(c){return t.enter("thematicBreak"),s(c)}function s(c){return i=c,l(c)}function l(c){return c===i?(t.enter("thematicBreakSequence"),a(c)):r>=3&&(c===null||j(c))?(t.exit("thematicBreak"),e(c)):n(c)}function a(c){return c===i?(t.consume(c),r++,a):(t.exit("thematicBreakSequence"),X(c)?ie(t,l,"whitespace")(c):l(c))}}const _e={continuation:{tokenize:Sk},exit:Nk,name:"list",tokenize:Ck},xk={partial:!0,tokenize:Tk},wk={partial:!0,tokenize:Mk};function Ck(t,e,n){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,s=0;return l;function l(h){const p=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(p==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Fl(h)){if(r.containerState.type||(r.containerState.type=p,t.enter(p,{_container:!0})),p==="listUnordered")return t.enter("listItemPrefix"),h===42||h===45?t.check(Vo,n,c)(h):c(h);if(!r.interrupt||h===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),a(h)}return n(h)}function a(h){return Fl(h)&&++s<10?(t.consume(h),a):(!r.interrupt||s<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(t.exit("listItemValue"),c(h)):n(h)}function c(h){return t.enter("listItemMarker"),t.consume(h),t.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,t.check(ho,r.interrupt?n:u,t.attempt(xk,d,f))}function u(h){return r.containerState.initialBlankLine=!0,o++,d(h)}function f(h){return X(h)?(t.enter("listItemPrefixWhitespace"),t.consume(h),t.exit("listItemPrefixWhitespace"),d):n(h)}function d(h){return r.containerState.size=o+r.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(h)}}function Sk(t,e,n){const r=this;return r.containerState._closeFlow=void 0,t.check(ho,i,o);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ie(t,e,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!X(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,t.attempt(wk,e,s)(l))}function s(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,ie(t,t.attempt(_e,e,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function Mk(t,e,n){const r=this;return ie(t,i,"listItemIndent",r.containerState.size+1);function i(o){const s=r.events[r.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?e(o):n(o)}}function Nk(t){t.exit(this.containerState.type)}function Tk(t,e,n){const r=this;return ie(t,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const s=r.events[r.events.length-1];return!X(o)&&s&&s[1].type==="listItemPrefixWhitespace"?e(o):n(o)}}const Cu={name:"setextUnderline",resolveTo:Ik,tokenize:Ak};function Ik(t,e){const n=new ns;let r=t.length,i,o,s;for(;r--;)if(t[r][0]==="enter"){if(t[r][1].type==="content"){i=r;break}t[r][1].type==="paragraph"&&(o=r)}else t[r][1].type==="content"&&n.add(r,1,[]),!s&&t[r][1].type==="definition"&&(s=r);const l={type:"setextHeading",start:{...t[i][1].start},end:{...t[t.length-1][1].end}};return t[o][1].type="setextHeadingText",s?(n.add(o,0,[["enter",l,e]]),n.add(s+1,0,[["exit",t[i][1],e]]),t[i][1].end={...t[s][1].end}):t[i][1]=l,n.add(t.length,0,[["exit",l,e]]),n.consume(t),t}function Ak(t,e,n){const r=this;let i;return o;function o(c){let u=r.events.length,f;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){f=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(t.enter("setextHeadingLine"),i=c,s(c)):n(c)}function s(c){return t.enter("setextHeadingLineSequence"),l(c)}function l(c){return c===i?(t.consume(c),l):(t.exit("setextHeadingLineSequence"),X(c)?ie(t,a,"lineSuffix")(c):a(c))}function a(c){return c===null||j(c)?(t.exit("setextHeadingLine"),e(c)):n(c)}}const Ek={tokenize:vk};function vk(t){const e=this,n=t.attempt(ho,r,t.attempt(this.parser.constructs.flowInitial,i,ie(t,t.attempt(this.parser.constructs.flow,i,t.attempt(Fy,i)),"linePrefix")));return n;function r(o){if(o===null){t.consume(o);return}return t.enter("lineEndingBlank"),t.consume(o),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n}function i(o){if(o===null){t.consume(o);return}return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),e.currentConstruct=void 0,n}}const Ok={resolveAll:Vh()},Dk=$h("string"),Rk=$h("text");function $h(t){return{resolveAll:Vh(t==="text"?zk:void 0),tokenize:e};function e(n){const r=this,i=this.parser.constructs[t],o=n.attempt(i,s,l);return s;function s(u){return c(u)?o(u):l(u)}function l(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),a}function a(u){return c(u)?(n.exit("data"),o(u)):(n.consume(u),a)}function c(u){if(u===null)return!0;const f=i[u];let d=-1;if(f)for(;++d<f.length;){const h=f[d];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function Vh(t){return e;function e(n,r){let i=-1,o;for(;++i<=n.length;)o===void 0?n[i]&&n[i][1].type==="data"&&(o=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==o+2&&(n[o][1].end=n[i-1][1].end,n.splice(o+2,i-o-2),i=o+2),o=void 0);return t?t(n,r):n}}function zk(t,e){const n=new ns;let r=0;for(;++r<=t.length;)if((r===t.length||t[r][1].type==="lineEnding")&&t[r-1][1].type==="data"){const i=t[r-1][1],o=e.sliceStream(i);let s=o.length,l=-1,a=0,c;for(;s--;){const u=o[s];if(typeof u=="string"){for(l=u.length;u.charCodeAt(l-1)===32;)a++,l--;if(l)break;l=-1}else if(u===-2)c=!0,a++;else if(u!==-1){s++;break}}if(e._contentTypeTextTrailing&&r===t.length&&(a=0),a){const u={type:r===t.length||c||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?l:i.start._bufferIndex+l,_index:i.start._index+s,line:i.end.line,column:i.end.column-a,offset:i.end.offset-a},end:{...i.end}};i.end={...u.start},i.start.offset===i.end.offset?Object.assign(i,u):n.add(r,0,[["enter",u,e],["exit",u,e]])}r++}return n.consume(t),t}const Pk={42:_e,43:_e,45:_e,48:_e,49:_e,50:_e,51:_e,52:_e,53:_e,54:_e,55:_e,56:_e,57:_e,62:Dh},Bk={91:Hy},Lk={[-2]:Us,[-1]:Us,32:Us},Fk={35:Gy,42:Vo,45:[Cu,Vo],60:Xy,61:Cu,95:Vo,96:wu,126:wu},_k={38:zh,92:Rh},$k={[-5]:Gs,[-4]:Gs,[-3]:Gs,33:pk,38:zh,42:_l,60:[by,rk],91:gk,92:[Jy,Rh],93:Ta,95:_l,96:Dy},Vk={null:[_l,Ok]},jk={null:[42,95]},Hk={null:[]},qk=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:jk,contentInitial:Bk,disable:Hk,document:Pk,flow:Fk,flowInitial:Lk,insideSpan:Vk,string:_k,text:$k},Symbol.toStringTag,{value:"Module"}));function Wk(t,e,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},o=[];let s=[],l=[];const a={attempt:D(P),check:D(S),consume:C,enter:w,exit:E,interrupt:D(S,{interrupt:!0})},c={code:null,containerState:{},defineSkip:m,events:[],now:p,parser:t,previous:null,sliceSerialize:d,sliceStream:h,write:f};let u=e.tokenize.call(c,a);return e.resolveAll&&o.push(e),c;function f(R){return s=ot(s,R),y(),s[s.length-1]!==null?[]:(F(e,0),c.events=Ss(o,c.events,c),c.events)}function d(R,A){return Jk(h(R),A)}function h(R){return Kk(s,R)}function p(){const{_bufferIndex:R,_index:A,line:L,column:V,offset:_}=r;return{_bufferIndex:R,_index:A,line:L,column:V,offset:_}}function m(R){i[R.line]=R.column,M()}function y(){for(;r._index<s.length;){const R=s[r._index];if(typeof R=="string"){const A=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===A&&r._bufferIndex<R.length;)g(R.charCodeAt(r._bufferIndex))}else g(R)}}function g(R){u=u(R)}function C(R){j(R)?(r.line++,r.column=1,r.offset+=R===-3?2:1,M()):R!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=R}function w(R,A){const L=A||{};return L.type=R,L.start=p(),c.events.push(["enter",L,c]),l.push(L),L}function E(R){const A=l.pop();return A.end=p(),c.events.push(["exit",A,c]),A}function P(R,A){F(R,A.from)}function S(R,A){A.restore()}function D(R,A){return L;function L(V,_,Y){let ne,ce,be,k;return Array.isArray(V)?fe(V):"tokenize"in V?fe([V]):Oe(V);function Oe(ye){return si;function si(sn){const cr=sn!==null&&ye[sn],ur=sn!==null&&ye.null,Ws=[...Array.isArray(cr)?cr:cr?[cr]:[],...Array.isArray(ur)?ur:ur?[ur]:[]];return fe(Ws)(sn)}}function fe(ye){return ne=ye,ce=0,ye.length===0?Y:b(ye[ce])}function b(ye){return si;function si(sn){return k=Z(),be=ye,ye.partial||(c.currentConstruct=ye),ye.name&&c.parser.constructs.disable.null.includes(ye.name)?ar():ye.tokenize.call(A?Object.assign(Object.create(c),A):c,a,ft,ar)(sn)}}function ft(ye){return R(be,k),_}function ar(ye){return k.restore(),++ce<ne.length?b(ne[ce]):Y}}}function F(R,A){R.resolveAll&&!o.includes(R)&&o.push(R),R.resolve&&mt(c.events,A,c.events.length-A,R.resolve(c.events.slice(A),c)),R.resolveTo&&(c.events=R.resolveTo(c.events,c))}function Z(){const R=p(),A=c.previous,L=c.currentConstruct,V=c.events.length,_=Array.from(l);return{from:V,restore:Y};function Y(){r=R,c.previous=A,c.currentConstruct=L,c.events.length=V,l=_,M()}}function M(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Kk(t,e){const n=e.start._index,r=e.start._bufferIndex,i=e.end._index,o=e.end._bufferIndex;let s;if(n===i)s=[t[n].slice(r,o)];else{if(s=t.slice(n,i),r>-1){const l=s[0];typeof l=="string"?s[0]=l.slice(r):s.shift()}o>0&&s.push(t[i].slice(0,o))}return s}function Jk(t,e){let n=-1;const r=[];let i;for(;++n<t.length;){const o=t[n];let s;if(typeof o=="string")s=o;else switch(o){case-5:{s="\r";break}case-4:{s=`
|
|
3
|
-
`;break}case-3:{s=`\r
|
|
4
|
-
`;break}case-2:{s=e?" ":" ";break}case-1:{if(!e&&i)continue;s=" ";break}default:s=String.fromCharCode(o)}i=o===-2,r.push(s)}return r.join("")}function Uk(t){const r={constructs:Ah([qk,...(t||{}).extensions||[]]),content:i(hy),defined:[],document:i(py),flow:i(Ek),lazy:{},string:i(Dk),text:i(Rk)};return r;function i(o){return s;function s(l){return Wk(r,o,l)}}}function Gk(t){for(;!Ph(t););return t}const Su=/[\0\t\n\r]/g;function Yk(){let t=1,e="",n=!0,r;return i;function i(o,s,l){o=e+(typeof o=="string"?o.toString():new TextDecoder(s||void 0).decode(o));const a=[];let c=0;for(e="",n&&(o.charCodeAt(0)===65279&&c++,n=void 0);c<o.length;){Su.lastIndex=c;const u=Su.exec(o),f=u&&u.index!==void 0?u.index:o.length,d=o.charCodeAt(f);if(!u){e=o.slice(c);break}if(d===10&&c===f&&r)a.push(-3),r=void 0;else switch(r&&(a.push(-5),r=void 0),c<f&&(a.push(o.slice(c,f)),t+=f-c),d){case 0:{a.push(65533),t++;break}case 9:{const h=Math.ceil(t/4)*4;for(a.push(-2);t++<h;)a.push(-1);break}case 10:{a.push(-4),t=1;break}default:r=!0,t=1}c=f+1}return l&&(r&&a.push(-5),e&&a.push(e),a.push(null)),a}}const Qk=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function jh(t){return t.replace(Qk,Xk)}function Xk(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),o=i===120||i===88;return Eh(n.slice(o?2:1),o?16:10)}return Na(n)||t}function ki(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?Mu(t.position):"start"in t||"end"in t?Mu(t):"line"in t||"column"in t?jl(t):""}function jl(t){return Nu(t&&t.line)+":"+Nu(t&&t.column)}function Mu(t){return jl(t&&t.start)+"-"+jl(t&&t.end)}function Nu(t){return t&&typeof t=="number"?t:1}const Hh={}.hasOwnProperty;function Zk(t,e,n){return e&&typeof e=="object"&&(n=e,e=void 0),eb(n)(Gk(Uk(n).document().write(Yk()(t,e,!0))))}function eb(t){const e={afterExit:[],beforeEnter:[],transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(cu),autolinkProtocol:M,autolinkEmail:M,atxHeading:s(su),blockQuote:s(Ws),characterEscape:M,characterReference:M,codeFenced:s(ou),codeFencedFenceInfo:l,codeFencedFenceMeta:l,codeIndented:s(ou,l),codeText:s(Ng,l),codeTextData:M,data:M,codeFlowValue:M,definition:s(Tg),definitionDestinationString:l,definitionLabelString:l,definitionTitleString:l,emphasis:s(Ig),hardBreakEscape:s(lu),hardBreakTrailing:s(lu),htmlFlow:s(au,l),htmlFlowData:M,htmlText:s(au,l),htmlTextData:M,image:s(Ag),label:l,link:s(cu),listItem:s(Eg),listItemValue:h,listOrdered:s(uu,d),listUnordered:s(uu),paragraph:s(vg),reference:ft,referenceString:l,resourceDestinationString:l,resourceTitleString:l,setextHeading:s(su),strong:s(Og),thematicBreak:s(Rg)},exit:{atxHeading:c(),atxHeadingSequence:S,autolink:c(),autolinkEmail:ur,autolinkProtocol:cr,blockQuote:c(),characterEscapeValue:R,characterReferenceMarkerHexadecimal:ye,characterReferenceMarkerNumeric:ye,characterReferenceValue:si,characterReference:sn,codeFenced:c(g),codeFencedFence:y,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:R,codeIndented:c(C),codeText:c(Y),codeTextData:R,data:R,definition:c(),definitionDestinationString:P,definitionLabelString:w,definitionTitleString:E,emphasis:c(),hardBreakEscape:c(L),hardBreakTrailing:c(L),htmlFlow:c(V),htmlFlowData:R,htmlText:c(_),htmlTextData:R,image:c(ce),label:k,labelText:be,lineEnding:A,link:c(ne),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ar,resourceDestinationString:Oe,resourceTitleString:fe,resource:b,setextHeading:c(Z),setextHeadingLineSequence:F,setextHeadingText:D,strong:c(),thematicBreak:c()}};qh(e,(t||{}).mdastExtensions||[]);const n={};return r;function r(N){let O={type:"root",children:[],position:void 0};const U={stack:[O],tokenStack:[],config:e,enter:a,exit:u,buffer:l,resume:f,data:n},Q=[],Le=[];let le=-1;for(;++le<N.length;)if(Le.push(N[le]),N[le][1].type==="listOrdered"||N[le][1].type==="listUnordered")if(N[le][0]==="enter")Q.push(Le.length-1);else{const Fe=Q.pop();o(Le,Fe)}for(N=Le,le=-1;++le<N.length;){const Fe=e[N[le][0]];N[le][0]==="enter"&&e.beforeEnter.length>0&&i(e.beforeEnter,{...U,sliceSerialize:N[le][2].sliceSerialize},N[le][1]),Hh.call(Fe,N[le][1].type)&&Fe[N[le][1].type].call({...U,sliceSerialize:N[le][2].sliceSerialize},N[le][1]),N[le][0]==="exit"&&e.afterExit.length>0&&i(e.afterExit,{...U,sliceSerialize:N[le][2].sliceSerialize},N[le][1])}if(U.tokenStack.length>0){const Fe=U.tokenStack[U.tokenStack.length-1];(Fe[1]||Tu).call(U,void 0,Fe[0])}for(O.position={start:ln(N.length>0?N[0][1].start:{line:1,column:1,offset:0}),end:ln(N.length>0?N[N.length-2][1].end:{line:1,column:1,offset:0})},le=-1;++le<e.transforms.length;)O=e.transforms[le](O)||O;return O}function i(N,O,U){let Q=-1;for(;++Q<N.length;)N[Q].call(O,U)}function o(N,O){const U=N.length-1;let Q=O-1,Le=-1,le=!1,Fe,bt,li,ai;const ci=[];for(;++Q<=U;){const Ke=N[Q];switch(Ke[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ke[0]==="enter"?Le++:Le--,ai=void 0;break}case"lineEndingBlank":{Ke[0]==="enter"&&(Fe&&!ai&&!Le&&!li&&(li=Q),ai=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ai=void 0}if(!Le&&Ke[0]==="enter"&&Ke[1].type==="listItemPrefix"||Le===-1&&Ke[0]==="exit"&&(Ke[1].type==="listUnordered"||Ke[1].type==="listOrdered")){if(Fe){let fr=Q;for(bt=void 0;fr--;){const zt=N[fr];if(zt[1].type==="lineEnding"||zt[1].type==="lineEndingBlank"){if(zt[0]==="exit")continue;bt&&(N[bt][1].type="lineEndingBlank",le=!0),zt[1].type="lineEnding",bt=fr}else if(!(zt[1].type==="linePrefix"||zt[1].type==="blockQuotePrefix"||zt[1].type==="blockQuotePrefixWhitespace"||zt[1].type==="blockQuoteMarker"||zt[1].type==="listItemIndent"))break}li&&(!bt||li<bt)&&(Fe._spread=!0),Fe.end=Object.assign({},bt?N[bt][1].start:Ke[1].end),ci.push({at:bt||Q,event:["exit",Fe,Ke[2]]})}if(Ke[1].type==="listItemPrefix"){const fr={type:"listItem",_spread:!1,start:Object.assign({},Ke[1].start),end:void 0};Fe=fr,ci.push({at:Q,event:["enter",fr,Ke[2]]}),li=void 0,ai=!0}}}const fu=N.splice(O);let Ks=0;for(Q=-1;++Q<fu.length;){for(;Ks<ci.length&&ci[Ks].at===O+Q;)N.push(ci[Ks++].event);N.push(fu[Q])}N[O][1]._spread=le}function s(N,O){return U;function U(Q){a.call(this,N(Q),Q),O&&O.call(this,Q)}}function l(){this.stack.push({type:"fragment",children:[]})}function a(N,O,U){this.stack[this.stack.length-1].children.push(N),this.stack.push(N),this.tokenStack.push([O,U||void 0]),N.position={start:ln(O.start),end:void 0}}function c(N){return O;function O(U){N&&N.call(this,U),u.call(this,U)}}function u(N,O){const U=this.stack.pop(),Q=this.tokenStack.pop();if(!Q)throw new Error("Cannot close `"+N.type+"` ("+ki({start:N.start,end:N.end})+"): it’s not open");Q[0].type!==N.type&&(O?O.call(this,N,Q[0]):(Q[1]||Tu).call(this,N,Q[0])),U.position.end=ln(N.end)}function f(){return Cs(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function h(N){if(this.data.expectingFirstListItemValue){const O=this.stack[this.stack.length-2];O.start=Number.parseInt(this.sliceSerialize(N),10),this.data.expectingFirstListItemValue=void 0}}function p(){const N=this.resume(),O=this.stack[this.stack.length-1];O.lang=N}function m(){const N=this.resume(),O=this.stack[this.stack.length-1];O.meta=N}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){const N=this.resume(),O=this.stack[this.stack.length-1];O.value=N.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function C(){const N=this.resume(),O=this.stack[this.stack.length-1];O.value=N.replace(/(\r?\n|\r)$/g,"")}function w(N){const O=this.resume(),U=this.stack[this.stack.length-1];U.label=O,U.identifier=gt(this.sliceSerialize(N)).toLowerCase()}function E(){const N=this.resume(),O=this.stack[this.stack.length-1];O.title=N}function P(){const N=this.resume(),O=this.stack[this.stack.length-1];O.url=N}function S(N){const O=this.stack[this.stack.length-1];if(!O.depth){const U=this.sliceSerialize(N).length;O.depth=U}}function D(){this.data.setextHeadingSlurpLineEnding=!0}function F(N){const O=this.stack[this.stack.length-1];O.depth=this.sliceSerialize(N).codePointAt(0)===61?1:2}function Z(){this.data.setextHeadingSlurpLineEnding=void 0}function M(N){const U=this.stack[this.stack.length-1].children;let Q=U[U.length-1];(!Q||Q.type!=="text")&&(Q=Dg(),Q.position={start:ln(N.start),end:void 0},U.push(Q)),this.stack.push(Q)}function R(N){const O=this.stack.pop();O.value+=this.sliceSerialize(N),O.position.end=ln(N.end)}function A(N){const O=this.stack[this.stack.length-1];if(this.data.atHardBreak){const U=O.children[O.children.length-1];U.position.end=ln(N.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(O.type)&&(M.call(this,N),R.call(this,N))}function L(){this.data.atHardBreak=!0}function V(){const N=this.resume(),O=this.stack[this.stack.length-1];O.value=N}function _(){const N=this.resume(),O=this.stack[this.stack.length-1];O.value=N}function Y(){const N=this.resume(),O=this.stack[this.stack.length-1];O.value=N}function ne(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const O=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=O,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function ce(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const O=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=O,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function be(N){const O=this.sliceSerialize(N),U=this.stack[this.stack.length-2];U.label=jh(O),U.identifier=gt(O).toLowerCase()}function k(){const N=this.stack[this.stack.length-1],O=this.resume(),U=this.stack[this.stack.length-1];if(this.data.inReference=!0,U.type==="link"){const Q=N.children;U.children=Q}else U.alt=O}function Oe(){const N=this.resume(),O=this.stack[this.stack.length-1];O.url=N}function fe(){const N=this.resume(),O=this.stack[this.stack.length-1];O.title=N}function b(){this.data.inReference=void 0}function ft(){this.data.referenceType="collapsed"}function ar(N){const O=this.resume(),U=this.stack[this.stack.length-1];U.label=O,U.identifier=gt(this.sliceSerialize(N)).toLowerCase(),this.data.referenceType="full"}function ye(N){this.data.characterReferenceType=N.type}function si(N){const O=this.sliceSerialize(N),U=this.data.characterReferenceType;let Q;U?(Q=Eh(O,U==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Q=Na(O);const Le=this.stack[this.stack.length-1];Le.value+=Q}function sn(N){const O=this.stack.pop();O.position.end=ln(N.end)}function cr(N){R.call(this,N);const O=this.stack[this.stack.length-1];O.url=this.sliceSerialize(N)}function ur(N){R.call(this,N);const O=this.stack[this.stack.length-1];O.url="mailto:"+this.sliceSerialize(N)}function Ws(){return{type:"blockquote",children:[],position:void 0}}function ou(){return{type:"code",lang:null,meta:null,value:"",position:void 0}}function Ng(){return{type:"inlineCode",value:"",position:void 0}}function Tg(){return{type:"definition",identifier:"",label:null,title:null,url:"",position:void 0}}function Ig(){return{type:"emphasis",children:[],position:void 0}}function su(){return{type:"heading",depth:0,children:[],position:void 0}}function lu(){return{type:"break",position:void 0}}function au(){return{type:"html",value:"",position:void 0}}function Ag(){return{type:"image",title:null,url:"",alt:null,position:void 0}}function cu(){return{type:"link",title:null,url:"",children:[],position:void 0}}function uu(N){return{type:"list",ordered:N.type==="listOrdered",start:null,spread:N._spread,children:[],position:void 0}}function Eg(N){return{type:"listItem",spread:N._spread,checked:null,children:[],position:void 0}}function vg(){return{type:"paragraph",children:[],position:void 0}}function Og(){return{type:"strong",children:[],position:void 0}}function Dg(){return{type:"text",value:"",position:void 0}}function Rg(){return{type:"thematicBreak",position:void 0}}}function ln(t){return{line:t.line,column:t.column,offset:t.offset}}function qh(t,e){let n=-1;for(;++n<e.length;){const r=e[n];Array.isArray(r)?qh(t,r):tb(t,r)}}function tb(t,e){let n;for(n in e)if(Hh.call(e,n))switch(n){case"canContainEols":{const r=e[n];r&&t[n].push(...r);break}case"transforms":{const r=e[n];r&&t[n].push(...r);break}case"afterExit":case"beforeEnter":{const r=e[n];r&&t[n].push(r);break}case"enter":case"exit":{const r=e[n];r&&Object.assign(t[n],r);break}}}function Tu(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+ki({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+ki({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+ki({start:e.start,end:e.end})+") is still open")}function Hl(t){const e=this;e.parser=n;function n(r){return Zk(r,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}const Ms=(function(t){if(t==null)return ob;if(typeof t=="function")return Ns(t);if(typeof t=="object")return Array.isArray(t)?nb(t):rb(t);if(typeof t=="string")return ib(t);throw new Error("Expected function, string, or object as test")});function nb(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=Ms(t[n]);return Ns(r);function r(...i){let o=-1;for(;++o<e.length;)if(e[o].apply(this,i))return!0;return!1}}function rb(t){const e=t;return Ns(n);function n(r){const i=r;let o;for(o in t)if(i[o]!==e[o])return!1;return!0}}function ib(t){return Ns(e);function e(n){return n&&n.type===t}}function Ns(t){return e;function e(n,r,i){return!!(sb(n)&&t.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function ob(){return!0}function sb(t){return t!==null&&typeof t=="object"&&"type"in t}const Wh=Ms(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]),Iu={}.hasOwnProperty;function lb(t,e){const n=e||{};function r(i,...o){let s=r.invalid;const l=r.handlers;if(i&&Iu.call(i,t)){const a=String(i[t]);s=Iu.call(l,a)?l[a]:r.unknown}if(s)return s.call(this,i,...o)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const ab={}.hasOwnProperty;function Kh(t,e){let n=-1,r;if(e.extensions)for(;++n<e.extensions.length;)Kh(t,e.extensions[n]);for(r in e)if(ab.call(e,r))switch(r){case"extensions":break;case"unsafe":{Au(t[r],e[r]);break}case"join":{Au(t[r],e[r]);break}case"handlers":{cb(t[r],e[r]);break}default:t.options[r]=e[r]}return t}function Au(t,e){e&&t.push(...e)}function cb(t,e){e&&Object.assign(t,e)}function ub(t,e,n,r){const i=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);const s=n.indentLines(n.containerFlow(t,o.current()),fb);return i(),s}function fb(t,e,n){return">"+(n?"":" ")+t}function Jh(t,e){return Eu(t,e.inConstruct,!0)&&!Eu(t,e.notInConstruct,!1)}function Eu(t,e,n){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return n;let r=-1;for(;++r<e.length;)if(t.includes(e[r]))return!0;return!1}function vu(t,e,n,r){let i=-1;for(;++i<n.unsafe.length;){const o=n.unsafe[i];if(o.character===`
|
|
5
|
-
`&&!o.before&&!o.after&&Jh(n.stack,o))return/[\t ]/.test(r.before)?"":" "}return`\\
|
|
6
|
-
`}function hb(t,e){const n=String(t);let r=n.indexOf(e),i=r,o=0,s=0;if(typeof e!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++o>s&&(s=o):o=1,i=r+e.length,r=n.indexOf(e,i);return s}function jo(t,e){return!!(e.options.fences===!1&&t.value&&!t.lang&&/[^\n\r ]/.test(t.value)&&!/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(t.value))}function db(t){const e=t.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function pb(t,e,n,r){const i=db(n),o=t.value||"";if(jo(t,n)){const f=n.enter("codeIndented"),d=n.indentLines(o,mb);return f(),d}const s=n.createTracker(r),l=i.repeat(Math.max(hb(o,i)+1,3)),a=n.enter("codeFenced"),c=i==="`"?"GraveAccent":"Tilde";let u=s.move(l);if(t.lang){const f=n.enter(`codeFencedLang${c}`);u+=s.move(n.safe(t.lang,{before:u,after:" ",encode:["`"],...s.current()})),f()}if(t.lang&&t.meta){const f=n.enter(`codeFencedMeta${c}`);u+=s.move(" "),u+=s.move(n.safe(t.meta,{before:u,after:`
|
|
7
|
-
`,encode:["`"],...s.current()})),f()}return u+=s.move(`
|
|
8
|
-
`),o&&(u+=s.move(o+`
|
|
9
|
-
`)),u+=s.move(l),a(),u}function mb(t,e,n){return(n?"":" ")+t}function Ia(t){const e=t.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function gb(t,e,n,r){const i=Ia(n),o=i==='"'?"Quote":"Apostrophe",s=n.enter("definition");let l=n.enter("label");const a=n.createTracker(r);let c=a.move("[");return c+=a.move(n.safe(n.associationId(t),{before:c,after:"]",...a.current()})),c+=a.move("]: "),l(),!t.url||/[\0- \u007F]/.test(t.url)?(l=n.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(n.safe(t.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(l=n.enter("destinationRaw"),c+=a.move(n.safe(t.url,{before:c,after:t.title?" ":`
|
|
10
|
-
`,...a.current()}))),l(),t.title&&(l=n.enter(`title${o}`),c+=a.move(" "+i),c+=a.move(n.safe(t.title,{before:c,after:i,...a.current()})),c+=a.move(i),l()),s(),c}function yb(t){const e=t.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function rs(t){const e=t.codePointAt(0);return e===void 0?"":String.fromCodePoint(e)}function xr(t){const e=t.codePointAt(t.length-2);return e!==void 0&&e>65535?t.slice(-2):t.slice(-1)}function Aa(t){return"&#x"+t.toString(16).toUpperCase()+";"}function Ou(t,e,n){const r=Tt(t),i=Tt(e);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function ql(t){if(t.charCodeAt(0)!==60)return;const e=t.charCodeAt(1);if(e===33){const l=t.charCodeAt(2);return l===45?2:l===91?5:Ce(l)?4:void 0}if(e===63)return 3;const n=e===47,r=n?2:1;let i=r,o=t.charCodeAt(i);if(!Ce(o))return;for(;o===45||Re(o);)o=t.charCodeAt(++i);const s=t.slice(r,i).toLowerCase();return!n&&o!==47&&Vl.includes(s)?1:_h.includes(s)?6:7}const Uh=new Map([["*",!1],["_",!0]]);function kb(t,e,n){const r=new Set;for(const o of t){const s=n.get(o);if(s&&o.attention&&e.some(l=>l.attention===o.attention))for(const l of s.tokens)r.add(l.attention)}const i=[];for(const o of t)o.attention&&r.delete(o.attention)&&i.push(o.attention);return i.reverse(),i}function Gh(t,e,n){const r=[],i=new Map,o=new Map;let s=0;for(;s<t.length;){if(!t[s].attention){s++;continue}const l=t[s].value.charAt(0),a=Uh.get(l);let c=s+1;for(;c<t.length&&t[c].attention&&t[c].value.charAt(0)===l;)c++;const u=s?t[s-1].value:e,f=Tt(u.charCodeAt(u.length-1)),d=Tt((c<t.length?t[c].value:n).charCodeAt(0)),h=!d||d===2&&!!f,p=!f||f===2&&!!d,m={tokens:t.slice(s,c),markers:[],start:0,end:0,open:a?h&&(!!f||!p):h,close:a?p&&(!!d||!h):p,split:a!==void 0};for(const y of m.tokens){i.set(y,[...m.tokens]),o.set(y,m);let g=y.value.length;for(;g--;)m.markers.push(y)}m.end=m.markers.length,r.push(m),s=c}for(wb(r,i),s=-1;++s<t.length;){const l=i.get(t[s]);if(l)return{attention:kb(t,l,o),index:s}}}function bb(t,e,n){return po(Yh(t,e,n),n.before,n.after)}function Oo(t,e){const n=t[e?0:t.length-1];if(!n||n.attention)return;const r=e?rs(n.value):xr(n.value),i=Aa(r.codePointAt(0));if(e)n.value=i+n.value.slice(r.length);else{let o=n.value.slice(0,n.value.length-r.length),s=0;for(;o.charCodeAt(o.length-1-s)===92;)s++;s%2&&(o+="\\"),n.value=o+i}}function xb(t,e,n,r,i){for(const o of n.attention){const s=e.get(o)||o.sequences[0];for(const l of o.sequences){if(l===s)continue;const a=new Map(e);a.set(o,l);const c=Ts(t,a,r,i),u=Gh(c,r,i);if(!u||u.index>n.index)return{chosen:a,mistake:u,tokens:c}}}}function wb(t,e){const n=new Map;for(const r of t){const i=r.tokens[0].value.charAt(0);let o=n.get(i);o||(o=[],n.set(i,o));let s=r.close?o.length:0;for(;s--&&r.start<r.end;){const l=o[s],a=l.end-l.start,c=r.end-r.start;if(r.split?(l.close||r.open)&&c%3&&!((a+c)%3):a!==l.markers.length||a!==c)continue;const u=r.split?a>1&&c>1?2:1:c,f=l.markers.slice(l.end-u,l.end),d=r.markers.slice(r.start,r.start+u),h=f[0],p=d[0];if(h===f[u-1]&&h.value.length===u&&p===d[u-1]&&p.value.length===u&&h.attention===p.attention)e.delete(h),e.delete(p);else{const m=[...new Set([...f,...d])];for(const y of m){const g=e.get(y);g&&g.push(...m)}}l.end-=u,r.start+=u,l.start===l.end&&o.splice(s,1),s=o.length}r.open&&r.start<r.end&&o.push(r)}}function Cb(t,e,n){if(e.length===0)throw new Error("Cannot serialize `"+t+"` as attention without markers, expected one or more markers");if(n.length===0)throw new Error("Cannot serialize `"+t+"` as attention without sizes, expected one or more sizes");for(const i of n)if(!Number.isSafeInteger(i)||i<1)throw new Error("Cannot serialize `"+t+"` as attention with `"+i+"` as size, expected positive integer");const r=[];for(const i of e){if(i.length!==1)throw new Error("Cannot serialize `"+t+"` as attention with `"+i+"` as marker, expected a single ascii character");if(!vh(i.charCodeAt(0)))throw new Error("Cannot serialize `"+t+"` as attention with `"+i+"` as marker, expected ascii punctuation");for(const o of n)r.push(i.repeat(o))}return r}function Yh(t,e,n){const r=e.indexStack,i=t.children||[],o=[];let s=-1,l=n.before;r.push(-1);let a=e.createTracker(n);for(;++s<i.length;){const c=i[s];let u;if(r[r.length-1]=s,s+1<i.length){let h=e.handle.handlers[i[s+1].type];h&&h.peek&&(h=h.peek),u=h?rs(h(i[s+1],t,e,{before:"",after:"",...a.current()})):""}else u=n.after;const f=o[o.length-1];typeof f=="string"&&(l==="\r"||l===`
|
|
11
|
-
`)&&c.type==="html"&&ql(c.value)!==7&&(o[o.length-1]=f.replace(/(\r?\n|\r)$/," "),l=" ",a=e.createTracker(n),a.move(po(o,n.before,n.after)));const d=e.handle.handlers[c.type];if(d&&d.attention){const h=Ea(c,d.attention,e,a);if(!h)continue;o.push(h),l=xr(h.sequences[0])}else{const h=e.handle(c,t,e,{...a.current(),after:u,before:l});if(!h)continue;a.move(h),o.push(h),l=xr(h)}}return r.pop(),o}function Ea(t,e,n,r){const{construct:i,markers:o,sizes:s}=e(t,n),l=Cb(t.type,o,s),a=l[0],c=n.enter(i),u=n.createTracker(r.current());u.move(a);const f=Yh(t,n,{...u.current(),before:a,after:a});if(c(),f.length!==0)return r.move(a),r.move(po(f,a,a)),r.move(a),{children:f,sequences:l}}function Du(t,e,n,r){let i=Ts(t,e,n,r),o=Gh(i,n,r);for(;o;){const s=xb(t,e,o,n,r);if(!s)return;e=s.chosen,i=s.tokens,o=s.mistake}return i}function Qh(t,e,n,r){let i=n,o=-1;for(;++o<t.length;){const s=t[o];if(typeof s=="string"){i="";continue}const l=o===t.length-1?r:"",a=s.sequences.find(function(c){const u=c.charAt(0);return u!==i.charAt(0)&&u!==l.charAt(0)||t.length===1&&Uh.has(u)&&c.length>n.length})||s.sequences[0];a!==s.sequences[0]&&e.set(s,a),Qh(s.children,e,a,a),i=a}}function Ts(t,e,n,r){const i=[];let o,s=xr(n),l=-1;for(;++l<t.length;){const a=t[l];if(typeof a=="string"){const w={value:a,attention:void 0};o&&o===rs(a)&&Oo([w],!0),o=void 0,i.push(w),w.value&&(s=xr(w.value));continue}const c=e.get(a)||a.sequences[0],u=c.charAt(0),f=t[l+1],d=s,h=rs(f===void 0?r:typeof f=="string"?f:e.get(f)||f.sequences[0]),p=Ts(a.children,e,c,c),m=p[0].value,y=Ou(d.charCodeAt(d.length-1),m.charCodeAt(0),u);y.inside&&Oo(p,!0);const g=xr(p[p.length-1].value),C=Ou(h.charCodeAt(0),g.charCodeAt(g.length-1),u);C.inside&&Oo(p,!1),y.outside&&d!==`
|
|
12
|
-
`&&d!=="\r"&&Oo(i,!1),C.outside&&(o=h),i.push({value:c,attention:a},...p,{value:c,attention:a}),s=c.charAt(c.length-1)}return i}function po(t,e,n){const r=new Map;Qh(t,r,e,n);const i=(r.size>0?Du(t,r,e,n):void 0)||Du(t,new Map,e,n)||Ts(t,new Map,e,n);let o="";for(const s of i)o+=s.value;return o}va.attention=Xh;va.peek=Sb;function va(t,e,n,r){const i=n.enter("phrasing"),o=Ea(t,Xh,n,n.createTracker(r)),s=o?po([o],r.before,r.after):"";return i(),s}function Xh(t,e){return{construct:"emphasis",markers:yb(e)==="*"?["*","_"]:["_","*"],sizes:[1]}}function Sb(t,e,n){return n.options.emphasis||"*"}const Zh=[],Mb=!0,bi=!1,qr="skip";function is(t,e,n,r){if(!t||typeof t!="object")throw new Error("Unexpected value `"+t+"` for `tree`, expected node");let i=!0,o,s,l,a;if(typeof n=="function"||n&&typeof n=="object"?(o=e,s=n,r&&(i=!1)):(s=e,n&&(i=!1)),typeof s=="function")l=s;else if(s&&typeof s=="object"){if(!(s.enter===null||s.enter===void 0))if(typeof s.enter=="function")l=s.enter;else throw new Error("Unexpected value `"+s.enter+"` for `visitors.enter`, expected optional visitor");if(typeof s.exit=="function")a=s.exit;else throw new Error("Unexpected value `"+s.exit+"` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)")}else throw new Error("Unexpected value `"+s+"` for `enter` or `visitors`, expected visitor or object with visitors");const c=Ms(o),u=i?1:-1;f(t,void 0,[])();function f(d,h,p){const m=d&&typeof d=="object"?d:{};if(typeof m.type=="string"){const g=typeof m.tagName=="string"?m.tagName:typeof m.name=="string"?m.name:void 0;Object.defineProperty(y,"name",{value:"node ("+(d.type+(g?"<"+g+">":""))+")"})}return y;function y(){const g=!o||c(d,h,p[p.length-1]||void 0);let C=Zh;if(l&&g&&(C=Ru(l(d,p,h)),C[0]===bi))return C;if("children"in d&&d.children){const w=d;if(w.children&&C[0]!==qr){let E=(i?-1:w.children.length)+u;const P=[...p,w];for(;E>-1&&E<w.children.length;){const S=w.children[E],D=f(S,E,P)();if(D[0]===bi)return D;E=typeof D[1]=="number"?D[1]:E+u}}}if(a&&g){const w=Ru(a(d,p,h));if(w[0]===qr)throw new Error("Unexpected value `"+w[0]+"` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing");if(w[0]===bi||typeof w[1]=="number")return w}return C}}}function Ru(t){return Array.isArray(t)?t:typeof t=="number"?[Mb,t]:t==null?Zh:[t]}function ir(t,e,n,r){let i,o,s;typeof n=="function"||n&&typeof n=="object"?(i=e,o=n,s=r):(o=e,s=n),typeof o=="function"?is(t,i,Wl(o),s):is(t,i,Nb(o),s)}function Nb(t){return!t||typeof t!="object"?t:{enter:typeof t.enter=="function"?Wl(t.enter):t.enter,exit:typeof t.exit=="function"?Wl(t.exit):t.exit}}function Wl(t){return e;function e(n,r,i){return t(n,i,r[r.length-1])}}function ed(t,e){let n=!1;return ir(t,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,bi}),!!((!t.depth||t.depth<3)&&Cs(t)&&(e.options.setext||n))}function Tb(t,e,n,r){const i=Math.max(Math.min(6,t.depth||1),1),o=n.createTracker(r);if(ed(t,n)){const f=n.enter("headingSetext"),d=n.enter("phrasing"),h=n.containerPhrasing(t,{...o.current(),before:`
|
|
13
|
-
`,after:`
|
|
14
|
-
`});return d(),f(),h+`
|
|
15
|
-
`+(i===1?"=":"-").repeat(h.length-(Math.max(h.lastIndexOf("\r"),h.lastIndexOf(`
|
|
16
|
-
`))+1))}const s="#".repeat(i),l=n.enter("headingAtx"),a=n.enter("phrasing");o.move(s+" ");let c=n.containerPhrasing(t,{before:"# ",after:`
|
|
17
|
-
`,...o.current()});const u=c.charCodeAt(0);return(u===9||u===32)&&(c=Aa(u)+c.slice(1)),c=c?s+" "+c:s,n.options.closeAtx&&(c+=" "+s),a(),l(),c}td.peek=Ib;function td(t){return t.value||""}function Ib(){return"<"}nd.peek=Ab;function nd(t,e,n,r){const i=Ia(n),o=i==='"'?"Quote":"Apostrophe",s=n.enter("image");let l=n.enter("label");const a=n.createTracker(r);let c=a.move("![");return c+=a.move(n.safe(t.alt,{before:c,after:"]",...a.current()})),c+=a.move("]("),l(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(l=n.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(n.safe(t.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(l=n.enter("destinationRaw"),c+=a.move(n.safe(t.url,{before:c,after:t.title?" ":")",...a.current()}))),l(),t.title&&(l=n.enter(`title${o}`),c+=a.move(" "+i),c+=a.move(n.safe(t.title,{before:c,after:i,...a.current()})),c+=a.move(i),l()),c+=a.move(")"),s(),c}function Ab(){return"!"}rd.peek=Eb;function rd(t,e,n,r){const i=t.referenceType,o=n.enter("imageReference");let s=n.enter("label");const l=n.createTracker(r);let a=l.move("![");const c=n.safe(t.alt,{before:a,after:"]",...l.current()});a+=l.move(c+"]["),s();const u=n.stack;n.stack=u.filter(function(d){return d!=="phrasing"}),s=n.enter("reference");const f=n.safe(n.associationId(t),{before:a,after:"]",...l.current()});return s(),n.stack=u,o(),i==="full"||!c||c!==f?a+=l.move(f+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function Eb(){return"!"}id.peek=vb;function id(t,e,n){let r=t.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const s=n.unsafe[o],l=n.compilePattern(s);if(!s.atBreak)continue;let a;for(;a=l.exec(r);){let c=a.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(a.index+1)}}return i+r+i}function vb(){return"`"}function od(t,e){const n=Cs(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][+\-.a-z]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}sd.peek=Ob;function sd(t,e,n,r){const i=Ia(n),o=i==='"'?"Quote":"Apostrophe",s=n.createTracker(r);if(od(t,n)){const p=n.stack;n.stack=p.filter(function(g){return g!=="phrasing"});const m=n.enter("autolink");let y=s.move("<");return y+=s.move(n.containerPhrasing(t,{before:y,after:">",...s.current()})),y+=s.move(">"),m(),n.stack=p,y}const l=n.enter("link");let a=n.enter("label"),c=s.move("[");const u=n.containerPhrasing(t,{before:c,after:"](",...s.current()});c+=s.move(u),a(),c+=s.move("](");const f=/[\0- \u007F]/.test(t.url),d=r.before.charAt(r.before.length-1);let h=t.title||void 0;if(!h&&!f&&(d===`
|
|
18
|
-
`||d==="\r")){let p=0;for(;p<u.length&&u.charCodeAt(p)!==93;)p+=u.charCodeAt(p)===92?2:1;u.charCodeAt(p+1)===58&&(h="")}return!t.url&&typeof h=="string"||f?(a=n.enter("destinationLiteral"),c+=s.move("<"),c+=s.move(n.safe(t.url,{before:c,after:">",...s.current()})),c+=s.move(">")):(a=n.enter("destinationRaw"),c+=s.move(n.safe(t.url,{before:c,after:typeof h=="string"?" ":")",...s.current()}))),a(),typeof h=="string"&&(a=n.enter(`title${o}`),c+=s.move(" "+i),c+=s.move(n.safe(h,{before:c,after:i,...s.current()})),c+=s.move(i),a()),c+=s.move(")"),l(),c}function Ob(t,e,n){return od(t,n)?"<":"["}ld.peek=Db;function ld(t,e,n,r){const i=t.referenceType,o=n.enter("linkReference");let s=n.enter("label");const l=n.createTracker(r);let a=l.move("[");const c=n.containerPhrasing(t,{before:a,after:"]",...l.current()});a+=l.move(c+"]["),s();const u=n.stack;n.stack=u.filter(function(d){return d!=="phrasing"}),s=n.enter("reference");const f=n.safe(n.associationId(t),{before:a,after:"]",...l.current()});return s(),n.stack=u,o(),i==="full"||!c||c!==f?a+=l.move(f+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function Db(){return"["}function Oa(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function Rb(t){const e=Oa(t),n=t.options.bulletOther;if(!n)return e==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+n+"`) to be different");return n}function zb(t){const e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function Da(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function Pb(t,e,n,r){const i=n.enter("list"),o=n.bulletCurrent;let s=t.ordered?zb(n):Oa(n);const l=t.ordered?s==="."?")":".":Rb(n);let a=e&&n.bulletLastUsed?s===n.bulletLastUsed:!1;if(!t.ordered){const u=t.children?t.children[0]:void 0;if((s==="*"||s==="-")&&u&&(!u.children||!u.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(a=!0),Da(n)===s&&u){let f=-1;for(;++f<t.children.length;){const d=t.children[f];if(d&&d.type==="listItem"&&d.children&&d.children[0]&&d.children[0].type==="thematicBreak"){a=!0;break}}}}a&&(s=l),n.bulletCurrent=s;const c=n.containerFlow(t,r);return n.bulletLastUsed=s,n.bulletCurrent=o,i(),c}function Bb(t){const e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function Lb(t,e,n,r){const i=Bb(n);let o=n.bulletCurrent||Oa(n);e&&e.type==="list"&&e.ordered&&(o=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+o);let s=o.length+1;(i==="tab"||i==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(s=Math.ceil(s/4)*4);const l=n.createTracker(r);l.move(o+" ".repeat(s-o.length)),l.shift(s);const a=n.enter("listItem"),c=n.indentLines(n.containerFlow(t,l.current()),u);return a(),c;function u(f,d,h){return d?(h?"":" ".repeat(s))+f:(h?o:o+" ".repeat(s-o.length))+f}}function Fb(t,e,n,r){const i=n.enter("paragraph"),o=n.enter("phrasing"),s=n.containerPhrasing(t,r);return o(),i(),s}function _b(t,e,n,r){if(!t.children.some(function(l){return Wh(l)}))return n.containerFlow(t,r);const o=n.enter("phrasing"),s=n.containerPhrasing(t,r);return o(),s}function $b(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}Ra.attention=ad;Ra.peek=Vb;function Ra(t,e,n,r){const i=n.enter("phrasing"),o=Ea(t,ad,n,n.createTracker(r)),s=o?po([o],r.before,r.after):"";return i(),s}function ad(t,e){return{construct:"strong",markers:$b(e)==="*"?["*","_"]:["_","*"],sizes:[2]}}function Vb(t,e,n){return n.options.strong||"*"}function jb(t,e,n,r){const i=e?e.children:[],o=n.indexStack[n.indexStack.length-1];return n.safe(t.value,{...r,afterNode:i[o+1],beforeNode:i[o-1]})}function Hb(t){const e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function qb(t,e,n){const r=(Da(n)+(n.options.ruleSpaces?" ":"")).repeat(Hb(n));return n.options.ruleSpaces?r.slice(0,-1):r}const ss={blockquote:ub,break:vu,code:pb,definition:gb,emphasis:va,hardBreak:vu,heading:Tb,html:td,image:nd,imageReference:rd,inlineCode:id,link:sd,linkReference:ld,list:Pb,listItem:Lb,paragraph:Fb,root:_b,strong:Ra,text:jb,thematicBreak:qb},Wb=[Kb];function Kb(t,e,n,r){if(e.type==="code"&&jo(e,r)&&(t.type==="list"||t.type===e.type&&jo(t,r)))return!1;if("spread"in n&&typeof n.spread=="boolean"){if(n.spread)return 1;if(t.type==="html"){const o=ql(t.value);if(o===void 0||o===6||o===7)return 1}if(t.type==="blockquote"&&e.type==="blockquote"||(t.type==="definition"||t.type==="paragraph")&&e.type==="list"&&(e.ordered&&typeof e.start=="number"&&e.start!==1||e.children.length>0&&e.children[0].children.length===0)||t.type==="paragraph"&&e.type==="thematicBreak"&&Da(r)==="-"&&!r.options.ruleSpaces)return 1;let i=t;for(;(i.type==="blockquote"||i.type==="list"||i.type==="listItem")&&i.children.length>0;)i=i.children[i.children.length-1];if(i.type!=="definition"&&i.type!=="paragraph")return 0;if(e.type==="code"&&jo(e,r))return 1;if(e.type==="html"){const o=ql(e.value);if(o===void 0||o===7)return 1}return(t.type==="paragraph"||t!==i)&&(e.type==="definition"||e.type==="heading"&&ed(e,r)||e.type==="paragraph")?1:0}}const An=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],cd=[{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:`
|
|
19
|
-
`,inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:"\r",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"\r",after:"\\r",inConstruct:"phrasing"},{character:`
|
|
20
|
-
`,before:"\\n",inConstruct:"phrasing"},{character:`
|
|
21
|
-
`,after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:An},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:`(?:[\r
|
|
22
|
-
]|$)`},{character:"&",after:"[#A-Za-z]",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","destinationRaw","phrasing","titleApostrophe","titleQuote"]},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:An},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:`(?:[ \r
|
|
23
|
-
*])`},{character:"*",inConstruct:"phrasing",notInConstruct:An},{atBreak:!0,character:"+",after:`(?:[ \r
|
|
24
|
-
])`},{atBreak:!0,character:"-",after:`(?:[ \r
|
|
25
|
-
-])`},{atBreak:!0,before:"\\d+",character:".",after:`(?:[ \r
|
|
26
|
-
]|$)`},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:An},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:An},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:An},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:An},{atBreak:!0,character:"~"},{character:"<",inConstruct:"autolink"},{character:">",inConstruct:"autolink"},{character:"",inConstruct:"autolink"}];let zu=-1;for(;++zu<33;)cd.push({character:String.fromCharCode(zu),inConstruct:"autolink"});function Jb(t){return t.label||!t.identifier?t.label||"":jh(t.identifier)}function Ub(t){if(!t._compiled){const e=(t.atBreak?"[\\r\\n][\\t ]*":"")+(t.before?"(?:"+t.before+")":"");t._compiled=new RegExp((t.beforeNode?"^":e?"("+e+")":"")+(/[$()*+.?[\\\]^{|}]/.test(t.character)?"\\":"")+t.character+(t.afterNode?"$":t.after?"(?:"+t.after+")":""),t.unicode?"gu":"g")}return t._compiled}function Gb(t,e,n){const r=e.indexStack,i=t.children||[],o=e.createTracker(n),s=[];let l=-1;for(r.push(-1);++l<i.length;){const a=i[l];r[r.length-1]=l,s.push(o.move(e.handle(a,t,e,{before:`
|
|
27
|
-
`,after:`
|
|
28
|
-
`,...o.current()}))),a.type!=="list"&&(e.bulletLastUsed=void 0),l<i.length-1&&s.push(o.move(Yb(a,i[l+1],t,e)))}return r.pop(),s.join("")}function Yb(t,e,n,r){let i=r.join.length;for(;i--;){const o=r.join[i](t,e,n,r);if(o===!0||o===1)break;if(typeof o=="number")return`
|
|
29
|
-
`.repeat(1+o);if(o===!1)return`
|
|
30
|
-
|
|
31
|
-
<!---->
|
|
32
|
-
|
|
33
|
-
`}return`
|
|
34
|
-
|
|
35
|
-
`}const Qb=/\r?\n|\r/g;function Xb(t,e){const n=[];let r=0,i=0,o;for(;o=Qb.exec(t);)s(t.slice(r,o.index)),n.push(o[0]),r=o.index+o[0].length,i++;return s(t.slice(r)),n.join("");function s(l){n.push(e(l,i,!l))}}const Ys={}.hasOwnProperty;function Zb(t,e,n){const r=(n.before||"")+(e||"")+(n.after||""),i=[],o=[],s={},l=t.stack.includes("autolink"),a=n.before?n.before.length:0,c=r.length-(n.after?n.after.length:0);let u=-1;for(;++u<t.unsafe.length;){const h=t.unsafe[u];if(!Jh(t.stack,h)||!Pu(h.beforeNode,n.beforeNode)||!Pu(h.afterNode,n.afterNode))continue;const p=t.compilePattern(h),m=h.beforeNode?a:0,y=r.slice(m,h.afterNode?c:void 0);let g;for(;g=p.exec(y);){const C=!!(h.before||h.atBreak),w=!!h.after,E=m+g.index+(C?g[1].length:0);Ys.call(s,E)?(s[E].before&&!C&&(s[E].before=!1),s[E].after&&!w&&(s[E].after=!1)):(i.push(E),s[E]={before:C,after:w})}}i.sort(e1);let f=a;for(u=-1;++u<i.length;){const h=i[u];if(!(h<f||h>=c)){if(r.charAt(h)==="_"&&h>0&&Tt(r.charCodeAt(h-1))===void 0&&!Ys.call(s,h-1)&&!(h-1===a&&/[*_]/.test(r.charAt(a-1)))){let p=h+1;for(;p<c&&r.charAt(p)==="_";)p++;const m=p-h-1;if(i[u+m]===p-1&&p<r.length&&Tt(r.charCodeAt(p))===void 0&&!Ys.call(s,p)&&!(p===c-1&&/[*_]/.test(r.charAt(c)))){u+=m;continue}}if(!(h+1<c&&i[u+1]===h+1&&s[h].after&&!s[h+1].before&&!s[h+1].after||h-1>=a&&i[u-1]===h-1&&s[h].before&&!s[h-1].before&&!s[h-1].after)){if(f!==h){const p=r.slice(f,h);o.push(l?p:Bu(p,"\\"))}f=h+1,l?o.push("%"+r.charCodeAt(h).toString(16).toUpperCase().padStart(2,"0")):/[!-/:-@[-`{-~]/.test(r.charAt(h))&&(!n.encode||!n.encode.includes(r.charAt(h)))?o.push("\\"+r.charAt(h)):o.push(Aa(r.charCodeAt(h)))}}}const d=r.slice(f,c);return o.push(l?d:Bu(d,n.after)),o.join("")}function Pu(t,e){return t?e?typeof t=="string"?t===e.type:t.includes(e.type):!1:!0}function e1(t,e){return t-e}function Bu(t,e){const n=/\\(?=[!-/:-@[-`{-~])/g,r=[],i=[],o=t+e;let s=-1,l=0,a;for(;a=n.exec(o);)r.push(a.index);for(;++s<r.length;)l!==r[s]&&i.push(t.slice(l,r[s])),i.push("\\"),l=r[s];return i.push(t.slice(l)),i.join("")}function t1(t){const e=t||{},n=e.now||{};let r=e.lineShift||0,i=n.line||1,o=n.column||1;return{move:a,current:s,shift:l};function s(){return{now:{line:i,column:o},lineShift:r}}function l(c){r+=c}function a(c){const u=c||"",f=u.split(/\r?\n|\r/g),d=f[f.length-1];return i+=f.length-1,o=f.length===1?o+d.length:1+d.length+r,u}}function n1(t,e){const n=e||{},r={associationId:Jb,bulletCurrent:void 0,bulletLastUsed:void 0,containerPhrasing:s1,containerFlow:l1,createTracker:t1,compilePattern:Ub,enter:o,handlers:{...ss},handle:void 0,indentLines:Xb,indexStack:[],join:[...Wb],options:{},safe:a1,stack:[],unsafe:[...cd]};Kh(r,n),r.options.tightDefinitions&&r.join.push(o1),r.handle=lb("type",{invalid:r1,unknown:i1,handlers:r.handlers});let i=r.handle(Wh(t)?{type:"root",children:[t]}:t,void 0,r,{before:`
|
|
36
|
-
`,after:`
|
|
37
|
-
`,now:{line:1,column:1},lineShift:0});return i&&i.charCodeAt(i.length-1)!==10&&i.charCodeAt(i.length-1)!==13&&(i+=`
|
|
38
|
-
`),i;function o(s){return r.stack.push(s),l;function l(){r.stack.pop()}}}function r1(t){throw new Error("Cannot handle value `"+t+"`, expected node")}function i1(t){const e=t;throw new Error("Cannot handle unknown node `"+e.type+"`")}function o1(t,e){if(t.type==="definition"&&t.type===e.type)return 0}function s1(t,e){return bb(t,this,e)}function l1(t,e){return Gb(t,this,e)}function a1(t,e){return Zb(this,t,e)}function Kl(t){const e=this;e.compiler=n;function n(r){return n1(r,{...e.data("settings"),...t,extensions:e.data("toMarkdownExtensions")||[]})}}function Lu(t){if(t)throw t}var Qs,Fu;function c1(){if(Fu)return Qs;Fu=1;var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(c){return typeof Array.isArray=="function"?Array.isArray(c):e.call(c)==="[object Array]"},o=function(c){if(!c||e.call(c)!=="[object Object]")return!1;var u=t.call(c,"constructor"),f=c.constructor&&c.constructor.prototype&&t.call(c.constructor.prototype,"isPrototypeOf");if(c.constructor&&!u&&!f)return!1;var d;for(d in c);return typeof d>"u"||t.call(c,d)},s=function(c,u){n&&u.name==="__proto__"?n(c,u.name,{enumerable:!0,configurable:!0,value:u.newValue,writable:!0}):c[u.name]=u.newValue},l=function(c,u){if(u==="__proto__")if(t.call(c,u)){if(r)return r(c,u).value}else return;return c[u]};return Qs=function a(){var c,u,f,d,h,p,m=arguments[0],y=1,g=arguments.length,C=!1;for(typeof m=="boolean"&&(C=m,m=arguments[1]||{},y=2),(m==null||typeof m!="object"&&typeof m!="function")&&(m={});y<g;++y)if(c=arguments[y],c!=null)for(u in c)f=l(m,u),d=l(c,u),m!==d&&(C&&d&&(o(d)||(h=i(d)))?(h?(h=!1,p=f&&i(f)?f:[]):p=f&&o(f)?f:{},s(m,{name:u,newValue:a(C,p,d)})):typeof d<"u"&&s(m,{name:u,newValue:d}));return m},Qs}var u1=c1();const Xs=jg(u1);function Jl(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function f1(){const t=[],e={run:n,use:r};return e;function n(...i){let o=-1;const s=i.pop();if(typeof s!="function")throw new TypeError("Expected function as last argument, not "+s);l(null,...i);function l(a,...c){const u=t[++o];let f=-1;if(a){s(a);return}for(;++f<i.length;)(c[f]===null||c[f]===void 0)&&(c[f]=i[f]);i=c,u?h1(u,l)(...c):s(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return t.push(i),e}}function h1(t,e){let n;return r;function r(...s){const l=t.length>s.length;let a;l&&s.push(i);try{a=t.apply(this,s)}catch(c){const u=c;if(l&&n)throw u;return i(u)}l||(a&&a.then&&typeof a.then=="function"?a.then(o,i):a instanceof Error?i(a):o(a))}function i(s,...l){n||(n=!0,e(s,...l))}function o(s){i(null,s)}}class ud extends Error{constructor(e,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},s=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof e=="string"?i=e:!o.cause&&e&&(s=!0,i=e.message,o.cause=e),!o.ruleId&&!o.source&&typeof r=="string"){const a=r.indexOf(":");a===-1?o.ruleId=r:(o.source=r.slice(0,a),o.ruleId=r.slice(a+1))}if(!o.place&&o.ancestors){const a=o.ancestors[o.ancestors.length-1];a&&(o.place=a.position)}const l=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=ki(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=s&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Object.defineProperties(ud.prototype,{file:{configurable:!0,enumerable:!0,value:"",writable:!0},name:{configurable:!0,enumerable:!0,value:"",writable:!0},reason:{configurable:!0,enumerable:!0,value:"",writable:!0},message:{configurable:!0,enumerable:!0,value:"",writable:!0},stack:{configurable:!0,enumerable:!0,value:"",writable:!0},column:{configurable:!0,enumerable:!0,writable:!0},line:{configurable:!0,enumerable:!0,writable:!0},ancestors:{configurable:!0,enumerable:!0,writable:!0},cause:{configurable:!0,enumerable:!0,writable:!0},fatal:{configurable:!0,enumerable:!0,writable:!0},place:{configurable:!0,enumerable:!0,writable:!0},ruleId:{configurable:!0,enumerable:!0,writable:!0},source:{configurable:!0,enumerable:!0,writable:!0}});const xt={basename:d1,dirname:p1,extname:m1,join:g1,sep:"/"};function d1(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');mo(t);let n=0,r=-1,i=t.length,o;if(e===void 0||e.length===0||e.length>t.length){for(;i--;)if(t.codePointAt(i)===47){if(o){n=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":t.slice(n,r)}if(e===t)return"";let s=-1,l=e.length-1;for(;i--;)if(t.codePointAt(i)===47){if(o){n=i+1;break}}else s<0&&(o=!0,s=i+1),l>-1&&(t.codePointAt(i)===e.codePointAt(l--)?l<0&&(r=i):(l=-1,r=s));return n===r?r=s:r<0&&(r=t.length),t.slice(n,r)}function p1(t){if(mo(t),t.length===0)return".";let e=-1,n=t.length,r;for(;--n;)if(t.codePointAt(n)===47){if(r){e=n;break}}else r||(r=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function m1(t){mo(t);let e=t.length,n=-1,r=0,i=-1,o=0,s;for(;e--;){const l=t.codePointAt(e);if(l===47){if(s){r=e+1;break}continue}n<0&&(s=!0,n=e+1),l===46?i<0?i=e:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||n<0||o===0||o===1&&i===n-1&&i===r+1?"":t.slice(i,n)}function g1(...t){let e=-1,n;for(;++e<t.length;)mo(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":y1(n)}function y1(t){mo(t);const e=t.codePointAt(0)===47;let n=k1(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function k1(t,e){let n="",r=0,i=-1,o=0,s=-1,l,a;for(;++s<=t.length;){if(s<t.length)l=t.codePointAt(s);else{if(l===47)break;l=47}if(l===47){if(!(i===s-1||o===1))if(i!==s-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(a=n.lastIndexOf("/"),a!==n.length-1){a<0?(n="",r=0):(n=n.slice(0,a),r=n.length-1-n.lastIndexOf("/")),i=s,o=0;continue}}else if(n.length>0){n="",r=0,i=s,o=0;continue}}e&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+t.slice(i+1,s):n=t.slice(i+1,s),r=s-i-1;i=s,o=0}else l===46&&o>-1?o++:o=-1}return n}function mo(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const b1={cwd:x1};function x1(){return"/"}function Ul(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function w1(t){if(typeof t=="string")t=new URL(t);else if(!Ul(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return C1(t)}function C1(t){if(t.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const e=t.pathname;let n=-1;for(;++n<e.length;)if(e.codePointAt(n)===37&&e.codePointAt(n+1)===50){const r=e.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(e)}const Zs=["history","path","basename","stem","extname","dirname"];class S1{constructor(e){let n;e?Ul(e)?n={path:e}:typeof e=="string"||M1(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":b1.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Zs.length;){const o=Zs[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let i;for(i in n)Zs.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?xt.basename(this.path):void 0}set basename(e){tl(e,"basename"),el(e,"basename"),this.path=xt.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?xt.dirname(this.path):void 0}set dirname(e){_u(this.basename,"dirname"),this.path=xt.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?xt.extname(this.path):void 0}set extname(e){if(el(e,"extname"),_u(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=xt.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Ul(e)&&(e=w1(e)),tl(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?xt.basename(this.path,this.extname):void 0}set stem(e){tl(e,"stem"),el(e,"stem"),this.path=xt.join(this.dirname||"",e+(this.extname||""))}fail(e,n,r){const i=this.message(e,n,r);throw i.fatal=!0,i}info(e,n,r){const i=this.message(e,n,r);return i.fatal=void 0,i}message(e,n,r){const i=new ud(e,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function el(t,e){if(t&&t.includes(xt.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+xt.sep+"`")}function tl(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function _u(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function M1(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const N1=(function(t){const r=this.constructor.prototype,i=r[t],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o}),T1={}.hasOwnProperty;class za extends N1{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=f1()}copy(){const e=new za;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];e.use(...r)}return e.data(Xs(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(il("data",this.frozen),this.namespace[e]=n,this):T1.call(this.namespace,e)&&this.namespace[e]||void 0:e?(il("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(e,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const n=Do(e),r=this.parser||this.Parser;return nl("parse",r),r(String(n),n)}process(e,n){const r=this;return this.freeze(),nl("process",this.parser||this.Parser),rl("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(o,s){const l=Do(e),a=r.parse(l);r.run(a,l,function(u,f,d){if(u||!f||!d)return c(u);const h=f,p=r.stringify(h,d);A1(p)?d.value=p:d.result=p,c(u,d)});function c(u,f){u||!f?s(u):o?o(f):n(void 0,f)}}}processSync(e){let n=!1,r;return this.freeze(),nl("processSync",this.parser||this.Parser),rl("processSync",this.compiler||this.Compiler),this.process(e,i),Vu("processSync","process",n),r;function i(o,s){n=!0,Lu(o),r=s}}run(e,n,r){$u(e),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(s,l){const a=Do(n);i.run(e,a,c);function c(u,f,d){const h=f||e;u?l(u):s?s(h):r(void 0,h,d)}}}runSync(e,n){let r=!1,i;return this.run(e,n,o),Vu("runSync","run",r),i;function o(s,l){Lu(s),i=l,r=!0}}stringify(e,n){this.freeze();const r=Do(n),i=this.compiler||this.Compiler;return rl("stringify",i),$u(e),i(e,r)}use(e,...n){const r=this.attachers,i=this.namespace;if(il("use",this.frozen),e!=null)if(typeof e=="function")a(e,n);else if(typeof e=="object")Array.isArray(e)?l(e):s(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function o(c){if(typeof c=="function")a(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[u,...f]=c;a(u,f)}else s(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function s(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(c.plugins),c.settings&&(i.settings=Xs(!0,i.settings,c.settings))}function l(c){let u=-1;if(c!=null)if(Array.isArray(c))for(;++u<c.length;){const f=c[u];o(f)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function a(c,u){let f=-1,d=-1;for(;++f<r.length;)if(r[f][0]===c){d=f;break}if(d===-1)r.push([c,...u]);else if(u.length>0){let[h,...p]=u;const m=r[d][1];Jl(m)&&Jl(h)&&(h=Xs(!0,m,h)),r[d]=[c,h,...p]}}}}const Gl=new za().freeze();function nl(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function rl(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function il(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function $u(t){if(!Jl(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function Vu(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function Do(t){return I1(t)?t:new S1(t)}function I1(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function A1(t){return typeof t=="string"||E1(t)}function E1(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}function xe(t){this.content=t}xe.prototype={constructor:xe,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),o=r.content.slice();return i==-1?o.push(n||t,e):(o[i+1]=e,n&&(o[i]=n)),new xe(o)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new xe(n)},addToStart:function(t,e){return new xe([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new xe(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),o=r.find(t);return i.splice(o==-1?i.length:o,0,e,n),new xe(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=xe.from(t),t.size?new xe(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=xe.from(t),t.size?new xe(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=xe.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};xe.from=function(t){if(t instanceof xe)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new xe(e)};function fd(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),o=e.child(r);if(i==o){n+=i.nodeSize;continue}if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){let s=i.text,l=o.text,a=0;for(;s[a]==l[a];a++)n++;return a&&a<s.length&&a<l.length&&pd(s.charCodeAt(a-1))&&dd(s.charCodeAt(a))&&n--,n}if(i.content.size||o.content.size){let s=fd(i.content,o.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function hd(t,e,n,r){for(let i=t.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:n,b:r};let s=t.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let c=s.text,u=l.text,f=c.length,d=u.length;for(;f>0&&d>0&&c[f-1]==u[d-1];)f--,d--,n--,r--;return f&&d&&f<c.length&&pd(c.charCodeAt(f-1))&&dd(c.charCodeAt(f))&&(n++,r++),{a:n,b:r}}if(s.content.size||l.content.size){let c=hd(s.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}function dd(t){return t>=56320&&t<57344}function pd(t){return t>=55296&&t<56320}class I{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,o){for(let s=0,l=0;l<n;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,i+l,o||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let o="",s=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new I(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let o=0,s=0;s<n;o++){let l=this.content[o],a=s+l.nodeSize;a>e&&((s<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),i+=l.nodeSize),s=a}return new I(r,i)}cutByIndex(e,n){return e==n?I.empty:e==0&&n==this.content.length?this:new I(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new I(i,o)}addToStart(e){return new I([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new I(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return fd(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return hd(this,e,n,r)}findIndex(e){if(e==0)return Ro(0,e);if(e==this.size)return Ro(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),o=r+i.nodeSize;if(o>=e)return o==e?Ro(n+1,o):Ro(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return I.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return I.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return I.empty;let n,r=0;for(let i=0;i<e.length;i++){let o=e[i];r+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(n||(n=e.slice(0,i)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new I(n||e,r)}static from(e){if(!e)return I.empty;if(e instanceof I)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new I([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}I.empty=new I([],0);const ol={index:0,offset:0};function Ro(t,e){return ol.index=t,ol.offset=e,ol}function ls(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!ls(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!ls(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class re{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))n||(n=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ls(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);return r.create(n.attrs)}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return re.none;if(e instanceof re)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}}re.none=[];class Di extends Error{}class z{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=gd(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new z(r,this.openStart,this.openEnd)}removeBetween(e,n){return new z(md(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return z.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new z(I.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)i++;return new z(e,r,i)}}z.empty=new z(I.empty,0,0);function md(t,e,n){let{index:r,offset:i}=t.findIndex(e),o=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(i==e||o.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(md(o.content,e-i-1,n-i-1)))}function gd(t,e,n,r,i,o){let{index:s,offset:l}=t.findIndex(e),a=t.maybeChild(s);if(l==e||a.isText)return o&&r<=0&&i<=0&&!o.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=gd(a.content,e-l-1,n,s==0?r-1:0,s==t.childCount-1?i-1:0,a);return c&&t.replaceChild(s,a.copy(c))}function v1(t,e,n){if(n.openStart>t.depth)throw new Di("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Di("Inconsistent open depths");return yd(t,e,n,0)}function yd(t,e,n,r){let i=t.index(r),o=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=yd(t,e,n,r+1);return o.copy(o.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,l=s.content;return $n(s,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=O1(n,t);return $n(o,bd(t,s,l,e,r))}else return $n(o,as(t,e,r))}function kd(t,e){if(!e.type.compatibleContent(t.type))throw new Di("Cannot join "+e.type.name+" onto "+t.type.name)}function Yl(t,e,n){let r=t.node(n);return kd(r,e.node(n)),r}function _n(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function xi(t,e,n,r){let i=(e||t).node(n),o=0,s=e?e.index(n):i.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(_n(t.nodeAfter,r),o++));for(let l=o;l<s;l++)_n(i.child(l),r);e&&e.depth==n&&e.textOffset&&_n(e.nodeBefore,r)}function $n(t,e){if(!t.type.validContent(e))throw new Di("Invalid content for node "+t.type.name);return t.copy(e)}function bd(t,e,n,r,i){let o=t.depth>i&&Yl(t,e,i+1),s=r.depth>i&&Yl(n,r,i+1),l=[];return xi(null,t,i,l),o&&s&&e.index(i)==n.index(i)?(kd(o,s),_n($n(o,bd(t,e,n,r,i+1)),l)):(o&&_n($n(o,as(t,e,i+1)),l),xi(e,n,i,l),s&&_n($n(s,as(n,r,i+1)),l)),xi(r,null,i,l),new I(l)}function as(t,e,n){let r=[];if(xi(null,t,n,r),t.depth>n){let i=Yl(t,e,n+1);_n($n(i,as(t,e,n+1)),r)}return xi(e,null,n,r),new I(r)}function O1(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let o=n-1;o>=0;o--)i=e.node(o).copy(I.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class Ri{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let o=0;o<e;o++)i+=r.child(o).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return re.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new xd(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,o=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),c=o-a;if(r.push(s,l,i+a),!c||(s=s.child(l),s.isText))break;o=c-1,i+=a+1}return new Ri(n,r,o)}static resolveCached(e,n){let r=ju.get(e);if(r)for(let o=0;o<r.elts.length;o++){let s=r.elts[o];if(s.pos==n)return s}else ju.set(e,r=new D1);let i=r.elts[r.i]=Ri.resolve(e,n);return r.i=(r.i+1)%R1,i}}class D1{constructor(){this.elts=[],this.i=0}}const R1=12,ju=new WeakMap;class xd{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const z1=Object.create(null);class st{constructor(e,n,r,i=re.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||I.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&ls(this.attrs,n||e.defaultAttrs||z1)&&re.sameSet(this.marks,r||re.none)}copy(e=null){return e==this.content?this:new st(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new st(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return z.empty;let i=this.resolve(e),o=this.resolve(n),s=r?0:i.sharedDepth(n),l=i.start(s),c=i.node(s).content.cut(i.pos-l,o.pos-l);return new z(c,i.depth-s,o.depth-s)}replace(e,n,r){return v1(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return Ri.resolveCached(this,e)}resolveNoCache(e){return Ri.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),wd(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=I.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=i;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(r),s=o&&o.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),qu(this.type.attrs,this.attrs,"node",this.type.name);let e=re.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];qu(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!re.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=I.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,i,r)}}st.prototype.text=void 0;const Hu=(()=>{let{stack:t}=new Error("/");if(!t||!/\n\s*at\s/.test(t))return n=>n;let e=Object.create(null);return n=>(e[n],n)})();class cs extends st{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):wd(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return Hu(this.text.slice(e,n))}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new cs(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new cs(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(Hu(this.text.slice(e,n)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function wd(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}function qu(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let i in t)t[i].validate&&t[i].validate(e[i])}class Yn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new P1(e,n);if(r.next==null)return Yn.empty;let i=Cd(r);r.next&&r.err("Unexpected trailing text");let o=j1(V1(i));return H1(o,r),o}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let o=n;i&&o<r;o++)i=i.matchType(e.child(o).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function o(s,l){let a=s.matchFragment(e,r);if(a&&(!n||a.validEnd))return I.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:f}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let d=o(f,l.concat(u));if(d)return d}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),o=i.match;if(o.matchType(e)){let s=[];for(let l=i;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:l,next:a}=o.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return o}).join(`
|
|
39
|
-
`)}}Yn.empty=new Yn(!0);class P1{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Cd(t){let e=[];do e.push(B1(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function B1(t){let e=[];do e.push(L1(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function L1(t){let e=$1(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=F1(t,e);else break;return e}function Wu(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function F1(t,e){let n=Wu(t),r=n;return t.eat(",")&&(t.next!="}"?r=Wu(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function _1(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let o in n){let s=n[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function $1(t){if(t.eat("(")){let e=Cd(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=_1(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function V1(t){let e=[[]];return i(o(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=o(s.exprs[a],l);if(a==s.exprs.length-1)return c;i(c,l=n())}else if(s.type=="star"){let a=n();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=n();i(o(s.expr,a),u),a=u}if(s.max==-1)i(o(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=n();r(a,u),i(o(s.expr,a),u),a=u}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Sd(t,e){return e-t}function Ku(t,e){let n=[];return r(e),n.sort(Sd);function r(i){let o=t[i];if(o.length==1&&!o[0].term)return r(o[0].to);n.push(i);for(let s=0;s<o.length;s++){let{term:l,to:a}=o[s];!l&&n.indexOf(a)==-1&&r(a)}}}function j1(t){let e=Object.create(null);return n(Ku(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);Ku(t,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new Yn(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(Sd);o.next.push({type:i[s][0],next:e[l.join(",")]||n(l)})}return o}}function H1(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],o=!i.validEnd,s=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];s.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Md(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Nd(t,e){let n=Object.create(null);for(let r in t){let i=t[r],o=e&&e[r];if(o===void 0)if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+r);else i.validate&&i.validate(o);n[r]=o}return n}function Td(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new W1(t,r,e[r]);return n}let Qn=class Id{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Td(e,r.attrs),this.defaultAttrs=Md(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Yn.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Nd(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new st(this,this.computeAttrs(e),I.from(n),re.setFrom(r))}createChecked(e=null,n,r){return n=I.from(n),this.checkContent(n),new st(this,this.computeAttrs(e),n,re.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=I.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let i=this.contentMatch.matchFragment(n),o=i&&i.fillBefore(I.empty,!0);return o?new st(this,e,n.append(o),re.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:re.none:e}static compile(e,n){let r=Object.create(null);e.forEach((o,s)=>r[o]=new Id(o,n,s));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function q1(t,e,n){let r=n.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${o}`)}}class W1{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?q1(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Is{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Td(e,i.attrs),this.excluded=null;let o=Md(this.attrs);this.instance=o?new re(this,o):null}create(e=null){return!e&&this.instance?this.instance:new re(this,Nd(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new Is(o,i++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}excludes(e){return this.excluded.indexOf(e)>-1}}class K1{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=xe.from(e.nodes),n.marks=xe.from(e.marks||{}),this.nodes=Qn.compile(this.spec.nodes,this),this.marks=Is.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=Yn.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?Ju(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:Ju(this,s.split(" "))}this.nodeFromJSON=i=>st.fromJSON(this,i),this.markFromJSON=i=>re.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Qn){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new cs(r,r.defaultAttrs,e,re.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function Ju(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],o=t.marks[i],s=o;if(o)n.push(o);else for(let l in t.marks){let a=t.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function J1(t){return t.tag!=null}function U1(t){return t.style!=null}class Xn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(J1(i))this.tags.push(i);else if(U1(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,n={}){let r=new Gu(this,n,!1);return r.addAll(e,re.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Gu(this,n,!0);return r.addAll(e,re.none,n.from,n.to),z.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(Q1(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,n,r,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let l=n[s];if((l.priority==null?50:l.priority)<o)break}n.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{r(s=Yu(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=Yu(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Xn(e,Xn.schemaRules(e)))}}const Ad={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},G1={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ed={ol:!0,ul:!0},zi=1,Ql=2,wi=4;function Uu(t,e,n){return e!=null?(e?zi:0)|(e==="full"?Ql:0):t&&t.whitespace=="pre"?zi|Ql:n&~wi}class zo{constructor(e,n,r,i,o,s){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=re.none,this.match=o||(s&wi?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(I.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&zi)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let n=I.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(I.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ad.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Gu{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,o,s=Uu(null,n.preserveWhitespace,0)|(r?wi:0);i?o=new zo(i.type,i.attrs,re.none,!0,n.topMatch||i.type.contentMatch,s):r?o=new zo(null,null,re.none,!0,null,s):o=new zo(e.schema.topNodeType,null,re.none,!0,null,s),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,o=i.options&Ql?"full":this.localPreserveWS||(i.options&zi)>0,{schema:s}=this.parser;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,`
|
|
40
|
-
`);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(s.text(l[a]),n,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Ed.hasOwnProperty(s)&&this.parser.normalizeLists&&Y1(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:G1.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Ad.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=a&&a.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
41
|
-
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=r.getPropertyValue(o);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(o,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,i){let o,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,n.attrs||null,r,n.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,n,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,n);this.findAtPoint(e,o)}findPlace(e,n,r){let i,o;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,o=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(o);for(let s=0;s<i.length;s++)n=this.enterInner(i[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=re.none;for(let l of i.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):Qu(l.type,e.type))&&(s=l.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,n,r,i){let o=this.findPlace(e.create(n),r,!1);return o&&(o=this.enterInner(e,n,r,!0,i)),o}enterInner(e,n,r,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=Uu(e,o,s.options);s.options&wi&&s.content.length==0&&(l|=wi);let a=re.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):Qu(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new zo(e,n,a,i,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=zi)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function Y1(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ed.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Q1(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Yu(t){let e={};for(let n in t)e[n]=t[n];return e}function Qu(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let o=[],s=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||o.indexOf(u)<0&&s(u))return!0}};if(s(i.contentMatch))return!0}}class or{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Po(n).createDocumentFragment());let i=r,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let l=0,a=0;for(;l<o.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)i=o.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,n);u&&(o.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){if(e.isText)return Po(n).createTextNode(e.text);let{dom:r,contentDOM:i}=Ho(Po(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Ho(Po(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return typeof n=="string"?{dom:e.createTextNode(n)}:Ho(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new or(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Xu(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Xu(e.marks)}}function Xu(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Po(t){return t.document||window.document}const Zu=new WeakMap;function X1(t){let e=Zu.get(t);return e===void 0&&Zu.set(t,e=Z1(t)),e}function Z1(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function Ho(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=X1(r))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let l,a=n?t.createElementNS(n,i):t.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),c[f]):f=="style"&&a.style?a.style.cssText=c[f]:a.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let d=e[f];if(d===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof d=="string")a.appendChild(t.createTextNode(d));else{let{dom:h,contentDOM:p}=Ho(t,d,n,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const vd=65535,Od=Math.pow(2,16);function e0(t,e){return t+e*Od}function ef(t){return t&vd}function t0(t){return(t-(t&vd))/Od}const Dd=1,Rd=2,qo=4,zd=8;class Xl{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&zd)>0}get deletedBefore(){return(this.delInfo&(Dd|qo))>0}get deletedAfter(){return(this.delInfo&(Rd|qo))>0}get deletedAcross(){return(this.delInfo&qo)>0}}class Ge{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ge.empty)return Ge.empty}recover(e){let n=0,r=ef(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+t0(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+o],u=this.ranges[l+s],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:n:n,h=a+i+(d<0?0:u);if(r)return h;let p=e==(n<0?a:f)?null:e0(l/3,e-a),m=0;return c&&(m|=e==a?Rd:e==f?Dd:qo,(n<0?e!=a:e!=f)&&(m|=zd)),new Xl(h,m,p)}i+=u-c}return r?e+i:new Xl(e+i,0,null)}touches(e,n){let r=0,i=ef(n),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?o:0),a=s+(this.inverted?0:o),c=this.ranges[i+n],u=this.ranges[i+r];e(l,l+c,a,a+u),o+=u-c}}invert(){return new Ge(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ge.empty:new Ge(e<0?[0,-e,0]:[0,0,e])}}Ge.empty=new Ge([]);class Pi{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Pi(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Pi;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],l=s.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new Xl(e,i,null)}}const sl=Object.create(null);class me{getMap(){return Ge.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=sl[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in sl)throw new RangeError("Duplicate use of step JSON ID "+e);return sl[e]=n,n.prototype.jsonID=e,n}}class he{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new he(e,null)}static fail(e){return new he(null,e)}static fromReplace(e,n,r,i){try{return he.ok(e.replace(n,r,i))}catch(o){if(o instanceof Di)return he.fail(o.message);throw o}}}function Pa(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let o=t.child(i);o.content.size&&(o=o.copy(Pa(o.content,e,o))),o.isInline&&(o=e(o,n,i)),r.push(o)}return I.fromArray(r)}class St extends me{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new z(Pa(n.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return he.fromReplace(e,this.from,this.to,o)}invert(e){let n=[];return e.nodesBetween(this.from,this.to,(r,i)=>{if(r.isInline&&r.isAtom){let o=this.mark.addToSet(r.marks);if(!re.sameSet(o,r.marks)){let s=Math.max(this.from,i),l=Math.min(this.to,i+r.nodeSize);us(Jt,s,l,this.mark,n);for(let a of r.marks)a.isInSet(o)||us(St,s,l,a,n)}}}),n.length==1?n[0]:new Vn(n)}map(e){let n=e.map(this.from,1),r=e.map(this.to,-1);return n>=r?null:new St(n,r,this.mark)}merge(e){return e instanceof St&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new St(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new St(n.from,n.to,e.markFromJSON(n.mark))}}me.jsonID("addMark",St);class Jt extends me{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new z(Pa(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return he.fromReplace(e,this.from,this.to,r)}invert(e){let n=[];return e.nodesBetween(this.from,this.to,(r,i)=>{r.isInline&&r.isAtom&&this.mark.isInSet(r.marks)&&us(St,Math.max(this.from,i),Math.min(this.to,i+r.nodeSize),this.mark,n)}),n.length==1?n[0]:new Vn(n)}map(e){let n=e.map(this.from,1),r=e.map(this.to,-1);return n>=r?null:new Jt(n,r,this.mark)}merge(e){return e instanceof Jt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Jt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Jt(n.from,n.to,e.markFromJSON(n.mark))}}me.jsonID("removeMark",Jt);function us(t,e,n,r,i){let o=i.length?i[i.length-1]:null;o&&o instanceof t&&o.to==e&&o.mark.eq(r)?i[i.length-1]=new t(o.from,n,r):i.push(new t(e,n,r))}class Vn extends me{constructor(e){super(),this.steps=e}apply(e){for(let n of this.steps){let r=n.apply(e);if(!r.doc)return r;e=r.doc}return new he(e,null)}invert(e){return new Vn(this.steps.map(n=>n.invert(e)))}map(e){let n=[];for(let r of this.steps){let i=r.map(e);i&&n.push(i)}return n.length?new Vn(n):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,n){if(!Array.isArray(n.steps)||!n.steps.every(r=>r.stepType=="addMark"||r.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new Vn(n.steps.map(r=>me.fromJSON(e,r)))}}me.jsonID("markSet",Vn);class kn extends me{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return he.fromReplace(e,this.pos,this.pos+1,new z(I.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new kn(this.pos,n.marks[i]);return new kn(this.pos,this.mark)}}return new Zn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new kn(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new kn(n.pos,e.markFromJSON(n.mark))}}me.jsonID("addNodeMark",kn);class Zn extends me{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return he.fromReplace(e,this.pos,this.pos+1,new z(I.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new kn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Zn(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Zn(n.pos,e.markFromJSON(n.mark))}}me.jsonID("removeNodeMark",Zn);class de extends me{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&Zl(e,this.from,this.to)?he.fail("Structure replace would overwrite content"):he.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ge([this.from,this.to-this.from,this.slice.size])}invert(e){return new de(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&de.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new de(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof de)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?z.empty:new z(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new de(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?z.empty:new z(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new de(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new de(n.from,n.to,z.fromJSON(e,n.slice),!!n.structure)}}de.MAP_BIAS=1;me.jsonID("replace",de);class Ee extends me{constructor(e,n,r,i,o,s,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Zl(e,this.from,this.gapFrom)||Zl(e,this.gapTo,this.to)))return he.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return he.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?he.fromReplace(e,this.from,this.to,r):he.fail("Content does not fit in gap")}getMap(){return new Ge([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Ee(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||o>r.pos||i>o?null:new Ee(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ee(n.from,n.to,n.gapFrom,n.gapTo,z.fromJSON(e,n.slice),n.insert,!!n.structure)}}me.jsonID("replaceAround",Ee);function Zl(t,e,n){let r=t.resolve(e),i=n-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function n0(t,e,n,r){let i=[];t.doc.nodesBetween(e,n,(o,s,l)=>{if(!o.isInline)return;let a=o.marks;if(!r.isInSet(a)&&l.type.allowsMarkType(r.type)){let c=Math.max(s,e),u=Math.min(s+o.nodeSize,n);us(St,c,u,r,i)}}),i.forEach(o=>t.step(o))}function r0(t,e,n,r){let i=[],o=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline||!s.isAtom)return;o++;let a=null;if(r instanceof Is){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,n);for(let u=0;u<a.length;u++){let f=a[u],d;for(let h=0;h<i.length;h++){let p=i[h];p.step==o-1&&f.eq(i[h].style)&&(d=p)}d?(d.to=c,d.step=o):i.push({style:f,from:Math.max(l,e),to:c,step:o})}}}),i.forEach(s=>t.step(new Jt(s.from,s.to,s.style)))}function Ba(t,e,n,r=n.contentMatch,i=!0){let o=t.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),u=l+c.nodeSize,f=r.matchType(c.type);if(!f)s.push(new de(l,u,z.empty));else{r=f;for(let d=0;d<c.marks.length;d++)n.allowsMarkType(c.marks[d].type)||t.step(new Jt(l,u,c.marks[d]));if(i&&c.isText&&n.whitespace!="pre"){let d,h=/\r?\n|\r/g,p;for(;d=h.exec(c.text);)p||(p=new z(I.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new de(l+d.index,l+d.index+d[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(I.empty,!0);t.replace(l,l,new z(a,0,0))}for(let a=s.length-1;a>=0;a--)t.step(s[a])}function i0(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function As(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,o=0;;--r){let s=t.$from.node(r),l=t.$from.index(r)+i,a=t.$to.indexAfter(r)-o;if(r<t.depth&&s.canReplace(l,a,n))return r;if(r==0||s.type.spec.isolating||!i0(s,l,a))break;l&&(i=1),a<s.childCount&&(o=1)}return null}function o0(t,e,n){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),l=i.after(o+1),a=s,c=l,u=I.empty,f=0;for(let p=o,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,u=I.from(r.node(p).copy(u)),f++):a--;let d=I.empty,h=0;for(let p=o,m=!1;p>n;p--)m||i.after(p+1)<i.end(p)?(m=!0,d=I.from(i.node(p).copy(d)),h++):c++;t.step(new Ee(a,c,s,l,new z(u.append(d),f,h),u.size-f,!0))}function La(t,e,n=null,r=t){let i=s0(t,e),o=i&&l0(r,e);return o?i.map(tf).concat({type:e,attrs:n}).concat(o.map(tf)):null}function tf(t){return{type:t,attrs:null}}function s0(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return n.canReplaceWith(r,i,s)?o:null}function l0(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:s}function a0(t,e,n){let r=I.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=I.from(n[s].type.create(n[s].attrs,r))}let i=e.start,o=e.end;t.step(new Ee(i,o,i,o,new z(r,0,0),n.length,!0))}function c0(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{let a=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,a)&&u0(t.doc,t.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Bd(t,s,l,o),Ba(t,t.mapping.slice(o).map(l,1),r,void 0,c===null);let u=t.mapping.slice(o),f=u.map(l,1),d=u.map(l+s.nodeSize,1);return t.step(new Ee(f,d,f+1,d-1,new z(I.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Pd(t,s,l,o),!1}})}function Pd(t,e,n,r){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=t.mapping.slice(r).map(n+1+o+s.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Bd(t,e,n,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+o);t.replaceWith(s,s+1,e.type.schema.text(`
|
|
42
|
-
`))}})}function u0(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function f0(t,e,n,r,i){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ee(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new z(I.from(s),0,0),1,!0))}function Ci(t,e,n=1,r){let i=t.resolve(e),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=n-2;c>o;c--,u--){let f=i.node(c),d=i.index(c);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(d,f.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||f;if(!f.canReplace(d+1,f.childCount)||!m.type.validContent(h))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function h0(t,e,n=1,r){let i=t.doc.resolve(e),o=I.empty,s=I.empty;for(let l=i.depth,a=i.depth-n,c=n-1;l>a;l--,c--){o=I.from(i.node(l).copy(o));let u=r&&r[c];s=I.from(u?u.type.create(u.attrs,s):i.node(l).copy(s))}t.step(new de(e,e,new z(o.append(s),n,n),!0))}function Es(t,e){let n=t.resolve(e),r=n.index();return p0(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function d0(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==r?t.type.schema.nodes.text:o.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(o.marks))return!1}return n.validEnd}function p0(t,e){return!!(t&&e&&!t.isLeaf&&d0(t,e))}function m0(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,o=t.doc.resolve(e-n),s=o.node().type;if(i&&s.inlineContent){let u=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);u&&!f?r=!1:!u&&f&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);Bd(t,u.node(),u.before(),l)}s.inlineContent&&Ba(t,e+n-1,s,o.node().contentMatchAt(o.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new de(c,a.map(e+n,-1),z.empty,!0)),r===!0){let u=t.doc.resolve(c);Pd(t,u.node(),u.before(),t.steps.length)}return t}function g0(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function y0(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let o=0;o<n.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(n.openStart==0&&n.size?2:1);o++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1;for(let a=0;a<2;a++){if(a){if(!l)break;l=-l}let c=r.index(s)+(l>0?1:0),u=r.node(s),f=!1;if(o==1)f=u.canReplace(c,c,i);else{let d=u.contentMatchAt(c).findWrapping(i.firstChild.type);f=d&&u.canReplaceWith(c,c,d[0])}if(f)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}}return null}function vs(t,e,n=e,r=z.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return Ld(i,o,r)?new de(e,n,r):new k0(i,o,r).fit()}function Ld(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class k0{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=I.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=I.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new z(o,s,l);return e>-1?new Ee(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new de(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let o=n.firstChild;if(n.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=nf(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(n==1&&(s?c.matchType(s.type)||(f=c.fillBefore(I.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(n==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced;return rf(e,-1)<=n?!1:(this.unplaced.size>1&&rf(e,1)>r&&r++,this.unplaced=new z(e,n+1,r),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=nf(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new z(di(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new z(di(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let m=0;m<o.length;m++)this.openFrontierNode(o[m]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:f,type:d}=this.frontier[n];if(i){for(let m=0;m<i.childCount;m++)u.push(i.child(m));f=f.matchFragment(i)}let h=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),y=f.matchType(m.type);if(!y)break;c++,(c>1||a==0||m.content.size)&&(f=y,u.push(Fd(m.mark(d.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=pi(this.placed,n,I.from(u)),this.frontier[n].match=f,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,y=u[u.length-1];y&&m<h;m++)this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),y=y.lastChild;this.unplaced=p?e==0?z.empty:new z(di(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new z(di(s.content,e,c),e,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!ll(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=ll(e,n,i,r,o);if(s){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=ll(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:s,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=pi(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=pi(this.placed,this.depth,I.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(I.empty,!0);n.childCount&&(this.placed=pi(this.placed,this.frontier.length,n))}}function di(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(di(t.firstChild.content,e-1,n)))}function pi(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(pi(t.lastChild.content,e-1,n)))}function nf(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Fd(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Fd(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(I.empty,!0)))),t.copy(r)}function ll(t,e,n,r,i){let o=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!b0(n,o.content,s)?l:null}function b0(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function x0(t){return t.spec.defining||t.spec.definingForContent}function rf(t,e){for(let n=0;;n++){let r=e<0?t.firstChild:t.lastChild;if(!r||r.isAtom)return n;t=r.content}}function w0(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),o=t.doc.resolve(n);if(Ld(i,o,r))return t.step(new de(e,n,r));let s=$d(i,o);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let d=i.depth,h=i.pos-1;d>0;d--,h--){let p=i.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==h&&s.splice(1,0,-d)}let a=s.indexOf(l),c=[],u=r.openStart;for(let d=r.content,h=0;;h++){let p=d.firstChild;if(c.push(p),h==r.openStart)break;d=p.content}for(let d=u-1;d>=0;d--){let h=c[d],p=x0(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=d;else if(p||!h.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let h=(d+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<s.length;m++){let y=s[(m+a)%s.length],g=!0;y<0&&(g=!1,y=-y);let C=i.node(y-1),w=i.index(y-1);if(C.canReplaceWith(w,w,p.type,p.marks))return t.replace(i.before(y),g?o.after(y):n,new z(_d(r.content,0,r.openStart,h),h,r.openEnd))}}let f=t.steps.length;for(let d=s.length-1;d>=0&&(t.replace(e,n,r),!(t.steps.length>f));d--){let h=s[d];h<0||(e=i.before(h),n=o.after(h))}}function _d(t,e,n,r,i){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(_d(o.content,e+1,n,r,o)))}if(e>r){let o=i.contentMatchAt(0),s=o.fillBefore(t).append(t);t=s.append(o.matchFragment(s).fillBefore(I.empty,!0))}return t}function C0(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=g0(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new z(I.from(r),0,0))}function S0(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let s=r.sharedDepth(n),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>s;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=i.depth;a>0&&n==i.start(a);a--)n=i.before(a);r=t.doc.resolve(e),i=t.doc.resolve(n)}}let o=$d(r,i);for(let s=0;s<o.length;s++){let l=o[s],a=s==o.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function $d(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(o<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}class wr extends me{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return he.fromReplace(e,this.pos,this.pos+1,new z(I.from(i),0,n.isLeaf?0:1))}getMap(){return Ge.empty}invert(e){return new wr(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new wr(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new wr(n.pos,n.attr,n.value)}}me.jsonID("attr",wr);class Bi extends me{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return he.ok(r)}getMap(){return Ge.empty}invert(e){return new Bi(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Bi(n.attr,n.value)}}me.jsonID("docAttr",Bi);let Wr=class extends Error{};Wr=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Wr.prototype=Object.create(Error.prototype);Wr.prototype.constructor=Wr;Wr.prototype.name="TransformError";class Vd{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Pi}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Wr(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((o,s,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=z.empty){let i=vs(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new z(I.from(r),0,0))}delete(e,n){return this.replace(e,n,z.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return w0(this,e,n,r),this}replaceRangeWith(e,n,r){return C0(this,e,n,r),this}deleteRange(e,n){return S0(this,e,n),this}lift(e,n){return o0(this,e,n),this}join(e,n=1){return m0(this,e,n),this}wrap(e,n){return a0(this,e,n),this}setBlockType(e,n=e,r,i=null){return c0(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return f0(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new wr(e,n,r)),this}setDocAttribute(e,n){return this.step(new Bi(e,n)),this}addNodeMark(e,n){return this.step(new kn(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof re)n.isInSet(r.marks)&&this.step(new Zn(e,n));else{let i=r.marks,o,s=[];for(;o=n.isInSet(i);)s.push(new Zn(e,o)),i=o.removeFromSet(i);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,n=1,r){return h0(this,e,n,r),this}addMark(e,n,r){return n0(this,e,n,r),this}removeMark(e,n,r){return r0(this,e,n,r),this}clearIncompatible(e,n,r){return Ba(this,e,n,r),this}}const al=Object.create(null);class q{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new jd(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=z.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let o=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(o);e.replaceRange(u.map(a.pos),u.map(c.pos),l?z.empty:n),l==0&&lf(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:l}=i[o],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),lf(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new G(e):pr(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=n<0?pr(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):pr(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Qe(e.node(0))}static atStart(e){return pr(e,e,0,0,1)||new Qe(e)}static atEnd(e){return pr(e,e,e.content.size,e.childCount,-1)||new Qe(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=al[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in al)throw new RangeError("Duplicate use of selection JSON ID "+e);return al[e]=n,n.prototype.jsonID=e,n}getBookmark(){return G.between(this.$anchor,this.$head).getBookmark()}}q.prototype.visible=!0;class jd{constructor(e,n){this.$from=e,this.$to=n}}let of=!1;function sf(t){!of&&!t.parent.inlineContent&&(of=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class G extends q{constructor(e,n=e){sf(e),sf(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return q.near(r);let i=e.resolve(n.map(this.anchor));return new G(i.parent.inlineContent?i:r,r)}replace(e,n=z.empty){if(super.replace(e,n),n==z.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof G&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Os(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new G(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=q.findFrom(n,r,!0)||q.findFrom(n,-r,!0);if(o)n=o.$head;else return q.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(q.findFrom(e,-r,!0)||q.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new G(e,n)}}q.jsonID("text",G);class Os{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Os(e.map(this.anchor),e.map(this.head))}resolve(e){return G.between(e.resolve(this.anchor),e.resolve(this.head))}}class W extends q{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),o=e.resolve(i);return r?q.near(o):new W(o)}content(){return new z(I.from(this.node),0,0)}eq(e){return e instanceof W&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Fa(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new W(e.resolve(n.anchor))}static create(e,n){return new W(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}W.prototype.visible=!1;q.jsonID("node",W);class Fa{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Os(r,r):new Fa(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&W.isSelectable(r)?new W(n):q.near(n)}}class Qe extends q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=z.empty){if(n==z.empty){e.delete(0,e.doc.content.size);let r=q.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Qe(e)}map(e){return new Qe(e)}eq(e){return e instanceof Qe}getBookmark(){return M0}}q.jsonID("all",Qe);const M0={map(){return this},resolve(t){return new Qe(t)}};function pr(t,e,n,r,i,o=!1){if(e.inlineContent)return G.create(t,n);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&W.isSelectable(l))return W.create(t,n-(i<0?l.nodeSize:0))}else{let a=pr(t,l,n+i,i<0?l.childCount:0,i,o);if(a)return a}n+=l.nodeSize*i}return null}function lf(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof de||i instanceof Ee))return;let o=t.mapping.maps[r],s;o.forEach((l,a,c,u)=>{s==null&&(s=u)}),t.setSelection(q.near(t.doc.resolve(s),n))}const af=1,Bo=2,cf=4;class N0 extends Vd{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|af)&~Bo,this.storedMarks=null,this}get selectionSet(){return(this.updated&af)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Bo,this}ensureMarks(e){return re.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Bo)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Bo,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||re.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(n);o=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(q.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=cf,this}get scrolledIntoView(){return(this.updated&cf)>0}}function uf(t,e){return!e||!t?t:t.bind(e)}class mi{constructor(e,n,r){this.name=e,this.init=uf(n.init,r),this.apply=uf(n.apply,r)}}const T0=[new mi("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new mi("selection",{init(t,e){return t.selection||q.atStart(e.doc)},apply(t){return t.selection}}),new mi("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new mi("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class cl{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=T0.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new mi(r.key,r.spec.state,r))})}}class br{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=i?i[s].n:0,c=i?i[s].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),o=!0}i&&(i[s]={state:r,n:n.length})}}if(!o)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new br(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];n[o.name]=o.apply(e,this[o.name],this,n)}return n}get tr(){return new N0(this)}static create(e){let n=new cl(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new br(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new cl(this.schema,e.plugins),r=n.fields,i=new br(n);for(let o=0;o<r.length;o++){let s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new cl(e.schema,e.plugins),o=new br(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=st.fromJSON(e.schema,n.doc);else if(s.name=="selection")o.selection=q.fromJSON(o.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){o[s.name]=c.fromJSON.call(a,e,n[l],o);return}}o[s.name]=s.init(e,o)}}),o}}function Hd(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Hd(i,e,{})),n[r]=i}return n}class Ne{constructor(e){this.spec=e,this.props={},e.props&&Hd(e.props,this,this.props),this.key=e.key?e.key.key:qd("plugin")}getState(e){return e[this.key]}}const ul=Object.create(null);function qd(t){return t in ul?t+"$"+ ++ul[t]:(ul[t]=0,t+"$")}class Te{constructor(e="key"){this.key=qd(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const _a=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Wd(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Kd=(t,e,n)=>{let r=Wd(t,n);if(!r)return!1;let i=$a(r);if(!i){let s=r.blockRange(),l=s&&As(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(Gd(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Kr(o,"end")||W.isSelectable(o)))for(let s=r.depth;;s--){let l=vs(t.doc,r.before(s),r.after(s),z.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(Kr(o,"end")?q.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):W.create(a.doc,i.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},I0=(t,e,n)=>{let r=Wd(t,n);if(!r)return!1;let i=$a(r);return i?A0(t,i,e):!1};function A0(t,e,n){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=vs(t.doc,o,a,z.empty);if(!c||c.from!=o||c instanceof de&&c.slice.size>=a-o)return!1;if(n){let u=t.tr.step(c);u.setSelection(G.create(u.doc,o)),n(u.scrollIntoView())}return!0}function Kr(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const Jd=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=$a(r)}let s=o&&o.nodeBefore;return!s||!W.isSelectable(s)?!1:(e&&e(t.tr.setSelection(W.create(t.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function $a(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function E0(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const v0=(t,e,n)=>{let r=E0(t,n);if(!r)return!1;let i=Ud(r);if(!i)return!1;let o=i.nodeAfter;if(Gd(t,i,e,1))return!0;if(r.parent.content.size==0&&(Kr(o,"start")||W.isSelectable(o))){let s=vs(t.doc,r.before(),r.after(),z.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=t.tr.step(s);l.setSelection(Kr(o,"start")?q.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):W.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},O0=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;o=Ud(r)}let s=o&&o.nodeAfter;return!s||!W.isSelectable(s)?!1:(e&&e(t.tr.setSelection(W.create(t.doc,o.pos)).scrollIntoView()),!0)};function Ud(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const D0=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
|
43
|
-
`).scrollIntoView()),!0)};function Va(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const R0=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=Va(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,s.createAndFill());a.setSelection(q.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},z0=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Qe||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Va(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(s,o.createAndFill());l.setSelection(G.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},P0=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(Ci(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&As(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function B0(t){return(e,n)=>{if(e.selection instanceof W&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!Ci(e.doc,h.pos)?!1:(n&&n(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof G||e.selection instanceof Qe)&&r.deleteSelection();let{$from:i}=r.selection,o=r.steps.length,s=[],l,a,c=!1,u=!1;for(let h=i.depth;;h--)if(i.node(h).isBlock){c=i.end(h)==i.pos+(i.depth-h),u=i.start(h)==i.pos-(i.depth-h),a=Va(i.node(h-1).contentMatchAt(i.indexAfter(h-1))),s.unshift(c&&a?{type:a}:null),l=h;break}else{if(h==1)return!1;s.unshift(null)}let f=i.pos,d=Ci(r.doc,f,s.length,s);if(d||(s[0]=a?{type:a}:null,d=Ci(r.doc,f,s.length,s)),!d)return!1;if(r.split(f,s.length,s),!c&&u&&i.node(l).type!=a){let h=r.mapping.slice(o),p=h.map(i.before(l)),m=r.doc.resolve(p);a&&i.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(h.map(i.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}const L0=B0(),F0=(t,e)=>(e&&e(t.tr.setSelection(new Qe(t.doc))),!0);function _0(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||Es(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Gd(t,e,n,r){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&_0(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&l.matchType(s[0]||o.type).validEnd){if(n){let h=e.pos+o.nodeSize,p=I.empty;for(let g=s.length-1;g>=0;g--)p=I.from(s[g].create(null,p));p=I.from(i.copy(p));let m=t.tr.step(new Ee(e.pos-1,h,e.pos,h,new z(p,1,0),s.length,!0)),y=m.doc.resolve(h+2*s.length);y.nodeAfter&&y.nodeAfter.type==i.type&&Es(m.doc,y.pos)&&m.join(y.pos),n(m.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&a?null:q.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),d=f&&As(f);if(d!=null&&d>=e.depth)return n&&n(t.tr.lift(f,d).scrollIntoView()),!0;if(c&&Kr(o,"start",!0)&&Kr(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=o,y=1;for(;!m.isTextblock;m=m.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let g=I.empty;for(let w=p.length-1;w>=0;w--)g=I.from(p[w].copy(g));let C=t.tr.step(new Ee(e.pos-p.length,e.pos+o.nodeSize,e.pos+y,e.pos+o.nodeSize-y,new z(g,p.length,0),0,!0));n(C.scrollIntoView())}return!0}}return!1}function Yd(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(n&&n(e.tr.setSelection(G.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const $0=Yd(-1),V0=Yd(1);function ja(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),l=s&&La(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Li(t,e=null){return function(n,r){let i=!1;for(let o=0;o<n.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:l}}=n.selection.ranges[o];n.doc.nodesBetween(s,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)i=!0;else{let u=n.doc.resolve(c),f=u.index();i=u.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let o=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[s];o.setBlockType(l,a,t,e)}r(o.scrollIntoView())}return!0}}function j0(t,e,n,r){for(let i=0;i<e.length;i++){let{$from:o,$to:s}=e[i],l=o.depth==0?t.inlineContent&&t.type.allowsMarkType(n):!1;if(t.nodesBetween(o.pos,s.pos,(a,c)=>{if(l)return!1;l=a.inlineContent&&a.type.allowsMarkType(n)}),l)return!0}return!1}function Ds(t,e=null,n){return function(r,i){let{empty:o,$cursor:s,ranges:l}=r.selection;if(o&&!s||!j0(r.doc,l,t))return!1;if(i)if(s)t.isInSet(r.storedMarks||s.marks())?i(r.tr.removeStoredMark(t)):i(r.tr.addStoredMark(t.create(e)));else{let a,c=r.tr;a=!l.some(u=>r.doc.rangeHasMark(u.$from.pos,u.$to.pos,t));for(let u=0;u<l.length;u++){let{$from:f,$to:d}=l[u];if(!a)c.removeMark(f.pos,d.pos,t);else{let h=f.pos,p=d.pos,m=f.nodeAfter,y=d.nodeBefore,g=m&&m.isText?/^\s*/.exec(m.text)[0].length:0,C=y&&y.isText?/\s*$/.exec(y.text)[0].length:0;h+g<p&&(h+=g,p-=C),c.addMark(h,p,t.create(e))}}i(c.scrollIntoView())}return!0}}function Zr(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}let fl=Zr(_a,Kd,Jd),ff=Zr(_a,v0,O0);const _t={Enter:Zr(D0,z0,P0,L0),"Mod-Enter":R0,Backspace:fl,"Mod-Backspace":fl,"Shift-Backspace":fl,Delete:ff,"Mod-Delete":ff,"Mod-a":F0},Qd={"Ctrl-h":_t.Backspace,"Alt-Backspace":_t["Mod-Backspace"],"Ctrl-d":_t.Delete,"Ctrl-Alt-Backspace":_t["Mod-Delete"],"Alt-Delete":_t["Mod-Delete"],"Alt-d":_t["Mod-Delete"],"Ctrl-a":$0,"Ctrl-e":V0};for(let t in _t)Qd[t]=_t[t];const H0=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,q0=H0?Qd:_t;class tt{constructor(e,n,r={}){this.match=e,this.match=e,this.handler=typeof n=="string"?W0(n):n,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}}function W0(t){return function(e,n,r,i){let o=t;if(n[1]){let s=n[0].lastIndexOf(n[1]);o+=n[0].slice(s+n[1].length),r+=s;let l=r-i;l>0&&(o=n[0].slice(s-l,s)+o,r=i)}return e.tr.insertText(o,r,i)}}const K0=(t,e)=>{let n=t.plugins;for(let r=0;r<n.length;r++){let i=n[r],o;if(i.spec.isInputRules&&(o=i.getState(t))){if(e){let s=t.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(o.text){let a=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,t.schema.text(o.text,a))}else s.delete(o.from,o.to);e(s)}return!0}}return!1};new tt(/--$/,"—",{inCodeMark:!1});new tt(/\.\.\.$/,"…",{inCodeMark:!1});new tt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1});new tt(/"$/,"”",{inCodeMark:!1});new tt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1});new tt(/'$/,"’",{inCodeMark:!1});function Ha(t,e,n,r){let i,o;return e instanceof Qn?o=e:(i=e,o=e.nodeType,n=e.getAttrs,r=e.joinPredicate),new tt(t,(s,l,a,c)=>{let u=n instanceof Function?n(l):n,f=s.tr.delete(a,c),d=f.doc.resolve(a),h=d.blockRange(),p=h&&La(h,o,u);if(!p)return null;f.wrap(h,p);let m=f.doc.resolve(a-1).nodeBefore;return m&&m.type==o&&Es(f.doc,a-1)&&(!r||r(l,m))&&f.join(a-1),f},i)}function Xd(t,e,n){let r,i;return e instanceof Qn?i=e:(r=e,i=e.nodeType,n=e.getAttrs),new tt(t,(o,s,l,a)=>{let c=o.doc.resolve(l),u=n instanceof Function?n(s):n;return c.node(-1).canReplaceWith(c.index(-1),c.indexAfter(-1),i)?o.tr.delete(l,a).setBlockType(l,l,i,u):null},r)}const Sn=typeof navigator<"u"?navigator:null,hf=typeof document<"u"?document:null,Nn=Sn&&Sn.userAgent||"",ea=/Edge\/(\d+)/.exec(Nn),Zd=/MSIE \d/.exec(Nn),ta=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Nn),qa=!!(Zd||ta||ea);Zd?document.documentMode:ta?+ta[1]:ea&&+ea[1];const J0=!qa&&/gecko\/(\d+)/i.test(Nn);J0&&+(/Firefox\/(\d+)/.exec(Nn)||[0,0])[1];const na=!qa&&/Chrome\/(\d+)/.exec(Nn),U0=!!na;na&&+na[1];const G0=!qa&&!!Sn&&/Apple Computer/.test(Sn.vendor),Y0=G0&&(/Mobile\/\w+/.test(Nn)||!!Sn&&Sn.maxTouchPoints>2);Y0||Sn&&/Mac/.test(Sn.platform);const Q0=/Android \d/.test(Nn),X0=!!hf&&"webkitFontSmoothing"in hf.documentElement.style;X0&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];function hl(t,e,n,r,i,o){if(t.composing)return!1;const s=t.state,l=s.doc.resolve(e);if(l.parent.type.spec.code)return!1;const a=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,void 0,"")+r;for(let c of i){const u=c,f=u.match.exec(a),d=f&&f[0]&&u.handler(s,f,e-(f[0].length-r.length),n);if(d)return u.undoable!==!1&&d.setMeta(o,{transform:d,from:e,to:n,text:r}),t.dispatch(d),!0}return!1}const Z0=new Te("MILKDOWN_CUSTOM_INPUTRULES");function ex({rules:t}){const e=new Ne({key:Z0,isInputRules:!0,state:{init(){return null},apply(n,r){const i=n.getMeta(this);return i||(n.selectionSet||n.docChanged?null:r)}},props:{handleTextInput(n,r,i,o){return hl(n,r,i,o,t,e)},handleDOMEvents:{compositionend:n=>(setTimeout(()=>{const{$cursor:r}=n.state.selection;r&&hl(n,r.pos,r.pos,"",t,e)}),!1),keydown:(n,r)=>!(Q0&&U0&&r.key==="Enter")||n.composing?!1:n.someProp("handleKeyDown",i=>i(n,r))?(r.preventDefault(),!0):!1},handleKeyDown(n,r){if(r.key!=="Enter")return!1;const{$cursor:i}=n.state.selection;return i?hl(n,i.pos,i.pos,`
|
|
44
|
-
`,t,e):!1}}});return e}function ep(t){return t.some(e=>e.type.spec.code)}function df(t,e,n){if(e>=n)return!1;let r=!1;return t.doc.nodesBetween(e,n,i=>(i.isInline&&ep(i.marks)&&(r=!0),!r)),r}function tx(t,e){var n;return ep((n=t.storedMarks)!=null?n:t.doc.resolve(e).marks())}function go(t,e,n={}){return new tt(t,(r,i,o,s)=>{var l,a,c,u;const{tr:f}=r,d=i.length;let h=i[d-1],p=i[0],m=[],y;const g={group:h,fullMatch:p,start:o,end:s},C=(l=n.updateCaptured)==null?void 0:l.call(n,g);if(Object.assign(g,C),{group:h,fullMatch:p,start:o,end:s}=g,p===null||(h==null?void 0:h.trim())==="")return null;if(h){const w=p.search(/\S/),E=o+p.indexOf(h),P=E+h.length,S=df(r,o+w,E),D=P<s&&df(r,P,s);if(S||D||tx(r,s))return null;m=(a=f.storedMarks)!=null?a:[],P<s&&f.delete(P,s),E>o&&f.delete(o+w,E),y=o+w+h.length;const F=(c=n.getAttr)==null?void 0:c.call(n,i);f.addMark(o,y,e.create(F)),f.setStoredMarks(m),(u=n.beforeDispatch)==null||u.call(n,{match:i,start:o,end:s,tr:f})}return f})}function tp(t){return Object.assign(Object.create(t),t).setTime(Date.now())}function nx(t,e){return Array.isArray(t)&&t.includes(e.type)||e.type===t}function rx(t){if(t.content.childCount===1){const e=t.content.firstChild;if((e==null?void 0:e.type.name)==="text"&&e.marks.length===0)return e;if((e==null?void 0:e.type.name)==="paragraph"&&e.childCount===1){const n=e.firstChild;if((n==null?void 0:n.type.name)==="text"&&n.marks.length===0)return n}}return!1}function ix(t){return e=>{for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r)){const i=e.before(n),o=e.after(n);return{from:i,to:o,node:r}}}}}function ox(t,e){return ix(n=>n.type===e)(t)}function sx(t,e){const n=e.nodes[t];if(!n)throw Yg("node",t);return n}function lx(t){return e=>{for(let n=e.depth;n>0;n--){const r=e.node(n);if(t(r))return{pos:e.before(n),start:e.start(n),depth:n,node:r}}}}function ax(t,e){if(!(t instanceof W))return;const{node:n,$from:r}=t;if(nx(e,n))return{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}}const cx=(t,e)=>{const{selection:n,doc:r}=t;if(n instanceof W)return{hasNode:n.node.type===e,pos:n.from,target:n.node};const{from:i,to:o}=n;let s=!1,l=-1,a=null;return r.nodesBetween(i,o,(c,u)=>a?!1:c.type===e?(s=!0,l=u,a=c,!1):!0),{hasNode:s,pos:l,target:a}},ux=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),fx=typeof navigator<"u"&&/Win/.test(navigator.platform);function hx(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))ux?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function dx(t){let e=Object.create(null);for(let n in t)e[hx(n)]=t[n];return e}function dl(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function np(t){return new Ne({props:{handleKeyDown:rp(t)}})}function rp(t){let e=dx(t);return function(n,r){let i=$g(r),o,s=e[dl(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[dl(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(fx&&r.ctrlKey&&r.altKey)&&(o=Vg[r.keyCode])&&o!=i){let l=e[dl(o,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var ip=class{},op=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=t=>{var e;(e=this.top())==null||e.push(t)},this.open=t=>{this.elements.push(t)},this.close=()=>{const t=this.elements.pop();if(!t)throw Nh();return t}}},px=class sp extends ip{constructor(e,n,r){super(),this.type=e,this.content=n,this.attrs=r}push(e,...n){this.content.push(e,...n)}pop(){return this.content.pop()}static create(e,n,r){return new sp(e,n,r)}},dt,Rr,Qi,Xi,Zi,zr,Pr,Kn,mx=(Kn=class extends op{constructor(n){super();B(this,dt);B(this,Rr);B(this,Qi);B(this,Xi);B(this,Zi);B(this,zr);B(this,Pr);v(this,dt,re.none),v(this,Rr,r=>r.isText),v(this,Qi,(r,i)=>{if(x(this,Rr).call(this,r)&&x(this,Rr).call(this,i)&&re.sameSet(r.marks,i.marks))return this.schema.text(r.text+i.text,r.marks)}),v(this,Xi,r=>{const i=Object.values({...this.schema.nodes,...this.schema.marks}).find(o=>o.spec.parseMarkdown.match(r));if(!i)throw Ug(r);return i}),v(this,Zi,r=>{const i=x(this,Xi).call(this,r);i.spec.parseMarkdown.runner(this,r,i)}),this.injectRoot=(r,i,o)=>(this.openNode(i,o),this.next(r.children),this),this.openNode=(r,i)=>(this.open(px.create(r,[],i)),this),v(this,zr,()=>{v(this,dt,re.none);const r=this.close();return x(this,Pr).call(this,r.type,r.attrs,r.content)}),this.closeNode=()=>{try{x(this,zr).call(this)}catch(r){console.error(r)}return this},v(this,Pr,(r,i,o)=>{const s=r.createAndFill(i,o,x(this,dt));if(!s)throw Jg(r,i,o);return this.push(s),s}),this.addNode=(r,i,o)=>{try{x(this,Pr).call(this,r,i,o)}catch(s){console.error(s)}return this},this.openMark=(r,i)=>{const o=r.create(i);return v(this,dt,o.addToSet(x(this,dt))),this},this.closeMark=r=>(v(this,dt,r.removeFromSet(x(this,dt))),this),this.addText=r=>{try{const i=this.top();if(!i)throw Nh();const o=i.pop(),s=this.schema.text(r,x(this,dt));if(!o)return i.push(s),this;const l=x(this,Qi).call(this,o,s);return l?(i.push(l),this):(i.push(o,s),this)}catch(i){return console.error(i),this}},this.build=()=>{let r;do r=x(this,zr).call(this);while(this.size());return r},this.next=(r=[])=>([r].flat().forEach(i=>x(this,Zi).call(this,i)),this),this.toDoc=()=>this.build(),this.run=(r,i)=>{const o=r.runSync(r.parse(i),i);return this.next(o),this},this.schema=n}},dt=new WeakMap,Rr=new WeakMap,Qi=new WeakMap,Xi=new WeakMap,Zi=new WeakMap,zr=new WeakMap,Pr=new WeakMap,Kn.create=(n,r)=>{const i=new Kn(n);return o=>(i.run(r,o),i.toDoc())},Kn),Jn,pf=(Jn=class extends ip{constructor(e,n,r,i={}){super(),this.type=e,this.children=n,this.value=r,this.props=i,this.push=(o,...s)=>{this.children||(this.children=[]),this.children.push(o,...s)},this.pop=()=>{var o;return(o=this.children)==null?void 0:o.pop()}}},Jn.create=(e,n,r,i={})=>new Jn(e,n,r,i),Jn),gx=t=>Object.prototype.hasOwnProperty.call(t,"size"),De,Br,eo,to,no,ro,Lr,Fr,io,oo,Rn,gn,so,_r,Un,yx=(Un=class extends op{constructor(n){super();B(this,De);B(this,Br);B(this,eo);B(this,to);B(this,no);B(this,ro);B(this,Lr);B(this,Fr);B(this,io);B(this,oo);B(this,Rn);B(this,gn);B(this,so);B(this,_r);v(this,De,[]),v(this,Br,r=>{const i=Object.values({...this.schema.nodes,...this.schema.marks}).find(o=>o.spec.toMarkdown.match(r));if(!i)throw Gg(r.type);return i}),v(this,eo,r=>x(this,Br).call(this,r).spec.toMarkdown.runner(this,r)),v(this,to,(r,i)=>x(this,Br).call(this,r).spec.toMarkdown.runner(this,r,i)),v(this,no,r=>{const i=l=>l.type.spec.priority??50,o=[...r].sort((l,a)=>i(l)-i(a)),s=[];return x(this,De).forEach(({mark:l})=>{const a=o.findIndex(c=>c.eq(l));a>=0&&s.push(...o.splice(a,1))}),s.concat(o)}),v(this,ro,r=>{const i=r==null?void 0:r.marks;let o=0;for(;o<x(this,De).length;){const{mark:s,spanning:l}=x(this,De)[o];if(l&&(i!=null&&i.some(a=>a.eq(s))))o++;else break}for(let s=x(this,De).length-1;s>=o;s--)x(this,_r).call(this,x(this,De)[s].mark)}),v(this,Lr,(r,i)=>{x(this,no).call(this,r.marks).every(o=>!x(this,to).call(this,o,r))&&x(this,eo).call(this,r),x(this,ro).call(this,i)}),v(this,Fr,r=>{const{children:i}=r;return i&&(r.children=i.reduce((o,s,l)=>{if(l===0)return[s];const a=o.at(-1);if(a&&a.isMark&&s.isMark){const{children:c,...u}=s,{children:f,...d}=a;if(s.type===a.type&&c&&f&&JSON.stringify(u)===JSON.stringify(d)){const h={...d,children:[...f,...c]};return o.slice(0,-1).concat(x(this,Fr).call(this,h))}}return o.concat(s)},[])),r}),v(this,io,r=>{const i={...r.props,type:r.type};return r.children&&(i.children=r.children),r.value&&(i.value=r.value),i}),this.openNode=(r,i,o)=>(this.open(pf.create(r,void 0,i,o)),this),v(this,oo,(r,i)=>{let o="",s="";const l=r.children;if(l){const c=l[0],u=l.at(-1);if(u&&u.type==="text"&&u.value.endsWith(" ")){const f=u.value,d=f.trimEnd();s=f.slice(d.length),u.value=d}if(c&&c.type==="text"&&c.value.startsWith(" ")){const f=c.value,d=f.trimStart();o=f.slice(0,f.length-d.length),c.value=d}}o.length&&x(this,gn).call(this,"text",void 0,o);const a=i();return s.length&&x(this,gn).call(this,"text",void 0,s),a}),v(this,Rn,(r=!1)=>{const i=this.close(),o=()=>x(this,gn).call(this,i.type,i.children,i.value,i.props);return r?x(this,oo).call(this,i,o):o()}),this.closeNode=()=>(x(this,Rn).call(this),this),v(this,gn,(r,i,o,s)=>{const l=pf.create(r,i,o,s),a=x(this,Fr).call(this,x(this,io).call(this,l));return this.push(a),a}),this.addNode=(r,i,o,s)=>(x(this,gn).call(this,r,i,o,s),this),v(this,so,(r,i,o,s)=>x(this,De).some(l=>l.mark.eq(r))?this:(x(this,De).push({mark:r,spanning:o==null}),this.openNode(i,o,{...s,isMark:!0}))),v(this,_r,r=>{let i=-1;for(let o=x(this,De).length-1;o>=0;o--)if(x(this,De)[o].mark.eq(r)){i=o;break}i<0||(x(this,De).splice(i,1),x(this,Rn).call(this,!0))}),this.withMark=(r,i,o,s)=>(x(this,so).call(this,r,i,o,s),this),this.closeMark=r=>(x(this,_r).call(this,r),this),this.build=()=>{let r=null;do r=x(this,Rn).call(this);while(this.size());return r.children||(r.children=[]),r},this.next=r=>gx(r)?(r.forEach((i,o,s)=>{x(this,Lr).call(this,i,r.maybeChild(s+1)??void 0)}),this):(x(this,Lr).call(this,r),this),this.toString=r=>r.stringify(this.build()),this.run=r=>(v(this,De,[]),this.next(r),this),this.schema=n}},De=new WeakMap,Br=new WeakMap,eo=new WeakMap,to=new WeakMap,no=new WeakMap,ro=new WeakMap,Lr=new WeakMap,Fr=new WeakMap,io=new WeakMap,oo=new WeakMap,Rn=new WeakMap,gn=new WeakMap,so=new WeakMap,_r=new WeakMap,Un.create=(n,r)=>{const i=new Un(n);return o=>(i.run(o),i.toString(r))},Un);const we=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Jr=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let ra=null;const Ft=function(t,e,n){let r=ra||(ra=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},kx=function(){ra=null},er=function(t,e,n,r){return n&&(mf(t,e,n,r,-1)||mf(t,e,n,r,1))},bx=/^(img|br|input|textarea|hr)$/i;function mf(t,e,n,r,i){for(var o;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Ae(t))){let s=t.parentNode;if(!s||!$(s)||yo(t)||bx.test(t.nodeName)||t.contentEditable=="false")return!1;e=we(t)+(i<0?0:1),t=s}else if($(t)){let s=t.childNodes[e+(i<0?-1:0)];if($(s)&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else t=s,e=i<0?Ae(t):0}else return!1}}function Ae(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function $(t){return t.nodeType==1}function pe(t){return t.nodeType==3}function tr(t,e){return e?t.contains($(e)?e:e.parentNode):!1}function xx(t,e){for(;;){if(pe(t)&&e)return t;if($(t)&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Ae(t)}else if(t.parentNode&&!yo(t))e=we(t),t=t.parentNode;else return null}}function wx(t,e){for(;;){if(pe(t)&&e<t.nodeValue.length)return t;if($(t)&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!yo(t))e=we(t)+1,t=t.parentNode;else return null}}function Cx(t,e,n){for(let r=e==0,i=e==Ae(t);r||i;){if(t==n)return!0;let o=we(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==Ae(t)}}function yo(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Rs=function(t){return t.focusNode&&er(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Sx(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Mx(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Nx(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Ae(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Ae(r.startContainer),r.startOffset)}}}const It=typeof navigator<"u"?navigator:null,gf=typeof document<"u"?document:null,Tn=It&&It.userAgent||"",ia=/Edge\/(\d+)/.exec(Tn),lp=/MSIE \d/.exec(Tn),oa=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Tn),je=!!(lp||oa||ia),bn=lp?document.documentMode:oa?+oa[1]:ia?+ia[1]:0,Xe=!je&&/gecko\/(\d+)/i.test(Tn);Xe&&+(/Firefox\/(\d+)/.exec(Tn)||[0,0])[1];const sa=!je&&/Chrome\/(\d+)/.exec(Tn),Se=!!sa,ap=sa?+sa[1]:0,ve=!je&&!!It&&/Apple Computer/.test(It.vendor),Ur=ve&&(/Mobile\/\w+/.test(Tn)||!!It&&It.maxTouchPoints>2),it=Ur||(It?/Mac/.test(It.platform):!1),cp=It?/Win/.test(It.platform):!1,Ut=/Android \d/.test(Tn),zs=!!gf&&"webkitFontSmoothing"in gf.documentElement.style,Tx=zs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ix(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Pt(t,e){return typeof t=="number"?t:t[e]}function Ax(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function yf(t,e,n){if(!la(e)&&e.left==0)return;let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(!$(s)){s=Jr(s);continue}let l=s==o.body,a=l?Ix(o):Ax(s),c=0,u=0;if(e.top<a.top+Pt(r,"top")?u=-(a.top-e.top+Pt(i,"top")):e.bottom>a.bottom-Pt(r,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+Pt(i,"top")-a.top:e.bottom-a.bottom+Pt(i,"bottom")),e.left<a.left+Pt(r,"left")?c=-(a.left-e.left+Pt(i,"left")):e.right>a.right-Pt(r,"right")&&(c=e.right-a.right+Pt(i,"right")),c||u)if(l)o.defaultView.scrollBy(c,u);else{let d=s.scrollLeft,h=s.scrollTop;u&&(s.scrollTop+=u),c&&(s.scrollLeft+=c);let p=s.scrollLeft-d,m=s.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}let f=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(f))break;s=f=="absolute"?s.offsetParent:Jr(s)}}function Ex(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=t.root.elementFromPoint(o,s);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:up(t.dom)}}function up(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Jr(r));return e}function vx({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;fp(n,r==0?0:r-e)}function fp(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:o}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let hr=null;function Ox(t){if(t.setActive)return t.setActive();if(hr)return t.focus(hr);let e=up(t);t.focus(hr==null?{get preventScroll(){return hr={preventScroll:!0},!0}}:void 0),hr||(hr=!1,fp(e,0))}function hp(t,e){let n,r=2e8,i,o=0,s=e.top,l=e.top,a,c;for(let u=t.firstChild,f=0;u;u=u.nextSibling,f++){let d;if($(u))d=u.getClientRects();else if(pe(u))d=Ft(u).getClientRects();else continue;for(let h=0;h<d.length;h++){let p=d[h];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){n=u,r=m,i=m&&pe(n)?{left:p.right<e.left?p.right:p.left,top:e.top}:e,$(u)&&m&&(o=f+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(o=f+1)}}return!n&&a&&(n=a,i=c,r=0),n&&pe(n)?Dx(n,i):!n||r?{node:t,offset:o}:hp(n,i)}function Dx(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);let s=an(r,1);if(s.top!=s.bottom&&Wa(e,s)){i={node:t,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function Wa(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Rx(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function zx(t,e,n){let{node:r,offset:i}=hp(e,n),o=-1;if($(r)&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,o)}function Px(t,e,n,r){let i=-1;for(let o=e,s=!1;o!=t.dom;){let l=t.docView.nearestDesc(o,!0),a;if(!l)return null;if($(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?i=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function dp(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),o=i;;){let s=t.childNodes[o];if($(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Wa(e,c))return dp(s,e,c)}}if((o=(o+1)%r)==i)break}return t}function Bx(t,e){let n=t.dom.ownerDocument,r,i=0,o=Nx(n,e.left,e.top);o&&({node:r,offset:i}=o);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!s||!t.dom.contains(s)){let c=t.dom.getBoundingClientRect();if(!Wa(e,c)||(s=dp(t.dom,e,c),!s))return null}if(ve)for(let c=s;r&&c;c=Jr(c))c.draggable&&(r=void 0);if(s=Rx(s,e),r){if(Xe&&$(r)&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let c;zs&&i&&$(r)&&$(c=r.childNodes[i-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&$(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||!$(r)||r.childNodes[i-1].nodeName!="BR")&&(l=Px(t,r,i,e))}l==null&&(l=zx(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function la(t){return t.top<t.bottom||t.left<t.right}function an(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(la(r))return r}return Array.prototype.find.call(n,la)||t.getBoundingClientRect()}const Lx=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function pp(t,e,n){let{node:r,offset:i,atom:o}=t.docView.domFromPos(e,n<0?-1:1),s=zs||Xe;if(pe(r))if(s&&(Lx.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let a=an(Ft(r,i,i),n);if(Xe&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=an(Ft(r,i-1,i-1),-1);if(c.top==a.top){let u=an(Ft(r,i,i+1),-1);if(u.top!=a.top)return fi(u,u.left<c.left)}}return a}else{let a=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==r.nodeValue.length?(a--,u=1):n<0?a--:c++,fi(an(Ft(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==Ae(r))){let a=r.childNodes[i-1];if($(a))return pl(a.getBoundingClientRect(),!1)}if(o==null&&i<Ae(r)){let a=r.childNodes[i];if($(a))return pl(a.getBoundingClientRect(),!0)}return pl(r.getBoundingClientRect(),n>=0)}if(o==null&&i&&(n<0||i==Ae(r))){let a=r.childNodes[i-1],c=pe(a)?Ft(a,Ae(a)-(s?0:1)):$(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return fi(an(c,1),!1)}if(o==null&&i<Ae(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?pe(a)?Ft(a,0,s?0:1):$(a)?a:null:null;if(c)return fi(an(c,-1),!0)}return fi(an(pe(r)?Ft(r):r,-n),n>=0)}function fi(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function pl(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function mp(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function Fx(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return mp(t,e,()=>{let{node:o}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=pp(t,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if($(l))a=l.getClientRects();else if(pe(l))a=Ft(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const _x=/[\u0590-\u08ac]/;function $x(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=t.domSelection();return l?!_x.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?o:s:mp(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:f}=t.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),y=p&&!tr(h,p)||a==p&&c==m;try{l.collapse(u,f),a&&(a!=u||c!=f)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),y}):r.pos==r.start()||r.pos==r.end()}let kf=null,bf=null,xf=!1;function Vx(t,e,n){return kf==e&&bf==n?xf:(kf=e,bf=n,xf=n=="up"||n=="down"?Fx(t,e,n):$x(t,e,n))}const lt=0,wf=1,vn=2,yt=3;class ko{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=lt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&tr(this.contentDOM,e))if(r<0){let o,s;if(e==this.contentDOM)o=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>we(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let o=e.compareDocumentPosition(this.contentDOM);o&16?i=n>Array.from(e.childNodes).findIndex(s=>s.contains(this.contentDOM)):i=!(o&4)}else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!n||o.node))if(r&&(s=o.nodeDOM)&&!($(s)?tr(s,e):s==e))r=!1;else return o}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],o=r+i.size;if(r==e&&o!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let l=i.children[s];if(l.size){i=l;break}}return i}if(e<o)return i.descAt(e-r-i.border);r=o}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let o=0;r<this.children.length;r++){let s=this.children[r],l=o+s.size;if(l>e){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(;r>0;r--){let o=this.children[r-1];if(o.size||!(o instanceof yp||o instanceof gp&&o.side>=0))break}if(n<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&n&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?we(o.dom)+1:0}}else{let o,s=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,n):{node:this.contentDOM,offset:o?we(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(i==-1&&e<=c){let u=s+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=s;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=we(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){o=we(f.dom);break}n+=f.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(!$(n)||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let o=Math.min(e,n),s=Math.max(e,n);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],y=p+m.size;if(o>p&&s<y)return m.setSelection(e-p-m.border,n-p-m.border,r,i);p=y}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),f=!1;if((Xe||ve)&&e==n){let{node:h,offset:p}=l;if(pe(h)){if(f=!!(p&&h.nodeValue[p-1]==`
|
|
45
|
-
`),f&&p==h.nodeValue.length)for(let m=h,y;m;m=m.parentNode){if(y=m.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:we(y)+1});break}let g=m.pmViewDesc;if(g&&g.node&&g.node.isBlock)break}}else{let m=h.childNodes[p-1];f=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Xe&&u.focusNode&&u.focusNode!=a.node&&$(u.focusNode)){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||f&&ve)&&er(l.node,l.offset,u.anchorNode,u.anchorOffset)&&er(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==n)&&!(f&&Xe)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>n){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let o=this.children[i],s=r+o.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let l=r+o.border,a=s-o.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?vn:wf,e==l&&n==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=yt:o.markDirty(e-l,n-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?vn:yt}r=s}this.dirty=vn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?vn:wf;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class gp extends ko{constructor(e,n,r,i){let o,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){let l=$(s)?s:document.createElement("span");l!=s&&(l.appendChild(s),s=l),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==lt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class jx extends ko{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class xn extends ko{constructor(e,n,r,i,o){super(e,[],r,i),this.mark=n,this.spec=o}static create(e,n,r,i){let o=i.nodeViews[n.type.name],s=o&&o(n,i,r);return(!s||!s.dom)&&(s=or.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new xn(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&yt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=yt&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=lt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=lt}}slice(e,n,r){let i=xn.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;n<s&&(o=ca(o,n,s,r)),e>0&&(o=ca(o,0,e,r));for(let l=0;l<o.length;l++)o[l].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class wn extends ko{constructor(e,n,r,i,o,s,l){super(e,[],o,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,o,s){let l=o.nodeViews[n.type.name],a,c=l&&l(n,o,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,f=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!pe(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=or.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let d=u;return u=xp(u,r,n),c?a=new Hx(e,n,r,i,u,f||null,d,c):n.isText?new Ps(e,n,r,i,u,d):new wn(e,n,r,i,u,f||null,d)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let i=this.children[r];if(this.dom.contains(i.dom.parentNode)){n.contentElement=i.dom.parentNode;break}}if(!n.contentElement){let r=e&&e.find(i=>$(i)&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));r?n.contentElement=r:n.getContent=()=>I.empty}}return n}matchesNode(e,n,r){return this.dirty==lt&&e.eq(this.node)&&fs(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,o=e.composing?this.localCompositionInfo(e,n):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new Wx(this,s&&s.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;Ux(this.node,this.innerDeco,(f,d,h)=>{f.spec.marks?a.syncToMarks(f.spec.marks,r,e,d):f.type.side>=0&&!h&&a.syncToMarks(d==this.node.childCount?re.none:this.node.child(d).marks,r,e,d),a.placeWidget(f,e,i)},(f,d,h,p)=>{a.syncToMarks(f.marks,r,e,p),u&&f.isAtom&&!f.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(f,d,h,p)||l&&e.state.selection.from>i&&e.state.selection.to<i+f.nodeSize&&(m=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(f,d,h,m,e)||a.updateNextNode(f,d,h,e,p,i)||a.addNode(f,d,h,e,i),i+=f.nodeSize,c&&(u=f.isAtom&&!f.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==vn)&&(s&&this.protectLocalComposition(e,s),kp(this.contentDOM,this.children,e),Ur&&Gx(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof G)||r<n||i>n+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=Yx(this.node.content,s,r-n,i-n);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new jx(this,o,n,i);e.input.compositionNodes.push(s),this.children=ca(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==yt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=lt}updateOuterDeco(e){if(fs(e,this.outerDeco))return;let n=!$(this.nodeDOM),r=this.dom;this.dom=bp(this.dom,this.nodeDOM,aa(this.outerDeco,this.node,n),aa(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){$(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){$(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Cf(t,e,n,r,i){xp(r,e,t);let o=new wn(void 0,t,e,n,r,r,r);return o.contentDOM&&o.updateChildren(i,0),o}class Ps extends wn{constructor(e,n,r,i,o,s){super(e,n,r,i,o,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==yt||this.dirty!=lt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=lt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=lt,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),o=document.createTextNode(i.text);return new Ps(this.parent,i,this.outerDeco,this.innerDeco,o,o)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=yt)}get domAtom(){return!1}isText(e){return this.node.text==e}}class yp extends ko{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==lt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Hx extends wn{constructor(e,n,r,i,o,s,l,a){super(e,n,r,i,o,s,l),this.spec=a}update(e,n,r,i){if(this.dirty==yt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function kp(t,e,n){let r=t.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],l=s.dom;if(l.parentNode==t){for(;l!=r;)r=Sf(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(s instanceof xn){let a=r?r.previousSibling:t.lastChild;kp(s.contentDOM,s.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Sf(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Si=function(t){t&&(this.nodeName=t)};Si.prototype=Object.create(null);const On=[new Si];function aa(t,e,n){if(t.length==0)return On;let r=n?On[0]:new Si,i=[r];for(let o=0;o<t.length;o++){let s=t[o].type.attrs;if(s){s.nodeName&&i.push(r=new Si(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&i.length==1&&i.push(r=new Si(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return i}function bp(t,e,n,r){if(n==On&&r==On)return e;let i=e;for(let o=0;o<r.length;o++){let s=r[o],l=n[o];if(o){let a;l&&l.nodeName==s.nodeName&&i!=t&&(a=i.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=On[0]),i=a}qx(i,l||On[0],s)}return i}function qx(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)i.indexOf(r[o])==-1&&t.classList.remove(r[o]);for(let o=0;o<i.length;o++)r.indexOf(i[o])==-1&&t.classList.add(i[o]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function xp(t,e,n){return bp(t,t,On,aa(e,n,!$(t)))}function fs(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Sf(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Wx{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Kx(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,i){let o=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;o<l&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=lt,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let f=this.top.children[u];if(f.matchesMark(e[s])&&!this.isLocked(f.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof xn&&u.dirty!=yt&&u.mark.type==e[s].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[s])&&(u.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=xn.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,n,r,i,o){let s=this.top.children[i];return s.dirty==yt&&s.dom==s.contentDOM&&(s.dirty=vn),s.update(e,n,r,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,o,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof wn){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let u=a.dom,f,d=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=yt&&fs(n,a.outerDeco));if(!d&&a.update(e,n,r,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(f=this.recreateWrapper(a,e,n,r,i,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=vn,f.updateChildren(i,s+1),f.dirty=lt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,o,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!fs(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=wn.create(this.top,n,r,i,o,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,i,o){let s=wn.create(this.top,e,n,r,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new gp(this.top,e,n,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof xn;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Ps)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ve||Se)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new yp(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||$(e)&&e.contains(this.lock.parentNode))}}function Kx(t,e){let n=e,r=n.children.length,i=t.childCount,o=new Map,s=[];e:for(;i>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof xn)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function Jx(t,e){return t.type.side-e.type.side}function Ux(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,i,e.forChild(o,u),c),o+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,f;for(;s<i.length&&i[s].to==o;){let y=i[s++];y.widget&&(u?(f||(f=[u])).push(y):u=y)}if(u)if(f){f.sort(Jx);for(let y=0;y<f.length;y++)n(f[y],c,!!a)}else n(u,c,!!a);let d,h;if(a)h=-1,d=a,a=null;else if(c<t.childCount)h=c,d=t.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=o&&l.splice(y--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)l.push(i[s++]);let p=o+d.nodeSize;if(d.isText){let y=p;s<i.length&&i[s].from<y&&(y=i[s].from);for(let g=0;g<l.length;g++)l[g].to<y&&(y=l[g].to);y<p&&(a=d.cut(y-o),d=d.cut(0,y-o),p=y,h=-1)}else for(;s<i.length&&i[s].to<p;)s++;let m=d.isInline&&!d.isLeaf?l.filter(y=>!y.inline):l.slice();r(d,m,e.forChild(o,d),h),o=p}}function Gx(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function Yx(t,e,n,r){for(let i=0,o=0;i<t.childCount&&o<=r;){let s=t.child(i++),l=o;if(o+=s.nodeSize,!s.isText)continue;let a=s.text;for(;i<t.childCount;){let c=t.child(i++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=n){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function ca(t,e,n,r,i){let o=[];for(let s=0,l=0;s<t.length;s++){let a=t[s],c=l,u=l+=a.size;c>=n||u<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,r)),i&&(o.push(i),i=void 0),u>n&&o.push(a.slice(n-c,a.size,r)))}return o}function Ka(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),o=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Rs(n)){for(a=s;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&W.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&Cx(n.focusNode,n.focusOffset,i.dom))){let f=i.posBefore;c=new W(s==f?l:r.resolve(f))}else if(Xe&&e=="key"&&s>t.state.selection.to&&$(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&i&&i.posAtStart>t.state.selection.to)for(let f=n.focusNode;;f=f.parentNode){if(getComputedStyle(f).overflow!="visible"){c=q.findFrom(r.resolve(i.posAtStart),1);break}if(f==i.dom||f.nextSibling||!f.parentNode||!$(f.parentNode))break}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,d=s;for(let h=0;h<n.rangeCount;h++){let p=n.getRangeAt(h);f=Math.min(f,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,s]=d==t.state.selection.anchor?[d,f]:[f,d],l=r.resolve(s)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||t.state.selection.head<l.pos&&!o?1:-1;c=Ja(t,u,l,f)}return c}function wp(t){return t.editable?t.hasFocus():Sp(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Qt(t,e=!1){let n=t.state.selection;if(Cp(t,n),!wp(t))return;let r=t.input.mouseDown;if(!e&&Se&&r){let i=t.domSelectionRange(),o=t.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&er(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Xx(t);else{let{anchor:i,head:o}=n,s,l;Mf&&!(n instanceof G)&&(n.$from.parent.inlineContent||(s=Nf(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Nf(t,n.to))),t.docView.setSelection(i,o,t,e),Mf&&(s&&Tf(s),l&&Tf(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Qx(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}const Mf=ve||Se&&ap<63;function Nf(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(ve&&i&&i.contentEditable=="false")return ml(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return ml(i);if(o)return ml(o)}}function ml(t){return t.contentEditable="true",ve&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Tf(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Qx(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!wp(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Xx(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,we(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&je&&bn<=11&&(n.disabled=!0,n.disabled=!1)}function Cp(t,e){if(e instanceof W){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(If(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else If(t)}function If(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ja(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||G.between(e,n,r)}function Af(t){return t.editable&&!t.hasFocus()?!1:Sp(t)}function Sp(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return tr(t.dom,e.anchorNode)&&(t.editable||tr(t.dom,e.focusNode))}catch{return!1}}function Zx(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return er(e.node,e.offset,n.anchorNode,n.anchorOffset)}function ua(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return o&&q.findFrom(o,e)}function cn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Ef(t,e,n){let r=t.state.selection;if(r instanceof G)if(n.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=t.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return cn(t,new G(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=ua(t.state,e);return i&&i instanceof W?cn(t,i):!1}else if(!it||n.indexOf("m")<0){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?W.isSelectable(o)?cn(t,new W(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):cn(t,new G(t.state.doc.resolve(e<0?l:l+o.nodeSize))):!1}}else return!1;else{if(r instanceof W&&r.node.isInline)return cn(t,new G(e>0?r.$to:r.$from));{let i=ua(t.state,e);return i?cn(t,i):!1}}}function Mi(t,e){let n=t.pmViewDesc;return n?n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR"):$(t)&&t.contentEditable=="false"}function dr(t,e){return e<0?ew(t):tw(t)}function ew(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,s=!1;for(Xe&&$(n)&&r<Ae(n)&&Mi(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!$(n))break;let l=n.childNodes[r-1];if(Mi(l,-1))i=n,o=--r;else if(pe(l))n=l,r=n.nodeValue.length;else break}else{if(Mp(n))break;{let l=n.previousSibling;for(;l&&Mi(l,-1);)i=n.parentNode,o=we(l),l=l.previousSibling;if(l)n=l,r=Ae(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?fa(t,n,r):i&&fa(t,i,o)}function tw(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=Ae(n),o,s;for(;;)if(r<i){if(!$(n))break;let l=n.childNodes[r];if(Mi(l,1))o=n,s=++r;else break}else{if(Mp(n))break;{let l=n.nextSibling;for(;l&&Mi(l,1);)o=l.parentNode,s=we(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=Ae(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}o&&fa(t,o,s)}function Mp(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function nw(t,e){for(;t&&e==t.childNodes.length&&!yo(t);)e=we(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(pe(n))return n;if($(n)&&n.contentEditable=="false")break;t=n,e=0}}function rw(t,e){for(;t&&!e&&!yo(t);)e=we(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(pe(n))return n;if($(n)&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function fa(t,e,n){if(!pe(e)){let s,l;(l=nw(e,n))?(e=l,n=0):(s=rw(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection(),i=t.domSelectionRange();if(!r)return;Rs(i)?r.collapse(e,n):r.extend&&(r.collapse(i.anchorNode,i.anchorOffset),r.extend(e,n)),t.domObserver.setCurSelection();let{state:o}=t;setTimeout(()=>{t.state==o&&Qt(t)},50)}function vf(t,e){let n=t.state.doc.resolve(e);if(!(Se||cp)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),l=(s.top+s.bottom)/2;if(l>o.top&&l<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<n.end()){let s=t.coordsAtPos(e+1),l=(s.top+s.bottom)/2;if(l>o.top&&l<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}let r=t.dom;for(let o=n.depth;o>0;o--)if(n.node(o).isBlock){r=t.nodeDOM(n.before(o))||r;break}return getComputedStyle(r).direction=="rtl"?"rtl":"ltr"}function Of(t,e,n){let r=t.state.selection;if(r instanceof G&&!r.empty||n.indexOf("s")>-1||it&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=ua(t.state,e);if(s&&s instanceof W)return cn(t,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof Qe?q.near(s,e):q.findFrom(s,e);return l?cn(t,l):!1}return!1}function Df(t,e){if(!(t.state.selection instanceof G))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let s=t.state.tr;return e<0?s.delete(n.pos-o.nodeSize,n.pos):s.delete(n.pos,n.pos+o.nodeSize),t.dispatch(s),!0}return!1}function Rf(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function iw(t){if(!ve||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&$(e)&&n==0&&e.firstChild&&$(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Rf(t,r,"true"),setTimeout(()=>Rf(t,r,"false"),20)}return!1}function ow(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function sw(t,e){let n=e.keyCode,r=ow(e);if(n==8||it&&n==72&&r=="c")return Df(t,-1)||dr(t,-1);if(n==46&&!e.shiftKey||it&&n==68&&r=="c")return Df(t,1)||dr(t,1);if(n==13||n==27)return!0;if(n==37||it&&n==66&&r=="c"){let i=n==37?vf(t,t.state.selection.from)=="ltr"?-1:1:-1;return Ef(t,i,r)||dr(t,i)}else if(n==39||it&&n==70&&r=="c"){let i=n==39?vf(t,t.state.selection.from)=="ltr"?1:-1:1;return Ef(t,i,r)||dr(t,i)}else{if(n==38||it&&n==80&&r=="c")return Of(t,-1,r)||dr(t,-1);if(n==40||it&&n==78&&r=="c")return iw(t)||Of(t,1,r)||dr(t,1);if(r==(it?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Ua(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=t.someProp("clipboardSerializer")||or.fromSchema(t.state.schema),l=vp(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&$(c)&&(u=Ep[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),f++}c=a.firstChild}c&&$(c)&&c.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(n)}`);let d=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
|
|
46
|
-
|
|
47
|
-
`);return{dom:a,text:d,slice:e}}function Np(t,e,n,r,i){let o=i.parent.type.spec.code,s,l;if(!n&&!e)return null;let a=!!e&&(r||o||!n);if(a){if(t.someProp("transformPastedText",d=>{e=d(e,o||r,t)}),o)return l=new z(I.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
48
|
-
`))),0,0),t.someProp("transformPasted",d=>{l=d(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",d=>d(e,i,r,t));if(f)l=f;else{let d=i.marks(),{schema:h}=t.state,p=or.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let y=s.appendChild(document.createElement("p"));m&&y.appendChild(p.serializeNode(h.text(m,d)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=uw(n),zs&&fw(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=s.firstChild;for(;d&&!$(d);)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Xn.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!lw.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=hw(zf(l,+u[1],+u[2]),u[4]);else if(l=z.maxOpen(aw(l.content,i),!0),l.openStart||l.openEnd){let f=0,d=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;d<l.openEnd&&!h.type.spec.isolating;d++,h=h.lastChild);l=zf(l,f,d)}return t.someProp("transformPasted",f=>{l=f(l,t,a)}),l}const lw=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function aw(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),o,s=[];if(t.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&Ip(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Ap(s[s.length-1],o.length));let u=Tp(l,a);s.push(u),i=i.matchType(u.type),o=a}}),s)return I.from(s)}return t}function Tp(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,I.from(t));return t}function Ip(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let o=Ip(t,e,n,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(I.from(Tp(n,t,i+1))))}}function Ap(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ap(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(I.empty,!0);return t.copy(n.append(r))}function ha(t,e,n,r,i,o){let s=e<0?t.firstChild:t.lastChild,l=s.content;return t.childCount>1&&(o=0),i<r-1&&(l=ha(l,e,n,r,i+1,o)),i>=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(I.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function zf(t,e,n){return e<t.openStart&&(t=new z(ha(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new z(ha(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Ep={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function vp(){return document.implementation.createHTMLDocument("title")}let hi=null;function cw(t){let e=window.trustedTypes;if(!e)return t;if(!hi){if(hi=e.defaultPolicy)try{return hi.createHTML(t)}catch{}hi=e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return hi.createHTML(t)}function uw(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=vp(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(t),o;if((o=i&&Ep[i[1].toLowerCase()])&&(t=o.map(s=>"<"+s+">").join("")+t+o.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=cw(t),o)for(let s=0;s<o.length;s++)r=r.querySelector(o[s])||r;for(let s=0;s<n.styleSheets.length;s++){let l=n.styleSheets[s];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let f=0;f<u.length;f++)u[f].style.cssText+=c.style.cssText}}}return r}function fw(t){let e=t.querySelectorAll(Se?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function hw(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:o,openEnd:s}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{i=I.from(a.create(r[l+1],i))}catch{break}o++,s++}return new z(i,o,s)}const Pe={},Be={},dw={touchstart:!0,touchmove:!0};class pw{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function mw(t){for(let e in Pe){let n=Pe[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{yw(t,r)&&!Ga(t,r)&&(t.editable||!(r.type in Be))&&n(t,r)},dw[e]?{passive:!0}:void 0)}ve&&t.dom.addEventListener("input",()=>null),da(t)}function Gt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function gw(t){t.input.mouseDown&&t.input.mouseDown.done(),t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function da(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Ga(t,r))})}function Ga(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function yw(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function kw(t,e){!Ga(t,e)&&Pe[e.type]&&(t.editable||!(e.type in Be))&&Pe[e.type](t,e)}function fn(t,e){let{input:n}=t;return n.lastKeyDispatched||t.composing?!1:(n.lastKeyDispatched=!0,typeof e=="string"&&(e=Sx(e=="Backspace"?8:13,e)),t.someProp("handleKeyDown",r=>r(t,e)))}Be.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!zp(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),t.input.lastKeyDispatched=!1,!(Ut&&Se&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Ur&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(fn(t,"Enter"),t.input.lastIOSEnter=0)},200)}else fn(t,n)||sw(t,n)?n.preventDefault():Gt(t,"key")};Be.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Be.keypress=(t,e)=>{let n=e;if(zp(t)||!n.charCode||n.ctrlKey&&!n.altKey||it&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof G)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),o=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i,o))&&t.dispatch(o()),n.preventDefault()}};function bo(t){return{left:t.clientX,top:t.clientY}}function bw(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Ya(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(t.someProp(e,l=>s>o.depth?l(t,n,o.nodeAfter,o.before(s),i,!0):l(t,n,o.node(s),o.before(s),i,!1)))return!0;return!1}function xo(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function xw(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&W.isSelectable(r)?(xo(t,new W(n)),!0):!1}function ww(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof W&&(r=n.node);let o=t.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(W.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(s);break}}return i!=null?(xo(t,W.create(t.state.doc,i)),!0):!1}function Cw(t,e,n,r,i){return Ya(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?ww(t,n):xw(t,n))}function Sw(t,e,n,r){return Ya(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function Mw(t,e,n,r){return Ya(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||Nw(t,n,r)}function Nw(t,e,n){if(n.button!=0)return!1;let r=Op(t,e,!0),i=t.state.doc;return r?(xo(t,r),r instanceof G&&i.eq(t.state.doc)&&(t.input.mouseDown=new Iw(t,r)),!0):!1}function Op(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?G.create(r,0,r.content.size):null;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)return G.create(r,l+1,l+1+s.content.size);if(n&&W.isSelectable(s))return W.create(r,l)}return null}function Qa(t){return hs(t)}const Dp=it?"metaKey":"ctrlKey";Pe.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Qa(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&bw(n,t.input.lastClick)&&!n[Dp]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let s=t.posAtCoords(bo(n));s&&(o=="singleClick"?t.input.mouseDown=new Tw(t,s,n,!!r):(o=="doubleClick"?Sw:Mw)(t,s.pos,s.inside,n)?n.preventDefault():Gt(t,"pointer"))};class Rp{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class Tw extends Rp{constructor(e,n,r,i){super(e),this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[Dp],this.allowDefault=r.shiftKey;let o,s;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);o=u.parent,s=u.depth?u.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&$(a.nodeDOM)?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof W&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Xe&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),Gt(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||Qt(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(bo(e))),this.updateAllowDefault(e),this.allowDefault||!n?Gt(this.view,"pointer"):Cw(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ve&&this.mightDrag&&!this.mightDrag.node.isAtom||Se&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(xo(this.view,q.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Gt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Gt(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class Iw extends Rp{constructor(e,n){super(e),this.startSelection=n,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Gt(this.view,"pointer");let n=this.view.posAtCoords(bo(e)),r=n&&Op(this.view,n.inside,!1);if(!r)return;let{doc:i}=this.view.state,o=this.startSelection,[s,l]=r.from<o.from?[o.to,r.from]:[o.from,r.to];xo(this.view,G.create(i,s,l))}}Pe.touchstart=t=>{t.input.lastTouch=Date.now(),Qa(t),Gt(t,"pointer")};Pe.touchmove=t=>{t.input.lastTouch=Date.now(),Gt(t,"pointer")};Pe.contextmenu=t=>Qa(t);function zp(t,e){return t.composing?!0:ve&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Aw=Ut?5e3:-1;Be.compositionstart=Be.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof G&&e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Se&&cp&&Ew(t)))t.markCursor=t.state.storedMarks||n.marks(),hs(t,!0),t.markCursor=null;else if(hs(t,!e.selection.empty),Xe&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&$(i)&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(pe(s)){let l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}t.input.composing=!0}Pp(t,Aw)};function Ew(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||!$(e)||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return $(r)&&r.contentEditable=="false"}Be.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Pp(t,20))};function Pp(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>hs(t),e))}function Bp(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function vw(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=xx(e.focusNode,e.focusOffset),r=wx(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function hs(t,e=!1){if(!(Ut&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Bp(t),e||t.docView&&t.docView.dirty){let n=Ka(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Ow(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Fi=je&&bn<15||Ur&&Tx<604;Pe.copy=Be.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=Fi?null:n.clipboardData,s=r.content(),{dom:l,text:a}=Ua(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Ow(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Dw(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Rw(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?_i(t,r.value,null,i,e):_i(t,r.textContent,r.innerHTML,i,e)},50)}function _i(t,e,n,r,i){let o=Np(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,i,o||z.empty)))return!0;if(!o)return!1;let s=Dw(o),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(o);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Lp(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Be.paste=(t,e)=>{let n=e;if(t.composing&&!Ut)return;let r=Fi?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&_i(t,Lp(r),r.getData("text/html"),i,n)?n.preventDefault():Rw(t,n)};class Fp{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const zw=it?"altKey":"ctrlKey";function _p(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[zw]}Pe.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,o=i.empty?null:t.posAtCoords(bo(n)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof W?i.to-1:i.to))){if(r&&r.mightDrag)s=W.create(t.state.doc,r.mightDrag.pos);else if(n.target&&$(n.target)){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(s=W.create(t.state.doc,f.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:c,slice:u}=Ua(t,l);(!n.dataTransfer.files.length||!Se||ap>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Fi?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Fi||n.dataTransfer.setData("text/plain",c),t.dragging=new Fp(u,_p(t,n),s)};Pe.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Be.dragover=Be.dragenter=(t,e)=>e.preventDefault();Be.drop=(t,e)=>{try{Pw(t,e,t.dragging)}finally{t.dragging=null}};function Pw(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(bo(e));if(!r)return;let i=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",h=>{o=h(o,t,!1)}):o=Np(t,Lp(e.dataTransfer),Fi?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&_p(t,e));if(t.someProp("handleDrop",h=>h(t,e,o||z.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?y0(t.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let a=t.state.tr;if(s){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=a.doc;if(u?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(f))return;let d=a.doc.resolve(c);if(u&&W.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new W(d));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,y,g)=>h=g),a.setSelection(Ja(t,d,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Pe.focus=t=>{if(t.input.lastFocus=Date.now(),!t.focused){t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0;let e=t.domSelectionRange();if(!t.domObserver.currentSelection.eq(e)){let{focusNode:n,focusOffset:r}=e;setTimeout(()=>{let i=t.domSelectionRange();i.focusNode==n&&i.focusOffset==r&&t.docView&&t.hasFocus()&&Qt(t)},20)}}};Pe.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Pe.beforeinput=(t,e)=>{if(Ut&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||t.domObserver.pendingRecords().length||(t.dom.blur(),t.focus(),fn(t,"Backspace")))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in Be)Pe[t]=Be[t];function $i(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class pa{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let n=this.frag.child(this.index);if(this.off==e)return n;this.off+=n.nodeSize,this.index++}return null}}class ds{constructor(e,n){this.toDOM=e,this.spec=n||jn,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new Me(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ds&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&$i(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Cn{constructor(e,n){this.attrs=e,this.spec=n||jn}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new Me(o,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Cn&&$i(this.attrs,e.attrs)&&$i(this.spec,e.spec)}static is(e){return e.type instanceof Cn}destroy(){}}class Xa{constructor(e,n){this.attrs=e,this.spec=n||jn}map(e,n,r,i){let o=e.mapResult(n.from+i,1);if(o.deleted)return null;let s=e.mapResult(n.to+i,-1);return s.deleted||s.pos<=o.pos?null:new Me(o.pos-r,s.pos-r,this)}valid(e,n,r){let i=r.nodeAt(n.from);return!!i&&!i.isText&&n.from+i.nodeSize==n.to}eq(e){return this==e||e instanceof Xa&&$i(this.attrs,e.attrs)&&$i(this.spec,e.spec)}destroy(){}}class Me{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Me(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Me(e,e,new ds(n,r))}static inline(e,n,r,i){return new Me(e,n,new Cn(r,i))}static node(e,n,r,i){return new Me(e,n,new Xa(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Cn}get widget(){return this.type instanceof ds}}const mr=[],jn={};class ue{constructor(e,n){this.local=e.length?e:mr,this.children=n.length?n:mr}static create(e,n){return n.length?ps(n,e,0,jn):Ie}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,o){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=n&&l.to>=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,i+l,o)}}map(e,n,r){return this==Ie||e.maps.length==0?this:this.mapInner(e,n,0,0,r||jn)}mapInner(e,n,r,i,o){let s;if(this.local.length){let l=new pa(n.content);for(let a=0;a<this.local.length;a++){let c=this.local[a].map(e,r,i);c&&c.type.valid(n,c,l)?(s||(s=[])).push(c):o.onRemove&&o.onRemove(this.local[a].spec)}}return this.children.length?Bw(this.children,s||[],e,n,r,i,o):s?new ue(s.sort(Hn),mr):Ie}add(e,n){return n.length?this==Ie?ue.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,o=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Vp(n,l,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<a;)o+=3;i[o]==a?i[o+2]=i[o+2].addInner(l,u,c+1):i.splice(o,0,a,a+l.nodeSize,ps(u,l,c+1,jn)),o+=3}});let s=$p(o?jp(n):n,-r);if(s.length){let l=new pa(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||s.splice(a--,1)}return new ue(s.length?this.local.concat(s).sort(Hn):this.local,i||this.children)}remove(e){return e.length==0||this==Ie?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let o=0;o<r.length;o+=3){let s,l=r[o]+n,a=r[o+1]+n;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(s,l+1);c!=Ie?r[o+2]=c:(r.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let l=0;l<i.length;l++)i[l].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new ue(i,r):Ie}forChild(e,n){if(this==Ie)return this;if(n.isLeaf)return ue.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>o&&a.type instanceof Cn){let c=Math.max(o,a.from)-o,u=Math.min(s,a.to)-o;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new ue(i.sort(Hn),mr);return r?new hn([l,r]):l}return r||Ie}eq(e){if(this==e)return!0;if(!(e instanceof ue)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Za(this.localsInner(e))}localsInner(e){if(this==Ie)return mr;if(e.inlineContent||!this.local.some(Cn.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Cn||n.push(this.local[r]);return n}forEachSet(e){e(this)}}ue.empty=new ue([],[]);ue.removeOverlap=Za;const Ie=ue.empty;class hn{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,jn));return hn.from(r)}forChild(e,n){if(n.isLeaf)return ue.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,n);o!=Ie&&(o instanceof hn?r=r.concat(o.members):r.push(o))}return hn.from(r)}eq(e){if(!(e instanceof hn)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!n)n=o;else{r&&(n=n.slice(),r=!1);for(let s=0;s<o.length;s++)n.push(o[s])}}return n?Za(r?n:n.sort(Hn)):mr}static from(e){switch(e.length){case 0:return Ie;case 1:return e[0];default:return new hn(e.every(n=>n instanceof ue)?e:e.reduce((n,r)=>n.concat(r instanceof ue?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function Bw(t,e,n,r,i,o,s){let l=t.slice();for(let c=0,u=o;c<n.maps.length;c++){let f=0;n.maps[c].forEach((d,h,p,m)=>{let y=m-p-(h-d);for(let g=0;g<l.length;g+=3){let C=l[g+1];if(C<0||d>C+u-f)continue;let w=l[g]+u-f;h>=w?l[g+1]=d<=w?-2:-1:d>=u&&y&&(l[g]+=y,l[g+1]+=y)}f+=y}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+o),f=u-i;if(f<0||f>=r.content.size){a=!0;continue}let d=n.map(t[c+1]+o,-1),h=d-i,{index:p,offset:m}=r.content.findIndex(f),y=r.maybeChild(p);if(y&&m==f&&m+y.nodeSize==h){let g=l[c+2].mapInner(n,y,u+1,t[c]+o+1,s);g!=Ie?(l[c]=f,l[c+1]=h,l[c+2]=g):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Lw(l,t,e,n,i,o,s),u=ps(c,r,0,s);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let h=u.children[f];for(;d<l.length&&l[d]<h;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new ue(e.sort(Hn),l)}function $p(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new Me(i.from+e,i.to+e,i.type))}return n}function Lw(t,e,n,r,i,o,s){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,i,c);f?n.push(f):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+o+1);return n}function Vp(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let o=0,s;o<t.length;o++)(s=t[o])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),t[o]=null);return i}function jp(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function ps(t,e,n,r){let i=[],o=!1;e.forEach((l,a)=>{let c=Vp(t,l,a+n);if(c){o=!0;let u=ps(c,l,n+a+1,r);u!=Ie&&i.push(a,a+l.nodeSize,u)}});let s=$p(o?jp(t):t,-n).sort(Hn);if(s.length){let l=new pa(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1))}return s.length||i.length?new ue(s,i):Ie}function Hn(t,e){return t.from-e.from||t.to-e.to}function Za(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let o=e[i];if(o.from==r.from){o.to!=r.to&&(e==t&&(e=t.slice()),e[i]=o.copy(o.from,r.to),Pf(e,i+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,o.from),Pf(e,i,r.copy(o.from,r.to)));break}}}return e}function Pf(t,e,n){for(;e<t.length&&Hn(n,t[e])>0;)e++;t.splice(e,0,n)}function gl(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Ie&&e.push(r)}),t.cursorWrapper&&e.push(ue.create(t.state.doc,[t.cursorWrapper.deco])),hn.from(e)}const Fw={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},_w=je&&bn<=11;class $w{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Vw{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new $w,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);je&&bn<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():ve&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),_w&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Fw)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Af(this.view)){if(this.suppressingSelectionUpdates)return Qt(this.view);if(je&&bn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&er(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let o=e.focusNode;o;o=Jr(o))n.add(o);for(let o=e.anchorNode;o;o=Jr(o))if(n.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:pe(r)?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r,i=!1;!this.suppressingSelectionUpdates&&Af(e)&&(r=e.domSelectionRange(),i=!this.currentSelection.eq(r)&&!this.ignoreSelectionChange(r));let o=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let f=this.registerMutation(n[u],a);f&&(o=o<0?f.from:Math.min(f.from,o),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Se&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&n.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let f=u.nextSibling;for(;f&&$(f);){if(f.contentEditable=="false"){u.parentNode.removeChild(u);break}f=f.firstChild}}}else if(Xe&&a.length){let u=a.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let h=d.parentNode;h&&h.nodeName=="LI"&&(!f||qw(e,f)!=h)&&d.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Rs(r)&&(c=Ka(e))&&c.eq(q.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Qt(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),jw(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Ww(e,a)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):r&&!this.currentSelection.eq(r)&&Qt(e),r&&this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];n.push(f),pe(f)&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,o=e.nextSibling;if(je&&bn<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:d}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(o=d)}let s=i&&i.parentNode==e.target?we(i)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=o&&o.parentNode==e.target?we(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Bf=new WeakMap,Lf=!1;function jw(t){if(!Bf.has(t)&&(Bf.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Xe,Lf)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Lf=!0}}function Ff(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return er(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function Hw(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Ff(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Ff(t,n):null}function qw(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function Ww(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let o of e)if(((n=o.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!$(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(o,l.firstChild),r==o&&t.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function Kw(t,e,n,r){let{node:i,fromOffset:o,toOffset:s,from:l,to:a}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,f=c.anchorNode;if(f&&tr(t.dom,f)&&(u=[{node:f,offset:c.anchorOffset}],Rs(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Se&&t.input.lastKeyCode===8)for(let g=s;g>o;g--){let C=i.childNodes[g-1],w=C.pmViewDesc;if(C.nodeName=="BR"&&!w){s=g;break}if(!w||w.size)break}let d=t.state.doc,h=t.someProp("domParser")||Xn.fromSchema(t.state.schema),p=d.resolve(l),m=null,y=h.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Jw(r),context:p});if(u&&u[0].pos!=null){let g=u[0].pos,C=u[1]&&u[1].pos;C==null&&(C=g),m={anchor:g+l,head:C+l}}return{doc:y,sel:m,from:l,to:a}}const Jw=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(ve&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||ve&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},Uw=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Gw(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let D=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,F=Ka(t,D);if(F&&!t.state.selection.eq(F)){if(Se&&Ut&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&fn(t,"Enter"))return;let Z=t.state.tr.setSelection(F);D=="pointer"?Z.setMeta("pointer",!0):D=="key"&&Z.scrollIntoView(),o&&Z.setMeta("composition",o),t.dispatch(Z)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=Kw(t,e,n,i),u=t.state.doc,f=u.slice(c.from,c.to),d,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(d=t.state.selection.to,h="end"):(d=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let p=Zw(f.content,c.doc.content,c.from,d,h);if(p&&t.input.domChangeCount++,(Ur&&t.input.lastIOSEnter>Date.now()-225||Ut)&&i.some(D=>$(D)&&!Uw.test(D.nodeName))&&(!p||p.endA>=p.endB)&&fn(t,"Enter")){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof G&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let D=_f(t,t.state.doc,c.sel);if(D&&!D.eq(t.state.selection)){let F=t.state.tr.setSelection(D);o&&F.setMeta("composition",o),t.dispatch(F)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof G&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),je&&bn<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),g=u.resolve(p.start),C=m.sameParent(y)&&m.parent.inlineContent&&g.end()>=p.endA;if((Ur&&t.input.lastIOSEnter>Date.now()-225&&(!C||i.some(D=>D.nodeName=="DIV"||D.nodeName=="P"))||!C&&Xw(c.doc,m.pos,y.pos))&&fn(t,"Enter")){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&(C?p.endA>p.start&&p.endB==p.start:Qw(u,p.start,p.endA,m,y))&&fn(t,"Backspace")){Ut&&Se&&t.domObserver.suppressSelectionUpdates();return}Se&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Ut&&!C&&m.start()!=y.start()&&y.parentOffset==0&&m.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>fn(t,"Enter"),20));let w=p.start,E=p.endA,P=D=>{let F=D||t.state.tr.replace(w,E,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let Z=_f(t,F.doc,c.sel);Z&&!(Se&&t.composing&&Z.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(Z.head==w||Z.head==F.mapping.map(E)-1)||je&&Z.empty&&Z.head==w)&&F.setSelection(Z)}return o&&F.setMeta("composition",o),F.scrollIntoView()},S;if(C)if(m.pos==y.pos){je&&bn<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Qt(t),20));let D=P(t.state.tr.delete(w,E)),F=u.resolve(p.start).marksAcross(u.resolve(p.endA));F&&D.ensureMarks(F),t.dispatch(D)}else if(p.endA==p.endB&&(S=Yw(m.parent.content.cut(m.parentOffset,y.parentOffset),g.parent.content.cut(g.parentOffset,p.endA-g.start())))){let D=P(t.state.tr);S.type=="add"?D.addMark(w,E,S.mark):D.removeMark(w,E,S.mark),t.dispatch(D)}else if(m.parent.child(m.index()).isText&&m.index()==y.index()-(y.textOffset?0:1)){let D=m.parent.textBetween(m.parentOffset,y.parentOffset),F=()=>P(t.state.tr.insertText(D,w,E));t.someProp("handleTextInput",Z=>Z(t,w,E,D,F))||t.dispatch(F())}else t.dispatch(P());else t.dispatch(P())}function _f(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ja(t,e.resolve(n.anchor),e.resolve(n.head))}function Yw(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,s,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<n.length;u++)o=n[u].removeFromSet(o);if(i.length==1&&o.length==0)l=i[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(I.from(c).eq(t))return{mark:l,type:s}}function Qw(t,e,n,r,i){if(n-e<=i.pos-r.pos||yl(r,!0,!1)<i.pos)return!1;let o=t.resolve(e);if(!r.parent.inlineContent){let l=o.nodeAfter;return l!=null&&n==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=t.resolve(yl(o,!0,!0));return!s.parent.isTextblock||s.pos>n||yl(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Xw(t,e,n){let r=0,i=0;return t.nodesBetween(e,n,(o,s)=>{o.isTextblock&&s>=e&&s<n?r++:(o.isText?/\S/.test(o.text.slice(Math.max(0,e-s),Math.min(o.nodeSize,n-s))):o.isLeaf)&&i++}),i==0&&r==1}function yl(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Zw(t,e,n,r,i){let o=t.findDiffStart(e,n),s=n+t.size,l=n+e.size;if(o==null)return null;let{a,b:c}=t.findDiffEnd(e,s,l);if(i=="end"){let u=Math.max(0,o-Math.min(a,c));r-=a+u-o}if(a<o&&s<l){let u=r<=o&&r>=a?o-r:0;o-=u,c=o+(c-a),a=o}else if(c<o){let u=r<=o&&r>=c?o-r:0;o-=u,a=o+(a-c),c=o}return{start:o,endA:a,endB:c}}class Hp{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new pw,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(qf),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=jf(this),Vf(this),this.nodeViews=Hf(this),this.docView=Cf(this.state.doc,$f(this),gl(this),this.dom,this),this.domObserver=new Vw(this,(r,i,o,s)=>Gw(this,r,i,o,s)),this.domObserver.start(),mw(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&da(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(qf),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(Bp(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Hf(this);tC(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&da(this),this.editable=jf(this),Vf(this);let a=gl(this),c=$f(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,c,a);(f||!e.selection.eq(i.selection))&&(s=!0);let d=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Ex(this);if(s){this.domObserver.stop();let h=f&&(je||Se)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&eC(i.selection,e.selection);if(f){let m=Se?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=vw(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Cf(e.doc,c,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let p=this.input.mouseDown;h||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Zx(this)&&p.delaySelUpdate())?Qt(this,h):(Cp(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&vx(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!tr(this.dom,e))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof W){let n=this.docView.domAfterPos(this.state.selection.from);$(n)&&yf(this,n.getBoundingClientRect(),e)}else yf(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let o=r.from+(this.state.doc.content.size-n.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new Fp(e.slice,e.move,i<0?void 0:W.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(i=n?n(l):l))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let l=o[s].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(je){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Ox(this.dom),Qt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Bx(this,e)}coordsAtPos(e,n=1){return pp(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return Vx(this,n||this.state,e)}pasteHTML(e,n){return _i(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return _i(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ua(this,e)}destroy(){this.docView&&(gw(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],gl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,kx())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return kw(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?ve&&this.root.nodeType===11&&Mx(this.dom.ownerDocument)==this.dom&&Hw(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Hp.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function $f(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Me.node(0,t.state.doc.content.size,e)]}function Vf(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Me.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function jf(t){return!t.someProp("editable",e=>e(t.state)===!1)}function eC(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Hf(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function tC(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function qf(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}function tn(t,e){return t.meta={package:"@milkdown/core",group:"System",...e},t}var qp={text:(t,e,n,r)=>{const i=t.value;return/^[^*_\\]*\s+$/.test(i)?i:n.safe(i,{...r,encode:[]})},strong:(t,e,n,r)=>{const i=t.marker||n.options.strong||"*",o=n.enter("strong"),s=n.createTracker(r);let l=s.move(i+i);return l+=s.move(n.containerPhrasing(t,{before:l,after:i,...s.current()})),l+=s.move(i+i),o(),l},emphasis:(t,e,n,r)=>{const i=t.marker||n.options.emphasis||"*",o=n.enter("emphasis"),s=n.createTracker(r);let l=s.move(i);return l+=s.move(n.containerPhrasing(t,{before:l,after:i,...s.current()})),l+=s.move(i),o(),l}},Xt=te({},"editorView"),gi=te({},"editorState"),kl=te([],"initTimer"),Wf=te({},"editor"),Vi=te([],"inputRules"),nr=te([],"prosePlugins"),ji=te([],"remarkPlugins"),Hi=te([],"nodeView"),qi=te([],"markView"),qn=te(Gl().use(Hl).use(Kl),"remark"),Cr=te({handlers:qp,encode:[]},"remarkStringifyOptions"),Wo=vt("ConfigReady");function nC(t){const e=n=>(n.record(Wo),async()=>(await t(n),n.done(Wo),()=>{n.clearTimer(Wo)}));return tn(e,{displayName:"Config"}),e}var Sr=vt("InitReady");function rC(t){const e=n=>(n.inject(Wf,t).inject(nr,[]).inject(ji,[]).inject(Vi,[]).inject(Hi,[]).inject(qi,[]).inject(Cr,{handlers:qp,encode:[]}).inject(qn,Gl().use(Hl).use(Kl)).inject(kl,[Wo]).record(Sr),async()=>{await n.waitTimers(kl);const r=n.get(Cr);return n.set(qn,Gl().use(Hl).use(Kl,r)),n.done(Sr),()=>{n.remove(Wf).remove(nr).remove(ji).remove(Vi).remove(Hi).remove(qi).remove(Cr).remove(qn).remove(kl).clearTimer(Sr)}});return tn(e,{displayName:"Init"}),e}var ze=vt("SchemaReady"),bl=te([],"schemaTimer"),Zt=te({},"schema"),Ni=te([],"nodes"),Ti=te([],"marks");function Kf(t){var e;return{...t,parseDOM:(e=t.parseDOM)==null?void 0:e.map(n=>({priority:t.priority,...n}))}}var Wp=t=>(t.inject(Zt,{}).inject(Ni,[]).inject(Ti,[]).inject(bl,[Sr]).record(ze),async()=>{await t.waitTimers(bl);const e=t.get(qn),n=t.get(ji).reduce((s,l)=>s.use(l.plugin,l.options),e);t.set(qn,n);const r=Object.fromEntries(t.get(Ni).map(([s,l])=>[s,Kf(l)])),i=Object.fromEntries(t.get(Ti).map(([s,l])=>[s,Kf(l)])),o=new K1({nodes:r,marks:i});return t.set(Zt,o),t.done(ze),()=>{t.remove(Zt).remove(Ni).remove(Ti).remove(bl).clearTimer(ze)}});tn(Wp,{displayName:"Schema"});var zn,rt,Sh,Kp=(Sh=class{constructor(){B(this,zn);B(this,rt);v(this,zn,new Th),v(this,rt,null),this.setCtx=t=>{v(this,rt,t)},this.chain=()=>{if(x(this,rt)==null)throw Js();const t=x(this,rt),e=[],n=this.get.bind(this),r={run:()=>{const o=Zr(...e),s=t.get(Xt);return o(s.state,s.dispatch,s)},inline:o=>(e.push(o),r),pipe:i.bind(this)};function i(o,s){const l=n(o);return e.push(l(s)),r}return r}}get ctx(){return x(this,rt)}create(t,e){const n=t.create(x(this,zn).sliceMap);return n.set(e),n}get(t){return x(this,zn).get(t).get()}remove(t){return x(this,zn).remove(t)}call(t,e){if(x(this,rt)==null)throw Js();const n=this.get(t)(e),r=x(this,rt).get(Xt);return n(r.state,r.dispatch,r)}inline(t){if(x(this,rt)==null)throw Js();const e=x(this,rt).get(Xt);return t(e.state,e.dispatch,e)}},zn=new WeakMap,rt=new WeakMap,Sh);function iC(t="cmdKey"){return te((()=>()=>!1),t)}var ee=te(new Kp,"commands"),xl=te([ze],"commandsTimer"),Ii=vt("CommandsReady"),Jp=t=>{const e=new Kp;return e.setCtx(t),t.inject(ee,e).inject(xl,[ze]).record(Ii),async()=>(await t.waitTimers(xl),t.done(Ii),()=>{t.remove(ee).remove(xl).clearTimer(Ii)})};tn(Jp,{displayName:"Commands"});function oC(t){return t.Backspace=Zr(K0,_a,I0,Jd),t}var Pn,$e,Mh,Up=(Mh=class{constructor(){B(this,Pn);B(this,$e);v(this,Pn,null),v(this,$e,[]),this.setCtx=t=>{v(this,Pn,t)},this.add=t=>(x(this,$e).push(t),()=>{v(this,$e,x(this,$e).filter(e=>e!==t))}),this.addObjectKeymap=t=>{const e=[];return Object.entries(t).forEach(([n,r])=>{if(typeof r=="function"){const i={key:n,onRun:()=>r};x(this,$e).push(i),e.push(()=>{v(this,$e,x(this,$e).filter(o=>o!==i))})}else x(this,$e).push(r),e.push(()=>{v(this,$e,x(this,$e).filter(i=>i!==r))})}),()=>{e.forEach(n=>n())}},this.addBaseKeymap=()=>{const t=oC(q0);return this.addObjectKeymap(t)},this.build=()=>{const t={};return x(this,$e).forEach(e=>{t[e.key]=[...t[e.key]||[],e]}),Object.fromEntries(Object.entries(t).map(([e,n])=>{const r=n.sort((o,s)=>(s.priority??50)-(o.priority??50));return[e,(o,s,l)=>{const a=x(this,Pn);if(a==null)throw ws();const c=r.map(u=>u.onRun(a));return Zr(...c)(o,s,l)}]}))}}get ctx(){return x(this,Pn)}},Pn=new WeakMap,$e=new WeakMap,Mh),ms=te(new Up,"keymap"),wl=te([ze],"keymapTimer"),Ai=vt("KeymapReady"),sC=t=>{const e=new Up;return e.setCtx(t),t.inject(ms,e).inject(wl,[ze]).record(Ai),async()=>(await t.waitTimers(wl),t.done(Ai),()=>{t.remove(ms).remove(wl).clearTimer(Ai)})},Ko=vt("ParserReady"),Gp=(()=>{throw ws()}),Ei=te(Gp,"parser"),Cl=te([],"parserTimer"),Yp=t=>(t.inject(Ei,Gp).inject(Cl,[ze]).record(Ko),async()=>{await t.waitTimers(Cl);const e=t.get(qn),n=t.get(Zt);return t.set(Ei,mx.create(n,e)),t.done(Ko),()=>{t.remove(Ei).remove(Cl).clearTimer(Ko)}});tn(Yp,{displayName:"Parser"});var Jo=vt("SerializerReady"),Sl=te([],"serializerTimer"),Qp=(()=>{throw ws()}),vi=te(Qp,"serializer"),Xp=t=>(t.inject(vi,Qp).inject(Sl,[ze]).record(Jo),async()=>{await t.waitTimers(Sl);const e=t.get(qn),n=t.get(Zt);return t.set(vi,yx.create(n,e)),t.done(Jo),()=>{t.remove(vi).remove(Sl).clearTimer(Jo)}});tn(Xp,{displayName:"Serializer"});var Uo=te("","defaultValue"),Ml=te(t=>t,"stateOptions"),Nl=te([],"editorStateTimer"),Go=vt("EditorStateReady");function lC(t,e,n){if(typeof t=="string")return e(t);if(t.type==="html")return Xn.fromSchema(n).parse(t.dom);if(t.type==="json")return st.fromJSON(n,t.value);throw qg(t)}var aC=new Te("MILKDOWN_STATE_TRACKER"),Zp=t=>(t.inject(Uo,"").inject(gi,{}).inject(Ml,e=>e).inject(Nl,[Ko,Jo,Ii,Ai]).record(Go),async()=>{await t.waitTimers(Nl);const e=t.get(Zt),n=t.get(Ei),r=t.get(Vi),i=t.get(Ml),o=t.get(nr),s=lC(t.get(Uo),n,e),l=t.get(ms),a=l.addBaseKeymap(),c=[...o,new Ne({key:aC,state:{init:()=>{},apply:(d,h,p,m)=>{t.set(gi,m)}}}),ex({rules:r}),np(l.build())];t.set(nr,c);const u=i({schema:e,doc:s,plugins:c}),f=br.create(u);return t.set(gi,f),t.done(Go),()=>{a(),t.remove(Uo).remove(gi).remove(Ml).remove(Nl).clearTimer(Go)}});tn(Zp,{displayName:"EditorState"});var Wi=te([],"pasteRule"),Tl=te([ze],"pasteRuleTimer"),Yo=vt("PasteRuleReady"),em=t=>(t.inject(Wi,[]).inject(Tl,[ze]).record(Yo),async()=>(await t.waitTimers(Tl),t.done(Yo),()=>{t.remove(Wi).remove(Tl).clearTimer(Yo)}));tn(em,{displayName:"PasteRule"});var Il=vt("EditorViewReady"),Al=te([],"editorViewTimer"),Oi=te({},"editorViewOptions"),Qo=te(null,"root"),ma=te(null,"rootDOM"),ga=te({},"rootAttrs");function cC(t,e){const n=document.createElement("div");n.className="milkdown",t.appendChild(n),e.set(ma,n);const r=e.get(ga);return Object.entries(r).forEach(([i,o])=>n.setAttribute(i,o)),n}function uC(t){t.classList.add("editor"),t.setAttribute("role","textbox")}var fC=new Te("MILKDOWN_VIEW_CLEAR"),tm=t=>(t.inject(Qo,document.body).inject(Xt,{}).inject(Oi,{}).inject(ma,null).inject(ga,{}).inject(Al,[Go,Yo]).record(Il),async()=>{await t.wait(Sr);const e=t.get(Qo)||document.body,n=typeof e=="string"?document.querySelector(e):e;t.update(nr,a=>[new Ne({key:fC,view:c=>{const u=n?cC(n,t):void 0;return(()=>{if(u&&n){const d=c.dom;n.replaceChild(u,d),u.appendChild(d)}})(),{destroy:()=>{u!=null&&u.parentNode&&(u==null||u.parentNode.replaceChild(c.dom,u)),u==null||u.remove()}}}}),...a]),await t.waitTimers(Al);const r=t.get(gi),i=t.get(Oi),o=Object.fromEntries(t.get(Hi)),s=Object.fromEntries(t.get(qi)),l=new Hp(n,{state:r,nodeViews:o,markViews:s,transformPasted:(a,c,u)=>(t.get(Wi).sort((f,d)=>(d.priority??50)-(f.priority??50)).map(f=>f.run).forEach(f=>{a=f(a,c,u)}),a),...i});return uC(l.dom),t.set(Xt,l),t.done(Il),()=>{l==null||l.destroy(),t.remove(Qo).remove(Xt).remove(Oi).remove(ma).remove(ga).remove(Al).clearTimer(Il)}});tn(tm,{displayName:"EditorView"});var Bn,Ue,Wt,$r,lo,ao,Ve,Kt,Ln,co,Fn,Vr,uo,yn,jr,Hr,hC=(Hr=class{constructor(){B(this,Bn);B(this,Ue);B(this,Wt);B(this,$r);B(this,lo);B(this,ao);B(this,Ve);B(this,Kt);B(this,Ln);B(this,co);B(this,Fn);B(this,Vr);B(this,uo);B(this,yn);B(this,jr);v(this,Bn,!1),v(this,Ue,"Idle"),v(this,Wt,[]),v(this,$r,()=>{}),v(this,lo,new Th),v(this,ao,new ry),v(this,Ve,new Map),v(this,Kt,new Map),v(this,Ln,new ny(x(this,lo),x(this,ao))),v(this,co,()=>{const e=nC(async r=>{await Promise.all(x(this,Wt).map(i=>Promise.resolve(i(r))))}),n=[Wp,Yp,Xp,Jp,sC,em,Zp,tm,rC(this),e];x(this,Fn).call(this,n,x(this,Kt))}),v(this,Fn,(e,n)=>{e.forEach(r=>{const i=x(this,Ln).produce(x(this,Bn)?r.meta:void 0),o=r(i);n.set(r,{ctx:i,handler:o,cleanup:void 0})})}),v(this,Vr,(e,n=!1)=>Promise.all([e].flat().map(async r=>{var o;const i=(o=x(this,Ve).get(r))==null?void 0:o.cleanup;return n?x(this,Ve).delete(r):x(this,Ve).set(r,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof i=="function"?i():i}))),v(this,uo,async()=>{await Promise.all([...x(this,Kt).entries()].map(async([e,{cleanup:n}])=>typeof n=="function"?n():n)),x(this,Kt).clear()}),v(this,yn,e=>{v(this,Ue,e),x(this,$r).call(this,e)}),v(this,jr,e=>[...e.entries()].map(async([n,r])=>{const{ctx:i,handler:o}=r;if(!o)return;const s=await o();e.set(n,{ctx:i,handler:o,cleanup:s})})),this.enableInspector=(e=!0)=>(v(this,Bn,e),this),this.onStatusChange=e=>(v(this,$r,e),this),this.config=e=>(x(this,Wt).push(e),this),this.removeConfig=e=>(v(this,Wt,x(this,Wt).filter(n=>n!==e)),this),this.use=e=>{const n=[e].flat();return n.flat().forEach(r=>{x(this,Ve).set(r,{ctx:void 0,handler:void 0,cleanup:void 0})}),x(this,Ue)==="Created"&&x(this,Fn).call(this,n,x(this,Ve)),this},this.remove=async e=>x(this,Ue)==="OnCreate"?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(n=>{setTimeout(()=>{n(this.remove(e))},50)})):(await x(this,Vr).call(this,[e].flat(),!0),this),this.create=async()=>x(this,Ue)==="OnCreate"?this:(x(this,Ue)==="Created"&&await this.destroy(),x(this,yn).call(this,"OnCreate"),x(this,co).call(this),x(this,Fn).call(this,[...x(this,Ve).keys()],x(this,Ve)),await Promise.all([x(this,jr).call(this,x(this,Kt)),x(this,jr).call(this,x(this,Ve))].flat()),x(this,yn).call(this,"Created"),this),this.destroy=async(e=!1)=>x(this,Ue)==="Destroyed"||x(this,Ue)==="OnDestroy"?this:x(this,Ue)==="OnCreate"?new Promise(n=>{setTimeout(()=>{n(this.destroy(e))},50)}):(e&&v(this,Wt,[]),x(this,yn).call(this,"OnDestroy"),await x(this,Vr).call(this,[...x(this,Ve).keys()],e),await x(this,uo).call(this),x(this,yn).call(this,"Destroyed"),this),this.action=e=>e(x(this,Ln)),this.inspect=()=>x(this,Bn)?[...x(this,Kt).values(),...x(this,Ve).values()].map(({ctx:e})=>{var n;return(n=e==null?void 0:e.inspector)==null?void 0:n.read()}).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new Hr}get ctx(){return x(this,Ln)}get status(){return x(this,Ue)}},Bn=new WeakMap,Ue=new WeakMap,Wt=new WeakMap,$r=new WeakMap,lo=new WeakMap,ao=new WeakMap,Ve=new WeakMap,Kt=new WeakMap,Ln=new WeakMap,co=new WeakMap,Fn=new WeakMap,Vr=new WeakMap,uo=new WeakMap,yn=new WeakMap,jr=new WeakMap,Hr);function nm(t,e,n){const r=t.findIndex(([o])=>o===e);if(r===-1)return[...t,n];const i=t.slice();return i[r]=n,i}function K(t,e){const n=iC(t),r=i=>async()=>{r.key=n,await i.wait(Ii);const o=e(i);return i.get(ee).create(n,o),r.run=s=>i.get(ee).call(t,s),()=>{i.get(ee).remove(n)}};return r}function qe(t){const e=n=>async()=>{await n.wait(ze);const r=t(n);return n.update(Vi,i=>[...i,r]),e.inputRule=r,()=>{n.update(Vi,i=>i.filter(o=>o!==r))}};return e}function dC(t){const e=n=>async()=>{await n.wait(ze);const r=t(n);return n.update(Wi,i=>[...i,r]),e.pasteRule=r,()=>{n.update(Wi,i=>i.filter(o=>o!==r))}};return e}function pC(t,e){const n=r=>async()=>{const i=e(r);return r.update(Ti,o=>nm(o,t,[t,i])),n.id=t,n.schema=i,()=>{r.update(Ti,o=>o.filter(([s])=>s!==t))}};return n.type=r=>{const i=r.get(Zt).marks[t];if(!i)throw Xg(t);return i},n}function ec(t,e){const n=r=>async()=>{const i=e(r);return r.update(Ni,o=>nm(o,t,[t,i])),n.id=t,n.schema=i,()=>{r.update(Ni,o=>o.filter(([s])=>s!==t))}};return n.type=r=>{const i=r.get(Zt).nodes[t];if(!i)throw Qg(t);return i},n}function He(t){let e;const n=r=>async()=>(await r.wait(ze),e=t(r),r.update(nr,i=>[...i,e]),()=>{r.update(nr,i=>i.filter(o=>o!==e))});return n.plugin=()=>e,n.key=()=>e.spec.key,n}function mC(t){const e=n=>async()=>{await n.wait(Ai);const r=n.get(ms),i=t(n),o=r.addObjectKeymap(i);return e.keymap=i,()=>{o()}};return e}function Jf(t,e){const n=r=>async()=>{await r.wait(ze);const i=e(r);return t.type(r)instanceof Qn?r.update(Hi,o=>[...o,[t.id,i]]):r.update(qi,o=>[...o,[t.id,i]]),n.view=i,n.type=t,()=>{t.type(r)instanceof Qn?r.update(Hi,o=>o.filter(s=>s[0]!==t.id)):r.update(qi,o=>o.filter(s=>s[0]!==t.id))}};return n}function Ot(t,e){const n=te(t,e),r=i=>(i.inject(n),()=>()=>{i.remove(n)});return r.key=n,r}function ge(t,e){const n=Ot(e,t),r=ec(t,o=>o.get(n.key)(o)),i=[n,r];return i.id=r.id,i.node=r,i.type=o=>r.type(o),i.ctx=n,i.key=n.key,i.extendSchema=o=>ge(t,o(e)),i}function ei(t,e){const n=Ot(e,t),r=pC(t,o=>o.get(n.key)(o)),i=[n,r];return i.id=r.id,i.mark=r,i.type=o=>r.type(o),i.ctx=n,i.key=n.key,i.extendSchema=o=>ei(t,o(e)),i}function We(t,e){const n=Ot(Object.fromEntries(Object.entries(e).map(([o,{shortcuts:s,priority:l}])=>[o,{shortcuts:s,priority:l}])),`${t}Keymap`),r=mC(o=>{const s=o.get(n.key),l=Object.entries(e).flatMap(([a,{command:c}])=>{const u=s[a],f=[u.shortcuts].flat(),d=u.priority;return f.map(h=>[h,{key:h,onRun:c,priority:d}])});return Object.fromEntries(l)}),i=[n,r];return i.ctx=n,i.shortcuts=r,i.key=n.key,i.keymap=r.keymap,i}var kt=(t,e=()=>({}))=>Ot(e,`${t}Attr`),wo=(t,e=()=>({}))=>Ot(e,`${t}Attr`);function sr(t,e,n){const r=Ot({},t),i=s=>async()=>{await s.wait(Sr);const l={plugin:e(s),options:s.get(r.key)};return s.update(ji,a=>[...a,l]),()=>{s.update(ji,a=>a.filter(c=>c!==l))}},o=[r,i];return o.id=t,o.plugin=i,o.options=r,o}function Gr(t,e){return t instanceof Qn?e==t:t.indexOf(e)>-1}function gC(t,e){return function(n,r){let{$from:i,$to:o,node:s}=n.selection;if(s&&s.isBlock||i.depth<2||!i.sameParent(o))return!1;let l=i.node(-1);if(!Gr(t,l.type))return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||!Gr(t,i.node(-3).type)||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let f=I.empty,d=i.index(-1)?1:i.index(-2)?2:3;for(let g=i.depth-d;g>=i.depth-3;g--)f=I.from(i.node(g).copy(f));let h=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;f=f.append(I.from(i.node(-3).type.createAndFill()));let p=i.before(i.depth-(d-1)),m=n.tr.replace(p,i.after(-h),new z(f,4-d,0)),y=-1;m.doc.nodesBetween(p,m.doc.content.size,(g,C)=>{if(y>-1)return!1;g.isTextblock&&g.content.size==0&&(y=C+1)}),y>-1&&m.setSelection(q.near(m.doc.resolve(y))),r(m.scrollIntoView())}return!0}let a=o.pos==i.end()?l.contentMatchAt(0).defaultType:null,c=n.tr.delete(i.pos,o.pos),u=a?[null,{type:a}]:void 0;return Ci(c.doc,i.pos,2,u)?(r&&r(c.split(i.pos,2,u).scrollIntoView()),!0):!1}}function tc(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,s=>s.childCount>0&&Gr(t,s.firstChild.type));return o?n?Gr(t,r.node(o.depth-1).type)?yC(e,n,o):kC(e,n,o):!0:!1}}function yC(t,e,n){let r=t.tr,i=n.end,o=n.$to.end(n.depth),s=n.parent.child(n.endIndex-1).type;i<o&&(r.step(new Ee(i-1,o,i,o,new z(I.from(s.create(null,n.parent.copy())),1,0),1,!0)),n=new xd(r.doc.resolve(n.$from.pos),r.doc.resolve(o),n.depth));const l=As(n);if(l==null)return!1;r.lift(n,l);let a=r.doc.resolve(r.mapping.map(i,-1)-1);return Es(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function kC(t,e,n){let r=t.tr,i=n.parent;for(let h=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let o=r.doc.resolve(n.start),s=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==i.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?I.empty:I.from(i))))return!1;let f=o.pos,d=f+s.nodeSize;return r.step(new Ee(f-(l?1:0),d+(a?1:0),f+1,d-1,new z((l?I.empty:I.from(i.copy(I.empty))).append(a?I.empty:I.from(i.copy(I.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function bC(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&Gr(t,c.firstChild.type));if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let l=o.parent,a=l.child(s-1);if(!Gr(t,a.type))return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=I.from(c?a.lastChild.lastChild.type.create():null),f=new z(I.from(a.type.create(null,I.from(l.type.create(null,u)))),c?3:1,0),d=o.start,h=o.end;n(e.tr.step(new Ee(d-(c?3:1),h,d,h,f,1,!0)).scrollIntoView())}return!0}}function xC(t){const e=new Map;if(!t||!t.type)throw new Error("mdast-util-definitions expected node");return ir(t,"definition",function(r){const i=Uf(r.identifier);i&&!e.get(i)&&e.set(i,r)}),n;function n(r){const i=Uf(r);return e.get(i)}}function Uf(t){return String(t||"").toUpperCase()}function wC(){return function(t){const e=xC(t);ir(t,function(n,r,i){if(n.type==="definition"&&i!==void 0&&typeof r=="number")return i.children.splice(r,1),[qr,r];if(n.type==="imageReference"||n.type==="linkReference"){const o=e(n.identifier);if(o&&i&&typeof r=="number")return i.children[r]=n.type==="imageReference"?{type:"image",url:o.url,title:o.title,alt:n.alt}:{type:"link",url:o.url,title:o.title,children:n.children},[qr,r]}})}}function CC(t){const e={...t};return e.position&&(e.position={start:{...e.position.start},end:{...e.position.end}}),delete e.children,e}var SC="<br />",MC=/^<br\s*\/?\s*>$/i,NC=t=>typeof t=="string"&&MC.test(t.trim());function rm(t,e){var r;if(!(e.childCount>=1&&((r=e.lastChild)==null?void 0:r.type.name)==="hardbreak")){t.next(e.content);return}const n=[];e.content.forEach((i,o,s)=>{s!==e.childCount-1&&n.push(i)}),t.next(I.fromArray(n))}function T(t,e){return Object.assign(t,{meta:{package:"@milkdown/preset-commonmark",...e}}),t}var nc=wo("emphasis");T(nc,{displayName:"Attr<emphasis>",group:"Emphasis"});var lr=ei("emphasis",t=>({attrs:{marker:{default:t.get(Cr).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"}],toDOM:e=>["em",t.get(nc.key)(e)],parseMarkdown:{match:e=>e.type==="emphasis",runner:(e,n,r)=>{e.openMark(r,{marker:n.marker}),e.next(n.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="emphasis",runner:(e,n)=>{e.withMark(n,"emphasis",void 0,{marker:n.attrs.marker})}}}));T(lr.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"});T(lr.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var Bs=K("ToggleEmphasis",t=>()=>Ds(lr.type(t)));T(Bs,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var im=qe(t=>go(/(?:^|[^*])\*([^*]+)\*$/,lr.type(t),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:n})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:n+1}}));T(im,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var om=qe(t=>go(/\b_(?![_\s])(.*?[^_\s])_$/,lr.type(t),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:n})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:n+1}}));T(om,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var rc=We("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:t=>{const e=t.get(ee);return()=>e.call(Bs.key)}}});T(rc.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"});T(rc.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var ic=wo("strong");T(ic,{displayName:"Attr<strong>",group:"Strong"});var ti=ei("strong",t=>({attrs:{marker:{default:t.get(Cr).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>e.style.fontWeight!="normal"&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>e==="bold"},{style:"font-weight=400",clearMark:e=>e.type.name=="strong"},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:e=>["strong",t.get(ic.key)(e)],parseMarkdown:{match:e=>e.type==="strong",runner:(e,n,r)=>{e.openMark(r,{marker:n.marker}),e.next(n.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="strong",runner:(e,n)=>{e.withMark(n,"strong",void 0,{marker:n.attrs.marker})}}}));T(ti.mark,{displayName:"MarkSchema<strong>",group:"Strong"});T(ti.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var Ls=K("ToggleStrong",t=>()=>Ds(ti.type(t)));T(Ls,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var sm=qe(t=>go(new RegExp("(?<![\\w:/])(?:\\*\\*|__)([^*_]+?)(?:\\*\\*|__)(?![\\w/])$"),ti.type(t),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));T(sm,{displayName:"InputRule<strong>",group:"Strong"});var oc=We("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:t=>{const e=t.get(ee);return()=>e.call(Ls.key)}}});T(oc.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"});T(oc.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var sc=wo("inlineCode");T(sc,{displayName:"Attr<inlineCode>",group:"InlineCode"});var Yt=ei("inlineCode",t=>({priority:100,code:!0,inclusive:!1,parseDOM:[{tag:"code"}],toDOM:e=>["code",t.get(sc.key)(e)],parseMarkdown:{match:e=>e.type==="inlineCode",runner:(e,n,r)=>{e.openMark(r),e.addText(n.value),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="inlineCode",runner:(e,n,r)=>(e.withMark(n,"inlineCode",r.text||""),!0)}}));T(Yt.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"});T(Yt.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var Fs=K("ToggleInlineCode",t=>()=>(e,n)=>{const{selection:r,tr:i}=e;if(r.empty)return!1;const{from:o,to:s}=r;return e.doc.rangeHasMark(o,s,Yt.type(t))?(n==null||n(i.removeMark(o,s,Yt.type(t))),!0):(Object.keys(e.schema.marks).filter(l=>l!==Yt.type.name).map(l=>e.schema.marks[l]).forEach(l=>{i.removeMark(o,s,l)}),n==null||n(i.addMark(o,s,Yt.type(t).create())),!0)});T(Fs,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var lm=qe(t=>go(/(?:`)([^`]+)(?:`)$/,Yt.type(t)));T(lm,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var lc=We("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:t=>{const e=t.get(ee);return()=>e.call(Fs.key)}}});T(lc.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"});T(lc.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var TC=new Set(["http:","https:","mailto:","tel:","ftp:"]);function IC(t){return t<=32||t>=127&&t<=160||t>=8203&&t<=8205||t===8232||t===8233||t===65279}function AC(t){let e="";for(const n of t)IC(n.codePointAt(0)??0)||(e+=n);return e}function EC(t){var i;if(typeof t!="string")return"";const e=t.trim();if(!e)return"";const n=AC(e),r=(i=/^([a-z][a-z0-9+.-]*):/i.exec(n))==null?void 0:i[1];return!r||TC.has(`${r.toLowerCase()}:`)?e:""}var ac=wo("link");T(ac,{displayName:"Attr<link>",group:"Link"});var Mt=ei("link",t=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Et(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:e=>["a",{...t.get(ac.key)(e),...e.attrs,href:EC(e.attrs.href)}],parseMarkdown:{match:e=>e.type==="link",runner:(e,n,r)=>{const i=n.url,o=n.title;e.openMark(r,{href:i,title:o}),e.next(n.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="link",runner:(e,n)=>{e.withMark(n,"link",void 0,{title:n.attrs.title,url:n.attrs.href})}}}));T(Mt.mark,{displayName:"MarkSchema<link>",group:"Link"});var am=K("ToggleLink",t=>(e={})=>Ds(Mt.type(t),e));T(am,{displayName:"Command<toggleLinkCommand>",group:"Link"});var cm=K("UpdateLink",t=>(e={})=>(n,r)=>{if(!r)return!1;let i,o=-1;const{selection:s}=n,{from:l,to:a}=s;if(n.doc.nodesBetween(l,l===a?a+1:a,(p,m)=>{if(Mt.type(t).isInSet(p.marks))return i=p,o=m,!1}),!i)return!1;const c=i.marks.find(({type:p})=>p===Mt.type(t));if(!c)return!1;const u=o,f=o+i.nodeSize,{tr:d}=n,h=Mt.type(t).create({...c.attrs,...e});return h?(r(d.removeMark(u,f,c).addMark(u,f,h).setSelection(new G(d.selection.$anchor)).scrollIntoView()),!0):!1});T(cm,{displayName:"Command<updateLinkCommand>",group:"Link"});var um=ec("doc",()=>({content:"block+",parseMarkdown:{match:({type:t})=>t==="root",runner:(t,e,n)=>{t.injectRoot(e,n)}},toMarkdown:{match:t=>t.type.name==="doc",runner:(t,e)=>{t.openNode("root");const n=e.childCount>0?e.child(e.childCount-1):null,r=(n==null?void 0:n.type.name)==="paragraph"&&n.content.size===0?e.content.cut(0,e.content.size-n.nodeSize):e.content;t.next(r)}}}));T(um,{displayName:"NodeSchema<doc>",group:"Doc"});var fm=Object.freeze(["root","blockquote","listItem","footnoteDefinition"]),vC=new Set(["paragraph","heading","tableCell","link","linkReference","emphasis","strong","delete","footnote"]),gs=Ot(fm,"blockContainerTypes");T(gs,{displayName:"Ctx<blockContainerTypes>",group:"Remark"});var Gf=new Set;function hm(t){const e=t.isInjected(gs.key)?t.get(gs.key):fm,n=new Set;for(const r of e){if(vC.has(r)){Gf.has(r)||(Gf.add(r),console.warn(`[milkdown/preset-commonmark] "${r}" holds phrasing content and cannot be a block container; it is ignored in blockContainerTypes.`));continue}n.add(r)}return n}var OC=new Set(["paragraph","tableCell"]);function DC(t,e){return is(t,n=>n.type==="html"&&NC(n.value),(n,r)=>{const i=r[r.length-1];if(i){if(OC.has(i.type)){i.children.length===1&&(i.children=[]);return}if(e.has(i.type)){const o=n;return o.children=[],delete o.value,o.type="paragraph",qr}}})}var _s=sr("remark-preserve-empty-line",t=>()=>e=>DC(e,hm(t)));T(_s.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"});T(_s.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var cc=kt("paragraph");T(cc,{displayName:"Attr<paragraph>",group:"Paragraph"});var At=ge("paragraph",t=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:e=>["p",t.get(cc.key)(e),0],parseMarkdown:{match:e=>e.type==="paragraph",runner:(e,n,r)=>{e.openNode(r),n.children?e.next(n.children):e.addText(n.value||""),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="paragraph",runner:(e,n)=>{e.openNode("paragraph"),(!n.content||n.content.size===0)&&RC(t)?e.addNode("html",void 0,SC):rm(e,n),e.closeNode()}}}));function RC(t){return t.isInjected(_s.options.key)}T(At.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"});T(At.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var Yr=K("TurnIntoText",t=>()=>Li(At.type(t)));T(Yr,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var uc=We("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:t=>{const e=t.get(ee);return()=>e.call(Yr.key)}}});T(uc.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"});T(uc.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var zC=Array(6).fill(0).map((t,e)=>e+1);function PC(t){return t.textContent.toLowerCase().trim().replace(/\s+/g,"-")}var $s=Ot(PC,"headingIdGenerator");T($s,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var fc=kt("heading");T(fc,{displayName:"Attr<heading>",group:"Heading"});var Dt=ge("heading",t=>{const e=t.get($s.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:zC.map(n=>({tag:`h${n}`,getAttrs:r=>{if(!(r instanceof HTMLElement))throw Et(r);return{level:n,id:r.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...t.get(fc.key)(n),id:n.attrs.id||e(n)},0],parseMarkdown:{match:({type:n})=>n==="heading",runner:(n,r,i)=>{const o=r.depth;n.openNode(i,{level:o}),n.next(r.children),n.closeNode()}},toMarkdown:{match:n=>n.type.name==="heading",runner:(n,r)=>{n.openNode("heading",void 0,{depth:r.attrs.level}),rm(n,r),n.closeNode()}}}});T(Dt.node,{displayName:"NodeSchema<heading>",group:"Heading"});T(Dt.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var dm=qe(t=>Xd(/^(?<hashes>#+)\s$/,Dt.type(t),e=>{var o,s;const n=((s=(o=e.groups)==null?void 0:o.hashes)==null?void 0:s.length)||0,{$from:r}=t.get(Xt).state.selection,i=r.node();if(i.type.name==="heading"){let l=Number(i.attrs.level)+Number(n);return l>6&&(l=6),{level:l}}return{level:n}}));T(dm,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var Ct=K("WrapInHeading",t=>e=>(e??(e=1),e<1?Li(At.type(t)):Li(Dt.type(t),{level:e})));T(Ct,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var hc=K("DowngradeHeading",t=>()=>(e,n,r)=>{const{$from:i}=e.selection,o=i.node();if(o.type!==Dt.type(t)||!e.selection.empty||i.parentOffset!==0)return!1;const s=o.attrs.level-1;return s?(n==null||n(e.tr.setNodeMarkup(e.selection.$from.before(),void 0,{...o.attrs,level:s})),!0):Li(At.type(t))(e,n,r)});T(hc,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var dc=We("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:t=>{const e=t.get(ee);return()=>e.call(Ct.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:t=>{const e=t.get(ee);return()=>e.call(Ct.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:t=>{const e=t.get(ee);return()=>e.call(Ct.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:t=>{const e=t.get(ee);return()=>e.call(Ct.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:t=>{const e=t.get(ee);return()=>e.call(Ct.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:t=>{const e=t.get(ee);return()=>e.call(Ct.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:t=>{const e=t.get(ee);return()=>e.call(hc.key)}}});T(dc.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"});T(dc.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var pc=kt("blockquote");T(pc,{displayName:"Attr<blockquote>",group:"Blockquote"});var ni=ge("blockquote",t=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:e=>["blockquote",t.get(pc.key)(e),0],parseMarkdown:{match:({type:e})=>e==="blockquote",runner:(e,n,r)=>{e.openNode(r).next(n.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="blockquote",runner:(e,n)=>{e.openNode("blockquote").next(n.content).closeNode()}}}));T(ni.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"});T(ni.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var pm=qe(t=>Ha(/^\s*>\s$/,ni.type(t)));T(pm,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var Vs=K("WrapInBlockquote",t=>()=>ja(ni.type(t)));T(Vs,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var mc=We("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:t=>{const e=t.get(ee);return()=>e.call(Vs.key)}}});T(mc.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"});T(mc.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var gc=kt("codeBlock",()=>({pre:{},code:{}}));T(gc,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var ri=ge("code_block",t=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Et(e);return{language:e.dataset.language}}}],toDOM:e=>{const n=t.get(gc.key)(e),r=e.attrs.language,i=r&&r.length>0?{"data-language":r}:void 0;return["pre",{...n.pre,...i},["code",n.code,0]]},parseMarkdown:{match:({type:e})=>e==="code",runner:(e,n,r)=>{const i=n.lang??"",o=n.value;e.openNode(r,{language:i}),o&&e.addText(o),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="code_block",runner:(e,n)=>{var r;e.addNode("code",void 0,((r=n.content.firstChild)==null?void 0:r.text)||"",{lang:n.attrs.language})}}}));T(ri.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"});T(ri.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var mm=qe(t=>Xd(/^```(?<language>[a-z]*)?[\s\n]$/,ri.type(t),e=>{var n;return{language:((n=e.groups)==null?void 0:n.language)??""}}));T(mm,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var js=K("CreateCodeBlock",t=>(e="")=>Li(ri.type(t),{language:e}));T(js,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});var BC=K("UpdateCodeBlockLanguage",()=>({pos:t,language:e}={pos:-1,language:""})=>(n,r)=>t>=0?(r==null||r(n.tr.setNodeAttribute(t,"language",e)),!0):!1);T(BC,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var yc=We("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:t=>{const e=t.get(ee);return()=>e.call(js.key)}}});T(yc.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"});T(yc.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var kc=kt("image");T(kc,{displayName:"Attr<image>",group:"Image"});var Nt=ge("image",t=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Et(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:e=>["img",{...t.get(kc.key)(e),...e.attrs}],parseMarkdown:{match:({type:e})=>e==="image",runner:(e,n,r)=>{const i=n.url,o=n.alt??"",s=n.title??"";e.addNode(r,{src:i,alt:o,title:s})}},toMarkdown:{match:e=>e.type.name==="image",runner:(e,n)=>{e.addNode("image",void 0,void 0,{title:n.attrs.title,url:n.attrs.src,alt:n.attrs.alt})}}}));T(Nt.node,{displayName:"NodeSchema<image>",group:"Image"});T(Nt.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var gm=K("InsertImage",t=>(e={})=>(n,r)=>{if(!r)return!0;const{src:i="",alt:o="",title:s=""}=e,l=Nt.type(t).create({src:i,alt:o,title:s});return l&&r(n.tr.replaceSelectionWith(l).scrollIntoView()),!0});T(gm,{displayName:"Command<insertImageCommand>",group:"Image"});var ym=K("UpdateImage",t=>(e={})=>(n,r)=>{const i=ax(n.selection,Nt.type(t));if(!i)return!1;const{node:o,pos:s}=i,l={...o.attrs},{src:a,alt:c,title:u}=e;return a!==void 0&&(l.src=a),c!==void 0&&(l.alt=c),u!==void 0&&(l.title=u),r==null||r(n.tr.setNodeMarkup(s,void 0,l).scrollIntoView()),!0});T(ym,{displayName:"Command<updateImageCommand>",group:"Image"});var LC=qe(t=>new tt(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(e,n,r,i)=>{const[o,s,l="",a]=n;return o?e.tr.replaceWith(r,i,Nt.type(t).create({src:l,alt:s,title:a})):null}));T(LC,{displayName:"InputRule<insertImageInputRule>",group:"Image"});var ys=kt("hardbreak",t=>({"data-type":"hardbreak","data-is-inline":t.attrs.isInline}));T(ys,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var Co=ge("hardbreak",t=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:e=>e.attrs.isInline?["span",t.get(ys.key)(e)," "]:["br",t.get(ys.key)(e)],parseMarkdown:{match:({type:e})=>e==="break",runner:(e,n,r)=>{var i;e.addNode(r,{isInline:!!((i=n.data)!=null&&i.isInline)})}},leafText:()=>`
|
|
49
|
-
`,toMarkdown:{match:e=>e.type.name==="hardbreak",runner:(e,n)=>{n.attrs.isInline?e.addNode("text",void 0,`
|
|
50
|
-
`):e.addNode("break")}}}));T(Co.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"});T(Co.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var bc=K("InsertHardbreak",t=>()=>(e,n)=>{var o;const{selection:r,tr:i}=e;if(!(r instanceof G))return!1;if(r.empty){const s=r.$from.node();if(s.childCount>0&&((o=s.lastChild)==null?void 0:o.type.name)==="hardbreak")return n==null||n(i.replaceRangeWith(r.to-1,r.to,e.schema.node("paragraph")).setSelection(q.near(i.doc.resolve(r.to))).scrollIntoView()),!0}return n==null||n(i.setMeta("hardbreak",!0).replaceSelectionWith(Co.type(t).create(),!1).scrollIntoView()),!0});T(bc,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var xc=We("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:t=>{const e=t.get(ee);return()=>e.call(bc.key)}}});T(xc.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"});T(xc.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var wc=kt("hr");T(wc,{displayName:"Attr<hr>",group:"Hr"});var So=ge("hr",t=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:e=>["hr",t.get(wc.key)(e)],parseMarkdown:{match:({type:e})=>e==="thematicBreak",runner:(e,n,r)=>{e.addNode(r)}},toMarkdown:{match:e=>e.type.name==="hr",runner:e=>{e.addNode("thematicBreak")}}}));T(So.node,{displayName:"NodeSchema<hr>",group:"Hr"});T(So.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var km=qe(t=>new tt(/^(?:---|___\s|\*\*\*\s)$/,(e,n,r,i)=>{const{tr:o}=e;return n[0]&&o.replaceWith(r-1,i,So.type(t).create()),o}));T(km,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var bm=K("InsertHr",t=>()=>(e,n)=>{if(!n)return!0;const r=At.node.type(t).create(),{tr:i,selection:o}=e,{from:s}=o,l=So.type(t).create();if(!l)return!0;const a=i.replaceSelectionWith(l).insert(s,r),c=q.findFrom(a.doc.resolve(s),1,!0);return c&&n(a.setSelection(c).scrollIntoView()),!0});T(bm,{displayName:"Command<insertHrCommand>",group:"Hr"});var Cc=kt("bulletList");T(Cc,{displayName:"Attr<bulletList>",group:"BulletList"});var nn=ge("bullet_list",t=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Et(e);return{spread:e.dataset.spread==="true"}}}],toDOM:e=>["ul",{...t.get(Cc.key)(e),"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:n})=>e==="list"&&!n,runner:(e,n,r)=>{const i=n.spread??!1;e.openNode(r,{spread:i}).next(n.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="bullet_list",runner:(e,n)=>{e.openNode("list",void 0,{ordered:!1,spread:n.attrs.spread}).next(n.content).closeNode()}}}));T(nn.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"});T(nn.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var xm=qe(t=>Ha(/^\s*([-+*])\s$/,nn.type(t)));T(xm,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var Mo=K("WrapInBulletList",t=>()=>ja(nn.type(t)));T(Mo,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var Sc=We("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:t=>{const e=t.get(ee);return()=>e.call(Mo.key)}}});T(Sc.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"});T(Sc.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var Mc=kt("orderedList");T(Mc,{displayName:"Attr<orderedList>",group:"OrderedList"});var rn=ge("ordered_list",t=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Et(e);return{spread:e.dataset.spread==="true",order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:e=>["ol",{...t.get(Mc.key)(e),...e.attrs.order===1?{}:{start:e.attrs.order},"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:n})=>e==="list"&&!!n,runner:(e,n,r)=>{const i=n.spread??!0;e.openNode(r,{spread:i,order:n.start??1}).next(n.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="ordered_list",runner:(e,n)=>{e.openNode("list",void 0,{ordered:!0,start:n.attrs.order??1,spread:n.attrs.spread}),e.next(n.content),e.closeNode()}}}));T(rn.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"});T(rn.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var wm=qe(t=>Ha(/^\s*(\d+)\.\s$/,rn.type(t),e=>({order:Number(e[1])}),(e,n)=>n.childCount+n.attrs.order===Number(e[1])));T(wm,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var No=K("WrapInOrderedList",t=>()=>ja(rn.type(t)));T(No,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var Nc=We("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:t=>{const e=t.get(ee);return()=>e.call(No.key)}}});T(Nc.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"});T(Nc.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var Tc=kt("listItem");T(Tc,{displayName:"Attr<listItem>",group:"ListItem"});var at=ge("list_item",t=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"•",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Et(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread==="true"}}}],toDOM:e=>["li",{...t.get(Tc.key)(e),"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e})=>e==="listItem",runner:(e,n,r)=>{const i=n.label!=null?`${n.label}.`:"•",o=n.label!=null?"ordered":"bullet",s=n.spread??!0;e.openNode(r,{label:i,listType:o,spread:s}),e.next(n.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="list_item",runner:(e,n)=>{e.openNode("listItem",void 0,{spread:n.attrs.spread}),e.next(n.content),e.closeNode()}}}));T(at.node,{displayName:"NodeSchema<listItem>",group:"ListItem"});T(at.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var Ic=K("SinkListItem",t=>()=>bC(at.type(t)));T(Ic,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var Ac=K("LiftListItem",t=>()=>tc(at.type(t)));T(Ac,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var Ec=K("SplitListItem",t=>()=>(e,n,r)=>gC(at.type(t))(e,n&&(i=>{const{$from:o}=e.selection;if(o.parent.content.size===0&&o.node(-1).childCount===o.indexAfter(-1)){const{$from:s}=i.selection;i.setNodeMarkup(s.before(-1),void 0,o.node(-3).attrs)}n(i)}),r));T(Ec,{displayName:"Command<splitListItemCommand>",group:"ListItem"});function FC(t){return(e,n,r)=>{const{selection:i}=e;if(!(i instanceof G))return!1;const{empty:o,$from:s}=i;return!o||s.parentOffset!==0||s.node(-1).type!==at.type(t)?!1:Kd(e,n,r)}}var vc=K("LiftFirstListItem",t=>()=>FC(t));T(vc,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var Oc=We("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:t=>{const e=t.get(ee);return()=>e.call(Ec.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:t=>{const e=t.get(ee);return()=>e.call(Ic.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:t=>{const e=t.get(ee);return()=>e.call(Ac.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:t=>{const e=t.get(ee);return()=>e.call(vc.key)}}});T(Oc.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"});T(Oc.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var Cm=ec("text",()=>({group:"inline",parseMarkdown:{match:({type:t})=>t==="text",runner:(t,e)=>{t.addText(e.value)}},toMarkdown:{match:t=>t.type.name==="text",runner:(t,e)=>{t.addNode("text",void 0,e.text)}}}));T(Cm,{displayName:"NodeSchema<text>",group:"Text"});var Dc=kt("html");T(Dc,{displayName:"Attr<html>",group:"Html"});var Hs=ge("html",t=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:e=>{const n=document.createElement("span"),r={...t.get(Dc.key)(e),"data-value":e.attrs.value,"data-type":"html"};return n.textContent=e.attrs.value,["span",r,e.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>e==="html",runner:(e,n,r)=>{e.addNode(r,{value:n.value})}},toMarkdown:{match:e=>e.type.name==="html",runner:(e,n)=>{e.addNode("html",void 0,n.attrs.value)}}}));T(Hs.node,{displayName:"NodeSchema<html>",group:"Html"});T(Hs.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var _C=[um,cc,At,$s,fc,Dt,ys,Co,pc,ni,gc,ri,wc,So,kc,Nt,Cc,nn,Mc,rn,Tc,at,nc,lr,ic,ti,sc,Yt,ac,Mt,Dc,Hs,Cm].flat(),$C=[pm,xm,wm,mm,km,dm].flat(),VC=[im,om,lm,sm],jC=K("IsMarkSelected",()=>t=>e=>{if(!t)return!1;const{doc:n,selection:r}=e;return n.rangeHasMark(r.from,r.to,t)}),HC=K("IsNoteSelected",()=>t=>e=>t?cx(e,t).hasNode:!1),qC=K("ClearTextInCurrentBlock",()=>()=>(t,e)=>{let n=t.tr;const{$from:r,$to:i}=n.selection,{pos:o}=r,{pos:s}=i,l=o-r.node().content.size;return l<0?!1:(n=n.deleteRange(l,s),e==null||e(n),!0)}),WC=K("SetBlockType",()=>t=>(e,n)=>{const{nodeType:r,attrs:i=null}=t??{};if(!r)return!1;const o=e.tr,{from:s,to:l}=o.selection;try{o.setBlockType(s,l,r,i)}catch{return!1}return n==null||n(o),!0}),KC=K("WrapInBlockType",()=>t=>(e,n)=>{const{nodeType:r,attrs:i=null}=t??{};if(!r)return!1;let o=e.tr;try{const{$from:s,$to:l}=o.selection,a=s.blockRange(l),c=a&&La(a,r,i);if(!c)return!1;o=o.wrap(a,c)}catch{return!1}return n==null||n(o),!0}),JC=K("AddBlockType",()=>t=>(e,n)=>{const{nodeType:r,attrs:i=null}=t??{};if(!r)return!1;const o=e.tr;try{const s=r instanceof st?r:r.createAndFill(i);if(!s)return!1;o.replaceSelectionWith(s)}catch{return!1}return n==null||n(o),!0}),UC=K("SelectTextNearPos",()=>t=>(e,n)=>{const{pos:r}=t??{};if(r==null)return!1;const i=(s,l,a)=>Math.min(Math.max(s,l),a),o=e.tr;try{const s=e.doc.resolve(i(r,0,e.doc.content.size));o.setSelection(G.near(s))}catch{return!1}return n==null||n(o.scrollIntoView()),!0}),GC=[Yr,Vs,Ct,hc,js,bc,bm,gm,ym,No,Mo,Ic,Ec,Ac,vc,Bs,Fs,Ls,am,cm,jC,HC,qC,WC,KC,JC,UC],YC=[mc,yc,xc,dc,Oc,Nc,Sc,uc,rc,lc,oc].flat(),Rc=sr("remarkAddOrderInList",()=>()=>t=>{ir(t,"list",e=>{if(e.ordered){const n=e.start??1;e.children.forEach((r,i)=>{r.label=i+n})}})});T(Rc.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"});T(Rc.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var zc=sr("remarkLineBreak",()=>()=>t=>{const e=new RegExp("(?<![\\t ])[\\t ]*(?:\\r?\\n|\\r)","g");ir(t,"text",(n,r,i)=>{if(!n.value||typeof n.value!="string")return;const o=[];let s=0;e.lastIndex=0;let l=e.exec(n.value);for(;l;){const a=l.index;s!==a&&o.push({type:"text",value:n.value.slice(s,a)}),o.push({type:"break",data:{isInline:!0}}),s=a+l[0].length,l=e.exec(n.value)}if(o.length>0&&i&&typeof r=="number")return s<n.value.length&&o.push({type:"text",value:n.value.slice(s)}),i.children.splice(r,1,...o),r+o.length})});T(zc.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"});T(zc.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var Pc=sr("remarkInlineLink",()=>wC);T(Pc.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"});T(Pc.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var QC=t=>!!t.children,XC=t=>t.type==="html";function ZC(t,e){return n(t,0,null)[0];function n(r,i,o){if(QC(r)){const s=[];for(let l=0,a=r.children.length;l<a;l++){const c=r.children[l];if(c){const u=n(c,l,r);if(u)for(let f=0,d=u.length;f<d;f++){const h=u[f];h&&s.push(h)}}}r.children=s}return e(r,i,o)}}var Bc=sr("remarkHTMLTransformer",t=>()=>e=>{const n=hm(t);ZC(e,(r,i,o)=>XC(r)?(o&&n.has(o.type)&&(r.children=[CC(r)],delete r.value,r.type="paragraph"),[r]):[r])});T(Bc.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"});T(Bc.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var Lc=sr("remarkMarker",()=>()=>(t,e)=>{const n=r=>e.value.charAt(r.position.start.offset);ir(t,r=>["strong","emphasis"].includes(r.type),r=>{r.marker=n(r)})});T(Lc.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"});T(Lc.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var Sm=He(()=>{let t=!1;const e=new Te("MILKDOWN_INLINE_NODES_CURSOR"),n=new Ne({key:e,state:{init(){return!1},apply(r){if(!r.selection.empty)return!1;const i=r.selection.$from,o=i.nodeBefore,s=i.nodeAfter;return!!(o&&s&&o.isInline&&!o.isText&&s.isInline&&!s.isText)}},props:{handleDOMEvents:{compositionend:(r,i)=>t?(t=!1,requestAnimationFrame(()=>{if(n.getState(r.state)){const o=r.state.selection.from;i.preventDefault(),r.dispatch(r.state.tr.insertText(i.data||"",o))}}),!0):!1,compositionstart:r=>(n.getState(r.state)&&(t=!0),!1),beforeinput:(r,i)=>{if(n.getState(r.state)&&i instanceof InputEvent&&i.data&&!t){const o=r.state.selection.from;return i.preventDefault(),r.dispatch(r.state.tr.insertText(i.data||"",o)),!0}return!1}},decorations(r){if(n.getState(r)){const i=r.selection.$from.pos,o=document.createElement("span"),s=Me.widget(i,o,{side:-1}),l=document.createElement("span"),a=Me.widget(i,l);return setTimeout(()=>{o.contentEditable="true",l.contentEditable="true"}),ue.create(r.doc,[s,a])}return ue.empty}}});return n});T(Sm,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var Mm=He(t=>new Ne({key:new Te("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(e,n,r)=>{if(!e.length)return;const i=Co.type(t);let o;return e.forEach((s,l)=>{s.steps.forEach((a,c)=>{if(!(a instanceof St))return;const u=(h,p)=>e.slice(l).reduce((m,y,g)=>(g===0?y.mapping.slice(c+1):y.mapping).map(m,p),h),f=u(a.from,-1),d=u(a.to,1);r.doc.nodesBetween(f,d,(h,p)=>{h.type!==i||h.attrs.isInline||h.marks.length&&(o??(o=r.tr),o.setNodeMarkup(p,i,h.attrs,[]))})})}),o}}));T(Mm,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var Fc=Ot(["table","code_block"],"hardbreakFilterNodes");T(Fc,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var Nm=He(t=>{const e=t.get(Fc.key);return new Ne({key:new Te("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(n,r)=>{const i=n.getMeta("hardbreak"),[o]=n.steps;if(i&&o instanceof de){const s=r.doc.resolve(o.from);let l=s.depth,a=!0;for(;l>0;)e.includes(s.node(l).type.name)&&(a=!1),l--;return a}return!0}})});T(Nm,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var Tm=He(t=>{const e=new Te("MILKDOWN_HEADING_ID"),n=r=>{if(r.composing)return;const i=t.get($s.key),o=r.state.tr.setMeta("addToHistory",!1);let s=!1;const l={};r.state.doc.descendants((a,c)=>{if(a.type===Dt.type(t)){if(a.textContent.trim().length===0)return;const u=a.attrs;let f=i(a);l[f]?(l[f]+=1,f+=`-#${l[f]}`):l[f]=1,u.id!==f&&(s=!0,o.setMeta(e,!0).setNodeMarkup(c,void 0,{...u,id:f}))}}),s&&r.dispatch(o)};return new Ne({key:e,view:r=>(n(r),{update:(i,o)=>{i.state.doc.eq(o.doc)||n(i)}})})});T(Tm,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var Im=He(t=>{const e=(n,r,i)=>{if(!i.selection||n.some(f=>f.getMeta("addToHistory")===!1||!f.isGeneric))return null;const o=rn.type(t),s=nn.type(t),l=at.type(t),a=(f,d,h=1)=>{let p=!1;const m=`${d+h}.`;return f.label!==m&&(f.label=m,p=!0),p};let c=i.tr,u=!1;return i.doc.descendants((f,d,h,p)=>{if(f.type===s){const m=f.maybeChild(0);(m==null?void 0:m.type)===l&&m.attrs.listType==="ordered"&&(u=!0,c.setNodeMarkup(d,o,{spread:!0}),f.descendants((y,g,C,w)=>{if(y.type===l){const E={...y.attrs};a(E,w)&&(c=c.setNodeMarkup(g,void 0,E))}return!1}))}else if(f.type===l&&(h==null?void 0:h.type)===o){const m={...f.attrs};let y=!1;m.listType!=="ordered"&&(m.listType="ordered",y=!0),h!=null&&h.maybeChild(0)&&(y=a(m,p,(h==null?void 0:h.attrs.order)??1)),y&&(c=c.setNodeMarkup(d,void 0,m),u=!0)}}),u?c.setMeta("addToHistory",!1):null};return new Ne({key:new Te("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:e})});T(Im,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var eS=[Mm,Fc,Nm,Sm,gs,Rc,Pc,zc,Bc,Lc,_s,Tm,Im].flat(),tS=[_C,$C,VC,GC,YC,eS].flat();let ya,ka;if(typeof WeakMap<"u"){let t=new WeakMap;ya=e=>t.get(e),ka=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;ya=r=>{for(let i=0;i<t.length;i+=2)if(t[i]==r)return t[i+1]},ka=(r,i)=>(n==10&&(n=0),t[n++]=r,t[n++]=i)}var oe=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,i=e/this.width|0;let o=r+1,s=i+1;for(let l=1;o<this.width&&this.map[e+l]==n;l++)o++;for(let l=1;s<this.height&&this.map[e+this.width*l]==n;l++)s++;return{left:r,top:i,right:o,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:i,top:o,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?r==0:i==this.width)?null:this.map[o*this.width+(n<0?r-1:i)]:(n<0?o==0:s==this.height)?null:this.map[r+this.width*(n<0?o-1:s)]}rectBetween(t,e){const{left:n,right:r,top:i,bottom:o}=this.findCell(t),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(i,a),right:Math.max(r,l),bottom:Math.max(o,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let i=t.left;i<t.right;i++){const o=r*this.width+i,s=this.map[o];n[s]||(n[s]=!0,!(i==t.left&&i&&this.map[o-1]==s||r==t.top&&r&&this.map[o-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,i=0;;r++){const o=i+n.child(r).nodeSize;if(r==t){let s=e+t*this.width;const l=(t+1)*this.width;for(;s<l&&this.map[s]<i;)s++;return s==l?o-1:this.map[s]}i=o}}static get(t){return ya(t)||ka(t,nS(t))}};function nS(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=rS(t),n=t.childCount,r=[];let i=0,o=null;const s=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){const f=t.child(c);u++;for(let p=0;;p++){for(;i<r.length&&r[i]!=0;)i++;if(p==f.childCount)break;const m=f.child(p),{colspan:y,rowspan:g,colwidth:C}=m.attrs;for(let w=0;w<g;w++){if(w+c>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:u,n:g-w});break}const E=i+w*e;for(let P=0;P<y;P++){r[E+P]==0?r[E+P]=u:(o||(o=[])).push({type:"collision",row:c,pos:u,n:y-P});const S=C&&C[P];if(S){const D=(E+P)%e*2,F=s[D];F==null||F!=S&&s[D+1]==1?(s[D]=S,s[D+1]=1):F==S&&s[D+1]++}}}i+=y,u+=m.nodeSize}const d=(c+1)*e;let h=0;for(;i<d;)r[i++]==0&&h++;h&&(o||(o=[])).push({type:"missing",row:c,n:h}),u++}(e===0||n===0)&&(o||(o=[])).push({type:"zero_sized"});const l=new oe(e,n,r,o);let a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<n&&(a=!0);return a&&iS(l,s,t),l}function rS(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const i=t.child(r);let o=0;if(n)for(let s=0;s<r;s++){const l=t.child(s);for(let a=0;a<l.childCount;a++){const c=l.child(a);s+c.attrs.rowspan>r&&(o+=c.attrs.colspan)}}for(let s=0;s<i.childCount;s++){const l=i.child(s);o+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function iS(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i<t.map.length;i++){const o=t.map[i];if(r[o])continue;r[o]=!0;const s=n.nodeAt(o);if(!s)throw new RangeError(`No cell with offset ${o} found`);let l=null;const a=s.attrs;for(let c=0;c<a.colspan;c++){const u=e[(i+c)%t.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=oS(a)))[c]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:l})}}function oS(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Yf(t,e){if(typeof t=="string")return{};const n=t.getAttribute("data-colwidth"),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(",").map(s=>Number(s)):null,i=Number(t.getAttribute("colspan")||1),o={colspan:i,rowspan:Number(t.getAttribute("rowspan")||1),colwidth:r&&r.length==i?r:null};for(const s in e){const l=e[s].getFromDOM,a=l&&l(t);a!=null&&(o[s]=a)}return o}function Qf(t,e){const n={};t.attrs.colspan!=1&&(n.colspan=t.attrs.colspan),t.attrs.rowspan!=1&&(n.rowspan=t.attrs.rowspan),t.attrs.colwidth&&(n["data-colwidth"]=t.attrs.colwidth.join(","));for(const r in e){const i=e[r].setDOMAttr;i&&i(t.attrs[r],n)}return n}function sS(t){if(t!==null){if(!Array.isArray(t))throw new TypeError("colwidth must be null or an array");for(const e of t)if(typeof e!="number")throw new TypeError("colwidth must be null or an array of numbers")}}function lS(t){const e=t.cellAttributes||{},n={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:sS}};for(const r in e)n[r]={default:e[r].default,validate:e[r].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:t.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:t.cellContent,attrs:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:r=>Yf(r,e)}],toDOM(r){return["td",Qf(r,e),0]}},table_header:{content:t.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>Yf(r,e)}],toDOM(r){return["th",Qf(r,e),0]}}}}function ct(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const dn=new Te("selectingCells");function Qr(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function ut(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function qs(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Qr(e.$head)||aS(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function aS(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function ba(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function cS(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function _c(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Am(t,e,n){const r=t.node(-1),i=oe.get(r),o=t.start(-1),s=i.nextCell(t.pos-o,e,n);return s==null?null:t.node(0).resolve(o+s)}function rr(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function uS(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(e,0,0)}return r}function fS(t,e,n){const r=ct(e.type.schema).header_cell;for(let i=0;i<t.height;i++)if(e.nodeAt(t.map[n+i*t.width]).type!=r)return!1;return!0}var ae=class Lt extends q{constructor(e,n=e){const r=e.node(-1),i=oe.get(r),o=e.start(-1),s=i.rectBetween(e.pos-o,n.pos-o),l=e.node(0),a=i.cellsInRect(s).filter(u=>u!=n.pos-o);a.unshift(n.pos-o);const c=a.map(u=>{const f=r.nodeAt(u);if(!f)throw new RangeError(`No cell with offset ${u} found`);const d=o+u+1;return new jd(l.resolve(d),l.resolve(d+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(ba(r)&&ba(i)&&_c(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Lt.rowSelection(r,i):o&&this.isColSelection()?Lt.colSelection(r,i):new Lt(r,i)}return G.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=oe.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let a=i.top;a<i.bottom;a++){const c=[];for(let u=a*n.width+i.left,f=i.left;f<i.right;f++,u++){const d=n.map[u];if(o[d])continue;o[d]=!0;const h=n.findCell(d);let p=e.nodeAt(d);if(!p)throw new RangeError(`No cell with offset ${d} found`);const m=i.left-h.left,y=h.right-i.right;if(m>0||y>0){let g=p.attrs;if(m>0&&(g=rr(g,0,m)),y>0&&(g=rr(g,g.colspan-y,y)),h.left<i.left){if(p=p.type.createAndFill(g),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(g)}`)}else p=p.type.create(g,p.content)}if(h.top<i.top||h.bottom>i.bottom){const g={...p.attrs,rowspan:Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top)};h.top<i.top?p=p.type.createAndFill(g):p=p.type.create(g,p.content)}c.push(p)}s.push(e.child(a).copy(I.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:s;return new z(I.from(l),1,1)}replace(e,n=z.empty){const r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){const{$from:l,$to:a}=i[s],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),s?z.empty:n)}const o=q.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,n){this.replace(e,new z(I.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=oe.get(n),i=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let s=0;s<o.length;s++)e(n.nodeAt(o[s]),i+o[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=oe.get(r),o=e.start(-1),s=i.findCell(e.pos-o),l=i.findCell(n.pos-o),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(o+i.map[s.left])),l.bottom<i.height&&(n=a.resolve(o+i.map[i.width*(i.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(o+i.map[l.left])),s.bottom<i.height&&(e=a.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))),new Lt(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=oe.get(e),r=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-r),o=n.colCount(this.$headCell.pos-r);if(Math.min(i,o)>0)return!1;const s=i+this.$anchorCell.nodeAfter.attrs.colspan,l=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(e){return e instanceof Lt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=oe.get(r),o=e.start(-1),s=i.findCell(e.pos-o),l=i.findCell(n.pos-o),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(o+i.map[s.top*i.width])),l.right<i.width&&(n=a.resolve(o+i.map[i.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(o+i.map[l.top*i.width])),s.right<i.width&&(e=a.resolve(o+i.map[i.width*(s.top+1)-1]))),new Lt(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Lt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Lt(e.resolve(n),e.resolve(r))}getBookmark(){return new hS(this.$anchorCell.pos,this.$headCell.pos)}};ae.prototype.visible=!1;q.jsonID("cell",ae);var hS=class Em{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Em(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&_c(n,r)?new ae(n,r):q.near(r,1)}};function dS(t){if(!(t.selection instanceof ae))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Me.node(r,r+n.nodeSize,{class:"selectedCell"}))}),ue.create(t.doc,e)}function pS({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,i=t.depth;for(;i>=0&&!(t.after(i+1)<t.end(i));i--,n++);for(let o=e.depth;o>=0&&!(e.before(o+1)>e.start(o));o--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function mS({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&e.parentOffset===0}function gS(t,e,n){const r=(e||t).selection,i=(e||t).doc;let o,s;if(r instanceof W&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=ae.create(i,r.from);else if(s=="row"){const l=i.resolve(r.from+1);o=ae.rowSelection(l,l)}else if(!n){const l=oe.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];o=ae.create(i,a+1,c)}}else r instanceof G&&pS(r)?o=G.create(i,r.from):r instanceof G&&mS(r)&&(o=G.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=t.tr)).setSelection(o),e}const yS=new Te("fix-tables");function vm(t,e,n,r){const i=t.childCount,o=e.childCount;e:for(let s=0,l=0;s<o;s++){const a=e.child(s);for(let c=l,u=Math.min(i,s+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<i&&t.child(l).sameMarkup(a)?vm(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function kS(t,e){let n;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(n=bS(t,i,o,n))};return e?e.doc!=t.doc&&vm(e.doc,t.doc,0,r):t.doc.descendants(r),n}function bS(t,e,n,r){const i=oe.get(e);if(!i.problems)return r;r||(r=t.tr);const o=[];for(let a=0;a<i.height;a++)o.push(0);for(let a=0;a<i.problems.length;a++){const c=i.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const f=u.attrs;for(let d=0;d<f.rowspan;d++)o[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,rr(f,f.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let s,l;for(let a=0;a<o.length;a++)o[a]&&(s==null&&(s=a),l=a);for(let a=0,c=n+1;a<i.height;a++){const u=e.child(a),f=c+u.nodeSize,d=o[a];if(d>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const p=[];for(let y=0;y<d;y++){const g=ct(t.schema)[h].createAndFill();g&&p.push(g)}const m=(a==0||s==a-1)&&l==a?c+1:f-1;r.insert(r.mapping.map(m),p)}c=f}return r.setMeta(yS,{fixTables:!0})}function Om(t){const e=oe.get(t),n=[],r=e.height,i=e.width;for(let o=0;o<r;o++){const s=[];for(let l=0;l<i;l++){const a=o*i+l,c=e.map[a];if(o>0){const u=a-i;if(c===e.map[u]){s.push(null);continue}}if(l>0){const u=a-1;if(c===e.map[u]){s.push(null);continue}}s.push(t.nodeAt(c))}n.push(s)}return n}function Dm(t,e){const n=[],r=oe.get(t),i=r.height,o=r.width;for(let s=0;s<i;s++){const l=t.child(s),a=[];for(let u=0;u<o;u++){const f=e[s][u];if(!f)continue;const d=r.map[s*r.width+u],h=t.nodeAt(d);if(!h)continue;const p=h.type.createChecked(f.attrs,f.content,f.marks);a.push(p)}const c=l.type.createChecked(l.attrs,a,l.marks);n.push(c)}return t.type.createChecked(t.attrs,n,t.marks)}function Rm(t,e,n,r){const i=e[0]>n[0]?-1:1,o=t.splice(e[0],e.length),s=o.length%2===0?1:0;let l;return l=i===-1?n[0]:n[n.length-1]-s,t.splice(l,0,...o),t}function To(t){return xS(e=>e.type.spec.tableRole==="table",t)}function xS(t,e){for(let n=e.depth;n>=0;n-=1){const r=e.node(n);if(t(r))return{node:r,pos:n===0?0:e.before(n),start:e.start(n),depth:n}}return null}function gr(t,e){const n=To(e.$from);if(!n)return;const r=oe.get(n.node);if(!(t<0||t>r.width-1))return r.cellsInRect({left:t,right:t+1,top:0,bottom:r.height}).map(i=>{const o=n.node.nodeAt(i),s=i+n.start;return{pos:s,start:s+1,node:o,depth:n.depth+2}})}function yr(t,e){const n=To(e.$from);if(!n)return;const r=oe.get(n.node);if(!(t<0||t>r.height-1))return r.cellsInRect({left:0,right:r.width,top:t,bottom:t+1}).map(i=>{const o=n.node.nodeAt(i),s=i+n.start;return{pos:s,start:s+1,node:o,depth:n.depth+2}})}function Xf(t,e,n=e){let r=e,i=n;for(let u=e;u>=0;u--){const f=gr(u,t.selection);f&&f.forEach(d=>{const h=d.node.attrs.colspan+u-1;h>=r&&(r=u),h>i&&(i=h)})}for(let u=e;u<=i;u++){const f=gr(u,t.selection);f&&f.forEach(d=>{const h=d.node.attrs.colspan+u-1;d.node.attrs.colspan>1&&h>i&&(i=h)})}const o=[];for(let u=r;u<=i;u++){const f=gr(u,t.selection);f&&f.length>0&&o.push(u)}r=o[0],i=o[o.length-1];const s=gr(r,t.selection),l=yr(0,t.selection);if(!s||!l)return;const a=t.doc.resolve(s[s.length-1].pos);let c;for(let u=i;u>=r;u--){const f=gr(u,t.selection);if(f&&f.length>0){for(let d=l.length-1;d>=0;d--)if(l[d].pos===f[0].pos){c=f[0];break}if(c)break}}if(c)return{$anchor:a,$head:t.doc.resolve(c.pos),indexes:o}}function Zf(t,e,n=e){let r=e,i=n;for(let u=e;u>=0;u--){const f=yr(u,t.selection);f&&f.forEach(d=>{const h=d.node.attrs.rowspan+u-1;h>=r&&(r=u),h>i&&(i=h)})}for(let u=e;u<=i;u++){const f=yr(u,t.selection);f&&f.forEach(d=>{const h=d.node.attrs.rowspan+u-1;d.node.attrs.rowspan>1&&h>i&&(i=h)})}const o=[];for(let u=r;u<=i;u++){const f=yr(u,t.selection);f&&f.length>0&&o.push(u)}r=o[0],i=o[o.length-1];const s=yr(r,t.selection),l=gr(0,t.selection);if(!s||!l)return;const a=t.doc.resolve(s[s.length-1].pos);let c;for(let u=i;u>=r;u--){const f=yr(u,t.selection);if(f&&f.length>0){for(let d=l.length-1;d>=0;d--)if(l[d].pos===f[0].pos){c=f[0];break}if(c)break}}if(c)return{$anchor:a,$head:t.doc.resolve(c.pos),indexes:o}}function eh(t){return t[0].map((e,n)=>t.map(r=>r[n]))}function wS(t){var e,n;const{tr:r,originIndex:i,targetIndex:o,select:s,pos:l}=t,a=To(r.doc.resolve(l));if(!a)return!1;const c=(e=Xf(r,i))===null||e===void 0?void 0:e.indexes,u=(n=Xf(r,o))===null||n===void 0?void 0:n.indexes;if(!c||!u||c.includes(o))return!1;const f=CS(a.node,c,u);if(r.replaceWith(a.pos,a.pos+a.node.nodeSize,f),!s)return!0;const d=oe.get(f),h=a.start,p=o,m=d.positionAt(d.height-1,p,f),y=r.doc.resolve(h+m),g=d.positionAt(0,p,f),C=r.doc.resolve(h+g);return r.setSelection(ae.colSelection(y,C)),!0}function CS(t,e,n,r){let i=eh(Om(t));return i=Rm(i,e,n),i=eh(i),Dm(t,i)}function SS(t){var e,n;const{tr:r,originIndex:i,targetIndex:o,select:s,pos:l}=t,a=To(r.doc.resolve(l));if(!a)return!1;const c=(e=Zf(r,i))===null||e===void 0?void 0:e.indexes,u=(n=Zf(r,o))===null||n===void 0?void 0:n.indexes;if(!c||!u||c.includes(o))return!1;const f=MS(a.node,c,u);if(r.replaceWith(a.pos,a.pos+a.node.nodeSize,f),!s)return!0;const d=oe.get(f),h=a.start,p=o,m=d.positionAt(p,d.width-1,f),y=r.doc.resolve(h+m),g=d.positionAt(p,0,f),C=r.doc.resolve(h+g);return r.setSelection(ae.rowSelection(y,C)),!0}function MS(t,e,n,r){let i=Om(t);return i=Rm(i,e,n),Dm(t,i)}function In(t){const e=t.selection,n=qs(t),r=n.node(-1),i=n.start(-1),o=oe.get(r);return{...e instanceof ae?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(n.pos-i),tableStart:i,map:o,table:r}}function zm(t,{map:e,tableStart:n,table:r},i){let o=i>0?-1:0;fS(e,r,i+o)&&(o=i==0||i==e.width?null:0);for(let s=0;s<e.height;s++){const l=s*e.width+i;if(i>0&&i<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,uS(c.attrs,i-e.colCount(a))),s+=c.attrs.rowspan-1}else{const a=o==null?ct(r.type.schema).cell:r.nodeAt(e.map[l+o]).type,c=e.positionAt(s,i,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function NS(t,e){if(!ut(t))return!1;if(e){const n=In(t);e(zm(t.tr,n,n.left))}return!0}function TS(t,e){if(!ut(t))return!1;if(e){const n=In(t);e(zm(t.tr,n,n.right))}return!0}function IS(t,{map:e,table:n,tableStart:r},i){const o=t.mapping.maps.length;for(let s=0;s<e.height;){const l=s*e.width+i,a=e.map[l],c=n.nodeAt(a),u=c.attrs;if(i>0&&e.map[l-1]==a||i<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(o).map(r+a),null,rr(u,i-e.colCount(a)));else{const f=t.mapping.slice(o).map(r+a);t.delete(f,f+c.nodeSize)}s+=u.rowspan}}function AS(t,e){if(!ut(t))return!1;if(e){const n=In(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;IS(r,n,i),i!=n.left;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");n.table=o,n.map=oe.get(o)}e(r)}return!0}function ES(t,{map:e,table:n,tableStart:r},i){let o=0;for(let c=0;c<i;c++)o+=n.child(c).nodeSize;const s=o+n.child(i).nodeSize,l=t.mapping.maps.length;t.delete(o+r,s+r);const a=new Set;for(let c=0,u=i*e.width;c<e.width;c++,u++){const f=e.map[u];if(!a.has(f)){if(a.add(f),i>0&&f==e.map[u-e.width]){const d=n.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(l).map(f+r),null,{...d,rowspan:d.rowspan-1}),c+=d.colspan-1}else if(i<e.height&&f==e.map[u+e.width]){const d=n.nodeAt(f),h=d.attrs,p=d.type.create({...h,rowspan:d.attrs.rowspan-1},d.content),m=e.positionAt(i+1,c,n);t.insert(t.mapping.slice(l).map(r+m),p),c+=h.colspan-1}}}}function vS(t,e){if(!ut(t))return!1;if(e){const n=In(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;ES(r,n,i),i!=n.top;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");n.table=o,n.map=oe.get(n.table)}e(r)}return!0}function OS(t,e){return function(n,r){if(!ut(n))return!1;const i=qs(n);if(i.nodeAfter.attrs[t]===e)return!1;if(r){const o=n.tr;n.selection instanceof ae?n.selection.forEachCell((s,l)=>{s.attrs[t]!==e&&o.setNodeMarkup(l,null,{...s.attrs,[t]:e})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(o)}return!0}}function DS(t){return function(e,n){if(!ut(e))return!1;if(n){const r=ct(e.schema),i=In(e),o=e.tr,s=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),l=s.map(a=>i.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&o.setNodeMarkup(i.tableStart+s[a],r.cell,l[a].attrs);if(o.steps.length===0)for(let a=0;a<s.length;a++)o.setNodeMarkup(i.tableStart+s[a],r.header_cell,l[a].attrs);n(o)}return!0}}function th(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const o=e.table.nodeAt(r[i]);if(o&&o.type!==n.header_cell)return!1}return!0}function $c(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?DS(t):function(n,r){if(!ut(n))return!1;if(r){const i=ct(n.schema),o=In(n),s=n.tr,l=th("row",o,i),a=th("column",o,i),c=(t==="column"?l:t==="row"&&a)?1:0,u=t=="column"?{left:0,top:c,right:1,bottom:o.map.height}:t=="row"?{left:c,top:0,right:o.map.width,bottom:1}:o,f=t=="column"?a?i.cell:i.header_cell:t=="row"?l?i.cell:i.header_cell:i.cell;o.map.cellsInRect(u).forEach(d=>{const h=d+o.tableStart,p=s.doc.nodeAt(h);p&&s.setNodeMarkup(h,f,p.attrs)}),r(s)}return!0}}$c("row",{useDeprecatedLogic:!0});$c("column",{useDeprecatedLogic:!0});$c("cell",{useDeprecatedLogic:!0});function RS(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const o=t.node(-1).child(r),s=o.lastChild;if(s)return i-1-s.nodeSize;i-=o.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),i=t.after();r<n.childCount;r++){const o=n.child(r);if(o.childCount)return i+1;i+=o.nodeSize}}return null}function Pm(t){return function(e,n){if(!ut(e))return!1;const r=RS(qs(e),t);if(r==null)return!1;if(n){const i=e.doc.resolve(r);n(e.tr.setSelection(G.between(i,cS(i))).scrollIntoView())}return!0}}function zS(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Lo(t,e){const n=t.selection;if(!(n instanceof ae))return!1;if(e){const r=t.tr,i=ct(t.schema).cell.createAndFill().content;n.forEachCell((o,s)=>{o.content.eq(i)||r.replace(r.mapping.map(s+1),r.mapping.map(s+o.nodeSize-1),new z(i,0,0))}),r.docChanged&&e(r)}return!0}function PS(t){return(e,n)=>{const{from:r,to:i,select:o=!0,pos:s=e.selection.from}=t,l=e.tr;return SS({tr:l,originIndex:r,targetIndex:i,select:o,pos:s})?(n==null||n(l),!0):!1}}function BS(t){return(e,n)=>{const{from:r,to:i,select:o=!0,pos:s=e.selection.from}=t,l=e.tr;return wS({tr:l,originIndex:r,targetIndex:i,select:o,pos:s})?(n==null||n(l),!0):!1}}function LS(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,l=[];if(o=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,n-1),f=a<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=xa(ct(s).row,new z(c,u,f)).content),l.push(c)}else if(o=="cell"||o=="header_cell")l.push(n||r?xa(ct(s).row,new z(e,n,r)).content:e);else return null;return FS(s,l)}function FS(t,e){const n=[];for(let i=0;i<e.length;i++){const o=e[i];for(let s=o.childCount-1;s>=0;s--){const{rowspan:l,colspan:a}=o.child(s).attrs;for(let c=i;c<i+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=e.length&&e.push(I.empty),n[i]<r){const o=ct(t).cell.createAndFill(),s=[];for(let l=n[i];l<r;l++)s.push(o);e[i]=e[i].append(I.from(s))}return{height:e.length,width:r,rows:e}}function xa(t,e){const n=t.createAndFill();return new Vd(n).replace(0,n.content.size,e).doc}function _S({width:t,height:e,rows:n},r,i){if(t!=r){const o=[],s=[];for(let l=0;l<n.length;l++){const a=n[l],c=[];for(let u=o[l]||0,f=0;u<r;f++){let d=a.child(f%a.childCount);u+d.attrs.colspan>r&&(d=d.type.createChecked(rr(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let h=1;h<d.attrs.rowspan;h++)o[l+h]=(o[l+h]||0)+d.attrs.colspan}s.push(I.from(c))}n=s,t=r}if(e!=i){const o=[];for(let s=0,l=0;s<i;s++,l++){const a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let f=c.child(u);s+f.attrs.rowspan>i&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,i-f.attrs.rowspan)},f.content)),a.push(f)}o.push(I.from(a))}n=o,e=i}return{width:t,height:e,rows:n}}function $S(t,e,n,r,i,o,s){const l=t.doc.type.schema,a=ct(l);let c,u;if(i>e.width)for(let f=0,d=0;f<e.height;f++){const h=n.child(f);d+=h.nodeSize;const p=[];let m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=u||(u=a.header_cell.createAndFill());for(let y=e.width;y<i;y++)p.push(m);t.insert(t.mapping.slice(s).map(d-1+r),p)}if(o>e.height){const f=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,i);p++){const y=p>=e.width?!1:n.nodeAt(e.map[m+p]).type==a.header_cell;f.push(y?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const d=a.row.create(null,I.from(f)),h=[];for(let p=e.height;p<o;p++)h.push(d);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),h)}return!!(c||u)}function nh(t,e,n,r,i,o,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=i;c<o;c++){const u=s*e.width+c,f=e.map[u];if(e.map[u-e.width]==f){a=!0;const d=n.nodeAt(f),{top:h,left:p}=e.findCell(f);t.setNodeMarkup(t.mapping.slice(l).map(f+r),null,{...d.attrs,rowspan:s-h}),t.insert(t.mapping.slice(l).map(e.positionAt(s,p,n)),d.type.createAndFill({...d.attrs,rowspan:h+d.attrs.rowspan-s})),c+=d.attrs.colspan-1}}return a}function rh(t,e,n,r,i,o,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=i;c<o;c++){const u=c*e.width+s,f=e.map[u];if(e.map[u-1]==f){a=!0;const d=n.nodeAt(f),h=e.colCount(f),p=t.mapping.slice(l).map(f+r);t.setNodeMarkup(p,null,rr(d.attrs,s-h,d.attrs.colspan-(s-h))),t.insert(p+d.nodeSize,d.type.createAndFill(rr(d.attrs,0,s-h))),c+=d.attrs.rowspan-1}}return a}function ih(t,e,n,r,i){let o=n?t.doc.nodeAt(n-1):t.doc;if(!o)throw new Error("No table found");let s=oe.get(o);const{top:l,left:a}=r,c=a+i.width,u=l+i.height,f=t.tr;let d=0;function h(){if(o=n?f.doc.nodeAt(n-1):f.doc,!o)throw new Error("No table found");s=oe.get(o),d=f.mapping.maps.length}$S(f,s,o,n,c,u,d)&&h(),nh(f,s,o,n,a,c,l,d)&&h(),nh(f,s,o,n,a,c,u,d)&&h(),rh(f,s,o,n,l,u,a,d)&&h(),rh(f,s,o,n,l,u,c,d)&&h();for(let p=l;p<u;p++){const m=s.positionAt(p,a,o),y=s.positionAt(p,c,o);f.replace(f.mapping.slice(d).map(m+n),f.mapping.slice(d).map(y+n),new z(i.rows[p-l],0,0))}h(),f.setSelection(new ae(f.doc.resolve(n+s.positionAt(l,a,o)),f.doc.resolve(n+s.positionAt(u-1,c-1,o)))),e(f)}const VS=rp({ArrowLeft:Fo("horiz",-1),ArrowRight:Fo("horiz",1),ArrowUp:Fo("vert",-1),ArrowDown:Fo("vert",1),"Shift-ArrowLeft":_o("horiz",-1),"Shift-ArrowRight":_o("horiz",1),"Shift-ArrowUp":_o("vert",-1),"Shift-ArrowDown":_o("vert",1),Backspace:Lo,"Mod-Backspace":Lo,Delete:Lo,"Mod-Delete":Lo});function Xo(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Fo(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;if(o instanceof ae)return Xo(n,r,q.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;const s=Bm(i,t,e);if(s==null)return!1;if(t=="horiz")return Xo(n,r,q.near(n.doc.resolve(o.head+e),e));{const l=n.doc.resolve(s),a=Am(l,t,e);let c;return a?c=q.near(a,1):e<0?c=q.near(n.doc.resolve(l.before(-1)),-1):c=q.near(n.doc.resolve(l.after(-1)),1),Xo(n,r,c)}}}function _o(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let s;if(o instanceof ae)s=o;else{const a=Bm(i,t,e);if(a==null)return!1;s=new ae(n.doc.resolve(a))}const l=Am(s.$headCell,t,e);return l?Xo(n,r,new ae(s.$anchorCell,l)):!1}}function jS(t,e){const n=t.state.doc,r=Qr(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new ae(r))),!0):!1}function HS(t,e,n){if(!ut(t.state))return!1;let r=LS(n);const i=t.state.selection;if(i instanceof ae){r||(r={width:1,height:1,rows:[I.from(xa(ct(t.state.schema).cell,n))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),l=oe.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=_S(r,l.right-l.left,l.bottom-l.top),ih(t.state,t.dispatch,s,l,r),!0}else if(r){const o=qs(t.state),s=o.start(-1);return ih(t.state,t.dispatch,s,oe.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function qS(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=oh(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof ae)o(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Qr(t.state.selection.$anchor))!=null&&((n=El(t,e))===null||n===void 0?void 0:n.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(a,c){let u=El(t,c);const f=dn.getState(t.state)==null;if(!u||!_c(a,u))if(f)u=a;else return;const d=new ae(a,u);if(f||!t.state.selection.eq(d)){const h=t.state.tr.setSelection(d);f&&h.setMeta(dn,a.pos),t.dispatch(h)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),dn.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(dn,-1))}function l(a){const c=a,u=dn.getState(t.state);let f;if(u!=null)f=t.state.doc.resolve(u);else if(oh(t,c.target)!=r&&(f=El(t,e),!f))return s();f&&o(f,c)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function Bm(t,e,n){if(!(t.state.selection instanceof G))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const s=r.before(i),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?s:null}}return null}function oh(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function El(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Qr(t.state.doc.resolve(r))||Qr(t.state.doc.resolve(i))}var WS=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,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",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),wa(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,wa(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function wa(t,e,n,r,i,o){let s=0,l=!0,a=e.firstChild;const c=t.firstChild;if(c){for(let f=0,d=0;f<c.childCount;f++){const{colspan:h,colwidth:p}=c.child(f).attrs;for(let m=0;m<h;m++,d++){const y=i==d?o:p&&p[m],g=y?y+"px":"";if(s+=y||r,y||(l=!1),a)a.style.width!=g&&(a.style.width=g),a=a.nextSibling;else{const C=document.createElement("col");C.style.width=g,e.appendChild(C)}}}for(;a;){var u;const f=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=f}l?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const Ye=new Te("tableColumnResizing");function KS({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=WS,lastColumnResizable:i=!0}={}){const o=new Ne({key:Ye,state:{init(s,l){var a;const c=(a=o.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=ct(l.schema).table.name;return r&&c&&(c[u]=(f,d)=>new r(f,n,d)),new JS(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{const l=Ye.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{US(s,l,t,i)},mouseleave:s=>{GS(s)},mousedown:(s,l)=>{YS(s,l,e,n)}},decorations:s=>{const l=Ye.getState(s);if(l&&l.activeHandle>-1)return tM(s,l.activeHandle)},nodeViews:{}}});return o}var JS=class Zo{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Ye);if(r&&r.setHandle!=null)return new Zo(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Zo(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return ba(e.doc.resolve(i))||(i=-1),new Zo(i,n.dragging)}return n}};function US(t,e,n,r){if(!t.editable)return;const i=Ye.getState(t.state);if(i&&!i.dragging){const o=XS(e.target);let s=-1;if(o){const{left:l,right:a}=o.getBoundingClientRect();e.clientX-l<=n?s=sh(t,e,"left",n):a-e.clientX<=n&&(s=sh(t,e,"right",n))}if(s!=i.activeHandle){if(!r&&s!==-1){const l=t.state.doc.resolve(s),a=l.node(-1),c=oe.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Lm(t,s)}}}function GS(t){if(!t.editable)return;const e=Ye.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Lm(t,-1)}function YS(t,e,n,r){var i;if(!t.editable)return!1;const o=(i=t.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,s=Ye.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const l=t.state.doc.nodeAt(s.activeHandle),a=QS(t,s.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Ye,{setDragging:{startX:e.clientX,startWidth:a}}));function c(f){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",u);const d=Ye.getState(t.state);d!=null&&d.dragging&&(ZS(t,d.activeHandle,lh(d.dragging,f,n)),t.dispatch(t.state.tr.setMeta(Ye,{setDragging:null})))}function u(f){if(!f.which)return c(f);const d=Ye.getState(t.state);if(d&&d.dragging){const h=lh(d.dragging,f,n);ah(t,d.activeHandle,h,r)}}return ah(t,s.activeHandle,a,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",u),e.preventDefault(),!0}function QS(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=t.domAtPos(e);let s=o.node.childNodes[o.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(s-=r[a],l--);return s/l}function XS(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function sh(t,e,n,r){const i=n=="right"?-r:r,o=t.posAtCoords({left:e.clientX+i,top:e.clientY});if(!o)return-1;const{pos:s}=o,l=Qr(t.state.doc.resolve(s));if(!l)return-1;if(n=="right")return l.pos;const a=oe.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function lh(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function Lm(t,e){t.dispatch(t.state.tr.setMeta(Ye,{setHandle:e}))}function ZS(t,e,n){const r=t.state.doc.resolve(e),i=r.node(-1),o=oe.get(i),s=r.start(-1),l=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<o.height;c++){const u=c*o.width+l;if(c&&o.map[u]==o.map[u-o.width])continue;const f=o.map[u],d=i.nodeAt(f).attrs,h=d.colspan==1?0:l-o.colCount(f);if(d.colwidth&&d.colwidth[h]==n)continue;const p=d.colwidth?d.colwidth.slice():eM(d.colspan);p[h]=n,a.setNodeMarkup(s+f,null,{...d,colwidth:p})}a.docChanged&&t.dispatch(a)}function ah(t,e,n,r){const i=t.state.doc.resolve(e),o=i.node(-1),s=i.start(-1),l=oe.get(o).colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;let a=t.domAtPos(i.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&wa(o,a.firstChild,a,r,l,n)}function eM(t){return Array(t).fill(0)}function tM(t,e){const n=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return ue.empty;const o=oe.get(i),s=r.start(-1),l=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const u=l+c*o.width;if((l==o.width-1||o.map[u]!=o.map[u+1])&&(c==0||o.map[u]!=o.map[u-o.width])){var a;const f=o.map[u],d=s+f+i.nodeAt(f).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((a=Ye.getState(t))===null||a===void 0)&&a.dragging&&n.push(Me.node(s+f,s+f+i.nodeAt(f).nodeSize,{class:"column-resize-dragging"})),n.push(Me.widget(d,h))}}return ue.create(t.doc,n)}function nM({allowTableNodeSelection:t=!1}={}){return new Ne({key:dn,state:{init(){return null},apply(e,n){const r=e.getMeta(dn);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:i,pos:o}=e.mapping.mapResult(n);return i?null:o}},props:{decorations:dS,handleDOMEvents:{mousedown:qS},createSelectionBetween(e){return dn.getState(e.state)!=null?e.state.selection:null},handleTripleClick:jS,handleKeyDown:VS,handlePaste:HS},appendTransaction(e,n,r){return gS(r,kS(r,n),t)}})}var ks=typeof navigator<"u"?navigator:null,Vc=ks&&ks.userAgent||"",rM=/Edge\/(\d+)/.exec(Vc),iM=/MSIE \d/.exec(Vc),oM=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Vc),sM=!!(iM||oM||rM),lM=!sM&&!!ks&&/Apple Computer/.test(ks.vendor),Fm=new Te("safari-ime-span"),Ca=!1,aM={key:Fm,props:{decorations:cM,handleDOMEvents:{compositionstart:()=>{Ca=!0},compositionend:()=>{Ca=!1}}}};function cM(t){const{$from:e,$to:n,to:r}=t.selection;if(Ca&&e.sameParent(n)){const i=Me.widget(r,uM,{ignoreSelection:!0,key:"safari-ime-span"});return ue.create(t.doc,[i])}}function uM(t){const e=t.dom.ownerDocument.createElement("span");return e.className="ProseMirror-safari-ime-span",e}var fM=new Ne(lM?aM:{key:Fm});function ch(t,e){const n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(e);for(;i!==-1;)r++,i=n.indexOf(e,i+e.length);return r}function hM(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function dM(t,e,n){const i=Ms((n||{}).ignore||[]),o=pM(e);let s=-1;for(;++s<o.length;)is(t,l);function l(c,u,f){if(c.type==="text"&&typeof f=="number")return a(c,u,f);if(i(c,f,u[u.length-1]))return qr}function a(c,u,f){const d=u[u.length-1],h=o[s][0],p=o[s][1];let m=0,y=!1,g=[];h.lastIndex=0;let C=h.exec(c.value);for(;C;){const E=C.index,P={index:C.index,input:C.input,stack:[...u,c]};let S=p(...C,P);if(typeof S=="string"&&(S=S.length>0?{type:"text",value:S}:void 0),S===!1)h.lastIndex=E+1;else{if(m!==E&&w({type:"text",value:c.value.slice(m,E)}),Array.isArray(S))for(const D of S)w(D);else S&&w(S);m=E+C[0].length,y=!0}if(!h.global)break;C=h.exec(c.value)}return y?(m<c.value.length&&w({type:"text",value:c.value.slice(m)}),d.children.splice(f,1,...g)):g=[c],f+g.length;function w(E){const P=g[g.length-1];P&&P.type==="text"&&E.type==="text"?P.value+=E.value:g.push(E)}}}function pM(t){if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const e=[],n=!t[0]||Array.isArray(t[0])?t:[t];let r=-1;for(;++r<n.length;){const i=n[r];e.push([mM(i[0]),gM(i[1])])}return e}function mM(t){return typeof t=="string"?new RegExp(hM(t),"g"):t}function gM(t){return typeof t=="function"?t:function(){return t}}const vl="phrasing",Ol=["autolink","link","image","label"];function yM(){return{transforms:[MM],enter:{literalAutolink:bM,literalAutolinkEmail:Dl,literalAutolinkHttp:Dl,literalAutolinkWww:Dl},exit:{literalAutolink:SM,literalAutolinkEmail:CM,literalAutolinkHttp:xM,literalAutolinkWww:wM}}}function kM(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:vl,notInConstruct:Ol},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:vl,notInConstruct:Ol},{character:":",before:"[ps]",after:"\\/",inConstruct:vl,notInConstruct:Ol}]}}function bM(t){this.enter({type:"link",title:null,url:"",children:[],position:void 0},t)}function Dl(t){this.config.enter.autolinkProtocol.call(this,t)}function xM(t){this.config.exit.autolinkProtocol.call(this,t)}function wM(t){this.config.exit.data.call(this,t);const e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(t)}function CM(t){this.config.exit.autolinkEmail.call(this,t)}function SM(t){this.exit(t)}function MM(t){dM(t,[[new RegExp("(?<![\\da-z])(https?:\\/\\/|www(?=\\.))([\\w-]*\\.[\\w\\-.]*)([^\\t\\n\\r ]*)","gi"),NM],[new RegExp("(?<![\\w+\\-.@])xmpp:([\\w+\\-.]+)@([\\w-]+(?:\\.[\\w-]+)+)(\\/(?:[\\w\\-/]|\\.(?=[\\dA-Za-z]))*)?","g"),AM],[new RegExp("(?<![\\w+\\-.@])mailto:([\\w+\\-.]+)@([\\w-]+(?:\\.[\\w-]+)+)","g"),IM],[new RegExp("(?<![\\w+\\-.]|(?:^|[^\\d@A-Za-z])(?:mailto|xmpp):)([\\w+\\-.]+)@([\\w-]+(?:\\.[\\w-]+)+)","g"),TM]],{ignore:["link","linkReference"]})}function NM(t,e,n,r,i){if(!OM(i))return!1;let o="";if(/^w/i.test(e)&&(n=e+n,e="",o="http://"),fo(n.charCodeAt(0))||!EM(n))return!1;const s=vM(n+r),l={type:"link",title:null,url:o+e+s[0],children:[{type:"text",value:e+s[0],position:void 0}],position:void 0};return s[1]?[l,{type:"text",value:s[1],position:void 0}]:l}function TM(t,e,n){return/[\d\-_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+n,children:[{type:"text",value:e+"@"+n,position:void 0}],position:void 0}}function IM(t,e,n){if(/[\d\-_]$/.test(n))return!1;const r="mailto:"+e+"@"+n;return{type:"link",title:null,url:r,children:[{type:"text",value:r,position:void 0}],position:void 0}}function AM(t,e,n,r,i){if(/[\d\-_]$/.test(n)||r&&(!/[A-Za-z]$/.test(r)||i.input.charAt(i.index+t.length)==="@"))return!1;const o="xmpp:"+e+"@"+n+(r||"");return{type:"link",title:null,url:o,children:[{type:"text",value:o,position:void 0}],position:void 0}}function EM(t){const e=t.split(".");return!(e.length<2||e[e.length-1]&&(/_/.test(e[e.length-1])||!/[\dA-Za-z]/.test(e[e.length-1]))||e[e.length-2]&&(/_/.test(e[e.length-2])||!/[\dA-Za-z]/.test(e[e.length-2])))}function vM(t){let e=t.length;for(;e>0;){const s=t.charCodeAt(e-1);if(s===33||s===34||s===38||s===39||s===41||s===44||s===46||s===58||s===59||s===60||s===62||s===63||s===93||s===125)e--;else break}if(e===t.length)return[t,void 0];let n=t.slice(e);t=t.slice(0,e);let r=n.indexOf(")");const i=ch(t,"(");let o=ch(t,")");for(;r!==-1&&i>o;)t+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),o++;return[t,n]}function OM(t){const e=t.input.charCodeAt(t.index-1);return t.index===0||Gn(e)||fo(e)}_m.peek=$M;function DM(){this.buffer()}function RM(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function zM(){this.buffer()}function PM(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function BM(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=gt(this.sliceSerialize(t)).toLowerCase(),n.label=e}function LM(t){this.exit(t)}function FM(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=gt(this.sliceSerialize(t)).toLowerCase(),n.label=e}function _M(t){this.exit(t)}function $M(){return"["}function _m(t,e,n,r){const i=n.createTracker(r);let o=i.move("[^");const s=n.enter("footnoteReference"),l=n.enter("reference");return o+=i.move(n.safe(n.associationId(t),{after:"]",before:o})),l(),s(),o+=i.move("]"),o}function VM(){return{enter:{gfmFootnoteCallString:DM,gfmFootnoteCall:RM,gfmFootnoteDefinitionLabelString:zM,gfmFootnoteDefinition:PM},exit:{gfmFootnoteCallString:BM,gfmFootnoteCall:LM,gfmFootnoteDefinitionLabelString:FM,gfmFootnoteDefinition:_M}}}function jM(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:n,footnoteReference:_m},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,o,s){const l=o.createTracker(s);let a=l.move("[^");const c=o.enter("footnoteDefinition"),u=o.enter("label");return a+=l.move(o.safe(o.associationId(r),{before:a,after:"]"})),u(),a+=l.move("]:"),r.children&&r.children.length>0&&(l.shift(4),a+=l.move((e?`
|
|
51
|
-
`:" ")+o.indentLines(o.containerFlow(r,l.current()),e?$m:HM))),c(),a}}function HM(t,e,n){return e===0?t:$m(t,e,n)}function $m(t,e,n){return(n?"":" ")+t}const qM=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];jc.attention=GM;jc.peek=YM;function WM(){return{canContainEols:["delete"],enter:{strikethrough:JM},exit:{strikethrough:UM}}}function KM(){return{handlers:{delete:jc},unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:qM}]}}function JM(t){this.enter({type:"delete",children:[],position:void 0},t)}function UM(t){this.exit(t)}function jc(t,e,n,r){const i=n.createTracker(r),o=n.stack.includes("strikethrough")?"~":"~~",s=n.enter("strikethrough");let l=i.move(o);return l+=n.containerPhrasing(t,{...i.current(),before:l,after:"~"}),l+=i.move(o),s(),l}function GM(){return{construct:"strikethrough",markers:["~"],sizes:[2,1]}}function YM(){return"~"}function QM(t){return t.length}function XM(t,e){const n=e||{},r=(n.align||[]).concat(),i=n.stringLength||QM,o=[],s=[],l=[],a=[];let c=0,u=-1;for(;++u<t.length;){const m=[],y=[];let g=-1;for(t[u].length>c&&(c=t[u].length);++g<t[u].length;){const C=ZM(t[u][g]);if(n.alignDelimiters!==!1){const w=i(C);y[g]=w,(a[g]===void 0||w>a[g])&&(a[g]=w)}m.push(C)}s[u]=m,l[u]=y}let f=-1;if(typeof r=="object"&&"length"in r)for(;++f<c;)o[f]=uh(r[f]);else{const m=uh(r);for(;++f<c;)o[f]=m}f=-1;const d=[],h=[];for(;++f<c;){const m=o[f];let y="",g="";m===99?(y=":",g=":"):m===108?y=":":m===114&&(g=":");let C=n.alignDelimiters===!1?1:Math.max(1,a[f]-y.length-g.length);const w=y+"-".repeat(C)+g;n.alignDelimiters!==!1&&(C=y.length+C+g.length,C>a[f]&&(a[f]=C),h[f]=C),d[f]=w}s.splice(1,0,d),l.splice(1,0,h),u=-1;const p=[];for(;++u<s.length;){const m=s[u],y=l[u],g=n.fillRows===!1?Math.max(1,s[u===1?0:u].length):c;f=-1;const C=[];for(;++f<g;){const w=m[f]||"";let E="",P="";if(n.alignDelimiters!==!1){const S=a[f]-(y[f]||0),D=o[f];if(D===114)E=" ".repeat(S);else if(D===99){const F=S/2;S%2?(E=" ".repeat(F+.5),P=" ".repeat(F-.5)):(E=" ".repeat(F),P=E)}else P=" ".repeat(S)}n.delimiterStart!==!1&&!f&&C.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&w==="")&&(n.delimiterStart!==!1||f)&&C.push(" "),n.alignDelimiters!==!1&&C.push(E),C.push(w),n.alignDelimiters!==!1&&C.push(P),n.padding!==!1&&C.push(" "),(n.delimiterEnd!==!1||f!==g-1)&&C.push("|")}p.push(n.delimiterEnd===!1?C.join("").replace(/ +$/,""):C.join(""))}return p.join(`
|
|
52
|
-
`)}function ZM(t){return t==null?"":String(t)}function uh(t){const e=typeof t=="string"?t.codePointAt(0):0;return e===67||e===99?99:e===76||e===108?108:e===82||e===114?114:0}function eN(){return{enter:{table:tN,tableData:fh,tableHeader:fh,tableRow:rN},exit:{codeText:iN,table:nN,tableData:Rl,tableHeader:Rl,tableRow:Rl}}}function tN(t){const e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[],position:void 0},t),this.data.inTable=!0}function nN(t){this.exit(t),this.data.inTable=void 0}function rN(t){this.enter({type:"tableRow",children:[],position:void 0},t)}function Rl(t){this.exit(t)}function fh(t){this.enter({type:"tableCell",children:[],position:void 0},t)}function iN(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,oN));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function oN(t,e){return e==="|"?e:t}function sN(t){const e=t||{},{tableCellPadding:n,tablePipeAlign:r,stringLength:i}=e,o=n?" ":"|";return{handlers:{inlineCode:d,table:s,tableCell:a,tableRow:l},join:[lN],unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
53
|
-
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}]};function s(h,p,m,y){const g=u(h,m,y),C=g[0];if(C){let w=h.align?h.align.length:0,E=-1;if(!w)for(;++E<g.length;)g[E].length>w&&(w=g[E].length);for(;C.length<w;)C.push("")}return c(g,h.align)}function l(h,p,m,y){const g=f(h,m,y),C=c([g]);return C.slice(0,C.indexOf(`
|
|
54
|
-
`))}function a(h,p,m,y){const g=m.enter("tableCell"),C=m.enter("phrasing"),w=m.containerPhrasing(h,{...y,before:o,after:o});return C(),g(),w}function c(h,p){return XM(h,{align:p,alignDelimiters:r,fillRows:!1,padding:n,stringLength:i})}function u(h,p,m){const{children:y}=h;let g=-1;const C=[],w=p.enter("table");for(;++g<y.length;)C[g]=f(y[g],p,m);return w(),C}function f(h,p,m){const{children:y}=h;let g=-1;const C=[],w=p.enter("tableRow");for(;++g<y.length;)C[g]=a(y[g],h,p,m);return w(),C}function d(h,p,m){const y=ss.inlineCode(h,p,m);if(!m.stack.includes("tableCell"))return y;const g=[];let C=0,w=y.indexOf("|");for(;w!==-1;){let E=w;for(;E>C&&y.charCodeAt(E-1)===92;)E--;g.push(y.slice(C,w)),(w-E)%2===0&&g.push("\\"),C=w,w=y.indexOf("|",w+1)}return g.push(y.slice(C)),g.join("")}}function lN(t,e,n,r){if(t.type==="table"&&n.type==="listItem"&&n.spread===!1&&(e.type==="definition"||e.type==="heading"&&aN(e,r)||e.type==="paragraph"||e.type==="table"))return 1}function aN(t,e){let n=!1;return ir(t,function(r){if(r.type==="break"||"value"in r&&/\r?\n|\r/.test(r.value))return n=!0,bi}),!!((!t.depth||t.depth<3)&&Cs(t)&&(e.options.setext||n))}function cN(){return{exit:{taskListCheckValueChecked:hh,taskListCheckValueUnchecked:hh,paragraph:fN}}}function uN(){return{handlers:{paragraph:hN},join:[dN]}}function hh(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function fN(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=e.children;let o=-1,s;for(;++o<i.length;){const l=i[o];if(l.type==="paragraph"){s=l;break}}s===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start={...r.position.start}))}}this.exit(t)}function hN(t,e,n,r){if(!e||e.type!=="listItem"||Vm(e)!==t)return ss.paragraph(t,e,n,r);const i="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);o.move(i);const s=ss.paragraph(t.children.length>0?t:{type:"paragraph",children:[{type:"text",value:" "}]},e,n,{...r,...o.current()});return i+s}function dN(t,e,n){if(!(t.type==="definition"&&n.type==="listItem"))return;const r=Vm(n);if(r&&n.children.indexOf(t)<n.children.indexOf(r))return 0}function Vm(t){if(typeof t.checked=="boolean")for(const e of t.children){if(e.type==="paragraph")return e;if(e.type!=="definition")return}}function pN(){return[yM(),VM(),WM(),eN(),cN()]}function mN(t){return{extensions:[kM(),jM(t),KM(),sN(t),uN()]}}const gN={tokenize:CN,partial:!0},jm={tokenize:SN,partial:!0},Hm={tokenize:MN,partial:!0},qm={tokenize:NN,partial:!0},yN={tokenize:TN,partial:!0},Wm={name:"wwwAutolink",tokenize:xN,previous:Jm},Km={name:"protocolAutolink",tokenize:wN,previous:Um},on={name:"emailAutolink",tokenize:bN,previous:Gm},Rt={};function kN(){return{text:Rt}}let En=48;for(;En<123;)Rt[En]=on,En++,En===58?En=65:En===91&&(En=97);Rt[43]=on;Rt[45]=on;Rt[46]=on;Rt[95]=on;Rt[72]=[on,Km];Rt[104]=[on,Km];Rt[87]=[on,Wm];Rt[119]=[on,Wm];function bN(t,e,n){const r=this;let i,o;return s;function s(f){return!Sa(f)||!Gm.call(r,r.previous)||Hc(r.events)?n(f):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),l(f))}function l(f){return Sa(f)?(t.consume(f),l):f===64?(t.consume(f),a):n(f)}function a(f){return f===46?t.check(yN,u,c)(f):f===45||f===95||Re(f)?(o=!0,t.consume(f),a):u(f)}function c(f){return t.consume(f),i=!0,a}function u(f){return o&&i&&Ce(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(f)):n(f)}}function xN(t,e,n){const r=this;return i;function i(s){return s!==87&&s!==119||!Jm.call(r,r.previous)||Hc(r.events)?n(s):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(gN,t.attempt(jm,t.attempt(Hm,o),n),n)(s))}function o(s){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(s)}}function wN(t,e,n){const r=this;let i="",o=!1;return s;function s(f){return(f===72||f===104)&&Um.call(r,r.previous)&&!Hc(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),t.consume(f),l):n(f)}function l(f){if(Ce(f)&&i.length<5)return i+=String.fromCodePoint(f),t.consume(f),l;if(f===58){const d=i.toLowerCase();if(d==="http"||d==="https")return t.consume(f),a}return n(f)}function a(f){return f===47?(t.consume(f),o?c:(o=!0,a)):n(f)}function c(f){return f===null||ts(f)||se(f)||Gn(f)||fo(f)?n(f):t.attempt(jm,t.attempt(Hm,u),n)(f)}function u(f){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(f)}}function CN(t,e,n){let r=0;return i;function i(s){return(s===87||s===119)&&r<3?(r++,t.consume(s),i):s===46&&r===3?(t.consume(s),o):n(s)}function o(s){return s===null?n(s):e(s)}}function SN(t,e,n){let r,i,o;return s;function s(c){return c===46||c===95?t.check(qm,a,l)(c):c===null||se(c)||Gn(c)||c!==45&&fo(c)?a(c):(o=!0,t.consume(c),s)}function l(c){return c===95?r=!0:(i=r,r=void 0),t.consume(c),s}function a(c){return i||r||!o?n(c):e(c)}}function MN(t,e){let n=0,r=0;return i;function i(s){return s===40?(n++,t.consume(s),i):s===41&&r<n?o(s):s===33||s===34||s===38||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===60||s===63||s===93||s===95||s===126?t.check(qm,e,o)(s):s===null||se(s)||Gn(s)?e(s):(t.consume(s),i)}function o(s){return s===41&&r++,t.consume(s),i}}function NN(t,e,n){return r;function r(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(t.consume(l),r):l===38?(t.consume(l),o):l===93?(t.consume(l),i):l===60||l===null||se(l)||Gn(l)?e(l):n(l)}function i(l){return l===null||l===40||l===91||se(l)||Gn(l)?e(l):r(l)}function o(l){return Ce(l)?s(l):n(l)}function s(l){return l===59?(t.consume(l),r):Ce(l)?(t.consume(l),s):n(l)}}function TN(t,e,n){return r;function r(o){return t.consume(o),i}function i(o){return Re(o)?n(o):e(o)}}function Jm(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||se(t)}function Um(t){return!Ce(t)}function Gm(t){return!(t===47||Sa(t))}function Sa(t){return t===43||t===45||t===46||t===95||Re(t)}function Hc(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const IN={tokenize:PN,partial:!0};function AN(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:DN,continuation:{tokenize:RN},exit:zN}},text:{91:{name:"gfmFootnoteCall",tokenize:ON},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:EN,resolveTo:vN}}}}function EN(t,e,n){const r=this;let i=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s;for(;i--;){const a=r.events[i][1];if(a.type==="labelImage"){s=a;break}if(a.type==="gfmFootnoteCall"||a.type==="labelLink"||a.type==="label"||a.type==="image"||a.type==="link")break}return l;function l(a){if(!s||!s._balanced)return n(a);const c=gt(r.sliceSerialize({start:s.end,end:r.now()}));return c.codePointAt(0)!==94||!o.includes(c.slice(1))?n(a):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(a),t.exit("gfmFootnoteCallLabelMarker"),e(a))}}function vN(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},l=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",i,e],["exit",i,e],["enter",o,e],["enter",s,e],["exit",s,e],["exit",o,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...l),t}function ON(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,s;return l;function l(f){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),a}function a(f){return f!==94?n(f):(t.enter("gfmFootnoteCallMarker"),t.consume(f),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(f){if(o>999||f===93&&!s||f===null||f===91||se(f))return n(f);if(f===93){t.exit("chunkString");const d=t.exit("gfmFootnoteCallString");return i.includes(gt(r.sliceSerialize(d)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(f)}return se(f)||(s=!0),o++,t.consume(f),f===92?u:c}function u(f){return f===91||f===92||f===93?(t.consume(f),o++,c):c(f)}}function DN(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,s=0,l;return a;function a(p){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(p),t.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(p){return p===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(p),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",u):n(p)}function u(p){if(s>999||p===93&&!l||p===null||p===91||se(p))return n(p);if(p===93){t.exit("chunkString");const m=t.exit("gfmFootnoteDefinitionLabelString");return o=gt(r.sliceSerialize(m)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(p),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),d}return se(p)||(l=!0),s++,t.consume(p),p===92?f:u}function f(p){return p===91||p===92||p===93?(t.consume(p),s++,u):u(p)}function d(p){return p===58?(t.enter("definitionMarker"),t.consume(p),t.exit("definitionMarker"),i.includes(o)||i.push(o),ie(t,h,"gfmFootnoteDefinitionWhitespace")):n(p)}function h(p){return e(p)}}function RN(t,e,n){return t.check(ho,e,t.attempt(IN,e,n))}function zN(t){t.exit("gfmFootnoteDefinition")}function PN(t,e,n){const r=this;return ie(t,i,"gfmFootnoteDefinitionIndent",5);function i(o){const s=r.events[r.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?e(o):n(o)}}function BN(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(s,l){let a=-1;for(;++a<s.length;)if(s[a][0]==="enter"&&s[a][1].type==="strikethroughSequenceTemporary"&&s[a][1]._close){let c=a;for(;c--;)if(s[c][0]==="exit"&&s[c][1].type==="strikethroughSequenceTemporary"&&s[c][1]._open&&s[a][1].end.offset-s[a][1].start.offset===s[c][1].end.offset-s[c][1].start.offset){s[a][1].type="strikethroughSequence",s[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},s[c][1].start),end:Object.assign({},s[a][1].end)},f={type:"strikethroughText",start:Object.assign({},s[c][1].end),end:Object.assign({},s[a][1].start)},d=[["enter",u,l],["enter",s[c][1],l],["exit",s[c][1],l],["enter",f,l]],h=l.parser.constructs.insideSpan.null;h&&mt(d,d.length,0,Ss(h,s.slice(c+1,a),l)),mt(d,d.length,0,[["exit",f,l],["enter",s[a][1],l],["exit",s[a][1],l],["exit",u,l]]),mt(s,c-1,a-c+3,d),a=c+d.length-2;break}}for(a=-1;++a<s.length;)s[a][1].type==="strikethroughSequenceTemporary"&&(s[a][1].type="data");return s}function o(s,l,a){const c=this.previous,u=this.events;let f=0;return d;function d(p){return c===126&&u[u.length-1][1].type!=="characterEscape"?a(p):(s.enter("strikethroughSequenceTemporary"),h(p))}function h(p){const m=Tt(c);if(p===126)return f>1?a(p):(s.consume(p),f++,h);if(f<2&&!n)return a(p);const y=s.exit("strikethroughSequenceTemporary"),g=Tt(p);return y._open=!g||g===2&&!!m,y._close=!m||m===2&&!!g,l(p)}}}class LN{constructor(){this.map=[],this.index=new Map}add(e,n,r){FN(this,e,n,r)}consume(e){if(this.map.sort(function(o,s){return o[0]-s[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const o of i)e.push(o);i=r.pop()}this.map.length=0,this.index.clear()}}function FN(t,e,n,r){if(n===0&&r.length===0)return;const i=t.index.get(e);if(i){i[1]+=n,i[2].push(...r);return}const o=[e,n,r];t.map.push(o),t.index.set(e,o)}function _N(t,e){let n=!1;const r=[];for(;e<t.length;){const i=t[e];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function $N(){return{flow:{null:{name:"table",tokenize:VN,resolveAll:jN}}}}function VN(t,e,n){const r=this;let i=0,o=0,s;return l;function l(M){let R=r.events.length-1;for(;R>-1;){const{type:V}=r.events[R][1];if(V==="lineEnding"||V==="linePrefix")R--;else break}const A=R>-1?r.events[R][1].type:null,L=A==="tableHead"||A==="tableRow"?S:a;return L===S&&r.parser.lazy[r.now().line]?n(M):L(M)}function a(M){return t.enter("tableHead"),t.enter("tableRow"),c(M)}function c(M){return M===124||(s=!0,o+=1),u(M)}function u(M){return M===null?n(M):j(M)?o>1?(o=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(M),t.exit("lineEnding"),h):n(M):X(M)?ie(t,u,"whitespace")(M):(o+=1,s&&(s=!1,i+=1),M===124?(t.enter("tableCellDivider"),t.consume(M),t.exit("tableCellDivider"),s=!0,u):(t.enter("data"),f(M)))}function f(M){return M===null||M===124||se(M)?(t.exit("data"),u(M)):(t.consume(M),M===92?d:f)}function d(M){return M===92||M===124?(t.consume(M),f):f(M)}function h(M){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(M):(t.enter("tableDelimiterRow"),s=!1,X(M)?ie(t,p,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):p(M))}function p(M){return M===45||M===58?y(M):M===124?(s=!0,t.enter("tableCellDivider"),t.consume(M),t.exit("tableCellDivider"),m):P(M)}function m(M){return X(M)?ie(t,y,"whitespace")(M):y(M)}function y(M){return M===58?(o+=1,s=!0,t.enter("tableDelimiterMarker"),t.consume(M),t.exit("tableDelimiterMarker"),g):M===45?(o+=1,g(M)):M===null||j(M)?E(M):P(M)}function g(M){return M===45?(t.enter("tableDelimiterFiller"),C(M)):P(M)}function C(M){return M===45?(t.consume(M),C):M===58?(s=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(M),t.exit("tableDelimiterMarker"),w):(t.exit("tableDelimiterFiller"),w(M))}function w(M){return X(M)?ie(t,E,"whitespace")(M):E(M)}function E(M){return M===124?p(M):M===null||j(M)?!s||i!==o?P(M):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(M)):P(M)}function P(M){return n(M)}function S(M){return t.enter("tableRow"),D(M)}function D(M){return M===124?(t.enter("tableCellDivider"),t.consume(M),t.exit("tableCellDivider"),D):M===null||j(M)?(t.exit("tableRow"),e(M)):X(M)?ie(t,D,"whitespace")(M):(t.enter("data"),F(M))}function F(M){return M===null||M===124||se(M)?(t.exit("data"),D(M)):(t.consume(M),M===92?Z:F)}function Z(M){return M===92||M===124?(t.consume(M),F):F(M)}}function jN(t,e){let n=-1,r=!0,i=0,o=[0,0,0,0],s=[0,0,0,0],l=!1,a=0,c,u,f;const d=new LN;for(;++n<t.length;){const h=t[n],p=h[1];h[0]==="enter"?p.type==="tableHead"?(l=!1,a!==0&&(dh(d,e,a,c,u),u=void 0,a=0),c={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},d.add(n,0,[["enter",c,e]])):p.type==="tableRow"||p.type==="tableDelimiterRow"?(r=!0,f=void 0,o=[0,0,0,0],s=[0,n+1,0,0],l&&(l=!1,u={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},d.add(n,0,[["enter",u,e]])),i=p.type==="tableDelimiterRow"?2:u?3:1):i&&(p.type==="data"||p.type==="tableDelimiterMarker"||p.type==="tableDelimiterFiller")?(r=!1,s[2]===0&&(o[1]!==0&&(s[0]=s[1],f=$o(d,e,o,i,void 0,f),o=[0,0,0,0]),s[2]=n)):p.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(s[0]=s[1],f=$o(d,e,o,i,void 0,f)),o=s,s=[o[1],n,0,0])):p.type==="tableHead"?(l=!0,a=n):p.type==="tableRow"||p.type==="tableDelimiterRow"?(a=n,o[1]!==0?(s[0]=s[1],f=$o(d,e,o,i,n,f)):s[1]!==0&&(f=$o(d,e,s,i,n,f)),i=0):i&&(p.type==="data"||p.type==="tableDelimiterMarker"||p.type==="tableDelimiterFiller")&&(s[3]=n)}for(a!==0&&dh(d,e,a,c,u),d.consume(e.events),n=-1;++n<e.events.length;){const h=e.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=_N(e.events,n))}return t}function $o(t,e,n,r,i,o){const s=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(o.end=Object.assign({},kr(e.events,n[0])),t.add(n[0],0,[["exit",o,e]]));const a=kr(e.events,n[1]);if(o={type:s,start:Object.assign({},a),end:Object.assign({},a)},t.add(n[1],0,[["enter",o,e]]),n[2]!==0){const c=kr(e.events,n[2]),u=kr(e.events,n[3]),f={type:l,start:Object.assign({},c),end:Object.assign({},u)};if(t.add(n[2],0,[["enter",f,e]]),r!==2){const d=e.events[n[2]],h=e.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){const p=n[2]+1,m=n[3]-n[2]-1;t.add(p,m,[])}}t.add(n[3]+1,0,[["exit",f,e]])}return i!==void 0&&(o.end=Object.assign({},kr(e.events,i)),t.add(i,0,[["exit",o,e]]),o=void 0),o}function dh(t,e,n,r,i){const o=[],s=kr(e.events,n);i&&(i.end=Object.assign({},s),o.push(["exit",i,e])),r.end=Object.assign({},s),o.push(["exit",r,e]),t.add(n+1,0,o)}function kr(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const HN={name:"tasklistCheck",tokenize:WN};function qN(){return{text:{91:HN}}}function WN(t,e,n){const r=this;return i;function i(a){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(a):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(a),t.exit("taskListCheckMarker"),o)}function o(a){return se(a)?(t.enter("taskListCheckValueUnchecked"),t.consume(a),t.exit("taskListCheckValueUnchecked"),s):a===88||a===120?(t.enter("taskListCheckValueChecked"),t.consume(a),t.exit("taskListCheckValueChecked"),s):n(a)}function s(a){return a===93?(t.enter("taskListCheckMarker"),t.consume(a),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),l):n(a)}function l(a){return j(a)?e(a):X(a)?t.check({tokenize:KN},e,n)(a):n(a)}}function KN(t,e,n){return ie(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function JN(t){return Ah([kN(),AN(),BN(t),$N(),qN()])}const UN={};function GN(t){const e=this,n=t||UN,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),s=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(JN(n)),o.push(pN()),s.push(mN(n))}function H(t,e){return Object.assign(t,{meta:{package:"@milkdown/preset-gfm",...e}}),t}var qc=wo("strike_through");H(qc,{displayName:"Attr<strikethrough>",group:"Strikethrough"});var Io=ei("strike_through",t=>({parseDOM:[{tag:"del"},{style:"text-decoration",getAttrs:e=>e==="line-through"}],toDOM:e=>["del",t.get(qc.key)(e)],parseMarkdown:{match:e=>e.type==="delete",runner:(e,n,r)=>{e.openMark(r),e.next(n.children),e.closeMark(r)}},toMarkdown:{match:e=>e.type.name==="strike_through",runner:(e,n)=>{e.withMark(n,"delete")}}}));H(Io.mark,{displayName:"MarkSchema<strikethrough>",group:"Strikethrough"});H(Io.ctx,{displayName:"MarkSchemaCtx<strikethrough>",group:"Strikethrough"});var Wc=K("ToggleStrikeThrough",t=>()=>Ds(Io.type(t)));H(Wc,{displayName:"Command<ToggleStrikethrough>",group:"Strikethrough"});var Ym=qe(t=>go(new RegExp("(?<![\\w:/])(~{1,2})(.+?)\\1(?!\\w|\\/)$"),Io.type(t)));H(Ym,{displayName:"InputRule<strikethrough>",group:"Strikethrough"});var Kc=We("strikeThroughKeymap",{ToggleStrikethrough:{shortcuts:"Mod-Alt-x",command:t=>{const e=t.get(ee);return()=>e.call(Wc.key)}}});H(Kc.ctx,{displayName:"KeymapCtx<strikethrough>",group:"Strikethrough"});H(Kc.shortcuts,{displayName:"Keymap<strikethrough>",group:"Strikethrough"});function Qm(t,e){const n=e.content.firstChild;if(e.childCount!==1||(n==null?void 0:n.type.name)!=="paragraph"){t.next(e.content);return}const r=n.lastChild,i=(r==null?void 0:r.type.name)==="hardbreak"?n.content.cut(0,n.content.size-r.nodeSize):n.content;t.next(i)}var Ao=lS({tableGroup:"block",cellContent:"paragraph",cellAttributes:{alignment:{default:"left",getFromDOM:t=>t.style.textAlign||"left",setDOMAttr:(t,e)=>{e.style=`text-align: ${t||"left"}`}}}}),en=ge("table",()=>({...Ao.table,content:"table_header_row table_row+",disableDropCursor:!0,parseMarkdown:{match:t=>t.type==="table",runner:(t,e,n)=>{const r=e.align,i=e.children.map((o,s)=>({...o,align:r,isHeader:s===0}));t.openNode(n),t.next(i),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="table",runner:(t,e)=>{var i;const n=(i=e.content.firstChild)==null?void 0:i.content;if(!n)return;const r=[];n.forEach(o=>{r.push(o.attrs.alignment)}),t.openNode("table",void 0,{align:r}),t.next(e.content),t.closeNode()}}}));H(en.node,{displayName:"NodeSchema<table>",group:"Table"});H(en.ctx,{displayName:"NodeSchemaCtx<table>",group:"Table"});var Eo=ge("table_header_row",()=>({...Ao.table_row,disableDropCursor:!0,content:"(table_header)*",parseDOM:[{tag:"tr[data-is-header]"},{tag:"tr",getAttrs:t=>t instanceof HTMLElement&&t.querySelector("th")?{}:!1}],toDOM(){return["tr",{"data-is-header":!0},0]},parseMarkdown:{match:t=>!!(t.type==="tableRow"&&t.isHeader),runner:(t,e,n)=>{const r=e.align,i=e.children.map((o,s)=>({...o,align:r[s],isHeader:e.isHeader}));t.openNode(n),t.next(i),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="table_header_row",runner:(t,e)=>{e.content.size!==0&&(t.openNode("tableRow",void 0,{isHeader:!0}),t.next(e.content),t.closeNode())}}}));H(Eo.node,{displayName:"NodeSchema<tableHeaderRow>",group:"Table"});H(Eo.ctx,{displayName:"NodeSchemaCtx<tableHeaderRow>",group:"Table"});var ii=ge("table_row",()=>({...Ao.table_row,disableDropCursor:!0,content:"(table_cell)*",parseMarkdown:{match:t=>t.type==="tableRow",runner:(t,e,n)=>{const r=e.align,i=e.children.map((o,s)=>({...o,align:r[s]}));t.openNode(n),t.next(i),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="table_row",runner:(t,e)=>{e.content.size!==0&&(t.openNode("tableRow"),t.next(e.content),t.closeNode())}}}));H(ii.node,{displayName:"NodeSchema<tableRow>",group:"Table"});H(ii.ctx,{displayName:"NodeSchemaCtx<tableRow>",group:"Table"});var vo=ge("table_cell",()=>({...Ao.table_cell,disableDropCursor:!0,parseMarkdown:{match:t=>t.type==="tableCell"&&!t.isHeader,runner:(t,e,n)=>{const r=e.align;t.openNode(n,{alignment:r}).openNode(t.schema.nodes.paragraph).next(e.children).closeNode().closeNode()}},toMarkdown:{match:t=>t.type.name==="table_cell",runner:(t,e)=>{t.openNode("tableCell"),Qm(t,e),t.closeNode()}}}));H(vo.node,{displayName:"NodeSchema<tableCell>",group:"Table"});H(vo.ctx,{displayName:"NodeSchemaCtx<tableCell>",group:"Table"});var Xr=ge("table_header",()=>({...Ao.table_header,disableDropCursor:!0,parseMarkdown:{match:t=>t.type==="tableCell"&&!!t.isHeader,runner:(t,e,n)=>{const r=e.align;t.openNode(n,{alignment:r}),t.openNode(t.schema.nodes.paragraph),t.next(e.children),t.closeNode(),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="table_header",runner:(t,e)=>{t.openNode("tableCell"),Qm(t,e),t.closeNode()}}}));H(Xr.node,{displayName:"NodeSchema<tableHeader>",group:"Table"});H(Xr.ctx,{displayName:"NodeSchemaCtx<tableHeader>",group:"Table"});function Xm(t,e=3,n=3){const r=Array(n).fill(0).map(()=>vo.type(t).createAndFill()),i=Array(n).fill(0).map(()=>Xr.type(t).createAndFill()),o=Array(e).fill(0).map((s,l)=>l===0?Eo.type(t).create(null,i):ii.type(t).create(null,r));return en.type(t).create(null,o)}function Zm(t){return(e,n)=>r=>{n=n??r.selection.from;const i=r.doc.resolve(n),o=lx(a=>a.type.name==="table")(i),s=o?{node:o.node,from:o.start}:void 0,l=t==="row";if(s){const a=oe.get(s.node);if(e>=0&&e<(l?a.height:a.width)){const c=a.positionAt(l?e:a.height-1,l?a.width-1:e,s.node),u=r.doc.resolve(s.from+c),f=l?ae.rowSelection:ae.colSelection,d=a.positionAt(l?e:0,l?0:e,s.node),h=r.doc.resolve(s.from+d);return tp(r.setSelection(f(u,h)))}}return r}}var YN=Zm("row"),QN=Zm("col");function eg(t,e,{map:n,tableStart:r,table:i},o){const s=Array(o).fill(0).reduce((a,c,u)=>a+i.child(u).nodeSize,r),l=Array(n.width).fill(0).map((a,c)=>{const u=i.nodeAt(n.map[c]);return vo.type(t).createAndFill({alignment:u==null?void 0:u.attrs.alignment})});return e.insert(s,ii.type(t).create(null,l)),e}function XN(t){const e=To(t.$from);if(!e)return;const n=oe.get(e.node);return n.cellsInRect({left:0,right:n.width,top:0,bottom:n.height}).map(r=>{const i=e.node.nodeAt(r),o=r+e.start;return{pos:o,start:o+1,node:i}})}function ZN(t){const e=XN(t.selection);if(e&&e[0]){const n=t.doc.resolve(e[0].pos),r=e[e.length-1];if(r){const i=t.doc.resolve(r.pos);return tp(t.setSelection(new ae(i,n)))}}return t}var Jc=K("GoToPrevTableCell",()=>()=>Pm(-1));H(Jc,{displayName:"Command<goToPrevTableCellCommand>",group:"Table"});var Uc=K("GoToNextTableCell",()=>()=>Pm(1));H(Uc,{displayName:"Command<goToNextTableCellCommand>",group:"Table"});var Gc=K("ExitTable",t=>()=>(e,n)=>{if(!ut(e))return!1;const{$head:r}=e.selection,i=ox(r,en.type(t));if(!i)return!1;const{to:o}=i,s=e.tr.replaceWith(o,o,At.type(t).createAndFill());return s.setSelection(q.near(s.doc.resolve(o),1)).scrollIntoView(),n==null||n(s),!0});H(Gc,{displayName:"Command<breakTableCommand>",group:"Table"});var tg=K("InsertTable",t=>({row:e,col:n}={})=>(r,i)=>{const{selection:o,tr:s}=r,{from:l}=o,a=Xm(t,e,n),c=s.replaceSelectionWith(a),u=q.findFrom(c.doc.resolve(l),1,!0);return u&&c.setSelection(u),i==null||i(c),!0});H(tg,{displayName:"Command<insertTableCommand>",group:"Table"});var ng=K("MoveRow",()=>({from:t,to:e,pos:n}={})=>PS({from:t??0,to:e??0,pos:n}));H(ng,{displayName:"Command<moveRowCommand>",group:"Table"});var rg=K("MoveCol",()=>({from:t,to:e,pos:n}={})=>BS({from:t??0,to:e??0,pos:n}));H(rg,{displayName:"Command<moveColCommand>",group:"Table"});var ig=K("SelectRow",()=>(t={index:0})=>(e,n)=>{const{tr:r}=e;return!!(n==null?void 0:n(YN(t.index,t.pos)(r)))});H(ig,{displayName:"Command<selectRowCommand>",group:"Table"});var og=K("SelectCol",()=>(t={index:0})=>(e,n)=>{const{tr:r}=e;return!!(n==null?void 0:n(QN(t.index,t.pos)(r)))});H(og,{displayName:"Command<selectColCommand>",group:"Table"});var sg=K("SelectTable",()=>()=>(t,e)=>{const{tr:n}=t;return!!(e==null?void 0:e(ZN(n)))});H(sg,{displayName:"Command<selectTableCommand>",group:"Table"});var lg=K("DeleteSelectedCells",()=>()=>(t,e)=>{const{selection:n}=t;if(!(n instanceof ae))return!1;const r=n.isRowSelection(),i=n.isColSelection();return r&&i?zS(t,e):i?AS(t,e):vS(t,e)});H(lg,{displayName:"Command<deleteSelectedCellsCommand>",group:"Table"});var ag=K("AddColBefore",()=>()=>NS);H(ag,{displayName:"Command<addColBeforeCommand>",group:"Table"});var cg=K("AddColAfter",()=>()=>TS);H(cg,{displayName:"Command<addColAfterCommand>",group:"Table"});var ug=K("AddRowBefore",t=>()=>(e,n)=>{if(!ut(e))return!1;if(n){const r=In(e);n(eg(t,e.tr,r,r.top))}return!0});H(ug,{displayName:"Command<addRowBeforeCommand>",group:"Table"});var fg=K("AddRowAfter",t=>()=>(e,n)=>{if(!ut(e))return!1;if(n){const r=In(e);n(eg(t,e.tr,r,r.bottom))}return!0});H(fg,{displayName:"Command<addRowAfterCommand>",group:"Table"});var hg=K("SetAlign",()=>(t="left")=>OS("alignment",t));H(hg,{displayName:"Command<setAlignCommand>",group:"Table"});var dg=qe(t=>new tt(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(e,n,r,i)=>{var a,c;const o=e.doc.resolve(r);if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),en.type(t)))return null;const s=Xm(t,Math.max(Number(((a=n.groups)==null?void 0:a.row)??0),2),Number((c=n.groups)==null?void 0:c.col)),l=e.tr.replaceRangeWith(r,i,s);return l.setSelection(G.create(l.doc,r+3)).scrollIntoView()}));H(dg,{displayName:"InputRule<insertTableInputRule>",group:"Table"});var pg=dC(t=>({run:(e,n,r)=>{if(r)return e;function i(c){var y;const u=c.childCount,f=((y=c.lastChild)==null?void 0:y.childCount)??0;if(u===0||f===0)return At.type(t).create();const d=c.firstChild;if(!(f>0&&d&&d.childCount===0))return c;if(u>=3){const g=c.child(1),C=[];for(let P=0;P<g.childCount;P++){const S=g.child(P);C.push(Xr.type(t).create(S.attrs,S.content,S.marks))}const w=d.type.create(d.attrs,C),E=[];for(let P=2;P<u;P++)E.push(c.child(P));return c.type.create(c.attrs,[w,...E])}const h=Array(f).fill(0).map(()=>Xr.type(t).createAndFill()),p=new z(I.from(h),0,0),m=d.replace(0,0,p);return c.replace(0,d.nodeSize,new z(I.from(m),0,0))}function o(c){const u=ii.type(t),f=[];let d=[],h=!1;function p(){if(d.length===0)return;const m=Eo.type(t).createAndFill(),y=en.type(t).create(null,[m,...d]);f.push(i(y)),d=[]}return c.forEach(m=>{m.type===u?(h=!0,d.push(m)):(p(),f.push(m))}),p(),h?I.from(f):c}function s(c){let u=o(c),f=u!==c;const d=[];return u.forEach(h=>{if(h.type===en.type(t)){const p=i(h);p!==h&&(f=!0),d.push(p)}else if(h.childCount>0){const p=s(h.content);p!==h.content?(f=!0,d.push(h.copy(p))):d.push(h)}else d.push(h)}),f?I.from(d):c}function l(c){const u=[],f=[];c.forEach(d=>f.push(d));for(let d=0;d<f.length;d++){const h=f[d],p=f[d+1];h.type===At.type(t)&&h.content.size===0&&p&&p.type===en.type(t)||u.push(h)}return u.length<f.length?I.from(u):c}let a=s(e.content);return a=l(a),new z(I.from(a),e.openStart,e.openEnd)}}));H(pg,{displayName:"PasteRule<table>",group:"Table"});var Yc=We("tableKeymap",{NextCell:{priority:100,shortcuts:["Mod-]","Tab"],command:t=>{const e=t.get(ee);return()=>e.call(Uc.key)}},PrevCell:{shortcuts:["Mod-[","Shift-Tab"],command:t=>{const e=t.get(ee);return()=>e.call(Jc.key)}},ExitTable:{shortcuts:["Mod-Enter","Enter"],command:t=>{const e=t.get(ee);return()=>e.call(Gc.key)}}});H(Yc.ctx,{displayName:"KeymapCtx<table>",group:"Table"});H(Yc.shortcuts,{displayName:"Keymap<table>",group:"Table"});var zl="footnote_definition",ph="footnoteDefinition",Qc=ge("footnote_definition",()=>({group:"block",content:"block+",defining:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`dl[data-type="${zl}"]`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw Et(t);return{label:t.dataset.label}},contentElement:"dd"}],toDOM:t=>{const e=t.attrs.label;return["dl",{"data-label":e,"data-type":zl},["dt",e],["dd",0]]},parseMarkdown:{match:({type:t})=>t===ph,runner:(t,e,n)=>{t.openNode(n,{label:e.label}).next(e.children).closeNode()}},toMarkdown:{match:t=>t.type.name===zl,runner:(t,e)=>{t.openNode(ph,void 0,{label:e.attrs.label,identifier:e.attrs.label}).next(e.content).closeNode()}}}));H(Qc.ctx,{displayName:"NodeSchemaCtx<footnodeDef>",group:"footnote"});H(Qc.node,{displayName:"NodeSchema<footnodeDef>",group:"footnote"});var Pl="footnote_reference",Xc=ge("footnote_reference",()=>({group:"inline",inline:!0,atom:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`sup[data-type="${Pl}"]`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw Et(t);return{label:t.dataset.label}}}],toDOM:t=>{const e=t.attrs.label;return["sup",{"data-label":e,"data-type":Pl},e]},parseMarkdown:{match:({type:t})=>t==="footnoteReference",runner:(t,e,n)=>{t.addNode(n,{label:e.label})}},toMarkdown:{match:t=>t.type.name===Pl,runner:(t,e)=>{t.addNode("footnoteReference",void 0,void 0,{label:e.attrs.label,identifier:e.attrs.label})}}}));H(Xc.ctx,{displayName:"NodeSchemaCtx<footnodeRef>",group:"footnote"});H(Xc.node,{displayName:"NodeSchema<footnodeRef>",group:"footnote"});var Zc=at.extendSchema(t=>e=>{const n=t(e);return{...n,attrs:{...n.attrs,checked:{default:null,validate:"boolean|null"}},parseDOM:[{tag:'li[data-item-type="task"]',getAttrs:r=>{if(!(r instanceof HTMLElement))throw Et(r);return{label:r.dataset.label,listType:r.dataset.listType,spread:r.dataset.spread==="true",checked:r.dataset.checked?r.dataset.checked==="true":null}}},...(n==null?void 0:n.parseDOM)||[]],toDOM:r=>n.toDOM&&r.attrs.checked==null?n.toDOM(r):["li",{"data-item-type":"task","data-label":r.attrs.label,"data-list-type":r.attrs.listType,"data-spread":r.attrs.spread,"data-checked":r.attrs.checked},0],parseMarkdown:{match:({type:r})=>r==="listItem",runner:(r,i,o)=>{if(i.checked==null){n.parseMarkdown.runner(r,i,o);return}const s=i.label!=null?`${i.label}.`:"•",l=i.checked!=null?!!i.checked:null,a=i.label!=null?"ordered":"bullet",c=i.spread??!0;r.openNode(o,{label:s,listType:a,spread:c,checked:l}),r.next(i.children),r.closeNode()}},toMarkdown:{match:r=>r.type.name==="list_item",runner:(r,i)=>{if(i.attrs.checked==null){n.toMarkdown.runner(r,i);return}const o=i.attrs.label,s=i.attrs.listType,l=i.attrs.spread,a=i.attrs.checked;r.openNode("listItem",void 0,{label:o,listType:s,spread:l,checked:a}),r.next(i.content),r.closeNode()}}}});H(Zc.node,{displayName:"NodeSchema<taskListItem>",group:"ListItem"});H(Zc.ctx,{displayName:"NodeSchemaCtx<taskListItem>",group:"ListItem"});var mg=qe(()=>new tt(/^\[(?<checked>\s|x)\]\s$/,(t,e,n,r)=>{var u;const i=t.doc.resolve(n);let o=0,s=i.node(o);for(;s&&s.type.name!=="list_item";)o--,s=i.node(o);if(!s||s.attrs.checked!=null)return null;const l=((u=e.groups)==null?void 0:u.checked)==="x",a=i.before(o),c=t.tr;return c.deleteRange(n,r).setNodeMarkup(a,void 0,{...s.attrs,checked:l}),c}));H(mg,{displayName:"InputRule<wrapInTaskListInputRule>",group:"ListItem"});var eT=[Kc,Yc].flat(),tT=[dg,mg],nT=[Ym],rT=[pg],gg=He(()=>fM);H(gg,{displayName:"Prose<autoInsertSpanPlugin>",group:"Prose"});var iT=He(()=>KS({}));H(iT,{displayName:"Prose<columnResizingPlugin>",group:"Prose"});var yg=He(()=>nM({allowTableNodeSelection:!0}));H(yg,{displayName:"Prose<tableEditingPlugin>",group:"Prose"});var eu=sr("remarkGFM",()=>GN);H(eu.plugin,{displayName:"Remark<remarkGFMPlugin>",group:"Remark"});H(eu.options,{displayName:"RemarkConfig<remarkGFMPlugin>",group:"Remark"});var oT=new Te("MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN");function sT(t,e){let n=0;return e.forEach((r,i,o)=>{r===t&&(n=o)}),n}function lT(t,e){const n=t.content.findDiffStart(e.content);if(n==null)return null;const r=t.content.findDiffEnd(e.content);return r?{from:n,to:Math.max(r.b,n)}:null}var kg=He(()=>new Ne({key:oT,appendTransaction:(t,e,n)=>{if(e.doc===n.doc)return;const r=lT(e.doc,n.doc);if(!r)return;let i;const o=(s,l)=>{if(s.type.name!=="table_cell")return;const a=n.doc.resolve(l),c=a.node(a.depth),u=a.node(a.depth-1).firstChild;if(!u)return;const f=sT(s,c),d=u.maybeChild(f);if(!d)return;const h=d.attrs.alignment;h!==s.attrs.alignment&&(i||(i=n.tr),i.setNodeMarkup(l,void 0,{...s.attrs,alignment:h}))};return n.doc.nodesBetween(r.from,r.to,(s,l)=>s.type.name!=="table"?!0:(n.doc.nodesBetween(l,l+s.nodeSize,o),!1)),i}}));H(kg,{displayName:"Prose<keepTableAlignPlugin>",group:"Prose"});var aT=[kg,gg,eu,yg].flat(),cT=[Zc,en,Eo,ii,Xr,vo,Qc,Xc,qc,Io].flat(),uT=[Uc,Jc,Gc,tg,ng,rg,ig,og,sg,lg,ug,fg,ag,cg,hg,Wc],fT=[cT,tT,rT,nT,eT,uT,aT].flat(),bs=200,ke=function(){};ke.prototype.append=function(e){return e.length?(e=ke.from(e),!this.length&&e||e.length<bs&&this.leafAppend(e)||this.length<bs&&e.leafPrepend(this)||this.appendInner(e)):this};ke.prototype.prepend=function(e){return e.length?ke.from(e).append(this):this};ke.prototype.appendInner=function(e){return new hT(this,e)};ke.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?ke.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ke.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ke.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};ke.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},n,r),i};ke.from=function(e){return e instanceof ke?e:e&&e.length?new bg(e):ke.empty};var bg=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a<s;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,l){for(var a=o-1;a>=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=bs)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=bs)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(ke);ke.empty=new bg([]);var hT=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(r,i):r>=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ke);const dT=500;class pt{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;n&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((f,d)=>{if(!f.step){i||(i=this.remapping(r,d+1),o=i.maps.length),o--,u.push(f);return}if(i){u.push(new wt(f.map));let h=f.step.map(i.slice(o)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new wt(p,void 0,void 0,c.length+u.length))),o--,p&&i.appendMap(p,o)}else s.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(o)):f.selection,a=new pt(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,n,r,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),d=new wt(e.mapping.maps[u],f,n),h;(h=a&&a.merge(d))&&(d=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(d),n&&(s++,n=void 0),i||(a=d)}let c=s-r.depth;return c>mT&&(l=pT(l,c),s-=c),new pt(l.append(o),s)}remapping(e,n){let r=new Pi;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new pt(this.items.append(e.map(n=>new wt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],i=this.items.length-n,o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},i);let a=n;this.items.forEach(d=>{let h=o.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=o.maps[h];if(d.step){let m=e.steps[h].invert(e.docs[h]),y=d.selection&&d.selection.map(o.slice(a+1,h));y&&l++,r.push(new wt(p,m,y))}else r.push(new wt(p))},i);let c=[];for(let d=n;d<s;d++)c.push(new wt(o.maps[d]));let u=this.items.slice(0,i).append(c).append(r),f=new pt(u,l);return f.emptyItemCount()>dT&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=s.selection&&s.selection.map(n.slice(r));u&&o++;let f=new wt(c.invert(),a,u),d,h=i.length-1;(d=i.length&&i[h].merge(f))?i[h]=d:i.push(f)}}else s.map&&r--},this.items.length,0),new pt(ke.from(i.reverse()),o)}}pt.empty=new pt(ke.empty,0);function pT(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class wt{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new wt(n.getMap().invert(),n,this.selection)}}}class un{constructor(e,n,r,i,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const mT=20;function gT(t,e,n,r){let i=n.getMeta(Wn),o;if(i)return i.historyState;n.getMeta(bT)&&(t=new un(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Wn))return s.getMeta(Wn).redo?new un(t.done.addTransform(n,void 0,r,es(e)),t.undone,mh(n.mapping.maps),t.prevTime,t.prevComposition):new un(t.done,t.undone.addTransform(n,void 0,r,es(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!s&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!yT(n,t.prevRanges)),c=s?Bl(t.prevRanges,n.mapping):mh(n.mapping.maps);return new un(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,es(e)),pt.empty,c,n.time,l??t.prevComposition)}else return(o=n.getMeta("rebased"))?new un(t.done.rebased(n,o),t.undone.rebased(n,o),Bl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new un(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Bl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function yT(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&i>=e[o]&&(n=!0)}),n}function mh(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,o,s)=>e.push(o,s));return e}function Bl(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),o=e.map(t[r+1],-1);i<=o&&n.push(i,o)}return n}function kT(t,e,n){let r=es(e),i=Wn.get(e).spec.config,o=(n?t.undone:t.done).popEvent(e,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(n?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),i,r),a=new un(n?l:o.remaining,n?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(Wn,{redo:n,historyState:a})}let Ll=!1,gh=null;function es(t){let e=t.plugins;if(gh!=e){Ll=!1,gh=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Ll=!0;break}}return Ll}const Wn=new Te("history"),bT=new Te("closeHistory");function xT(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Ne({key:Wn,state:{init(){return new un(pt.empty,pt.empty,null,0,-1)},apply(e,n,r){return gT(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?wg:r=="historyRedo"?Cg:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function xg(t,e){return(n,r)=>{let i=Wn.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let o=kT(i,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const wg=xg(!1,!0),Cg=xg(!0,!0);function oi(t,e){return Object.assign(t,{meta:{package:"@milkdown/plugin-history",...e}}),t}var tu=K("Undo",()=>()=>wg);oi(tu,{displayName:"Command<undo>"});var nu=K("Redo",()=>()=>Cg);oi(nu,{displayName:"Command<redo>"});var ru=Ot({},"historyProviderConfig");oi(ru,{displayName:"Ctx<historyProviderConfig>"});var Sg=He(t=>xT(t.get(ru.key)));oi(Sg,{displayName:"Ctx<historyProviderPlugin>"});var iu=We("historyKeymap",{Undo:{shortcuts:"Mod-z",command:t=>{const e=t.get(ee);return()=>e.call(tu.key)}},Redo:{shortcuts:["Mod-y","Shift-Mod-z"],command:t=>{const e=t.get(ee);return()=>e.call(nu.key)}}});oi(iu.ctx,{displayName:"KeymapCtx<history>"});oi(iu.shortcuts,{displayName:"Keymap<history>"});var wT=[ru,Sg,iu,tu,nu].flat();function Ma(t){if(!t)return!1;if(Array.isArray(t))return t.length>1?!1:Ma(t[0]);const e=t.content;return e?Ma(e):t.type==="text"}function CT(t,e){return Object.assign(t,{meta:{package:"@milkdown/plugin-clipboard",...e}}),t}function yh(t,e){const n=rx(e);if(n)return t.dispatch(t.state.tr.replaceSelectionWith(n,!0)),!0;try{return t.dispatch(t.state.tr.replaceSelection(e)),!0}catch{return!1}}var Mg=He(t=>{const e=t.get(Zt);t.update(Oi,r=>({...r,editable:r.editable??(()=>!0),transformPastedHTML:(i,o)=>{const s=r.transformPastedHTML;return s&&(i=s(i,o)),i.includes("docs-internal-guid")&&(i=i.replace(/<b[^>]*id="docs-internal-guid[^"]*"[^>]*>([\s\S]*)<\/b>/,"$1"),i=i.replace(/<div[^>]*>(<table[\s\S]*?<\/table>)<\/div>/g,"$1")),i}}));const n=new Te("MILKDOWN_CLIPBOARD");return new Ne({key:n,props:{handlePaste:(r,i,o)=>{var p,m,y;const s=t.get(Ei),l=(m=(p=r.props).editable)==null?void 0:m.call(p,r.state),{clipboardData:a}=i;if(!l||!a||r.state.selection.$from.node().type.spec.code)return!1;const c=a.getData("text/plain"),u=a.getData("vscode-editor-data");if(u){const g=(y=JSON.parse(u))==null?void 0:y.mode;if(c&&g){const{tr:C}=r.state,w=sx("code_block",e);return C.replaceSelectionWith(w.create({language:g})).setSelection(G.near(C.doc.resolve(Math.max(0,C.selection.from-2)))).insertText(c.replace(/\r\n?/g,`
|
|
55
|
-
`)),r.dispatch(C),!0}}const f=a.getData("text/html");if(f.length===0&&c.length===0)return!1;if(f.length>0&&o)return yh(r,o);const d=Xn.fromSchema(e);let h;if(f.length===0){const g=s(c);if(!g||typeof g=="string")return!1;h=or.fromSchema(e).serializeFragment(g.content)}else{const g=document.createElement("template");g.innerHTML=f,h=g.content.cloneNode(!0),g.remove()}return yh(r,d.parseSlice(h))},clipboardTextSerializer:r=>{const i=t.get(vi);if(Ma(r.content.toJSON()))return r.content.textBetween(0,r.content.size,`
|
|
56
|
-
|
|
57
|
-
`);const o=e.topNodeType.createAndFill(void 0,r.content);return o?i(o):""}}})});CT(Mg,{displayName:"Prose<clipboard>"});const ST={strong:!1,em:!1,code:!1,link:!1,heading:0,bullet:!1,ordered:!1,quote:!1,codeBlock:!1};function kh(t,e){const n=t.parent,r=t.start();let i=null,o=null;return n.forEach((s,l)=>{const a=s.marks.find(u=>u.type===e),c=r+l;if(a){const u=String(a.attrs.href??"");o&&o.href===u&&o.to===c?o.to=c+s.nodeSize:o={from:c,to:c+s.nodeSize,href:u},t.pos>=o.from&&t.pos<=o.to&&(i={...o})}else o=null}),i}function MT(t){const e=t.trim();return e?/^[a-z][a-z0-9+.-]*:/i.test(e)||/^[/#.?]/.test(e)?e:/^[\w-]+(\.[\w-]+)+(\/|$|:)/.test(e)?`https://${e}`:e:""}function NT(t,e){const{state:n}=t,{$from:r,from:i,to:o,empty:s}=n.selection,l=u=>s?!!(n.storedMarks??r.marks()).some(f=>f.type===u):n.doc.rangeHasMark(i,o,u),a=new Set;for(let u=r.depth;u>0;u-=1)a.add(r.node(u).type.name);const c=r.parent.type===Dt.type(e)?Number(r.parent.attrs.level):0;return{strong:l(ti.type(e)),em:l(lr.type(e)),code:l(Yt.type(e)),link:l(Mt.type(e)),heading:c,bullet:a.has(nn.type(e).name),ordered:a.has(rn.type(e).name),quote:a.has(ni.type(e).name),codeBlock:r.parent.type===ri.type(e)}}function bh(t){const e=document.createElement("span");e.className="md-img",e.contentEditable="false";const n=document.createElement("img");n.draggable=!1,e.append(n);let r="",i;const o=()=>{const s=Fg(t.path,r);let l="ok",a="";if(s.kind==="outside")l="blocked",a=`Путь вне проекта: ${r}`;else if(s.kind==="project"){const u=t.images[s.path];if(!u)l="loading",a=`Загружается: ${s.path}`,t.requestImage(s.path);else if("error"in u)l="missing",a=`Нет файла: ${s.path}`;else{const f=_g(u);n.getAttribute("src")!==f&&n.setAttribute("src",f)}}else n.getAttribute("src")!==r&&n.setAttribute("src",r);e.dataset.state=l,n.hidden=l!=="ok",n.style.width=i?`${i}px`:"";let c=e.querySelector(".md-img__ph");l==="ok"?c==null||c.remove():(c||(c=document.createElement("span"),c.className="md-img__ph",e.prepend(c)),c.textContent=a)};return t.imageViews.add(o),{dom:e,set(s,l,a){r=s,i=a,n.alt=l,o()},dispose:()=>t.imageViews.delete(o)}}function TT(t){const e=Jf(Nt.node,()=>r=>{const i=bh(t);return i.set(String(r.attrs.src),String(r.attrs.alt)),{dom:i.dom,selectNode:()=>i.dom.classList.add("is-selected"),deselectNode:()=>i.dom.classList.remove("is-selected"),update:o=>o.type!==r.type?!1:(i.set(String(o.attrs.src),String(o.attrs.alt)),!0),destroy:i.dispose}}),n=Jf(Hs.node,()=>r=>{const i=a=>{const c=/^\s*<img\b/i.test(a)?Pg(a)[0]:void 0;if(c){const f=bh(t);return f.set(c.src,c.alt,c.width),f.dom.title=a,{dom:f.dom,dispose:f.dispose}}const u=document.createElement("span");return u.className="mdtext-html",u.contentEditable="false",u.textContent=a.length>80?`${a.slice(0,77)}…`:a,u.title=`HTML сохранится как есть:
|
|
58
|
-
${a}`,{dom:u,dispose:()=>{}}};let o=String(r.attrs.value),s=i(o);const l=document.createElement("span");return l.className="mdtext-htmlwrap",l.append(s.dom),{dom:l,selectNode:()=>l.classList.add("is-selected"),deselectNode:()=>l.classList.remove("is-selected"),update:a=>{if(a.type!==r.type)return!1;const c=String(a.attrs.value);return c!==o&&(o=c,s.dispose(),s=i(c),l.replaceChildren(s.dom)),!0},stopEvent:()=>!1,ignoreMutation:()=>!0,destroy:()=>s.dispose()}});return[e,n]}function IT(t,e,n){const r=new Te("ccv-text-edited"),i=He(l=>{let a;return new Ne({key:r,state:{init:()=>!1,apply:(c,u)=>u||c.docChanged&&c.getMeta("addToHistory")!==!1},view:()=>({update(c,u){n(NT(c,l)),r.getState(c.state)&&!u.doc.eq(c.state.doc)&&(clearTimeout(a),a=setTimeout(()=>e.flush(),160))},destroy(){clearTimeout(a)}})})}),o=He(l=>{const a=f=>()=>(e.call(f),!0),c=f=>a((d,h)=>{const p=h.state.selection.$from.parent,m=p.type===Dt.type(d)&&p.attrs.level===f;d.get(ee).call(m?Yr.key:Ct.key,f)}),u=(f,d)=>a((h,p)=>{const{$from:m}=p.state.selection;for(let y=m.depth;y>0;y-=1)if(m.node(y).type===f(h)){tc(at.type(h))(p.state,p.dispatch);return}h.get(ee).call(d)});return np({"Mod-1":c(1),"Mod-2":c(2),"Mod-3":c(3),"Mod-0":a(f=>f.get(ee).call(Yr.key)),"Mod-Shift-8":u(f=>nn.type(f),Mo.key),"Mod-Shift-7":u(f=>rn.type(f),No.key),"Mod-k":()=>(e.openLink(),!0),"Mod-s":()=>(e.flush(!0),!0)})}),s=He(l=>{const a=(c,u,f)=>{let d=c.state.tr;u!==null&&(d=d.setSelection(q.near(d.doc.resolve(u)))),c.dispatch(d.replaceSelectionWith(f,!1).scrollIntoView()),c.focus()};return new Ne({props:{handleDOMEvents:{dragover(c,u){return pu(u.dataTransfer)?(u.preventDefault(),u.dataTransfer&&(u.dataTransfer.dropEffect="copy"),!0):!1}},handleDrop(c,u){var g;if(!pu(u.dataTransfer))return!1;const f=Bg(u.dataTransfer);if(!f)return!1;u.preventDefault();const d=/^(!)?\[([^\]]*)\]\((.*)\)$/.exec(Lg(t.path,f.path,f.kind));if(!d)return!0;const h=((g=c.posAtCoords({left:u.clientX,top:u.clientY}))==null?void 0:g.pos)??null,[,p,m="",y=""]=d;if(p)a(c,h,Nt.type(l).create({src:y,alt:"",title:""}));else{const C=Mt.type(l).create({href:y});a(c,h,c.state.schema.text(m,[C]))}return!0},handlePaste(c,u){var d,h;const f=Array.from(((d=u.clipboardData)==null?void 0:d.files)??[]).filter(p=>p.type.startsWith("image/"));if(f.length===0)return!1;u.preventDefault();for(const p of f){const m=t.pasteImage(t.path,p,()=>{var w;if(c.isDestroyed||!m)return;const g=(w=/\(([^)]*)\)/.exec(m))==null?void 0:w[1];let C=c.state.tr;c.state.doc.descendants((E,P)=>{E.type===Nt.type(l)&&E.attrs.src===g&&(C=C.delete(C.mapping.map(P),C.mapping.map(P+E.nodeSize)))}),C.docChanged&&c.dispatch(C)}),y=m?(h=/\(([^)]*)\)/.exec(m))==null?void 0:h[1]:void 0;y&&a(c,null,Nt.type(l).create({src:y,alt:"",title:""}))}return!0},handleClickOn(c,u,f,d,h){return f.type!==at.type(l)||f.attrs.checked==null||h.target.tagName!=="LI"||h.offsetX>26?!1:(c.dispatch(c.state.tr.setNodeMarkup(d,void 0,{...f.attrs,checked:!f.attrs.checked})),!0)}}})});return[i,o,s,...TT(t)]}function PT({path:t,doc:e,onChange:n,onSave:r,images:i,onRequestImage:o,onPasteImage:s}){const l=Je.useRef(null),a=Je.useRef(null),[c,u]=Je.useState(ST),[f,d]=Je.useState(!1),[h,p]=Je.useState(null),m=Je.useRef(null),y=Je.useRef({path:t,doc:e,onChange:n,onSave:r});y.current={path:t,doc:e,onChange:n,onSave:r};const g=Je.useRef({path:t,images:i,requestImage:o,pasteImage:s,imageViews:new Set});g.current.path=t,g.current.images=i,g.current.requestImage=o,g.current.pasteImage=s,Je.useEffect(()=>{for(const A of g.current.imageViews)A()},[i]);const C=Je.useCallback(A=>{var L;(L=a.current)==null||L.action(V=>A(V,V.get(Xt)))},[]),w=Je.useCallback((A,L=!0)=>{const V=a.current;if(!V)return;let _=null;V.action(k=>{const Oe=k.get(Xt);_=AT(k.get(vi)(Oe.state.doc))});const{path:Y,doc:ne,onChange:ce,onSave:be}=y.current;_!==null&&(_!==ne&&(L?zg.flushSync(()=>ce(Y,_)):ce(Y,_)),A===!0&&be(Y))},[]),E=Je.useCallback(()=>{C((A,L)=>{const V=Mt.type(A),{$from:_}=L.state.selection,Y=kh(_,V);p({href:(Y==null?void 0:Y.href)??"",had:!!Y})}),requestAnimationFrame(()=>{var A;return(A=m.current)==null?void 0:A.select()})},[C]);Je.useEffect(()=>{const A=l.current;if(!A)return;let L=!1;const V={call:C,flush:ne=>w(ne===!0),openLink:E},_=hC.make().config(ne=>{ne.set(Qo,A),ne.set(Uo,y.current.doc);const ce=y.current.doc,be=/^\s*\* /m.test(ce)&&!/^\s*- /m.test(ce);ne.update(Cr,k=>({...k,bullet:be?"*":"-",rule:/^\*{3,}\s*$/m.test(ce)?"*":"-",emphasis:/(^|[^_\w])_[^_\s][^_]*_([^_\w]|$)/.test(ce)&&!/\*[^*\s][^*]*\*/.test(ce)?"_":"*",fences:!0,listItemIndent:"one"})),ne.update(Oi,k=>({...k,attributes:{class:"markdown-preview mdtext__doc",spellcheck:"true",role:"textbox","aria-multiline":"true","aria-label":"Текст документа"}}))}).use(tS).use(fT).use(wT).use(Mg).use(IT(g.current,V,u));a.current=_,_.create().then(()=>{L||d(!0)});const Y=g.current.imageViews;return()=>{L=!0;try{w(!1,!1)}catch{}a.current=null,Y.clear(),_.destroy()}},[C,w,E]);const P=A=>()=>{C((L,V)=>{A(L,V),V.focus()})},S=(A,L)=>P(V=>{V.get(ee).call(A,L)}),D=A=>P((L,V)=>{const _=V.state.selection.$from.parent,Y=_.type===Dt.type(L)&&_.attrs.level===A;L.get(ee).call(Y?Yr.key:Ct.key,A)}),F=A=>P((L,V)=>{const _=A?rn.type(L):nn.type(L),{$from:Y}=V.state.selection;for(let ne=Y.depth;ne>0;ne-=1)if(Y.node(ne).type===_){tc(at.type(L))(V.state,V.dispatch);return}L.get(ee).call(A?No.key:Mo.key)}),Z=A=>{const L=MT(A);C((V,_)=>{const Y=Mt.type(V),{state:ne}=_,{from:ce,to:be,empty:k,$from:Oe}=ne.selection;let fe=ne.tr;const b=kh(Oe,Y);L?k&&b?fe=fe.removeMark(b.from,b.to,Y).addMark(b.from,b.to,Y.create({href:L})):k?fe=fe.replaceSelectionWith(ne.schema.text(L,[Y.create({href:L})]),!1):fe=fe.removeMark(ce,be,Y).addMark(ce,be,Y.create({href:L})):k&&b?fe=fe.removeMark(b.from,b.to,Y):fe=fe.removeMark(ce,be,Y),_.dispatch(fe),_.focus()}),p(null)},M=typeof navigator<"u"&&/mac/i.test(navigator.platform)?"⌘":"Ctrl+",R=(A,L)=>L?`${A} (${M}${L})`:A;return J.jsxs("div",{className:"mdtext",children:[J.jsxs("div",{className:"mdtext__bar",role:"toolbar","aria-label":"Форматирование",onMouseDown:A=>{A.target.closest("input")||A.preventDefault()},children:[J.jsx(Bt,{label:R("Жирный","B"),on:c.strong,onClick:S(Ls.key),children:J.jsx("b",{children:"Ж"})}),J.jsx(Bt,{label:R("Курсив","I"),on:c.em,onClick:S(Bs.key),children:J.jsx("i",{children:"К"})}),J.jsx(Bt,{label:R("Код в строке","E"),on:c.code,onClick:S(Fs.key),children:J.jsx("span",{className:"mdtext__mono",children:"<>"})}),J.jsx(Bt,{label:R("Ссылка","K"),on:c.link||h!==null,onClick:E,children:J.jsxs("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[J.jsx("path",{d:"M6.7 9.3a3 3 0 0 0 4.2 0l2-2a3 3 0 0 0-4.2-4.2l-.8.8"}),J.jsx("path",{d:"M9.3 6.7a3 3 0 0 0-4.2 0l-2 2a3 3 0 0 0 4.2 4.2l.8-.8"})]})}),J.jsx("span",{className:"mdtext__sep","aria-hidden":!0}),[1,2,3].map(A=>J.jsx(Bt,{label:R(`Заголовок ${A}`,String(A)),on:c.heading===A,onClick:D(A),children:J.jsxs("span",{className:"mdtext__h",children:["Н",J.jsx("sub",{children:A})]})},A)),J.jsx("span",{className:"mdtext__sep","aria-hidden":!0}),J.jsx(Bt,{label:R("Маркированный список","Shift+8"),on:c.bullet,onClick:F(!1),children:J.jsxs("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"currentColor",children:[J.jsx("circle",{cx:"2.5",cy:"4",r:"1.2"}),J.jsx("circle",{cx:"2.5",cy:"8",r:"1.2"}),J.jsx("circle",{cx:"2.5",cy:"12",r:"1.2"}),J.jsx("path",{d:"M6 3.4h8v1.2H6zM6 7.4h8v1.2H6zM6 11.4h8v1.2H6z"})]})}),J.jsx(Bt,{label:R("Нумерованный список","Shift+7"),on:c.ordered,onClick:F(!0),children:J.jsxs("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"currentColor",children:[J.jsx("text",{x:"0",y:"5.6",fontSize:"5",fontFamily:"sans-serif",children:"1"}),J.jsx("text",{x:"0",y:"9.6",fontSize:"5",fontFamily:"sans-serif",children:"2"}),J.jsx("text",{x:"0",y:"13.6",fontSize:"5",fontFamily:"sans-serif",children:"3"}),J.jsx("path",{d:"M6 3.4h8v1.2H6zM6 7.4h8v1.2H6zM6 11.4h8v1.2H6z"})]})}),J.jsx(Bt,{label:R("Цитата","Shift+B"),on:c.quote,onClick:S(Vs.key),children:J.jsxs("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"currentColor",children:[J.jsx("path",{d:"M2 3h1.6v10H2z"}),J.jsx("path",{d:"M6 4.4h8v1.2H6zM6 7.4h8v1.2H6zM6 10.4h5v1.2H6z"})]})}),J.jsx(Bt,{label:R("Блок кода","Alt+C"),on:c.codeBlock,onClick:S(js.key),children:J.jsx("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:J.jsx("path",{d:"M5.5 4.5 2 8l3.5 3.5M10.5 4.5 14 8l-3.5 3.5"})})})]}),h&&J.jsxs("form",{className:"mdtext__link",onSubmit:A=>{A.preventDefault(),Z(h.href)},children:[J.jsx("label",{className:"mdtext__linklabel",htmlFor:"mdtext-link-url",children:"Ссылка"}),J.jsx("input",{id:"mdtext-link-url",ref:m,className:"mdtext__linkinput",type:"text",inputMode:"url",autoFocus:!0,spellCheck:!1,placeholder:"https://… или путь к файлу",value:h.href,onChange:A=>p({...h,href:A.target.value}),onKeyDown:A=>{A.key==="Escape"&&(A.preventDefault(),p(null),C((L,V)=>V.focus()))}}),J.jsx("button",{type:"submit",className:"btn btn--sm",children:"Применить"}),h.had&&J.jsx("button",{type:"button",className:"btn btn--sm",onClick:()=>Z(""),children:"Убрать"}),J.jsx("button",{type:"button",className:"btn btn--sm",onClick:()=>{p(null),C((A,L)=>L.focus())},children:"Отмена"})]}),J.jsx("div",{className:"mdtext__scroll",onMouseDown:A=>{A.target===A.currentTarget&&(A.preventDefault(),C((L,V)=>{V.focus(),V.dispatch(V.state.tr.setSelection(q.atEnd(V.state.doc)))}))},children:J.jsx("div",{ref:l,className:"mdtext__host","data-ready":f||void 0})})]})}function Bt({label:t,on:e,onClick:n,children:r}){return J.jsx("button",{type:"button",className:"mdtext__tool"+(e?" is-on":""),title:t,"aria-label":t,"aria-pressed":e,onClick:n,children:r})}function AT(t){let e=null;return t.split(`
|
|
59
|
-
`).map(n=>{const r=/^\s*(`{3,}|~{3,})/.exec(n);if(r){const i=r[1];return e===null?e=i[0]:i[0]===e&&(e=null),n}return e!==null||!n.includes("|")||!/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(n)?n:n.replace(/(:?)(-+)(:?)/g,(i,o,s,l)=>{const a=Math.max(3-o.length-l.length,1);return o+(s.length<a?"-".repeat(a):s)+l})}).join(`
|
|
60
|
-
`)}export{PT as default,AT as widenTableDelimiters};
|