@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.
Files changed (83) hide show
  1. package/bundle/ccv.mjs +403 -563
  2. package/package.json +1 -1
  3. package/web/assets/MarkdownTextEditor-DoP0b52_.js +60 -0
  4. package/web/assets/{abnfDiagram-S7VZAUFO-DJLBYC4E.js → abnfDiagram-S7VZAUFO-CApqnaGR.js} +1 -1
  5. package/web/assets/{architectureDiagram-YGSQEFNW-CjOULv4y.js → architectureDiagram-YGSQEFNW-jwCcwggk.js} +1 -1
  6. package/web/assets/{blockDiagram-APKKGZFW-BxtAGaqL.js → blockDiagram-APKKGZFW-Bji4PkTF.js} +1 -1
  7. package/web/assets/{c4Diagram-KJ2TOQU5-DixwjD35.js → c4Diagram-KJ2TOQU5-BFRf3dTO.js} +1 -1
  8. package/web/assets/{chunk-2Q5K7J3B-D5RSYb7c.js → chunk-2Q5K7J3B-DUFwqu3B.js} +1 -1
  9. package/web/assets/{chunk-5VM5RSS4-Zw9KRmHP.js → chunk-5VM5RSS4-BNCdpRtw.js} +1 -1
  10. package/web/assets/{chunk-HFQBQIA3-Dz3Jqjvc.js → chunk-HFQBQIA3-D8sImu8E.js} +1 -1
  11. package/web/assets/{chunk-JWPE2WC7-CYC8lXvq.js → chunk-JWPE2WC7-BhL2yBgo.js} +1 -1
  12. package/web/assets/{chunk-KQLB2F66-BpsntY2B.js → chunk-KQLB2F66-pFBglgtP.js} +2 -2
  13. package/web/assets/{chunk-KS47KZWR-CIw-CgK1.js → chunk-KS47KZWR-BrLOmWWS.js} +1 -1
  14. package/web/assets/{chunk-OY52VR5R-DyNxKUIK.js → chunk-OY52VR5R-Cgk3JXPf.js} +1 -1
  15. package/web/assets/{chunk-TU62E6Q5-CHgxHE0R.js → chunk-TU62E6Q5-e2yCDokg.js} +1 -1
  16. package/web/assets/{chunk-XXDRQBXY-CQ0zLLMg.js → chunk-XXDRQBXY-DU6jFvHG.js} +1 -1
  17. package/web/assets/{classDiagram-v2-L25IHNXF-DyN77x6F.js → classDiagram-v2-L25IHNXF-Bt1zi6CS.js} +1 -1
  18. package/web/assets/{codemirror-Dh-4cMdO.js → codemirror-CNxAt-Eg.js} +1 -1
  19. package/web/assets/{codemirrorImages-BHHbVBQN.js → codemirrorImages-C30a2wIG.js} +1 -1
  20. package/web/assets/{cose-bilkent-JH36ORCC-D1H3X9ot.js → cose-bilkent-JH36ORCC-CYITjt4m.js} +1 -1
  21. package/web/assets/{cynefin-EF2NZ3EQ-B4SsJI8I.js → cynefin-EF2NZ3EQ-BiYmPyip.js} +1 -1
  22. package/web/assets/{cynefinDiagram-L36ESFBY-D543PDJ4.js → cynefinDiagram-L36ESFBY-DiITK0W-.js} +1 -1
  23. package/web/assets/{dagre-SPEB5RXH-CksMpjx8.js → dagre-SPEB5RXH-BnOvnJrY.js} +1 -1
  24. package/web/assets/{diagram-3B7GL73J-DywKf_aW.js → diagram-3B7GL73J-DnFw5yRA.js} +1 -1
  25. package/web/assets/{diagram-DNEMPZML-QaEKUl5W.js → diagram-DNEMPZML-CLe-W-8E.js} +1 -1
  26. package/web/assets/{diagram-L3MUGCDN-51y_ny8R.js → diagram-L3MUGCDN-xhFV1YT8.js} +1 -1
  27. package/web/assets/{diagram-LA4NIPWU-Cg_nbBL_.js → diagram-LA4NIPWU-S58Cgi0K.js} +1 -1
  28. package/web/assets/{diagram-MHCOC4E2-DFHCPZYb.js → diagram-MHCOC4E2-fbSbD-Tu.js} +1 -1
  29. package/web/assets/{diagram-XPFHEONP-dBKRRNZa.js → diagram-XPFHEONP-C3K_xR1q.js} +1 -1
  30. package/web/assets/{ebnfDiagram-UZSYDL2S-BwTgNIAm.js → ebnfDiagram-UZSYDL2S-BG_udZa4.js} +1 -1
  31. package/web/assets/{elk-XV6XMXQE-BR-xb3ob.js → elk-XV6XMXQE-DE6K1qve.js} +1 -1
  32. package/web/assets/{erDiagram-EYBAPDEH-BB1wg_fV.js → erDiagram-EYBAPDEH-xkeusKpC.js} +1 -1
  33. package/web/assets/{flowDiagram-MALGAFMO-CRDw4nX3.js → flowDiagram-MALGAFMO-OisK-T0f.js} +1 -1
  34. package/web/assets/{ganttDiagram-23REXITY-MYQEYJ-I.js → ganttDiagram-23REXITY-DmQVS3ZV.js} +1 -1
  35. package/web/assets/{gitGraphDiagram-STJD7YCW-Dhn0_pRI.js → gitGraphDiagram-STJD7YCW-Cll-SkVb.js} +1 -1
  36. package/web/assets/{index-DRJgyVu5.js → index-B2l2owfY.js} +1 -1
  37. package/web/assets/{index-BJdwUs7I.js → index-BTQSusTZ.js} +1 -1
  38. package/web/assets/{index-Bod45-bM.js → index-B_jwjnO_.js} +1 -1
  39. package/web/assets/{index-v-BrSiuM.js → index-Bta4Smbo.js} +1 -1
  40. package/web/assets/{index-CaL1Ugw4.js → index-BzBiXh1K.js} +1 -1
  41. package/web/assets/index-C0GRVSmD.css +1 -0
  42. package/web/assets/{index-7ivf0ID5.js → index-CJzQgsOc.js} +1 -1
  43. package/web/assets/index-CM1F7OtV.js +172 -0
  44. package/web/assets/{index-BJHr8-zK.js → index-CUm9rUfI.js} +1 -1
  45. package/web/assets/{index-DIouQVG8.js → index-CXbAKkq5.js} +1 -1
  46. package/web/assets/{index-DaBTH0ea.js → index-CYTyvY7n.js} +1 -1
  47. package/web/assets/{index-DqLAItfN.js → index-CcKihMD9.js} +1 -1
  48. package/web/assets/{index-DtR2v4RD.js → index-CkV2xkfY.js} +1 -1
  49. package/web/assets/{index-BLLxsupM.js → index-CkpIGiUh.js} +1 -1
  50. package/web/assets/{index-BK9FAkRg.js → index-D5xJiVmD.js} +1 -1
  51. package/web/assets/{index-Cbs1XkJa.js → index-DM3T56Jf.js} +1 -1
  52. package/web/assets/{index-C13EW7hw.js → index-DXCiYt0O.js} +1 -1
  53. package/web/assets/{index-DtwnaAnT.js → index-Zq9V5ZB9.js} +1 -1
  54. package/web/assets/{index-DqxhStF7.js → index-cu8Fcww3.js} +1 -1
  55. package/web/assets/{index-CE1Pd4z7.js → index-fF3dLvWP.js} +1 -1
  56. package/web/assets/{index-DlMbLAnE.js → index-qOoKNKZw.js} +1 -1
  57. package/web/assets/{infoDiagram-KBXO4MBG-By-j1Q2z.js → infoDiagram-KBXO4MBG-CFnvxUDW.js} +1 -1
  58. package/web/assets/{ishikawaDiagram-M35NCXHK-Cj7pfKCW.js → ishikawaDiagram-M35NCXHK-CjJXkiZb.js} +1 -1
  59. package/web/assets/{journeyDiagram-OPLOXDXO-B7acuJLi.js → journeyDiagram-OPLOXDXO-CYBHLPC5.js} +1 -1
  60. package/web/assets/{kanban-definition-BZKZHSQY-B0N1FM8N.js → kanban-definition-BZKZHSQY-BzNwzCFX.js} +1 -1
  61. package/web/assets/{mermaid.core-Rt-JZroF.js → mermaid.core-CFBl9TP8.js} +4 -4
  62. package/web/assets/{mindmap-definition-I2QAS2VK-Du6Bq1D4.js → mindmap-definition-I2QAS2VK-X8WzviFV.js} +1 -1
  63. package/web/assets/{pegDiagram-FD4XPPHP-Cx3y_VAW.js → pegDiagram-FD4XPPHP-kvO-a_98.js} +1 -1
  64. package/web/assets/{pieDiagram-J4AKIIQI-DrpfcCiI.js → pieDiagram-J4AKIIQI-BEiN8l-e.js} +1 -1
  65. package/web/assets/{quadrantDiagram-XTYBLID2-BbJ2d8x8.js → quadrantDiagram-XTYBLID2-Cf-t2xpS.js} +1 -1
  66. package/web/assets/{railroadDiagram-MRQ6NCDL-C8B9eHMq.js → railroadDiagram-MRQ6NCDL-Bou3xfYm.js} +1 -1
  67. package/web/assets/{requirementDiagram-Y7LWUY3S--8FcyGsP.js → requirementDiagram-Y7LWUY3S-Ch1ghejU.js} +1 -1
  68. package/web/assets/{sankeyDiagram-WGJFYUXA-CYq-mQmD.js → sankeyDiagram-WGJFYUXA-DCjH5hxL.js} +1 -1
  69. package/web/assets/{sequenceDiagram-5NDRBG5M-C-Llg4wI.js → sequenceDiagram-5NDRBG5M-DrspJAAy.js} +1 -1
  70. package/web/assets/{sizeCapture-INFHLROL-80lnJyWe.js → sizeCapture-INFHLROL-BpOJNwe1.js} +1 -1
  71. package/web/assets/{stateDiagram-v2-FJ4FJNEA-QZyfUycB.js → stateDiagram-v2-FJ4FJNEA-RkYUtnsy.js} +1 -1
  72. package/web/assets/{swimlanes-UMQ2AFYF-BxT8Ql8H.js → swimlanes-UMQ2AFYF-BR4cicEg.js} +1 -1
  73. package/web/assets/swimlanesDiagram-OMPLPG4O-DGwvhioW.js +8 -0
  74. package/web/assets/{timeline-definition-SEUHKTQE-DWywP4r0.js → timeline-definition-SEUHKTQE-Bq2VoDLH.js} +1 -1
  75. package/web/assets/{usecaseDiagram-AFA6YXN4-BgmSQD90.js → usecaseDiagram-AFA6YXN4-BsB6aBKf.js} +1 -1
  76. package/web/assets/{vennDiagram-NNMJR3RB-B9ikZp8F.js → vennDiagram-NNMJR3RB-8pOZirDr.js} +1 -1
  77. package/web/assets/{wardleyDiagram-S7YFUSEH-CptNVfVi.js → wardleyDiagram-S7YFUSEH-Dx-je9ls.js} +1 -1
  78. package/web/assets/{xychartDiagram-GGNKY7IX-DV4TDhUT.js → xychartDiagram-GGNKY7IX-mpETY7ui.js} +1 -1
  79. package/web/index.html +2 -2
  80. package/web/assets/MarkdownTextEditor-B3B8_rFw.js +0 -60
  81. package/web/assets/index-eIS20v-m.css +0 -1
  82. package/web/assets/index-gy3hTMSD.js +0 -167
  83. package/web/assets/swimlanesDiagram-OMPLPG4O-BZDLC88s.js +0 -8
@@ -0,0 +1,60 @@
1
+ var Mu=t=>{throw TypeError(t)};var Nu=(t,e,n)=>e.has(t)||Mu("Cannot "+n);var x=(t,e,n)=>(Nu(t,e,"read from private field"),n?n.call(t):e.get(t)),$=(t,e,n)=>e.has(t)?Mu("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),D=(t,e,n,r)=>(Nu(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n);import{m as Ne,n as Ug,o as N,S as Gg,q as _f,p as Yg,u as Tu,v as Qg,e as Xg,f as Iu,r as Zg,i as ey}from"./index-CM1F7OtV.js";import{k as ty,b as ny}from"./index-Vcq4gwWv.js";import{g as ry}from"./_commonjsHelpers-CqkleIqs.js";var ct=(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})({}),ut=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)}},iy=(t,e)=>typeof e=="function"?"[Function]":e,Os=t=>JSON.stringify(t,iy);function oy(t){return new ut(ct.docTypeError,`Doc type error, unsupported type: ${Os(t)}`)}function sy(t){return new ut(ct.contextNotFound,`Context "${t}" not found, do you forget to inject it?`)}function ly(t){return new ut(ct.timerNotFound,`Timer "${t}" not found, do you forget to record it?`)}function Ds(){return new ut(ct.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function ay(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 ut(ct.createNodeInParserFail,o.join(`
2
+ `))}function $f(){return new ut(ct.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function cy(t){return new ut(ct.parserMatchError,`Cannot match target parser for node: ${Os(t)}.`)}function uy(t){return new ut(ct.serializerMatchError,`Cannot match target serializer for node: ${Os(t)}.`)}function hy(t,e){return new ut(ct.getAtomFromSchemaFail,`Cannot get ${t}: ${e} from schema.`)}function Ht(t){return new ut(ct.expectDomTypeError,`Expect to be a dom, but get: ${Os(t)}.`)}function tl(){return new ut(ct.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 fy(t){return new ut(ct.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${t}" in schema.`)}function dy(t){return new ut(ct.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${t}" in schema.`)}var jf=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 sy(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)}},Nt,Zt,Lr,zf,py=(zf=class{constructor(e,n,r){$(this,Nt);$(this,Zt);$(this,Lr);D(this,Nt,[]),D(this,Lr,()=>{x(this,Nt).forEach(i=>i(x(this,Zt)))}),this.set=i=>{D(this,Zt,i),x(this,Lr).call(this)},this.get=()=>x(this,Zt),this.update=i=>{D(this,Zt,i(x(this,Zt))),x(this,Lr).call(this)},this.type=r,D(this,Zt,n),e.set(r.id,this)}on(e){return x(this,Nt).push(e),()=>{D(this,Nt,x(this,Nt).filter(n=>n!==e))}}once(e){const n=this.on(r=>{e(r),n()});return n}off(e){D(this,Nt,x(this,Nt).filter(n=>n!==e))}offAll(){D(this,Nt,[])}},Nt=new WeakMap,Zt=new WeakMap,Lr=new WeakMap,zf),my=class{constructor(t,e){this.id=Symbol(`Context-${e}`),this.name=e,this._defaultValue=t,this._typeInfo=()=>{throw Ds()}}create(t,e=this._defaultValue){return new py(t,e,this)}},ie=(t,e)=>new my(t,e),io,oo,so,qn,Br,Nn,Fr,_r,$r,Pf,gy=(Pf=class{constructor(t,e,n){$(this,io);$(this,oo);$(this,so);$(this,qn);$(this,Br);$(this,Nn);$(this,Fr);$(this,_r);$(this,$r);D(this,qn,new Set),D(this,Br,new Set),D(this,Nn,new Map),D(this,Fr,new Map),this.read=()=>({metadata:x(this,io),injectedSlices:[...x(this,qn)].map(r=>({name:typeof r=="string"?r:r.name,value:x(this,_r).call(this,r)})),consumedSlices:[...x(this,Br)].map(r=>({name:typeof r=="string"?r:r.name,value:x(this,_r).call(this,r)})),recordedTimers:[...x(this,Nn)].map(([r,{duration:i}])=>({name:r.name,duration:i,status:x(this,$r).call(this,r)})),waitTimers:[...x(this,Fr)].map(([r,{duration:i}])=>({name:r.name,duration:i,status:x(this,$r).call(this,r)}))}),this.onRecord=r=>{x(this,Nn).set(r,{start:Date.now(),duration:0})},this.onClear=r=>{x(this,Nn).delete(r)},this.onDone=r=>{const i=x(this,Nn).get(r);i&&(i.duration=Date.now()-i.start)},this.onWait=(r,i)=>{const o=Date.now();i.finally(()=>{x(this,Fr).set(r,{duration:Date.now()-o})}).catch(console.error)},this.onInject=r=>{x(this,qn).add(r)},this.onRemove=r=>{x(this,qn).delete(r)},this.onUse=r=>{x(this,Br).add(r)},D(this,_r,r=>x(this,oo).get(r).get()),D(this,$r,r=>x(this,so).get(r).status),D(this,oo,t),D(this,so,e),D(this,io,n)}},io=new WeakMap,oo=new WeakMap,so=new WeakMap,qn=new WeakMap,Br=new WeakMap,Nn=new WeakMap,Fr=new WeakMap,_r=new WeakMap,$r=new WeakMap,Pf),en,tn,lo,pt,jr,yy=(jr=class{constructor(e,n,r){$(this,en);$(this,tn);$(this,lo);$(this,pt);this.produce=i=>i&&Object.keys(i).length?new jr(x(this,en),x(this,tn),{...i}):this,this.inject=(i,o)=>{var l;const s=i.create(x(this,en).sliceMap);return o!=null&&s.set(o),(l=x(this,pt))==null||l.onInject(i),this},this.remove=i=>{var o;return x(this,en).remove(i),(o=x(this,pt))==null||o.onRemove(i),this},this.record=i=>{var o;return i.create(x(this,tn).store),(o=x(this,pt))==null||o.onRecord(i),this},this.clearTimer=i=>{var o;return x(this,tn).remove(i),(o=x(this,pt))==null||o.onClear(i),this},this.isInjected=i=>x(this,en).has(i),this.isRecorded=i=>x(this,tn).has(i),this.use=i=>{var o;return(o=x(this,pt))==null||o.onUse(i),x(this,en).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,tn).get(i),this.done=i=>{var o;this.timer(i).done(),(o=x(this,pt))==null||o.onDone(i)},this.wait=i=>{var s;const o=this.timer(i).start();return(s=x(this,pt))==null||s.onWait(i,o),o},this.waitTimers=async i=>{await Promise.all(this.get(i).map(o=>this.wait(o)))},D(this,en,e),D(this,tn,n),D(this,lo,r),r&&D(this,pt,new gy(e,n,r))}get meta(){return x(this,lo)}get inspector(){return x(this,pt)}},en=new WeakMap,tn=new WeakMap,lo=new WeakMap,pt=new WeakMap,jr),ky=class{constructor(){this.store=new Map,this.get=t=>{const e=this.store.get(t.id);if(!e)throw ly(t.name);return e},this.remove=t=>{this.store.delete(t.id)},this.has=t=>this.store.has(t.id)}},Vr,Tn,Hr,nn,rn,qr,ao,Lf,by=(Lf=class{constructor(t,e){$(this,Vr);$(this,Tn);$(this,Hr);$(this,nn);$(this,rn);$(this,qr);$(this,ao);D(this,Vr,null),D(this,Tn,null),D(this,nn,"pending"),D(this,rn,null),this.start=()=>(x(this,Vr)??D(this,Vr,new Promise((n,r)=>{D(this,Tn,i=>{i instanceof CustomEvent&&i.detail.id===x(this,Hr)&&(D(this,nn,"resolved"),x(this,qr).call(this),i.stopImmediatePropagation(),n())}),x(this,ao).call(this,()=>{x(this,nn)==="pending"&&D(this,nn,"rejected"),x(this,qr).call(this),r(new Error(`Timing ${this.type.name} timeout.`))}),D(this,nn,"pending"),addEventListener(this.type.name,x(this,Tn))})),x(this,Vr)),this.done=()=>{const n=new CustomEvent(this.type.name,{detail:{id:x(this,Hr)}});dispatchEvent(n)},D(this,qr,()=>{x(this,rn)!==null&&(clearTimeout(x(this,rn)),D(this,rn,null)),x(this,Tn)&&removeEventListener(this.type.name,x(this,Tn))}),D(this,ao,n=>{D(this,rn,setTimeout(()=>{D(this,rn,null),n()},this.type.timeout))}),D(this,Hr,Symbol(e.name)),this.type=e,t.set(e.id,this)}get status(){return x(this,nn)}},Vr=new WeakMap,Tn=new WeakMap,Hr=new WeakMap,nn=new WeakMap,rn=new WeakMap,qr=new WeakMap,ao=new WeakMap,Lf),xy=class{constructor(t,e=3e3){this.create=n=>new by(n,this),this.id=Symbol(`Timer-${t}`),this.name=t,this.timeout=e}},qt=(t,e=3e3)=>new xy(t,e);const wy={};function Rs(t,e){const n=wy,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Vf(t,r,i)}function Vf(t,e,n){if(Cy(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 Au(t.children,e,n)}return Array.isArray(t)?Au(t,e,n):""}function Au(t,e,n){const r=[];let i=-1;for(;++i<t.length;)r[i]=Vf(t[i],e,n);return r.join("")}function Cy(t){return!!(t&&typeof t=="object")}const vu=document.createElement("i");function za(t){const e="&"+t+";";vu.innerHTML=e;const n=vu.textContent;return n.charCodeAt(n.length-1)===59&&t!=="semi"||n===e?!1:n}function At(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 yt(t,e){return t.length>0?(At(t,t.length,0,e),t):e}const Eu={}.hasOwnProperty;function Hf(t){const e={};let n=-1;for(;++n<t.length;)Sy(e,t[n]);return e}function Sy(t,e){let n;for(n in e){const i=(Eu.call(t,n)?t[n]:void 0)||(t[n]={}),o=e[n];let s;if(o)for(s in o){Eu.call(i,s)||(i[s]=[]);const l=o[s];My(i[s],Array.isArray(l)?l:l?[l]:[])}}}function My(t,e){let n=-1;const r=[];for(;++n<e.length;)(e[n].add==="after"?t:r).push(e[n]);At(t,0,0,r)}function qf(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 vt(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ae=Pn(/[A-Za-z]/),$e=Pn(/[\dA-Za-z]/),Ny=Pn(/[#-'*+\--9=?A-Z^-~]/);function ds(t){return t!==null&&(t<32||t===127)}const Kl=Pn(/\d/),Ty=Pn(/[\dA-Fa-f]/),Wf=Pn(/[!-/:-@[-`{-~]/);function q(t){return t!==null&&t<-2}function ue(t){return t!==null&&(t<0||t===32)}function te(t){return t===-2||t===-1||t===32}const Mo=Pn(new RegExp("\\p{P}|\\p{S}","u")),lr=Pn(/\s/);function Pn(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function le(t,e,n,r){const i=r?r-1:1/0;let o=0;return s;function s(a){return te(a)?(t.enter(n),l(a)):e(a)}function l(a){return te(a)&&o++<i?(t.consume(a),l):(t.exit(n),e(a))}}function Kf(t,e,n,r,i,o){let s=0;return l;function l(u){return te(u)?(t.enter(r),a(u)):c(u)}function a(u){return te(u)&&s<o?(t.consume(u),s++,a):(t.exit(r),c(u))}function c(u){return s>=i?e(u):n(u)}}const Iy={tokenize:Ay};function Ay(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"),le(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 q(l)?(t.consume(l),t.exit("chunkText"),o):(t.consume(l),s)}}let ps=class{constructor(){this.index=new Map,this.map=[]}add(e,n,r){Ou(this,e,n,r,!1)}addBefore(e,n,r){Ou(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 Ou(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 vy={tokenize:Ey},Du={tokenize:Oy};function Ey(t){const e=this,n=[];let r=0,i,o,s;return l;function l(w){if(r<n.length){const v=n[r];return e.containerState=v[1],t.attempt(v[0].continuation,a,c)(w)}return c(w)}function a(w){if(r++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&C();const v=e.events.length;let B=v,S;for(;B--;)if(e.events[B][0]==="exit"&&e.events[B][1].type==="chunkFlow"){S=e.events[B][1].end;break}g(r);let R=v;for(;R<e.events.length;)e.events[R][1].end={...S},R++;const F=new ps;return F.add(B+1,0,e.events.slice(v)),F.add(v,R-v,[]),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(Du,u,h)(w)}function u(w){return i&&C(),g(r),d(w)}function h(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(Du,f,p)(w)}function f(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 q(w)?(t.consume(w),y(t.exit("chunkFlow")),r=0,e.interrupt=void 0,l):(t.consume(w),m)}function y(w,v){const B=e.sliceStream(w);if(v&&B.push(null),w.previous=o,o&&(o.next=w),o=w,i.defineSkip(w.start),i.write(B),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 R=e.events.length;let F=R,ee,M;for(;F--;)if(e.events[F][0]==="exit"&&e.events[F][1].type==="chunkFlow"){if(ee){M=e.events[F][1].end;break}ee=!0}for(g(r),S=R;S<e.events.length;)e.events[S][1].end={...M},S++;const P=new ps;P.add(F+1,0,e.events.slice(R)),P.add(R,S-R,[]),P.consume(e.events)}}function g(w){let v=n.length;for(;v-- >w;){const B=n[v];e.containerState=B[1],B[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 Oy(t,e,n){return le(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function jt(t){if(t===null||ue(t)||lr(t))return 1;if(Mo(t))return 2}function zs(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 Jl={name:"attention",resolveAll:Dy,tokenize:Ry};function Dy(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};Ru(s,-o),Ru(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}},h={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=yt(r,[["enter",t[i][1],e],["exit",t[i][1],e]])),r=yt(r,[["enter",h,e],["enter",a,e],["exit",a,e],["enter",u,e]]),r=yt(r,zs(e.parser.constructs.insideSpan.null,t.slice(i+1,n),e)),r=yt(r,[["exit",u,e],["enter",c,e],["exit",c,e],["exit",h,e]]);let d=0;t[n][1].end.offset-t[n][1].start.offset&&(d=2,r=yt(r,[["enter",t[n][1],e],["exit",t[n][1],e]])),At(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 Ry(t,e){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=jt(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=jt(a),h=!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?h:h&&(i||!d)),c._close=!!(o===42?d:d&&(u||!h)),e(a)}}function Ru(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const zy={name:"autolink",tokenize:Py};function Py(t,e,n){let r=0;return i;function i(f){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),o}function o(f){return Ae(f)?(t.consume(f),s):f===64?n(f):c(f)}function s(f){return f===43||f===45||f===46||$e(f)?(r=1,l(f)):c(f)}function l(f){return f===58?(t.consume(f),r=0,a):(f===43||f===45||f===46||$e(f))&&r++<32?(t.consume(f),l):(r=0,c(f))}function a(f){return f===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.exit("autolink"),e):f===null||f===32||f===60||ds(f)?n(f):(t.consume(f),a)}function c(f){return f===64?(t.consume(f),u):Ny(f)?(t.consume(f),c):n(f)}function u(f){return $e(f)?h(f):n(f)}function h(f){return f===46?(t.consume(f),r=0,u):f===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.exit("autolink"),e):d(f)}function d(f){if((f===45||$e(f))&&r++<63){const p=f===45?d:h;return t.consume(f),p}return n(f)}}const No={partial:!0,tokenize:Ly};function Ly(t,e,n){return r;function r(o){return te(o)?le(t,i,"linePrefix")(o):i(o)}function i(o){return o===null||q(o)?e(o):n(o)}}const Jf={continuation:{tokenize:Fy},exit:_y,name:"blockQuote",tokenize:By};function By(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 te(s)?(t.enter("blockQuotePrefixWhitespace"),t.consume(s),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(s))}}function Fy(t,e,n){const r=this;return i;function i(s){return te(s)?le(t,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):o(s)}function o(s){return t.attempt(Jf,e,n)(s)}}function _y(t){t.exit("blockQuote")}const Uf={name:"characterEscape",tokenize:$y};function $y(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 Wf(o)?(t.enter("characterEscapeValue"),t.consume(o),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(o)}}const Gf={name:"characterReference",tokenize:jy};function jy(t,e,n){const r=this;let i=0,o,s;return l;function l(h){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(h),t.exit("characterReferenceMarker"),a}function a(h){return h===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(h),t.exit("characterReferenceMarkerNumeric"),c):(t.enter("characterReferenceValue"),o=31,s=$e,u(h))}function c(h){return h===88||h===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(h),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),o=6,s=Ty,u):(t.enter("characterReferenceValue"),o=7,s=Kl,u(h))}function u(h){if(h===59&&i){const d=t.exit("characterReferenceValue");return s===$e&&!za(r.sliceSerialize(d))?n(h):(t.enter("characterReferenceMarker"),t.consume(h),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return s(h)&&i++<o?(t.consume(h),u):n(h)}}const Ul={partial:!0,tokenize:Vy};function Vy(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 zu={concrete:!0,name:"codeFenced",tokenize:Hy};function Hy(t,e,n){const r=this,i={partial:!0,tokenize:B};let o=0,s=0,l;return a;function a(S){return c(S)}function c(S){const R=r.events[r.events.length-1];return o=R&&R[1].type==="linePrefix"?R[2].sliceSerialize(R[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"),te(S)?le(t,h,"whitespace")(S):h(S))}function h(S){return S===null||q(S)?(t.exit("codeFencedFence"),r.interrupt?e(S):t.check(Ul,m,v)(S)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),d(S))}function d(S){return S===null||q(S)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),h(S)):te(S)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),le(t,f,"whitespace")(S)):S===96&&S===l?n(S):(t.consume(S),d)}function f(S){return S===null||q(S)?h(S):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),p(S))}function p(S){return S===null||q(S)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),h(S)):S===96&&S===l?n(S):(t.consume(S),p)}function m(S){return t.attempt(i,v,y)(S)}function y(S){return t.enter("lineEnding"),t.consume(S),t.exit("lineEnding"),g}function g(S){return o>0&&te(S)?le(t,C,"linePrefix",o+1)(S):C(S)}function C(S){return S===null||q(S)?t.check(Ul,m,v)(S):(t.enter("codeFlowValue"),w(S))}function w(S){return S===null||q(S)?(t.exit("codeFlowValue"),C(S)):(t.consume(S),w)}function v(S){return t.exit("codeFenced"),e(S)}function B(S,R,F){let ee=0;return M;function M(ne){return S.enter("lineEnding"),S.consume(ne),S.exit("lineEnding"),P}function P(ne){return S.enter("codeFencedFence"),te(ne)?le(S,j,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ne):j(ne)}function j(ne){return ne===l?(S.enter("codeFencedFenceSequence"),ae(ne)):F(ne)}function ae(ne){return ne===l?(ee++,S.consume(ne),ae):ee>=s?(S.exit("codeFencedFenceSequence"),te(ne)?le(S,he,"whitespace")(ne):he(ne)):F(ne)}function he(ne){return ne===null||q(ne)?(S.exit("codeFencedFence"),R(ne)):F(ne)}}}const nl={name:"codeIndented",tokenize:Wy},qy={partial:!0,tokenize:Ky};function Wy(t,e,n){return r;function r(l){return t.enter("codeIndented"),Kf(t,i,n,"linePrefix",4,4)(l)}function i(l){return l===null?s(l):q(l)?t.attempt(qy,i,s)(l):(t.enter("codeFlowValue"),o(l))}function o(l){return l===null||q(l)?(t.exit("codeFlowValue"),i(l)):(t.consume(l),o)}function s(l){return t.exit("codeIndented"),e(l)}}function Ky(t,e,n){const r=this;return i;function i(s){return r.parser.lazy[r.now().line]?n(s):q(s)?(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),i):Kf(t,e,o,"linePrefix",4,4)(s)}function o(s){return q(s)?i(s):n(s)}}const Jy={name:"codeText",previous:Gy,resolve:Uy,tokenize:Yy};function Uy(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 Gy(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Yy(t,e,n){let r=0,i,o;return s;function s(h){return t.enter("codeText"),t.enter("codeTextSequence"),l(h)}function l(h){return h===96?(t.consume(h),r++,l):(t.exit("codeTextSequence"),a(h))}function a(h){return h===null?n(h):h===32?(t.enter("space"),t.consume(h),t.exit("space"),a):h===96?(o=t.enter("codeTextSequence"),i=0,u(h)):q(h)?(t.enter("lineEnding"),t.consume(h),t.exit("lineEnding"),a):(t.enter("codeTextData"),c(h))}function c(h){return h===null||h===32||h===96||q(h)?(t.exit("codeTextData"),a(h)):(t.consume(h),c)}function u(h){return h===96?(t.consume(h),i++,u):i===r?(t.exit("codeTextSequence"),t.exit("codeText"),e(h)):(o.type="codeTextData",c(h))}}class Qy{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&&wi(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),wi(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),wi(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);wi(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);wi(this.left,n.reverse())}}}function wi(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 Yf(t){const e={};let n=-1,r,i,o,s,l,a,c;const u=new Qy(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,Xy(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 At(t,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function Xy(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,h,d=-1,f=n,p=0,m=0;const y=[m];for(;f;){for(;t.get(++i)[1]!==f;);o.push(i),f._tokenizer||(u=r.sliceStream(f),f.next||u.push(null),h&&s.defineSkip(f.start),f._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(u),f._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),h=f,f=f.next}for(f=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),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(s.events=[],f?(f._tokenizer=void 0,f.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 Zy={resolve:tk,tokenize:nk},ek={partial:!0,tokenize:rk};function tk(t){return Yf(t),t}function nk(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):q(l)?t.check(ek,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 rk(t,e,n){const r=this;return i;function i(s){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),le(t,o,"linePrefix")}function o(s){if(s===null||q(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 Qf(t,e,n,r,i,o,s,l,a){const c=a||Number.POSITIVE_INFINITY;let u=0;return h;function h(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||ds(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"}),f(g))}function f(g){return g===62?(t.exit("chunkString"),t.exit(l),d(g)):g===null||g===60||q(g)?n(g):(t.consume(g),g===92?p:f)}function p(g){return g===60||g===62||g===92?(t.consume(g),f):f(g)}function m(g){return!u&&(g===null||g===41||ue(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||ds(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 Xf(t,e,n,r,i,o){const s=this;let l=0,a;return c;function c(f){return t.enter(r),t.enter(i),t.consume(f),t.exit(i),t.enter(o),u}function u(f){return l>999||f===null||f===91||f===93&&!a||f===94&&!l&&"_hiddenFootnoteSupport"in s.parser.constructs?n(f):f===93?(t.exit(o),t.enter(i),t.consume(f),t.exit(i),t.exit(r),e):q(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),u):(t.enter("chunkString",{contentType:"string"}),h(f))}function h(f){return f===null||f===91||f===93||q(f)||l++>999?(t.exit("chunkString"),u(f)):(t.consume(f),a||(a=!te(f)),f===92?d:h)}function d(f){return f===91||f===92||f===93?(t.consume(f),l++,h):h(f)}}function Zf(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):q(d)?(t.enter("lineEnding"),t.consume(d),t.exit("lineEnding"),le(t,c,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),u(d))}function u(d){return d===s||d===null||q(d)?(t.exit("chunkString"),c(d)):(t.consume(d),d===92?h:u)}function h(d){return d===s||d===92?(t.consume(d),u):u(d)}}function Ai(t,e){let n;return r;function r(i){return q(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),n=!0,r):te(i)?le(t,r,n?"linePrefix":"lineSuffix")(i):e(i)}}const ik={name:"definition",tokenize:sk},ok={partial:!0,tokenize:lk};function sk(t,e,n){const r=this;let i;return o;function o(f){return t.enter("definition"),s(f)}function s(f){return Xf.call(r,t,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function l(f){return i=vt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(t.enter("definitionMarker"),t.consume(f),t.exit("definitionMarker"),a):n(f)}function a(f){return ue(f)?Ai(t,c)(f):c(f)}function c(f){return Qf(t,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function u(f){return t.attempt(ok,h,h)(f)}function h(f){return te(f)?le(t,d,"whitespace")(f):d(f)}function d(f){return f===null||q(f)?(t.exit("definition"),r.parser.defined.push(i),e(f)):n(f)}}function lk(t,e,n){return r;function r(l){return ue(l)?Ai(t,i)(l):n(l)}function i(l){return Zf(t,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return te(l)?le(t,s,"whitespace")(l):s(l)}function s(l){return l===null||q(l)?e(l):n(l)}}const ak={name:"hardBreakEscape",tokenize:ck};function ck(t,e,n){return r;function r(o){return t.enter("hardBreakEscape"),t.consume(o),i}function i(o){return q(o)?(t.exit("hardBreakEscape"),e(o)):n(o)}}const uk={name:"headingAtx",resolve:hk,tokenize:fk};function hk(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"};At(t,r,n-r+1,[["enter",i,e],["enter",o,e],["exit",o,e],["exit",i,e]])}return t}function fk(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||ue(u)?(t.exit("atxHeadingSequence"),l(u)):n(u)}function l(u){return u===35?(t.enter("atxHeadingSequence"),a(u)):u===null||q(u)?(t.exit("atxHeading"),e(u)):te(u)?le(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||ue(u)?(t.exit("atxHeadingText"),l(u)):(t.consume(u),c)}}const ed=["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"],Gl=["pre","script","style","textarea"],dk={concrete:!0,name:"htmlFlow",resolveTo:mk,tokenize:gk},pk={partial:!0,tokenize:yk};function mk(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 gk(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),h}function h(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):Ae(b)?(t.consume(b),s=String.fromCharCode(b),y):n(b)}function d(b){return b===45?(t.consume(b),i=2,f):b===91?(t.consume(b),i=5,l=0,p):Ae(b)?(t.consume(b),i=4,r.interrupt?e:k):n(b)}function f(b){return b===45?(t.consume(b),r.interrupt?e:k):n(b)}function p(b){const qe="CDATA[";return b===qe.charCodeAt(l++)?(t.consume(b),l===qe.length?r.interrupt?e:j:p):n(b)}function m(b){return Ae(b)?(t.consume(b),s=String.fromCharCode(b),y):n(b)}function y(b){if(b===null||b===47||b===62||ue(b)){const qe=b===47,A=s.toLowerCase();return!qe&&!o&&Gl.includes(A)?(i=1,r.interrupt?e(b):j(b)):ed.includes(s.toLowerCase())?(i=6,qe?(t.consume(b),g):r.interrupt?e(b):j(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(b):o?C(b):w(b))}return b===45||$e(b)?(t.consume(b),s+=String.fromCharCode(b),y):n(b)}function g(b){return b===62?(t.consume(b),r.interrupt?e:j):n(b)}function C(b){return te(b)?(t.consume(b),C):M(b)}function w(b){return b===47?(t.consume(b),M):b===58||b===95||Ae(b)?(t.consume(b),v):te(b)?(t.consume(b),w):M(b)}function v(b){return b===45||b===46||b===58||b===95||$e(b)?(t.consume(b),v):B(b)}function B(b){return b===61?(t.consume(b),S):te(b)?(t.consume(b),B):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,R):te(b)?(t.consume(b),S):F(b)}function R(b){return b===a?(t.consume(b),a=null,ee):b===null||q(b)?n(b):(t.consume(b),R)}function F(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||ue(b)?B(b):(t.consume(b),F)}function ee(b){return b===47||b===62||te(b)?w(b):n(b)}function M(b){return b===62?(t.consume(b),P):n(b)}function P(b){return b===null||q(b)?j(b):te(b)?(t.consume(b),P):n(b)}function j(b){return b===45&&i===2?(t.consume(b),ge):b===60&&i===1?(t.consume(b),se):b===62&&i===4?(t.consume(b),nt):b===63&&i===3?(t.consume(b),k):b===93&&i===5?(t.consume(b),Ct):q(b)&&(i===6||i===7)?(t.exit("htmlFlowData"),t.check(pk,St,ae)(b)):b===null||q(b)?(t.exit("htmlFlowData"),ae(b)):(t.consume(b),j)}function ae(b){return t.check(Ul,he,St)(b)}function he(b){return t.enter("lineEnding"),t.consume(b),t.exit("lineEnding"),ne}function ne(b){return b===null||q(b)?ae(b):(t.enter("htmlFlowData"),j(b))}function ge(b){return b===45?(t.consume(b),k):j(b)}function se(b){return b===47?(t.consume(b),s="",Re):j(b)}function Re(b){if(b===62){const qe=s.toLowerCase();return Gl.includes(qe)?(t.consume(b),nt):j(b)}return Ae(b)&&s.length<8?(t.consume(b),s+=String.fromCharCode(b),Re):j(b)}function Ct(b){return b===93?(t.consume(b),k):j(b)}function k(b){return b===62?(t.consume(b),nt):b===45&&i===2?(t.consume(b),k):j(b)}function nt(b){return b===null||q(b)?(t.exit("htmlFlowData"),St(b)):(t.consume(b),nt)}function St(b){return t.exit("htmlFlow"),e(b)}}function yk(t,e,n){return r;function r(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),t.attempt(No,e,n)}}const kk={name:"htmlText",tokenize:bk};function bk(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),B):k===63?(t.consume(k),w):Ae(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):Ae(k)?(t.consume(k),C):n(k)}function u(k){return k===45?(t.consume(k),f):n(k)}function h(k){return k===null?n(k):k===45?(t.consume(k),d):q(k)?(s=h,se(k)):(t.consume(k),h)}function d(k){return k===45?(t.consume(k),f):h(k)}function f(k){return k===62?ge(k):k===45?d(k):h(k)}function p(k){const nt="CDATA[";return k===nt.charCodeAt(o++)?(t.consume(k),o===nt.length?m:p):n(k)}function m(k){return k===null?n(k):k===93?(t.consume(k),y):q(k)?(s=m,se(k)):(t.consume(k),m)}function y(k){return k===93?(t.consume(k),g):m(k)}function g(k){return k===62?ge(k):k===93?(t.consume(k),g):m(k)}function C(k){return k===null||k===62?ge(k):q(k)?(s=C,se(k)):(t.consume(k),C)}function w(k){return k===null?n(k):k===63?(t.consume(k),v):q(k)?(s=w,se(k)):(t.consume(k),w)}function v(k){return k===62?ge(k):w(k)}function B(k){return Ae(k)?(t.consume(k),S):n(k)}function S(k){return k===45||$e(k)?(t.consume(k),S):R(k)}function R(k){return q(k)?(s=R,se(k)):te(k)?(t.consume(k),R):ge(k)}function F(k){return k===45||$e(k)?(t.consume(k),F):k===47||k===62||ue(k)?ee(k):n(k)}function ee(k){return k===47?(t.consume(k),ge):k===58||k===95||Ae(k)?(t.consume(k),M):q(k)?(s=ee,se(k)):te(k)?(t.consume(k),ee):ge(k)}function M(k){return k===45||k===46||k===58||k===95||$e(k)?(t.consume(k),M):P(k)}function P(k){return k===61?(t.consume(k),j):q(k)?(s=P,se(k)):te(k)?(t.consume(k),P):ee(k)}function j(k){return k===null||k===60||k===61||k===62||k===96?n(k):k===34||k===39?(t.consume(k),i=k,ae):q(k)?(s=j,se(k)):te(k)?(t.consume(k),j):(t.consume(k),he)}function ae(k){return k===i?(t.consume(k),i=void 0,ne):k===null?n(k):q(k)?(s=ae,se(k)):(t.consume(k),ae)}function he(k){return k===null||k===34||k===39||k===60||k===61||k===96?n(k):k===47||k===62||ue(k)?ee(k):(t.consume(k),he)}function ne(k){return k===47||k===62||ue(k)?ee(k):n(k)}function ge(k){return k===62?(t.consume(k),t.exit("htmlTextData"),t.exit("htmlText"),e):n(k)}function se(k){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(k),t.exit("lineEnding"),Re}function Re(k){return te(k)?le(t,Ct,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):Ct(k)}function Ct(k){return t.enter("htmlTextData"),s(k)}}const Pa={name:"labelEnd",resolveAll:Sk,resolveTo:Mk,tokenize:Nk},xk={tokenize:Tk},wk={tokenize:Ik},Ck={tokenize:Ak};function Sk(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&&At(t,0,t.length,n),t}function Mk(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=yt(s,t.slice(i+1,i+r+3)),s=yt(s,[["enter",c,e]]),s=yt(s,zs(e.parser.constructs.insideSpan.null,t.slice(i+r+4,o-3),e)),s=yt(s,[["exit",c,e],t[o-2],t[o-1],["exit",a,e]]),s=yt(s,t.slice(o+1)),s=yt(s,[["exit",l,e]]),At(t,i,t.length,s),t}function Nk(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?h(d):(s=r.parser.defined.includes(vt(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(xk,u,s?u:h)(d):d===91?t.attempt(wk,u,s?c:h)(d):s?u(d):h(d)}function c(d){return t.attempt(Ck,u,h)(d)}function u(d){return i.pop(),e(d)}function h(d){return o._balanced=!0,n(d)}}function Tk(t,e,n){return r;function r(h){return t.enter("resource"),t.enter("resourceMarker"),t.consume(h),t.exit("resourceMarker"),i}function i(h){return ue(h)?Ai(t,o)(h):o(h)}function o(h){return h===41?u(h):Qf(t,s,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function s(h){return ue(h)?Ai(t,a)(h):u(h)}function l(h){return n(h)}function a(h){return h===34||h===39||h===40?Zf(t,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):u(h)}function c(h){return ue(h)?Ai(t,u)(h):u(h)}function u(h){return h===41?(t.enter("resourceMarker"),t.consume(h),t.exit("resourceMarker"),t.exit("resource"),e):n(h)}}function Ik(t,e,n){const r=this;return i;function i(l){return Xf.call(r,t,o,s,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(vt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?e(l):n(l)}function s(l){return n(l)}}function Ak(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 vk={name:"labelStartImage",resolveAll:Pa.resolveAll,tokenize:Ek};function Ek(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 Ok={name:"labelStartLink",resolveAll:Pa.resolveAll,tokenize:Dk};function Dk(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 rl={name:"lineEnding",tokenize:Rk};function Rk(t,e){return n;function n(r){return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),le(t,e,"linePrefix")}}const Xo={name:"thematicBreak",tokenize:zk};function zk(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||q(c))?(t.exit("thematicBreak"),e(c)):n(c)}function a(c){return c===i?(t.consume(c),r++,a):(t.exit("thematicBreakSequence"),te(c)?le(t,l,"whitespace")(c):l(c))}}const Ue={continuation:{tokenize:Fk},exit:$k,name:"list",tokenize:Bk},Pk={partial:!0,tokenize:jk},Lk={partial:!0,tokenize:_k};function Bk(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(f){const p=r.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(p==="listUnordered"?!r.containerState.marker||f===r.containerState.marker:Kl(f)){if(r.containerState.type||(r.containerState.type=p,t.enter(p,{_container:!0})),p==="listUnordered")return t.enter("listItemPrefix"),f===42||f===45?t.check(Xo,n,c)(f):c(f);if(!r.interrupt||f===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),a(f)}return n(f)}function a(f){return Kl(f)&&++s<10?(t.consume(f),a):(!r.interrupt||s<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(t.exit("listItemValue"),c(f)):n(f)}function c(f){return t.enter("listItemMarker"),t.consume(f),t.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||f,t.check(No,r.interrupt?n:u,t.attempt(Pk,d,h))}function u(f){return r.containerState.initialBlankLine=!0,o++,d(f)}function h(f){return te(f)?(t.enter("listItemPrefixWhitespace"),t.consume(f),t.exit("listItemPrefixWhitespace"),d):n(f)}function d(f){return r.containerState.size=o+r.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(f)}}function Fk(t,e,n){const r=this;return r.containerState._closeFlow=void 0,t.check(No,i,o);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,le(t,e,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!te(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(Lk,e,s)(l))}function s(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,le(t,t.attempt(Ue,e,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function _k(t,e,n){const r=this;return le(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 $k(t){t.exit(this.containerState.type)}function jk(t,e,n){const r=this;return le(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!te(o)&&s&&s[1].type==="listItemPrefixWhitespace"?e(o):n(o)}}const Pu={name:"setextUnderline",resolveTo:Vk,tokenize:Hk};function Vk(t,e){const n=new ps;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 Hk(t,e,n){const r=this;let i;return o;function o(c){let u=r.events.length,h;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){h=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(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"),te(c)?le(t,a,"lineSuffix")(c):a(c))}function a(c){return c===null||q(c)?(t.exit("setextHeadingLine"),e(c)):n(c)}}const qk={tokenize:Wk};function Wk(t){const e=this,n=t.attempt(No,r,t.attempt(this.parser.constructs.flowInitial,i,le(t,t.attempt(this.parser.constructs.flow,i,t.attempt(Zy,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 Kk={resolveAll:nd()},Jk=td("string"),Uk=td("text");function td(t){return{resolveAll:nd(t==="text"?Gk: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 h=i[u];let d=-1;if(h)for(;++d<h.length;){const f=h[d];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function nd(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 Gk(t,e){const n=new ps;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 Yk={42:Ue,43:Ue,45:Ue,48:Ue,49:Ue,50:Ue,51:Ue,52:Ue,53:Ue,54:Ue,55:Ue,56:Ue,57:Ue,62:Jf},Qk={91:ik},Xk={[-2]:nl,[-1]:nl,32:nl},Zk={35:uk,42:Xo,45:[Pu,Xo],60:dk,61:Pu,95:Xo,96:zu,126:zu},eb={38:Gf,92:Uf},tb={[-5]:rl,[-4]:rl,[-3]:rl,33:vk,38:Gf,42:Jl,60:[zy,kk],91:Ok,92:[ak,Uf],93:Pa,95:Jl,96:Jy},nb={null:[Jl,Kk]},rb={null:[42,95]},ib={null:[]},ob=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:rb,contentInitial:Qk,disable:ib,document:Yk,flow:Zk,flowInitial:Xk,insideSpan:nb,string:eb,text:tb},Symbol.toStringTag,{value:"Module"}));function sb(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:R(B),check:R(S),consume:C,enter:w,exit:v,interrupt:R(S,{interrupt:!0})},c={code:null,containerState:{},defineSkip:m,events:[],now:p,parser:t,previous:null,sliceSerialize:d,sliceStream:f,write:h};let u=e.tokenize.call(c,a);return e.resolveAll&&o.push(e),c;function h(P){return s=yt(s,P),y(),s[s.length-1]!==null?[]:(F(e,0),c.events=zs(o,c.events,c),c.events)}function d(P,j){return ab(f(P),j)}function f(P){return lb(s,P)}function p(){const{_bufferIndex:P,_index:j,line:ae,column:he,offset:ne}=r;return{_bufferIndex:P,_index:j,line:ae,column:he,offset:ne}}function m(P){i[P.line]=P.column,M()}function y(){for(;r._index<s.length;){const P=s[r._index];if(typeof P=="string"){const j=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===j&&r._bufferIndex<P.length;)g(P.charCodeAt(r._bufferIndex))}else g(P)}}function g(P){u=u(P)}function C(P){q(P)?(r.line++,r.column=1,r.offset+=P===-3?2:1,M()):P!==-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=P}function w(P,j){const ae=j||{};return ae.type=P,ae.start=p(),c.events.push(["enter",ae,c]),l.push(ae),ae}function v(P){const j=l.pop();return j.end=p(),c.events.push(["exit",j,c]),j}function B(P,j){F(P,j.from)}function S(P,j){j.restore()}function R(P,j){return ae;function ae(he,ne,ge){let se,Re,Ct,k;return Array.isArray(he)?St(he):"tokenize"in he?St([he]):nt(he);function nt(O){return _;function _(H){const G=H!==null&&O[H],re=H!==null&&O.null,pe=[...Array.isArray(G)?G:G?[G]:[],...Array.isArray(re)?re:re?[re]:[]];return St(pe)(H)}}function St(O){return se=O,Re=0,O.length===0?ge:b(O[Re])}function b(O){return _;function _(H){return k=ee(),Ct=O,O.partial||(c.currentConstruct=O),O.name&&c.parser.constructs.disable.null.includes(O.name)?A():O.tokenize.call(j?Object.assign(Object.create(c),j):c,a,qe,A)(H)}}function qe(O){return P(Ct,k),ne}function A(O){return k.restore(),++Re<se.length?b(se[Re]):ge}}}function F(P,j){P.resolveAll&&!o.includes(P)&&o.push(P),P.resolve&&At(c.events,j,c.events.length-j,P.resolve(c.events.slice(j),c)),P.resolveTo&&(c.events=P.resolveTo(c.events,c))}function ee(){const P=p(),j=c.previous,ae=c.currentConstruct,he=c.events.length,ne=Array.from(l);return{from:he,restore:ge};function ge(){r=P,c.previous=j,c.currentConstruct=ae,c.events.length=he,l=ne,M()}}function M(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function lb(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 ab(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 cb(t){const r={constructs:Hf([ob,...(t||{}).extensions||[]]),content:i(Iy),defined:[],document:i(vy),flow:i(qk),lazy:{},string:i(Jk),text:i(Uk)};return r;function i(o){return s;function s(l){return sb(r,o,l)}}}function ub(t){for(;!Yf(t););return t}const Lu=/[\0\t\n\r]/g;function hb(){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;){Lu.lastIndex=c;const u=Lu.exec(o),h=u&&u.index!==void 0?u.index:o.length,d=o.charCodeAt(h);if(!u){e=o.slice(c);break}if(d===10&&c===h&&r)a.push(-3),r=void 0;else switch(r&&(a.push(-5),r=void 0),c<h&&(a.push(o.slice(c,h)),t+=h-c),d){case 0:{a.push(65533),t++;break}case 9:{const f=Math.ceil(t/4)*4;for(a.push(-2);t++<f;)a.push(-1);break}case 10:{a.push(-4),t=1;break}default:r=!0,t=1}c=h+1}return l&&(r&&a.push(-5),e&&a.push(e),a.push(null)),a}}const fb=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function rd(t){return t.replace(fb,db)}function db(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),o=i===120||i===88;return qf(n.slice(o?2:1),o?16:10)}return za(n)||t}function vi(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?Bu(t.position):"start"in t||"end"in t?Bu(t):"line"in t||"column"in t?Yl(t):""}function Yl(t){return Fu(t&&t.line)+":"+Fu(t&&t.column)}function Bu(t){return Yl(t&&t.start)+"-"+Yl(t&&t.end)}function Fu(t){return t&&typeof t=="number"?t:1}const id={}.hasOwnProperty;function pb(t,e,n){return e&&typeof e=="object"&&(n=e,e=void 0),mb(n)(ub(cb(n).document().write(hb()(t,e,!0))))}function mb(t){const e={afterExit:[],beforeEnter:[],transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(wu),autolinkProtocol:M,autolinkEmail:M,atxHeading:s(Mt),blockQuote:s(pe),characterEscape:M,characterReference:M,codeFenced:s(We),codeFencedFenceInfo:l,codeFencedFenceMeta:l,codeIndented:s(We,l),codeText:s(ze,l),codeTextData:M,data:M,codeFlowValue:M,definition:s(dt),definitionDestinationString:l,definitionLabelString:l,definitionTitleString:l,emphasis:s(Se),hardBreakEscape:s(bu),hardBreakTrailing:s(bu),htmlFlow:s(xu,l),htmlFlowData:M,htmlText:s(xu,l),htmlTextData:M,image:s(Vg),label:l,link:s(wu),listItem:s(Hg),listItemValue:f,listOrdered:s(Cu,d),listUnordered:s(Cu),paragraph:s(qg),reference:qe,referenceString:l,resourceDestinationString:l,resourceTitleString:l,setextHeading:s(Mt),strong:s(Wg),thematicBreak:s(Jg)},exit:{atxHeading:c(),atxHeadingSequence:S,autolink:c(),autolinkEmail:re,autolinkProtocol:G,blockQuote:c(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:O,characterReferenceMarkerNumeric:O,characterReferenceValue:_,characterReference:H,codeFenced:c(g),codeFencedFence:y,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:P,codeIndented:c(C),codeText:c(ge),codeTextData:P,data:P,definition:c(),definitionDestinationString:B,definitionLabelString:w,definitionTitleString:v,emphasis:c(),hardBreakEscape:c(ae),hardBreakTrailing:c(ae),htmlFlow:c(he),htmlFlowData:P,htmlText:c(ne),htmlTextData:P,image:c(Re),label:k,labelText:Ct,lineEnding:j,link:c(se),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:A,resourceDestinationString:nt,resourceTitleString:St,resource:b,setextHeading:c(ee),setextHeadingLineSequence:F,setextHeadingText:R,strong:c(),thematicBreak:c()}};od(e,(t||{}).mdastExtensions||[]);const n={};return r;function r(T){let z={type:"root",children:[],position:void 0};const Y={stack:[z],tokenStack:[],config:e,enter:a,exit:u,buffer:l,resume:h,data:n},Z=[],Ke=[];let fe=-1;for(;++fe<T.length;)if(Ke.push(T[fe]),T[fe][1].type==="listOrdered"||T[fe][1].type==="listUnordered")if(T[fe][0]==="enter")Z.push(Ke.length-1);else{const Je=Z.pop();o(Ke,Je)}for(T=Ke,fe=-1;++fe<T.length;){const Je=e[T[fe][0]];T[fe][0]==="enter"&&e.beforeEnter.length>0&&i(e.beforeEnter,{...Y,sliceSerialize:T[fe][2].sliceSerialize},T[fe][1]),id.call(Je,T[fe][1].type)&&Je[T[fe][1].type].call({...Y,sliceSerialize:T[fe][2].sliceSerialize},T[fe][1]),T[fe][0]==="exit"&&e.afterExit.length>0&&i(e.afterExit,{...Y,sliceSerialize:T[fe][2].sliceSerialize},T[fe][1])}if(Y.tokenStack.length>0){const Je=Y.tokenStack[Y.tokenStack.length-1];(Je[1]||_u).call(Y,void 0,Je[0])}for(z.position={start:kn(T.length>0?T[0][1].start:{line:1,column:1,offset:0}),end:kn(T.length>0?T[T.length-2][1].end:{line:1,column:1,offset:0})},fe=-1;++fe<e.transforms.length;)z=e.transforms[fe](z)||z;return z}function i(T,z,Y){let Z=-1;for(;++Z<T.length;)T[Z].call(z,Y)}function o(T,z){const Y=T.length-1;let Z=z-1,Ke=-1,fe=!1,Je,zt,ki,bi;const xi=[];for(;++Z<=Y;){const rt=T[Z];switch(rt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{rt[0]==="enter"?Ke++:Ke--,bi=void 0;break}case"lineEndingBlank":{rt[0]==="enter"&&(Je&&!bi&&!Ke&&!ki&&(ki=Z),bi=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:bi=void 0}if(!Ke&&rt[0]==="enter"&&rt[1].type==="listItemPrefix"||Ke===-1&&rt[0]==="exit"&&(rt[1].type==="listUnordered"||rt[1].type==="listOrdered")){if(Je){let Cr=Z;for(zt=void 0;Cr--;){const Ut=T[Cr];if(Ut[1].type==="lineEnding"||Ut[1].type==="lineEndingBlank"){if(Ut[0]==="exit")continue;zt&&(T[zt][1].type="lineEndingBlank",fe=!0),Ut[1].type="lineEnding",zt=Cr}else if(!(Ut[1].type==="linePrefix"||Ut[1].type==="blockQuotePrefix"||Ut[1].type==="blockQuotePrefixWhitespace"||Ut[1].type==="blockQuoteMarker"||Ut[1].type==="listItemIndent"))break}ki&&(!zt||ki<zt)&&(Je._spread=!0),Je.end=Object.assign({},zt?T[zt][1].start:rt[1].end),xi.push({at:zt||Z,event:["exit",Je,rt[2]]})}if(rt[1].type==="listItemPrefix"){const Cr={type:"listItem",_spread:!1,start:Object.assign({},rt[1].start),end:void 0};Je=Cr,xi.push({at:Z,event:["enter",Cr,rt[2]]}),ki=void 0,bi=!0}}}const Su=T.splice(z);let el=0;for(Z=-1;++Z<Su.length;){for(;el<xi.length&&xi[el].at===z+Z;)T.push(xi[el++].event);T.push(Su[Z])}T[z][1]._spread=fe}function s(T,z){return Y;function Y(Z){a.call(this,T(Z),Z),z&&z.call(this,Z)}}function l(){this.stack.push({type:"fragment",children:[]})}function a(T,z,Y){this.stack[this.stack.length-1].children.push(T),this.stack.push(T),this.tokenStack.push([z,Y||void 0]),T.position={start:kn(z.start),end:void 0}}function c(T){return z;function z(Y){T&&T.call(this,Y),u.call(this,Y)}}function u(T,z){const Y=this.stack.pop(),Z=this.tokenStack.pop();if(!Z)throw new Error("Cannot close `"+T.type+"` ("+vi({start:T.start,end:T.end})+"): it’s not open");Z[0].type!==T.type&&(z?z.call(this,T,Z[0]):(Z[1]||_u).call(this,T,Z[0])),Y.position.end=kn(T.end)}function h(){return Rs(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(T){if(this.data.expectingFirstListItemValue){const z=this.stack[this.stack.length-2];z.start=Number.parseInt(this.sliceSerialize(T),10),this.data.expectingFirstListItemValue=void 0}}function p(){const T=this.resume(),z=this.stack[this.stack.length-1];z.lang=T}function m(){const T=this.resume(),z=this.stack[this.stack.length-1];z.meta=T}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){const T=this.resume(),z=this.stack[this.stack.length-1];z.value=T.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function C(){const T=this.resume(),z=this.stack[this.stack.length-1];z.value=T.replace(/(\r?\n|\r)$/g,"")}function w(T){const z=this.resume(),Y=this.stack[this.stack.length-1];Y.label=z,Y.identifier=vt(this.sliceSerialize(T)).toLowerCase()}function v(){const T=this.resume(),z=this.stack[this.stack.length-1];z.title=T}function B(){const T=this.resume(),z=this.stack[this.stack.length-1];z.url=T}function S(T){const z=this.stack[this.stack.length-1];if(!z.depth){const Y=this.sliceSerialize(T).length;z.depth=Y}}function R(){this.data.setextHeadingSlurpLineEnding=!0}function F(T){const z=this.stack[this.stack.length-1];z.depth=this.sliceSerialize(T).codePointAt(0)===61?1:2}function ee(){this.data.setextHeadingSlurpLineEnding=void 0}function M(T){const Y=this.stack[this.stack.length-1].children;let Z=Y[Y.length-1];(!Z||Z.type!=="text")&&(Z=Kg(),Z.position={start:kn(T.start),end:void 0},Y.push(Z)),this.stack.push(Z)}function P(T){const z=this.stack.pop();z.value+=this.sliceSerialize(T),z.position.end=kn(T.end)}function j(T){const z=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Y=z.children[z.children.length-1];Y.position.end=kn(T.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(z.type)&&(M.call(this,T),P.call(this,T))}function ae(){this.data.atHardBreak=!0}function he(){const T=this.resume(),z=this.stack[this.stack.length-1];z.value=T}function ne(){const T=this.resume(),z=this.stack[this.stack.length-1];z.value=T}function ge(){const T=this.resume(),z=this.stack[this.stack.length-1];z.value=T}function se(){const T=this.stack[this.stack.length-1];if(this.data.inReference){const z=this.data.referenceType||"shortcut";T.type+="Reference",T.referenceType=z,delete T.url,delete T.title}else delete T.identifier,delete T.label;this.data.referenceType=void 0}function Re(){const T=this.stack[this.stack.length-1];if(this.data.inReference){const z=this.data.referenceType||"shortcut";T.type+="Reference",T.referenceType=z,delete T.url,delete T.title}else delete T.identifier,delete T.label;this.data.referenceType=void 0}function Ct(T){const z=this.sliceSerialize(T),Y=this.stack[this.stack.length-2];Y.label=rd(z),Y.identifier=vt(z).toLowerCase()}function k(){const T=this.stack[this.stack.length-1],z=this.resume(),Y=this.stack[this.stack.length-1];if(this.data.inReference=!0,Y.type==="link"){const Z=T.children;Y.children=Z}else Y.alt=z}function nt(){const T=this.resume(),z=this.stack[this.stack.length-1];z.url=T}function St(){const T=this.resume(),z=this.stack[this.stack.length-1];z.title=T}function b(){this.data.inReference=void 0}function qe(){this.data.referenceType="collapsed"}function A(T){const z=this.resume(),Y=this.stack[this.stack.length-1];Y.label=z,Y.identifier=vt(this.sliceSerialize(T)).toLowerCase(),this.data.referenceType="full"}function O(T){this.data.characterReferenceType=T.type}function _(T){const z=this.sliceSerialize(T),Y=this.data.characterReferenceType;let Z;Y?(Z=qf(z,Y==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Z=za(z);const Ke=this.stack[this.stack.length-1];Ke.value+=Z}function H(T){const z=this.stack.pop();z.position.end=kn(T.end)}function G(T){P.call(this,T);const z=this.stack[this.stack.length-1];z.url=this.sliceSerialize(T)}function re(T){P.call(this,T);const z=this.stack[this.stack.length-1];z.url="mailto:"+this.sliceSerialize(T)}function pe(){return{type:"blockquote",children:[],position:void 0}}function We(){return{type:"code",lang:null,meta:null,value:"",position:void 0}}function ze(){return{type:"inlineCode",value:"",position:void 0}}function dt(){return{type:"definition",identifier:"",label:null,title:null,url:"",position:void 0}}function Se(){return{type:"emphasis",children:[],position:void 0}}function Mt(){return{type:"heading",depth:0,children:[],position:void 0}}function bu(){return{type:"break",position:void 0}}function xu(){return{type:"html",value:"",position:void 0}}function Vg(){return{type:"image",title:null,url:"",alt:null,position:void 0}}function wu(){return{type:"link",title:null,url:"",children:[],position:void 0}}function Cu(T){return{type:"list",ordered:T.type==="listOrdered",start:null,spread:T._spread,children:[],position:void 0}}function Hg(T){return{type:"listItem",spread:T._spread,checked:null,children:[],position:void 0}}function qg(){return{type:"paragraph",children:[],position:void 0}}function Wg(){return{type:"strong",children:[],position:void 0}}function Kg(){return{type:"text",value:"",position:void 0}}function Jg(){return{type:"thematicBreak",position:void 0}}}function kn(t){return{line:t.line,column:t.column,offset:t.offset}}function od(t,e){let n=-1;for(;++n<e.length;){const r=e[n];Array.isArray(r)?od(t,r):gb(t,r)}}function gb(t,e){let n;for(n in e)if(id.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 _u(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+vi({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+vi({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+vi({start:e.start,end:e.end})+") is still open")}function Ql(t){const e=this;e.parser=n;function n(r){return pb(r,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}const Ps=(function(t){if(t==null)return xb;if(typeof t=="function")return Ls(t);if(typeof t=="object")return Array.isArray(t)?yb(t):kb(t);if(typeof t=="string")return bb(t);throw new Error("Expected function, string, or object as test")});function yb(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=Ps(t[n]);return Ls(r);function r(...i){let o=-1;for(;++o<e.length;)if(e[o].apply(this,i))return!0;return!1}}function kb(t){const e=t;return Ls(n);function n(r){const i=r;let o;for(o in t)if(i[o]!==e[o])return!1;return!0}}function bb(t){return Ls(e);function e(n){return n&&n.type===t}}function Ls(t){return e;function e(n,r,i){return!!(wb(n)&&t.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function xb(){return!0}function wb(t){return t!==null&&typeof t=="object"&&"type"in t}const sd=Ps(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]),$u={}.hasOwnProperty;function Cb(t,e){const n=e||{};function r(i,...o){let s=r.invalid;const l=r.handlers;if(i&&$u.call(i,t)){const a=String(i[t]);s=$u.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 Sb={}.hasOwnProperty;function ld(t,e){let n=-1,r;if(e.extensions)for(;++n<e.extensions.length;)ld(t,e.extensions[n]);for(r in e)if(Sb.call(e,r))switch(r){case"extensions":break;case"unsafe":{ju(t[r],e[r]);break}case"join":{ju(t[r],e[r]);break}case"handlers":{Mb(t[r],e[r]);break}default:t.options[r]=e[r]}return t}function ju(t,e){e&&t.push(...e)}function Mb(t,e){e&&Object.assign(t,e)}function Nb(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()),Tb);return i(),s}function Tb(t,e,n){return">"+(n?"":" ")+t}function ad(t,e){return Vu(t,e.inConstruct,!0)&&!Vu(t,e.notInConstruct,!1)}function Vu(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 Hu(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&&ad(n.stack,o))return/[\t ]/.test(r.before)?"":" "}return`\\
6
+ `}function Ib(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 Zo(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 Ab(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 vb(t,e,n,r){const i=Ab(n),o=t.value||"";if(Zo(t,n)){const h=n.enter("codeIndented"),d=n.indentLines(o,Eb);return h(),d}const s=n.createTracker(r),l=i.repeat(Math.max(Ib(o,i)+1,3)),a=n.enter("codeFenced"),c=i==="`"?"GraveAccent":"Tilde";let u=s.move(l);if(t.lang){const h=n.enter(`codeFencedLang${c}`);u+=s.move(n.safe(t.lang,{before:u,after:" ",encode:["`"],...s.current()})),h()}if(t.lang&&t.meta){const h=n.enter(`codeFencedMeta${c}`);u+=s.move(" "),u+=s.move(n.safe(t.meta,{before:u,after:`
7
+ `,encode:["`"],...s.current()})),h()}return u+=s.move(`
8
+ `),o&&(u+=s.move(o+`
9
+ `)),u+=s.move(l),a(),u}function Eb(t,e,n){return(n?"":" ")+t}function La(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 Ob(t,e,n,r){const i=La(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 Db(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 ms(t){const e=t.codePointAt(0);return e===void 0?"":String.fromCodePoint(e)}function Dr(t){const e=t.codePointAt(t.length-2);return e!==void 0&&e>65535?t.slice(-2):t.slice(-1)}function Ba(t){return"&#x"+t.toString(16).toUpperCase()+";"}function qu(t,e,n){const r=jt(t),i=jt(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 Xl(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:Ae(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(!Ae(o))return;for(;o===45||$e(o);)o=t.charCodeAt(++i);const s=t.slice(r,i).toLowerCase();return!n&&o!==47&&Gl.includes(s)?1:ed.includes(s)?6:7}const cd=new Map([["*",!1],["_",!0]]);function Rb(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 ud(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=cd.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,h=jt(u.charCodeAt(u.length-1)),d=jt((c<t.length?t[c].value:n).charCodeAt(0)),f=!d||d===2&&!!h,p=!h||h===2&&!!d,m={tokens:t.slice(s,c),markers:[],start:0,end:0,open:a?f&&(!!h||!p):f,close:a?p&&(!!d||!f):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(Lb(r,i),s=-1;++s<t.length;){const l=i.get(t[s]);if(l)return{attention:Rb(t,l,o),index:s}}}function zb(t,e,n){return To(hd(t,e,n),n.before,n.after)}function Vo(t,e){const n=t[e?0:t.length-1];if(!n||n.attention)return;const r=e?ms(n.value):Dr(n.value),i=Ba(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 Pb(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=Bs(t,a,r,i),u=ud(c,r,i);if(!u||u.index>n.index)return{chosen:a,mistake:u,tokens:c}}}}function Lb(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,h=l.markers.slice(l.end-u,l.end),d=r.markers.slice(r.start,r.start+u),f=h[0],p=d[0];if(f===h[u-1]&&f.value.length===u&&p===d[u-1]&&p.value.length===u&&f.attention===p.attention)e.delete(f),e.delete(p);else{const m=[...new Set([...h,...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 Bb(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(!Wf(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 hd(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 f=e.handle.handlers[i[s+1].type];f&&f.peek&&(f=f.peek),u=f?ms(f(i[s+1],t,e,{before:"",after:"",...a.current()})):""}else u=n.after;const h=o[o.length-1];typeof h=="string"&&(l==="\r"||l===`
11
+ `)&&c.type==="html"&&Xl(c.value)!==7&&(o[o.length-1]=h.replace(/(\r?\n|\r)$/," "),l=" ",a=e.createTracker(n),a.move(To(o,n.before,n.after)));const d=e.handle.handlers[c.type];if(d&&d.attention){const f=Fa(c,d.attention,e,a);if(!f)continue;o.push(f),l=Dr(f.sequences[0])}else{const f=e.handle(c,t,e,{...a.current(),after:u,before:l});if(!f)continue;a.move(f),o.push(f),l=Dr(f)}}return r.pop(),o}function Fa(t,e,n,r){const{construct:i,markers:o,sizes:s}=e(t,n),l=Bb(t.type,o,s),a=l[0],c=n.enter(i),u=n.createTracker(r.current());u.move(a);const h=hd(t,n,{...u.current(),before:a,after:a});if(c(),h.length!==0)return r.move(a),r.move(To(h,a,a)),r.move(a),{children:h,sequences:l}}function Wu(t,e,n,r){let i=Bs(t,e,n,r),o=ud(i,n,r);for(;o;){const s=Pb(t,e,o,n,r);if(!s)return;e=s.chosen,i=s.tokens,o=s.mistake}return i}function fd(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&&cd.has(u)&&c.length>n.length})||s.sequences[0];a!==s.sequences[0]&&e.set(s,a),fd(s.children,e,a,a),i=a}}function Bs(t,e,n,r){const i=[];let o,s=Dr(n),l=-1;for(;++l<t.length;){const a=t[l];if(typeof a=="string"){const w={value:a,attention:void 0};o&&o===ms(a)&&Vo([w],!0),o=void 0,i.push(w),w.value&&(s=Dr(w.value));continue}const c=e.get(a)||a.sequences[0],u=c.charAt(0),h=t[l+1],d=s,f=ms(h===void 0?r:typeof h=="string"?h:e.get(h)||h.sequences[0]),p=Bs(a.children,e,c,c),m=p[0].value,y=qu(d.charCodeAt(d.length-1),m.charCodeAt(0),u);y.inside&&Vo(p,!0);const g=Dr(p[p.length-1].value),C=qu(f.charCodeAt(0),g.charCodeAt(g.length-1),u);C.inside&&Vo(p,!1),y.outside&&d!==`
12
+ `&&d!=="\r"&&Vo(i,!1),C.outside&&(o=f),i.push({value:c,attention:a},...p,{value:c,attention:a}),s=c.charAt(c.length-1)}return i}function To(t,e,n){const r=new Map;fd(t,r,e,n);const i=(r.size>0?Wu(t,r,e,n):void 0)||Wu(t,new Map,e,n)||Bs(t,new Map,e,n);let o="";for(const s of i)o+=s.value;return o}_a.attention=dd;_a.peek=Fb;function _a(t,e,n,r){const i=n.enter("phrasing"),o=Fa(t,dd,n,n.createTracker(r)),s=o?To([o],r.before,r.after):"";return i(),s}function dd(t,e){return{construct:"emphasis",markers:Db(e)==="*"?["*","_"]:["_","*"],sizes:[1]}}function Fb(t,e,n){return n.options.emphasis||"*"}const pd=[],_b=!0,Ei=!1,ni="skip";function gs(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=Ps(o),u=i?1:-1;h(t,void 0,[])();function h(d,f,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,f,p[p.length-1]||void 0);let C=pd;if(l&&g&&(C=Ku(l(d,p,f)),C[0]===Ei))return C;if("children"in d&&d.children){const w=d;if(w.children&&C[0]!==ni){let v=(i?-1:w.children.length)+u;const B=[...p,w];for(;v>-1&&v<w.children.length;){const S=w.children[v],R=h(S,v,B)();if(R[0]===Ei)return R;v=typeof R[1]=="number"?R[1]:v+u}}}if(a&&g){const w=Ku(a(d,p,f));if(w[0]===ni)throw new Error("Unexpected value `"+w[0]+"` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing");if(w[0]===Ei||typeof w[1]=="number")return w}return C}}}function Ku(t){return Array.isArray(t)?t:typeof t=="number"?[_b,t]:t==null?pd:[t]}function kr(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"?gs(t,i,Zl(o),s):gs(t,i,$b(o),s)}function $b(t){return!t||typeof t!="object"?t:{enter:typeof t.enter=="function"?Zl(t.enter):t.enter,exit:typeof t.exit=="function"?Zl(t.exit):t.exit}}function Zl(t){return e;function e(n,r,i){return t(n,i,r[r.length-1])}}function md(t,e){let n=!1;return kr(t,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Ei}),!!((!t.depth||t.depth<3)&&Rs(t)&&(e.options.setext||n))}function jb(t,e,n,r){const i=Math.max(Math.min(6,t.depth||1),1),o=n.createTracker(r);if(md(t,n)){const h=n.enter("headingSetext"),d=n.enter("phrasing"),f=n.containerPhrasing(t,{...o.current(),before:`
13
+ `,after:`
14
+ `});return d(),h(),f+`
15
+ `+(i===1?"=":"-").repeat(f.length-(Math.max(f.lastIndexOf("\r"),f.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=Ba(u)+c.slice(1)),c=c?s+" "+c:s,n.options.closeAtx&&(c+=" "+s),a(),l(),c}gd.peek=Vb;function gd(t){return t.value||""}function Vb(){return"<"}yd.peek=Hb;function yd(t,e,n,r){const i=La(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 Hb(){return"!"}kd.peek=qb;function kd(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 h=n.safe(n.associationId(t),{before:a,after:"]",...l.current()});return s(),n.stack=u,o(),i==="full"||!c||c!==h?a+=l.move(h+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function qb(){return"!"}bd.peek=Wb;function bd(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 Wb(){return"`"}function xd(t,e){const n=Rs(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))}wd.peek=Kb;function wd(t,e,n,r){const i=La(n),o=i==='"'?"Quote":"Apostrophe",s=n.createTracker(r);if(xd(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 h=/[\0- \u007F]/.test(t.url),d=r.before.charAt(r.before.length-1);let f=t.title||void 0;if(!f&&!h&&(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&&(f="")}return!t.url&&typeof f=="string"||h?(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 f=="string"?" ":")",...s.current()}))),a(),typeof f=="string"&&(a=n.enter(`title${o}`),c+=s.move(" "+i),c+=s.move(n.safe(f,{before:c,after:i,...s.current()})),c+=s.move(i),a()),c+=s.move(")"),l(),c}function Kb(t,e,n){return xd(t,n)?"<":"["}Cd.peek=Jb;function Cd(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 h=n.safe(n.associationId(t),{before:a,after:"]",...l.current()});return s(),n.stack=u,o(),i==="full"||!c||c!==h?a+=l.move(h+"]"):i==="shortcut"?a=a.slice(0,-1):a+=l.move("]"),a}function Jb(){return"["}function $a(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 Ub(t){const e=$a(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 Gb(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 ja(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 Yb(t,e,n,r){const i=n.enter("list"),o=n.bulletCurrent;let s=t.ordered?Gb(n):$a(n);const l=t.ordered?s==="."?")":".":Ub(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),ja(n)===s&&u){let h=-1;for(;++h<t.children.length;){const d=t.children[h];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 Qb(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 Xb(t,e,n,r){const i=Qb(n);let o=n.bulletCurrent||$a(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(h,d,f){return d?(f?"":" ".repeat(s))+h:(f?o:o+" ".repeat(s-o.length))+h}}function Zb(t,e,n,r){const i=n.enter("paragraph"),o=n.enter("phrasing"),s=n.containerPhrasing(t,r);return o(),i(),s}function e1(t,e,n,r){if(!t.children.some(function(l){return sd(l)}))return n.containerFlow(t,r);const o=n.enter("phrasing"),s=n.containerPhrasing(t,r);return o(),s}function t1(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}Va.attention=Sd;Va.peek=n1;function Va(t,e,n,r){const i=n.enter("phrasing"),o=Fa(t,Sd,n,n.createTracker(r)),s=o?To([o],r.before,r.after):"";return i(),s}function Sd(t,e){return{construct:"strong",markers:t1(e)==="*"?["*","_"]:["_","*"],sizes:[2]}}function n1(t,e,n){return n.options.strong||"*"}function r1(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 i1(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 o1(t,e,n){const r=(ja(n)+(n.options.ruleSpaces?" ":"")).repeat(i1(n));return n.options.ruleSpaces?r.slice(0,-1):r}const ys={blockquote:Nb,break:Hu,code:vb,definition:Ob,emphasis:_a,hardBreak:Hu,heading:jb,html:gd,image:yd,imageReference:kd,inlineCode:bd,link:wd,linkReference:Cd,list:Yb,listItem:Xb,paragraph:Zb,root:e1,strong:Va,text:r1,thematicBreak:o1},s1=[l1];function l1(t,e,n,r){if(e.type==="code"&&Zo(e,r)&&(t.type==="list"||t.type===e.type&&Zo(t,r)))return!1;if("spread"in n&&typeof n.spread=="boolean"){if(n.spread)return 1;if(t.type==="html"){const o=Xl(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"&&ja(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"&&Zo(e,r))return 1;if(e.type==="html"){const o=Xl(e.value);if(o===void 0||o===7)return 1}return(t.type==="paragraph"||t!==i)&&(e.type==="definition"||e.type==="heading"&&md(e,r)||e.type==="paragraph")?1:0}}const _n=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],Md=[{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:_n},{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:_n},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:`(?:[ \r
23
+ *])`},{character:"*",inConstruct:"phrasing",notInConstruct:_n},{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:_n},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:_n},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:_n},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:_n},{atBreak:!0,character:"~"},{character:"<",inConstruct:"autolink"},{character:">",inConstruct:"autolink"},{character:"",inConstruct:"autolink"}];let Ju=-1;for(;++Ju<33;)Md.push({character:String.fromCharCode(Ju),inConstruct:"autolink"});function a1(t){return t.label||!t.identifier?t.label||"":rd(t.identifier)}function c1(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 u1(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(h1(a,i[l+1],t,e)))}return r.pop(),s.join("")}function h1(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 f1=/\r?\n|\r/g;function d1(t,e){const n=[];let r=0,i=0,o;for(;o=f1.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 il={}.hasOwnProperty;function p1(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 f=t.unsafe[u];if(!ad(t.stack,f)||!Uu(f.beforeNode,n.beforeNode)||!Uu(f.afterNode,n.afterNode))continue;const p=t.compilePattern(f),m=f.beforeNode?a:0,y=r.slice(m,f.afterNode?c:void 0);let g;for(;g=p.exec(y);){const C=!!(f.before||f.atBreak),w=!!f.after,v=m+g.index+(C?g[1].length:0);il.call(s,v)?(s[v].before&&!C&&(s[v].before=!1),s[v].after&&!w&&(s[v].after=!1)):(i.push(v),s[v]={before:C,after:w})}}i.sort(m1);let h=a;for(u=-1;++u<i.length;){const f=i[u];if(!(f<h||f>=c)){if(r.charAt(f)==="_"&&f>0&&jt(r.charCodeAt(f-1))===void 0&&!il.call(s,f-1)&&!(f-1===a&&/[*_]/.test(r.charAt(a-1)))){let p=f+1;for(;p<c&&r.charAt(p)==="_";)p++;const m=p-f-1;if(i[u+m]===p-1&&p<r.length&&jt(r.charCodeAt(p))===void 0&&!il.call(s,p)&&!(p===c-1&&/[*_]/.test(r.charAt(c)))){u+=m;continue}}if(!(f+1<c&&i[u+1]===f+1&&s[f].after&&!s[f+1].before&&!s[f+1].after||f-1>=a&&i[u-1]===f-1&&s[f].before&&!s[f-1].before&&!s[f-1].after)){if(h!==f){const p=r.slice(h,f);o.push(l?p:Gu(p,"\\"))}h=f+1,l?o.push("%"+r.charCodeAt(f).toString(16).toUpperCase().padStart(2,"0")):/[!-/:-@[-`{-~]/.test(r.charAt(f))&&(!n.encode||!n.encode.includes(r.charAt(f)))?o.push("\\"+r.charAt(f)):o.push(Ba(r.charCodeAt(f)))}}}const d=r.slice(h,c);return o.push(l?d:Gu(d,n.after)),o.join("")}function Uu(t,e){return t?e?typeof t=="string"?t===e.type:t.includes(e.type):!1:!0}function m1(t,e){return t-e}function Gu(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 g1(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||"",h=u.split(/\r?\n|\r/g),d=h[h.length-1];return i+=h.length-1,o=h.length===1?o+d.length:1+d.length+r,u}}function y1(t,e){const n=e||{},r={associationId:a1,bulletCurrent:void 0,bulletLastUsed:void 0,containerPhrasing:w1,containerFlow:C1,createTracker:g1,compilePattern:c1,enter:o,handlers:{...ys},handle:void 0,indentLines:d1,indexStack:[],join:[...s1],options:{},safe:S1,stack:[],unsafe:[...Md]};ld(r,n),r.options.tightDefinitions&&r.join.push(x1),r.handle=Cb("type",{invalid:k1,unknown:b1,handlers:r.handlers});let i=r.handle(sd(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 k1(t){throw new Error("Cannot handle value `"+t+"`, expected node")}function b1(t){const e=t;throw new Error("Cannot handle unknown node `"+e.type+"`")}function x1(t,e){if(t.type==="definition"&&t.type===e.type)return 0}function w1(t,e){return zb(t,this,e)}function C1(t,e){return u1(t,this,e)}function S1(t,e){return p1(this,t,e)}function ea(t){const e=this;e.compiler=n;function n(r){return y1(r,{...e.data("settings"),...t,extensions:e.data("toMarkdownExtensions")||[]})}}function Yu(t){if(t)throw t}var ol,Qu;function M1(){if(Qu)return ol;Qu=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"),h=c.constructor&&c.constructor.prototype&&t.call(c.constructor.prototype,"isPrototypeOf");if(c.constructor&&!u&&!h)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 ol=function a(){var c,u,h,d,f,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)h=l(m,u),d=l(c,u),m!==d&&(C&&d&&(o(d)||(f=i(d)))?(f?(f=!1,p=h&&i(h)?h:[]):p=h&&o(h)?h:{},s(m,{name:u,newValue:a(C,p,d)})):typeof d<"u"&&s(m,{name:u,newValue:d}));return m},ol}var N1=M1();const sl=ry(N1);function ta(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 T1(){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 h=-1;if(a){s(a);return}for(;++h<i.length;)(c[h]===null||c[h]===void 0)&&(c[h]=i[h]);i=c,u?I1(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 I1(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 Nd 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=vi(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(Nd.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 Pt={basename:A1,dirname:v1,extname:E1,join:O1,sep:"/"};function A1(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Io(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 v1(t){if(Io(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 E1(t){Io(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 O1(...t){let e=-1,n;for(;++e<t.length;)Io(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":D1(n)}function D1(t){Io(t);const e=t.codePointAt(0)===47;let n=R1(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function R1(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 Io(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const z1={cwd:P1};function P1(){return"/"}function na(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function L1(t){if(typeof t=="string")t=new URL(t);else if(!na(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 B1(t)}function B1(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 ll=["history","path","basename","stem","extname","dirname"];class F1{constructor(e){let n;e?na(e)?n={path:e}:typeof e=="string"||_1(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":z1.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<ll.length;){const o=ll[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)ll.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Pt.basename(this.path):void 0}set basename(e){cl(e,"basename"),al(e,"basename"),this.path=Pt.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Pt.dirname(this.path):void 0}set dirname(e){Xu(this.basename,"dirname"),this.path=Pt.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Pt.extname(this.path):void 0}set extname(e){if(al(e,"extname"),Xu(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=Pt.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){na(e)&&(e=L1(e)),cl(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Pt.basename(this.path,this.extname):void 0}set stem(e){cl(e,"stem"),al(e,"stem"),this.path=Pt.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 Nd(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 al(t,e){if(t&&t.includes(Pt.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Pt.sep+"`")}function cl(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function Xu(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function _1(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const $1=(function(t){const r=this.constructor.prototype,i=r[t],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o}),j1={}.hasOwnProperty;class Ha extends $1{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=T1()}copy(){const e=new Ha;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];e.use(...r)}return e.data(sl(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(fl("data",this.frozen),this.namespace[e]=n,this):j1.call(this.namespace,e)&&this.namespace[e]||void 0:e?(fl("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=Ho(e),r=this.parser||this.Parser;return ul("parse",r),r(String(n),n)}process(e,n){const r=this;return this.freeze(),ul("process",this.parser||this.Parser),hl("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(o,s){const l=Ho(e),a=r.parse(l);r.run(a,l,function(u,h,d){if(u||!h||!d)return c(u);const f=h,p=r.stringify(f,d);H1(p)?d.value=p:d.result=p,c(u,d)});function c(u,h){u||!h?s(u):o?o(h):n(void 0,h)}}}processSync(e){let n=!1,r;return this.freeze(),ul("processSync",this.parser||this.Parser),hl("processSync",this.compiler||this.Compiler),this.process(e,i),eh("processSync","process",n),r;function i(o,s){n=!0,Yu(o),r=s}}run(e,n,r){Zu(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=Ho(n);i.run(e,a,c);function c(u,h,d){const f=h||e;u?l(u):s?s(f):r(void 0,f,d)}}}runSync(e,n){let r=!1,i;return this.run(e,n,o),eh("runSync","run",r),i;function o(s,l){Yu(s),i=l,r=!0}}stringify(e,n){this.freeze();const r=Ho(n),i=this.compiler||this.Compiler;return hl("stringify",i),Zu(e),i(e,r)}use(e,...n){const r=this.attachers,i=this.namespace;if(fl("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,...h]=c;a(u,h)}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=sl(!0,i.settings,c.settings))}function l(c){let u=-1;if(c!=null)if(Array.isArray(c))for(;++u<c.length;){const h=c[u];o(h)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function a(c,u){let h=-1,d=-1;for(;++h<r.length;)if(r[h][0]===c){d=h;break}if(d===-1)r.push([c,...u]);else if(u.length>0){let[f,...p]=u;const m=r[d][1];ta(m)&&ta(f)&&(f=sl(!0,m,f)),r[d]=[c,f,...p]}}}}const ra=new Ha().freeze();function ul(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function hl(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function fl(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 Zu(t){if(!ta(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function eh(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function Ho(t){return V1(t)?t:new F1(t)}function V1(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function H1(t){return typeof t=="string"||q1(t)}function q1(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}function Te(t){this.content=t}Te.prototype={constructor:Te,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 Te(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 Te(n)},addToStart:function(t,e){return new Te([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Te(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 Te(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=Te.from(t),t.size?new Te(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Te.from(t),t.size?new Te(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Te.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}};Te.from=function(t){if(t instanceof Te)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Te(e)};function Td(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&&vd(s.charCodeAt(a-1))&&Ad(s.charCodeAt(a))&&n--,n}if(i.content.size||o.content.size){let s=Td(i.content,o.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function Id(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,h=c.length,d=u.length;for(;h>0&&d>0&&c[h-1]==u[d-1];)h--,d--,n--,r--;return h&&d&&h<c.length&&vd(c.charCodeAt(h-1))&&Ad(c.charCodeAt(h))&&(n++,r++),{a:n,b:r}}if(s.content.size||l.content.size){let c=Id(s.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}function Ad(t){return t>=56320&&t<57344}function vd(t){return t>=55296&&t<56320}class E{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 E(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 E(r,i)}cutByIndex(e,n){return e==n?E.empty:e==0&&n==this.content.length?this:new E(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 E(i,o)}addToStart(e){return new E([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new E(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 Td(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Id(this,e,n,r)}findIndex(e){if(e==0)return qo(0,e);if(e==this.size)return qo(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?qo(n+1,o):qo(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 E.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return E.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return E.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 E(n||e,r)}static from(e){if(!e)return E.empty;if(e instanceof E)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new E([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}E.empty=new E([],0);const dl={index:0,offset:0};function qo(t,e){return dl.index=t,dl.offset=e,dl}function ks(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(!ks(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!ks(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class oe{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&&ks(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 oe.none;if(e instanceof oe)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}}oe.none=[];class Hi extends Error{}class L{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=Od(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new L(r,this.openStart,this.openEnd)}removeBetween(e,n){return new L(Ed(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 L.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 L(E.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 L(e,r,i)}}L.empty=new L(E.empty,0,0);function Ed(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(Ed(o.content,e-i-1,n-i-1)))}function Od(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=Od(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 W1(t,e,n){if(n.openStart>t.depth)throw new Hi("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Hi("Inconsistent open depths");return Dd(t,e,n,0)}function Dd(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=Dd(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 Xn(s,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=K1(n,t);return Xn(o,zd(t,s,l,e,r))}else return Xn(o,bs(t,e,r))}function Rd(t,e){if(!e.type.compatibleContent(t.type))throw new Hi("Cannot join "+e.type.name+" onto "+t.type.name)}function ia(t,e,n){let r=t.node(n);return Rd(r,e.node(n)),r}function Qn(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 Oi(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&&(Qn(t.nodeAfter,r),o++));for(let l=o;l<s;l++)Qn(i.child(l),r);e&&e.depth==n&&e.textOffset&&Qn(e.nodeBefore,r)}function Xn(t,e){if(!t.type.validContent(e))throw new Hi("Invalid content for node "+t.type.name);return t.copy(e)}function zd(t,e,n,r,i){let o=t.depth>i&&ia(t,e,i+1),s=r.depth>i&&ia(n,r,i+1),l=[];return Oi(null,t,i,l),o&&s&&e.index(i)==n.index(i)?(Rd(o,s),Qn(Xn(o,zd(t,e,n,r,i+1)),l)):(o&&Qn(Xn(o,bs(t,e,i+1)),l),Oi(e,n,i,l),s&&Qn(Xn(s,bs(n,r,i+1)),l)),Oi(r,null,i,l),new E(l)}function bs(t,e,n){let r=[];if(Oi(null,t,n,r),t.depth>n){let i=ia(t,e,n+1);Qn(Xn(i,bs(t,e,n+1)),r)}return Oi(e,null,n,r),new E(r)}function K1(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(E.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class qi{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 oe.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 Pd(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 qi(n,r,o)}static resolveCached(e,n){let r=th.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 th.set(e,r=new J1);let i=r.elts[r.i]=qi.resolve(e,n);return r.i=(r.i+1)%U1,i}}class J1{constructor(){this.elts=[],this.i=0}}const U1=12,th=new WeakMap;class Pd{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 G1=Object.create(null);class kt{constructor(e,n,r,i=oe.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||E.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&&ks(this.attrs,n||e.defaultAttrs||G1)&&oe.sameSet(this.marks,r||oe.none)}copy(e=null){return e==this.content?this:new kt(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new kt(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 L.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 L(c,i.depth-s,o.depth-s)}replace(e,n,r){return W1(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 qi.resolveCached(this,e)}resolveNoCache(e){return qi.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()+")"),Ld(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=E.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),rh(this.type.attrs,this.attrs,"node",this.type.name);let e=oe.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];rh(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!oe.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=E.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,i,r)}}kt.prototype.text=void 0;const nh=(()=>{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 xs extends kt{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):Ld(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return nh(this.text.slice(e,n))}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new xs(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new xs(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(nh(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 Ld(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}function rh(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 ar{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Y1(e,n);if(r.next==null)return ar.empty;let i=Bd(r);r.next&&r.err("Unexpected trailing text");let o=rx(nx(i));return ix(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 E.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:h}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(h)==-1){i.push(h);let d=o(h,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
+ `)}}ar.empty=new ar(!0);class Y1{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 Bd(t){let e=[];do e.push(Q1(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Q1(t){let e=[];do e.push(X1(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function X1(t){let e=tx(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=Z1(t,e);else break;return e}function ih(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Z1(t,e){let n=ih(t),r=n;return t.eat(",")&&(t.next!="}"?r=ih(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function ex(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 tx(t){if(t.eat("(")){let e=Bd(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=ex(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 nx(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 Fd(t,e){return e-t}function oh(t,e){let n=[];return r(e),n.sort(Fd);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 rx(t){let e=Object.create(null);return n(oh(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]);oh(t,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new ar(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(Fd);o.next.push({type:i[s][0],next:e[l.join(",")]||n(l)})}return o}}function ix(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 _d(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 $d(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 jd(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new sx(t,r,e[r]);return n}let cr=class Vd{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=jd(e,r.attrs),this.defaultAttrs=_d(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==ar.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:$d(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new kt(this,this.computeAttrs(e),E.from(n),oe.setFrom(r))}createChecked(e=null,n,r){return n=E.from(n),this.checkContent(n),new kt(this,this.computeAttrs(e),n,oe.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=E.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(E.empty,!0);return o?new kt(this,e,n.append(o),oe.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:oe.none:e}static compile(e,n){let r=Object.create(null);e.forEach((o,s)=>r[o]=new Vd(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 ox(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 sx{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?ox(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Fs{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=jd(e,i.attrs),this.excluded=null;let o=_d(this.attrs);this.instance=o?new oe(this,o):null}create(e=null){return!e&&this.instance?this.instance:new oe(this,$d(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new Fs(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 lx{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=Te.from(e.nodes),n.marks=Te.from(e.marks||{}),this.nodes=cr.compile(this.spec.nodes,this),this.marks=Fs.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]=ar.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?sh(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==""?[]:sh(this,s.split(" "))}this.nodeFromJSON=i=>kt.fromJSON(this,i),this.markFromJSON=i=>oe.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 cr){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 xs(r,r.defaultAttrs,e,oe.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 sh(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 ax(t){return t.tag!=null}function cx(t){return t.style!=null}class ur{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(ax(i))this.tags.push(i);else if(cx(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 ah(this,n,!1);return r.addAll(e,oe.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new ah(this,n,!0);return r.addAll(e,oe.none,n.from,n.to),L.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(fx(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=ch(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=ch(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new ur(e,ur.schemaRules(e)))}}const Hd={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},ux={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},qd={ol:!0,ul:!0},Wi=1,oa=2,Di=4;function lh(t,e,n){return e!=null?(e?Wi:0)|(e==="full"?oa:0):t&&t.whitespace=="pre"?Wi|oa:n&~Di}class Wo{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=oe.none,this.match=o||(s&Di?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(E.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&Wi)){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=E.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(E.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&&!Hd.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ah{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=lh(null,n.preserveWhitespace,0)|(r?Di:0);i?o=new Wo(i.type,i.attrs,oe.none,!0,n.topMatch||i.type.contentMatch,s):r?o=new Wo(null,null,oe.none,!0,null,s):o=new Wo(e.schema.topNodeType,null,oe.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&oa?"full":this.localPreserveWS||(i.options&Wi)>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;qd.hasOwnProperty(s)&&this.parser.normalizeLists&&hx(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:ux.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(Hd.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 h=a&&a.skip?n:this.readStyles(e,n);h&&this.addAll(e,h),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=oe.none;for(let l of i.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):uh(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=lh(e,o,s.options);s.options&Di&&s.content.length==0&&(l|=Di);let a=oe.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):uh(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Wo(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|=Wi)}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 hx(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&qd.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function fx(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ch(t){let e={};for(let n in t)e[n]=t[n];return e}function uh(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 br{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Ko(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 Ko(n).createTextNode(e.text);let{dom:r,contentDOM:i}=es(Ko(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&&es(Ko(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return typeof n=="string"?{dom:e.createTextNode(n)}:es(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new br(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=hh(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return hh(e.marks)}}function hh(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Ko(t){return t.document||window.document}const fh=new WeakMap;function dx(t){let e=fh.get(t);return e===void 0&&fh.set(t,e=px(t)),e}function px(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 es(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=dx(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 h in c)if(c[h]!=null){let d=h.indexOf(" ");d>0?a.setAttributeNS(h.slice(0,d),h.slice(d+1),c[h]):h=="style"&&a.style?a.style.cssText=c[h]:a.setAttribute(h,c[h])}}for(let h=u;h<e.length;h++){let d=e[h];if(d===0){if(h<e.length-1||h>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:f,contentDOM:p}=es(t,d,n,r);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Wd=65535,Kd=Math.pow(2,16);function mx(t,e){return t+e*Kd}function dh(t){return t&Wd}function gx(t){return(t-(t&Wd))/Kd}const Jd=1,Ud=2,ts=4,Gd=8;class sa{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Gd)>0}get deletedBefore(){return(this.delInfo&(Jd|ts))>0}get deletedAfter(){return(this.delInfo&(Ud|ts))>0}get deletedAcross(){return(this.delInfo&ts)>0}}class ot{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ot.empty)return ot.empty}recover(e){let n=0,r=dh(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+gx(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],h=a+c;if(e<=h){let d=c?e==a?-1:e==h?1:n:n,f=a+i+(d<0?0:u);if(r)return f;let p=e==(n<0?a:h)?null:mx(l/3,e-a),m=0;return c&&(m|=e==a?Ud:e==h?Jd:ts,(n<0?e!=a:e!=h)&&(m|=Gd)),new sa(f,m,p)}i+=u-c}return r?e+i:new sa(e+i,0,null)}touches(e,n){let r=0,i=dh(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 ot(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ot.empty:new ot(e<0?[0,-e,0]:[0,0,e])}}ot.empty=new ot([]);class Ki{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 Ki(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 Ki;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 sa(e,i,null)}}const pl=Object.create(null);class we{getMap(){return ot.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=pl[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 pl)throw new RangeError("Duplicate use of step JSON ID "+e);return pl[e]=n,n.prototype.jsonID=e,n}}class ye{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ye(e,null)}static fail(e){return new ye(null,e)}static fromReplace(e,n,r,i){try{return ye.ok(e.replace(n,r,i))}catch(o){if(o instanceof Hi)return ye.fail(o.message);throw o}}}function qa(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let o=t.child(i);o.content.size&&(o=o.copy(qa(o.content,e,o))),o.isInline&&(o=e(o,n,i)),r.push(o)}return E.fromArray(r)}class Ft extends we{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 L(qa(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 ye.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(!oe.sameSet(o,r.marks)){let s=Math.max(this.from,i),l=Math.min(this.to,i+r.nodeSize);ws(ln,s,l,this.mark,n);for(let a of r.marks)a.isInSet(o)||ws(Ft,s,l,a,n)}}}),n.length==1?n[0]:new Zn(n)}map(e){let n=e.map(this.from,1),r=e.map(this.to,-1);return n>=r?null:new Ft(n,r,this.mark)}merge(e){return e instanceof Ft&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ft(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 Ft(n.from,n.to,e.markFromJSON(n.mark))}}we.jsonID("addMark",Ft);class ln extends we{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 L(qa(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ye.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)&&ws(Ft,Math.max(this.from,i),Math.min(this.to,i+r.nodeSize),this.mark,n)}),n.length==1?n[0]:new Zn(n)}map(e){let n=e.map(this.from,1),r=e.map(this.to,-1);return n>=r?null:new ln(n,r,this.mark)}merge(e){return e instanceof ln&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ln(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 ln(n.from,n.to,e.markFromJSON(n.mark))}}we.jsonID("removeMark",ln);function ws(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 Zn extends we{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 ye(e,null)}invert(e){return new Zn(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 Zn(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 Zn(n.steps.map(r=>we.fromJSON(e,r)))}}we.jsonID("markSet",Zn);class vn extends we{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ye.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ye.fromReplace(e,this.pos,this.pos+1,new L(E.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 vn(this.pos,n.marks[i]);return new vn(this.pos,this.mark)}}return new hr(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new vn(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 vn(n.pos,e.markFromJSON(n.mark))}}we.jsonID("addNodeMark",vn);class hr extends we{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ye.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ye.fromReplace(e,this.pos,this.pos+1,new L(E.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new vn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new hr(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 hr(n.pos,e.markFromJSON(n.mark))}}we.jsonID("removeNodeMark",hr);class ke extends we{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&la(e,this.from,this.to)?ye.fail("Structure replace would overwrite content"):ye.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ot([this.from,this.to-this.from,this.slice.size])}invert(e){return new ke(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&&ke.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new ke(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ke)||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?L.empty:new L(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ke(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?L.empty:new L(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ke(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 ke(n.from,n.to,L.fromJSON(e,n.slice),!!n.structure)}}ke.MAP_BIAS=1;we.jsonID("replace",ke);class Be extends we{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&&(la(e,this.from,this.gapFrom)||la(e,this.gapTo,this.to)))return ye.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ye.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ye.fromReplace(e,this.from,this.to,r):ye.fail("Content does not fit in gap")}getMap(){return new ot([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 Be(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 Be(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 Be(n.from,n.to,n.gapFrom,n.gapTo,L.fromJSON(e,n.slice),n.insert,!!n.structure)}}we.jsonID("replaceAround",Be);function la(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 yx(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);ws(Ft,c,u,r,i)}}),i.forEach(o=>t.step(o))}function kx(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 Fs){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 h=a[u],d;for(let f=0;f<i.length;f++){let p=i[f];p.step==o-1&&h.eq(i[f].style)&&(d=p)}d?(d.to=c,d.step=o):i.push({style:h,from:Math.max(l,e),to:c,step:o})}}}),i.forEach(s=>t.step(new ln(s.from,s.to,s.style)))}function Wa(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,h=r.matchType(c.type);if(!h)s.push(new ke(l,u,L.empty));else{r=h;for(let d=0;d<c.marks.length;d++)n.allowsMarkType(c.marks[d].type)||t.step(new ln(l,u,c.marks[d]));if(i&&c.isText&&n.whitespace!="pre"){let d,f=/\r?\n|\r/g,p;for(;d=f.exec(c.text);)p||(p=new L(E.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new ke(l+d.index,l+d.index+d[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(E.empty,!0);t.replace(l,l,new L(a,0,0))}for(let a=s.length-1;a>=0;a--)t.step(s[a])}function bx(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function _s(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||!bx(s,l,a))break;l&&(i=1),a<s.childCount&&(o=1)}return null}function xx(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=E.empty,h=0;for(let p=o,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,u=E.from(r.node(p).copy(u)),h++):a--;let d=E.empty,f=0;for(let p=o,m=!1;p>n;p--)m||i.after(p+1)<i.end(p)?(m=!0,d=E.from(i.node(p).copy(d)),f++):c++;t.step(new Be(a,c,s,l,new L(u.append(d),h,f),u.size-h,!0))}function Ka(t,e,n=null,r=t){let i=wx(t,e),o=i&&Cx(r,e);return o?i.map(ph).concat({type:e,attrs:n}).concat(o.map(ph)):null}function ph(t){return{type:t,attrs:null}}function wx(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 Cx(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 Sx(t,e,n){let r=E.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=E.from(n[s].type.create(n[s].attrs,r))}let i=e.start,o=e.end;t.step(new Be(i,o,i,o,new L(r,0,0),n.length,!0))}function Mx(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)&&Nx(t.doc,t.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&Qd(t,s,l,o),Wa(t,t.mapping.slice(o).map(l,1),r,void 0,c===null);let u=t.mapping.slice(o),h=u.map(l,1),d=u.map(l+s.nodeSize,1);return t.step(new Be(h,d,h+1,d-1,new L(E.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Yd(t,s,l,o),!1}})}function Yd(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 Qd(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 Nx(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Tx(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 Be(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new L(E.from(s),0,0),1,!0))}function Ri(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 h=i.node(c),d=i.index(c);if(h.type.spec.isolating)return!1;let f=h.content.cutByIndex(d,h.childCount),p=r&&r[u+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||h;if(!h.canReplace(d+1,h.childCount)||!m.type.validContent(f))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 Ix(t,e,n=1,r){let i=t.doc.resolve(e),o=E.empty,s=E.empty;for(let l=i.depth,a=i.depth-n,c=n-1;l>a;l--,c--){o=E.from(i.node(l).copy(o));let u=r&&r[c];s=E.from(u?u.type.create(u.attrs,s):i.node(l).copy(s))}t.step(new ke(e,e,new L(o.append(s),n,n),!0))}function $s(t,e){let n=t.resolve(e),r=n.index();return vx(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Ax(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 vx(t,e){return!!(t&&e&&!t.isLeaf&&Ax(t,e))}function Ex(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",h=!!s.contentMatch.matchType(i);u&&!h?r=!1:!u&&h&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);Qd(t,u.node(),u.before(),l)}s.inlineContent&&Wa(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 ke(c,a.map(e+n,-1),L.empty,!0)),r===!0){let u=t.doc.resolve(c);Yd(t,u.node(),u.before(),t.steps.length)}return t}function Ox(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 Dx(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),h=!1;if(o==1)h=u.canReplace(c,c,i);else{let d=u.contentMatchAt(c).findWrapping(i.firstChild.type);h=d&&u.canReplaceWith(c,c,d[0])}if(h)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}}return null}function js(t,e,n=e,r=L.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return Xd(i,o,r)?new ke(e,n,r):new Rx(i,o,r).fit()}function Xd(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class Rx{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=E.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=E.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 L(o,s,l);return e>-1?new Be(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new ke(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=mh(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,h=null;if(n==1&&(s?c.matchType(s.type)||(h=c.fillBefore(E.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:h};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 gh(e,-1)<=n?!1:(this.unplaced.size>1&&gh(e,1)>r&&r++,this.unplaced=new L(e,n+1,r),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=mh(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new L(Mi(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new L(Mi(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:h,type:d}=this.frontier[n];if(i){for(let m=0;m<i.childCount;m++)u.push(i.child(m));h=h.matchFragment(i)}let f=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),y=h.matchType(m.type);if(!y)break;c++,(c>1||a==0||m.content.size)&&(h=y,u.push(Zd(m.mark(d.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=Ni(this.placed,n,E.from(u)),this.frontier[n].match=h,p&&f<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<f;m++)this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),y=y.lastChild;this.unplaced=p?e==0?L.empty:new L(Mi(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new L(Mi(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||!ml(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=ml(e,n,i,r,o);if(s){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=ml(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=Ni(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=Ni(this.placed,this.depth,E.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(E.empty,!0);n.childCount&&(this.placed=Ni(this.placed,this.frontier.length,n))}}function Mi(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Mi(t.firstChild.content,e-1,n)))}function Ni(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Ni(t.lastChild.content,e-1,n)))}function mh(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Zd(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Zd(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(E.empty,!0)))),t.copy(r)}function ml(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&&!zx(n,o.content,s)?l:null}function zx(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function Px(t){return t.spec.defining||t.spec.definingForContent}function gh(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 Lx(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),o=t.doc.resolve(n);if(Xd(i,o,r))return t.step(new ke(e,n,r));let s=tp(i,o);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let d=i.depth,f=i.pos-1;d>0;d--,f--){let p=i.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==f&&s.splice(1,0,-d)}let a=s.indexOf(l),c=[],u=r.openStart;for(let d=r.content,f=0;;f++){let p=d.firstChild;if(c.push(p),f==r.openStart)break;d=p.content}for(let d=u-1;d>=0;d--){let f=c[d],p=Px(f.type);if(p&&!f.sameMarkup(i.node(Math.abs(l)-1)))u=d;else if(p||!f.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let f=(d+u+1)%(r.openStart+1),p=c[f];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 L(ep(r.content,0,r.openStart,f),f,r.openEnd))}}let h=t.steps.length;for(let d=s.length-1;d>=0&&(t.replace(e,n,r),!(t.steps.length>h));d--){let f=s[d];f<0||(e=i.before(f),n=o.after(f))}}function ep(t,e,n,r,i){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(ep(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(E.empty,!0))}return t}function Bx(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=Ox(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new L(E.from(r),0,0))}function Fx(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=tp(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 tp(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 Rr extends we{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 ye.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 ye.fromReplace(e,this.pos,this.pos+1,new L(E.from(i),0,n.isLeaf?0:1))}getMap(){return ot.empty}invert(e){return new Rr(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 Rr(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 Rr(n.pos,n.attr,n.value)}}we.jsonID("attr",Rr);class Ji extends we{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 ye.ok(r)}getMap(){return ot.empty}invert(e){return new Ji(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 Ji(n.attr,n.value)}}we.jsonID("docAttr",Ji);let ri=class extends Error{};ri=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};ri.prototype=Object.create(Error.prototype);ri.prototype.constructor=ri;ri.prototype.name="TransformError";class np{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ki}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new ri(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=L.empty){let i=js(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new L(E.from(r),0,0))}delete(e,n){return this.replace(e,n,L.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Lx(this,e,n,r),this}replaceRangeWith(e,n,r){return Bx(this,e,n,r),this}deleteRange(e,n){return Fx(this,e,n),this}lift(e,n){return xx(this,e,n),this}join(e,n=1){return Ex(this,e,n),this}wrap(e,n){return Sx(this,e,n),this}setBlockType(e,n=e,r,i=null){return Mx(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return Tx(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Rr(e,n,r)),this}setDocAttribute(e,n){return this.step(new Ji(e,n)),this}addNodeMark(e,n){return this.step(new vn(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 oe)n.isInSet(r.marks)&&this.step(new hr(e,n));else{let i=r.marks,o,s=[];for(;o=n.isInSet(i);)s.push(new hr(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 Ix(this,e,n,r),this}addMark(e,n,r){return yx(this,e,n,r),this}removeMark(e,n,r){return kx(this,e,n,r),this}clearIncompatible(e,n,r){return Wa(this,e,n,r),this}}const gl=Object.create(null);class K{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new rp(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=L.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?L.empty:n),l==0&&bh(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),bh(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new Q(e):Tr(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?Tr(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):Tr(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 lt(e.node(0))}static atStart(e){return Tr(e,e,0,0,1)||new lt(e)}static atEnd(e){return Tr(e,e,e.content.size,e.childCount,-1)||new lt(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=gl[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 gl)throw new RangeError("Duplicate use of selection JSON ID "+e);return gl[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Q.between(this.$anchor,this.$head).getBookmark()}}K.prototype.visible=!0;class rp{constructor(e,n){this.$from=e,this.$to=n}}let yh=!1;function kh(t){!yh&&!t.parent.inlineContent&&(yh=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Q extends K{constructor(e,n=e){kh(e),kh(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 K.near(r);let i=e.resolve(n.map(this.anchor));return new Q(i.parent.inlineContent?i:r,r)}replace(e,n=L.empty){if(super.replace(e,n),n==L.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Q&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Vs(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 Q(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=K.findFrom(n,r,!0)||K.findFrom(n,-r,!0);if(o)n=o.$head;else return K.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(K.findFrom(e,-r,!0)||K.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Q(e,n)}}K.jsonID("text",Q);class Vs{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Vs(e.map(this.anchor),e.map(this.head))}resolve(e){return Q.between(e.resolve(this.anchor),e.resolve(this.head))}}class U extends K{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?K.near(o):new U(o)}content(){return new L(E.from(this.node),0,0)}eq(e){return e instanceof U&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ja(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new U(e.resolve(n.anchor))}static create(e,n){return new U(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}U.prototype.visible=!1;K.jsonID("node",U);class Ja{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Vs(r,r):new Ja(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&U.isSelectable(r)?new U(n):K.near(n)}}class lt extends K{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=L.empty){if(n==L.empty){e.delete(0,e.doc.content.size);let r=K.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new lt(e)}map(e){return new lt(e)}eq(e){return e instanceof lt}getBookmark(){return _x}}K.jsonID("all",lt);const _x={map(){return this},resolve(t){return new lt(t)}};function Tr(t,e,n,r,i,o=!1){if(e.inlineContent)return Q.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&&U.isSelectable(l))return U.create(t,n-(i<0?l.nodeSize:0))}else{let a=Tr(t,l,n+i,i<0?l.childCount:0,i,o);if(a)return a}n+=l.nodeSize*i}return null}function bh(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof ke||i instanceof Be))return;let o=t.mapping.maps[r],s;o.forEach((l,a,c,u)=>{s==null&&(s=u)}),t.setSelection(K.near(t.doc.resolve(s),n))}const xh=1,Jo=2,wh=4;class $x extends np{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|xh)&~Jo,this.storedMarks=null,this}get selectionSet(){return(this.updated&xh)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Jo,this}ensureMarks(e){return oe.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&Jo)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Jo,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)||oe.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(K.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|=wh,this}get scrolledIntoView(){return(this.updated&wh)>0}}function Ch(t,e){return!e||!t?t:t.bind(e)}class Ti{constructor(e,n,r){this.name=e,this.init=Ch(n.init,r),this.apply=Ch(n.apply,r)}}const jx=[new Ti("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Ti("selection",{init(t,e){return t.selection||K.atStart(e.doc)},apply(t){return t.selection}}),new Ti("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Ti("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class yl{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=jx.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 Ti(r.key,r.spec.state,r))})}}class Or{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 h=0;h<this.config.plugins.length;h++)i.push(h<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 Or(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 $x(this)}static create(e){let n=new yl(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Or(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 yl(this.schema,e.plugins),r=n.fields,i=new Or(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 yl(e.schema,e.plugins),o=new Or(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=kt.fromJSON(e.schema,n.doc);else if(s.name=="selection")o.selection=K.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 ip(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=ip(i,e,{})),n[r]=i}return n}class Oe{constructor(e){this.spec=e,this.props={},e.props&&ip(e.props,this,this.props),this.key=e.key?e.key.key:op("plugin")}getState(e){return e[this.key]}}const kl=Object.create(null);function op(t){return t in kl?t+"$"+ ++kl[t]:(kl[t]=0,t+"$")}class De{constructor(e="key"){this.key=op(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ua=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function sp(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const lp=(t,e,n)=>{let r=sp(t,n);if(!r)return!1;let i=Ga(r);if(!i){let s=r.blockRange(),l=s&&_s(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(up(t,i,e,-1))return!0;if(r.parent.content.size==0&&(ii(o,"end")||U.isSelectable(o)))for(let s=r.depth;;s--){let l=js(t.doc,r.before(s),r.after(s),L.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(ii(o,"end")?K.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):U.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},Vx=(t,e,n)=>{let r=sp(t,n);if(!r)return!1;let i=Ga(r);return i?Hx(t,i,e):!1};function Hx(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=js(t.doc,o,a,L.empty);if(!c||c.from!=o||c instanceof ke&&c.slice.size>=a-o)return!1;if(n){let u=t.tr.step(c);u.setSelection(Q.create(u.doc,o)),n(u.scrollIntoView())}return!0}function ii(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 ap=(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=Ga(r)}let s=o&&o.nodeBefore;return!s||!U.isSelectable(s)?!1:(e&&e(t.tr.setSelection(U.create(t.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Ga(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 qx(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Wx=(t,e,n)=>{let r=qx(t,n);if(!r)return!1;let i=cp(r);if(!i)return!1;let o=i.nodeAfter;if(up(t,i,e,1))return!0;if(r.parent.content.size==0&&(ii(o,"start")||U.isSelectable(o))){let s=js(t.doc,r.before(),r.after(),L.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=t.tr.step(s);l.setSelection(ii(o,"start")?K.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):U.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},Kx=(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=cp(r)}let s=o&&o.nodeAfter;return!s||!U.isSelectable(s)?!1:(e&&e(t.tr.setSelection(U.create(t.doc,o.pos)).scrollIntoView()),!0)};function cp(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 Jx=(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 Ya(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 Ux=(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=Ya(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(K.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Gx=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof lt||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Ya(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(Q.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},Yx=(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(Ri(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&_s(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function Qx(t){return(e,n)=>{if(e.selection instanceof U&&e.selection.node.isBlock){let{$from:f}=e.selection;return!f.parentOffset||!Ri(e.doc,f.pos)?!1:(n&&n(e.tr.split(f.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof Q||e.selection instanceof lt)&&r.deleteSelection();let{$from:i}=r.selection,o=r.steps.length,s=[],l,a,c=!1,u=!1;for(let f=i.depth;;f--)if(i.node(f).isBlock){c=i.end(f)==i.pos+(i.depth-f),u=i.start(f)==i.pos-(i.depth-f),a=Ya(i.node(f-1).contentMatchAt(i.indexAfter(f-1))),s.unshift(c&&a?{type:a}:null),l=f;break}else{if(f==1)return!1;s.unshift(null)}let h=i.pos,d=Ri(r.doc,h,s.length,s);if(d||(s[0]=a?{type:a}:null,d=Ri(r.doc,h,s.length,s)),!d)return!1;if(r.split(h,s.length,s),!c&&u&&i.node(l).type!=a){let f=r.mapping.slice(o),p=f.map(i.before(l)),m=r.doc.resolve(p);a&&i.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(f.map(i.before(l)),a)}return n&&n(r.scrollIntoView()),!0}}const Xx=Qx(),Zx=(t,e)=>(e&&e(t.tr.setSelection(new lt(t.doc))),!0);function e0(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||$s(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function up(t,e,n,r){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&e0(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 f=e.pos+o.nodeSize,p=E.empty;for(let g=s.length-1;g>=0;g--)p=E.from(s[g].create(null,p));p=E.from(i.copy(p));let m=t.tr.step(new Be(e.pos-1,f,e.pos,f,new L(p,1,0),s.length,!0)),y=m.doc.resolve(f+2*s.length);y.nodeAfter&&y.nodeAfter.type==i.type&&$s(m.doc,y.pos)&&m.join(y.pos),n(m.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&a?null:K.findFrom(e,1),h=u&&u.$from.blockRange(u.$to),d=h&&_s(h);if(d!=null&&d>=e.depth)return n&&n(t.tr.lift(h,d).scrollIntoView()),!0;if(c&&ii(o,"start",!0)&&ii(i,"end")){let f=i,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let m=o,y=1;for(;!m.isTextblock;m=m.firstChild)y++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(n){let g=E.empty;for(let w=p.length-1;w>=0;w--)g=E.from(p[w].copy(g));let C=t.tr.step(new Be(e.pos-p.length,e.pos+o.nodeSize,e.pos+y,e.pos+o.nodeSize-y,new L(g,p.length,0),0,!0));n(C.scrollIntoView())}return!0}}return!1}function hp(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(Q.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const t0=hp(-1),n0=hp(1);function Qa(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),l=s&&Ka(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Ui(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),h=u.index();i=u.parent.canReplaceWith(h,h+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 r0(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 Ao(t,e=null,n){return function(r,i){let{empty:o,$cursor:s,ranges:l}=r.selection;if(o&&!s||!r0(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:h,$to:d}=l[u];if(!a)c.removeMark(h.pos,d.pos,t);else{let f=h.pos,p=d.pos,m=h.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;f+g<p&&(f+=g,p-=C),c.addMark(f,p,t.create(e))}}i(c.scrollIntoView())}return!0}}function ui(...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 bl=ui(Ua,lp,ap),Sh=ui(Ua,Wx,Kx);const Xt={Enter:ui(Jx,Gx,Yx,Xx),"Mod-Enter":Ux,Backspace:bl,"Mod-Backspace":bl,"Shift-Backspace":bl,Delete:Sh,"Mod-Delete":Sh,"Mod-a":Zx},fp={"Ctrl-h":Xt.Backspace,"Alt-Backspace":Xt["Mod-Backspace"],"Ctrl-d":Xt.Delete,"Ctrl-Alt-Backspace":Xt["Mod-Delete"],"Alt-Delete":Xt["Mod-Delete"],"Alt-d":Xt["Mod-Delete"],"Ctrl-a":t0,"Ctrl-e":n0};for(let t in Xt)fp[t]=Xt[t];const i0=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,o0=i0?fp:Xt;class ht{constructor(e,n,r={}){this.match=e,this.match=e,this.handler=typeof n=="string"?s0(n):n,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}}function s0(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 l0=(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 ht(/--$/,"—",{inCodeMark:!1});new ht(/\.\.\.$/,"…",{inCodeMark:!1});new ht(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1});new ht(/"$/,"”",{inCodeMark:!1});new ht(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1});new ht(/'$/,"’",{inCodeMark:!1});function Xa(t,e,n,r){let i,o;return e instanceof cr?o=e:(i=e,o=e.nodeType,n=e.getAttrs,r=e.joinPredicate),new ht(t,(s,l,a,c)=>{let u=n instanceof Function?n(l):n,h=s.tr.delete(a,c),d=h.doc.resolve(a),f=d.blockRange(),p=f&&Ka(f,o,u);if(!p)return null;h.wrap(f,p);let m=h.doc.resolve(a-1).nodeBefore;return m&&m.type==o&&$s(h.doc,a-1)&&(!r||r(l,m))&&h.join(a-1),h},i)}function dp(t,e,n){let r,i;return e instanceof cr?i=e:(r=e,i=e.nodeType,n=e.getAttrs),new ht(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 zn=typeof navigator<"u"?navigator:null,Mh=typeof document<"u"?document:null,Ln=zn&&zn.userAgent||"",aa=/Edge\/(\d+)/.exec(Ln),pp=/MSIE \d/.exec(Ln),ca=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ln),Za=!!(pp||ca||aa);pp?document.documentMode:ca?+ca[1]:aa&&+aa[1];const a0=!Za&&/gecko\/(\d+)/i.test(Ln);a0&&+(/Firefox\/(\d+)/.exec(Ln)||[0,0])[1];const ua=!Za&&/Chrome\/(\d+)/.exec(Ln),c0=!!ua;ua&&+ua[1];const u0=!Za&&!!zn&&/Apple Computer/.test(zn.vendor),h0=u0&&(/Mobile\/\w+/.test(Ln)||!!zn&&zn.maxTouchPoints>2);h0||zn&&/Mac/.test(zn.platform);const f0=/Android \d/.test(Ln),d0=!!Mh&&"webkitFontSmoothing"in Mh.documentElement.style;d0&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];function xl(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,h=u.match.exec(a),d=h&&h[0]&&u.handler(s,h,e-(h[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 p0=new De("MILKDOWN_CUSTOM_INPUTRULES");function m0({rules:t}){const e=new Oe({key:p0,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 xl(n,r,i,o,t,e)},handleDOMEvents:{compositionend:n=>(setTimeout(()=>{const{$cursor:r}=n.state.selection;r&&xl(n,r.pos,r.pos,"",t,e)}),!1),keydown:(n,r)=>!(f0&&c0&&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?xl(n,i.pos,i.pos,`
44
+ `,t,e):!1}}});return e}function mp(t){return t.some(e=>e.type.spec.code)}function Nh(t,e,n){if(e>=n)return!1;let r=!1;return t.doc.nodesBetween(e,n,i=>(i.isInline&&mp(i.marks)&&(r=!0),!r)),r}function g0(t,e){var n;return mp((n=t.storedMarks)!=null?n:t.doc.resolve(e).marks())}function vo(t,e,n={}){return new ht(t,(r,i,o,s)=>{var l,a,c,u;const{tr:h}=r,d=i.length;let f=i[d-1],p=i[0],m=[],y;const g={group:f,fullMatch:p,start:o,end:s},C=(l=n.updateCaptured)==null?void 0:l.call(n,g);if(Object.assign(g,C),{group:f,fullMatch:p,start:o,end:s}=g,p===null||(f==null?void 0:f.trim())==="")return null;if(f){const w=p.search(/\S/),v=o+p.indexOf(f),B=v+f.length,S=Nh(r,o+w,v),R=B<s&&Nh(r,B,s);if(S||R||g0(r,s))return null;m=(a=h.storedMarks)!=null?a:[],B<s&&h.delete(B,s),v>o&&h.delete(o+w,v),y=o+w+f.length;const F=(c=n.getAttr)==null?void 0:c.call(n,i);h.addMark(o,y,e.create(F)),h.setStoredMarks(m),(u=n.beforeDispatch)==null||u.call(n,{match:i,start:o,end:s,tr:h})}return h})}function gp(t){return Object.assign(Object.create(t),t).setTime(Date.now())}function y0(t,e){return Array.isArray(t)&&t.includes(e.type)||e.type===t}function k0(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 b0(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 x0(t,e){return b0(n=>n.type===e)(t)}function w0(t,e){const n=e.nodes[t];if(!n)throw hy("node",t);return n}function C0(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 S0(t,e){if(!(t instanceof U))return;const{node:n,$from:r}=t;if(y0(e,n))return{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}}const M0=(t,e)=>{const{selection:n,doc:r}=t;if(n instanceof U)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}},N0=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),T0=typeof navigator<"u"&&/Win/.test(navigator.platform);function I0(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))N0?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 A0(t){let e=Object.create(null);for(let n in t)e[I0(n)]=t[n];return e}function wl(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 yp(t){return new Oe({props:{handleKeyDown:kp(t)}})}function kp(t){let e=A0(t);return function(n,r){let i=ty(r),o,s=e[wl(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[wl(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(T0&&r.ctrlKey&&r.altKey)&&(o=ny[r.keyCode])&&o!=i){let l=e[wl(o,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var bp=class{},xp=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 $f();return t}}},v0=class wp extends bp{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 wp(e,n,r)}},Tt,Wr,co,uo,ho,Kr,Jr,ir,E0=(ir=class extends xp{constructor(n){super();$(this,Tt);$(this,Wr);$(this,co);$(this,uo);$(this,ho);$(this,Kr);$(this,Jr);D(this,Tt,oe.none),D(this,Wr,r=>r.isText),D(this,co,(r,i)=>{if(x(this,Wr).call(this,r)&&x(this,Wr).call(this,i)&&oe.sameSet(r.marks,i.marks))return this.schema.text(r.text+i.text,r.marks)}),D(this,uo,r=>{const i=Object.values({...this.schema.nodes,...this.schema.marks}).find(o=>o.spec.parseMarkdown.match(r));if(!i)throw cy(r);return i}),D(this,ho,r=>{const i=x(this,uo).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(v0.create(r,[],i)),this),D(this,Kr,()=>{D(this,Tt,oe.none);const r=this.close();return x(this,Jr).call(this,r.type,r.attrs,r.content)}),this.closeNode=()=>{try{x(this,Kr).call(this)}catch(r){console.error(r)}return this},D(this,Jr,(r,i,o)=>{const s=r.createAndFill(i,o,x(this,Tt));if(!s)throw ay(r,i,o);return this.push(s),s}),this.addNode=(r,i,o)=>{try{x(this,Jr).call(this,r,i,o)}catch(s){console.error(s)}return this},this.openMark=(r,i)=>{const o=r.create(i);return D(this,Tt,o.addToSet(x(this,Tt))),this},this.closeMark=r=>(D(this,Tt,r.removeFromSet(x(this,Tt))),this),this.addText=r=>{try{const i=this.top();if(!i)throw $f();const o=i.pop(),s=this.schema.text(r,x(this,Tt));if(!o)return i.push(s),this;const l=x(this,co).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,Kr).call(this);while(this.size());return r},this.next=(r=[])=>([r].flat().forEach(i=>x(this,ho).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}},Tt=new WeakMap,Wr=new WeakMap,co=new WeakMap,uo=new WeakMap,ho=new WeakMap,Kr=new WeakMap,Jr=new WeakMap,ir.create=(n,r)=>{const i=new ir(n);return o=>(i.run(r,o),i.toDoc())},ir),or,Th=(or=class extends bp{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()}}},or.create=(e,n,r,i={})=>new or(e,n,r,i),or),O0=t=>Object.prototype.hasOwnProperty.call(t,"size"),_e,Ur,fo,po,mo,go,Gr,Yr,yo,ko,Wn,In,bo,Qr,sr,D0=(sr=class extends xp{constructor(n){super();$(this,_e);$(this,Ur);$(this,fo);$(this,po);$(this,mo);$(this,go);$(this,Gr);$(this,Yr);$(this,yo);$(this,ko);$(this,Wn);$(this,In);$(this,bo);$(this,Qr);D(this,_e,[]),D(this,Ur,r=>{const i=Object.values({...this.schema.nodes,...this.schema.marks}).find(o=>o.spec.toMarkdown.match(r));if(!i)throw uy(r.type);return i}),D(this,fo,r=>x(this,Ur).call(this,r).spec.toMarkdown.runner(this,r)),D(this,po,(r,i)=>x(this,Ur).call(this,r).spec.toMarkdown.runner(this,r,i)),D(this,mo,r=>{const i=l=>l.type.spec.priority??50,o=[...r].sort((l,a)=>i(l)-i(a)),s=[];return x(this,_e).forEach(({mark:l})=>{const a=o.findIndex(c=>c.eq(l));a>=0&&s.push(...o.splice(a,1))}),s.concat(o)}),D(this,go,r=>{const i=r==null?void 0:r.marks;let o=0;for(;o<x(this,_e).length;){const{mark:s,spanning:l}=x(this,_e)[o];if(l&&(i!=null&&i.some(a=>a.eq(s))))o++;else break}for(let s=x(this,_e).length-1;s>=o;s--)x(this,Qr).call(this,x(this,_e)[s].mark)}),D(this,Gr,(r,i)=>{x(this,mo).call(this,r.marks).every(o=>!x(this,po).call(this,o,r))&&x(this,fo).call(this,r),x(this,go).call(this,i)}),D(this,Yr,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:h,...d}=a;if(s.type===a.type&&c&&h&&JSON.stringify(u)===JSON.stringify(d)){const f={...d,children:[...h,...c]};return o.slice(0,-1).concat(x(this,Yr).call(this,f))}}return o.concat(s)},[])),r}),D(this,yo,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(Th.create(r,void 0,i,o)),this),D(this,ko,(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 h=u.value,d=h.trimEnd();s=h.slice(d.length),u.value=d}if(c&&c.type==="text"&&c.value.startsWith(" ")){const h=c.value,d=h.trimStart();o=h.slice(0,h.length-d.length),c.value=d}}o.length&&x(this,In).call(this,"text",void 0,o);const a=i();return s.length&&x(this,In).call(this,"text",void 0,s),a}),D(this,Wn,(r=!1)=>{const i=this.close(),o=()=>x(this,In).call(this,i.type,i.children,i.value,i.props);return r?x(this,ko).call(this,i,o):o()}),this.closeNode=()=>(x(this,Wn).call(this),this),D(this,In,(r,i,o,s)=>{const l=Th.create(r,i,o,s),a=x(this,Yr).call(this,x(this,yo).call(this,l));return this.push(a),a}),this.addNode=(r,i,o,s)=>(x(this,In).call(this,r,i,o,s),this),D(this,bo,(r,i,o,s)=>x(this,_e).some(l=>l.mark.eq(r))?this:(x(this,_e).push({mark:r,spanning:o==null}),this.openNode(i,o,{...s,isMark:!0}))),D(this,Qr,r=>{let i=-1;for(let o=x(this,_e).length-1;o>=0;o--)if(x(this,_e)[o].mark.eq(r)){i=o;break}i<0||(x(this,_e).splice(i,1),x(this,Wn).call(this,!0))}),this.withMark=(r,i,o,s)=>(x(this,bo).call(this,r,i,o,s),this),this.closeMark=r=>(x(this,Qr).call(this,r),this),this.build=()=>{let r=null;do r=x(this,Wn).call(this);while(this.size());return r.children||(r.children=[]),r},this.next=r=>O0(r)?(r.forEach((i,o,s)=>{x(this,Gr).call(this,i,r.maybeChild(s+1)??void 0)}),this):(x(this,Gr).call(this,r),this),this.toString=r=>r.stringify(this.build()),this.run=r=>(D(this,_e,[]),this.next(r),this),this.schema=n}},_e=new WeakMap,Ur=new WeakMap,fo=new WeakMap,po=new WeakMap,mo=new WeakMap,go=new WeakMap,Gr=new WeakMap,Yr=new WeakMap,yo=new WeakMap,ko=new WeakMap,Wn=new WeakMap,In=new WeakMap,bo=new WeakMap,Qr=new WeakMap,sr.create=(n,r)=>{const i=new sr(n);return o=>(i.run(o),i.toString(r))},sr);const Ie=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},oi=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let ha=null;const Qt=function(t,e,n){let r=ha||(ha=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},R0=function(){ha=null},fr=function(t,e,n,r){return n&&(Ih(t,e,n,r,-1)||Ih(t,e,n,r,1))},z0=/^(img|br|input|textarea|hr)$/i;function Ih(t,e,n,r,i){for(var o;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Le(t))){let s=t.parentNode;if(!s||!V(s)||Eo(t)||z0.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ie(t)+(i<0?0:1),t=s}else if(V(t)){let s=t.childNodes[e+(i<0?-1:0)];if(V(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?Le(t):0}else return!1}}function Le(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function V(t){return t.nodeType==1}function xe(t){return t.nodeType==3}function dr(t,e){return e?t.contains(V(e)?e:e.parentNode):!1}function P0(t,e){for(;;){if(xe(t)&&e)return t;if(V(t)&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Le(t)}else if(t.parentNode&&!Eo(t))e=Ie(t),t=t.parentNode;else return null}}function L0(t,e){for(;;){if(xe(t)&&e<t.nodeValue.length)return t;if(V(t)&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Eo(t))e=Ie(t)+1,t=t.parentNode;else return null}}function B0(t,e,n){for(let r=e==0,i=e==Le(t);r||i;){if(t==n)return!0;let o=Ie(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==Le(t)}}function Eo(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 Hs=function(t){return t.focusNode&&fr(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function F0(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function _0(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function $0(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Le(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Le(r.startContainer),r.startOffset)}}}const Vt=typeof navigator<"u"?navigator:null,Ah=typeof document<"u"?document:null,Bn=Vt&&Vt.userAgent||"",fa=/Edge\/(\d+)/.exec(Bn),Cp=/MSIE \d/.exec(Bn),da=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Bn),Qe=!!(Cp||da||fa),En=Cp?document.documentMode:da?+da[1]:fa?+fa[1]:0,at=!Qe&&/gecko\/(\d+)/i.test(Bn);at&&+(/Firefox\/(\d+)/.exec(Bn)||[0,0])[1];const pa=!Qe&&/Chrome\/(\d+)/.exec(Bn),ve=!!pa,Sp=pa?+pa[1]:0,Fe=!Qe&&!!Vt&&/Apple Computer/.test(Vt.vendor),si=Fe&&(/Mobile\/\w+/.test(Bn)||!!Vt&&Vt.maxTouchPoints>2),gt=si||(Vt?/Mac/.test(Vt.platform):!1),Mp=Vt?/Win/.test(Vt.platform):!1,an=/Android \d/.test(Bn),qs=!!Ah&&"webkitFontSmoothing"in Ah.documentElement.style,j0=qs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function V0(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 Gt(t,e){return typeof t=="number"?t:t[e]}function H0(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 vh(t,e,n){if(!ma(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(!V(s)){s=oi(s);continue}let l=s==o.body,a=l?V0(o):H0(s),c=0,u=0;if(e.top<a.top+Gt(r,"top")?u=-(a.top-e.top+Gt(i,"top")):e.bottom>a.bottom-Gt(r,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+Gt(i,"top")-a.top:e.bottom-a.bottom+Gt(i,"bottom")),e.left<a.left+Gt(r,"left")?c=-(a.left-e.left+Gt(i,"left")):e.right>a.right-Gt(r,"right")&&(c=e.right-a.right+Gt(i,"right")),c||u)if(l)o.defaultView.scrollBy(c,u);else{let d=s.scrollLeft,f=s.scrollTop;u&&(s.scrollTop+=u),c&&(s.scrollLeft+=c);let p=s.scrollLeft-d,m=s.scrollTop-f;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}let h=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(h))break;s=h=="absolute"?s.offsetParent:oi(s)}}function q0(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:Np(t.dom)}}function Np(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=oi(r));return e}function W0({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Tp(n,r==0?0:r-e)}function Tp(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 Sr=null;function K0(t){if(t.setActive)return t.setActive();if(Sr)return t.focus(Sr);let e=Np(t);t.focus(Sr==null?{get preventScroll(){return Sr={preventScroll:!0},!0}}:void 0),Sr||(Sr=!1,Tp(e,0))}function Ip(t,e){let n,r=2e8,i,o=0,s=e.top,l=e.top,a,c;for(let u=t.firstChild,h=0;u;u=u.nextSibling,h++){let d;if(V(u))d=u.getClientRects();else if(xe(u))d=Qt(u).getClientRects();else continue;for(let f=0;f<d.length;f++){let p=d[f];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&&xe(n)?{left:p.right<e.left?p.right:p.left,top:e.top}:e,V(u)&&m&&(o=h+(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=h+1)}}return!n&&a&&(n=a,i=c,r=0),n&&xe(n)?J0(n,i):!n||r?{node:t,offset:o}:Ip(n,i)}function J0(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=bn(r,1);if(s.top!=s.bottom&&ec(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 ec(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function U0(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function G0(t,e,n){let{node:r,offset:i}=Ip(e,n),o=-1;if(V(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 Y0(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(V(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 Ap(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(V(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(ec(e,c))return Ap(s,e,c)}}if((o=(o+1)%r)==i)break}return t}function Q0(t,e){let n=t.dom.ownerDocument,r,i=0,o=$0(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(!ec(e,c)||(s=Ap(t.dom,e,c),!s))return null}if(Fe)for(let c=s;r&&c;c=oi(c))c.draggable&&(r=void 0);if(s=U0(s,e),r){if(at&&V(r)&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],h;u.nodeName=="IMG"&&(h=u.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&i++}let c;qs&&i&&V(r)&&V(c=r.childNodes[i-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&V(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||!V(r)||r.childNodes[i-1].nodeName!="BR")&&(l=Y0(t,r,i,e))}l==null&&(l=G0(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function ma(t){return t.top<t.bottom||t.left<t.right}function bn(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(ma(r))return r}return Array.prototype.find.call(n,ma)||t.getBoundingClientRect()}const X0=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function vp(t,e,n){let{node:r,offset:i,atom:o}=t.docView.domFromPos(e,n<0?-1:1),s=qs||at;if(xe(r))if(s&&(X0.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let a=bn(Qt(r,i,i),n);if(at&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=bn(Qt(r,i-1,i-1),-1);if(c.top==a.top){let u=bn(Qt(r,i,i+1),-1);if(u.top!=a.top)return Ci(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++,Ci(bn(Qt(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==Le(r))){let a=r.childNodes[i-1];if(V(a))return Cl(a.getBoundingClientRect(),!1)}if(o==null&&i<Le(r)){let a=r.childNodes[i];if(V(a))return Cl(a.getBoundingClientRect(),!0)}return Cl(r.getBoundingClientRect(),n>=0)}if(o==null&&i&&(n<0||i==Le(r))){let a=r.childNodes[i-1],c=xe(a)?Qt(a,Le(a)-(s?0:1)):V(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Ci(bn(c,1),!1)}if(o==null&&i<Le(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?xe(a)?Qt(a,0,s?0:1):V(a)?a:null:null;if(c)return Ci(bn(c,-1),!0)}return Ci(bn(xe(r)?Qt(r):r,-n),n>=0)}function Ci(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 Cl(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 Ep(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 Z0(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Ep(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=vp(t,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(V(l))a=l.getClientRects();else if(xe(l))a=Qt(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 ew=/[\u0590-\u08ac]/;function tw(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?!ew.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?o:s:Ep(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:h}=t.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",n,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),y=p&&!dr(f,p)||a==p&&c==m;try{l.collapse(u,h),a&&(a!=u||c!=h)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),y}):r.pos==r.start()||r.pos==r.end()}let Eh=null,Oh=null,Dh=!1;function nw(t,e,n){return Eh==e&&Oh==n?Dh:(Eh=e,Oh=n,Dh=n=="up"||n=="down"?Z0(t,e,n):tw(t,e,n))}const bt=0,Rh=1,Vn=2,Et=3;class Oo{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=bt,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&&dr(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>Ie(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)&&!(V(s)?dr(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 Dp||o instanceof Op&&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?Ie(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?Ie(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 h=l;h>0;h--){let d=this.children[h-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=Ie(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 h=this.children[u];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){o=Ie(h.dom);break}n+=h.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(!V(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 f=0,p=0;f<this.children.length;f++){let m=this.children[f],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(),h=!1;if((at||Fe)&&e==n){let{node:f,offset:p}=l;if(xe(f)){if(h=!!(p&&f.nodeValue[p-1]==`
45
+ `),h&&p==f.nodeValue.length)for(let m=f,y;m;m=m.parentNode){if(y=m.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:Ie(y)+1});break}let g=m.pmViewDesc;if(g&&g.node&&g.node.isBlock)break}}else{let m=f.childNodes[p-1];h=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(at&&u.focusNode&&u.focusNode!=a.node&&V(u.focusNode)){let f=u.focusNode.childNodes[u.focusOffset];f&&f.contentEditable=="false"&&(i=!0)}if(!(i||h&&Fe)&&fr(l.node,l.offset,u.anchorNode,u.anchorOffset)&&fr(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==n)&&!(h&&at)){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 f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}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:Rh,e==l&&n==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Et:o.markDirty(e-l,n-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Vn:Et}r=s}this.dirty=Vn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Vn:Rh;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Op extends Oo{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=V(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==bt&&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 rw extends Oo{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 On extends Oo{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=br.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new On(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Et||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Et&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=bt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=bt}}slice(e,n,r){let i=On.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;n<s&&(o=ya(o,n,s,r)),e>0&&(o=ya(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 Dn extends Oo{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,h=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!xe(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:h}=br.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!h&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let d=u;return u=Pp(u,r,n),c?a=new iw(e,n,r,i,u,h||null,d,c):n.isText?new Ws(e,n,r,i,u,d):new Dn(e,n,r,i,u,h||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=>V(i)&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));r?n.contentElement=r:n.getContent=()=>E.empty}}return n}matchesNode(e,n,r){return this.dirty==bt&&e.eq(this.node)&&Cs(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 sw(this,s&&s.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;cw(this.node,this.innerDeco,(h,d,f)=>{h.spec.marks?a.syncToMarks(h.spec.marks,r,e,d):h.type.side>=0&&!f&&a.syncToMarks(d==this.node.childCount?oe.none:this.node.child(d).marks,r,e,d),a.placeWidget(h,e,i)},(h,d,f,p)=>{a.syncToMarks(h.marks,r,e,p),u&&h.isAtom&&!h.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(h,d,f,p)||l&&e.state.selection.from>i&&e.state.selection.to<i+h.nodeSize&&(m=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(h,d,f,m,e)||a.updateNextNode(h,d,f,e,p,i)||a.addNode(h,d,f,e,i),i+=h.nodeSize,c&&(u=h.isAtom&&!h.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Vn)&&(s&&this.protectLocalComposition(e,s),Rp(this.contentDOM,this.children,e),si&&uw(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Q)||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=hw(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 rw(this,o,n,i);e.input.compositionNodes.push(s),this.children=ya(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==Et||!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=bt}updateOuterDeco(e){if(Cs(e,this.outerDeco))return;let n=!V(this.nodeDOM),r=this.dom;this.dom=zp(this.dom,this.nodeDOM,ga(this.outerDeco,this.node,n),ga(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){V(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){V(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 zh(t,e,n,r,i){Pp(r,e,t);let o=new Dn(void 0,t,e,n,r,r,r);return o.contentDOM&&o.updateChildren(i,0),o}class Ws extends Dn{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==Et||this.dirty!=bt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=bt||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=bt,!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 Ws(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=Et)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Dp extends Oo{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==bt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class iw extends Dn{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==Et)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 Rp(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=Ph(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(s instanceof On){let a=r?r.previousSibling:t.lastChild;Rp(s.contentDOM,s.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Ph(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const zi=function(t){t&&(this.nodeName=t)};zi.prototype=Object.create(null);const Hn=[new zi];function ga(t,e,n){if(t.length==0)return Hn;let r=n?Hn[0]:new zi,i=[r];for(let o=0;o<t.length;o++){let s=t[o].type.attrs;if(s){s.nodeName&&i.push(r=new zi(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&i.length==1&&i.push(r=new zi(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 zp(t,e,n,r){if(n==Hn&&r==Hn)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=Hn[0]),i=a}ow(i,l||Hn[0],s)}return i}function ow(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 Pp(t,e,n){return zp(t,t,Hn,ga(e,n,!V(t)))}function Cs(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 Ph(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class sw{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=lw(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=bt,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 h=this.top.children[u];if(h.matchesMark(e[s])&&!this.isLocked(h.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof On&&u.dirty!=Et&&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=On.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==Et&&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 Dn){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let u=a.dom,h,d=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Et&&Cs(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&&(h=this.recreateWrapper(a,e,n,r,i,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=Vn,h.updateChildren(i,s+1),h.dirty=bt),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)||!Cs(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Dn.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=Dn.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 Op(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 On;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Ws)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Fe||ve)&&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 Dp(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||V(e)&&e.contains(this.lock.parentNode))}}function lw(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 On)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 aw(t,e){return t.type.side-e.type.side}function cw(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,h;for(;s<i.length&&i[s].to==o;){let y=i[s++];y.widget&&(u?(h||(h=[u])).push(y):u=y)}if(u)if(h){h.sort(aw);for(let y=0;y<h.length;y++)n(h[y],c,!!a)}else n(u,c,!!a);let d,f;if(a)f=-1,d=a,a=null;else if(c<t.childCount)f=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,f=-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),f),o=p}}function uw(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 hw(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 ya(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 tc(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(Hs(n)){for(a=s;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&U.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&B0(n.focusNode,n.focusOffset,i.dom))){let h=i.posBefore;c=new U(s==h?l:r.resolve(h))}else if(at&&e=="key"&&s>t.state.selection.to&&V(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&i&&i.posAtStart>t.state.selection.to)for(let h=n.focusNode;;h=h.parentNode){if(getComputedStyle(h).overflow!="visible"){c=K.findFrom(r.resolve(i.posAtStart),1);break}if(h==i.dom||h.nextSibling||!h.parentNode||!V(h.parentNode))break}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=s,d=s;for(let f=0;f<n.rangeCount;f++){let p=n.getRangeAt(f);h=Math.min(h,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(h<0)return null;[a,s]=d==t.state.selection.anchor?[d,h]:[h,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 h=e=="pointer"||t.state.selection.head<l.pos&&!o?1:-1;c=nc(t,u,l,h)}return c}function Lp(t){return t.editable?t.hasFocus():Fp(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function hn(t,e=!1){let n=t.state.selection;if(Bp(t,n),!Lp(t))return;let r=t.input.mouseDown;if(!e&&ve&&r){let i=t.domSelectionRange(),o=t.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&fr(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)dw(t);else{let{anchor:i,head:o}=n,s,l;Lh&&!(n instanceof Q)&&(n.$from.parent.inlineContent||(s=Bh(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Bh(t,n.to))),t.docView.setSelection(i,o,t,e),Lh&&(s&&Fh(s),l&&Fh(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&fw(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}const Lh=Fe||ve&&Sp<63;function Bh(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(Fe&&i&&i.contentEditable=="false")return Sl(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return Sl(i);if(o)return Sl(o)}}function Sl(t){return t.contentEditable="true",Fe&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Fh(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function fw(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(()=>{(!Lp(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function dw(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ie(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Qe&&En<=11&&(n.disabled=!0,n.disabled=!1)}function Bp(t,e){if(e instanceof U){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(_h(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else _h(t)}function _h(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function nc(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Q.between(e,n,r)}function $h(t){return t.editable&&!t.hasFocus()?!1:Fp(t)}function Fp(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return dr(t.dom,e.anchorNode)&&(t.editable||dr(t.dom,e.focusNode))}catch{return!1}}function pw(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return fr(e.node,e.offset,n.anchorNode,n.anchorOffset)}function ka(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&&K.findFrom(o,e)}function xn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function jh(t,e,n){let r=t.state.selection;if(r instanceof Q)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 xn(t,new Q(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=ka(t.state,e);return i&&i instanceof U?xn(t,i):!1}else if(!gt||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?U.isSelectable(o)?xn(t,new U(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):xn(t,new Q(t.state.doc.resolve(e<0?l:l+o.nodeSize))):!1}}else return!1;else{if(r instanceof U&&r.node.isInline)return xn(t,new Q(e>0?r.$to:r.$from));{let i=ka(t.state,e);return i?xn(t,i):!1}}}function Pi(t,e){let n=t.pmViewDesc;return n?n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR"):V(t)&&t.contentEditable=="false"}function Mr(t,e){return e<0?mw(t):gw(t)}function mw(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,s=!1;for(at&&V(n)&&r<Le(n)&&Pi(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!V(n))break;let l=n.childNodes[r-1];if(Pi(l,-1))i=n,o=--r;else if(xe(l))n=l,r=n.nodeValue.length;else break}else{if(_p(n))break;{let l=n.previousSibling;for(;l&&Pi(l,-1);)i=n.parentNode,o=Ie(l),l=l.previousSibling;if(l)n=l,r=Le(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?ba(t,n,r):i&&ba(t,i,o)}function gw(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=Le(n),o,s;for(;;)if(r<i){if(!V(n))break;let l=n.childNodes[r];if(Pi(l,1))o=n,s=++r;else break}else{if(_p(n))break;{let l=n.nextSibling;for(;l&&Pi(l,1);)o=l.parentNode,s=Ie(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=Le(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}o&&ba(t,o,s)}function _p(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function yw(t,e){for(;t&&e==t.childNodes.length&&!Eo(t);)e=Ie(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(xe(n))return n;if(V(n)&&n.contentEditable=="false")break;t=n,e=0}}function kw(t,e){for(;t&&!e&&!Eo(t);)e=Ie(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(xe(n))return n;if(V(n)&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function ba(t,e,n){if(!xe(e)){let s,l;(l=yw(e,n))?(e=l,n=0):(s=kw(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection(),i=t.domSelectionRange();if(!r)return;Hs(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&&hn(t)},50)}function Vh(t,e){let n=t.state.doc.resolve(e);if(!(ve||Mp)&&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 Hh(t,e,n){let r=t.state.selection;if(r instanceof Q&&!r.empty||n.indexOf("s")>-1||gt&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=ka(t.state,e);if(s&&s instanceof U)return xn(t,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof lt?K.near(s,e):K.findFrom(s,e);return l?xn(t,l):!1}return!1}function qh(t,e){if(!(t.state.selection instanceof Q))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 Wh(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function bw(t){if(!Fe||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&V(e)&&n==0&&e.firstChild&&V(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Wh(t,r,"true"),setTimeout(()=>Wh(t,r,"false"),20)}return!1}function xw(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function ww(t,e){let n=e.keyCode,r=xw(e);if(n==8||gt&&n==72&&r=="c")return qh(t,-1)||Mr(t,-1);if(n==46&&!e.shiftKey||gt&&n==68&&r=="c")return qh(t,1)||Mr(t,1);if(n==13||n==27)return!0;if(n==37||gt&&n==66&&r=="c"){let i=n==37?Vh(t,t.state.selection.from)=="ltr"?-1:1:-1;return jh(t,i,r)||Mr(t,i)}else if(n==39||gt&&n==70&&r=="c"){let i=n==39?Vh(t,t.state.selection.from)=="ltr"?1:-1:1;return jh(t,i,r)||Mr(t,i)}else{if(n==38||gt&&n==80&&r=="c")return Hh(t,-1,r)||Mr(t,-1);if(n==40||gt&&n==78&&r=="c")return bw(t)||Hh(t,1,r)||Mr(t,1);if(r==(gt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function rc(t,e){t.someProp("transformCopied",f=>{e=f(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 f=r.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let s=t.someProp("clipboardSerializer")||br.fromSchema(t.state.schema),l=Wp(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,h=0;for(;c&&V(c)&&(u=qp[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let p=l.createElement(u[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),h++}c=a.firstChild}c&&V(c)&&c.setAttribute("data-pm-slice",`${i} ${o}${h?` -${h}`:""} ${JSON.stringify(n)}`);let d=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,`
46
+
47
+ `);return{dom:a,text:d,slice:e}}function $p(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 L(E.from(t.state.schema.text(e.replace(/\r\n?/g,`
48
+ `))),0,0),t.someProp("transformPasted",d=>{l=d(l,t,!0)}),l;let h=t.someProp("clipboardTextParser",d=>d(e,i,r,t));if(h)l=h;else{let d=i.marks(),{schema:f}=t.state,p=br.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let y=s.appendChild(document.createElement("p"));m&&y.appendChild(p.serializeNode(f.text(m,d)))})}}else t.someProp("transformPastedHTML",h=>{n=h(n,t)}),s=Nw(n),qs&&Tw(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 h=+u[3];h>0;h--){let d=s.firstChild;for(;d&&!V(d);)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||ur.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Cw.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Iw(Kh(l,+u[1],+u[2]),u[4]);else if(l=L.maxOpen(Sw(l.content,i),!0),l.openStart||l.openEnd){let h=0,d=0;for(let f=l.content.firstChild;h<l.openStart&&!f.type.spec.isolating;h++,f=f.firstChild);for(let f=l.content.lastChild;d<l.openEnd&&!f.type.spec.isolating;d++,f=f.lastChild);l=Kh(l,h,d)}return t.someProp("transformPasted",h=>{l=h(l,t,a)}),l}const Cw=/^(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 Sw(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&&Vp(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Hp(s[s.length-1],o.length));let u=jp(l,a);s.push(u),i=i.matchType(u.type),o=a}}),s)return E.from(s)}return t}function jp(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,E.from(t));return t}function Vp(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let o=Vp(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(E.from(jp(n,t,i+1))))}}function Hp(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Hp(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(E.empty,!0);return t.copy(n.append(r))}function xa(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=xa(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(E.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function Kh(t,e,n){return e<t.openStart&&(t=new L(xa(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new L(xa(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const qp={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 Wp(){return document.implementation.createHTMLDocument("title")}let Si=null;function Mw(t){let e=window.trustedTypes;if(!e)return t;if(!Si){if(Si=e.defaultPolicy)try{return Si.createHTML(t)}catch{}Si=e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return Si.createHTML(t)}function Nw(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Wp(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(t),o;if((o=i&&qp[i[1].toLowerCase()])&&(t=o.map(s=>"<"+s+">").join("")+t+o.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=Mw(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 h=0;h<u.length;h++)u[h].style.cssText+=c.style.cssText}}}return r}function Tw(t){let e=t.querySelectorAll(ve?"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 Iw(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=E.from(a.create(r[l+1],i))}catch{break}o++,s++}return new L(i,o,s)}const Ve={},He={},Aw={touchstart:!0,touchmove:!0};class vw{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 Ew(t){for(let e in Ve){let n=Ve[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Dw(t,r)&&!ic(t,r)&&(t.editable||!(r.type in He))&&n(t,r)},Aw[e]?{passive:!0}:void 0)}Fe&&t.dom.addEventListener("input",()=>null),wa(t)}function cn(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Ow(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 wa(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>ic(t,r))})}function ic(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Dw(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 Rw(t,e){!ic(t,e)&&Ve[e.type]&&(t.editable||!(e.type in He))&&Ve[e.type](t,e)}function Cn(t,e){let{input:n}=t;return n.lastKeyDispatched||t.composing?!1:(n.lastKeyDispatched=!0,typeof e=="string"&&(e=F0(e=="Backspace"?8:13,e)),t.someProp("handleKeyDown",r=>r(t,e)))}He.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Gp(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),t.input.lastKeyDispatched=!1,!(an&&ve&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),si&&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&&(Cn(t,"Enter"),t.input.lastIOSEnter=0)},200)}else Cn(t,n)||ww(t,n)?n.preventDefault():cn(t,"key")};He.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};He.keypress=(t,e)=>{let n=e;if(Gp(t)||!n.charCode||n.ctrlKey&&!n.altKey||gt&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Q)||!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 Do(t){return{left:t.clientX,top:t.clientY}}function zw(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function oc(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 Ro(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 Pw(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&U.isSelectable(r)?(Ro(t,new U(n)),!0):!1}function Lw(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof U&&(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(U.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?(Ro(t,U.create(t.state.doc,i)),!0):!1}function Bw(t,e,n,r,i){return oc(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?Lw(t,n):Pw(t,n))}function Fw(t,e,n,r){return oc(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function _w(t,e,n,r){return oc(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||$w(t,n,r)}function $w(t,e,n){if(n.button!=0)return!1;let r=Kp(t,e,!0),i=t.state.doc;return r?(Ro(t,r),r instanceof Q&&i.eq(t.state.doc)&&(t.input.mouseDown=new Vw(t,r)),!0):!1}function Kp(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?Q.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 Q.create(r,l+1,l+1+s.content.size);if(n&&U.isSelectable(s))return U.create(r,l)}return null}function sc(t){return Ss(t)}const Jp=gt?"metaKey":"ctrlKey";Ve.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=sc(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&zw(n,t.input.lastClick)&&!n[Jp]&&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(Do(n));s&&(o=="singleClick"?t.input.mouseDown=new jw(t,s,n,!!r):(o=="doubleClick"?Fw:_w)(t,s.pos,s.inside,n)?n.preventDefault():cn(t,"pointer"))};class Up{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 jw extends Up{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[Jp],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&&V(a.nodeDOM)?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof U&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&at&&!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()),cn(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||hn(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(Do(e))),this.updateAllowDefault(e),this.allowDefault||!n?cn(this.view,"pointer"):Bw(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Fe&&this.mightDrag&&!this.mightDrag.node.isAtom||ve&&!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)?(Ro(this.view,K.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):cn(this.view,"pointer")}move(e){this.updateAllowDefault(e),cn(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 Vw extends Up{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(),cn(this.view,"pointer");let n=this.view.posAtCoords(Do(e)),r=n&&Kp(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];Ro(this.view,Q.create(i,s,l))}}Ve.touchstart=t=>{t.input.lastTouch=Date.now(),sc(t),cn(t,"pointer")};Ve.touchmove=t=>{t.input.lastTouch=Date.now(),cn(t,"pointer")};Ve.contextmenu=t=>sc(t);function Gp(t,e){return t.composing?!0:Fe&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Hw=an?5e3:-1;He.compositionstart=He.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Q&&e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ve&&Mp&&qw(t)))t.markCursor=t.state.storedMarks||n.marks(),Ss(t,!0),t.markCursor=null;else if(Ss(t,!e.selection.empty),at&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&V(i)&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(xe(s)){let l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}t.input.composing=!0}Yp(t,Hw)};function qw(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||!V(e)||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return V(r)&&r.contentEditable=="false"}He.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++,Yp(t,20))};function Yp(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Ss(t),e))}function Qp(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Ww(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=P0(e.focusNode,e.focusOffset),r=L0(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 Ss(t,e=!1){if(!(an&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Qp(t),e||t.docView&&t.docView.dirty){let n=tc(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 Kw(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 Gi=Qe&&En<15||si&&j0<604;Ve.copy=He.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=Gi?null:n.clipboardData,s=r.content(),{dom:l,text:a}=rc(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Kw(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Jw(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Uw(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?Yi(t,r.value,null,i,e):Yi(t,r.textContent,r.innerHTML,i,e)},50)}function Yi(t,e,n,r,i){let o=$p(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,i,o||L.empty)))return!0;if(!o)return!1;let s=Jw(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 Xp(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," "):""}He.paste=(t,e)=>{let n=e;if(t.composing&&!an)return;let r=Gi?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Yi(t,Xp(r),r.getData("text/html"),i,n)?n.preventDefault():Uw(t,n)};class Zp{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Gw=gt?"altKey":"ctrlKey";function em(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[Gw]}Ve.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(Do(n)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof U?i.to-1:i.to))){if(r&&r.mightDrag)s=U.create(t.state.doc,r.mightDrag.pos);else if(n.target&&V(n.target)){let h=t.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=t.docView&&(s=U.create(t.state.doc,h.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:c,slice:u}=rc(t,l);(!n.dataTransfer.files.length||!ve||Sp>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Gi?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Gi||n.dataTransfer.setData("text/plain",c),t.dragging=new Zp(u,em(t,n),s)};Ve.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};He.dragover=He.dragenter=(t,e)=>e.preventDefault();He.drop=(t,e)=>{try{Yw(t,e,t.dragging)}finally{t.dragging=null}};function Yw(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Do(e));if(!r)return;let i=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",f=>{o=f(o,t,!1)}):o=$p(t,Xp(e.dataTransfer),Gi?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&em(t,e));if(t.someProp("handleDrop",f=>f(t,e,o||L.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?Dx(t.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let a=t.state.tr;if(s){let{node:f}=n;f?f.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,h=a.doc;if(u?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(h))return;let d=a.doc.resolve(c);if(u&&U.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new U(d));else{let f=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,y,g)=>f=g),a.setSelection(nc(t,d,a.doc.resolve(f)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Ve.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()&&hn(t)},20)}}};Ve.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)};Ve.beforeinput=(t,e)=>{if(an&&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(),Cn(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 He)Ve[t]=He[t];function Qi(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 Ca{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 Ms{constructor(e,n){this.toDOM=e,this.spec=n||er,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 Ee(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ms&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Qi(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Rn{constructor(e,n){this.attrs=e,this.spec=n||er}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 Ee(o,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Rn&&Qi(this.attrs,e.attrs)&&Qi(this.spec,e.spec)}static is(e){return e.type instanceof Rn}destroy(){}}class lc{constructor(e,n){this.attrs=e,this.spec=n||er}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 Ee(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 lc&&Qi(this.attrs,e.attrs)&&Qi(this.spec,e.spec)}destroy(){}}class Ee{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ee(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 Ee(e,e,new Ms(n,r))}static inline(e,n,r,i){return new Ee(e,n,new Rn(r,i))}static node(e,n,r,i){return new Ee(e,n,new lc(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Rn}get widget(){return this.type instanceof Ms}}const Ir=[],er={};class me{constructor(e,n){this.local=e.length?e:Ir,this.children=n.length?n:Ir}static create(e,n){return n.length?Ns(n,e,0,er):Pe}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==Pe||e.maps.length==0?this:this.mapInner(e,n,0,0,r||er)}mapInner(e,n,r,i,o){let s;if(this.local.length){let l=new Ca(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?Qw(this.children,s||[],e,n,r,i,o):s?new me(s.sort(tr),Ir):Pe}add(e,n){return n.length?this==Pe?me.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=nm(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,Ns(u,l,c+1,er)),o+=3}});let s=tm(o?rm(n):n,-r);if(s.length){let l=new Ca(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||s.splice(a--,1)}return new me(s.length?this.local.concat(s).sort(tr):this.local,i||this.children)}remove(e){return e.length==0||this==Pe?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,h;u<e.length;u++)(h=e[u])&&h.from>l&&h.to<a&&(e[u]=null,(s||(s=[])).push(h));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(s,l+1);c!=Pe?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 me(i,r):Pe}forChild(e,n){if(this==Pe)return this;if(n.isLeaf)return me.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 Rn){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 me(i.sort(tr),Ir);return r?new Sn([l,r]):l}return r||Pe}eq(e){if(this==e)return!0;if(!(e instanceof me)||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 ac(this.localsInner(e))}localsInner(e){if(this==Pe)return Ir;if(e.inlineContent||!this.local.some(Rn.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Rn||n.push(this.local[r]);return n}forEachSet(e){e(this)}}me.empty=new me([],[]);me.removeOverlap=ac;const Pe=me.empty;class Sn{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,er));return Sn.from(r)}forChild(e,n){if(n.isLeaf)return me.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,n);o!=Pe&&(o instanceof Sn?r=r.concat(o.members):r.push(o))}return Sn.from(r)}eq(e){if(!(e instanceof Sn)||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?ac(r?n:n.sort(tr)):Ir}static from(e){switch(e.length){case 0:return Pe;case 1:return e[0];default:return new Sn(e.every(n=>n instanceof me)?e:e.reduce((n,r)=>n.concat(r instanceof me?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function Qw(t,e,n,r,i,o,s){let l=t.slice();for(let c=0,u=o;c<n.maps.length;c++){let h=0;n.maps[c].forEach((d,f,p,m)=>{let y=m-p-(f-d);for(let g=0;g<l.length;g+=3){let C=l[g+1];if(C<0||d>C+u-h)continue;let w=l[g]+u-h;f>=w?l[g+1]=d<=w?-2:-1:d>=u&&y&&(l[g]+=y,l[g+1]+=y)}h+=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),h=u-i;if(h<0||h>=r.content.size){a=!0;continue}let d=n.map(t[c+1]+o,-1),f=d-i,{index:p,offset:m}=r.content.findIndex(h),y=r.maybeChild(p);if(y&&m==h&&m+y.nodeSize==f){let g=l[c+2].mapInner(n,y,u+1,t[c]+o+1,s);g!=Pe?(l[c]=h,l[c+1]=f,l[c+2]=g):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Xw(l,t,e,n,i,o,s),u=Ns(c,r,0,s);e=u.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,d=0;h<u.children.length;h+=3){let f=u.children[h];for(;d<l.length&&l[d]<f;)d+=3;l.splice(d,0,u.children[h],u.children[h+1],u.children[h+2])}}return new me(e.sort(tr),l)}function tm(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 Ee(i.from+e,i.to+e,i.type))}return n}function Xw(t,e,n,r,i,o,s){function l(a,c){for(let u=0;u<a.local.length;u++){let h=a.local[u].map(r,i,c);h?n.push(h):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 nm(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 rm(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Ns(t,e,n,r){let i=[],o=!1;e.forEach((l,a)=>{let c=nm(t,l,a+n);if(c){o=!0;let u=Ns(c,l,n+a+1,r);u!=Pe&&i.push(a,a+l.nodeSize,u)}});let s=tm(o?rm(t):t,-n).sort(tr);if(s.length){let l=new Ca(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 me(s,i):Pe}function tr(t,e){return t.from-e.from||t.to-e.to}function ac(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),Jh(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),Jh(e,i,r.copy(o.from,r.to)));break}}}return e}function Jh(t,e,n){for(;e<t.length&&tr(n,t[e])>0;)e++;t.splice(e,0,n)}function Ml(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Pe&&e.push(r)}),t.cursorWrapper&&e.push(me.create(t.state.doc,[t.cursorWrapper.deco])),Sn.from(e)}const Zw={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},eC=Qe&&En<=11;class tC{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 nC{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new tC,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]);Qe&&En<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Fe&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),eC&&(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,Zw)),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($h(this.view)){if(this.suppressingSelectionUpdates)return hn(this.view);if(Qe&&En<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&fr(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=oi(o))n.add(o);for(let o=e.anchorNode;o;o=oi(o))if(n.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:xe(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&&$h(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 h=this.registerMutation(n[u],a);h&&(o=o<0?h.from:Math.min(h.from,o),s=s<0?h.to:Math.max(h.to,s),h.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||ve&&(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 h=u.nextSibling;for(;h&&V(h);){if(h.contentEditable=="false"){u.parentNode.removeChild(u);break}h=h.firstChild}}}else if(at&&a.length){let u=a.filter(h=>h.nodeName=="BR");if(u.length==2){let[h,d]=u;h.parentNode&&h.parentNode.parentNode==d.parentNode?d.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let d of u){let f=d.parentNode;f&&f.nodeName=="LI"&&(!h||oC(e,h)!=f)&&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&&Hs(r)&&(c=tc(e))&&c.eq(K.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,hn(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),rC(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,sC(e,a)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):r&&!this.currentSelection.eq(r)&&hn(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 h=e.addedNodes[u];n.push(h),xe(h)&&(this.lastChangedTextNode=h)}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(Qe&&En<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:h,nextSibling:d}=e.addedNodes[u];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(o=d)}let s=i&&i.parentNode==e.target?Ie(i)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=o&&o.parentNode==e.target?Ie(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 Uh=new WeakMap,Gh=!1;function rC(t){if(!Uh.has(t)&&(Uh.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=at,Gh)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."),Gh=!0}}function Yh(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return fr(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function iC(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Yh(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?Yh(t,n):null}function oC(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 sC(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||!V(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 lC(t,e,n,r){let{node:i,fromOffset:o,toOffset:s,from:l,to:a}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,h=c.anchorNode;if(h&&dr(t.dom,h)&&(u=[{node:h,offset:c.anchorOffset}],Hs(c)||u.push({node:c.focusNode,offset:c.focusOffset})),ve&&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,f=t.someProp("domParser")||ur.fromSchema(t.state.schema),p=d.resolve(l),m=null,y=f.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:aC(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 aC=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(Fe&&/^(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||Fe&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},cC=/^(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 uC(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let R=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,F=tc(t,R);if(F&&!t.state.selection.eq(F)){if(ve&&an&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&Cn(t,"Enter"))return;let ee=t.state.tr.setSelection(F);R=="pointer"?ee.setMeta("pointer",!0):R=="key"&&ee.scrollIntoView(),o&&ee.setMeta("composition",o),t.dispatch(ee)}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=lC(t,e,n,i),u=t.state.doc,h=u.slice(c.from,c.to),d,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(d=t.state.selection.to,f="end"):(d=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let p=pC(h.content,c.doc.content,c.from,d,f);if(p&&t.input.domChangeCount++,(si&&t.input.lastIOSEnter>Date.now()-225||an)&&i.some(R=>V(R)&&!cC.test(R.nodeName))&&(!p||p.endA>=p.endB)&&Cn(t,"Enter")){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof Q&&!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 R=Qh(t,t.state.doc,c.sel);if(R&&!R.eq(t.state.selection)){let F=t.state.tr.setSelection(R);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 Q&&(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)),Qe&&En<=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((si&&t.input.lastIOSEnter>Date.now()-225&&(!C||i.some(R=>R.nodeName=="DIV"||R.nodeName=="P"))||!C&&dC(c.doc,m.pos,y.pos))&&Cn(t,"Enter")){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&(C?p.endA>p.start&&p.endB==p.start:fC(u,p.start,p.endA,m,y))&&Cn(t,"Backspace")){an&&ve&&t.domObserver.suppressSelectionUpdates();return}ve&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),an&&!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(()=>Cn(t,"Enter"),20));let w=p.start,v=p.endA,B=R=>{let F=R||t.state.tr.replace(w,v,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let ee=Qh(t,F.doc,c.sel);ee&&!(ve&&t.composing&&ee.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(ee.head==w||ee.head==F.mapping.map(v)-1)||Qe&&ee.empty&&ee.head==w)&&F.setSelection(ee)}return o&&F.setMeta("composition",o),F.scrollIntoView()},S;if(C)if(m.pos==y.pos){Qe&&En<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>hn(t),20));let R=B(t.state.tr.delete(w,v)),F=u.resolve(p.start).marksAcross(u.resolve(p.endA));F&&R.ensureMarks(F),t.dispatch(R)}else if(p.endA==p.endB&&(S=hC(m.parent.content.cut(m.parentOffset,y.parentOffset),g.parent.content.cut(g.parentOffset,p.endA-g.start())))){let R=B(t.state.tr);S.type=="add"?R.addMark(w,v,S.mark):R.removeMark(w,v,S.mark),t.dispatch(R)}else if(m.parent.child(m.index()).isText&&m.index()==y.index()-(y.textOffset?0:1)){let R=m.parent.textBetween(m.parentOffset,y.parentOffset),F=()=>B(t.state.tr.insertText(R,w,v));t.someProp("handleTextInput",ee=>ee(t,w,v,R,F))||t.dispatch(F())}else t.dispatch(B());else t.dispatch(B())}function Qh(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:nc(t,e.resolve(n.anchor),e.resolve(n.head))}function hC(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(E.from(c).eq(t))return{mark:l,type:s}}function fC(t,e,n,r,i){if(n-e<=i.pos-r.pos||Nl(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(Nl(o,!0,!0));return!s.parent.isTextblock||s.pos>n||Nl(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function dC(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 Nl(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 pC(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 im{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 vw,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(nf),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=ef(this),Zh(this),this.nodeViews=tf(this),this.docView=zh(this.state.doc,Xh(this),Ml(this),this.dom,this),this.domObserver=new nC(this,(r,i,o,s)=>uC(this,r,i,o,s)),this.domObserver.start(),Ew(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&&wa(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(nf),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&&(Qp(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 f=tf(this);gC(f,this.nodeViews)&&(this.nodeViews=f,o=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&wa(this),this.editable=ef(this),Zh(this);let a=Ml(this),c=Xh(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=o||!this.docView.matchesNode(e.doc,c,a);(h||!e.selection.eq(i.selection))&&(s=!0);let d=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&q0(this);if(s){this.domObserver.stop();let f=h&&(Qe||ve)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&mC(i.selection,e.selection);if(h){let m=ve?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Ww(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=zh(e.doc,c,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}let p=this.input.mouseDown;f||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&pw(this)&&p.delaySelUpdate())?hn(this,f):(Bp(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&&W0(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!dr(this.dom,e))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof U){let n=this.docView.domAfterPos(this.state.selection.from);V(n)&&vh(this,n.getBoundingClientRect(),e)}else vh(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 Zp(e.slice,e.move,i<0?void 0:U.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(Qe){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&&K0(this.dom),hn(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 Q0(this,e)}coordsAtPos(e,n=1){return vp(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 nw(this,n||this.state,e)}pasteHTML(e,n){return Yi(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Yi(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return rc(this,e)}destroy(){this.docView&&(Ow(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ml(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,R0())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Rw(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?Fe&&this.root.nodeType===11&&_0(this.dom.ownerDocument)==this.dom&&iC(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}im.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Xh(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"),[Ee.node(0,t.state.doc.content.size,e)]}function Zh(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:Ee.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function ef(t){return!t.someProp("editable",e=>e(t.state)===!1)}function mC(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 tf(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 gC(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 nf(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 dn(t,e){return t.meta={package:"@milkdown/core",group:"System",...e},t}var om={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}},_t=ie({},"editorView"),Ii=ie({},"editorState"),Tl=ie([],"initTimer"),rf=ie({},"editor"),Xi=ie([],"inputRules"),pr=ie([],"prosePlugins"),Zi=ie([],"remarkPlugins"),eo=ie([],"nodeView"),to=ie([],"markView"),nr=ie(ra().use(Ql).use(ea),"remark"),zr=ie({handlers:om,encode:[]},"remarkStringifyOptions"),ns=qt("ConfigReady");function yC(t){const e=n=>(n.record(ns),async()=>(await t(n),n.done(ns),()=>{n.clearTimer(ns)}));return dn(e,{displayName:"Config"}),e}var Pr=qt("InitReady");function kC(t){const e=n=>(n.inject(rf,t).inject(pr,[]).inject(Zi,[]).inject(Xi,[]).inject(eo,[]).inject(to,[]).inject(zr,{handlers:om,encode:[]}).inject(nr,ra().use(Ql).use(ea)).inject(Tl,[ns]).record(Pr),async()=>{await n.waitTimers(Tl);const r=n.get(zr);return n.set(nr,ra().use(Ql).use(ea,r)),n.done(Pr),()=>{n.remove(rf).remove(pr).remove(Zi).remove(Xi).remove(eo).remove(to).remove(zr).remove(nr).remove(Tl).clearTimer(Pr)}});return dn(e,{displayName:"Init"}),e}var je=qt("SchemaReady"),Il=ie([],"schemaTimer"),fn=ie({},"schema"),Li=ie([],"nodes"),Bi=ie([],"marks");function of(t){var e;return{...t,parseDOM:(e=t.parseDOM)==null?void 0:e.map(n=>({priority:t.priority,...n}))}}var sm=t=>(t.inject(fn,{}).inject(Li,[]).inject(Bi,[]).inject(Il,[Pr]).record(je),async()=>{await t.waitTimers(Il);const e=t.get(nr),n=t.get(Zi).reduce((s,l)=>s.use(l.plugin,l.options),e);t.set(nr,n);const r=Object.fromEntries(t.get(Li).map(([s,l])=>[s,of(l)])),i=Object.fromEntries(t.get(Bi).map(([s,l])=>[s,of(l)])),o=new lx({nodes:r,marks:i});return t.set(fn,o),t.done(je),()=>{t.remove(fn).remove(Li).remove(Bi).remove(Il).clearTimer(je)}});dn(sm,{displayName:"Schema"});var Kn,mt,Bf,lm=(Bf=class{constructor(){$(this,Kn);$(this,mt);D(this,Kn,new jf),D(this,mt,null),this.setCtx=t=>{D(this,mt,t)},this.chain=()=>{if(x(this,mt)==null)throw tl();const t=x(this,mt),e=[],n=this.get.bind(this),r={run:()=>{const o=ui(...e),s=t.get(_t);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,mt)}create(t,e){const n=t.create(x(this,Kn).sliceMap);return n.set(e),n}get(t){return x(this,Kn).get(t).get()}remove(t){return x(this,Kn).remove(t)}call(t,e){if(x(this,mt)==null)throw tl();const n=this.get(t)(e),r=x(this,mt).get(_t);return n(r.state,r.dispatch,r)}inline(t){if(x(this,mt)==null)throw tl();const e=x(this,mt).get(_t);return t(e.state,e.dispatch,e)}},Kn=new WeakMap,mt=new WeakMap,Bf);function bC(t="cmdKey"){return ie((()=>()=>!1),t)}var X=ie(new lm,"commands"),Al=ie([je],"commandsTimer"),Fi=qt("CommandsReady"),am=t=>{const e=new lm;return e.setCtx(t),t.inject(X,e).inject(Al,[je]).record(Fi),async()=>(await t.waitTimers(Al),t.done(Fi),()=>{t.remove(X).remove(Al).clearTimer(Fi)})};dn(am,{displayName:"Commands"});function xC(t){return t.Backspace=ui(l0,Ua,Vx,ap),t}var Jn,Ge,Ff,cm=(Ff=class{constructor(){$(this,Jn);$(this,Ge);D(this,Jn,null),D(this,Ge,[]),this.setCtx=t=>{D(this,Jn,t)},this.add=t=>(x(this,Ge).push(t),()=>{D(this,Ge,x(this,Ge).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,Ge).push(i),e.push(()=>{D(this,Ge,x(this,Ge).filter(o=>o!==i))})}else x(this,Ge).push(r),e.push(()=>{D(this,Ge,x(this,Ge).filter(i=>i!==r))})}),()=>{e.forEach(n=>n())}},this.addBaseKeymap=()=>{const t=xC(o0);return this.addObjectKeymap(t)},this.build=()=>{const t={};return x(this,Ge).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,Jn);if(a==null)throw Ds();const c=r.map(u=>u.onRun(a));return ui(...c)(o,s,l)}]}))}}get ctx(){return x(this,Jn)}},Jn=new WeakMap,Ge=new WeakMap,Ff),Ts=ie(new cm,"keymap"),vl=ie([je],"keymapTimer"),_i=qt("KeymapReady"),wC=t=>{const e=new cm;return e.setCtx(t),t.inject(Ts,e).inject(vl,[je]).record(_i),async()=>(await t.waitTimers(vl),t.done(_i),()=>{t.remove(Ts).remove(vl).clearTimer(_i)})},rs=qt("ParserReady"),um=(()=>{throw Ds()}),$i=ie(um,"parser"),El=ie([],"parserTimer"),hm=t=>(t.inject($i,um).inject(El,[je]).record(rs),async()=>{await t.waitTimers(El);const e=t.get(nr),n=t.get(fn);return t.set($i,E0.create(n,e)),t.done(rs),()=>{t.remove($i).remove(El).clearTimer(rs)}});dn(hm,{displayName:"Parser"});var is=qt("SerializerReady"),Ol=ie([],"serializerTimer"),fm=(()=>{throw Ds()}),ji=ie(fm,"serializer"),dm=t=>(t.inject(ji,fm).inject(Ol,[je]).record(is),async()=>{await t.waitTimers(Ol);const e=t.get(nr),n=t.get(fn);return t.set(ji,D0.create(n,e)),t.done(is),()=>{t.remove(ji).remove(Ol).clearTimer(is)}});dn(dm,{displayName:"Serializer"});var ss=ie("","defaultValue"),Dl=ie(t=>t,"stateOptions"),Rl=ie([],"editorStateTimer"),ls=qt("EditorStateReady");function CC(t,e,n){if(typeof t=="string")return e(t);if(t.type==="html")return ur.fromSchema(n).parse(t.dom);if(t.type==="json")return kt.fromJSON(n,t.value);throw oy(t)}var SC=new De("MILKDOWN_STATE_TRACKER"),pm=t=>(t.inject(ss,"").inject(Ii,{}).inject(Dl,e=>e).inject(Rl,[rs,is,Fi,_i]).record(ls),async()=>{await t.waitTimers(Rl);const e=t.get(fn),n=t.get($i),r=t.get(Xi),i=t.get(Dl),o=t.get(pr),s=CC(t.get(ss),n,e),l=t.get(Ts),a=l.addBaseKeymap(),c=[...o,new Oe({key:SC,state:{init:()=>{},apply:(d,f,p,m)=>{t.set(Ii,m)}}}),m0({rules:r}),yp(l.build())];t.set(pr,c);const u=i({schema:e,doc:s,plugins:c}),h=Or.create(u);return t.set(Ii,h),t.done(ls),()=>{a(),t.remove(ss).remove(Ii).remove(Dl).remove(Rl).clearTimer(ls)}});dn(pm,{displayName:"EditorState"});var no=ie([],"pasteRule"),zl=ie([je],"pasteRuleTimer"),as=qt("PasteRuleReady"),mm=t=>(t.inject(no,[]).inject(zl,[je]).record(as),async()=>(await t.waitTimers(zl),t.done(as),()=>{t.remove(no).remove(zl).clearTimer(as)}));dn(mm,{displayName:"PasteRule"});var Pl=qt("EditorViewReady"),Ll=ie([],"editorViewTimer"),Vi=ie({},"editorViewOptions"),cs=ie(null,"root"),Sa=ie(null,"rootDOM"),Ma=ie({},"rootAttrs");function MC(t,e){const n=document.createElement("div");n.className="milkdown",t.appendChild(n),e.set(Sa,n);const r=e.get(Ma);return Object.entries(r).forEach(([i,o])=>n.setAttribute(i,o)),n}function NC(t){t.classList.add("editor"),t.setAttribute("role","textbox")}var TC=new De("MILKDOWN_VIEW_CLEAR"),gm=t=>(t.inject(cs,document.body).inject(_t,{}).inject(Vi,{}).inject(Sa,null).inject(Ma,{}).inject(Ll,[ls,as]).record(Pl),async()=>{await t.wait(Pr);const e=t.get(cs)||document.body,n=typeof e=="string"?document.querySelector(e):e;t.update(pr,a=>[new Oe({key:TC,view:c=>{const u=n?MC(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(Ll);const r=t.get(Ii),i=t.get(Vi),o=Object.fromEntries(t.get(eo)),s=Object.fromEntries(t.get(to)),l=new im(n,{state:r,nodeViews:o,markViews:s,transformPasted:(a,c,u)=>(t.get(no).sort((h,d)=>(d.priority??50)-(h.priority??50)).map(h=>h.run).forEach(h=>{a=h(a,c,u)}),a),...i});return NC(l.dom),t.set(_t,l),t.done(Pl),()=>{l==null||l.destroy(),t.remove(cs).remove(_t).remove(Vi).remove(Sa).remove(Ma).remove(Ll).clearTimer(Pl)}});dn(gm,{displayName:"EditorView"});var Un,it,on,Xr,xo,wo,Ye,sn,Gn,Co,Yn,Zr,So,An,ei,ti,IC=(ti=class{constructor(){$(this,Un);$(this,it);$(this,on);$(this,Xr);$(this,xo);$(this,wo);$(this,Ye);$(this,sn);$(this,Gn);$(this,Co);$(this,Yn);$(this,Zr);$(this,So);$(this,An);$(this,ei);D(this,Un,!1),D(this,it,"Idle"),D(this,on,[]),D(this,Xr,()=>{}),D(this,xo,new jf),D(this,wo,new ky),D(this,Ye,new Map),D(this,sn,new Map),D(this,Gn,new yy(x(this,xo),x(this,wo))),D(this,Co,()=>{const e=yC(async r=>{await Promise.all(x(this,on).map(i=>Promise.resolve(i(r))))}),n=[sm,hm,dm,am,wC,mm,pm,gm,kC(this),e];x(this,Yn).call(this,n,x(this,sn))}),D(this,Yn,(e,n)=>{e.forEach(r=>{const i=x(this,Gn).produce(x(this,Un)?r.meta:void 0),o=r(i);n.set(r,{ctx:i,handler:o,cleanup:void 0})})}),D(this,Zr,(e,n=!1)=>Promise.all([e].flat().map(async r=>{var o;const i=(o=x(this,Ye).get(r))==null?void 0:o.cleanup;return n?x(this,Ye).delete(r):x(this,Ye).set(r,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof i=="function"?i():i}))),D(this,So,async()=>{await Promise.all([...x(this,sn).entries()].map(async([e,{cleanup:n}])=>typeof n=="function"?n():n)),x(this,sn).clear()}),D(this,An,e=>{D(this,it,e),x(this,Xr).call(this,e)}),D(this,ei,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)=>(D(this,Un,e),this),this.onStatusChange=e=>(D(this,Xr,e),this),this.config=e=>(x(this,on).push(e),this),this.removeConfig=e=>(D(this,on,x(this,on).filter(n=>n!==e)),this),this.use=e=>{const n=[e].flat();return n.flat().forEach(r=>{x(this,Ye).set(r,{ctx:void 0,handler:void 0,cleanup:void 0})}),x(this,it)==="Created"&&x(this,Yn).call(this,n,x(this,Ye)),this},this.remove=async e=>x(this,it)==="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,Zr).call(this,[e].flat(),!0),this),this.create=async()=>x(this,it)==="OnCreate"?this:(x(this,it)==="Created"&&await this.destroy(),x(this,An).call(this,"OnCreate"),x(this,Co).call(this),x(this,Yn).call(this,[...x(this,Ye).keys()],x(this,Ye)),await Promise.all([x(this,ei).call(this,x(this,sn)),x(this,ei).call(this,x(this,Ye))].flat()),x(this,An).call(this,"Created"),this),this.destroy=async(e=!1)=>x(this,it)==="Destroyed"||x(this,it)==="OnDestroy"?this:x(this,it)==="OnCreate"?new Promise(n=>{setTimeout(()=>{n(this.destroy(e))},50)}):(e&&D(this,on,[]),x(this,An).call(this,"OnDestroy"),await x(this,Zr).call(this,[...x(this,Ye).keys()],e),await x(this,So).call(this),x(this,An).call(this,"Destroyed"),this),this.action=e=>e(x(this,Gn)),this.inspect=()=>x(this,Un)?[...x(this,sn).values(),...x(this,Ye).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 ti}get ctx(){return x(this,Gn)}get status(){return x(this,it)}},Un=new WeakMap,it=new WeakMap,on=new WeakMap,Xr=new WeakMap,xo=new WeakMap,wo=new WeakMap,Ye=new WeakMap,sn=new WeakMap,Gn=new WeakMap,Co=new WeakMap,Yn=new WeakMap,Zr=new WeakMap,So=new WeakMap,An=new WeakMap,ei=new WeakMap,ti);function ym(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 J(t,e){const n=bC(t),r=i=>async()=>{r.key=n,await i.wait(Fi);const o=e(i);return i.get(X).create(n,o),r.run=s=>i.get(X).call(t,s),()=>{i.get(X).remove(n)}};return r}function et(t){const e=n=>async()=>{await n.wait(je);const r=t(n);return n.update(Xi,i=>[...i,r]),e.inputRule=r,()=>{n.update(Xi,i=>i.filter(o=>o!==r))}};return e}function AC(t){const e=n=>async()=>{await n.wait(je);const r=t(n);return n.update(no,i=>[...i,r]),e.pasteRule=r,()=>{n.update(no,i=>i.filter(o=>o!==r))}};return e}function vC(t,e){const n=r=>async()=>{const i=e(r);return r.update(Bi,o=>ym(o,t,[t,i])),n.id=t,n.schema=i,()=>{r.update(Bi,o=>o.filter(([s])=>s!==t))}};return n.type=r=>{const i=r.get(fn).marks[t];if(!i)throw dy(t);return i},n}function cc(t,e){const n=r=>async()=>{const i=e(r);return r.update(Li,o=>ym(o,t,[t,i])),n.id=t,n.schema=i,()=>{r.update(Li,o=>o.filter(([s])=>s!==t))}};return n.type=r=>{const i=r.get(fn).nodes[t];if(!i)throw fy(t);return i},n}function Xe(t){let e;const n=r=>async()=>(await r.wait(je),e=t(r),r.update(pr,i=>[...i,e]),()=>{r.update(pr,i=>i.filter(o=>o!==e))});return n.plugin=()=>e,n.key=()=>e.spec.key,n}function EC(t){const e=n=>async()=>{await n.wait(_i);const r=n.get(Ts),i=t(n),o=r.addObjectKeymap(i);return e.keymap=i,()=>{o()}};return e}function sf(t,e){const n=r=>async()=>{await r.wait(je);const i=e(r);return t.type(r)instanceof cr?r.update(eo,o=>[...o,[t.id,i]]):r.update(to,o=>[...o,[t.id,i]]),n.view=i,n.type=t,()=>{t.type(r)instanceof cr?r.update(eo,o=>o.filter(s=>s[0]!==t.id)):r.update(to,o=>o.filter(s=>s[0]!==t.id))}};return n}function Wt(t,e){const n=ie(t,e),r=i=>(i.inject(n),()=>()=>{i.remove(n)});return r.key=n,r}function Ce(t,e){const n=Wt(e,t),r=cc(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=>Ce(t,o(e)),i}function xr(t,e){const n=Wt(e,t),r=vC(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=>xr(t,o(e)),i}function tt(t,e){const n=Wt(Object.fromEntries(Object.entries(e).map(([o,{shortcuts:s,priority:l}])=>[o,{shortcuts:s,priority:l}])),`${t}Keymap`),r=EC(o=>{const s=o.get(n.key),l=Object.entries(e).flatMap(([a,{command:c}])=>{const u=s[a],h=[u.shortcuts].flat(),d=u.priority;return h.map(f=>[f,{key:f,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 Rt=(t,e=()=>({}))=>Wt(e,`${t}Attr`),zo=(t,e=()=>({}))=>Wt(e,`${t}Attr`);function Fn(t,e,n){const r=Wt({},t),i=s=>async()=>{await s.wait(Pr);const l={plugin:e(s),options:s.get(r.key)};return s.update(Zi,a=>[...a,l]),()=>{s.update(Zi,a=>a.filter(c=>c!==l))}},o=[r,i];return o.id=t,o.plugin=i,o.options=r,o}function li(t,e){return t instanceof cr?e==t:t.indexOf(e)>-1}function OC(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(!li(t,l.type))return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||!li(t,i.node(-3).type)||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let h=E.empty,d=i.index(-1)?1:i.index(-2)?2:3;for(let g=i.depth-d;g>=i.depth-3;g--)h=E.from(i.node(g).copy(h));let f=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;h=h.append(E.from(i.node(-3).type.createAndFill()));let p=i.before(i.depth-(d-1)),m=n.tr.replace(p,i.after(-f),new L(h,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(K.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 Ri(c.doc,i.pos,2,u)?(r&&r(c.split(i.pos,2,u).scrollIntoView()),!0):!1}}function uc(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,s=>s.childCount>0&&li(t,s.firstChild.type));return o?n?li(t,r.node(o.depth-1).type)?DC(e,n,o):RC(e,n,o):!0:!1}}function DC(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 Be(i-1,o,i,o,new L(E.from(s.create(null,n.parent.copy())),1,0),1,!0)),n=new Pd(r.doc.resolve(n.$from.pos),r.doc.resolve(o),n.depth));const l=_s(n);if(l==null)return!1;r.lift(n,l);let a=r.doc.resolve(r.mapping.map(i,-1)-1);return $s(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function RC(t,e,n){let r=t.tr,i=n.parent;for(let f=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)f-=i.child(p).nodeSize,r.delete(f-1,f+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?E.empty:E.from(i))))return!1;let h=o.pos,d=h+s.nodeSize;return r.step(new Be(h-(l?1:0),d+(a?1:0),h+1,d-1,new L((l?E.empty:E.from(i.copy(E.empty))).append(a?E.empty:E.from(i.copy(E.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function zC(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&li(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(!li(t,a.type))return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=E.from(c?a.lastChild.lastChild.type.create():null),h=new L(E.from(a.type.create(null,E.from(l.type.create(null,u)))),c?3:1,0),d=o.start,f=o.end;n(e.tr.step(new Be(d-(c?3:1),f,d,f,h,1,!0)).scrollIntoView())}return!0}}function PC(t){const e=new Map;if(!t||!t.type)throw new Error("mdast-util-definitions expected node");return kr(t,"definition",function(r){const i=lf(r.identifier);i&&!e.get(i)&&e.set(i,r)}),n;function n(r){const i=lf(r);return e.get(i)}}function lf(t){return String(t||"").toUpperCase()}function LC(){return function(t){const e=PC(t);kr(t,function(n,r,i){if(n.type==="definition"&&i!==void 0&&typeof r=="number")return i.children.splice(r,1),[ni,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},[ni,r]}})}}function BC(t){const e={...t};return e.position&&(e.position={start:{...e.position.start},end:{...e.position.end}}),delete e.children,e}var FC="<br />",_C=/^<br\s*\/?\s*>$/i,$C=t=>typeof t=="string"&&_C.test(t.trim());function km(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(E.fromArray(n))}function I(t,e){return Object.assign(t,{meta:{package:"@milkdown/preset-commonmark",...e}}),t}var hc=zo("emphasis");I(hc,{displayName:"Attr<emphasis>",group:"Emphasis"});var wr=xr("emphasis",t=>({attrs:{marker:{default:t.get(zr).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"}],toDOM:e=>["em",t.get(hc.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})}}}));I(wr.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"});I(wr.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var Ks=J("ToggleEmphasis",t=>()=>Ao(wr.type(t)));I(Ks,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var bm=et(t=>vo(/(?:^|[^*])\*([^*]+)\*$/,wr.type(t),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:n})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:n+1}}));I(bm,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var xm=et(t=>vo(/\b_(?![_\s])(.*?[^_\s])_$/,wr.type(t),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:n})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:n+1}}));I(xm,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var fc=tt("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:t=>{const e=t.get(X);return()=>e.call(Ks.key)}}});I(fc.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"});I(fc.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var dc=zo("strong");I(dc,{displayName:"Attr<strong>",group:"Strong"});var hi=xr("strong",t=>({attrs:{marker:{default:t.get(zr).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(dc.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})}}}));I(hi.mark,{displayName:"MarkSchema<strong>",group:"Strong"});I(hi.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var Js=J("ToggleStrong",t=>()=>Ao(hi.type(t)));I(Js,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var wm=et(t=>vo(new RegExp("(?<![\\w:/])(?:\\*\\*|__)([^*_]+?)(?:\\*\\*|__)(?![\\w/])$"),hi.type(t),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));I(wm,{displayName:"InputRule<strong>",group:"Strong"});var pc=tt("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:t=>{const e=t.get(X);return()=>e.call(Js.key)}}});I(pc.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"});I(pc.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var mc=zo("inlineCode");I(mc,{displayName:"Attr<inlineCode>",group:"InlineCode"});var un=xr("inlineCode",t=>({priority:100,code:!0,inclusive:!1,parseDOM:[{tag:"code"}],toDOM:e=>["code",t.get(mc.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)}}));I(un.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"});I(un.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var Us=J("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,un.type(t))?(n==null||n(i.removeMark(o,s,un.type(t))),!0):(Object.keys(e.schema.marks).filter(l=>l!==un.type.name).map(l=>e.schema.marks[l]).forEach(l=>{i.removeMark(o,s,l)}),n==null||n(i.addMark(o,s,un.type(t).create())),!0)});I(Us,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var Cm=et(t=>vo(/(?:`)([^`]+)(?:`)$/,un.type(t)));I(Cm,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var gc=tt("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:t=>{const e=t.get(X);return()=>e.call(Us.key)}}});I(gc.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"});I(gc.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var jC=new Set(["http:","https:","mailto:","tel:","ftp:"]);function VC(t){return t<=32||t>=127&&t<=160||t>=8203&&t<=8205||t===8232||t===8233||t===65279}function HC(t){let e="";for(const n of t)VC(n.codePointAt(0)??0)||(e+=n);return e}function qC(t){var i;if(typeof t!="string")return"";const e=t.trim();if(!e)return"";const n=HC(e),r=(i=/^([a-z][a-z0-9+.-]*):/i.exec(n))==null?void 0:i[1];return!r||jC.has(`${r.toLowerCase()}:`)?e:""}var yc=zo("link");I(yc,{displayName:"Attr<link>",group:"Link"});var $t=xr("link",t=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ht(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:e=>["a",{...t.get(yc.key)(e),...e.attrs,href:qC(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})}}}));I($t.mark,{displayName:"MarkSchema<link>",group:"Link"});var Sm=J("ToggleLink",t=>(e={})=>Ao($t.type(t),e));I(Sm,{displayName:"Command<toggleLinkCommand>",group:"Link"});var Mm=J("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($t.type(t).isInSet(p.marks))return i=p,o=m,!1}),!i)return!1;const c=i.marks.find(({type:p})=>p===$t.type(t));if(!c)return!1;const u=o,h=o+i.nodeSize,{tr:d}=n,f=$t.type(t).create({...c.attrs,...e});return f?(r(d.removeMark(u,h,c).addMark(u,h,f).setSelection(new Q(d.selection.$anchor)).scrollIntoView()),!0):!1});I(Mm,{displayName:"Command<updateLinkCommand>",group:"Link"});var Nm=cc("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)}}}));I(Nm,{displayName:"NodeSchema<doc>",group:"Doc"});var Tm=Object.freeze(["root","blockquote","listItem","footnoteDefinition"]),WC=new Set(["paragraph","heading","tableCell","link","linkReference","emphasis","strong","delete","footnote"]),Is=Wt(Tm,"blockContainerTypes");I(Is,{displayName:"Ctx<blockContainerTypes>",group:"Remark"});var af=new Set;function Im(t){const e=t.isInjected(Is.key)?t.get(Is.key):Tm,n=new Set;for(const r of e){if(WC.has(r)){af.has(r)||(af.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 KC=new Set(["paragraph","tableCell"]);function JC(t,e){return gs(t,n=>n.type==="html"&&$C(n.value),(n,r)=>{const i=r[r.length-1];if(i){if(KC.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",ni}}})}var Gs=Fn("remark-preserve-empty-line",t=>()=>e=>JC(e,Im(t)));I(Gs.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"});I(Gs.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var kc=Rt("paragraph");I(kc,{displayName:"Attr<paragraph>",group:"Paragraph"});var Dt=Ce("paragraph",t=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:e=>["p",t.get(kc.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)&&UC(t)?e.addNode("html",void 0,FC):km(e,n),e.closeNode()}}}));function UC(t){return t.isInjected(Gs.options.key)}I(Dt.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"});I(Dt.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var mr=J("TurnIntoText",t=>()=>Ui(Dt.type(t)));I(mr,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var bc=tt("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:t=>{const e=t.get(X);return()=>e.call(mr.key)}}});I(bc.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"});I(bc.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var GC=Array(6).fill(0).map((t,e)=>e+1);function YC(t){return t.textContent.toLowerCase().trim().replace(/\s+/g,"-")}var Ys=Wt(YC,"headingIdGenerator");I(Ys,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var xc=Rt("heading");I(xc,{displayName:"Attr<heading>",group:"Heading"});var Kt=Ce("heading",t=>{const e=t.get(Ys.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:GC.map(n=>({tag:`h${n}`,getAttrs:r=>{if(!(r instanceof HTMLElement))throw Ht(r);return{level:n,id:r.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...t.get(xc.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}),km(n,r),n.closeNode()}}}});I(Kt.node,{displayName:"NodeSchema<heading>",group:"Heading"});I(Kt.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var Am=et(t=>dp(/^(?<hashes>#+)\s$/,Kt.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(_t).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}}));I(Am,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var Bt=J("WrapInHeading",t=>e=>(e??(e=1),e<1?Ui(Dt.type(t)):Ui(Kt.type(t),{level:e})));I(Bt,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var wc=J("DowngradeHeading",t=>()=>(e,n,r)=>{const{$from:i}=e.selection,o=i.node();if(o.type!==Kt.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):Ui(Dt.type(t))(e,n,r)});I(wc,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var Cc=tt("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:t=>{const e=t.get(X);return()=>e.call(Bt.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:t=>{const e=t.get(X);return()=>e.call(Bt.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:t=>{const e=t.get(X);return()=>e.call(Bt.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:t=>{const e=t.get(X);return()=>e.call(Bt.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:t=>{const e=t.get(X);return()=>e.call(Bt.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:t=>{const e=t.get(X);return()=>e.call(Bt.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:t=>{const e=t.get(X);return()=>e.call(wc.key)}}});I(Cc.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"});I(Cc.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var Sc=Rt("blockquote");I(Sc,{displayName:"Attr<blockquote>",group:"Blockquote"});var fi=Ce("blockquote",t=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:e=>["blockquote",t.get(Sc.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()}}}));I(fi.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"});I(fi.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var vm=et(t=>Xa(/^\s*>\s$/,fi.type(t)));I(vm,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var Qs=J("WrapInBlockquote",t=>()=>Qa(fi.type(t)));I(Qs,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var Mc=tt("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:t=>{const e=t.get(X);return()=>e.call(Qs.key)}}});I(Mc.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"});I(Mc.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var Nc=Rt("codeBlock",()=>({pre:{},code:{}}));I(Nc,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var gr=Ce("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 Ht(e);return{language:e.dataset.language}}}],toDOM:e=>{const n=t.get(Nc.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})}}}));I(gr.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"});I(gr.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var Em=et(t=>dp(/^```(?<language>[a-z]*)?[\s\n]$/,gr.type(t),e=>{var n;return{language:((n=e.groups)==null?void 0:n.language)??""}}));I(Em,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var Xs=J("CreateCodeBlock",t=>(e="")=>Ui(gr.type(t),{language:e}));I(Xs,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});var QC=J("UpdateCodeBlockLanguage",()=>({pos:t,language:e}={pos:-1,language:""})=>(n,r)=>t>=0?(r==null||r(n.tr.setNodeAttribute(t,"language",e)),!0):!1);I(QC,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var Tc=tt("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:t=>{const e=t.get(X);return()=>e.call(Xs.key)}}});I(Tc.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"});I(Tc.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var Ic=Rt("image");I(Ic,{displayName:"Attr<image>",group:"Image"});var Ot=Ce("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 Ht(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:e=>["img",{...t.get(Ic.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})}}}));I(Ot.node,{displayName:"NodeSchema<image>",group:"Image"});I(Ot.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var Om=J("InsertImage",t=>(e={})=>(n,r)=>{if(!r)return!0;const{src:i="",alt:o="",title:s=""}=e,l=Ot.type(t).create({src:i,alt:o,title:s});return l&&r(n.tr.replaceSelectionWith(l).scrollIntoView()),!0});I(Om,{displayName:"Command<insertImageCommand>",group:"Image"});var Dm=J("UpdateImage",t=>(e={})=>(n,r)=>{const i=S0(n.selection,Ot.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});I(Dm,{displayName:"Command<updateImageCommand>",group:"Image"});var XC=et(t=>new ht(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(e,n,r,i)=>{const[o,s,l="",a]=n;return o?e.tr.replaceWith(r,i,Ot.type(t).create({src:l,alt:s,title:a})):null}));I(XC,{displayName:"InputRule<insertImageInputRule>",group:"Image"});var As=Rt("hardbreak",t=>({"data-type":"hardbreak","data-is-inline":t.attrs.isInline}));I(As,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var Po=Ce("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(As.key)(e)," "]:["br",t.get(As.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")}}}));I(Po.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"});I(Po.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var Ac=J("InsertHardbreak",t=>()=>(e,n)=>{var o;const{selection:r,tr:i}=e;if(!(r instanceof Q))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(K.near(i.doc.resolve(r.to))).scrollIntoView()),!0}return n==null||n(i.setMeta("hardbreak",!0).replaceSelectionWith(Po.type(t).create(),!1).scrollIntoView()),!0});I(Ac,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var vc=tt("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:t=>{const e=t.get(X);return()=>e.call(Ac.key)}}});I(vc.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"});I(vc.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var Ec=Rt("hr");I(Ec,{displayName:"Attr<hr>",group:"Hr"});var di=Ce("hr",t=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:e=>["hr",t.get(Ec.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")}}}));I(di.node,{displayName:"NodeSchema<hr>",group:"Hr"});I(di.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var Rm=et(t=>new ht(/^(?:---|___\s|\*\*\*\s)$/,(e,n,r,i)=>{const{tr:o}=e;return n[0]&&o.replaceWith(r-1,i,di.type(t).create()),o}));I(Rm,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var zm=J("InsertHr",t=>()=>(e,n)=>{if(!n)return!0;const r=Dt.node.type(t).create(),{tr:i,selection:o}=e,{from:s}=o,l=di.type(t).create();if(!l)return!0;const a=i.replaceSelectionWith(l).insert(s,r),c=K.findFrom(a.doc.resolve(s),1,!0);return c&&n(a.setSelection(c).scrollIntoView()),!0});I(zm,{displayName:"Command<insertHrCommand>",group:"Hr"});var Oc=Rt("bulletList");I(Oc,{displayName:"Attr<bulletList>",group:"BulletList"});var pn=Ce("bullet_list",t=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ht(e);return{spread:e.dataset.spread==="true"}}}],toDOM:e=>["ul",{...t.get(Oc.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()}}}));I(pn.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"});I(pn.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var Pm=et(t=>Xa(/^\s*([-+*])\s$/,pn.type(t)));I(Pm,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var pi=J("WrapInBulletList",t=>()=>Qa(pn.type(t)));I(pi,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var Dc=tt("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:t=>{const e=t.get(X);return()=>e.call(pi.key)}}});I(Dc.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"});I(Dc.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var Rc=Rt("orderedList");I(Rc,{displayName:"Attr<orderedList>",group:"OrderedList"});var mn=Ce("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 Ht(e);return{spread:e.dataset.spread==="true",order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:e=>["ol",{...t.get(Rc.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()}}}));I(mn.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"});I(mn.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var Lm=et(t=>Xa(/^\s*(\d+)\.\s$/,mn.type(t),e=>({order:Number(e[1])}),(e,n)=>n.childCount+n.attrs.order===Number(e[1])));I(Lm,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var Lo=J("WrapInOrderedList",t=>()=>Qa(mn.type(t)));I(Lo,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var zc=tt("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:t=>{const e=t.get(X);return()=>e.call(Lo.key)}}});I(zc.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"});I(zc.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var Pc=Rt("listItem");I(Pc,{displayName:"Attr<listItem>",group:"ListItem"});var Ze=Ce("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 Ht(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread==="true"}}}],toDOM:e=>["li",{...t.get(Pc.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()}}}));I(Ze.node,{displayName:"NodeSchema<listItem>",group:"ListItem"});I(Ze.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var Lc=J("SinkListItem",t=>()=>zC(Ze.type(t)));I(Lc,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var Bc=J("LiftListItem",t=>()=>uc(Ze.type(t)));I(Bc,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var Fc=J("SplitListItem",t=>()=>(e,n,r)=>OC(Ze.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));I(Fc,{displayName:"Command<splitListItemCommand>",group:"ListItem"});function ZC(t){return(e,n,r)=>{const{selection:i}=e;if(!(i instanceof Q))return!1;const{empty:o,$from:s}=i;return!o||s.parentOffset!==0||s.node(-1).type!==Ze.type(t)?!1:lp(e,n,r)}}var _c=J("LiftFirstListItem",t=>()=>ZC(t));I(_c,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var $c=tt("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:t=>{const e=t.get(X);return()=>e.call(Fc.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:t=>{const e=t.get(X);return()=>e.call(Lc.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:t=>{const e=t.get(X);return()=>e.call(Bc.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:t=>{const e=t.get(X);return()=>e.call(_c.key)}}});I($c.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"});I($c.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var Bm=cc("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)}}}));I(Bm,{displayName:"NodeSchema<text>",group:"Text"});var jc=Rt("html");I(jc,{displayName:"Attr<html>",group:"Html"});var ro=Ce("html",t=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:e=>{const n=document.createElement("span"),r={...t.get(jc.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)}}}));I(ro.node,{displayName:"NodeSchema<html>",group:"Html"});I(ro.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var eS=[Nm,kc,Dt,Ys,xc,Kt,As,Po,Sc,fi,Nc,gr,Ec,di,Ic,Ot,Oc,pn,Rc,mn,Pc,Ze,hc,wr,dc,hi,mc,un,yc,$t,jc,ro,Bm].flat(),tS=[vm,Pm,Lm,Em,Rm,Am].flat(),nS=[bm,xm,Cm,wm],rS=J("IsMarkSelected",()=>t=>e=>{if(!t)return!1;const{doc:n,selection:r}=e;return n.rangeHasMark(r.from,r.to,t)}),iS=J("IsNoteSelected",()=>t=>e=>t?M0(e,t).hasNode:!1),oS=J("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)}),sS=J("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}),lS=J("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&&Ka(a,r,i);if(!c)return!1;o=o.wrap(a,c)}catch{return!1}return n==null||n(o),!0}),aS=J("AddBlockType",()=>t=>(e,n)=>{const{nodeType:r,attrs:i=null}=t??{};if(!r)return!1;const o=e.tr;try{const s=r instanceof kt?r:r.createAndFill(i);if(!s)return!1;o.replaceSelectionWith(s)}catch{return!1}return n==null||n(o),!0}),cS=J("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(Q.near(s))}catch{return!1}return n==null||n(o.scrollIntoView()),!0}),uS=[mr,Qs,Bt,wc,Xs,Ac,zm,Om,Dm,Lo,pi,Lc,Fc,Bc,_c,Ks,Us,Js,Sm,Mm,rS,iS,oS,sS,lS,aS,cS],hS=[Mc,Tc,vc,Cc,$c,zc,Dc,bc,fc,gc,pc].flat(),Vc=Fn("remarkAddOrderInList",()=>()=>t=>{kr(t,"list",e=>{if(e.ordered){const n=e.start??1;e.children.forEach((r,i)=>{r.label=i+n})}})});I(Vc.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"});I(Vc.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var Hc=Fn("remarkLineBreak",()=>()=>t=>{const e=new RegExp("(?<![\\t ])[\\t ]*(?:\\r?\\n|\\r)","g");kr(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})});I(Hc.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"});I(Hc.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var qc=Fn("remarkInlineLink",()=>LC);I(qc.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"});I(qc.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var fS=t=>!!t.children,dS=t=>t.type==="html";function pS(t,e){return n(t,0,null)[0];function n(r,i,o){if(fS(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 h=0,d=u.length;h<d;h++){const f=u[h];f&&s.push(f)}}}r.children=s}return e(r,i,o)}}var Wc=Fn("remarkHTMLTransformer",t=>()=>e=>{const n=Im(t);pS(e,(r,i,o)=>dS(r)?(o&&n.has(o.type)&&(r.children=[BC(r)],delete r.value,r.type="paragraph"),[r]):[r])});I(Wc.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"});I(Wc.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var Kc=Fn("remarkMarker",()=>()=>(t,e)=>{const n=r=>e.value.charAt(r.position.start.offset);kr(t,r=>["strong","emphasis"].includes(r.type),r=>{r.marker=n(r)})});I(Kc.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"});I(Kc.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var Fm=Xe(()=>{let t=!1;const e=new De("MILKDOWN_INLINE_NODES_CURSOR"),n=new Oe({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=Ee.widget(i,o,{side:-1}),l=document.createElement("span"),a=Ee.widget(i,l);return setTimeout(()=>{o.contentEditable="true",l.contentEditable="true"}),me.create(r.doc,[s,a])}return me.empty}}});return n});I(Fm,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var _m=Xe(t=>new Oe({key:new De("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(e,n,r)=>{if(!e.length)return;const i=Po.type(t);let o;return e.forEach((s,l)=>{s.steps.forEach((a,c)=>{if(!(a instanceof Ft))return;const u=(f,p)=>e.slice(l).reduce((m,y,g)=>(g===0?y.mapping.slice(c+1):y.mapping).map(m,p),f),h=u(a.from,-1),d=u(a.to,1);r.doc.nodesBetween(h,d,(f,p)=>{f.type!==i||f.attrs.isInline||f.marks.length&&(o??(o=r.tr),o.setNodeMarkup(p,i,f.attrs,[]))})})}),o}}));I(_m,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var Jc=Wt(["table","code_block"],"hardbreakFilterNodes");I(Jc,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var $m=Xe(t=>{const e=t.get(Jc.key);return new Oe({key:new De("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(n,r)=>{const i=n.getMeta("hardbreak"),[o]=n.steps;if(i&&o instanceof ke){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}})});I($m,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var jm=Xe(t=>{const e=new De("MILKDOWN_HEADING_ID"),n=r=>{if(r.composing)return;const i=t.get(Ys.key),o=r.state.tr.setMeta("addToHistory",!1);let s=!1;const l={};r.state.doc.descendants((a,c)=>{if(a.type===Kt.type(t)){if(a.textContent.trim().length===0)return;const u=a.attrs;let h=i(a);l[h]?(l[h]+=1,h+=`-#${l[h]}`):l[h]=1,u.id!==h&&(s=!0,o.setMeta(e,!0).setNodeMarkup(c,void 0,{...u,id:h}))}}),s&&r.dispatch(o)};return new Oe({key:e,view:r=>(n(r),{update:(i,o)=>{i.state.doc.eq(o.doc)||n(i)}})})});I(jm,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var Vm=Xe(t=>{const e=(n,r,i)=>{if(!i.selection||n.some(h=>h.getMeta("addToHistory")===!1||!h.isGeneric))return null;const o=mn.type(t),s=pn.type(t),l=Ze.type(t),a=(h,d,f=1)=>{let p=!1;const m=`${d+f}.`;return h.label!==m&&(h.label=m,p=!0),p};let c=i.tr,u=!1;return i.doc.descendants((h,d,f,p)=>{if(h.type===s){const m=h.maybeChild(0);(m==null?void 0:m.type)===l&&m.attrs.listType==="ordered"&&(u=!0,c.setNodeMarkup(d,o,{spread:!0}),h.descendants((y,g,C,w)=>{if(y.type===l){const v={...y.attrs};a(v,w)&&(c=c.setNodeMarkup(g,void 0,v))}return!1}))}else if(h.type===l&&(f==null?void 0:f.type)===o){const m={...h.attrs};let y=!1;m.listType!=="ordered"&&(m.listType="ordered",y=!0),f!=null&&f.maybeChild(0)&&(y=a(m,p,(f==null?void 0:f.attrs.order)??1)),y&&(c=c.setNodeMarkup(d,void 0,m),u=!0)}}),u?c.setMeta("addToHistory",!1):null};return new Oe({key:new De("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:e})});I(Vm,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var mS=[_m,Jc,$m,Fm,Is,Vc,qc,Hc,Wc,Kc,Gs,jm,Vm].flat(),gS=[eS,tS,nS,uS,hS,mS].flat();let Na,Ta;if(typeof WeakMap<"u"){let t=new WeakMap;Na=e=>t.get(e),Ta=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Na=r=>{for(let i=0;i<t.length;i+=2)if(t[i]==r)return t[i+1]},Ta=(r,i)=>(n==10&&(n=0),t[n++]=r,t[n++]=i)}var ce=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 Na(t)||Ta(t,yS(t))}};function yS(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=kS(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 h=t.child(c);u++;for(let p=0;;p++){for(;i<r.length&&r[i]!=0;)i++;if(p==h.childCount)break;const m=h.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 v=i+w*e;for(let B=0;B<y;B++){r[v+B]==0?r[v+B]=u:(o||(o=[])).push({type:"collision",row:c,pos:u,n:y-B});const S=C&&C[B];if(S){const R=(v+B)%e*2,F=s[R];F==null||F!=S&&s[R+1]==1?(s[R]=S,s[R+1]=1):F==S&&s[R+1]++}}}i+=y,u+=m.nodeSize}const d=(c+1)*e;let f=0;for(;i<d;)r[i++]==0&&f++;f&&(o||(o=[])).push({type:"missing",row:c,n:f}),u++}(e===0||n===0)&&(o||(o=[])).push({type:"zero_sized"});const l=new ce(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&&bS(l,s,t),l}function kS(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 bS(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=xS(a)))[c]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:l})}}function xS(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function cf(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 uf(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 wS(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 CS(t){const e=t.cellAttributes||{},n={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:wS}};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=>cf(r,e)}],toDOM(r){return["td",uf(r,e),0]}},table_header:{content:t.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>cf(r,e)}],toDOM(r){return["th",uf(r,e),0]}}}}function wt(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 Mn=new De("selectingCells");function ai(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 ft(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 Zs(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=ai(e.$head)||SS(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function SS(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 Ia(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function MS(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Uc(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Hm(t,e,n){const r=t.node(-1),i=ce.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 yr(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 NS(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 TS(t,e,n){const r=wt(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 de=class Yt extends K{constructor(e,n=e){const r=e.node(-1),i=ce.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 h=r.nodeAt(u);if(!h)throw new RangeError(`No cell with offset ${u} found`);const d=o+u+1;return new rp(l.resolve(d),l.resolve(d+h.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(Ia(r)&&Ia(i)&&Uc(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Yt.rowSelection(r,i):o&&this.isColSelection()?Yt.colSelection(r,i):new Yt(r,i)}return Q.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=ce.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,h=i.left;h<i.right;h++,u++){const d=n.map[u];if(o[d])continue;o[d]=!0;const f=n.findCell(d);let p=e.nodeAt(d);if(!p)throw new RangeError(`No cell with offset ${d} found`);const m=i.left-f.left,y=f.right-i.right;if(m>0||y>0){let g=p.attrs;if(m>0&&(g=yr(g,0,m)),y>0&&(g=yr(g,g.colspan-y,y)),f.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(f.top<i.top||f.bottom>i.bottom){const g={...p.attrs,rowspan:Math.min(f.bottom,i.bottom)-Math.max(f.top,i.top)};f.top<i.top?p=p.type.createAndFill(g):p=p.type.create(g,p.content)}c.push(p)}s.push(e.child(a).copy(E.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:s;return new L(E.from(l),1,1)}replace(e,n=L.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?L.empty:n)}const o=K.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,n){this.replace(e,new L(E.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=ce.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=ce.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 Yt(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=ce.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 Yt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=ce.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 Yt(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Yt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Yt(e.resolve(n),e.resolve(r))}getBookmark(){return new IS(this.$anchorCell.pos,this.$headCell.pos)}};de.prototype.visible=!1;K.jsonID("cell",de);var IS=class qm{constructor(e,n){this.anchor=e,this.head=n}map(e){return new qm(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&&Uc(n,r)?new de(n,r):K.near(r,1)}};function AS(t){if(!(t.selection instanceof de))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Ee.node(r,r+n.nodeSize,{class:"selectedCell"}))}),me.create(t.doc,e)}function vS({$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 ES({$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 OS(t,e,n){const r=(e||t).selection,i=(e||t).doc;let o,s;if(r instanceof U&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=de.create(i,r.from);else if(s=="row"){const l=i.resolve(r.from+1);o=de.rowSelection(l,l)}else if(!n){const l=ce.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];o=de.create(i,a+1,c)}}else r instanceof Q&&vS(r)?o=Q.create(i,r.from):r instanceof Q&&ES(r)&&(o=Q.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=t.tr)).setSelection(o),e}const DS=new De("fix-tables");function Wm(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)?Wm(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function RS(t,e){let n;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(n=zS(t,i,o,n))};return e?e.doc!=t.doc&&Wm(e.doc,t.doc,0,r):t.doc.descendants(r),n}function zS(t,e,n,r){const i=ce.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 h=u.attrs;for(let d=0;d<h.rowspan;d++)o[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,yr(h,h.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),h=c+u.nodeSize,d=o[a];if(d>0){let f="cell";u.firstChild&&(f=u.firstChild.type.spec.tableRole);const p=[];for(let y=0;y<d;y++){const g=wt(t.schema)[f].createAndFill();g&&p.push(g)}const m=(a==0||s==a-1)&&l==a?c+1:h-1;r.insert(r.mapping.map(m),p)}c=h}return r.setMeta(DS,{fixTables:!0})}function Km(t){const e=ce.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 Jm(t,e){const n=[],r=ce.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 h=e[s][u];if(!h)continue;const d=r.map[s*r.width+u],f=t.nodeAt(d);if(!f)continue;const p=f.type.createChecked(h.attrs,h.content,h.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 Um(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 Bo(t){return PS(e=>e.type.spec.tableRole==="table",t)}function PS(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 Ar(t,e){const n=Bo(e.$from);if(!n)return;const r=ce.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 vr(t,e){const n=Bo(e.$from);if(!n)return;const r=ce.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 hf(t,e,n=e){let r=e,i=n;for(let u=e;u>=0;u--){const h=Ar(u,t.selection);h&&h.forEach(d=>{const f=d.node.attrs.colspan+u-1;f>=r&&(r=u),f>i&&(i=f)})}for(let u=e;u<=i;u++){const h=Ar(u,t.selection);h&&h.forEach(d=>{const f=d.node.attrs.colspan+u-1;d.node.attrs.colspan>1&&f>i&&(i=f)})}const o=[];for(let u=r;u<=i;u++){const h=Ar(u,t.selection);h&&h.length>0&&o.push(u)}r=o[0],i=o[o.length-1];const s=Ar(r,t.selection),l=vr(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 h=Ar(u,t.selection);if(h&&h.length>0){for(let d=l.length-1;d>=0;d--)if(l[d].pos===h[0].pos){c=h[0];break}if(c)break}}if(c)return{$anchor:a,$head:t.doc.resolve(c.pos),indexes:o}}function ff(t,e,n=e){let r=e,i=n;for(let u=e;u>=0;u--){const h=vr(u,t.selection);h&&h.forEach(d=>{const f=d.node.attrs.rowspan+u-1;f>=r&&(r=u),f>i&&(i=f)})}for(let u=e;u<=i;u++){const h=vr(u,t.selection);h&&h.forEach(d=>{const f=d.node.attrs.rowspan+u-1;d.node.attrs.rowspan>1&&f>i&&(i=f)})}const o=[];for(let u=r;u<=i;u++){const h=vr(u,t.selection);h&&h.length>0&&o.push(u)}r=o[0],i=o[o.length-1];const s=vr(r,t.selection),l=Ar(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 h=vr(u,t.selection);if(h&&h.length>0){for(let d=l.length-1;d>=0;d--)if(l[d].pos===h[0].pos){c=h[0];break}if(c)break}}if(c)return{$anchor:a,$head:t.doc.resolve(c.pos),indexes:o}}function df(t){return t[0].map((e,n)=>t.map(r=>r[n]))}function LS(t){var e,n;const{tr:r,originIndex:i,targetIndex:o,select:s,pos:l}=t,a=Bo(r.doc.resolve(l));if(!a)return!1;const c=(e=hf(r,i))===null||e===void 0?void 0:e.indexes,u=(n=hf(r,o))===null||n===void 0?void 0:n.indexes;if(!c||!u||c.includes(o))return!1;const h=BS(a.node,c,u);if(r.replaceWith(a.pos,a.pos+a.node.nodeSize,h),!s)return!0;const d=ce.get(h),f=a.start,p=o,m=d.positionAt(d.height-1,p,h),y=r.doc.resolve(f+m),g=d.positionAt(0,p,h),C=r.doc.resolve(f+g);return r.setSelection(de.colSelection(y,C)),!0}function BS(t,e,n,r){let i=df(Km(t));return i=Um(i,e,n),i=df(i),Jm(t,i)}function FS(t){var e,n;const{tr:r,originIndex:i,targetIndex:o,select:s,pos:l}=t,a=Bo(r.doc.resolve(l));if(!a)return!1;const c=(e=ff(r,i))===null||e===void 0?void 0:e.indexes,u=(n=ff(r,o))===null||n===void 0?void 0:n.indexes;if(!c||!u||c.includes(o))return!1;const h=_S(a.node,c,u);if(r.replaceWith(a.pos,a.pos+a.node.nodeSize,h),!s)return!0;const d=ce.get(h),f=a.start,p=o,m=d.positionAt(p,d.width-1,h),y=r.doc.resolve(f+m),g=d.positionAt(p,0,h),C=r.doc.resolve(f+g);return r.setSelection(de.rowSelection(y,C)),!0}function _S(t,e,n,r){let i=Km(t);return i=Um(i,e,n),Jm(t,i)}function gn(t){const e=t.selection,n=Zs(t),r=n.node(-1),i=n.start(-1),o=ce.get(r);return{...e instanceof de?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(n.pos-i),tableStart:i,map:o,table:r}}function Gm(t,{map:e,tableStart:n,table:r},i){let o=i>0?-1:0;TS(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,NS(c.attrs,i-e.colCount(a))),s+=c.attrs.rowspan-1}else{const a=o==null?wt(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 $S(t,e){if(!ft(t))return!1;if(e){const n=gn(t);e(Gm(t.tr,n,n.left))}return!0}function jS(t,e){if(!ft(t))return!1;if(e){const n=gn(t);e(Gm(t.tr,n,n.right))}return!0}function VS(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,yr(u,i-e.colCount(a)));else{const h=t.mapping.slice(o).map(r+a);t.delete(h,h+c.nodeSize)}s+=u.rowspan}}function Ym(t,e){if(!ft(t))return!1;if(e){const n=gn(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;VS(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=ce.get(o)}e(r)}return!0}function HS(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 h=e.map[u];if(!a.has(h)){if(a.add(h),i>0&&h==e.map[u-e.width]){const d=n.nodeAt(h).attrs;t.setNodeMarkup(t.mapping.slice(l).map(h+r),null,{...d,rowspan:d.rowspan-1}),c+=d.colspan-1}else if(i<e.height&&h==e.map[u+e.width]){const d=n.nodeAt(h),f=d.attrs,p=d.type.create({...f,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+=f.colspan-1}}}}function Qm(t,e){if(!ft(t))return!1;if(e){const n=gn(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;HS(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=ce.get(n.table)}e(r)}return!0}function qS(t,e){return function(n,r){if(!ft(n))return!1;const i=Zs(n);if(i.nodeAfter.attrs[t]===e)return!1;if(r){const o=n.tr;n.selection instanceof de?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 WS(t){return function(e,n){if(!ft(e))return!1;if(n){const r=wt(e.schema),i=gn(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 pf(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 Gc(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?WS(t):function(n,r){if(!ft(n))return!1;if(r){const i=wt(n.schema),o=gn(n),s=n.tr,l=pf("row",o,i),a=pf("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,h=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 f=d+o.tableStart,p=s.doc.nodeAt(f);p&&s.setNodeMarkup(f,h,p.attrs)}),r(s)}return!0}}Gc("row",{useDeprecatedLogic:!0});Gc("column",{useDeprecatedLogic:!0});Gc("cell",{useDeprecatedLogic:!0});function KS(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 Xm(t){return function(e,n){if(!ft(e))return!1;const r=KS(Zs(e),t);if(r==null)return!1;if(n){const i=e.doc.resolve(r);n(e.tr.setSelection(Q.between(i,MS(i))).scrollIntoView())}return!0}}function Zm(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 Uo(t,e){const n=t.selection;if(!(n instanceof de))return!1;if(e){const r=t.tr,i=wt(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 L(i,0,0))}),r.docChanged&&e(r)}return!0}function JS(t){return(e,n)=>{const{from:r,to:i,select:o=!0,pos:s=e.selection.from}=t,l=e.tr;return FS({tr:l,originIndex:r,targetIndex:i,select:o,pos:s})?(n==null||n(l),!0):!1}}function US(t){return(e,n)=>{const{from:r,to:i,select:o=!0,pos:s=e.selection.from}=t,l=e.tr;return LS({tr:l,originIndex:r,targetIndex:i,select:o,pos:s})?(n==null||n(l),!0):!1}}function GS(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),h=a<e.childCount-1?0:Math.max(0,r-1);(u||h)&&(c=Aa(wt(s).row,new L(c,u,h)).content),l.push(c)}else if(o=="cell"||o=="header_cell")l.push(n||r?Aa(wt(s).row,new L(e,n,r)).content:e);else return null;return YS(s,l)}function YS(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(E.empty),n[i]<r){const o=wt(t).cell.createAndFill(),s=[];for(let l=n[i];l<r;l++)s.push(o);e[i]=e[i].append(E.from(s))}return{height:e.length,width:r,rows:e}}function Aa(t,e){const n=t.createAndFill();return new np(n).replace(0,n.content.size,e).doc}function QS({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,h=0;u<r;h++){let d=a.child(h%a.childCount);u+d.attrs.colspan>r&&(d=d.type.createChecked(yr(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let f=1;f<d.attrs.rowspan;f++)o[l+f]=(o[l+f]||0)+d.attrs.colspan}s.push(E.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 h=c.child(u);s+h.attrs.rowspan>i&&(h=h.type.create({...h.attrs,rowspan:Math.max(1,i-h.attrs.rowspan)},h.content)),a.push(h)}o.push(E.from(a))}n=o,e=i}return{width:t,height:e,rows:n}}function XS(t,e,n,r,i,o,s){const l=t.doc.type.schema,a=wt(l);let c,u;if(i>e.width)for(let h=0,d=0;h<e.height;h++){const f=n.child(h);d+=f.nodeSize;const p=[];let m;f.lastChild==null||f.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 h=[];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;h.push(y?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const d=a.row.create(null,E.from(h)),f=[];for(let p=e.height;p<o;p++)f.push(d);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),f)}return!!(c||u)}function mf(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,h=e.map[u];if(e.map[u-e.width]==h){a=!0;const d=n.nodeAt(h),{top:f,left:p}=e.findCell(h);t.setNodeMarkup(t.mapping.slice(l).map(h+r),null,{...d.attrs,rowspan:s-f}),t.insert(t.mapping.slice(l).map(e.positionAt(s,p,n)),d.type.createAndFill({...d.attrs,rowspan:f+d.attrs.rowspan-s})),c+=d.attrs.colspan-1}}return a}function gf(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,h=e.map[u];if(e.map[u-1]==h){a=!0;const d=n.nodeAt(h),f=e.colCount(h),p=t.mapping.slice(l).map(h+r);t.setNodeMarkup(p,null,yr(d.attrs,s-f,d.attrs.colspan-(s-f))),t.insert(p+d.nodeSize,d.type.createAndFill(yr(d.attrs,0,s-f))),c+=d.attrs.rowspan-1}}return a}function yf(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=ce.get(o);const{top:l,left:a}=r,c=a+i.width,u=l+i.height,h=t.tr;let d=0;function f(){if(o=n?h.doc.nodeAt(n-1):h.doc,!o)throw new Error("No table found");s=ce.get(o),d=h.mapping.maps.length}XS(h,s,o,n,c,u,d)&&f(),mf(h,s,o,n,a,c,l,d)&&f(),mf(h,s,o,n,a,c,u,d)&&f(),gf(h,s,o,n,l,u,a,d)&&f(),gf(h,s,o,n,l,u,c,d)&&f();for(let p=l;p<u;p++){const m=s.positionAt(p,a,o),y=s.positionAt(p,c,o);h.replace(h.mapping.slice(d).map(m+n),h.mapping.slice(d).map(y+n),new L(i.rows[p-l],0,0))}f(),h.setSelection(new de(h.doc.resolve(n+s.positionAt(l,a,o)),h.doc.resolve(n+s.positionAt(u-1,c-1,o)))),e(h)}const ZS=kp({ArrowLeft:Go("horiz",-1),ArrowRight:Go("horiz",1),ArrowUp:Go("vert",-1),ArrowDown:Go("vert",1),"Shift-ArrowLeft":Yo("horiz",-1),"Shift-ArrowRight":Yo("horiz",1),"Shift-ArrowUp":Yo("vert",-1),"Shift-ArrowDown":Yo("vert",1),Backspace:Uo,"Mod-Backspace":Uo,Delete:Uo,"Mod-Delete":Uo});function us(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Go(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;if(o instanceof de)return us(n,r,K.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;const s=eg(i,t,e);if(s==null)return!1;if(t=="horiz")return us(n,r,K.near(n.doc.resolve(o.head+e),e));{const l=n.doc.resolve(s),a=Hm(l,t,e);let c;return a?c=K.near(a,1):e<0?c=K.near(n.doc.resolve(l.before(-1)),-1):c=K.near(n.doc.resolve(l.after(-1)),1),us(n,r,c)}}}function Yo(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let s;if(o instanceof de)s=o;else{const a=eg(i,t,e);if(a==null)return!1;s=new de(n.doc.resolve(a))}const l=Hm(s.$headCell,t,e);return l?us(n,r,new de(s.$anchorCell,l)):!1}}function eM(t,e){const n=t.state.doc,r=ai(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new de(r))),!0):!1}function tM(t,e,n){if(!ft(t.state))return!1;let r=GS(n);const i=t.state.selection;if(i instanceof de){r||(r={width:1,height:1,rows:[E.from(Aa(wt(t.state.schema).cell,n))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),l=ce.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=QS(r,l.right-l.left,l.bottom-l.top),yf(t.state,t.dispatch,s,l,r),!0}else if(r){const o=Zs(t.state),s=o.start(-1);return yf(t.state,t.dispatch,s,ce.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function nM(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=kf(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof de)o(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=ai(t.state.selection.$anchor))!=null&&((n=Bl(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=Bl(t,c);const h=Mn.getState(t.state)==null;if(!u||!Uc(a,u))if(h)u=a;else return;const d=new de(a,u);if(h||!t.state.selection.eq(d)){const f=t.state.tr.setSelection(d);h&&f.setMeta(Mn,a.pos),t.dispatch(f)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),Mn.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Mn,-1))}function l(a){const c=a,u=Mn.getState(t.state);let h;if(u!=null)h=t.state.doc.resolve(u);else if(kf(t,c.target)!=r&&(h=Bl(t,e),!h))return s();h&&o(h,c)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function eg(t,e,n){if(!(t.state.selection instanceof Q))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 kf(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Bl(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&&ai(t.state.doc.resolve(r))||ai(t.state.doc.resolve(i))}var rM=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")),va(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,va(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function va(t,e,n,r,i,o){let s=0,l=!0,a=e.firstChild;const c=t.firstChild;if(c){for(let h=0,d=0;h<c.childCount;h++){const{colspan:f,colwidth:p}=c.child(h).attrs;for(let m=0;m<f;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 h=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=h}l?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const st=new De("tableColumnResizing");function iM({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=rM,lastColumnResizable:i=!0}={}){const o=new Oe({key:st,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=wt(l.schema).table.name;return r&&c&&(c[u]=(h,d)=>new r(h,n,d)),new oM(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{const l=st.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{sM(s,l,t,i)},mouseleave:s=>{lM(s)},mousedown:(s,l)=>{aM(s,l,e,n)}},decorations:s=>{const l=st.getState(s);if(l&&l.activeHandle>-1)return dM(s,l.activeHandle)},nodeViews:{}}});return o}var oM=class hs{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(st);if(r&&r.setHandle!=null)return new hs(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new hs(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return Ia(e.doc.resolve(i))||(i=-1),new hs(i,n.dragging)}return n}};function sM(t,e,n,r){if(!t.editable)return;const i=st.getState(t.state);if(i&&!i.dragging){const o=uM(e.target);let s=-1;if(o){const{left:l,right:a}=o.getBoundingClientRect();e.clientX-l<=n?s=bf(t,e,"left",n):a-e.clientX<=n&&(s=bf(t,e,"right",n))}if(s!=i.activeHandle){if(!r&&s!==-1){const l=t.state.doc.resolve(s),a=l.node(-1),c=ce.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}tg(t,s)}}}function lM(t){if(!t.editable)return;const e=st.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&tg(t,-1)}function aM(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=st.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const l=t.state.doc.nodeAt(s.activeHandle),a=cM(t,s.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(st,{setDragging:{startX:e.clientX,startWidth:a}}));function c(h){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",u);const d=st.getState(t.state);d!=null&&d.dragging&&(hM(t,d.activeHandle,xf(d.dragging,h,n)),t.dispatch(t.state.tr.setMeta(st,{setDragging:null})))}function u(h){if(!h.which)return c(h);const d=st.getState(t.state);if(d&&d.dragging){const f=xf(d.dragging,h,n);wf(t,d.activeHandle,f,r)}}return wf(t,s.activeHandle,a,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",u),e.preventDefault(),!0}function cM(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 uM(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function bf(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=ai(t.state.doc.resolve(s));if(!l)return-1;if(n=="right")return l.pos;const a=ce.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 xf(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function tg(t,e){t.dispatch(t.state.tr.setMeta(st,{setHandle:e}))}function hM(t,e,n){const r=t.state.doc.resolve(e),i=r.node(-1),o=ce.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 h=o.map[u],d=i.nodeAt(h).attrs,f=d.colspan==1?0:l-o.colCount(h);if(d.colwidth&&d.colwidth[f]==n)continue;const p=d.colwidth?d.colwidth.slice():fM(d.colspan);p[f]=n,a.setNodeMarkup(s+h,null,{...d,colwidth:p})}a.docChanged&&t.dispatch(a)}function wf(t,e,n,r){const i=t.state.doc.resolve(e),o=i.node(-1),s=i.start(-1),l=ce.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&&va(o,a.firstChild,a,r,l,n)}function fM(t){return Array(t).fill(0)}function dM(t,e){const n=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return me.empty;const o=ce.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 h=o.map[u],d=s+h+i.nodeAt(h).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",!((a=st.getState(t))===null||a===void 0)&&a.dragging&&n.push(Ee.node(s+h,s+h+i.nodeAt(h).nodeSize,{class:"column-resize-dragging"})),n.push(Ee.widget(d,f))}}return me.create(t.doc,n)}function pM({allowTableNodeSelection:t=!1}={}){return new Oe({key:Mn,state:{init(){return null},apply(e,n){const r=e.getMeta(Mn);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:AS,handleDOMEvents:{mousedown:nM},createSelectionBetween(e){return Mn.getState(e.state)!=null?e.state.selection:null},handleTripleClick:eM,handleKeyDown:ZS,handlePaste:tM},appendTransaction(e,n,r){return OS(r,RS(r,n),t)}})}var vs=typeof navigator<"u"?navigator:null,Yc=vs&&vs.userAgent||"",mM=/Edge\/(\d+)/.exec(Yc),gM=/MSIE \d/.exec(Yc),yM=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Yc),kM=!!(gM||yM||mM),bM=!kM&&!!vs&&/Apple Computer/.test(vs.vendor),ng=new De("safari-ime-span"),Ea=!1,xM={key:ng,props:{decorations:wM,handleDOMEvents:{compositionstart:()=>{Ea=!0},compositionend:()=>{Ea=!1}}}};function wM(t){const{$from:e,$to:n,to:r}=t.selection;if(Ea&&e.sameParent(n)){const i=Ee.widget(r,CM,{ignoreSelection:!0,key:"safari-ime-span"});return me.create(t.doc,[i])}}function CM(t){const e=t.dom.ownerDocument.createElement("span");return e.className="ProseMirror-safari-ime-span",e}var SM=new Oe(bM?xM:{key:ng});function Cf(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 MM(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function NM(t,e,n){const i=Ps((n||{}).ignore||[]),o=TM(e);let s=-1;for(;++s<o.length;)gs(t,l);function l(c,u,h){if(c.type==="text"&&typeof h=="number")return a(c,u,h);if(i(c,h,u[u.length-1]))return ni}function a(c,u,h){const d=u[u.length-1],f=o[s][0],p=o[s][1];let m=0,y=!1,g=[];f.lastIndex=0;let C=f.exec(c.value);for(;C;){const v=C.index,B={index:C.index,input:C.input,stack:[...u,c]};let S=p(...C,B);if(typeof S=="string"&&(S=S.length>0?{type:"text",value:S}:void 0),S===!1)f.lastIndex=v+1;else{if(m!==v&&w({type:"text",value:c.value.slice(m,v)}),Array.isArray(S))for(const R of S)w(R);else S&&w(S);m=v+C[0].length,y=!0}if(!f.global)break;C=f.exec(c.value)}return y?(m<c.value.length&&w({type:"text",value:c.value.slice(m)}),d.children.splice(h,1,...g)):g=[c],h+g.length;function w(v){const B=g[g.length-1];B&&B.type==="text"&&v.type==="text"?B.value+=v.value:g.push(v)}}}function TM(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([IM(i[0]),AM(i[1])])}return e}function IM(t){return typeof t=="string"?new RegExp(MM(t),"g"):t}function AM(t){return typeof t=="function"?t:function(){return t}}const Fl="phrasing",_l=["autolink","link","image","label"];function vM(){return{transforms:[LM],enter:{literalAutolink:OM,literalAutolinkEmail:$l,literalAutolinkHttp:$l,literalAutolinkWww:$l},exit:{literalAutolink:PM,literalAutolinkEmail:zM,literalAutolinkHttp:DM,literalAutolinkWww:RM}}}function EM(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Fl,notInConstruct:_l},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Fl,notInConstruct:_l},{character:":",before:"[ps]",after:"\\/",inConstruct:Fl,notInConstruct:_l}]}}function OM(t){this.enter({type:"link",title:null,url:"",children:[],position:void 0},t)}function $l(t){this.config.enter.autolinkProtocol.call(this,t)}function DM(t){this.config.exit.autolinkProtocol.call(this,t)}function RM(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 zM(t){this.config.exit.autolinkEmail.call(this,t)}function PM(t){this.exit(t)}function LM(t){NM(t,[[new RegExp("(?<![\\da-z])(https?:\\/\\/|www(?=\\.))([\\w-]*\\.[\\w\\-.]*)([^\\t\\n\\r ]*)","gi"),BM],[new RegExp("(?<![\\w+\\-.@])xmpp:([\\w+\\-.]+)@([\\w-]+(?:\\.[\\w-]+)+)(\\/(?:[\\w\\-/]|\\.(?=[\\dA-Za-z]))*)?","g"),$M],[new RegExp("(?<![\\w+\\-.@])mailto:([\\w+\\-.]+)@([\\w-]+(?:\\.[\\w-]+)+)","g"),_M],[new RegExp("(?<![\\w+\\-.]|(?:^|[^\\d@A-Za-z])(?:mailto|xmpp):)([\\w+\\-.]+)@([\\w-]+(?:\\.[\\w-]+)+)","g"),FM]],{ignore:["link","linkReference"]})}function BM(t,e,n,r,i){if(!HM(i))return!1;let o="";if(/^w/i.test(e)&&(n=e+n,e="",o="http://"),Mo(n.charCodeAt(0))||!jM(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 FM(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 _M(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 $M(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 jM(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=Cf(t,"(");let o=Cf(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 HM(t){const e=t.input.charCodeAt(t.index-1);return t.index===0||lr(e)||Mo(e)}rg.peek=XM;function qM(){this.buffer()}function WM(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function KM(){this.buffer()}function JM(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function UM(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=vt(this.sliceSerialize(t)).toLowerCase(),n.label=e}function GM(t){this.exit(t)}function YM(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=vt(this.sliceSerialize(t)).toLowerCase(),n.label=e}function QM(t){this.exit(t)}function XM(){return"["}function rg(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 ZM(){return{enter:{gfmFootnoteCallString:qM,gfmFootnoteCall:WM,gfmFootnoteDefinitionLabelString:KM,gfmFootnoteDefinition:JM},exit:{gfmFootnoteCallString:UM,gfmFootnoteCall:GM,gfmFootnoteDefinitionLabelString:YM,gfmFootnoteDefinition:QM}}}function eN(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:n,footnoteReference:rg},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?ig:tN))),c(),a}}function tN(t,e,n){return e===0?t:ig(t,e,n)}function ig(t,e,n){return(n?"":" ")+t}const nN=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Qc.attention=lN;Qc.peek=aN;function rN(){return{canContainEols:["delete"],enter:{strikethrough:oN},exit:{strikethrough:sN}}}function iN(){return{handlers:{delete:Qc},unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:nN}]}}function oN(t){this.enter({type:"delete",children:[],position:void 0},t)}function sN(t){this.exit(t)}function Qc(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 lN(){return{construct:"strikethrough",markers:["~"],sizes:[2,1]}}function aN(){return"~"}function cN(t){return t.length}function uN(t,e){const n=e||{},r=(n.align||[]).concat(),i=n.stringLength||cN,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=hN(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 h=-1;if(typeof r=="object"&&"length"in r)for(;++h<c;)o[h]=Sf(r[h]);else{const m=Sf(r);for(;++h<c;)o[h]=m}h=-1;const d=[],f=[];for(;++h<c;){const m=o[h];let y="",g="";m===99?(y=":",g=":"):m===108?y=":":m===114&&(g=":");let C=n.alignDelimiters===!1?1:Math.max(1,a[h]-y.length-g.length);const w=y+"-".repeat(C)+g;n.alignDelimiters!==!1&&(C=y.length+C+g.length,C>a[h]&&(a[h]=C),f[h]=C),d[h]=w}s.splice(1,0,d),l.splice(1,0,f),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;h=-1;const C=[];for(;++h<g;){const w=m[h]||"";let v="",B="";if(n.alignDelimiters!==!1){const S=a[h]-(y[h]||0),R=o[h];if(R===114)v=" ".repeat(S);else if(R===99){const F=S/2;S%2?(v=" ".repeat(F+.5),B=" ".repeat(F-.5)):(v=" ".repeat(F),B=v)}else B=" ".repeat(S)}n.delimiterStart!==!1&&!h&&C.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&w==="")&&(n.delimiterStart!==!1||h)&&C.push(" "),n.alignDelimiters!==!1&&C.push(v),C.push(w),n.alignDelimiters!==!1&&C.push(B),n.padding!==!1&&C.push(" "),(n.delimiterEnd!==!1||h!==g-1)&&C.push("|")}p.push(n.delimiterEnd===!1?C.join("").replace(/ +$/,""):C.join(""))}return p.join(`
52
+ `)}function hN(t){return t==null?"":String(t)}function Sf(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 fN(){return{enter:{table:dN,tableData:Mf,tableHeader:Mf,tableRow:mN},exit:{codeText:gN,table:pN,tableData:jl,tableHeader:jl,tableRow:jl}}}function dN(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 pN(t){this.exit(t),this.data.inTable=void 0}function mN(t){this.enter({type:"tableRow",children:[],position:void 0},t)}function jl(t){this.exit(t)}function Mf(t){this.enter({type:"tableCell",children:[],position:void 0},t)}function gN(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,yN));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function yN(t,e){return e==="|"?e:t}function kN(t){const e=t||{},{tableCellPadding:n,tablePipeAlign:r,stringLength:i}=e,o=n?" ":"|";return{handlers:{inlineCode:d,table:s,tableCell:a,tableRow:l},join:[bN],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(f,p,m,y){const g=u(f,m,y),C=g[0];if(C){let w=f.align?f.align.length:0,v=-1;if(!w)for(;++v<g.length;)g[v].length>w&&(w=g[v].length);for(;C.length<w;)C.push("")}return c(g,f.align)}function l(f,p,m,y){const g=h(f,m,y),C=c([g]);return C.slice(0,C.indexOf(`
54
+ `))}function a(f,p,m,y){const g=m.enter("tableCell"),C=m.enter("phrasing"),w=m.containerPhrasing(f,{...y,before:o,after:o});return C(),g(),w}function c(f,p){return uN(f,{align:p,alignDelimiters:r,fillRows:!1,padding:n,stringLength:i})}function u(f,p,m){const{children:y}=f;let g=-1;const C=[],w=p.enter("table");for(;++g<y.length;)C[g]=h(y[g],p,m);return w(),C}function h(f,p,m){const{children:y}=f;let g=-1;const C=[],w=p.enter("tableRow");for(;++g<y.length;)C[g]=a(y[g],f,p,m);return w(),C}function d(f,p,m){const y=ys.inlineCode(f,p,m);if(!m.stack.includes("tableCell"))return y;const g=[];let C=0,w=y.indexOf("|");for(;w!==-1;){let v=w;for(;v>C&&y.charCodeAt(v-1)===92;)v--;g.push(y.slice(C,w)),(w-v)%2===0&&g.push("\\"),C=w,w=y.indexOf("|",w+1)}return g.push(y.slice(C)),g.join("")}}function bN(t,e,n,r){if(t.type==="table"&&n.type==="listItem"&&n.spread===!1&&(e.type==="definition"||e.type==="heading"&&xN(e,r)||e.type==="paragraph"||e.type==="table"))return 1}function xN(t,e){let n=!1;return kr(t,function(r){if(r.type==="break"||"value"in r&&/\r?\n|\r/.test(r.value))return n=!0,Ei}),!!((!t.depth||t.depth<3)&&Rs(t)&&(e.options.setext||n))}function wN(){return{exit:{taskListCheckValueChecked:Nf,taskListCheckValueUnchecked:Nf,paragraph:SN}}}function CN(){return{handlers:{paragraph:MN},join:[NN]}}function Nf(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function SN(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 MN(t,e,n,r){if(!e||e.type!=="listItem"||og(e)!==t)return ys.paragraph(t,e,n,r);const i="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);o.move(i);const s=ys.paragraph(t.children.length>0?t:{type:"paragraph",children:[{type:"text",value:" "}]},e,n,{...r,...o.current()});return i+s}function NN(t,e,n){if(!(t.type==="definition"&&n.type==="listItem"))return;const r=og(n);if(r&&n.children.indexOf(t)<n.children.indexOf(r))return 0}function og(t){if(typeof t.checked=="boolean")for(const e of t.children){if(e.type==="paragraph")return e;if(e.type!=="definition")return}}function TN(){return[vM(),ZM(),rN(),fN(),wN()]}function IN(t){return{extensions:[EM(),eN(t),iN(),kN(t),CN()]}}const AN={tokenize:zN,partial:!0},sg={tokenize:PN,partial:!0},lg={tokenize:LN,partial:!0},ag={tokenize:BN,partial:!0},vN={tokenize:FN,partial:!0},cg={name:"wwwAutolink",tokenize:DN,previous:hg},ug={name:"protocolAutolink",tokenize:RN,previous:fg},yn={name:"emailAutolink",tokenize:ON,previous:dg},Jt={};function EN(){return{text:Jt}}let $n=48;for(;$n<123;)Jt[$n]=yn,$n++,$n===58?$n=65:$n===91&&($n=97);Jt[43]=yn;Jt[45]=yn;Jt[46]=yn;Jt[95]=yn;Jt[72]=[yn,ug];Jt[104]=[yn,ug];Jt[87]=[yn,cg];Jt[119]=[yn,cg];function ON(t,e,n){const r=this;let i,o;return s;function s(h){return!Oa(h)||!dg.call(r,r.previous)||Xc(r.events)?n(h):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),l(h))}function l(h){return Oa(h)?(t.consume(h),l):h===64?(t.consume(h),a):n(h)}function a(h){return h===46?t.check(vN,u,c)(h):h===45||h===95||$e(h)?(o=!0,t.consume(h),a):u(h)}function c(h){return t.consume(h),i=!0,a}function u(h){return o&&i&&Ae(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(h)):n(h)}}function DN(t,e,n){const r=this;return i;function i(s){return s!==87&&s!==119||!hg.call(r,r.previous)||Xc(r.events)?n(s):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(AN,t.attempt(sg,t.attempt(lg,o),n),n)(s))}function o(s){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(s)}}function RN(t,e,n){const r=this;let i="",o=!1;return s;function s(h){return(h===72||h===104)&&fg.call(r,r.previous)&&!Xc(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(h),t.consume(h),l):n(h)}function l(h){if(Ae(h)&&i.length<5)return i+=String.fromCodePoint(h),t.consume(h),l;if(h===58){const d=i.toLowerCase();if(d==="http"||d==="https")return t.consume(h),a}return n(h)}function a(h){return h===47?(t.consume(h),o?c:(o=!0,a)):n(h)}function c(h){return h===null||ds(h)||ue(h)||lr(h)||Mo(h)?n(h):t.attempt(sg,t.attempt(lg,u),n)(h)}function u(h){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(h)}}function zN(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 PN(t,e,n){let r,i,o;return s;function s(c){return c===46||c===95?t.check(ag,a,l)(c):c===null||ue(c)||lr(c)||c!==45&&Mo(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 LN(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(ag,e,o)(s):s===null||ue(s)||lr(s)?e(s):(t.consume(s),i)}function o(s){return s===41&&r++,t.consume(s),i}}function BN(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||ue(l)||lr(l)?e(l):n(l)}function i(l){return l===null||l===40||l===91||ue(l)||lr(l)?e(l):r(l)}function o(l){return Ae(l)?s(l):n(l)}function s(l){return l===59?(t.consume(l),r):Ae(l)?(t.consume(l),s):n(l)}}function FN(t,e,n){return r;function r(o){return t.consume(o),i}function i(o){return $e(o)?n(o):e(o)}}function hg(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||ue(t)}function fg(t){return!Ae(t)}function dg(t){return!(t===47||Oa(t))}function Oa(t){return t===43||t===45||t===46||t===95||$e(t)}function Xc(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 _N={tokenize:JN,partial:!0};function $N(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:qN,continuation:{tokenize:WN},exit:KN}},text:{91:{name:"gfmFootnoteCall",tokenize:HN},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:jN,resolveTo:VN}}}}function jN(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=vt(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 HN(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,s;return l;function l(h){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),a}function a(h){return h!==94?n(h):(t.enter("gfmFootnoteCallMarker"),t.consume(h),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(h){if(o>999||h===93&&!s||h===null||h===91||ue(h))return n(h);if(h===93){t.exit("chunkString");const d=t.exit("gfmFootnoteCallString");return i.includes(vt(r.sliceSerialize(d)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(h)}return ue(h)||(s=!0),o++,t.consume(h),h===92?u:c}function u(h){return h===91||h===92||h===93?(t.consume(h),o++,c):c(h)}}function qN(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||ue(p))return n(p);if(p===93){t.exit("chunkString");const m=t.exit("gfmFootnoteDefinitionLabelString");return o=vt(r.sliceSerialize(m)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(p),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),d}return ue(p)||(l=!0),s++,t.consume(p),p===92?h:u}function h(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),le(t,f,"gfmFootnoteDefinitionWhitespace")):n(p)}function f(p){return e(p)}}function WN(t,e,n){return t.check(No,e,t.attempt(_N,e,n))}function KN(t){t.exit("gfmFootnoteDefinition")}function JN(t,e,n){const r=this;return le(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 UN(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)},h={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",h,l]],f=l.parser.constructs.insideSpan.null;f&&At(d,d.length,0,zs(f,s.slice(c+1,a),l)),At(d,d.length,0,[["exit",h,l],["enter",s[a][1],l],["exit",s[a][1],l],["exit",u,l]]),At(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 h=0;return d;function d(p){return c===126&&u[u.length-1][1].type!=="characterEscape"?a(p):(s.enter("strikethroughSequenceTemporary"),f(p))}function f(p){const m=jt(c);if(p===126)return h>1?a(p):(s.consume(p),h++,f);if(h<2&&!n)return a(p);const y=s.exit("strikethroughSequenceTemporary"),g=jt(p);return y._open=!g||g===2&&!!m,y._close=!m||m===2&&!!g,l(p)}}}class GN{constructor(){this.map=[],this.index=new Map}add(e,n,r){YN(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 YN(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 QN(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 XN(){return{flow:{null:{name:"table",tokenize:ZN,resolveAll:eT}}}}function ZN(t,e,n){const r=this;let i=0,o=0,s;return l;function l(M){let P=r.events.length-1;for(;P>-1;){const{type:he}=r.events[P][1];if(he==="lineEnding"||he==="linePrefix")P--;else break}const j=P>-1?r.events[P][1].type:null,ae=j==="tableHead"||j==="tableRow"?S:a;return ae===S&&r.parser.lazy[r.now().line]?n(M):ae(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):q(M)?o>1?(o=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(M),t.exit("lineEnding"),f):n(M):te(M)?le(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"),h(M)))}function h(M){return M===null||M===124||ue(M)?(t.exit("data"),u(M)):(t.consume(M),M===92?d:h)}function d(M){return M===92||M===124?(t.consume(M),h):h(M)}function f(M){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(M):(t.enter("tableDelimiterRow"),s=!1,te(M)?le(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):B(M)}function m(M){return te(M)?le(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||q(M)?v(M):B(M)}function g(M){return M===45?(t.enter("tableDelimiterFiller"),C(M)):B(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 te(M)?le(t,v,"whitespace")(M):v(M)}function v(M){return M===124?p(M):M===null||q(M)?!s||i!==o?B(M):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(M)):B(M)}function B(M){return n(M)}function S(M){return t.enter("tableRow"),R(M)}function R(M){return M===124?(t.enter("tableCellDivider"),t.consume(M),t.exit("tableCellDivider"),R):M===null||q(M)?(t.exit("tableRow"),e(M)):te(M)?le(t,R,"whitespace")(M):(t.enter("data"),F(M))}function F(M){return M===null||M===124||ue(M)?(t.exit("data"),R(M)):(t.consume(M),M===92?ee:F)}function ee(M){return M===92||M===124?(t.consume(M),F):F(M)}}function eT(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,h;const d=new GN;for(;++n<t.length;){const f=t[n],p=f[1];f[0]==="enter"?p.type==="tableHead"?(l=!1,a!==0&&(Tf(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,h=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],h=Qo(d,e,o,i,void 0,h),o=[0,0,0,0]),s[2]=n)):p.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(s[0]=s[1],h=Qo(d,e,o,i,void 0,h)),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],h=Qo(d,e,o,i,n,h)):s[1]!==0&&(h=Qo(d,e,s,i,n,h)),i=0):i&&(p.type==="data"||p.type==="tableDelimiterMarker"||p.type==="tableDelimiterFiller")&&(s[3]=n)}for(a!==0&&Tf(d,e,a,c,u),d.consume(e.events),n=-1;++n<e.events.length;){const f=e.events[n];f[0]==="enter"&&f[1].type==="table"&&(f[1]._align=QN(e.events,n))}return t}function Qo(t,e,n,r,i,o){const s=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(o.end=Object.assign({},Er(e.events,n[0])),t.add(n[0],0,[["exit",o,e]]));const a=Er(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=Er(e.events,n[2]),u=Er(e.events,n[3]),h={type:l,start:Object.assign({},c),end:Object.assign({},u)};if(t.add(n[2],0,[["enter",h,e]]),r!==2){const d=e.events[n[2]],f=e.events[n[3]];if(d[1].end=Object.assign({},f[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",h,e]])}return i!==void 0&&(o.end=Object.assign({},Er(e.events,i)),t.add(i,0,[["exit",o,e]]),o=void 0),o}function Tf(t,e,n,r,i){const o=[],s=Er(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 Er(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const tT={name:"tasklistCheck",tokenize:rT};function nT(){return{text:{91:tT}}}function rT(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 ue(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 q(a)?e(a):te(a)?t.check({tokenize:iT},e,n)(a):n(a)}}function iT(t,e,n){return le(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function oT(t){return Hf([EN(),$N(),UN(t),XN(),nT()])}const sT={};function lT(t){const e=this,n=t||sT,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),s=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(oT(n)),o.push(TN()),s.push(IN(n))}function W(t,e){return Object.assign(t,{meta:{package:"@milkdown/preset-gfm",...e}}),t}var Zc=zo("strike_through");W(Zc,{displayName:"Attr<strikethrough>",group:"Strikethrough"});var mi=xr("strike_through",t=>({parseDOM:[{tag:"del"},{style:"text-decoration",getAttrs:e=>e==="line-through"}],toDOM:e=>["del",t.get(Zc.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")}}}));W(mi.mark,{displayName:"MarkSchema<strikethrough>",group:"Strikethrough"});W(mi.ctx,{displayName:"MarkSchemaCtx<strikethrough>",group:"Strikethrough"});var Fo=J("ToggleStrikeThrough",t=>()=>Ao(mi.type(t)));W(Fo,{displayName:"Command<ToggleStrikethrough>",group:"Strikethrough"});var pg=et(t=>vo(new RegExp("(?<![\\w:/])(~{1,2})(.+?)\\1(?!\\w|\\/)$"),mi.type(t)));W(pg,{displayName:"InputRule<strikethrough>",group:"Strikethrough"});var eu=tt("strikeThroughKeymap",{ToggleStrikethrough:{shortcuts:"Mod-Alt-x",command:t=>{const e=t.get(X);return()=>e.call(Fo.key)}}});W(eu.ctx,{displayName:"KeymapCtx<strikethrough>",group:"Strikethrough"});W(eu.shortcuts,{displayName:"Keymap<strikethrough>",group:"Strikethrough"});function mg(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 _o=CS({tableGroup:"block",cellContent:"paragraph",cellAttributes:{alignment:{default:"left",getFromDOM:t=>t.style.textAlign||"left",setDOMAttr:(t,e)=>{e.style=`text-align: ${t||"left"}`}}}}),xt=Ce("table",()=>({..._o.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()}}}));W(xt.node,{displayName:"NodeSchema<table>",group:"Table"});W(xt.ctx,{displayName:"NodeSchemaCtx<table>",group:"Table"});var $o=Ce("table_header_row",()=>({..._o.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())}}}));W($o.node,{displayName:"NodeSchema<tableHeaderRow>",group:"Table"});W($o.ctx,{displayName:"NodeSchemaCtx<tableHeaderRow>",group:"Table"});var gi=Ce("table_row",()=>({..._o.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())}}}));W(gi.node,{displayName:"NodeSchema<tableRow>",group:"Table"});W(gi.ctx,{displayName:"NodeSchemaCtx<tableRow>",group:"Table"});var jo=Ce("table_cell",()=>({..._o.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"),mg(t,e),t.closeNode()}}}));W(jo.node,{displayName:"NodeSchema<tableCell>",group:"Table"});W(jo.ctx,{displayName:"NodeSchemaCtx<tableCell>",group:"Table"});var ci=Ce("table_header",()=>({..._o.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"),mg(t,e),t.closeNode()}}}));W(ci.node,{displayName:"NodeSchema<tableHeader>",group:"Table"});W(ci.ctx,{displayName:"NodeSchemaCtx<tableHeader>",group:"Table"});function gg(t,e=3,n=3){const r=Array(n).fill(0).map(()=>jo.type(t).createAndFill()),i=Array(n).fill(0).map(()=>ci.type(t).createAndFill()),o=Array(e).fill(0).map((s,l)=>l===0?$o.type(t).create(null,i):gi.type(t).create(null,r));return xt.type(t).create(null,o)}function yg(t){return(e,n)=>r=>{n=n??r.selection.from;const i=r.doc.resolve(n),o=C0(a=>a.type.name==="table")(i),s=o?{node:o.node,from:o.start}:void 0,l=t==="row";if(s){const a=ce.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),h=l?de.rowSelection:de.colSelection,d=a.positionAt(l?e:0,l?0:e,s.node),f=r.doc.resolve(s.from+d);return gp(r.setSelection(h(u,f)))}}return r}}var aT=yg("row"),cT=yg("col");function kg(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 jo.type(t).createAndFill({alignment:u==null?void 0:u.attrs.alignment})});return e.insert(s,gi.type(t).create(null,l)),e}function uT(t){const e=Bo(t.$from);if(!e)return;const n=ce.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 hT(t){const e=uT(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 gp(t.setSelection(new de(i,n)))}}return t}var tu=J("GoToPrevTableCell",()=>()=>Xm(-1));W(tu,{displayName:"Command<goToPrevTableCellCommand>",group:"Table"});var nu=J("GoToNextTableCell",()=>()=>Xm(1));W(nu,{displayName:"Command<goToNextTableCellCommand>",group:"Table"});var ru=J("ExitTable",t=>()=>(e,n)=>{if(!ft(e))return!1;const{$head:r}=e.selection,i=x0(r,xt.type(t));if(!i)return!1;const{to:o}=i,s=e.tr.replaceWith(o,o,Dt.type(t).createAndFill());return s.setSelection(K.near(s.doc.resolve(o),1)).scrollIntoView(),n==null||n(s),!0});W(ru,{displayName:"Command<breakTableCommand>",group:"Table"});var iu=J("InsertTable",t=>({row:e,col:n}={})=>(r,i)=>{const{selection:o,tr:s}=r,{from:l}=o,a=gg(t,e,n),c=s.replaceSelectionWith(a),u=K.findFrom(c.doc.resolve(l),1,!0);return u&&c.setSelection(u),i==null||i(c),!0});W(iu,{displayName:"Command<insertTableCommand>",group:"Table"});var bg=J("MoveRow",()=>({from:t,to:e,pos:n}={})=>JS({from:t??0,to:e??0,pos:n}));W(bg,{displayName:"Command<moveRowCommand>",group:"Table"});var xg=J("MoveCol",()=>({from:t,to:e,pos:n}={})=>US({from:t??0,to:e??0,pos:n}));W(xg,{displayName:"Command<moveColCommand>",group:"Table"});var wg=J("SelectRow",()=>(t={index:0})=>(e,n)=>{const{tr:r}=e;return!!(n==null?void 0:n(aT(t.index,t.pos)(r)))});W(wg,{displayName:"Command<selectRowCommand>",group:"Table"});var Cg=J("SelectCol",()=>(t={index:0})=>(e,n)=>{const{tr:r}=e;return!!(n==null?void 0:n(cT(t.index,t.pos)(r)))});W(Cg,{displayName:"Command<selectColCommand>",group:"Table"});var Sg=J("SelectTable",()=>()=>(t,e)=>{const{tr:n}=t;return!!(e==null?void 0:e(hT(n)))});W(Sg,{displayName:"Command<selectTableCommand>",group:"Table"});var Mg=J("DeleteSelectedCells",()=>()=>(t,e)=>{const{selection:n}=t;if(!(n instanceof de))return!1;const r=n.isRowSelection(),i=n.isColSelection();return r&&i?Zm(t,e):i?Ym(t,e):Qm(t,e)});W(Mg,{displayName:"Command<deleteSelectedCellsCommand>",group:"Table"});var ou=J("AddColBefore",()=>()=>$S);W(ou,{displayName:"Command<addColBeforeCommand>",group:"Table"});var su=J("AddColAfter",()=>()=>jS);W(su,{displayName:"Command<addColAfterCommand>",group:"Table"});var lu=J("AddRowBefore",t=>()=>(e,n)=>{if(!ft(e))return!1;if(n){const r=gn(e);n(kg(t,e.tr,r,r.top))}return!0});W(lu,{displayName:"Command<addRowBeforeCommand>",group:"Table"});var au=J("AddRowAfter",t=>()=>(e,n)=>{if(!ft(e))return!1;if(n){const r=gn(e);n(kg(t,e.tr,r,r.bottom))}return!0});W(au,{displayName:"Command<addRowAfterCommand>",group:"Table"});var Ng=J("SetAlign",()=>(t="left")=>qS("alignment",t));W(Ng,{displayName:"Command<setAlignCommand>",group:"Table"});var Tg=et(t=>new ht(/^\|(?<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),xt.type(t)))return null;const s=gg(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(Q.create(l.doc,r+3)).scrollIntoView()}));W(Tg,{displayName:"InputRule<insertTableInputRule>",group:"Table"});var Ig=AC(t=>({run:(e,n,r)=>{if(r)return e;function i(c){var y;const u=c.childCount,h=((y=c.lastChild)==null?void 0:y.childCount)??0;if(u===0||h===0)return Dt.type(t).create();const d=c.firstChild;if(!(h>0&&d&&d.childCount===0))return c;if(u>=3){const g=c.child(1),C=[];for(let B=0;B<g.childCount;B++){const S=g.child(B);C.push(ci.type(t).create(S.attrs,S.content,S.marks))}const w=d.type.create(d.attrs,C),v=[];for(let B=2;B<u;B++)v.push(c.child(B));return c.type.create(c.attrs,[w,...v])}const f=Array(h).fill(0).map(()=>ci.type(t).createAndFill()),p=new L(E.from(f),0,0),m=d.replace(0,0,p);return c.replace(0,d.nodeSize,new L(E.from(m),0,0))}function o(c){const u=gi.type(t),h=[];let d=[],f=!1;function p(){if(d.length===0)return;const m=$o.type(t).createAndFill(),y=xt.type(t).create(null,[m,...d]);h.push(i(y)),d=[]}return c.forEach(m=>{m.type===u?(f=!0,d.push(m)):(p(),h.push(m))}),p(),f?E.from(h):c}function s(c){let u=o(c),h=u!==c;const d=[];return u.forEach(f=>{if(f.type===xt.type(t)){const p=i(f);p!==f&&(h=!0),d.push(p)}else if(f.childCount>0){const p=s(f.content);p!==f.content?(h=!0,d.push(f.copy(p))):d.push(f)}else d.push(f)}),h?E.from(d):c}function l(c){const u=[],h=[];c.forEach(d=>h.push(d));for(let d=0;d<h.length;d++){const f=h[d],p=h[d+1];f.type===Dt.type(t)&&f.content.size===0&&p&&p.type===xt.type(t)||u.push(f)}return u.length<h.length?E.from(u):c}let a=s(e.content);return a=l(a),new L(E.from(a),e.openStart,e.openEnd)}}));W(Ig,{displayName:"PasteRule<table>",group:"Table"});var cu=tt("tableKeymap",{NextCell:{priority:100,shortcuts:["Mod-]","Tab"],command:t=>{const e=t.get(X);return()=>e.call(nu.key)}},PrevCell:{shortcuts:["Mod-[","Shift-Tab"],command:t=>{const e=t.get(X);return()=>e.call(tu.key)}},ExitTable:{shortcuts:["Mod-Enter","Enter"],command:t=>{const e=t.get(X);return()=>e.call(ru.key)}}});W(cu.ctx,{displayName:"KeymapCtx<table>",group:"Table"});W(cu.shortcuts,{displayName:"Keymap<table>",group:"Table"});var Vl="footnote_definition",If="footnoteDefinition",uu=Ce("footnote_definition",()=>({group:"block",content:"block+",defining:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`dl[data-type="${Vl}"]`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw Ht(t);return{label:t.dataset.label}},contentElement:"dd"}],toDOM:t=>{const e=t.attrs.label;return["dl",{"data-label":e,"data-type":Vl},["dt",e],["dd",0]]},parseMarkdown:{match:({type:t})=>t===If,runner:(t,e,n)=>{t.openNode(n,{label:e.label}).next(e.children).closeNode()}},toMarkdown:{match:t=>t.type.name===Vl,runner:(t,e)=>{t.openNode(If,void 0,{label:e.attrs.label,identifier:e.attrs.label}).next(e.content).closeNode()}}}));W(uu.ctx,{displayName:"NodeSchemaCtx<footnodeDef>",group:"footnote"});W(uu.node,{displayName:"NodeSchema<footnodeDef>",group:"footnote"});var Hl="footnote_reference",hu=Ce("footnote_reference",()=>({group:"inline",inline:!0,atom:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`sup[data-type="${Hl}"]`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw Ht(t);return{label:t.dataset.label}}}],toDOM:t=>{const e=t.attrs.label;return["sup",{"data-label":e,"data-type":Hl},e]},parseMarkdown:{match:({type:t})=>t==="footnoteReference",runner:(t,e,n)=>{t.addNode(n,{label:e.label})}},toMarkdown:{match:t=>t.type.name===Hl,runner:(t,e)=>{t.addNode("footnoteReference",void 0,void 0,{label:e.attrs.label,identifier:e.attrs.label})}}}));W(hu.ctx,{displayName:"NodeSchemaCtx<footnodeRef>",group:"footnote"});W(hu.node,{displayName:"NodeSchema<footnodeRef>",group:"footnote"});var fu=Ze.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 Ht(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()}}}});W(fu.node,{displayName:"NodeSchema<taskListItem>",group:"ListItem"});W(fu.ctx,{displayName:"NodeSchemaCtx<taskListItem>",group:"ListItem"});var Ag=et(()=>new ht(/^\[(?<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}));W(Ag,{displayName:"InputRule<wrapInTaskListInputRule>",group:"ListItem"});var fT=[eu,cu].flat(),dT=[Tg,Ag],pT=[pg],mT=[Ig],vg=Xe(()=>SM);W(vg,{displayName:"Prose<autoInsertSpanPlugin>",group:"Prose"});var gT=Xe(()=>iM({}));W(gT,{displayName:"Prose<columnResizingPlugin>",group:"Prose"});var Eg=Xe(()=>pM({allowTableNodeSelection:!0}));W(Eg,{displayName:"Prose<tableEditingPlugin>",group:"Prose"});var du=Fn("remarkGFM",()=>lT);W(du.plugin,{displayName:"Remark<remarkGFMPlugin>",group:"Remark"});W(du.options,{displayName:"RemarkConfig<remarkGFMPlugin>",group:"Remark"});var yT=new De("MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN");function kT(t,e){let n=0;return e.forEach((r,i,o)=>{r===t&&(n=o)}),n}function bT(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 Og=Xe(()=>new Oe({key:yT,appendTransaction:(t,e,n)=>{if(e.doc===n.doc)return;const r=bT(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 h=kT(s,c),d=u.maybeChild(h);if(!d)return;const f=d.attrs.alignment;f!==s.attrs.alignment&&(i||(i=n.tr),i.setNodeMarkup(l,void 0,{...s.attrs,alignment:f}))};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}}));W(Og,{displayName:"Prose<keepTableAlignPlugin>",group:"Prose"});var xT=[Og,vg,du,Eg].flat(),wT=[fu,xt,$o,gi,ci,jo,uu,hu,Zc,mi].flat(),CT=[nu,tu,ru,iu,bg,xg,wg,Cg,Sg,Mg,lu,au,ou,su,Ng,Fo],ST=[wT,dT,mT,pT,fT,CT,xT].flat(),Es=200,Me=function(){};Me.prototype.append=function(e){return e.length?(e=Me.from(e),!this.length&&e||e.length<Es&&this.leafAppend(e)||this.length<Es&&e.leafPrepend(this)||this.appendInner(e)):this};Me.prototype.prepend=function(e){return e.length?Me.from(e).append(this):this};Me.prototype.appendInner=function(e){return new MT(this,e)};Me.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Me.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Me.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Me.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)};Me.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};Me.from=function(e){return e instanceof Me?e:e&&e.length?new Dg(e):Me.empty};var Dg=(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<=Es)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Es)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})(Me);Me.empty=new Dg([]);var MT=(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})(Me);const NT=500;class It{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((h,d)=>{if(!h.step){i||(i=this.remapping(r,d+1),o=i.maps.length),o--,u.push(h);return}if(i){u.push(new Lt(h.map));let f=h.step.map(i.slice(o)),p;f&&s.maybeStep(f).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new Lt(p,void 0,void 0,c.length+u.length))),o--,p&&i.appendMap(p,o)}else s.maybeStep(h.step);if(h.selection)return l=i?h.selection.map(i.slice(o)):h.selection,a=new It(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 h=e.steps[u].invert(e.docs[u]),d=new Lt(e.mapping.maps[u],h,n),f;(f=a&&a.merge(d))&&(d=f,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>IT&&(l=TT(l,c),s-=c),new It(l.append(o),s)}remapping(e,n){let r=new Ki;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 It(this.items.append(e.map(n=>new Lt(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 f=o.getMirror(--a);if(f==null)return;s=Math.min(s,f);let p=o.maps[f];if(d.step){let m=e.steps[f].invert(e.docs[f]),y=d.selection&&d.selection.map(o.slice(a+1,f));y&&l++,r.push(new Lt(p,m,y))}else r.push(new Lt(p))},i);let c=[];for(let d=n;d<s;d++)c.push(new Lt(o.maps[d]));let u=this.items.slice(0,i).append(c).append(r),h=new It(u,l);return h.emptyItemCount()>NT&&(h=h.compress(this.items.length-r.length)),h}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 h=new Lt(c.invert(),a,u),d,f=i.length-1;(d=i.length&&i[f].merge(h))?i[f]=d:i.push(h)}}else s.map&&r--},this.items.length,0),new It(Me.from(i.reverse()),o)}}It.empty=new It(Me.empty,0);function TT(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Lt{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 Lt(n.getMap().invert(),n,this.selection)}}}class wn{constructor(e,n,r,i,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const IT=20;function AT(t,e,n,r){let i=n.getMeta(rr),o;if(i)return i.historyState;n.getMeta(OT)&&(t=new wn(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(rr))return s.getMeta(rr).redo?new wn(t.done.addTransform(n,void 0,r,fs(e)),t.undone,Af(n.mapping.maps),t.prevTime,t.prevComposition):new wn(t.done,t.undone.addTransform(n,void 0,r,fs(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||!vT(n,t.prevRanges)),c=s?ql(t.prevRanges,n.mapping):Af(n.mapping.maps);return new wn(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,fs(e)),It.empty,c,n.time,l??t.prevComposition)}else return(o=n.getMeta("rebased"))?new wn(t.done.rebased(n,o),t.undone.rebased(n,o),ql(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new wn(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),ql(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function vT(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 Af(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 ql(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 ET(t,e,n){let r=fs(e),i=rr.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 wn(n?l:o.remaining,n?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(rr,{redo:n,historyState:a})}let Wl=!1,vf=null;function fs(t){let e=t.plugins;if(vf!=e){Wl=!1,vf=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Wl=!0;break}}return Wl}const rr=new De("history"),OT=new De("closeHistory");function DT(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Oe({key:rr,state:{init(){return new wn(It.empty,It.empty,null,0,-1)},apply(e,n,r){return AT(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?zg:r=="historyRedo"?Pg:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Rg(t,e){return(n,r)=>{let i=rr.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let o=ET(i,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const zg=Rg(!1,!0),Pg=Rg(!0,!0);function yi(t,e){return Object.assign(t,{meta:{package:"@milkdown/plugin-history",...e}}),t}var pu=J("Undo",()=>()=>zg);yi(pu,{displayName:"Command<undo>"});var mu=J("Redo",()=>()=>Pg);yi(mu,{displayName:"Command<redo>"});var gu=Wt({},"historyProviderConfig");yi(gu,{displayName:"Ctx<historyProviderConfig>"});var Lg=Xe(t=>DT(t.get(gu.key)));yi(Lg,{displayName:"Ctx<historyProviderPlugin>"});var yu=tt("historyKeymap",{Undo:{shortcuts:"Mod-z",command:t=>{const e=t.get(X);return()=>e.call(pu.key)}},Redo:{shortcuts:["Mod-y","Shift-Mod-z"],command:t=>{const e=t.get(X);return()=>e.call(mu.key)}}});yi(yu.ctx,{displayName:"KeymapCtx<history>"});yi(yu.shortcuts,{displayName:"Keymap<history>"});var RT=[gu,Lg,yu,pu,mu].flat();function Da(t){if(!t)return!1;if(Array.isArray(t))return t.length>1?!1:Da(t[0]);const e=t.content;return e?Da(e):t.type==="text"}function zT(t,e){return Object.assign(t,{meta:{package:"@milkdown/plugin-clipboard",...e}}),t}function Ef(t,e){const n=k0(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 Bg=Xe(t=>{const e=t.get(fn);t.update(Vi,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 De("MILKDOWN_CLIPBOARD");return new Oe({key:n,props:{handlePaste:(r,i,o)=>{var p,m,y;const s=t.get($i),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=w0("code_block",e);return C.replaceSelectionWith(w.create({language:g})).setSelection(Q.near(C.doc.resolve(Math.max(0,C.selection.from-2)))).insertText(c.replace(/\r\n?/g,`
55
+ `)),r.dispatch(C),!0}}const h=a.getData("text/html");if(h.length===0&&c.length===0)return!1;if(h.length>0&&o)return Ef(r,o);const d=ur.fromSchema(e);let f;if(h.length===0){const g=s(c);if(!g||typeof g=="string")return!1;f=br.fromSchema(e).serializeFragment(g.content)}else{const g=document.createElement("template");g.innerHTML=h,f=g.content.cloneNode(!0),g.remove()}return Ef(r,d.parseSlice(f))},clipboardTextSerializer:r=>{const i=t.get(ji);if(Da(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):""}}})});zT(Bg,{displayName:"Prose<clipboard>"});const PT=new Set(["paragraph","heading","emphasis","strong","delete","link","tableCell"]);function Fg(t){const e=t.children;if(!e)return;for(const r of e)Fg(r);if(!PT.has(t.type))return;const n=[];for(let r=0;r<e.length;r+=1){const i=e[r];if(i.type==="html"&&/^<u>$/i.test(i.value??"")){let o=-1;for(let s=r+1;s<e.length;s+=1){const l=e[s];if(l.type==="html"&&/^<u>$/i.test(l.value??""))break;if(l.type==="html"&&/^<\/u>$/i.test(l.value??"")){o=s;break}}if(o>r+1){n.push({type:"underline",children:e.slice(r+1,o)}),r=o;continue}}n.push(i)}t.children=n}const LT=Fn("ccvUnderline",()=>()=>t=>Fg(t)),ku=xr("underline",()=>({parseDOM:[{tag:"u"},{style:"text-decoration",getAttrs:t=>String(t).includes("underline")?null:!1}],toDOM:()=>["u",0],parseMarkdown:{match:t=>t.type==="underline",runner:(t,e,n)=>{t.openMark(n),t.next(e.children),t.closeMark(n)}},toMarkdown:{match:t=>t.type.name==="underline",runner:(t,e)=>{t.withMark(e,"underline")}}})),Ra=J("ToggleUnderline",t=>()=>Ao(ku.type(t)));function BT(t,e,n,r){return`<u>${n.containerPhrasing(t,{...r,before:">",after:"<"})}</u>`}const FT={underline:!1,strike:!1,task:!1,table:!1,tableAlign:"",codeLang:"",strong:!1,em:!1,code:!1,link:!1,heading:0,bullet:!1,ordered:!1,quote:!1,codeBlock:!1};function Of(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 _T(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 $T(t,e){const{state:n}=t,{$from:r,from:i,to:o,empty:s}=n.selection,l=f=>s?!!(n.storedMarks??r.marks()).some(p=>p.type===f):n.doc.rangeHasMark(i,o,f),a=new Set;for(let f=r.depth;f>0;f-=1)a.add(r.node(f).type.name);const c=r.parent.type===Kt.type(e)?Number(r.parent.attrs.level):0;let u=!1,h="";for(let f=r.depth;f>0;f-=1){const p=r.node(f);!u&&p.type===Ze.type(e)&&p.attrs.checked!=null&&(u=!0),!h&&"alignment"in p.attrs&&(h=String(p.attrs.alignment||"left"))}const d=r.parent.type===gr.type(e);return{underline:l(ku.type(e)),strike:l(mi.type(e)),task:u,table:a.has(xt.type(e).name),tableAlign:h,codeLang:d?String(r.parent.attrs.language??""):"",strong:l(hi.type(e)),em:l(wr.type(e)),code:l(un.type(e)),link:l($t.type(e)),heading:c,bullet:a.has(pn.type(e).name),ordered:a.has(mn.type(e).name),quote:a.has(fi.type(e).name),codeBlock:r.parent.type===gr.type(e)}}function Df(t,e){const n=document.createElement("span");n.className="md-img",n.contentEditable="false";const r=document.createElement("img");r.draggable=!1,n.append(r);const i=document.createElement("span");i.className="md-img__grip",i.title="Потяните, чтобы изменить ширину",i.setAttribute("aria-label","Изменить ширину картинки"),n.append(i),Xg(i,n,()=>r,e);let o="",s;const l=()=>{const a=Zg(t.path,o);let c="ok",u="";if(a.kind==="outside")c="blocked",u=`Путь вне проекта: ${o}`;else if(a.kind==="project"){const d=t.images[a.path];if(!d)c="loading",u=`Загружается: ${a.path}`,t.requestImage(a.path);else if("error"in d)c="missing",u=`Нет файла: ${a.path}`;else{const f=ey(d);r.getAttribute("src")!==f&&r.setAttribute("src",f)}}else r.getAttribute("src")!==o&&r.setAttribute("src",o);n.dataset.state=c,r.hidden=c!=="ok",r.style.width=s?`${s}px`:"";let h=n.querySelector(".md-img__ph");c==="ok"?h==null||h.remove():(h||(h=document.createElement("span"),h.className="md-img__ph",n.prepend(h)),h.textContent=u)};return t.imageViews.add(l),{dom:n,set(a,c,u){o=a,s=u,r.alt=c,l()},dispose:()=>t.imageViews.delete(l)}}function jT(t){const e=i=>{var o,s;return((s=(o=i.target).closest)==null?void 0:s.call(o,".md-img__grip"))!=null},n=sf(Ot.node,i=>(o,s,l)=>{let a=o;const c=Df(t,u=>{const h=l();if(h===void 0)return;const d=Iu({raw:"",kind:"md",src:String(a.attrs.src),alt:String(a.attrs.alt)},u),f=ro.type(i).create({value:d});s.dispatch(s.state.tr.replaceWith(h,h+a.nodeSize,f))});return c.set(String(o.attrs.src),String(o.attrs.alt)),{dom:c.dom,stopEvent:e,selectNode:()=>c.dom.classList.add("is-selected"),deselectNode:()=>c.dom.classList.remove("is-selected"),update:u=>u.type!==o.type?!1:(a=u,c.set(String(u.attrs.src),String(u.attrs.alt)),!0),destroy:c.dispose}}),r=sf(ro.node,()=>(i,o,s)=>{const l=h=>{const d=/^\s*<img\b/i.test(h)?Yg(h)[0]:void 0;if(d){const p=Df(t,m=>{const y=s();y!==void 0&&o.dispatch(o.state.tr.setNodeMarkup(y,void 0,{value:Iu(d,m)}))});return p.set(d.src,d.alt,d.width),p.dom.title=h,{dom:p.dom,dispose:p.dispose}}const f=document.createElement("span");return f.className="mdtext-html",f.contentEditable="false",f.textContent=h.length>80?`${h.slice(0,77)}…`:h,f.title=`HTML сохранится как есть:
58
+ ${h}`,{dom:f,dispose:()=>{}}};let a=String(i.attrs.value),c=l(a);const u=document.createElement("span");return u.className="mdtext-htmlwrap",u.append(c.dom),{dom:u,selectNode:()=>u.classList.add("is-selected"),deselectNode:()=>u.classList.remove("is-selected"),update:h=>{if(h.type!==i.type)return!1;const d=String(h.attrs.value);return d!==a&&(a=d,c.dispose(),c=l(d),u.replaceChildren(c.dom)),!0},stopEvent:e,ignoreMutation:()=>!0,destroy:()=>c.dispose()}});return[n,r]}function _g(t,e){const n=()=>{const{$from:i}=e.state.selection;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===Ze.type(t))return{pos:i.before(o),node:i.node(o)};return null};let r=n();r||(t.get(X).call(pi.key),r=n()),r&&e.dispatch(e.state.tr.setNodeMarkup(r.pos,void 0,{...r.node.attrs,checked:r.node.attrs.checked==null?!1:null}))}function $g(t,e){const{state:n}=e,{$from:r}=n.selection,i=n.tr,o=di.type(t).create(),s=Dt.type(t);let l;r.depth===1&&r.parent.type===s&&r.parent.content.size===0?(i.replaceWith(r.before(),r.after(),o),l=r.before()+o.nodeSize):(i.insert(r.after(1),o),l=r.after(1)+o.nodeSize),l>=i.doc.content.size&&i.insert(l,s.create()),i.setSelection(K.near(i.doc.resolve(l),1)),e.dispatch(i.scrollIntoView())}function jg(t){const{from:e,to:n,empty:r}=t.state.selection;t.dispatch(r?t.state.tr.setStoredMarks([]):t.state.tr.removeMark(e,n))}function VT(t,e){if(!ft(t.state))return;const n=gn(t.state),r=t.state.tr;for(let i=0;i<n.map.height;i+=1){const o=n.tableStart+n.map.map[i*n.map.width+n.left],s=r.doc.nodeAt(o);s&&r.setNodeMarkup(o,void 0,{...s.attrs,alignment:e})}t.dispatch(r)}function HT(t,e,n){const r=new De("ccv-text-edited"),i=Xe(l=>{let a;return new Oe({key:r,state:{init:()=>!1,apply:(c,u)=>u||c.docChanged&&c.getMeta("addToHistory")!==!1},view:()=>({update(c,u){n($T(c,l)),r.getState(c.state)&&!u.doc.eq(c.state.doc)&&(clearTimeout(a),a=setTimeout(()=>e.flush(),160))},destroy(){clearTimeout(a)}})})}),o=Xe(l=>{const a=h=>()=>(e.call(h),!0),c=h=>a((d,f)=>{const p=f.state.selection.$from.parent,m=p.type===Kt.type(d)&&p.attrs.level===h;d.get(X).call(m?mr.key:Bt.key,h)}),u=(h,d)=>a((f,p)=>{const{$from:m}=p.state.selection;for(let y=m.depth;y>0;y-=1)if(m.node(y).type===h(f)){uc(Ze.type(f))(p.state,p.dispatch);return}f.get(X).call(d)});return yp({"Mod-1":c(1),"Mod-2":c(2),"Mod-3":c(3),"Mod-4":c(4),"Mod-5":c(5),"Mod-6":c(6),"Mod-0":a(h=>h.get(X).call(mr.key)),"Mod-u":a(h=>h.get(X).call(Ra.key)),"Mod-Shift-x":a(h=>h.get(X).call(Fo.key)),"Mod-Shift-9":a((h,d)=>_g(h,d)),"Mod-Shift--":a((h,d)=>$g(h,d)),"Mod-\\":a((h,d)=>jg(d)),"Mod-Shift-8":u(h=>pn.type(h),pi.key),"Mod-Shift-7":u(h=>mn.type(h),Lo.key),"Mod-k":()=>(e.openLink(),!0),"Mod-s":()=>(e.flush(!0),!0)})}),s=Xe(l=>{const a=(c,u,h)=>{let d=c.state.tr;u!==null&&(d=d.setSelection(K.near(d.doc.resolve(u)))),c.dispatch(d.replaceSelectionWith(h,!1).scrollIntoView()),c.focus()};return new Oe({props:{handleDOMEvents:{dragover(c,u){return Tu(u.dataTransfer)?(u.preventDefault(),u.dataTransfer&&(u.dataTransfer.dropEffect="copy"),!0):!1}},handleDrop(c,u){var g;if(!Tu(u.dataTransfer))return!1;const h=Qg(u.dataTransfer);if(!h)return!1;u.preventDefault();const d=/^(!)?\[([^\]]*)\]\((.*)\)$/.exec(_f(t.path,h.path,h.kind));if(!d)return!0;const f=((g=c.posAtCoords({left:u.clientX,top:u.clientY}))==null?void 0:g.pos)??null,[,p,m="",y=""]=d;if(p)a(c,f,Ot.type(l).create({src:y,alt:"",title:""}));else{const C=$t.type(l).create({href:y});a(c,f,c.state.schema.text(m,[C]))}return!0},handlePaste(c,u){var d,f;const h=Array.from(((d=u.clipboardData)==null?void 0:d.files)??[]).filter(p=>p.type.startsWith("image/"));if(h.length===0)return!1;u.preventDefault();for(const p of h){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((v,B)=>{v.type===Ot.type(l)&&v.attrs.src===g&&(C=C.delete(C.mapping.map(B),C.mapping.map(B+v.nodeSize)))}),C.docChanged&&c.dispatch(C)}),y=m?(f=/\(([^)]*)\)/.exec(m))==null?void 0:f[1]:void 0;y&&a(c,null,Ot.type(l).create({src:y,alt:"",title:""}))}return!0},handleClickOn(c,u,h,d,f){return h.type!==Ze.type(l)||h.attrs.checked==null||f.target.tagName!=="LI"||f.offsetX>26?!1:(c.dispatch(c.state.tr.setNodeMarkup(d,void 0,{...h.attrs,checked:!h.attrs.checked})),!0)}}})});return[LT,ku,Ra,i,o,s,...jT(t)].flat()}function XT({path:t,doc:e,onChange:n,onSave:r,images:i,onRequestImage:o,onPasteImage:s}){const l=Ne.useRef(null),a=Ne.useRef(null),[c,u]=Ne.useState(FT),[h,d]=Ne.useState(!1),[f,p]=Ne.useState(null),m=Ne.useRef(null),[y,g]=Ne.useState(null),[C,w]=Ne.useState({rows:0,cols:0}),[v,B]=Ne.useState({mode:"project",value:""});Ne.useEffect(()=>{if(!y)return;const A=_=>{_.target.closest(".mdtext__anchor")||g(null)},O=_=>{var H;_.key==="Escape"&&(_.stopPropagation(),g(null),(H=a.current)==null||H.action(G=>G.get(_t).focus()))};return document.addEventListener("mousedown",A),document.addEventListener("keydown",O,!0),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",O,!0)}},[y]);const S=Ne.useRef({path:t,doc:e,onChange:n,onSave:r});S.current={path:t,doc:e,onChange:n,onSave:r};const R=Ne.useRef({path:t,images:i,requestImage:o,pasteImage:s,imageViews:new Set});R.current.path=t,R.current.images=i,R.current.requestImage=o,R.current.pasteImage=s,Ne.useEffect(()=>{for(const A of R.current.imageViews)A()},[i]);const F=Ne.useCallback(A=>{var O;(O=a.current)==null||O.action(_=>A(_,_.get(_t)))},[]),ee=Ne.useCallback((A,O=!0)=>{const _=a.current;if(!_)return;let H=null;_.action(ze=>{const dt=ze.get(_t);H=WT(ze.get(ji)(dt.state.doc))});const{path:G,doc:re,onChange:pe,onSave:We}=S.current;H!==null&&(H!==re&&(O?Ug.flushSync(()=>pe(G,H)):pe(G,H)),A===!0&&We(G))},[]),M=Ne.useCallback(()=>{F((A,O)=>{const _=$t.type(A),{$from:H}=O.state.selection,G=Of(H,_);p({href:(G==null?void 0:G.href)??"",had:!!G})}),requestAnimationFrame(()=>{var A;return(A=m.current)==null?void 0:A.select()})},[F]);Ne.useEffect(()=>{const A=l.current;if(!A)return;let O=!1;const _={call:F,flush:re=>ee(re===!0),openLink:M},H=IC.make().config(re=>{re.set(cs,A),re.set(ss,S.current.doc);const pe=S.current.doc,We=/^\s*\* /m.test(pe)&&!/^\s*- /m.test(pe);re.update(zr,ze=>({...ze,bullet:We?"*":"-",rule:/^\*{3,}\s*$/m.test(pe)?"*":"-",emphasis:/(^|[^_\w])_[^_\s][^_]*_([^_\w]|$)/.test(pe)&&!/\*[^*\s][^*]*\*/.test(pe)?"_":"*",fences:!0,handlers:{...ze.handlers,underline:BT},listItemIndent:"one"})),re.update(Vi,ze=>({...ze,attributes:{class:"markdown-preview mdtext__doc",spellcheck:"true",role:"textbox","aria-multiline":"true","aria-label":"Текст документа"}}))}).use(gS).use(ST).use(RT).use(Bg).use(HT(R.current,_,u));a.current=H,H.create().then(()=>{O||d(!0)});const G=R.current.imageViews;return()=>{O=!0;try{ee(!1,!1)}catch{}a.current=null,G.clear(),H.destroy()}},[F,ee,M]);const P=A=>()=>{F((O,_)=>{A(O,_),_.focus()})},j=(A,O)=>P(_=>{_.get(X).call(A,O)}),ae=A=>P((O,_)=>{const H=_.state.selection.$from.parent,G=H.type===Kt.type(O)&&H.attrs.level===A;O.get(X).call(G?mr.key:Bt.key,A)}),he=A=>P((O,_)=>{const H=A?mn.type(O):pn.type(O),{$from:G}=_.state.selection;for(let re=G.depth;re>0;re-=1)if(G.node(re).type===H){uc(Ze.type(O))(_.state,_.dispatch);return}O.get(X).call(A?Lo.key:pi.key)}),ne=A=>{const O=_T(A);F((_,H)=>{const G=$t.type(_),{state:re}=H,{from:pe,to:We,empty:ze,$from:dt}=re.selection;let Se=re.tr;const Mt=Of(dt,G);O?ze&&Mt?Se=Se.removeMark(Mt.from,Mt.to,G).addMark(Mt.from,Mt.to,G.create({href:O})):ze?Se=Se.replaceSelectionWith(re.schema.text(O,[G.create({href:O})]),!1):Se=Se.removeMark(pe,We,G).addMark(pe,We,G.create({href:O})):ze&&Mt?Se=Se.removeMark(Mt.from,Mt.to,G):Se=Se.removeMark(pe,We,G),H.dispatch(Se),H.focus()}),p(null)},ge=typeof navigator<"u"&&/mac/i.test(navigator.platform)?"⌘":"Ctrl+",se=(A,O)=>O?`${A} (${ge}${O})`:A,Re=A=>g(O=>O===A?null:A),Ct=A=>()=>{g(null),ae(A)()},k=(A,O)=>{g(null),P((_,H)=>{const G=H.state.selection.from;_.get(X).call(iu.key,{row:A,col:O});let re=-1;if(H.state.doc.descendants((dt,Se)=>re>=0?!1:(dt.type===xt.type(_)&&Se+dt.nodeSize>=G&&(re=Se),dt.type!==xt.type(_))),re<0)return;const pe=H.state.tr,We=pe.doc.nodeAt(re);We==null||We.descendants((dt,Se)=>{"alignment"in dt.attrs&&pe.setNodeMarkup(re+1+Se,void 0,{...dt.attrs,alignment:null})});const ze=K.findFrom(pe.doc.resolve(re+1),1,!0);ze&&pe.setSelection(ze),H.dispatch(pe)})()},nt=()=>{var H;const A=v.value.trim();if(!A)return;let O=A;if(v.mode==="project"){const G=A.replace(/^(\.\/|\/)+/,"");O=((H=/\]\((.*)\)$/.exec(_f(t,G,"file")))==null?void 0:H[1])??G}const _=(A.split(/[\\/]/).pop()??"").replace(/[?#].*$/,"").replace(/\.[^.]*$/,"");g(null),B({...v,value:""}),P((G,re)=>{const pe=Ot.type(G).create({src:O,alt:_,title:""});re.dispatch(re.state.tr.replaceSelectionWith(pe,!1).scrollIntoView())})()},St=A=>{F((O,_)=>{_.dispatch(_.state.tr.setNodeAttribute(_.state.selection.$from.before(),"language",A)),_.focus()})},b=Rf.map(([A,O])=>({value:A,label:O}));c.codeLang&&!Rf.some(([A])=>A===c.codeLang)&&b.push({value:c.codeLang,label:c.codeLang});const qe=A=>{A.target.closest('input, [role="listbox"]')||A.preventDefault()};return N.jsxs("div",{className:"mdtext",children:[N.jsxs("div",{className:"mdtext__bar",role:"toolbar","aria-label":"Форматирование",onMouseDown:qe,children:[N.jsx(be,{label:se("Жирный","B"),on:c.strong,onClick:j(Js.key),children:N.jsx("b",{children:"Ж"})}),N.jsx(be,{label:se("Курсив","I"),on:c.em,onClick:j(Ks.key),children:N.jsx("i",{children:"К"})}),N.jsx(be,{label:se("Подчёркнутый","U"),on:c.underline,onClick:j(Ra.key),children:N.jsx("u",{children:"П"})}),N.jsx(be,{label:se("Зачёркнутый","Shift+X"),on:c.strike,onClick:j(Fo.key),children:N.jsx("s",{children:"З"})}),N.jsx(be,{label:se("Код в строке","E"),on:c.code,onClick:j(Us.key),children:N.jsx("span",{className:"mdtext__mono",children:"<>"})}),N.jsx(be,{label:se("Ссылка","K"),on:c.link||f!==null,onClick:M,children:N.jsxs("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[N.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"}),N.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"})]})}),N.jsx(be,{label:se("Снять форматирование","\\"),on:!1,onClick:P((A,O)=>jg(O)),children:N.jsxs("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[N.jsx("path",{d:"M3.5 3.5h7M7 3.5l-1.6 8M4.5 11.5h3.5"}),N.jsx("path",{d:"m10 9.5 3.5 3.5m0-3.5L10 13"})]})}),N.jsx("span",{className:"mdtext__sep","aria-hidden":!0}),[1,2,3].map(A=>N.jsx(be,{label:se(`Заголовок ${A}`,String(A)),on:c.heading===A,onClick:ae(A),children:N.jsxs("span",{className:"mdtext__h",children:["Н",N.jsx("sub",{children:A})]})},A)),N.jsxs("div",{className:"mdtext__anchor",children:[N.jsxs(be,{label:"Другие стили абзаца",on:c.heading>=4||y==="block",onClick:()=>Re("block"),popup:!0,children:[N.jsx("span",{className:"mdtext__h",children:c.heading>=4?N.jsxs(N.Fragment,{children:["Н",N.jsx("sub",{children:c.heading})]}):"¶"}),N.jsx("svg",{className:"mdtext__caret",viewBox:"0 0 12 12",width:"9",height:"9",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:N.jsx("path",{d:"M3 4.5 6 7.5 9 4.5"})})]}),y==="block"&&N.jsxs("div",{className:"mdtext__pop mdtext__menu",role:"menu","aria-label":"Стили абзаца",children:[N.jsxs("button",{type:"button",role:"menuitem",className:"mdtext__item",onClick:()=>{g(null),j(mr.key)()},children:[N.jsx("span",{children:"Обычный текст"}),N.jsxs("kbd",{children:[ge,"0"]})]}),[4,5,6].map(A=>N.jsxs("button",{type:"button",role:"menuitem",className:"mdtext__item"+(c.heading===A?" is-on":""),onClick:Ct(A),children:[N.jsxs("span",{children:["Заголовок ",A]}),N.jsxs("kbd",{children:[ge,A]})]},A))]})]}),N.jsx("span",{className:"mdtext__sep","aria-hidden":!0}),N.jsx(be,{label:se("Маркированный список","Shift+8"),on:c.bullet,onClick:he(!1),children:N.jsxs("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"currentColor",children:[N.jsx("circle",{cx:"2.5",cy:"4",r:"1.2"}),N.jsx("circle",{cx:"2.5",cy:"8",r:"1.2"}),N.jsx("circle",{cx:"2.5",cy:"12",r:"1.2"}),N.jsx("path",{d:"M6 3.4h8v1.2H6zM6 7.4h8v1.2H6zM6 11.4h8v1.2H6z"})]})}),N.jsx(be,{label:se("Нумерованный список","Shift+7"),on:c.ordered,onClick:he(!0),children:N.jsxs("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"currentColor",children:[N.jsx("text",{x:"0",y:"5.6",fontSize:"5",fontFamily:"sans-serif",children:"1"}),N.jsx("text",{x:"0",y:"9.6",fontSize:"5",fontFamily:"sans-serif",children:"2"}),N.jsx("text",{x:"0",y:"13.6",fontSize:"5",fontFamily:"sans-serif",children:"3"}),N.jsx("path",{d:"M6 3.4h8v1.2H6zM6 7.4h8v1.2H6zM6 11.4h8v1.2H6z"})]})}),N.jsx(be,{label:se("Список задач","Shift+9"),on:c.task,onClick:P((A,O)=>_g(A,O)),children:N.jsxs("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[N.jsx("rect",{x:"2",y:"2",width:"5",height:"5",rx:"1.2"}),N.jsx("path",{d:"m3.4 4.5 1.1 1.1L6 3.7"}),N.jsx("path",{d:"M9.5 4.5H14M9.5 11.5H14"}),N.jsx("rect",{x:"2",y:"9",width:"5",height:"5",rx:"1.2"})]})}),N.jsx(be,{label:se("Цитата","Shift+B"),on:c.quote,onClick:j(Qs.key),children:N.jsxs("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"currentColor",children:[N.jsx("path",{d:"M2 3h1.6v10H2z"}),N.jsx("path",{d:"M6 4.4h8v1.2H6zM6 7.4h8v1.2H6zM6 10.4h5v1.2H6z"})]})}),N.jsx(be,{label:se("Блок кода","Alt+C"),on:c.codeBlock,onClick:j(Xs.key),children:N.jsx("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:N.jsx("path",{d:"M5.5 4.5 2 8l3.5 3.5M10.5 4.5 14 8l-3.5 3.5"})})}),N.jsx(be,{label:se("Разделитель","Shift+-"),on:!1,onClick:P((A,O)=>$g(A,O)),children:N.jsxs("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[N.jsx("path",{d:"M2 8h12"}),N.jsx("path",{d:"M5 4h6M5 12h6",opacity:".45"})]})}),N.jsx("span",{className:"mdtext__sep","aria-hidden":!0}),N.jsxs("div",{className:"mdtext__anchor",children:[N.jsx(be,{label:"Таблица",on:c.table||y==="table",onClick:()=>Re("table"),popup:!0,children:N.jsxs("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round",children:[N.jsx("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),N.jsx("path",{d:"M2 6.5h12M2 10h12M6 3v10M10 3v10"})]})}),y==="table"&&N.jsxs("div",{className:"mdtext__pop mdtext__gridpop",role:"dialog","aria-label":"Размер таблицы",children:[N.jsx("div",{className:"mdtext__grid",role:"grid",onMouseLeave:()=>w({rows:0,cols:0}),onKeyDown:A=>{var re;const _={ArrowRight:[0,1],ArrowLeft:[0,-1],ArrowDown:[1,0],ArrowUp:[-1,0]}[A.key];if(!_)return;A.preventDefault();const H=Math.min(Nr,Math.max(1,(C.rows||1)+_[0])),G=Math.min(Nr,Math.max(1,(C.cols||1)+_[1]));w({rows:H,cols:G}),(re=A.currentTarget.querySelector(`[data-cell="${H}-${G}"]`))==null||re.focus()},children:Array.from({length:Nr*Nr},(A,O)=>{const _=Math.floor(O/Nr)+1,H=O%Nr+1;return N.jsx("button",{type:"button",role:"gridcell","data-cell":`${_}-${H}`,tabIndex:_===1&&H===1?0:-1,className:"mdtext__cell"+(_<=C.rows&&H<=C.cols?" is-lit":""),"aria-label":`${H} × ${_}`,onMouseEnter:()=>w({rows:_,cols:H}),onFocus:()=>w({rows:_,cols:H}),onClick:()=>k(_,H)},O)})}),N.jsx("div",{className:"mdtext__gridsize","aria-live":"polite",children:C.rows?`${C.cols} × ${C.rows}`:"Выберите размер"})]})]}),N.jsxs("div",{className:"mdtext__anchor",children:[N.jsx(be,{label:"Картинка",on:y==="image",onClick:()=>Re("image"),popup:!0,children:N.jsxs("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round",children:[N.jsx("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),N.jsx("circle",{cx:"5.8",cy:"6.4",r:"1.1"}),N.jsx("path",{d:"m2.5 12 3.6-3.4 2.6 2.3 2-1.8L13.5 12"})]})}),y==="image"&&N.jsxs("form",{className:"mdtext__pop mdtext__imgpop","aria-label":"Вставка картинки",onSubmit:A=>{A.preventDefault(),nt()},children:[N.jsx("div",{className:"mdtext__seg",role:"group","aria-label":"Источник картинки",children:[["project","Из проекта"],["url","По адресу"]].map(([A,O])=>N.jsx("button",{type:"button",className:"mdtext__segbtn"+(v.mode===A?" is-on":""),"aria-pressed":v.mode===A,onClick:()=>B({mode:A,value:""}),children:O},A))}),N.jsx("input",{className:"mdtext__linkinput",type:"text",autoFocus:!0,spellCheck:!1,"aria-label":v.mode==="project"?"Путь к файлу в проекте":"Адрес картинки",placeholder:v.mode==="project"?"assets/screenshot.png":"https://…",value:v.value,onChange:A=>B({...v,value:A.target.value})}),N.jsx("button",{type:"submit",className:"btn btn--sm",disabled:!v.value.trim(),children:"Вставить"})]})]}),N.jsxs("div",{className:"mdtext__anchor mdtext__anchor--end",children:[N.jsx(be,{label:"Горячие клавиши",on:y==="help",onClick:()=>Re("help"),popup:!0,children:N.jsx("span",{className:"mdtext__h",children:"?"})}),y==="help"&&N.jsx("div",{className:"mdtext__pop mdtext__help",role:"dialog","aria-label":"Горячие клавиши",children:qT(ge).map(A=>N.jsxs("section",{className:"mdtext__helpgroup",children:[N.jsx("h4",{children:A.title}),N.jsx("dl",{children:A.items.map(([O,_])=>N.jsxs("div",{children:[N.jsx("dt",{children:O}),N.jsx("dd",{children:N.jsx("kbd",{children:_})})]},O))})]},A.title))})]})]}),(c.table||c.codeBlock)&&N.jsxs("div",{className:"mdtext__ctx",role:"toolbar","aria-label":c.table?"Таблица":"Блок кода",onMouseDown:qe,children:[c.codeBlock&&N.jsxs(N.Fragment,{children:[N.jsx("span",{className:"mdtext__ctxlabel",children:"Язык кода"}),N.jsx(Gg,{className:"mdtext__lang",value:c.codeLang,options:b,ariaLabel:"Язык блока кода",onChange:St})]}),c.table&&N.jsxs(N.Fragment,{children:[N.jsx("span",{className:"mdtext__ctxlabel",children:"Таблица"}),N.jsx(jn,{label:"Строку выше",onClick:j(lu.key)}),N.jsx(jn,{label:"Строку ниже",onClick:j(au.key)}),N.jsx(jn,{label:"Столбец слева",onClick:j(ou.key)}),N.jsx(jn,{label:"Столбец справа",onClick:j(su.key)}),N.jsx("span",{className:"mdtext__sep","aria-hidden":!0}),N.jsx(jn,{label:"Удалить строку",danger:!0,onClick:P((A,O)=>void Qm(O.state,O.dispatch))}),N.jsx(jn,{label:"Удалить столбец",danger:!0,onClick:P((A,O)=>void Ym(O.state,O.dispatch))}),N.jsx("span",{className:"mdtext__sep","aria-hidden":!0}),[["left","по левому краю","M2 4h12M2 8h7M2 12h10"],["center","по центру","M2 4h12M4.5 8h7M3 12h10"],["right","по правому краю","M2 4h12M7 8h7M4 12h10"]].map(([A,O,_])=>N.jsx(be,{label:`Выравнивание столбца ${O}`,on:(c.tableAlign||"left")===A,onClick:P((H,G)=>VT(G,A)),children:N.jsx("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:N.jsx("path",{d:_})})},A)),N.jsx("span",{className:"mdtext__sep","aria-hidden":!0}),N.jsx(jn,{label:"Удалить таблицу",danger:!0,onClick:P((A,O)=>void Zm(O.state,O.dispatch))})]})]}),f&&N.jsxs("form",{className:"mdtext__link",onSubmit:A=>{A.preventDefault(),ne(f.href)},children:[N.jsx("label",{className:"mdtext__linklabel",htmlFor:"mdtext-link-url",children:"Ссылка"}),N.jsx("input",{id:"mdtext-link-url",ref:m,className:"mdtext__linkinput",type:"text",inputMode:"url",autoFocus:!0,spellCheck:!1,placeholder:"https://… или путь к файлу",value:f.href,onChange:A=>p({...f,href:A.target.value}),onKeyDown:A=>{A.key==="Escape"&&(A.preventDefault(),p(null),F((O,_)=>_.focus()))}}),N.jsx("button",{type:"submit",className:"btn btn--sm",children:"Применить"}),f.had&&N.jsx("button",{type:"button",className:"btn btn--sm",onClick:()=>ne(""),children:"Убрать"}),N.jsx("button",{type:"button",className:"btn btn--sm",onClick:()=>{p(null),F((A,O)=>O.focus())},children:"Отмена"})]}),N.jsx("div",{className:"mdtext__scroll",onMouseDown:A=>{A.target===A.currentTarget&&(A.preventDefault(),F((O,_)=>{_.focus(),_.dispatch(_.state.tr.setSelection(K.atEnd(_.state.doc)))}))},children:N.jsx("div",{ref:l,className:"mdtext__host","data-ready":h||void 0})})]})}function be({label:t,on:e,onClick:n,children:r,popup:i}){return N.jsx("button",{type:"button",className:"mdtext__tool"+(e?" is-on":""),title:t,"aria-label":t,...i?{"aria-haspopup":"true","aria-expanded":e}:{"aria-pressed":e},onClick:n,children:r})}function jn({label:t,onClick:e,danger:n}){return N.jsx("button",{type:"button",className:"mdtext__act"+(n?" is-danger":""),onClick:e,children:t})}const Nr=8,Rf=[["","Без языка"],["ts","TypeScript"],["js","JavaScript"],["json","JSON"],["bash","Bash"],["python","Python"],["html","HTML"],["css","CSS"],["sql","SQL"],["yaml","YAML"],["md","Markdown"],["diff","Diff"],["go","Go"],["rust","Rust"],["java","Java"],["cpp","C++"],["php","PHP"]];function qT(t){return[{title:"Текст",items:[["Жирный",`${t}B`],["Курсив",`${t}I`],["Подчёркнутый",`${t}U`],["Зачёркнутый",`${t}Shift+X`],["Код в строке",`${t}E`],["Ссылка",`${t}K`],["Снять форматирование",`${t}\\`]]},{title:"Абзац",items:[["Обычный текст",`${t}0`],["Заголовки 1–6",`${t}1 … ${t}6`],["Цитата",`${t}Shift+B`],["Блок кода",`${t}Alt+C`],["Разделитель",`${t}Shift+-`]]},{title:"Списки",items:[["Маркированный",`${t}Shift+8`],["Нумерованный",`${t}Shift+7`],["Задачи",`${t}Shift+9`],["Сдвинуть пункт","Tab"],["Вернуть пункт","Shift+Tab"]]},{title:"Файл",items:[["Сохранить",`${t}S`]]}]}function WT(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{XT as default,Fg as foldUnderline,Ra as toggleUnderlineCommand,BT as underlineHandler,ku as underlineSchema,WT as widenTableDelimiters};