@krantho/studio 1.1.4 → 1.1.5

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 (96) hide show
  1. package/dist/assets/{AssistantPanel-DpYeurU-.js → AssistantPanel-CeOJfSzu.js} +2 -2
  2. package/dist/assets/GraphBrowser-BNto7hgk.js +2 -0
  3. package/dist/assets/GraphCanvas-Wo0XaRUG.js +1 -0
  4. package/dist/assets/{action-button-DIrhqMRc.js → action-button-DPLZn2gk.js} +1 -1
  5. package/dist/assets/api-seo-CL5Gq_tK.js +1 -0
  6. package/dist/assets/{arduino-DKR9_xyJ.js → arduino-LsGX0_fs.js} +1 -1
  7. package/dist/assets/{arrow-down-B5kfR2lG.js → arrow-down-EM8VW6wf.js} +1 -1
  8. package/dist/assets/{arrow-left-7opbl8fu.js → arrow-left-DDRnAcp0.js} +1 -1
  9. package/dist/assets/{auth-CIpilSKF.js → auth-Dw_S0y7Q.js} +1 -1
  10. package/dist/assets/{c-CEM0h_nK.js → c-8MGCQYww.js} +1 -1
  11. package/dist/assets/{circle-check-big-DQjpuxcC.js → circle-check-big-BoM2gsTK.js} +1 -1
  12. package/dist/assets/{circle-dashed-cuYrILNo.js → circle-dashed-BrW3fkOb.js} +1 -1
  13. package/dist/assets/{circle-x-peGpq98w.js → circle-x-BFRqOpao.js} +1 -1
  14. package/dist/assets/{clike-BlGBRct5.js → clike-DDEFrJkJ.js} +1 -1
  15. package/dist/assets/{clock-DoBIVjZO.js → clock-D6yo3SXy.js} +1 -1
  16. package/dist/assets/{collection-view-Bbr6ff-2.js → collection-view-m8EZ-LL6.js} +1 -1
  17. package/dist/assets/{copy-V85khWct.js → copy-DLNaHdGn.js} +1 -1
  18. package/dist/assets/{corner-down-right-BpwOGRFR.js → corner-down-right-DjKESJQq.js} +1 -1
  19. package/dist/assets/{cpp-C0nea612.js → cpp-CCXrbquo.js} +1 -1
  20. package/dist/assets/createLucideIcon-Bepm3pPy.js +1 -0
  21. package/dist/assets/{csharp-C430X67Y.js → csharp-C9B8MEOG.js} +1 -1
  22. package/dist/assets/{data-table-B1kqxrEw.js → data-table-CkVtHoRX.js} +1 -1
  23. package/dist/assets/{editor-page-ydSt1TIL.js → editor-page-DygzC7e2.js} +4 -4
  24. package/dist/assets/{empty-state-CeUZocHx.js → empty-state-CFOGJxEy.js} +1 -1
  25. package/dist/assets/{export-helpers-C_HVpJN9.js → export-helpers-88w7CxCC.js} +1 -1
  26. package/dist/assets/{external-link-Dh7p8Ii6.js → external-link-WjUzPJ5r.js} +1 -1
  27. package/dist/assets/fill-job-B7N4431e.js +1 -0
  28. package/dist/assets/{fill-run-view-ChrOLoV4.js → fill-run-view-CwWAvqg1.js} +1 -1
  29. package/dist/assets/{findability-BrhtZ2yD.js → findability-CMuvomGn.js} +1 -1
  30. package/dist/assets/{format-C3ZX9yGM.js → format-Bm7d76kc.js} +1 -1
  31. package/dist/assets/{go-2ldyX7zA.js → go-C0xZKYRK.js} +1 -1
  32. package/dist/assets/graph-config-CkeJgPns.js +1 -0
  33. package/dist/assets/{image-editor-CAZbOhRZ.js → image-editor-DUnZn-si.js} +1 -1
  34. package/dist/assets/index-CZQJBss1.js +2 -0
  35. package/dist/assets/{info-Cxkabti5.js → info-C_gFhCsx.js} +1 -1
  36. package/dist/assets/{java-BaDy4FT-.js → java-DQEBLEMZ.js} +1 -1
  37. package/dist/assets/{javascript-DoKZVVG7.js → javascript-fLcGJpXd.js} +1 -1
  38. package/dist/assets/{kotlin-aNSUnDDr.js → kotlin-BhmBVS_0.js} +1 -1
  39. package/dist/assets/{layers-0VWe0rKm.js → layers-BzWhM_T4.js} +1 -1
  40. package/dist/assets/{list-checks-BCEhMMVY.js → list-checks-BycWtY9-.js} +1 -1
  41. package/dist/assets/live-markdown-editor-ColMfnPc.js +54 -0
  42. package/dist/assets/{markdown-ChIsYjIt.js → markdown-Cxg2MxWr.js} +1 -1
  43. package/dist/assets/{markup-C09yLKTH.js → markup-CaYP0gdG.js} +1 -1
  44. package/dist/assets/{markup-templating-DNhq-UOv.js → markup-templating-DwmVPbHS.js} +1 -1
  45. package/dist/assets/{media-model-D4F1Farw.js → media-model-s8-mD6gc.js} +1 -1
  46. package/dist/assets/media-page-BIWNwixX.js +1 -0
  47. package/dist/assets/{meter-ZOLJ0WhG.js → meter-ZmQjbS6d.js} +1 -1
  48. package/dist/assets/{objectivec-s2I4Tn1D.js → objectivec-CHvtiGZJ.js} +1 -1
  49. package/dist/assets/{pen-line-B524Nue8.js → pen-line-tXXn2ou2.js} +1 -1
  50. package/dist/assets/{pencil-xdGZtrO4.js → pencil-CGbkYPXO.js} +1 -1
  51. package/dist/assets/{php-B_6N-5RT.js → php-SxIHzpF9.js} +1 -1
  52. package/dist/assets/{pulse-page-zRYAQJh6.js → pulse-page-rQssy-k-.js} +1 -1
  53. package/dist/assets/rolldown-runtime-9C0vUP4u.js +1 -0
  54. package/dist/assets/{rotate-ccw-BgARBEK3.js → rotate-ccw-IHHFmrqQ.js} +1 -1
  55. package/dist/assets/{ruby-C8GJZDTg.js → ruby--MTbGwza.js} +1 -1
  56. package/dist/assets/{save-ClSXW9cb.js → save-DWhrs5es.js} +1 -1
  57. package/dist/assets/{send-kYpW5JED.js → send-Bf0SGwsO.js} +1 -1
  58. package/dist/assets/setup-page-C2UVL4hj.js +1 -0
  59. package/dist/assets/site-CI7ReWwB.js +1 -0
  60. package/dist/assets/site-model-DwdSKSWR.js +1 -0
  61. package/dist/assets/{site-overview-B0Dnsj2N.js → site-overview-BnmQMy6p.js} +1 -1
  62. package/dist/assets/{structure-page-DpM1G-M9.js → structure-page-Cjqo5mS4.js} +2 -2
  63. package/dist/assets/{trash-DzRCm500.js → trash-DFKejXb4.js} +1 -1
  64. package/dist/assets/{triangle-exclamation-point-ttN5lZI0.js → triangle-exclamation-point-CxTYPLt1.js} +1 -1
  65. package/dist/assets/{typescript-s_P45ayF.js → typescript-DuydAHsI.js} +1 -1
  66. package/dist/assets/{upload-CaqQJaUr.js → upload-9M4suN_I.js} +1 -1
  67. package/dist/assets/{use-drawer-actions-BeAi2hJS.js → use-drawer-actions-CXYpJuv5.js} +1 -1
  68. package/dist/assets/use-loaded-DJHzW9zx.js +1 -0
  69. package/dist/assets/{use-locale-versions-CcJ_us1I.js → use-locale-versions-DXUTVGkz.js} +1 -1
  70. package/dist/assets/{vendor-diff-DGCTJYJ4.js → vendor-diff-B5uXPOYl.js} +40 -40
  71. package/dist/assets/vendor-markdown-BXQo8zdD.js +79 -0
  72. package/dist/assets/{vendor-media-DXSmPN_d.js → vendor-media-BVfbikEZ.js} +1 -1
  73. package/dist/assets/vendor-react-Njf47Pb1.js +15 -0
  74. package/dist/assets/{vendor-react-DLioOiRN.css → vendor-react-bSyOAvy0.css} +1 -1
  75. package/dist/assets/vendor-reactflow-D7sfycOJ.js +1 -0
  76. package/dist/assets/vendor-router-Cwn5_0Pw.js +1 -0
  77. package/dist/index.html +9 -9
  78. package/package.json +23 -23
  79. package/dist/assets/GraphBrowser-Cm5q82MJ.js +0 -2
  80. package/dist/assets/GraphCanvas-CZJNUa_J.js +0 -1
  81. package/dist/assets/api-seo-DeG5gsh6.js +0 -1
  82. package/dist/assets/createLucideIcon-BklFHeMd.js +0 -1
  83. package/dist/assets/fill-job-CKtHKXwV.js +0 -1
  84. package/dist/assets/graph-config-CgXhm7XP.js +0 -1
  85. package/dist/assets/index-d5j-az5g.js +0 -2
  86. package/dist/assets/live-markdown-editor-DSsCNBWR.js +0 -54
  87. package/dist/assets/media-page-DuSUjFO1.js +0 -1
  88. package/dist/assets/rolldown-runtime-COiEfhsA.js +0 -1
  89. package/dist/assets/setup-page-CshRkFJ-.js +0 -1
  90. package/dist/assets/site-CGs9-oiw.js +0 -1
  91. package/dist/assets/site-model-BXHOxNij.js +0 -1
  92. package/dist/assets/use-loaded-BNCu0C-c.js +0 -1
  93. package/dist/assets/vendor-markdown-BeOOOWTF.js +0 -74
  94. package/dist/assets/vendor-react-CXaWJ_ii.js +0 -15
  95. package/dist/assets/vendor-reactflow-CMKi7AEX.js +0 -1
  96. package/dist/assets/vendor-router-B4czwg8X.js +0 -1
@@ -0,0 +1,54 @@
1
+ import{i as e,n as t,t as n}from"./rolldown-runtime-9C0vUP4u.js";import{n as r,o as i,s as a}from"./vendor-diff-B5uXPOYl.js";import{n as o}from"./use-loaded-DJHzW9zx.js";import{tt as s}from"./index-CZQJBss1.js";import{n as c,r as l,t as u}from"./createLucideIcon-Bepm3pPy.js";import{a as d,c as f,i as p,n as m,o as h,r as g,s as _,t as v}from"./editor-page-DygzC7e2.js";import{t as y}from"./arrow-down-EM8VW6wf.js";import{t as b}from"./arrow-left-DDRnAcp0.js";import{p as x}from"./use-drawer-actions-CXYpJuv5.js";import{t as S}from"./trash-DFKejXb4.js";var ee={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};ee.node;var te=u(ee),ne={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};ne.node;var re=u(ne),C={name:`italic`,size:24,node:[[`line`,{x1:`19`,x2:`10`,y1:`4`,y2:`4`,key:`15jd3p`}],[`line`,{x1:`14`,x2:`5`,y1:`20`,y2:`20`,key:`bu0au3`}],[`line`,{x1:`15`,x2:`9`,y1:`4`,y2:`20`,key:`uljnxc`}]]};C.node;var w=u(C),ie={name:`letter-b`,size:24,node:[[`path`,{d:`M6 12h9a4 4 0 010 8H7a1 1 0 01-1-1V5a1 1 0 011-1h7a4 4 0 010 8`,key:`n8tvfh`}]],aliases:[`bold`]};ie.node;var ae=u(ie),oe={name:`link`,size:24,node:[[`path`,{d:`m11 6 1.5-1.5a5 5 0 018.415 3.51A5 5 0 0119.5 11.5L18 13`,key:`tve22k`}],[`path`,{d:`m13 18-1.5 1.5a5 5 0 01-8.415-3.51A5 5 0 014.5 12.5L6 11`,key:`6clao3`}],[`path`,{d:`m9 15 6-6`,key:`1ygkhp`}]]};oe.node;var se=u(oe),ce={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};ce.node;var le=u(ce),ue={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};ue.node;var de=u(ue),fe={name:`quote`,size:24,node:[[`path`,{d:`M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`rib7q0`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`1ymkrd`}]]};fe.node;var pe=u(fe),me={name:`redo`,size:24,node:[[`path`,{d:`M21 7v6h-6`,key:`3ptur4`}],[`path`,{d:`M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7`,key:`1kgawr`}]]};me.node;var he=u(me),ge={name:`strikethrough`,size:24,node:[[`path`,{d:`M16 4H9a3 3 0 0 0-2.83 4`,key:`43sutm`}],[`path`,{d:`M14 12a4 4 0 0 1 0 8H6`,key:`nlfj13`}],[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}]]};ge.node;var _e=u(ge),ve={name:`table-2`,size:24,node:[[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]};ve.node;var ye=u(ve),be={name:`text-align-center`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M17 12H7`,key:`16if0g`}],[`path`,{d:`M19 19H5`,key:`vjpgq2`}]],aliases:[`align-center`]};be.node;var xe=u(be),Se={name:`text-align-end`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M21 19H7`,key:`4cu937`}]],aliases:[`align-right`]};Se.node;var Ce=u(Se),we={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};we.node;var Te=u(we),Ee={name:`undo`,size:24,node:[[`path`,{d:`M3 7v6h6`,key:`1v2h90`}],[`path`,{d:`M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13`,key:`1r6uu6`}]]};Ee.node;var De=u(Ee),Oe=function(e){return e.docTypeError=`docTypeError`,e.contextNotFound=`contextNotFound`,e.timerNotFound=`timerNotFound`,e.ctxCallOutOfScope=`ctxCallOutOfScope`,e.createNodeInParserFail=`createNodeInParserFail`,e.stackOverFlow=`stackOverFlow`,e.parserMatchError=`parserMatchError`,e.serializerMatchError=`serializerMatchError`,e.getAtomFromSchemaFail=`getAtomFromSchemaFail`,e.expectDomTypeError=`expectDomTypeError`,e.callCommandBeforeEditorView=`callCommandBeforeEditorView`,e.missingRootElement=`missingRootElement`,e.missingNodeInSchema=`missingNodeInSchema`,e.missingMarkInSchema=`missingMarkInSchema`,e.ctxNotBind=`ctxNotBind`,e.missingYjsDoc=`missingYjsDoc`,e.aiProviderError=`aiProviderError`,e.aiBuildContextError=`aiBuildContextError`,e}({}),ke=class extends Error{constructor(e,t,n){super(t,n),this.name=`MilkdownError`,this.code=e,n?.cause!==void 0&&(this.cause=n.cause)}},Ae=(e,t)=>typeof t==`function`?`[Function]`:t,je=e=>JSON.stringify(e,Ae);function Me(e){return new ke(Oe.docTypeError,`Doc type error, unsupported type: ${je(e)}`)}function Ne(e){return new ke(Oe.contextNotFound,`Context "${e}" not found, do you forget to inject it?`)}function Pe(e){return new ke(Oe.timerNotFound,`Timer "${e}" not found, do you forget to record it?`)}function Fe(){return new ke(Oe.ctxCallOutOfScope,`Should not call a context out of the plugin.`)}function Ie(e,t,n){let r=`Cannot create node for ${`name`in e?e.name:e}`,i=e=>{if(e==null)return`null`;if(Array.isArray(e))return`[${e.map(i).join(`, `)}]`;if(typeof e==`object`)return`toJSON`in e&&typeof e.toJSON==`function`?JSON.stringify(e.toJSON()):`spec`in e?JSON.stringify(e.spec):JSON.stringify(e);if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return JSON.stringify(e);if(typeof e==`function`)return`[Function: ${e.name||`anonymous`}]`;try{return String(e)}catch{return`[Unserializable]`}},a=[[`[Description]`,r],[`[Attributes]`,t],[`[Content]`,(n??[]).map(e=>e?typeof e==`object`&&`type`in e?`${e}`:i(e):`null`)]].reduce((e,[t,n])=>{let r=`${t}: ${i(n)}.`;return e.concat(r)},[]);return new ke(Oe.createNodeInParserFail,a.join(`
2
+ `))}function Le(){return new ke(Oe.stackOverFlow,`Stack over flow, cannot pop on an empty stack.`)}function Re(e){return new ke(Oe.parserMatchError,`Cannot match target parser for node: ${je(e)}.`)}function ze(e){return new ke(Oe.serializerMatchError,`Cannot match target serializer for node: ${je(e)}.`)}function Be(e){return new ke(Oe.expectDomTypeError,`Expect to be a dom, but get: ${je(e)}.`)}function Ve(){return new ke(Oe.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 He(e){return new ke(Oe.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`)}function Ue(e){return new ke(Oe.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${e}" in schema.`)}var We=class{constructor(){this.sliceMap=new Map,this.get=e=>{let t=typeof e==`string`?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);if(!t)throw Ne(typeof e==`string`?e:e.name);return t},this.remove=e=>{let t=typeof e==`string`?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>typeof e==`string`?[...this.sliceMap.values()].some(t=>t.type.name===e):this.sliceMap.has(e.id)}},Ge=class{#e;#t;#n;constructor(e,t,n){this.#e=[],this.#n=()=>{this.#e.forEach(e=>e(this.#t))},this.set=e=>{this.#t=e,this.#n()},this.get=()=>this.#t,this.update=e=>{this.#t=e(this.#t),this.#n()},this.type=n,this.#t=t,e.set(n.id,this)}on(e){return this.#e.push(e),()=>{this.#e=this.#e.filter(t=>t!==e)}}once(e){let t=this.on(n=>{e(n),t()});return t}off(e){this.#e=this.#e.filter(t=>t!==e)}offAll(){this.#e=[]}},Ke=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw Fe()}}create(e,t=this._defaultValue){return new Ge(e,t,this)}},T=(e,t)=>new Ke(e,t),qe=class{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n){this.#r=new Set,this.#i=new Set,this.#a=new Map,this.#o=new Map,this.read=()=>({metadata:this.#e,injectedSlices:[...this.#r].map(e=>({name:typeof e==`string`?e:e.name,value:this.#s(e)})),consumedSlices:[...this.#i].map(e=>({name:typeof e==`string`?e:e.name,value:this.#s(e)})),recordedTimers:[...this.#a].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#c(e)})),waitTimers:[...this.#o].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#c(e)}))}),this.onRecord=e=>{this.#a.set(e,{start:Date.now(),duration:0})},this.onClear=e=>{this.#a.delete(e)},this.onDone=e=>{let t=this.#a.get(e);t&&(t.duration=Date.now()-t.start)},this.onWait=(e,t)=>{let n=Date.now();t.finally(()=>{this.#o.set(e,{duration:Date.now()-n})}).catch(console.error)},this.onInject=e=>{this.#r.add(e)},this.onRemove=e=>{this.#r.delete(e)},this.onUse=e=>{this.#i.add(e)},this.#s=e=>this.#t.get(e).get(),this.#c=e=>this.#n.get(e).status,this.#t=e,this.#n=t,this.#e=n}#s;#c},Je=class e{#e;#t;#n;#r;constructor(t,n,r){this.produce=t=>t&&Object.keys(t).length?new e(this.#e,this.#t,{...t}):this,this.inject=(e,t)=>{let n=e.create(this.#e.sliceMap);return t!=null&&n.set(t),this.#r?.onInject(e),this},this.remove=e=>(this.#e.remove(e),this.#r?.onRemove(e),this),this.record=e=>(e.create(this.#t.store),this.#r?.onRecord(e),this),this.clearTimer=e=>(this.#t.remove(e),this.#r?.onClear(e),this),this.isInjected=e=>this.#e.has(e),this.isRecorded=e=>this.#t.has(e),this.use=e=>(this.#r?.onUse(e),this.#e.get(e)),this.get=e=>this.use(e).get(),this.set=(e,t)=>this.use(e).set(t),this.update=(e,t)=>this.use(e).update(t),this.timer=e=>this.#t.get(e),this.done=e=>{this.timer(e).done(),this.#r?.onDone(e)},this.wait=e=>{let t=this.timer(e).start();return this.#r?.onWait(e,t),t},this.waitTimers=async e=>{await Promise.all(this.get(e).map(e=>this.wait(e)))},this.#e=t,this.#t=n,this.#n=r,r&&(this.#r=new qe(t,n,r))}get meta(){return this.#n}get inspector(){return this.#r}},Ye=class{constructor(){this.store=new Map,this.get=e=>{let t=this.store.get(e.id);if(!t)throw Pe(e.name);return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}},Xe=class{#e;#t;#n;#r;#i;constructor(e,t){this.#e=null,this.#t=null,this.#r=`pending`,this.#i=null,this.start=()=>(this.#e??=new Promise((e,t)=>{this.#t=t=>{t instanceof CustomEvent&&t.detail.id===this.#n&&(this.#r=`resolved`,this.#a(),t.stopImmediatePropagation(),e())},this.#o(()=>{this.#r===`pending`&&(this.#r=`rejected`),this.#a(),t(Error(`Timing ${this.type.name} timeout.`))}),this.#r=`pending`,addEventListener(this.type.name,this.#t)}),this.#e),this.done=()=>{let e=new CustomEvent(this.type.name,{detail:{id:this.#n}});dispatchEvent(e)},this.#a=()=>{this.#i!==null&&(clearTimeout(this.#i),this.#i=null),this.#t&&removeEventListener(this.type.name,this.#t)},this.#o=e=>{this.#i=setTimeout(()=>{this.#i=null,e()},this.type.timeout)},this.#n=Symbol(t.name),this.type=t,e.set(t.id,this)}get status(){return this.#r}#a;#o},Ze=class{constructor(e,t=3e3){this.create=e=>new Xe(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},Qe=(e,t=3e3)=>new Ze(e,t),$e={};function et(e,t){let n=t||$e;return tt(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function tt(e,t,n){if(rt(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return nt(e.children,t,n)}return Array.isArray(e)?nt(e,t,n):``}function nt(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=tt(e[i],t,n);return r.join(``)}function rt(e){return!!(e&&typeof e==`object`)}function it(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function at(e,t){return e.length>0?(it(e,e.length,0,t),e):t}var ot={}.hasOwnProperty;function st(e){let t={},n=-1;for(;++n<e.length;)ct(t,e[n]);return t}function ct(e,t){let n;for(n in t){let r=(ot.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){ot.call(r,a)||(r[a]=[]);let e=i[a];lt(r[a],Array.isArray(e)?e:e?[e]:[])}}}function lt(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);it(e,0,0,r)}function ut(e,t){let n=Number.parseInt(e,t);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 dt(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var E=bt(/[A-Za-z]/),ft=bt(/[\dA-Za-z]/),pt=bt(/[#-'*+\--9=?A-Z^-~]/);function mt(e){return e!==null&&(e<32||e===127)}var ht=bt(/\d/),gt=bt(/[\dA-Fa-f]/),_t=bt(/[!-/:-@[-`{-~]/);function D(e){return e!==null&&e<-2}function O(e){return e!==null&&(e<0||e===32)}function k(e){return e===-2||e===-1||e===32}var vt=bt(/\p{P}|\p{S}/u),yt=bt(/\s/);function bt(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function A(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return k(r)?(e.enter(n),s(r)):t(r)}function s(r){return k(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function xt(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&k(t)?(e.enter(r),c(t)):l(t)}function c(t){return k(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}var St={tokenize:Ct};function Ct(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null)e.consume(n);else return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),A(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null)e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);else return D(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var wt=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){Tt(this,e,t,n,!1)}addBefore(e,t,n){Tt(this,e,t,n,!0)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function Tt(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}var Et={tokenize:Ot},Dt={tokenize:kt};function Ot(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;let c=new wt;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Dt,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Dt,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null)i&&v(),_(0),e.consume(n);else return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null)g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);else return D(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;let l=new wt;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function kt(e,t,n){return A(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function At(e){if(e===null||O(e)||yt(e))return 1;if(vt(e))return 2}function jt(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var Mt={name:`attention`,resolveAll:Nt,tokenize:Pt};function Nt(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;let a=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,o={...e[i][1].end},s={...e[n][1].start};Ft(o,-a),Ft(s,a);let c={type:a>1?`strongSequence`:`emphasisSequence`,start:o,end:{...e[i][1].end}},l={type:a>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:s},u={type:a>1?`strongText`:`emphasisText`,start:{...e[i][1].end},end:{...e[n][1].start}},d={type:a>1?`strong`:`emphasis`,start:{...c.start},end:{...l.end}};e[i][1].end={...c.start},e[n][1].start={...l.end},r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=at(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=at(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=at(r,jt(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=at(r,[[`exit`,u,t],[`enter`,l,t],[`exit`,l,t],[`exit`,d,t]]);let f=0;e[n][1].end.offset-e[n][1].start.offset&&(f=2,r=at(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),it(e,i-1,n-i+3,r),n=i+r.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Pt(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=At(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=At(o),u=!l||l===2&&i||n.includes(o)&&o!==42&&o!==95,d=!i||i===2&&l||n.includes(r)&&r!==42&&r!==95;return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Ft(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var It={name:`autolink`,tokenize:Lt};function Lt(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return E(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||ft(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||ft(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||mt(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):pt(t)?(e.consume(t),l):n(t)}function u(e){return ft(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||ft(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Rt={partial:!0,tokenize:zt};function zt(e,t,n){return r;function r(t){return k(t)?A(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||D(e)?t(e):n(e)}}var Bt={continuation:{tokenize:Ht},exit:Ut,name:`blockQuote`,tokenize:Vt};function Vt(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return k(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Ht(e,t,n){let r=this;return i;function i(t){return k(t)?A(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Bt,t,n)(r)}}function Ut(e){e.exit(`blockQuote`)}var Wt={name:`characterEscape`,tokenize:Gt};function Gt(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return _t(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var Kt={name:`characterReference`,tokenize:qt};function qt(e,t,n){let i=this,a=0,o,s;return c;function c(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),l}function l(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),u):(e.enter(`characterReferenceValue`),o=31,s=ft,d(t))}function u(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),o=6,s=gt,d):(e.enter(`characterReferenceValue`),o=7,s=ht,d(t))}function d(c){if(c===59&&a){let a=e.exit(`characterReferenceValue`);return s===ft&&!r(i.sliceSerialize(a))?n(c):(e.enter(`characterReferenceMarker`),e.consume(c),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return s(c)&&a++<o?(e.consume(c),d):n(c)}}var Jt={partial:!0,tokenize:Yt};function Yt(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var Xt={concrete:!0,name:`codeFenced`,tokenize:Zt};function Zt(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),k(t)?A(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||D(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(Jt,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||D(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):k(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),A(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||D(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||D(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&k(t)?A(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||D(t)?e.check(Jt,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||D(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),k(t)?A(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),k(t)?A(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||D(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}var Qt={name:`codeIndented`,tokenize:en},$t={partial:!0,tokenize:tn};function en(e,t,n){return r;function r(t){return e.enter(`codeIndented`),xt(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):D(t)?e.attempt($t,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||D(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function tn(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):D(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):xt(e,t,a,`linePrefix`,4,4)(o)}function a(e){return D(e)?i(e):n(e)}}var nn={name:`codeText`,previous:an,resolve:rn,tokenize:on};function rn(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function an(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function on(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):D(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||D(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var sn=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw 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,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&cn(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),cn(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),cn(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){let t=this.left.splice(e,1/0);cn(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);cn(this.left,t.reverse())}}}};function cn(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function ln(e){let t={},n=-1,r,i,a,o,s,c,l,u=new sn(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,un(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return it(e,0,1/0,u.slice(0)),!l}function un(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var dn={resolve:pn,tokenize:mn},fn={partial:!0,tokenize:hn};function pn(e){return ln(e),e}function mn(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):D(t)?e.check(fn,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function hn(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),A(e,a,`linePrefix`)}function a(i){if(i===null||D(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function gn(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||mt(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||D(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||O(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||mt(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function _n(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):D(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||D(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!k(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function vn(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):D(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),A(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||D(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function yn(e,t){let n;return r;function r(i){return D(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):k(i)?A(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var bn={name:`definition`,tokenize:Sn},xn={partial:!0,tokenize:Cn};function Sn(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return _n.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=dt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return O(t)?yn(e,l)(t):l(t)}function l(t){return gn(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(xn,d,d)(t)}function d(t){return k(t)?A(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||D(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Cn(e,t,n){return r;function r(t){return O(t)?yn(e,i)(t):n(t)}function i(t){return vn(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return k(t)?A(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||D(e)?t(e):n(e)}}var wn={name:`hardBreakEscape`,tokenize:Tn};function Tn(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return D(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var En={name:`headingAtx`,resolve:Dn,tokenize:On};function Dn(e,t){let n=e.length-2,r=3;if(e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r){let i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`};it(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function On(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||O(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||D(n)?(e.exit(`atxHeading`),t(n)):k(n)?A(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||O(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var kn=`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`.split(`.`),An=[`pre`,`script`,`style`,`textarea`],jn={concrete:!0,name:`htmlFlow`,resolveTo:Nn,tokenize:Pn},Mn={partial:!0,tokenize:Fn};function Nn(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Pn(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:de):E(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):E(a)?(e.consume(a),i=4,r.interrupt?t:de):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:de):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:w:m):n(i)}function h(t){return E(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||O(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&An.includes(l)?(i=1,r.interrupt?t(s):w(s)):kn.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):w(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||ft(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:w):n(i)}function v(t){return k(t)?(e.consume(t),v):re(t)}function y(t){return t===47?(e.consume(t),re):t===58||t===95||E(t)?(e.consume(t),b):k(t)?(e.consume(t),y):re(t)}function b(t){return t===45||t===46||t===58||t===95||ft(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):k(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,ee):k(t)?(e.consume(t),S):te(t)}function ee(t){return t===c?(e.consume(t),c=null,ne):t===null||D(t)?n(t):(e.consume(t),ee)}function te(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||O(t)?x(t):(e.consume(t),te)}function ne(e){return e===47||e===62||k(e)?y(e):n(e)}function re(t){return t===62?(e.consume(t),C):n(t)}function C(t){return t===null||D(t)?w(t):k(t)?(e.consume(t),C):n(t)}function w(t){return t===45&&i===2?(e.consume(t),se):t===60&&i===1?(e.consume(t),ce):t===62&&i===4?(e.consume(t),fe):t===63&&i===3?(e.consume(t),de):t===93&&i===5?(e.consume(t),ue):D(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Mn,pe,ie)(t)):t===null||D(t)?(e.exit(`htmlFlowData`),ie(t)):(e.consume(t),w)}function ie(t){return e.check(Jt,ae,pe)(t)}function ae(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),oe}function oe(t){return t===null||D(t)?ie(t):(e.enter(`htmlFlowData`),w(t))}function se(t){return t===45?(e.consume(t),de):w(t)}function ce(t){return t===47?(e.consume(t),o=``,le):w(t)}function le(t){if(t===62){let n=o.toLowerCase();return An.includes(n)?(e.consume(t),fe):w(t)}return E(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),le):w(t)}function ue(t){return t===93?(e.consume(t),de):w(t)}function de(t){return t===62?(e.consume(t),fe):t===45&&i===2?(e.consume(t),de):w(t)}function fe(t){return t===null||D(t)?(e.exit(`htmlFlowData`),pe(t)):(e.consume(t),fe)}function pe(n){return e.exit(`htmlFlow`),t(n)}}function Fn(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Rt,t,n)}}var In={name:`htmlText`,tokenize:Ln};function Ln(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):E(t)?(e.consume(t),te):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):E(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):D(t)?(o=d,ce(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?se(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):D(t)?(o=h,ce(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?se(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?se(t):D(t)?(o=v,ce(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):D(t)?(o=y,ce(t)):(e.consume(t),y)}function b(e){return e===62?se(e):y(e)}function x(t){return E(t)?(e.consume(t),S):n(t)}function S(t){return t===45||ft(t)?(e.consume(t),S):ee(t)}function ee(t){return D(t)?(o=ee,ce(t)):k(t)?(e.consume(t),ee):se(t)}function te(t){return t===45||ft(t)?(e.consume(t),te):t===47||t===62||O(t)?ne(t):n(t)}function ne(t){return t===47?(e.consume(t),se):t===58||t===95||E(t)?(e.consume(t),re):D(t)?(o=ne,ce(t)):k(t)?(e.consume(t),ne):se(t)}function re(t){return t===45||t===46||t===58||t===95||ft(t)?(e.consume(t),re):C(t)}function C(t){return t===61?(e.consume(t),w):D(t)?(o=C,ce(t)):k(t)?(e.consume(t),C):ne(t)}function w(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,ie):D(t)?(o=w,ce(t)):k(t)?(e.consume(t),w):(e.consume(t),ae)}function ie(t){return t===i?(e.consume(t),i=void 0,oe):t===null?n(t):D(t)?(o=ie,ce(t)):(e.consume(t),ie)}function ae(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||O(t)?ne(t):(e.consume(t),ae)}function oe(e){return e===47||e===62||O(e)?ne(e):n(e)}function se(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function ce(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),le}function le(t){return k(t)?A(e,ue,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):ue(t)}function ue(t){return e.enter(`htmlTextData`),o(t)}}var Rn={name:`labelEnd`,resolveAll:Hn,resolveTo:Un,tokenize:Wn},zn={tokenize:Gn},Bn={tokenize:Kn},Vn={tokenize:qn};function Hn(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&it(e,0,e.length,n),e}function Un(e,t){let n=e.length,r=0,i,a,o;for(;n--;){let t=e[n][1];if(i){if(t.type===`link`||t.type===`labelLink`&&t._inactive)break;e[n][0]===`enter`&&t.type===`labelLink`&&(t._inactive=!0)}else if(a){if(e[n][0]===`enter`&&(t.type===`labelImage`||t.type===`labelLink`)&&!t._balanced&&(i=n,t.type!==`labelLink`)){r=2;break}}else t.type===`labelEnd`&&(a=n)}let s={type:e[i][1].type===`labelLink`?`link`:`image`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:`label`,start:{...e[i][1].start},end:{...e[a][1].end}},l={type:`labelText`,start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return o=[[`enter`,s,t],[`enter`,c,t]],o=at(o,e.slice(i+1,i+r+3)),o=at(o,[[`enter`,l,t]]),o=at(o,jt(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=at(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=at(o,e.slice(a+1)),o=at(o,[[`exit`,s,t]]),it(e,i,e.length,o),e}function Wn(e,t,n){let r=this,i=r._labelStarts,a,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();a=i[i.length-1]}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(dt(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(zn,u,o?u:d)(t):t===91?e.attempt(Bn,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Vn,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function Gn(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return O(t)?yn(e,a)(t):a(t)}function a(t){return t===41?u(t):gn(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return O(t)?yn(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?vn(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return O(t)?yn(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Kn(e,t,n){let r=this;return i;function i(t){return _n.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(dt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function qn(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var Jn={name:`labelStartImage`,resolveAll:Rn.resolveAll,tokenize:Yn};function Yn(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),o}function o(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelImage`),s):n(t)}function s(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var Xn={name:`labelStartLink`,resolveAll:Rn.resolveAll,tokenize:Zn};function Zn(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var Qn={name:`lineEnding`,tokenize:$n};function $n(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),A(e,t,`linePrefix`)}}var er={name:`thematicBreak`,tokenize:tr};function tr(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||D(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),k(t)?A(e,s,`whitespace`)(t):s(t))}}var nr={continuation:{tokenize:or},exit:cr,name:`list`,tokenize:ar},rr={partial:!0,tokenize:lr},ir={partial:!0,tokenize:sr};function ar(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:ht(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(er,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return ht(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(Rt,r.interrupt?n:u,e.attempt(rr,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return k(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function or(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Rt,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,A(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!k(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(ir,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,A(e,e.attempt(nr,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function sr(e,t,n){let r=this;return A(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function cr(e){e.exit(this.containerState.type)}function lr(e,t,n){let r=this;return A(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!k(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var ur={name:`setextUnderline`,resolveTo:dr,tokenize:fr};function dr(e,t){let n=new wt,r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&n.add(r,1,[]),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type=`setextHeadingText`,o?(n.add(a,0,[[`enter`,s,t]]),n.add(o+1,0,[[`exit`,e[i][1],t]]),e[i][1].end={...e[o][1].end}):e[i][1]=s,n.add(e.length,0,[[`exit`,s,t]]),n.consume(e),e}function fr(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),k(t)?A(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||D(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var pr={tokenize:mr};function mr(e){let t=this,n=e.attempt(Rt,r,e.attempt(this.parser.constructs.flowInitial,i,A(e,e.attempt(this.parser.constructs.flow,i,e.attempt(dn,i)),`linePrefix`)));return n;function r(r){if(r===null)e.consume(r);else return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null)e.consume(r);else return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var hr={resolveAll:yr()},gr=vr(`string`),_r=vr(`text`);function vr(e){return{resolveAll:yr(e===`text`?br:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null)t.consume(e);else return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function yr(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):t[r]&&t[r][1].type===`data`||(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function br(e,t){let n=new wt,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var xr=t({attentionMarkers:()=>kr,contentInitial:()=>Cr,disable:()=>Ar,document:()=>Sr,flow:()=>Tr,flowInitial:()=>wr,insideSpan:()=>Or,string:()=>Er,text:()=>Dr}),Sr={42:nr,43:nr,45:nr,48:nr,49:nr,50:nr,51:nr,52:nr,53:nr,54:nr,55:nr,56:nr,57:nr,62:Bt},Cr={91:bn},wr={[-2]:Qt,[-1]:Qt,32:Qt},Tr={35:En,42:er,45:[ur,er],60:jn,61:ur,95:er,96:Xt,126:Xt},Er={38:Kt,92:Wt},Dr={[-5]:Qn,[-4]:Qn,[-3]:Qn,33:Jn,38:Kt,42:Mt,60:[It,In],91:Xn,92:[wn,Wt],93:Rn,95:Mt,96:nn},Or={null:[Mt,hr]},kr={null:[42,95]},Ar={null:[]};function jr(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:ee(x),check:ee(S),consume:v,enter:y,exit:b,interrupt:ee(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=at(o,e),g(),o[o.length-1]===null?(te(t,0),l.events=jt(a,l.events,l),l.events):[]}function f(e,t){return Nr(p(e),t)}function p(e){return Mr(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,re()}function g(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){D(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,re()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){te(e,t.from)}function S(e,t){t.restore()}function ee(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=ne(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function te(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&it(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function ne(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,re()}}function re(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Mr(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Nr(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
3
+ `;break;case-3:o=`\r
4
+ `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function Pr(e){let t={constructs:st([xr,...(e||{}).extensions||[]]),content:n(St),defined:[],document:n(Et),flow:n(pr),lazy:{},string:n(gr),text:n(_r)};return t;function n(e){return n;function n(n){return jr(t,e,n)}}}function Fr(e){for(;!ln(e););return e}var Ir=/[\0\t\n\r]/g;function Lr(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&=(i.charCodeAt(0)===65279&&c++,void 0);c<i.length;){Ir.lastIndex=c;let n=Ir.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var Rr=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function zr(e){return e.replace(Rr,Br)}function Br(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return ut(n.slice(t?2:1),t?16:10)}return r(n)||e}function Vr(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Ur(e.position):`start`in e||`end`in e?Ur(e):`line`in e||`column`in e?Hr(e):``}function Hr(e){return Wr(e&&e.line)+`:`+Wr(e&&e.column)}function Ur(e){return Hr(e&&e.start)+`-`+Hr(e&&e.end)}function Wr(e){return e&&typeof e==`number`?e:1}var Gr={}.hasOwnProperty;function Kr(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),qr(n)(Fr(Pr(n).document().write(Lr()(e,t,!0))))}function qr(e){let t={afterExit:[],beforeEnter:[],transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:s(Me),autolinkProtocol:C,autolinkEmail:C,atxHeading:s(Oe),blockQuote:s(Ce),characterEscape:C,characterReference:C,codeFenced:s(we),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:s(we,c),codeText:s(Te,c),codeTextData:C,data:C,codeFlowValue:C,definition:s(Ee),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:s(De),hardBreakEscape:s(ke),hardBreakTrailing:s(ke),htmlFlow:s(Ae,c),htmlFlowData:C,htmlText:s(Ae,c),htmlTextData:C,image:s(je),label:c,link:s(Me),listItem:s(Pe),listItemValue:m,listOrdered:s(Ne,p),listUnordered:s(Ne),paragraph:s(Fe),reference:ge,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:s(Oe),strong:s(Ie),thematicBreak:s(Re)},exit:{atxHeading:u(),atxHeadingSequence:ee,autolink:u(),autolinkEmail:Se,autolinkProtocol:xe,blockQuote:u(),characterEscapeValue:w,characterReferenceMarkerHexadecimal:ve,characterReferenceMarkerNumeric:ve,characterReferenceValue:ye,characterReference:be,codeFenced:u(v),codeFencedFence:_,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:w,codeIndented:u(y),codeText:u(ce),codeTextData:w,data:w,definition:u(),definitionDestinationString:S,definitionLabelString:b,definitionTitleString:x,emphasis:u(),hardBreakEscape:u(ae),hardBreakTrailing:u(ae),htmlFlow:u(oe),htmlFlowData:w,htmlText:u(se),htmlTextData:w,image:u(ue),label:fe,labelText:de,lineEnding:ie,link:u(le),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:_e,resourceDestinationString:pe,resourceTitleString:me,resource:he,setextHeading:u(re),setextHeadingLineSequence:ne,setextHeadingText:te,strong:u(),thematicBreak:u()}};Yr(t,(e||{}).mdastExtensions||[]);let n={};return i;function i(e){let r={type:`root`,children:[],position:void 0},i={stack:[r],tokenStack:[],config:t,enter:l,exit:d,buffer:c,resume:f,data:n},s=[],u=[],p=-1;for(;++p<e.length;)u.push(e[p]),(e[p][1].type===`listOrdered`||e[p][1].type===`listUnordered`)&&(e[p][0]===`enter`?s.push(u.length-1):o(u,s.pop()));for(e=u,p=-1;++p<e.length;){let n=t[e[p][0]];e[p][0]===`enter`&&t.beforeEnter.length>0&&a(t.beforeEnter,{...i,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),Gr.call(n,e[p][1].type)&&n[e[p][1].type].call({...i,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),e[p][0]===`exit`&&t.afterExit.length>0&&a(t.afterExit,{...i,sliceSerialize:e[p][2].sliceSerialize},e[p][1])}if(i.tokenStack.length>0){let e=i.tokenStack[i.tokenStack.length-1];(e[1]||Zr).call(i,void 0,e[0])}for(r.position={start:Jr(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Jr(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},p=-1;++p<t.transforms.length;)r=t.transforms[p](r)||r;return r}function a(e,t,n){let r=-1;for(;++r<e.length;)e[r].call(t,n)}function o(e,t){let n=e.length-1,r=t-1,i=-1,a=!1,o,s,c,l,u=[];for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let n=r;for(s=void 0;n--;){let t=e[n];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=n}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),u.push({at:s||r,event:[`exit`,o,t[2]]})}if(t[1].type===`listItemPrefix`){let e={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=e,u.push({at:r,event:[`enter`,e,t[2]]}),c=void 0,l=!0}}}let d=e.splice(t),f=0;for(r=-1;++r<d.length;){for(;f<u.length&&u[f].at===t+r;)e.push(u[f++].event);e.push(d[r])}e[t][1]._spread=a}function s(e,t){return n;function n(n){l.call(this,e(n),n),t&&t.call(this,n)}}function c(){this.stack.push({type:`fragment`,children:[]})}function l(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:Jr(t.start),end:void 0}}function u(e){return t;function t(t){e&&e.call(this,t),d.call(this,t)}}function d(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw Error("Cannot close `"+e.type+"` ("+Vr({start:e.start,end:e.end})+`): it’s not open`);r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||Zr).call(this,e,r[0])),n.position.end=Jr(e.end)}function f(){return et(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function m(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function h(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function _(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function b(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=dt(this.sliceSerialize(e)).toLowerCase()}function x(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function S(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ee(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function te(){this.data.setextHeadingSlurpLineEnding=!0}function ne(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function re(){this.data.setextHeadingSlurpLineEnding=void 0}function C(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&n.type===`text`||(n=Le(),n.position={start:Jr(e.start),end:void 0},t.push(n)),this.stack.push(n)}function w(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=Jr(e.end)}function ie(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=Jr(e.end),this.data.atHardBreak=void 0}else!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(C.call(this,e),w.call(this,e))}function ae(){this.data.atHardBreak=!0}function oe(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function se(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ce(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function le(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function ue(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function de(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=zr(t),n.identifier=dt(t).toLowerCase()}function fe(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function pe(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function me(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function he(){this.data.inReference=void 0}function ge(){this.data.referenceType=`collapsed`}function _e(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=dt(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ve(e){this.data.characterReferenceType=e.type}function ye(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,i;n?(i=ut(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):i=r(t);let a=this.stack[this.stack.length-1];a.value+=i}function be(e){let t=this.stack.pop();t.position.end=Jr(e.end)}function xe(e){w.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function Se(e){w.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function Ce(){return{type:`blockquote`,children:[],position:void 0}}function we(){return{type:`code`,lang:null,meta:null,value:``,position:void 0}}function Te(){return{type:`inlineCode`,value:``,position:void 0}}function Ee(){return{type:`definition`,identifier:``,label:null,title:null,url:``,position:void 0}}function De(){return{type:`emphasis`,children:[],position:void 0}}function Oe(){return{type:`heading`,depth:0,children:[],position:void 0}}function ke(){return{type:`break`,position:void 0}}function Ae(){return{type:`html`,value:``,position:void 0}}function je(){return{type:`image`,title:null,url:``,alt:null,position:void 0}}function Me(){return{type:`link`,title:null,url:``,children:[],position:void 0}}function Ne(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[],position:void 0}}function Pe(e){return{type:`listItem`,spread:e._spread,checked:null,children:[],position:void 0}}function Fe(){return{type:`paragraph`,children:[],position:void 0}}function Ie(){return{type:`strong`,children:[],position:void 0}}function Le(){return{type:`text`,value:``,position:void 0}}function Re(){return{type:`thematicBreak`,position:void 0}}}function Jr(e){return{line:e.line,column:e.column,offset:e.offset}}function Yr(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?Yr(e,r):Xr(e,r)}}function Xr(e,t){let n;for(n in t)if(Gr.call(t,n))switch(n){case`canContainEols`:case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`afterExit`:case`beforeEnter`:{let r=t[n];r&&e[n].push(r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function Zr(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+Vr({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Vr({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+Vr({start:t.start,end:t.end})+`) is still open`)}function Qr(e){let t=this;t.parser=n;function n(n){return Kr(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}var $r=(function(e){if(e==null)return ii;if(typeof e==`function`)return ri(e);if(typeof e==`object`)return Array.isArray(e)?ei(e):ti(e);if(typeof e==`string`)return ni(e);throw Error(`Expected function, string, or object as test`)});function ei(e){let t=[],n=-1;for(;++n<e.length;)t[n]=$r(e[n]);return ri(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function ti(e){let t=e;return ri(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function ni(e){return ri(t);function t(t){return t&&t.type===e}}function ri(e){return t;function t(t,n,r){return!!(ai(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function ii(){return!0}function ai(e){return typeof e==`object`&&!!e&&`type`in e}var oi=$r([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]),si={}.hasOwnProperty;function ci(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&si.call(t,e)){let n=String(t[e]);i=si.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var li={}.hasOwnProperty;function ui(e,t){let n=-1,r;if(t.extensions)for(;++n<t.extensions.length;)ui(e,t.extensions[n]);for(r in t)if(li.call(t,r))switch(r){case`extensions`:break;case`unsafe`:case`join`:di(e[r],t[r]);break;case`handlers`:fi(e[r],t[r]);break;default:e.options[r]=t[r]}return e}function di(e,t){t&&e.push(...t)}function fi(e,t){t&&Object.assign(e,t)}function pi(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),mi);return i(),o}function mi(e,t,n){return`>`+(n?``:` `)+e}function hi(e,t){return gi(e,t.inConstruct,!0)&&!gi(e,t.notInConstruct,!1)}function gi(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function _i(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;){let e=n.unsafe[i];if(e.character===`
5
+ `&&!e.before&&!e.after&&hi(n.stack,e))return/[\t ]/.test(r.before)?``:` `}return`\\
6
+ `}function vi(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function yi(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^\n\r ]/.test(e.value)||/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(e.value))}function bi(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function xi(e,t,n,r){let i=bi(n),a=e.value||``;if(yi(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,Si);return e(),t}let o=n.createTracker(r),s=i.repeat(Math.max(vi(a,i)+1,3)),c=n.enter(`codeFenced`),l=i==="`"?`GraveAccent`:`Tilde`,u=o.move(s);if(e.lang){let t=n.enter(`codeFencedLang${l}`);u+=o.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...o.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${l}`);u+=o.move(` `),u+=o.move(n.safe(e.meta,{before:u,after:`
7
+ `,encode:["`"],...o.current()})),t()}return u+=o.move(`
8
+ `),a&&(u+=o.move(a+`
9
+ `)),u+=o.move(s),c(),u}function Si(e,t,n){return(n?``:` `)+e}function Ci(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function wi(e,t,n,r){let i=Ci(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
10
+ `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function Ti(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Ei(e){let t=e.codePointAt(0);return t===void 0?``:String.fromCodePoint(t)}function Di(e){let t=e.codePointAt(e.length-2);return t!==void 0&&t>65535?e.slice(-2):e.slice(-1)}function Oi(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function ki(e,t,n){let r=At(e),i=At(t);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 Ai(e){if(e.charCodeAt(0)!==60)return;let t=e.charCodeAt(1);if(t===33){let t=e.charCodeAt(2);return t===45?2:t===91?5:E(t)?4:void 0}if(t===63)return 3;let n=t===47,r=n?2:1,i=r,a=e.charCodeAt(i);if(!E(a))return;for(;a===45||ft(a);)a=e.charCodeAt(++i);let o=e.slice(r,i).toLowerCase();return!n&&a!==47&&An.includes(o)?1:kn.includes(o)?6:7}var ji=new Map([[`*`,!1],[`_`,!0]]);function Mi(e,t,n){let r=new Set;for(let i of e){let e=n.get(i);if(e&&i.attention&&t.some(e=>e.attention===i.attention))for(let t of e.tokens)r.add(t.attention)}let i=[];for(let t of e)t.attention&&r.delete(t.attention)&&i.push(t.attention);return i.reverse(),i}function Ni(e,t,n){let r=[],i=new Map,a=new Map,o=0;for(;o<e.length;){if(!e[o].attention){o++;continue}let s=e[o].value.charAt(0),c=ji.get(s),l=o+1;for(;l<e.length&&e[l].attention&&e[l].value.charAt(0)===s;)l++;let u=o?e[o-1].value:t,d=At(u.charCodeAt(u.length-1)),f=At((l<e.length?e[l].value:n).charCodeAt(0)),p=!f||f===2&&!!d,m=!d||d===2&&!!f,h={tokens:e.slice(o,l),markers:[],start:0,end:0,open:c?p&&(!!d||!m):p,close:c?m&&(!!f||!p):m,split:c!==void 0};for(let e of h.tokens){i.set(e,[...h.tokens]),a.set(e,h);let t=e.value.length;for(;t--;)h.markers.push(e)}h.end=h.markers.length,r.push(h),o=l}for(Li(r,i),o=-1;++o<e.length;){let t=i.get(e[o]);if(t)return{attention:Mi(e,t,a),index:o}}}function Pi(e,t,n){return Wi(zi(e,t,n),n.before,n.after)}function Fi(e,t){let n=e[t?0:e.length-1];if(!n||n.attention)return;let r=t?Ei(n.value):Di(n.value),i=Oi(r.codePointAt(0));if(t)n.value=i+n.value.slice(r.length);else{let e=n.value.slice(0,n.value.length-r.length),t=0;for(;e.charCodeAt(e.length-1-t)===92;)t++;t%2&&(e+=`\\`),n.value=e+i}}function Ii(e,t,n,r,i){for(let a of n.attention){let o=t.get(a)||a.sequences[0];for(let s of a.sequences){if(s===o)continue;let c=new Map(t);c.set(a,s);let l=Ui(e,c,r,i),u=Ni(l,r,i);if(!u||u.index>n.index)return{chosen:c,mistake:u,tokens:l}}}}function Li(e,t){let n=new Map;for(let r of e){let e=r.tokens[0].value.charAt(0),i=n.get(e);i||(i=[],n.set(e,i));let a=r.close?i.length:0;for(;a--&&r.start<r.end;){let e=i[a],n=e.end-e.start,o=r.end-r.start;if(r.split?(e.close||r.open)&&o%3&&!((n+o)%3):n!==e.markers.length||n!==o)continue;let s=r.split?n>1&&o>1?2:1:o,c=e.markers.slice(e.end-s,e.end),l=r.markers.slice(r.start,r.start+s),u=c[0],d=l[0];if(u===c[s-1]&&u.value.length===s&&d===l[s-1]&&d.value.length===s&&u.attention===d.attention)t.delete(u),t.delete(d);else{let e=[...new Set([...c,...l])];for(let n of e){let r=t.get(n);r&&r.push(...e)}}e.end-=s,r.start+=s,e.start===e.end&&i.splice(a,1),a=i.length}r.open&&r.start<r.end&&i.push(r)}}function Ri(e,t,n){if(t.length===0)throw Error("Cannot serialize `"+e+"` as attention without markers, expected one or more markers");if(n.length===0)throw Error("Cannot serialize `"+e+"` as attention without sizes, expected one or more sizes");for(let t of n)if(!Number.isSafeInteger(t)||t<1)throw Error("Cannot serialize `"+e+"` as attention with `"+t+"` as size, expected positive integer");let r=[];for(let i of t){if(i.length!==1)throw Error("Cannot serialize `"+e+"` as attention with `"+i+"` as marker, expected a single ascii character");if(!_t(i.charCodeAt(0)))throw Error("Cannot serialize `"+e+"` as attention with `"+i+"` as marker, expected ascii punctuation");for(let e of n)r.push(i.repeat(e))}return r}function zi(e,t,n){let r=t.indexStack,i=e.children||[],a=[],o=-1,s=n.before;r.push(-1);let c=t.createTracker(n);for(;++o<i.length;){let l=i[o],u;if(r[r.length-1]=o,o+1<i.length){let n=t.handle.handlers[i[o+1].type];n&&n.peek&&(n=n.peek),u=n?Ei(n(i[o+1],e,t,{before:``,after:``,...c.current()})):``}else u=n.after;let d=a[a.length-1];typeof d==`string`&&(s===`\r`||s===`
11
+ `)&&l.type===`html`&&Ai(l.value)!==7&&(a[a.length-1]=d.replace(/(\r?\n|\r)$/,` `),s=` `,c=t.createTracker(n),c.move(Wi(a,n.before,n.after)));let f=t.handle.handlers[l.type];if(f&&f.attention){let e=Bi(l,f.attention,t,c);if(!e)continue;a.push(e),s=Di(e.sequences[0])}else{let n=t.handle(l,e,t,{...c.current(),after:u,before:s});if(!n)continue;c.move(n),a.push(n),s=Di(n)}}return r.pop(),a}function Bi(e,t,n,r){let{construct:i,markers:a,sizes:o}=t(e,n),s=Ri(e.type,a,o),c=s[0],l=n.enter(i),u=n.createTracker(r.current());u.move(c);let d=zi(e,n,{...u.current(),before:c,after:c});if(l(),d.length!==0)return r.move(c),r.move(Wi(d,c,c)),r.move(c),{children:d,sequences:s}}function Vi(e,t,n,r){let i=Ui(e,t,n,r),a=Ni(i,n,r);for(;a;){let o=Ii(e,t,a,n,r);if(!o)return;t=o.chosen,i=o.tokens,a=o.mistake}return i}function Hi(e,t,n,r){let i=n,a=-1;for(;++a<e.length;){let o=e[a];if(typeof o==`string`){i=``;continue}let s=a===e.length-1?r:``,c=o.sequences.find(function(t){let r=t.charAt(0);return r!==i.charAt(0)&&r!==s.charAt(0)||e.length===1&&ji.has(r)&&t.length>n.length})||o.sequences[0];c!==o.sequences[0]&&t.set(o,c),Hi(o.children,t,c,c),i=c}}function Ui(e,t,n,r){let i=[],a,o=Di(n),s=-1;for(;++s<e.length;){let n=e[s];if(typeof n==`string`){let e={value:n,attention:void 0};a&&a===Ei(n)&&Fi([e],!0),a=void 0,i.push(e),e.value&&(o=Di(e.value));continue}let c=t.get(n)||n.sequences[0],l=c.charAt(0),u=e[s+1],d=o,f=Ei(u===void 0?r:typeof u==`string`?u:t.get(u)||u.sequences[0]),p=Ui(n.children,t,c,c),m=p[0].value,h=ki(d.charCodeAt(d.length-1),m.charCodeAt(0),l);h.inside&&Fi(p,!0);let g=Di(p[p.length-1].value),_=ki(f.charCodeAt(0),g.charCodeAt(g.length-1),l);_.inside&&Fi(p,!1),h.outside&&d!==`
12
+ `&&d!==`\r`&&Fi(i,!1),_.outside&&(a=f),i.push({value:c,attention:n},...p,{value:c,attention:n}),o=c.charAt(c.length-1)}return i}function Wi(e,t,n){let r=new Map;Hi(e,r,t,n);let i=(r.size>0?Vi(e,r,t,n):void 0)||Vi(e,new Map,t,n)||Ui(e,new Map,t,n),a=``;for(let e of i)a+=e.value;return a}Gi.attention=Ki,Gi.peek=qi;function Gi(e,t,n,r){let i=n.enter(`phrasing`),a=Bi(e,Ki,n,n.createTracker(r)),o=a?Wi([a],r.before,r.after):``;return i(),o}function Ki(e,t){return{construct:`emphasis`,markers:Ti(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[1]}}function qi(e,t,n){return n.options.emphasis||`*`}function Ji(e){return e}var Yi=[],Xi=`skip`;function Zi(e,t,n,r){if(!e||typeof e!=`object`)throw Error("Unexpected value `"+e+"` for `tree`, expected node");let i=!0,a,o,s,c;if(typeof n==`function`||n&&typeof n==`object`?(a=t,o=n,r&&(i=!1)):(o=t,n&&(i=!1)),typeof o==`function`)s=o;else if(o&&typeof o==`object`){if(o.enter!==null&&o.enter!==void 0){if(typeof o.enter==`function`)s=o.enter;else throw Error("Unexpected value `"+o.enter+"` for `visitors.enter`, expected optional visitor")}if(typeof o.exit==`function`)c=o.exit;else throw Error("Unexpected value `"+o.exit+"` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)")}else throw Error("Unexpected value `"+o+"` for `enter` or `visitors`, expected visitor or object with visitors");let l=$r(a),u=i?1:-1;d(e,void 0,[])();function d(e,t,n){let r=e&&typeof e==`object`?e:{};if(typeof r.type==`string`){let t=typeof r.tagName==`string`?r.tagName:typeof r.name==`string`?r.name:void 0;Object.defineProperty(o,"name",{value:`node (`+Ji(e.type+(t?`<`+t+`>`:``))+`)`})}return o;function o(){let r=!a||l(e,t,n[n.length-1]||void 0),o=Yi;if(s&&r&&(o=Qi(s(e,n,t)),o[0]===!1))return o;if(`children`in e&&e.children){let t=e;if(t.children&&o[0]!==`skip`){let e=(i?-1:t.children.length)+u,r=[...n,t];for(;e>-1&&e<t.children.length;){let n=d(t.children[e],e,r)();if(n[0]===!1)return n;e=typeof n[1]==`number`?n[1]:e+u}}}if(c&&r){let r=Qi(c(e,n,t));if(r[0]===`skip`)throw Error("Unexpected value `"+r[0]+"` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing");if(r[0]===!1||typeof r[1]==`number`)return r}return o}}}function Qi(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?Yi:[e]}function $i(e,t,n,r){let i,a,o;typeof n==`function`||n&&typeof n==`object`?(i=t,a=n,o=r):(a=t,o=n),typeof a==`function`?Zi(e,i,ta(a),o):Zi(e,i,ea(a),o)}function ea(e){return!e||typeof e!=`object`?e:{enter:typeof e.enter==`function`?ta(e.enter):e.enter,exit:typeof e.exit==`function`?ta(e.exit):e.exit}}function ta(e){return t;function t(t,n,r){return e(t,r,n[n.length-1])}}function na(e,t){let n=!1;return $i(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&et(e)&&(t.options.setext||n))}function ra(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(na(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
13
+ `,after:`
14
+ `});return r(),t(),o+`
15
+ `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
16
+ `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
17
+ `,...a.current()}),u=l.charCodeAt(0);return(u===9||u===32)&&(l=Oi(u)+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}ia.peek=aa;function ia(e){return e.value||``}function aa(){return`<`}oa.peek=sa;function oa(e,t,n,r){let i=Ci(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function sa(){return`!`}ca.peek=la;function ca(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function la(){return`!`}ua.peek=da;function ua(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e);if(!e.atBreak)continue;let i;for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function da(){return"`"}function fa(e,t){let n=et(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][+\-.a-z]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}pa.peek=ma;function pa(e,t,n,r){let i=Ci(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r);if(fa(e,n)){let t=n.stack;n.stack=t.filter(function(e){return e!==`phrasing`});let r=n.enter(`autolink`),i=o.move(`<`);return i+=o.move(n.containerPhrasing(e,{before:i,after:`>`,...o.current()})),i+=o.move(`>`),r(),n.stack=t,i}let s=n.enter(`link`),c=n.enter(`label`),l=o.move(`[`),u=n.containerPhrasing(e,{before:l,after:`](`,...o.current()});l+=o.move(u),c(),l+=o.move(`](`);let d=/[\0- \u007F]/.test(e.url),f=r.before.charAt(r.before.length-1),p=e.title||void 0;if(!p&&!d&&(f===`
18
+ `||f===`\r`)){let e=0;for(;e<u.length&&u.charCodeAt(e)!==93;)e+=u.charCodeAt(e)===92?2:1;u.charCodeAt(e+1)===58&&(p=``)}return!e.url&&typeof p==`string`||d?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:typeof p==`string`?` `:`)`,...o.current()}))),c(),typeof p==`string`&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(p,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function ma(e,t,n){return fa(e,n)?`<`:`[`}ha.peek=ga;function ha(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function ga(){return`[`}function _a(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function va(e){let t=_a(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function ya(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function ba(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function xa(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?ya(n):_a(n),s=e.ordered?o===`.`?`)`:`.`:va(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if(o!==`*`&&o!==`-`||!t||t.children&&t.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||(c=!0),ba(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function Sa(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Ca(e,t,n,r){let i=Sa(n),a=n.bulletCurrent||_a(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function wa(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}function Ta(e,t,n,r){if(!e.children.some(function(e){return oi(e)}))return n.containerFlow(e,r);let i=n.enter(`phrasing`),a=n.containerPhrasing(e,r);return i(),a}function Ea(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Da.attention=Oa,Da.peek=ka;function Da(e,t,n,r){let i=n.enter(`phrasing`),a=Bi(e,Oa,n,n.createTracker(r)),o=a?Wi([a],r.before,r.after):``;return i(),o}function Oa(e,t){return{construct:`strong`,markers:Ea(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[2]}}function ka(e,t,n){return n.options.strong||`*`}function Aa(e,t,n,r){let i=t?t.children:[],a=n.indexStack[n.indexStack.length-1];return n.safe(e.value,{...r,afterNode:i[a+1],beforeNode:i[a-1]})}function ja(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Ma(e,t,n){let r=(ba(n)+(n.options.ruleSpaces?` `:``)).repeat(ja(n));return n.options.ruleSpaces?r.slice(0,-1):r}var Na={blockquote:pi,break:_i,code:xi,definition:wi,emphasis:Gi,hardBreak:_i,heading:ra,html:ia,image:oa,imageReference:ca,inlineCode:ua,link:pa,linkReference:ha,list:xa,listItem:Ca,paragraph:wa,root:Ta,strong:Da,text:Aa,thematicBreak:Ma},Pa=[Fa];function Fa(e,t,n,r){if(t.type===`code`&&yi(t,r)&&(e.type===`list`||e.type===t.type&&yi(e,r)))return!1;if(`spread`in n&&typeof n.spread==`boolean`){if(n.spread)return 1;if(e.type===`html`){let t=Ai(e.value);if(t===void 0||t===6||t===7)return 1}if(e.type===`blockquote`&&t.type===`blockquote`||(e.type===`definition`||e.type===`paragraph`)&&t.type===`list`&&(t.ordered&&typeof t.start==`number`&&t.start!==1||t.children.length>0&&t.children[0].children.length===0)||e.type===`paragraph`&&t.type===`thematicBreak`&&ba(r)===`-`&&!r.options.ruleSpaces)return 1;let i=e;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(t.type===`code`&&yi(t,r))return 1;if(t.type===`html`){let e=Ai(t.value);if(e===void 0||e===7)return 1}return(e.type===`paragraph`||e!==i)&&(t.type===`definition`||t.type===`heading`&&na(t,r)||t.type===`paragraph`)?1:0}}for(var Ia=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`],La=[{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:Ia},{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:Ia},{atBreak:!0,before:`\\d+`,character:`)`},{character:`)`,inConstruct:`destinationRaw`},{atBreak:!0,character:`*`,after:`(?:[ \r
23
+ *])`},{character:`*`,inConstruct:`phrasing`,notInConstruct:Ia},{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:Ia},{character:`<`,inConstruct:`destinationLiteral`},{atBreak:!0,character:`=`},{atBreak:!0,character:`>`},{character:`>`,inConstruct:`destinationLiteral`},{atBreak:!0,character:`[`},{character:`[`,inConstruct:`phrasing`,notInConstruct:Ia},{character:`[`,inConstruct:[`label`,`reference`]},{character:`\\`,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:`]`,inConstruct:[`label`,`reference`]},{atBreak:!0,character:`_`},{character:`_`,inConstruct:`phrasing`,notInConstruct:Ia},{atBreak:!0,character:"`"},{character:"`",inConstruct:[`codeFencedLangGraveAccent`,`codeFencedMetaGraveAccent`]},{character:"`",inConstruct:`phrasing`,notInConstruct:Ia},{atBreak:!0,character:`~`},{character:`<`,inConstruct:`autolink`},{character:`>`,inConstruct:`autolink`},{character:``,inConstruct:`autolink`}],Ra=-1;++Ra<33;)La.push({character:String.fromCharCode(Ra),inConstruct:`autolink`});function za(e){return e.label||!e.identifier?e.label||``:zr(e.identifier)}function Ba(e){if(!e._compiled){let t=(e.atBreak?`[\\r\\n][\\t ]*`:``)+(e.before?`(?:`+e.before+`)`:``);e._compiled=RegExp((e.beforeNode?`^`:t?`(`+t+`)`:``)+(/[$()*+.?[\\\]^{|}]/.test(e.character)?`\\`:``)+e.character+(e.afterNode?`$`:e.after?`(?:`+e.after+`)`:``),e.unicode?`gu`:`g`)}return e._compiled}function Va(e,t,n){let r=t.indexStack,i=e.children||[],a=t.createTracker(n),o=[],s=-1;for(r.push(-1);++s<i.length;){let n=i[s];r[r.length-1]=s,o.push(a.move(t.handle(n,e,t,{before:`
27
+ `,after:`
28
+ `,...a.current()}))),n.type!==`list`&&(t.bulletLastUsed=void 0),s<i.length-1&&o.push(a.move(Ha(n,i[s+1],e,t)))}return r.pop(),o.join(``)}function Ha(e,t,n,r){let i=r.join.length;for(;i--;){let a=r.join[i](e,t,n,r);if(a===!0||a===1)break;if(typeof a==`number`)return`
29
+ `.repeat(1+a);if(a===!1)return`
30
+
31
+ <!---->
32
+
33
+ `}return`
34
+
35
+ `}var Ua=/\r?\n|\r/g;function Wa(e,t){let n=[],r=0,i=0,a;for(;a=Ua.exec(e);)o(e.slice(r,a.index)),n.push(a[0]),r=a.index+a[0].length,i++;return o(e.slice(r)),n.join(``);function o(e){n.push(t(e,i,!e))}}var Ga={}.hasOwnProperty;function Ka(e,t,n){let r=(n.before||``)+(t||``)+(n.after||``),i=[],a=[],o={},s=e.stack.includes(`autolink`),c=n.before?n.before.length:0,l=r.length-(n.after?n.after.length:0),u=-1;for(;++u<e.unsafe.length;){let t=e.unsafe[u];if(!hi(e.stack,t)||!qa(t.beforeNode,n.beforeNode)||!qa(t.afterNode,n.afterNode))continue;let a=e.compilePattern(t),s=t.beforeNode?c:0,d=r.slice(s,t.afterNode?l:void 0),f;for(;f=a.exec(d);){let e=!!(t.before||t.atBreak),n=!!t.after,r=s+f.index+(e?f[1].length:0);Ga.call(o,r)?(o[r].before&&!e&&(o[r].before=!1),o[r].after&&!n&&(o[r].after=!1)):(i.push(r),o[r]={before:e,after:n})}}i.sort(Ja);let d=c;for(u=-1;++u<i.length;){let e=i[u];if(!(e<d||e>=l)){if(r.charAt(e)===`_`&&e>0&&At(r.charCodeAt(e-1))===void 0&&!Ga.call(o,e-1)&&!(e-1===c&&/[*_]/.test(r.charAt(c-1)))){let t=e+1;for(;t<l&&r.charAt(t)===`_`;)t++;let n=t-e-1;if(i[u+n]===t-1&&t<r.length&&At(r.charCodeAt(t))===void 0&&!Ga.call(o,t)&&!(t===l-1&&/[*_]/.test(r.charAt(l)))){u+=n;continue}}if(!(e+1<l&&i[u+1]===e+1&&o[e].after&&!o[e+1].before&&!o[e+1].after||e-1>=c&&i[u-1]===e-1&&o[e].before&&!o[e-1].before&&!o[e-1].after)){if(d!==e){let t=r.slice(d,e);a.push(s?t:Ya(t,`\\`))}d=e+1,s?a.push(`%`+r.charCodeAt(e).toString(16).toUpperCase().padStart(2,`0`)):/[!-/:-@[-`{-~]/.test(r.charAt(e))&&(!n.encode||!n.encode.includes(r.charAt(e)))?a.push(`\\`+r.charAt(e)):a.push(Oi(r.charCodeAt(e)))}}}let f=r.slice(d,l);return a.push(s?f:Ya(f,n.after)),a.join(``)}function qa(e,t){return e?t?typeof e==`string`?e===t.type:e.includes(t.type):!1:!0}function Ja(e,t){return e-t}function Ya(e,t){let n=/\\(?=[!-/:-@[-`{-~])/g,r=[],i=[],a=e+t,o=-1,s=0,c;for(;c=n.exec(a);)r.push(c.index);for(;++o<r.length;)s!==r[o]&&i.push(e.slice(s,r[o])),i.push(`\\`),s=r[o];return i.push(e.slice(s)),i.join(``)}function Xa(e){let t=e||{},n=t.now||{},r=t.lineShift||0,i=n.line||1,a=n.column||1;return{move:c,current:o,shift:s};function o(){return{now:{line:i,column:a},lineShift:r}}function s(e){r+=e}function c(e){let t=e||``,n=t.split(/\r?\n|\r/g),o=n[n.length-1];return i+=n.length-1,a=n.length===1?a+o.length:1+o.length+r,t}}function Za(e,t){let n=t||{},r={associationId:za,bulletCurrent:void 0,bulletLastUsed:void 0,containerPhrasing:to,containerFlow:no,createTracker:Xa,compilePattern:Ba,enter:a,handlers:{...Na},handle:void 0,indentLines:Wa,indexStack:[],join:[...Pa],options:{},safe:ro,stack:[],unsafe:[...La]};ui(r,n),r.options.tightDefinitions&&r.join.push(eo),r.handle=ci(`type`,{invalid:Qa,unknown:$a,handlers:r.handlers});let i=r.handle(oi(e)?{type:`root`,children:[e]}:e,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 a(e){return r.stack.push(e),t;function t(){r.stack.pop()}}}function Qa(e){throw Error("Cannot handle value `"+e+"`, expected node")}function $a(e){throw Error("Cannot handle unknown node `"+e.type+"`")}function eo(e,t){if(e.type===`definition`&&e.type===t.type)return 0}function to(e,t){return Pi(e,this,t)}function no(e,t){return Va(e,this,t)}function ro(e,t){return Ka(this,e,t)}function io(e){let t=this;t.compiler=n;function n(n){return Za(n,{...t.data(`settings`),...e,extensions:t.data(`toMarkdownExtensions`)||[]})}}function ao(e){if(e)throw e}var oo=n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function so(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function co(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a)r(a);else{for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?lo(s,i)(...o):r(null,...o)}}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function lo(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var uo=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=Vr(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Object.defineProperties(uo.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}});var fo={basename:po,dirname:mo,extname:ho,join:go,sep:`/`};function po(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);yo(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function mo(e){if(yo(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function ho(e){yo(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}}else n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function go(...e){let t=-1,n;for(;++t<e.length;)yo(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:_o(n)}function _o(e){yo(e);let t=e.codePointAt(0)===47,n=vo(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function vo(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function yo(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var bo={cwd:xo};function xo(){return`/`}function So(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function Co(e){if(typeof e==`string`)e=new URL(e);else if(!So(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return wo(e)}function wo(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var To=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],Eo=class{constructor(e){let t;t=e?So(e)?{path:e}:typeof e==`string`||Ao(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:bo.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<To.length;){let e=To[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)To.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?fo.basename(this.path):void 0}set basename(e){Oo(e,`basename`),Do(e,`basename`),this.path=fo.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?fo.dirname(this.path):void 0}set dirname(e){ko(this.basename,`dirname`),this.path=fo.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?fo.extname(this.path):void 0}set extname(e){if(Do(e,`extname`),ko(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=fo.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){So(e)&&(e=Co(e)),Oo(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?fo.basename(this.path,this.extname):void 0}set stem(e){Oo(e,`stem`),Do(e,`stem`),this.path=fo.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new uo(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function Do(e,t){if(e&&e.includes(fo.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+fo.sep+"`")}function Oo(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function ko(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function Ao(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var jo=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),Mo=e(oo(),1),No={}.hasOwnProperty,Po=new class e extends jo{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=co()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,Mo.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(Lo(`data`,this.frozen),this.namespace[e]=t,this):No.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Lo(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=Bo(e),n=this.parser||this.Parser;return Fo(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),Fo(`process`,this.parser||this.Parser),Io(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=Bo(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);Ho(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),Fo(`processSync`,this.parser||this.Parser),Io(`processSync`,this.compiler||this.Compiler),this.process(e,r),zo(`processSync`,`process`,t),n;function r(e,r){t=!0,ao(e),n=r}}run(e,t,n){Ro(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=Bo(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),zo(`runSync`,`run`,n),r;function i(e,t){ao(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=Bo(t),r=this.compiler||this.Compiler;return Io(`stringify`,r),Ro(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(Lo(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw 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");o(e.plugins),e.settings&&(r.settings=(0,Mo.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;)i(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];so(o)&&so(r)&&(r=(0,Mo.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function Fo(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function Io(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function Lo(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Ro(e){if(!so(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function zo(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function Bo(e){return Vo(e)?e:new Eo(e)}function Vo(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function Ho(e){return typeof e==`string`||Uo(e)}function Uo(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}function j(e){this.content=e}j.prototype={constructor:j,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new j(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new j(n)},addToStart:function(e,t){return new j([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new j(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new j(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=j.from(e),e.size?new j(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=j.from(e),e.size?new j(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=j.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},j.from=function(e){if(e instanceof j)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new j(t)};function Wo(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a)n+=i.nodeSize;else{if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&qo(e.charCodeAt(r-1))&&Ko(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=Wo(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}}function Go(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s)n-=c,r-=c;else{if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&qo(e.charCodeAt(i-1))&&Ko(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=Go(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}}function Ko(e){return e>=56320&&e<57344}function qo(e){return e>=55296&&e<56320}var M=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))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 t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Wo(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Go(this,e,t,n)}findIndex(e){if(e==0)return Yo(0,e);if(e==this.size)return Yo(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?Yo(t+1,i):Yo(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};M.empty=new M([],0);var Jo={index:0,offset:0};function Yo(e,t){return Jo.index=e,Jo.offset=t,Jo}function Xo(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Xo(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Xo(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var N=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Xo(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};N.none=[];var Zo=class extends Error{},P=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=$o(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Qo(this.content,t+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(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(M.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};P.empty=new P(M.empty,0,0);function Qo(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Qo(a.content,t-i-1,n-i-1)))}function $o(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=$o(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function es(e,t,n){if(n.openStart>e.depth)throw new Zo(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Zo(`Inconsistent open depths`);return ts(e,t,n,0)}function ts(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=ts(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}if(!n.content.size)return ss(a,ls(e,t,r));if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return ss(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}{let{start:i,end:o}=us(n,e);return ss(a,cs(e,i,o,t,r))}}function ns(e,t){if(!t.type.compatibleContent(e.type))throw new Zo(`Cannot join `+t.type.name+` onto `+e.type.name)}function rs(e,t,n){let r=e.node(n);return ns(r,t.node(n)),r}function is(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function as(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(is(e.nodeAfter,r),a++));for(let e=a;e<o;e++)is(i.child(e),r);t&&t.depth==n&&t.textOffset&&is(t.nodeBefore,r)}function ss(e,t){if(!e.type.validContent(t))throw new Zo(`Invalid content for node `+e.type.name);return e.copy(t)}function cs(e,t,n,r,i){let a=e.depth>i&&rs(e,t,i+1),o=r.depth>i&&rs(n,r,i+1),s=[];return as(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(ns(a,o),is(ss(a,cs(e,t,n,r,i+1)),s)):(a&&is(ss(a,ls(e,t,i+1)),s),as(t,n,i,s),o&&is(ss(o,ls(n,r,i+1)),s)),as(r,null,i,s),new M(s)}function ls(e,t,n){let r=[];return as(null,e,n,r),e.depth>n&&is(ss(rs(e,t,n+1),ls(e,t,n+1)),r),as(t,null,n,r),new M(r)}function us(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(M.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var ds=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.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 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 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,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return N.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive!==!1||r&&i[a].isInSet(r.marks)||(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive!==!1||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new hs(this,e,n);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 t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=ms.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else ms.set(t,r=new fs);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%ps,i}},fs=class{constructor(){this.elts=[],this.i=0}},ps=12,ms=new WeakMap,hs=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}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)}},gs=Object.create(null),_s=class e{constructor(e,t,n,r=N.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||M.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,t,n,r=0){this.content.nodesBetween(e,t,n,r,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,t,n,r){return this.content.textBetween(e,t,n,r)}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,t,n){return this.type==e&&Xo(this.attrs,t||e.defaultAttrs||gs)&&N.sameSet(this.marks,n||N.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return P.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new P(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return es(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return ds.resolveCached(this,e)}resolveNoCache(e){return ds.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}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()+`)`),bs(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=M.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.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),xs(this.type.attrs,this.attrs,`node`,this.type.name);let e=N.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];xs(n.type.attrs,n.attrs,`mark`,n.type.name),e=n.addToSet(e)}if(!N.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t 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(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=M.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}};_s.prototype.text=void 0;var vs=(()=>{let{stack:e}=Error(`/`);if(!e||!/\n\s*at\s/.test(e))return e=>e;let t=Object.create(null);return e=>(t[e],e)})(),ys=class e extends _s{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):bs(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return vs(this.text.slice(e,t))}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(vs(this.text.slice(e,t)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function bs(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}function xs(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}var Ss=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Cs(t,n);if(r.next==null)return e.empty;let i=ws(r);r.next&&r.err(`Unexpected trailing text`);let a=Ps(js(i));return Fs(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}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:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return M.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];a.isLeaf||a.hasRequiredAttrs()||a.name in t||r.type&&!o.validEnd||(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
39
+ `)}};Ss.empty=new Ss(!0);var Cs=class{constructor(e,t){this.string=e,this.nodeTypes=t,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 SyntaxError(e+` (in content expression '`+this.string+`')`)}};function ws(e){let t=[];do t.push(Ts(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function Ts(e){let t=[];do t.push(Es(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function Es(e){let t=As(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=Os(e,t);else break;return t}function Ds(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function Os(e,t){let n=Ds(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:Ds(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function ks(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function As(e){if(e.eat(`(`)){let t=ws(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=ks(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function js(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function Ms(e,t){return t-e}function Ns(e,t){let n=[];return r(t),n.sort(Ms);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function Ps(e){let t=Object.create(null);return n(Ns(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);Ns(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new Ss(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Ms);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Fs(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function Is(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Ls(e,t){let n=Object.create(null);for(let r in e){let i=e[r],a=t&&t[r];if(a===void 0){if(i.hasDefault)a=i.default;else throw RangeError(`No value supplied for attribute `+r)}else i.validate&&i.validate(a);n[r]=a}return n}function Rs(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Vs(e,r,t[r]);return n}var zs=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=Rs(e,n.attrs),this.defaultAttrs=Is(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Ss.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:Ls(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new _s(this,this.computeAttrs(e),M.from(t),N.setFrom(n))}createChecked(e=null,t,n){return t=M.from(t),this.checkContent(t),new _s(this,this.computeAttrs(e),t,N.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=M.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(M.empty,!0);return i?new _s(this,e,t.append(i),N.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw 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 t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:N.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Bs(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Vs=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Bs(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Hs=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Rs(e,r.attrs),this.excluded=null;let i=Is(this.attrs);this.instance=i?new N(this,i):null}create(e=null){return!e&&this.instance?this.instance:new N(this,Ls(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}},Us=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=j.from(e.nodes),t.marks=j.from(e.marks||{}),this.nodes=zs.compile(this.spec.nodes,this),this.marks=Hs.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=Ss.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?Ws(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:Ws(this,n.split(` `))}this.nodeFromJSON=e=>_s.fromJSON(this,e),this.markFromJSON=e=>N.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof zs))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new ys(n,n.defaultAttrs,e,N.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function Ws(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function Gs(e){return e.tag!=null}function Ks(e){return e.style!=null}var qs=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(Gs(e))this.tags.push(e);else if(Ks(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new nc(this,t,!1);return n.addAll(e,N.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new nc(this,t,!0);return n.addAll(e,N.none,t.from,t.to),P.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(ic(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=ac(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=ac(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},Js={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},Ys={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Xs={ol:!0,ul:!0},Zs=1,Qs=2,$s=4;function ec(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?Zs:0)|(t===`full`?Qs:0)}var tc=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=N.none,this.match=i||(a&$s?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(M.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Zs)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=M.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(M.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Js.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},nc=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=ec(null,t.preserveWhitespace,0)|(n?$s:0);i=r?new tc(r.type,r.attrs,N.none,!0,t.topMatch||r.type.contentMatch,a):n?new tc(null,null,N.none,!0,null,a):new tc(e.schema.topNodeType,null,N.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&Qs?`full`:this.localPreserveWS||(r.options&Zs)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
40
+ `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;Xs.hasOwnProperty(a)&&this.parser.normalizeLists&&rc(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));e:if(s?s.ignore:Ys.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(Js.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
41
+ `),t)}ignoreFallback(e,t){e.nodeName!=`BR`||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node){if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=N.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):oc(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=ec(e,i,a.options);a.options&$s&&a.content.length==0&&(o|=$s);let s=N.none;return n=n.filter(t=>!(a.type?a.type.allowsMarkType(t.type):oc(t.type,e))||(s=t.addToSet(s),!1)),this.nodes.push(new tc(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].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 t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=Zs);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function rc(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&Xs.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function ic(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function ac(e){let t={};for(let n in e)t[n]=e[n];return t}function oc(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var sc=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=lc(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name])a++;else{if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return lc(t).createTextNode(e.text);let{dom:n,contentDOM:r}=pc(lc(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&pc(lc(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:pc(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=cc(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return cc(e.marks)}};function cc(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function lc(e){return e.document||window.document}var uc=new WeakMap;function dc(e){let t=uc.get(e);return t===void 0&&uc.set(e,t=fc(e)),t}function fc(e){let t=null;function n(e){if(e&&typeof e==`object`){if(Array.isArray(e)){if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t])}else for(let t in e)n(e[t])}}return n(e),t}function pc(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=dc(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=pc(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var mc=65535,hc=2**16;function gc(e,t){return e+t*hc}function _c(e){return e&mc}function vc(e){return(e-(e&mc))/hc}var yc=1,bc=2,xc=4,Sc=8,Cc=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Sc)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&xc)>0}},wc=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=_c(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+vc(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:gc(o/3,e-s),f=0;return c&&(f|=e==s?bc:e==u?yc:xc,(t<0?e!=s:e!=u)&&(f|=Sc)),new Cc(a,f,d)}r+=l-c}return n?e+r:new Cc(e+r,0,null)}touches(e,t){let n=0,r=_c(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};wc.empty=new wc([]);var Tc=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new Cc(e,r,null)}},Ec=Object.create(null),F=class{getMap(){return wc.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=Ec[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Ec)throw RangeError(`Duplicate use of step JSON ID `+e);return Ec[e]=t,t.prototype.jsonID=e,t}},Dc=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof Zo)return e.fail(t.message);throw t}}};function Oc(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(Oc(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return M.fromArray(r)}var kc=class e extends F{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new P(Oc(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return Dc.fromReplace(e,this.from,this.to,i)}invert(t){let n=[];return t.nodesBetween(this.from,this.to,(t,r)=>{if(t.isInline&&t.isAtom){let i=this.mark.addToSet(t.marks);if(!N.sameSet(i,t.marks)){let a=Math.max(this.from,r),o=Math.min(this.to,r+t.nodeSize);jc(Ac,a,o,this.mark,n);for(let r of t.marks)r.isInSet(i)||jc(e,a,o,r,n)}}}),n.length==1?n[0]:new Mc(n)}map(t){let n=t.map(this.from,1),r=t.map(this.to,-1);return n>=r?null:new e(n,r,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};F.jsonID(`addMark`,kc);var Ac=class e extends F{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new P(Oc(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return Dc.fromReplace(e,this.from,this.to,n)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(e,n)=>{e.isInline&&e.isAtom&&this.mark.isInSet(e.marks)&&jc(kc,Math.max(this.from,n),Math.min(this.to,n+e.nodeSize),this.mark,t)}),t.length==1?t[0]:new Mc(t)}map(t){let n=t.map(this.from,1),r=t.map(this.to,-1);return n>=r?null:new e(n,r,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};F.jsonID(`removeMark`,Ac);function jc(e,t,n,r,i){let a=i.length?i[i.length-1]:null;a&&a instanceof e&&a.to==t&&a.mark.eq(r)?i[i.length-1]=new e(a.from,n,r):i.push(new e(t,n,r))}var Mc=class e extends F{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let n=t.apply(e);if(!n.doc)return n;e=n.doc}return new Dc(e,null)}invert(t){return new e(this.steps.map(e=>e.invert(t)))}map(t){let n=[];for(let e of this.steps){let r=e.map(t);r&&n.push(r)}return n.length?new e(n):null}toJSON(){return{stepType:`markSet`,steps:this.steps.map(e=>e.toJSON())}}static fromJSON(t,n){if(!Array.isArray(n.steps)||!n.steps.every(e=>e.stepType==`addMark`||e.stepType==`removeMark`))throw RangeError(`Invalid JSON for MarkSetStep`);return new e(n.steps.map(e=>F.fromJSON(t,e)))}};F.jsonID(`markSet`,Mc);var Nc=class e extends F{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Dc.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Dc.fromReplace(e,this.pos,this.pos+1,new P(M.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new Pc(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};F.jsonID(`addNodeMark`,Nc);var Pc=class e extends F{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Dc.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Dc.fromReplace(e,this.pos,this.pos+1,new P(M.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Nc(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};F.jsonID(`removeNodeMark`,Pc);var Fc=class e extends F{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Lc(e,this.from,this.to)?Dc.fail(`Structure replace would overwrite content`):Dc.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new wc([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?P.empty:new P(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?P.empty:new P(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}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(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,P.fromJSON(t,n.slice),!!n.structure)}};Fc.MAP_BIAS=1,F.jsonID(`replace`,Fc);var Ic=class e extends F{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(Lc(e,this.from,this.gapFrom)||Lc(e,this.gapTo,this.to)))return Dc.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Dc.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?Dc.fromReplace(e,this.from,this.to,n):Dc.fail(`Content does not fit in gap`)}getMap(){return new wc([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos||i>a?null:new e(n.pos,r.pos,i,a,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(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,P.fromJSON(t,n.slice),n.insert,!!n.structure)}};F.jsonID(`replaceAround`,Ic);function Lc(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Rc(e,t,n,r){let i=[];e.doc.nodesBetween(t,n,(e,a,o)=>{if(!e.isInline)return;let s=e.marks;!r.isInSet(s)&&o.type.allowsMarkType(r.type)&&jc(kc,Math.max(a,t),Math.min(a+e.nodeSize,n),r,i)}),i.forEach(t=>e.step(t))}function zc(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline||!e.isAtom)return;a++;let s=null;if(r instanceof Hs){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new Ac(t.from,t.to,t.style)))}function Bc(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Fc(s,l,P.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new Ac(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new P(M.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new Fc(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(M.empty,!0);e.replace(s,s,new P(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Vc(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Hc(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Vc(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function Uc(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=M.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=M.from(r.node(e).copy(u)),d++):c--;let f=M.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=M.from(i.node(e).copy(f)),p++):l++;e.step(new Ic(c,l,o,s,new P(u.append(f),d,p),u.size-d,!0))}function Wc(e,t,n=null,r=e){let i=Kc(e,t),a=i&&qc(r,t);return a?i.map(Gc).concat({type:t,attrs:n}).concat(a.map(Gc)):null}function Gc(e){return{type:e,attrs:null}}function Kc(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function qc(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function Jc(e,t,n){let r=M.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=M.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new Ic(i,a,i,a,new P(r,0,0),n.length,!0))}function Yc(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Qc(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&Zc(e,t,n,a),Bc(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new Ic(c,l,c+1,l-1,new P(M.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Xc(e,t,n,a),!1}})}function Xc(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function Zc(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
42
+ `))}})}function Qc(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function $c(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new Ic(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new P(M.from(o),0,0),1,!0))}function el(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function tl(e,t,n=1,r){let i=e.doc.resolve(t),a=M.empty,o=M.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=M.from(i.node(e).copy(a));let t=r&&r[s];o=M.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new Fc(t,t,new P(a.append(o),n,n),!0))}function nl(e,t){let n=e.resolve(t),r=n.index();return il(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function rl(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function il(e,t){return!!(e&&t&&!e.isLeaf&&rl(e,t))}function al(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);Zc(e,r.node(),r.before(),s)}o.inlineContent&&Bc(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new Fc(l,c.map(t+n,-1),P.empty,!0)),r===!0){let t=e.doc.resolve(l);Xc(e,t.node(),t.before(),e.steps.length)}return e}function ol(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function sl(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function cl(e,t,n=t,r=P.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return ll(i,a,r)?new Fc(t,n,r):new ul(i,a,r).fit()}function ll(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var ul=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=M.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=M.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new P(i,a,o);return e>-1?new Ic(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new Fc(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=pl(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(M.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced;return vl(e,-1)<=t?!1:(this.unplaced.size>1&&vl(e,1)>n&&n++,this.unplaced=new P(e,t+1,n),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=pl(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new P(dl(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new P(dl(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let a=this.unplaced,o=n?n.content:a.content,s=a.openStart-e,c=0,l=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)l.push(r.child(e));u=u.matchFragment(r)}let f=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let e=o.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||s==0||e.content.size)&&(u=t,l.push(ml(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=fl(this.placed,t,M.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=l[l.length-1];t&&e<f;e++)this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),t=t.lastChild;this.unplaced=p?e==0?P.empty:new P(dl(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new P(dl(a.content,e,c),e,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!hl(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=hl(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=hl(e,n,r,t,!0);if(!i||i.childCount)continue e}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=fl(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=fl(this.placed,this.depth,M.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(M.empty,!0);e.childCount&&(this.placed=fl(this.placed,this.frontier.length,e))}};function dl(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(dl(e.firstChild.content,t-1,n)))}function fl(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(fl(e.lastChild.content,t-1,n)))}function pl(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function ml(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,ml(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(M.empty,!0)))),e.copy(r)}function hl(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!gl(n,a.content,o)?s:null}function gl(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function _l(e){return e.spec.defining||e.spec.definingForContent}function vl(e,t){for(let n=0;;n++){let r=t<0?e.firstChild:e.lastChild;if(!r||r.isAtom)return n;e=r.content}}function yl(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(ll(i,a,r))return e.step(new Fc(t,n,r));let o=Cl(i,a);o[o.length-1]==0&&o.pop();let s=-(i.depth+1);o.unshift(s);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=_l(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t<o.length;t++){let l=o[(t+c)%o.length],u=!0;l<0&&(u=!1,l=-l);let f=i.node(l-1),p=i.index(l-1);if(f.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(l),u?a.after(l):n,new P(bl(r.content,0,r.openStart,s),s,r.openEnd))}}let d=e.steps.length;for(let s=o.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function bl(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(bl(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(M.empty,!0))}return e}function xl(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=ol(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new P(M.from(r),0,0))}function Sl(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=Cl(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function Cl(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var wl=class e extends F{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return Dc.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return Dc.fromReplace(e,this.pos,this.pos+1,new P(M.from(r),0,+!t.isLeaf))}getMap(){return wc.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};F.jsonID(`attr`,wl);var Tl=class e extends F{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return Dc.ok(n)}getMap(){return wc.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};F.jsonID(`docAttr`,Tl);var El=class extends Error{};El=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},El.prototype=Object.create(Error.prototype),El.prototype.constructor=El,El.prototype.name=`TransformError`;var Dl=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Tc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new El(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=P.empty){let r=cl(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new P(M.from(n),0,0))}delete(e,t){return this.replace(e,t,P.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return yl(this,e,t,n),this}replaceRangeWith(e,t,n){return xl(this,e,t,n),this}deleteRange(e,t){return Sl(this,e,t),this}lift(e,t){return Uc(this,e,t),this}join(e,t=1){return al(this,e,t),this}wrap(e,t){return Jc(this,e,t),this}setBlockType(e,t=e,n,r=null){return Yc(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return $c(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new wl(e,t,n)),this}setDocAttribute(e,t){return this.step(new Tl(e,t)),this}addNodeMark(e,t){return this.step(new Nc(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof N)t.isInSet(n.marks)&&this.step(new Pc(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new Pc(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return tl(this,e,t,n),this}addMark(e,t,n){return Rc(this,e,t,n),this}removeMark(e,t,n){return zc(this,e,t,n),this}clearIncompatible(e,t,n){return Bc(this,e,t,n),this}},Ol=Object.create(null),I=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new kl(e.min(t),e.max(t))]}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 t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=P.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?P.empty:t),o==0&&Ll(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),Ll(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new L(e):Il(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?Il(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Il(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Pl(e.node(0))}static atStart(e){return Il(e,e,0,0,1)||new Pl(e)}static atEnd(e){return Il(e,e,e.content.size,e.childCount,-1)||new Pl(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=Ol[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Ol)throw RangeError(`Duplicate use of selection JSON ID `+e);return Ol[e]=t,t.prototype.jsonID=e,t}getBookmark(){return L.between(this.$anchor,this.$head).getBookmark()}};I.prototype.visible=!0;var kl=class{constructor(e,t){this.$from=e,this.$to=t}},Al=!1;function jl(e){!Al&&!e.parent.inlineContent&&(Al=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var L=class e extends I{constructor(e,t=e){jl(e),jl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return I.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=P.empty){if(super.replace(e,t),t==P.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Ml(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=I.findFrom(n,r,!0)||I.findFrom(n,-r,!0);if(e)n=e.$head;else return I.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(I.findFrom(t,-r,!0)||I.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};I.jsonID(`text`,L);var Ml=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return L.between(e.resolve(this.anchor),e.resolve(this.head))}},R=class e extends I{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?I.near(a):new e(a)}content(){return new P(M.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new Nl(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};R.prototype.visible=!1,I.jsonID(`node`,R);var Nl=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new Ml(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&R.isSelectable(n)?new R(t):I.near(t)}},Pl=class e extends I{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=P.empty){if(t==P.empty){e.delete(0,e.doc.content.size);let t=I.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return Fl}};I.jsonID(`all`,Pl);var Fl={map(){return this},resolve(e){return new Pl(e)}};function Il(e,t,n,r,i,a=!1){if(t.inlineContent)return L.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=Il(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&R.isSelectable(r))return R.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function Ll(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof Fc||i instanceof Ic))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(I.near(e.doc.resolve(o),n))}var Rl=1,zl=2,Bl=4,Vl=class extends Dl{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 RangeError(`Selection passed to setSelection must point at the current document`);return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Rl)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&Rl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=zl,this}ensureMarks(e){return N.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&zl)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||N.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(I.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,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|=Bl,this}get scrolledIntoView(){return(this.updated&Bl)>0}};function Hl(e,t){return!t||!e?e:e.bind(t)}var Ul=class{constructor(e,t,n){this.name=e,this.init=Hl(t.init,n),this.apply=Hl(t.apply,n)}},Wl=[new Ul(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new Ul(`selection`,{init(e,t){return e.selection||I.atStart(t.doc)},apply(e){return e.selection}}),new Ul(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new Ul(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],Gl=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Wl.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Ul(e.key,e.spec.state,e))})}},Kl=class e{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,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let s=r?r[a].n:0,c=r?r[a].state:this,l=s<t.length&&o.spec.appendTransaction.call(o,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,a)){if(l.setMeta(`appendedTransaction`,e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<a?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),i=!0}r&&(r[a]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw RangeError(`Applying a mismatched transaction`);let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new Vl(this)}static create(t){let n=new Gl(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new Gl(this.schema,t.plugins),r=n.fields,i=new e(n);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new Gl(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=_s.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=I.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function ql(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=ql(i,t,{})),n[r]=i}return n}var Jl=class{constructor(e){this.spec=e,this.props={},e.props&&ql(e.props,this,this.props),this.key=e.key?e.key.key:Xl(`plugin`)}getState(e){return e[this.key]}},Yl=Object.create(null);function Xl(e){return e in Yl?e+`$`+ ++Yl[e]:(Yl[e]=0,e+`$`)}var Zl=class{constructor(e=`key`){this.key=Xl(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},Ql=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function $l(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var eu=(e,t,n)=>{let r=$l(e,n);if(!r)return!1;let i=au(r);if(!i){let n=r.blockRange(),i=n&&Hc(n);return i!=null&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(yu(e,i,t,-1))return!0;if(r.parent.content.size==0&&(ru(a,`end`)||R.isSelectable(a)))for(let n=r.depth;;n--){let o=cl(e.doc,r.before(n),r.after(n),P.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(ru(a,`end`)?I.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):R.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},tu=(e,t,n)=>{let r=$l(e,n);if(!r)return!1;let i=au(r);return i?nu(e,i,t):!1};function nu(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=cl(e.doc,i,o,P.empty);if(!s||s.from!=i||s instanceof Fc&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(L.create(t.doc,i)),n(t.scrollIntoView())}return!0}function ru(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var iu=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=au(r)}let o=a&&a.nodeBefore;return!o||!R.isSelectable(o)?!1:(t&&t(e.tr.setSelection(R.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function au(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function ou(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var su=(e,t,n)=>{let r=ou(e,n);if(!r)return!1;let i=lu(r);if(!i)return!1;let a=i.nodeAfter;if(yu(e,i,t,1))return!0;if(r.parent.content.size==0&&(ru(a,`start`)||R.isSelectable(a))){let n=cl(e.doc,r.before(),r.after(),P.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(ru(a,`start`)?I.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):R.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},cu=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=lu(r)}let o=a&&a.nodeAfter;return!o||!R.isSelectable(o)?!1:(t&&t(e.tr.setSelection(R.create(e.doc,a.pos)).scrollIntoView()),!0)};function lu(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var uu=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
43
+ `).scrollIntoView()),!0)};function du(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var fu=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=du(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(I.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},pu=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof Pl||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=du(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(L.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},mu=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(el(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Hc(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function hu(e){return(t,n)=>{if(t.selection instanceof R&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!el(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof L||t.selection instanceof Pl)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=du(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=el(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,el(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var gu=hu(),_u=(e,t)=>(t&&t(e.tr.setSelection(new Pl(e.doc))),!0);function vu(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||nl(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function yu(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&vu(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=M.empty;for(let e=o.length-1;e>=0;e--)s=M.from(o[e].create(null,s));s=M.from(i.copy(s));let c=e.tr.step(new Ic(t.pos-1,r,t.pos,r,new P(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&nl(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:I.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&Hc(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&ru(a,`start`,!0)&&ru(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=M.empty;for(let e=o.length-1;e>=0;e--)r=M.from(o[e].copy(r));n(e.tr.step(new Ic(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new P(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function bu(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(L.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var xu=bu(-1),Su=bu(1);function Cu(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&Wc(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function wu(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(e,t)){if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function Tu(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:a,$to:o}=t[i],s=a.depth==0&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(a.pos,o.pos,(e,t)=>{if(s||!r&&e.isAtom&&e.isInline&&t>=a.pos&&t+e.nodeSize<=o.pos)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}function Eu(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new kl(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new kl(r,i))}return t}function Du(e,t=null,n){let r=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,a=!(n&&n.includeWhitespace);return function(n,o){let{empty:s,$cursor:c,ranges:l}=n.selection;if(s&&!c||!Tu(n.doc,l,e,i))return!1;if(o){if(c)e.isInSet(n.storedMarks||c.marks())?o(n.tr.removeStoredMark(e)):o(n.tr.addStoredMark(e.create(t)));else{let s,c=n.tr;i||(l=Eu(l)),s=r?!l.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!l.every(t=>{let n=!1;return c.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,a)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!a&&a.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<l.length;n++){let{$from:r,$to:i}=l[n];if(!s)c.removeMark(r.pos,i.pos,e);else{let n=r.pos,o=i.pos,s=r.nodeAfter,l=i.nodeBefore,u=a&&s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=a&&l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+u<o&&(n+=u,o-=d),c.addMark(n,o,e.create(t))}}o(c.scrollIntoView())}}return!0}}function Ou(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var ku=Ou(Ql,eu,iu),Au=Ou(Ql,su,cu),ju={Enter:Ou(uu,pu,mu,gu),"Mod-Enter":fu,Backspace:ku,"Mod-Backspace":ku,"Shift-Backspace":ku,Delete:Au,"Mod-Delete":Au,"Mod-a":_u},Mu={"Ctrl-h":ju.Backspace,"Alt-Backspace":ju[`Mod-Backspace`],"Ctrl-d":ju.Delete,"Ctrl-Alt-Backspace":ju[`Mod-Delete`],"Alt-Delete":ju[`Mod-Delete`],"Alt-d":ju[`Mod-Delete`],"Ctrl-a":xu,"Ctrl-e":Su};for(let e in ju)Mu[e]=ju[e];var Nu=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?Mu:ju,Pu=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?Fu(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function Fu(e){return function(t,n,r,i){let a=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);a+=n[0].slice(e+n[1].length),r+=e;let t=r-i;t>0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var Iu=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let n=e.tr,r=a.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(a.text){let t=n.doc.resolve(a.from).marks();n.replaceWith(a.from,a.to,e.schema.text(a.text,t))}else n.delete(a.from,a.to);t(n)}return!0}}return!1};new Pu(/--$/,`—`,{inCodeMark:!1}),new Pu(/\.\.\.$/,`…`,{inCodeMark:!1}),new Pu(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new Pu(/"$/,`”`,{inCodeMark:!1}),new Pu(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new Pu(/'$/,`’`,{inCodeMark:!1});function Lu(e,t,n=null,r){return new Pu(e,(e,i,a,o)=>{let s=n instanceof Function?n(i):n,c=e.tr.delete(a,o),l=c.doc.resolve(a).blockRange(),u=l&&Wc(l,t,s);if(!u)return null;c.wrap(l,u);let d=c.doc.resolve(a-1).nodeBefore;return d&&d.type==t&&nl(c.doc,a-1)&&(!r||r(i,d))&&c.join(a-1),c})}function Ru(e,t,n=null){return new Pu(e,(e,r,i,a)=>{let o=e.doc.resolve(i),s=n instanceof Function?n(r):n;return o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t)?e.tr.delete(i,a).setBlockType(i,i,t,s):null})}var zu=typeof navigator<`u`?navigator:null,Bu=typeof document<`u`?document:null,Vu=zu&&zu.userAgent||``,Hu=/Edge\/(\d+)/.exec(Vu),Uu=/MSIE \d/.exec(Vu),Wu=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Vu),Gu=!!(Uu||Wu||Hu);Uu?document.documentMode:Wu?+Wu[1]:Hu&&+Hu[1],!Gu&&/gecko\/(\d+)/i.test(Vu)&&+(/Firefox\/(\d+)/.exec(Vu)||[0,0])[1];var Ku=!Gu&&/Chrome\/(\d+)/.exec(Vu),qu=!!Ku;Ku&&+Ku[1],!Gu&&zu&&/Apple Computer/.test(zu.vendor)&&(/Mobile\/\w+/.test(Vu)||zu&&zu.maxTouchPoints>2)||zu&&/Mac/.test(zu.platform);var Ju=/Android \d/.test(Vu);Bu&&`webkitFontSmoothing`in Bu.documentElement.style&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];function Yu(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t);if(s.parent.type.spec.code)return!1;let c=s.parent.textBetween(Math.max(0,s.parentOffset-500),s.parentOffset,void 0,``)+r;for(let s of i){let i=s,l=i.match.exec(c),u=l&&l[0]&&i.handler(o,l,t-(l[0].length-r.length),n);if(u)return i.undoable!==!1&&u.setMeta(a,{transform:u,from:t,to:n,text:r}),e.dispatch(u),!0}return!1}var Xu=new Zl(`MILKDOWN_CUSTOM_INPUTRULES`);function Zu({rules:e}){let t=new Jl({key:Xu,isInputRules:!0,state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return Yu(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>(setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&Yu(n,r.pos,r.pos,``,e,t)}),!1),keydown:(e,t)=>!(Ju&&qu&&t.key===`Enter`)||e.composing?!1:e.someProp(`handleKeyDown`,n=>n(e,t))?(t.preventDefault(),!0):!1},handleKeyDown(n,r){if(r.key!==`Enter`)return!1;let{$cursor:i}=n.state.selection;return i?Yu(n,i.pos,i.pos,`
44
+ `,e,t):!1}}});return t}function Qu(e){return e.some(e=>e.type.spec.code)}function $u(e,t,n){if(t>=n)return!1;let r=!1;return e.doc.nodesBetween(t,n,e=>(e.isInline&&Qu(e.marks)&&(r=!0),!r)),r}function ed(e,t){return Qu(e.storedMarks??e.doc.resolve(t).marks())}function td(e,t,n={}){return new Pu(e,(e,r,i,a)=>{var o;let{tr:s}=e,c=r[r.length-1],l=r[0],u=[],d,f={group:c,fullMatch:l,start:i,end:a},p=n.updateCaptured?.call(n,f);if(Object.assign(f,p),{group:c,fullMatch:l,start:i,end:a}=f,l===null||c?.trim()===``)return null;if(c){let f=l.search(/\S/),p=i+l.indexOf(c),m=p+c.length,h=$u(e,i+f,p),g=m<a&&$u(e,m,a);if(h||g||ed(e,a))return null;u=s.storedMarks??[],m<a&&s.delete(m,a),p>i&&s.delete(i+f,p),d=i+f+c.length;let _=n.getAttr?.call(n,r);s.addMark(i,d,t.create(_)),s.setStoredMarks(u),(o=n.beforeDispatch)==null||o.call(n,{match:r,start:i,end:a,tr:s})}return s})}function nd(e){return Object.assign(Object.create(e),e).setTime(Date.now())}function rd(e,t){return Array.isArray(e)&&e.includes(t.type)||t.type===e}function id(e){return t=>{for(let n=t.depth;n>0;--n){let r=t.node(n);if(e(r))return{from:t.before(n),to:t.after(n),node:r}}}}function ad(e,t){return id(e=>e.type===t)(e)}function od(e){return t=>{for(let n=t.depth;n>0;n--){let r=t.node(n);if(e(r))return{pos:t.before(n),start:t.start(n),depth:n,node:r}}}}function sd(e,t){if(!(e instanceof R))return;let{node:n,$from:r}=e;if(rd(t,n))return{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}}for(var cd=(e,t)=>{let{selection:n,doc:r}=e;if(n instanceof R)return{hasNode:n.node.type===t,pos:n.from,target:n.node};let{from:i,to:a}=n,o=!1,s=-1,c=null;return r.nodesBetween(i,a,(e,n)=>c?!1:e.type!==t||(o=!0,s=n,c=e,!1)),{hasNode:o,pos:s,target:c}},ld={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},ud={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},dd=typeof navigator<`u`&&/Mac/.test(navigator.platform),fd=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),pd=0;pd<10;pd++)ld[48+pd]=ld[96+pd]=String(pd);for(var pd=1;pd<=24;pd++)ld[pd+111]=`F`+pd;for(var pd=65;pd<=90;pd++)ld[pd]=String.fromCharCode(pd+32),ud[pd]=String.fromCharCode(pd);for(var md in ld)ud.hasOwnProperty(md)||(ud[md]=ld[md]);function hd(e){var t=!(dd&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||fd&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?ud:ld)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var gd=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),_d=typeof navigator<`u`&&/Win/.test(navigator.platform);function vd(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))gd?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function yd(e){let t=Object.create(null);for(let n in e)t[vd(n)]=e[n];return t}function bd(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function xd(e){return new Jl({props:{handleKeyDown:Sd(e)}})}function Sd(e){let t=yd(e);return function(e,n){let r=hd(n),i,a=t[bd(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[bd(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(_d&&n.ctrlKey&&n.altKey)&&(i=ld[n.keyCode])&&i!=r){let r=t[bd(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var Cd=class{},wd=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{let e=this.elements.pop();if(!e)throw Le();return e}}},Td=class e extends Cd{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(t,n,r){return new e(t,n,r)}},Ed=class extends wd{#e;static{this.create=(e,t)=>{let n=new this(e);return e=>(n.run(t,e),n.toDoc())}}constructor(e){super(),this.#e=N.none,this.#t=e=>e.isText,this.#n=(e,t)=>{if(this.#t(e)&&this.#t(t)&&N.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)},this.#r=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.parseMarkdown.match(e));if(!t)throw Re(e);return t},this.#i=e=>{let t=this.#r(e);t.spec.parseMarkdown.runner(this,e,t)},this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(Td.create(e,[],t)),this),this.#a=()=>{this.#e=N.none;let e=this.close();return this.#o(e.type,e.attrs,e.content)},this.closeNode=()=>{try{this.#a()}catch(e){console.error(e)}return this},this.#o=(e,t,n)=>{let r=e.createAndFill(t,n,this.#e);if(!r)throw Ie(e,t,n);return this.push(r),r},this.addNode=(e,t,n)=>{try{this.#o(e,t,n)}catch(e){console.error(e)}return this},this.hasMark=e=>!!e.isInSet(this.#e),this.openMark=(e,t)=>{let n=e.create(t);return this.#e=n.addToSet(this.#e),this},this.closeMark=e=>(this.#e=e.removeFromSet(this.#e),this),this.addText=e=>{try{let t=this.top();if(!t)throw Le();let n=t.pop(),r=this.schema.text(e,this.#e);if(!n)return t.push(r),this;let i=this.#n(n,r);return i?(t.push(i),this):(t.push(n,r),this)}catch(e){return console.error(e),this}},this.build=()=>{let e;do e=this.#a();while(this.size());return e},this.next=(e=[])=>([e].flat().forEach(e=>this.#i(e)),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{let n=e.runSync(e.parse(t),t);return this.next(n),this},this.schema=e}#t;#n;#r;#i;#a;#o},Dd=class e extends Cd{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(e,...t)=>{this.children||=[],this.children.push(e,...t)},this.pop=()=>this.children?.pop()}static{this.create=(t,n,r,i={})=>new e(t,n,r,i)}},Od=e=>Object.prototype.hasOwnProperty.call(e,`size`),kd=e=>!e.value&&!e.children?.some(e=>e.type!==`text`||e.value),Ad=class extends wd{#e;static{this.create=(e,t)=>{let n=new this(e);return e=>(n.run(e),n.toString(t))}}constructor(e){super(),this.#e=[],this.#t=e=>{let t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.toMarkdown.match(e));if(!t)throw ze(e.type);return t},this.#n=e=>this.#t(e).spec.toMarkdown.runner(this,e),this.#r=(e,t)=>this.#t(e).spec.toMarkdown.runner(this,e,t),this.#i=(e,t,n)=>{let r=1;for(;t?.maybeChild(n+r)?.marks.some(t=>t.eq(e));)r++;return r},this.#a=(e,t,n=0)=>{let r=e=>e.type.spec.priority??50,i=new Map,a=e=>{let r=i.get(e);return r??(r=this.#i(e,t,n),i.set(e,r)),r},o=[...e].sort((e,t)=>r(e)-r(t)||a(t)-a(e)),s=[];return this.#e.forEach(({mark:e})=>{let t=o.findIndex(t=>t.eq(e));t>=0&&s.push(...o.splice(t,1))}),s.concat(o)},this.#o=e=>{let t=e?.marks,n=0;for(;n<this.#e.length;){let{mark:e,spanning:r}=this.#e[n];if(r&&t?.some(t=>t.eq(e)))n++;else break}for(let e=this.#e.length-1;e>=n;e--)this.#m(this.#e[e].mark)},this.#s=(e,t,n=0)=>{let r=this.#a(e.marks,t,n).find(t=>this.#r(t,e));if(r){let e=this.#e.find(e=>e.mark.eq(r));e&&(e.selfContained=!0)}else this.#n(e);this.#o(t?.maybeChild(n+1)??void 0)},this.#c=e=>{let{children:t}=e;return t&&(e.children=t.reduce((e,t,n)=>{if(n===0)return[t];let r=e.at(-1);if(r&&r.isMark&&t.isMark){let{children:n,...i}=t,{children:a,...o}=r;if(t.type===r.type&&n&&a&&JSON.stringify(i)===JSON.stringify(o)){let t={...o,children:[...a,...n]};return e.slice(0,-1).concat(this.#c(t))}}return e.concat(t)},[])),e},this.#l=e=>{let t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t},this.openNode=(e,t,n)=>(this.open(Dd.create(e,void 0,t,n)),this),this.#u=(e,t)=>{let n=``,r=``,i=e.children;if(i){let e=i[0],t=i.at(-1);if(t&&t.type===`text`&&t.value.endsWith(` `)){let e=t.value,n=e.trimEnd();r=e.slice(n.length),t.value=n}if(e&&e.type===`text`&&e.value.startsWith(` `)){let t=e.value,r=t.trimStart();n=t.slice(0,t.length-r.length),e.value=r}}n.length&&this.#f(`text`,void 0,n),t(),r.length&&this.#f(`text`,void 0,r)},this.#d=()=>{let e=this.close();return this.#f(e.type,e.children,e.value,e.props)},this.closeNode=()=>(this.#d(),this),this.#f=(e,t,n,r)=>{let i=Dd.create(e,t,n,r),a=this.#c(this.#l(i));return this.push(a),a},this.addNode=(e,t,n,r)=>(this.#f(e,t,n,r),this),this.#p=(e,t,n,r)=>this.#e.some(t=>t.mark.eq(e))?this:(this.#e.push({mark:e,spanning:n==null}),this.openNode(t,n,{...r,isMark:!0})),this.#m=e=>{let t=-1;for(let n=this.#e.length-1;n>=0;n--)if(this.#e[n].mark.eq(e)){t=n;break}if(t<0)return;let[n]=this.#e.splice(t,1),r=this.close();this.#u(r,()=>{(n.selfContained||!kd(r))&&this.#f(r.type,r.children,r.value,r.props)})},this.withMark=(e,t,n,r)=>(this.#p(e,t,n,r),this),this.closeMark=e=>(this.#m(e),this),this.build=()=>{let e=null;do e=this.#d();while(this.size());return e.children||(e.children=[]),e},this.next=e=>Od(e)?(e.forEach((t,n,r)=>{this.#s(t,e,r)}),this):(this.#s(e),this),this.toString=e=>e.stringify(this.build()),this.run=e=>(this.#e=[],this.next(e),this),this.schema=e}#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m},z=e(a(),1),B=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},jd=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},Md=null,Nd=function(e,t,n){let r=Md||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Pd=function(){Md=null},Fd=function(e,t,n,r){return n&&(Ld(e,t,n,r,-1)||Ld(e,t,n,r,1))},Id=/^(img|br|input|textarea|hr)$/i;function Ld(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:V(e))){let n=e.parentNode;if(!n||!H(n)||Hd(e)||Id.test(e.nodeName)||e.contentEditable==`false`)return!1;t=B(e)+(i<0?0:1),e=n}else if(H(e)){let n=e.childNodes[t+(i<0?-1:0)];if(H(n)&&n.contentEditable==`false`){if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1}else e=n,t=i<0?V(e):0}else return!1}}function V(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function H(e){return e.nodeType==1}function U(e){return e.nodeType==3}function Rd(e,t){return t?e.contains(H(t)?t:t.parentNode):!1}function zd(e,t){for(;;){if(U(e)&&t)return e;if(H(e)&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=V(e)}else if(e.parentNode&&!Hd(e))t=B(e),e=e.parentNode;else return null}}function Bd(e,t){for(;;){if(U(e)&&t<e.nodeValue.length)return e;if(H(e)&&t<e.childNodes.length){if(e.contentEditable==`false`)return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!Hd(e))t=B(e)+1,e=e.parentNode;else return null}}function Vd(e,t,n){for(let r=t==0,i=t==V(e);r||i;){if(e==n)return!0;let t=B(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==V(e)}}function Hd(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var Ud=function(e){return e.focusNode&&Fd(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Wd(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function Gd(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function Kd(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(V(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(V(r.startContainer),r.startOffset)}}}var qd=typeof navigator<`u`?navigator:null,Jd=typeof document<`u`?document:null,Yd=qd&&qd.userAgent||``,Xd=/Edge\/(\d+)/.exec(Yd),Zd=/MSIE \d/.exec(Yd),Qd=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Yd),$d=!!(Zd||Qd||Xd),ef=Zd?document.documentMode:Qd?+Qd[1]:Xd?+Xd[1]:0,tf=!$d&&/gecko\/(\d+)/i.test(Yd);tf&&+(/Firefox\/(\d+)/.exec(Yd)||[0,0])[1];var nf=!$d&&/Chrome\/(\d+)/.exec(Yd),W=!!nf,rf=nf?+nf[1]:0,af=!$d&&!!qd&&/Apple Computer/.test(qd.vendor),of=af&&(/Mobile\/\w+/.test(Yd)||!!qd&&qd.maxTouchPoints>2),sf=of||(qd?/Mac/.test(qd.platform):!1),cf=qd?/Win/.test(qd.platform):!1,lf=/Android \d/.test(Yd),uf=!!Jd&&`webkitFontSmoothing`in Jd.documentElement.style,df=uf?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ff(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function pf(e,t){return typeof e==`number`?e:e[t]}function mf(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function hf(e,t,n){if(!Af(t)&&t.left==0)return;let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(!H(o)){o=jd(o);continue}let e=o==a.body,n=e?ff(a):mf(o),s=0,c=0;if(t.top<n.top+pf(r,`top`)?c=-(n.top-t.top+pf(i,`top`)):t.bottom>n.bottom-pf(r,`bottom`)&&(c=t.bottom-t.top>n.bottom-n.top?t.top+pf(i,`top`)-n.top:t.bottom-n.bottom+pf(i,`bottom`)),t.left<n.left+pf(r,`left`)?s=-(n.left-t.left+pf(i,`left`)):t.right>n.right-pf(r,`right`)&&(s=t.right-n.right+pf(i,`right`)),s||c){if(e)a.defaultView.scrollBy(s,c);else{let e=o.scrollLeft,n=o.scrollTop;c&&(o.scrollTop+=c),s&&(o.scrollLeft+=s);let r=o.scrollLeft-e,i=o.scrollTop-n;t={left:t.left-r,top:t.top-i,right:t.right-r,bottom:t.bottom-i}}}let l=e?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(l))break;o=l==`absolute`?o.offsetParent:jd(o)}}function gf(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o<Math.min(innerHeight,t.bottom);o+=5){let t=e.root.elementFromPoint(a,o);if(!t||t==e.dom||!e.dom.contains(t))continue;let s=t.getBoundingClientRect();if(s.top>=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:_f(e.dom)}}function _f(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=jd(r));return t}function vf({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;yf(n,r==0?0:r-t)}function yf(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:a}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var bf=null;function xf(e){if(e.setActive)return e.setActive();if(bf)return e.focus(bf);let t=_f(e);e.focus(bf==null?{get preventScroll(){return bf={preventScroll:!0},!0}}:void 0),bf||(bf=!1,yf(t,0))}function Sf(e,t){let n,r=2e8,i,a=0,o=t.top,s=t.top,c,l;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(H(u))e=u.getClientRects();else if(U(u))e=Nd(u).getClientRects();else continue;for(let f=0;f<e.length;f++){let p=e[f];if(p.top<=o&&p.bottom>=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=u,r=e,i=e&&U(n)?{left:p.right<t.left?p.right:p.left,top:t.top}:t,H(u)&&e&&(a=d+ +(t.left>=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&U(n)?Cf(n,i):!n||r?{node:e,offset:a}:Sf(n,i)}function Cf(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(e,a+1),r.setStart(e,a);let n=jf(r,1);if(n.top!=n.bottom&&wf(t,n)){i={node:e,offset:a+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function wf(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Tf(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function Ef(e,t,n){let{node:r,offset:i}=Sf(t,n),a=-1;if(H(r)&&!r.firstChild){let e=r.getBoundingClientRect();a=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function Df(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(H(t.dom)&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right<r.left||o.bottom<r.top)&&(i=t.posAfter),a=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}function Of(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let n=e.childNodes[a];if(H(n)){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(wf(t,i))return Of(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function kf(e,t){let n=e.dom.ownerDocument,r,i=0,a=Kd(n,t.left,t.top);a&&({node:r,offset:i}=a);let o=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s;if(!o||!e.dom.contains(o)){let n=e.dom.getBoundingClientRect();if(!wf(t,n)||(o=Of(e.dom,t,n),!o))return null}if(af)for(let e=o;r&&e;e=jd(e))e.draggable&&(r=void 0);if(o=Tf(o,t),r){if(tf&&H(r)&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let e=r.childNodes[i],n;e.nodeName==`IMG`&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&i++}let n;uf&&i&&H(r)&&H(n=r.childNodes[i-1])&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&H(r.lastChild)&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:i!=0&&H(r)&&r.childNodes[i-1].nodeName==`BR`||(s=Df(e,r,i,t))}s??=Ef(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function Af(e){return e.top<e.bottom||e.left<e.right}function jf(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(Af(e))return e}return Array.prototype.find.call(n,Af)||e.getBoundingClientRect()}var Mf=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Nf(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=uf||tf;if(U(r)){if(o&&(Mf.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=jf(Nd(r,i,i),n);if(tf&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=jf(Nd(r,i-1,i-1),-1);if(t.top==e.top){let n=jf(Nd(r,i,i+1),-1);if(n.top!=e.top)return Pf(n,n.left<t.left)}}return e}{let e=i,t=i,a=n<0?1:-1;return n<0&&!i?(t++,a=-1):n>=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,Pf(jf(Nd(r,e,t),a),a<0)}}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==V(r))){let e=r.childNodes[i-1];if(H(e))return Ff(e.getBoundingClientRect(),!1)}if(a==null&&i<V(r)){let e=r.childNodes[i];if(H(e))return Ff(e.getBoundingClientRect(),!0)}return Ff(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==V(r))){let e=r.childNodes[i-1],t=U(e)?Nd(e,V(e)-+!o):H(e)&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return Pf(jf(t,1),!1)}if(a==null&&i<V(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?U(e)?Nd(e,0,+!o):H(e)?e:null:null;if(t)return Pf(jf(t,-1),!0)}return Pf(jf(U(r)?Nd(r):r,-n),n>=0)}function Pf(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Ff(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function If(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function Lf(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return If(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Nf(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(H(e))t=e.getClientRects();else if(U(e))t=Nd(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var Rf=/[\u0590-\u08ac]/;function zf(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!Rf.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:If(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!Rd(l,u)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var Bf=null,Vf=null,Hf=!1;function Uf(e,t,n){return Bf==t&&Vf==n?Hf:(Bf=t,Vf=n,Hf=n==`up`||n==`down`?Lf(e,t,n):zf(e,t,n))}var Wf=0,Gf=1,Kf=2,qf=3,Jf=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=Wf,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].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 t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.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,t,n){if(this.contentDOM&&Rd(this.contentDOM,e)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>B(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let n=e.compareDocumentPosition(this.contentDOM);r=n&16?t>Array.from(e.childNodes).findIndex(e=>e.contains(this.contentDOM)):!(n&4)}else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node)){if(n&&(a=i.nodeDOM)&&!(H(a)?Rd(a,e):a==e))n=!1;else return i}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],a=t+i.size;if(a>e){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(;n>0;n--){let e=this.children[n-1];if(e.size||!(e instanceof tp||e instanceof Yf&&e.side>=0))break}if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?B(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?B(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let a=n,o=0;;o++){let n=this.children[o],s=a+n.size;if(r==-1&&e<=s){let i=a+n.border;if(e>=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=B(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=B(n.dom);break}t+=n.size}i==-1&&(i=this.contentDOM.childNodes.length);break}a=s}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(!H(t)||n==t.childNodes.length)throw RangeError(`No node after pos `+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),a=Math.max(e,t);for(let o=0,s=0;o<this.children.length;o++){let c=this.children[o],l=s+c.size;if(i>s&&a<l)return c.setSelection(e-s-c.border,t-s-c.border,n,r);s=l}let o=this.domFromPos(e,e?-1:1),s=t==e?o:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),l=n.domSelectionRange(),u=!1;if((tf||af)&&e==t){let{node:e,offset:t}=o;if(U(e)){if(u=!!(t&&e.nodeValue[t-1]==`
45
+ `),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:B(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(tf&&l.focusNode&&l.focusNode!=s.node&&H(l.focusNode)){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&af)&&Fd(o.node,o.offset,l.anchorNode,l.anchorOffset)&&Fd(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&tf)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?Kf:Gf,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=qf:i.markDirty(e-r,t-r);return}i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Kf:qf}n=a}this.dirty=Kf}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Kf:Gf;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Yf=class extends Jf{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let e=H(a)?a:document.createElement(`span`);e!=a&&(e.appendChild(a),a=e),e.hasAttribute(`contenteditable`)||(e.contentEditable=`false`),e.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Wf&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(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}},Xf=class extends Jf{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},Zf=class e extends Jf{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return o&&o.dom||(o=sc.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&qf||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=qf&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Wf){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=Wf}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=vp(a,n,o,r)),t>0&&(a=vp(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Qf=class e extends Jf{constructor(e,t,n,r,i,a,o){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!U(u))throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=sc.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=lp(u,r,n),l?c=new np(t,n,r,i,u,d||null,f,l):n.isText?new ep(t,n,r,i,u,f):new e(t,n,r,i,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(t.preserveWhitespace=`full`),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(t=>H(t)&&e.indexOf(t.parentNode)<0&&this.dom.contains(t));n?t.contentElement=n:t.getContent=()=>M.empty}}return t}matchesNode(e,t,n){return this.dirty==Wf&&e.eq(this.node)&&up(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new fp(this,a&&a.node,e),c=this.node.inlineContent,l=c&&this.node.isBlock;hp(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?N.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,u,d)=>{s.syncToMarks(t.marks,n,e,d),l&&t.isAtom&&!t.isText&&s.addHackNode(`IMG`,s.top);let f;s.findNodeMatch(t,a,u,d)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(f=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,u,f,e)||s.updateNextNode(t,a,u,e,d,r)||s.addNode(t,a,u,e,r),r+=t.nodeSize,c&&(l=t.isAtom&&!t.isText)}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==Kf)&&(a&&this.protectLocalComposition(e,a),rp(this.contentDOM,this.children,e),of&&gp(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof L)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=_p(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let a=new Xf(this,i,t,r);e.input.compositionNodes.push(a),this.children=vp(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==qf||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Wf}updateOuterDeco(e){if(up(e,this.outerDeco))return;let t=!H(this.nodeDOM),n=this.dom;this.dom=sp(this.dom,this.nodeDOM,op(this.outerDeco,this.node,t),op(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){H(this.nodeDOM)&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){H(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 $f(e,t,n,r,i){lp(r,t,e);let a=new Qf(void 0,e,t,n,r,r,r);return a.contentDOM&&a.updateChildren(i,0),a}var ep=class e extends Qf{constructor(e,t,n,r,i,a){super(e,t,n,r,i,null,a)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==qf||this.dirty!=Wf&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Wf||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Wf,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=qf)}get domAtom(){return!1}isText(e){return this.node.text==e}},tp=class extends Jf{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Wf&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},np=class extends Qf{constructor(e,t,n,r,i,a,o,s){super(e,t,n,r,i,a,o),this.spec=s}update(e,t,n,r){if(this.dirty==qf)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}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(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=dp(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof Zf){let t=r?r.previousSibling:e.lastChild;rp(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=dp(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var ip=function(e){e&&(this.nodeName=e)};ip.prototype=Object.create(null);var ap=[new ip];function op(e,t,n){if(e.length==0)return ap;let r=n?ap[0]:new ip,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new ip(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new ip(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function sp(e,t,n,r){if(n==ap&&r==ap)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName||(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=ap[0]),i=t}cp(i,o||ap[0],a)}return i}function cp(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function lp(e,t,n){return sp(e,e,ap,op(t,n,!H(e)))}function up(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function dp(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var fp=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=pp(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=Wf,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;break}}if(i<0&&this.index<this.top.children.length){let t=this.top.children[this.index];t instanceof Zf&&t.dirty!=qf&&t.mark.type==e[a].type&&t.spec.update&&!this.isLocked(t.dom)&&t.spec.update(e[a])&&(t.mark=e[a],i=this.index,this.changed=!0)}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=Zf.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let a=this.top.children[r];return a.dirty==qf&&a.dom==a.contentDOM&&(a.dirty=Kf),a.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof Qf){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=qf&&up(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Kf,u.updateChildren(r,a+1),u.dirty=Wf),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!up(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=Qf.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=Qf.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new Yf(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Zf;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof ep)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((af||W)&&e&&e.dom.contentEditable==`false`&&this.addHackNode(`IMG`,t),this.addHackNode(`BR`,this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e==`IMG`&&(n.className=`ProseMirror-separator`,n.alt=``),e==`BR`&&(n.className=`ProseMirror-trailingBreak`);let r=new tp(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||H(e)&&e.contains(this.lock.parentNode))}};function pp(e,t){let n=t,r=n.children.length,i=e.childCount,a=new Map,o=[];e:for(;i>0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof Zf)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break e;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function mp(e,t){return e.type.side-t.type.side}function hp(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u){if(d){d.sort(mp);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c)}let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function gp(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function _p(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function vp(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function yp(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(Ud(n)){for(c=o;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&R.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&Vd(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new R(o==e?s:r.resolve(e))}else if(tf&&t==`key`&&o>e.state.selection.to&&H(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&i&&i.posAtStart>e.state.selection.to)for(let e=n.focusNode;;e=e.parentNode){if(getComputedStyle(e).overflow!=`visible`){l=I.findFrom(r.resolve(i.posAtStart),1);break}if(e==i.dom||e.nextSibling||!e.parentNode||!H(e.parentNode))break}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let a=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(t<0)return null;[c,o]=i==e.state.selection.anchor?[i,t]:[t,i],s=r.resolve(o)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let n=t==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=Ap(e,u,s,n)}return l}function bp(e){return e.editable?e.hasFocus():Mp(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function xp(e,t=!1){let n=e.state.selection;if(Op(e,n),!bp(e))return;let r=e.input.mouseDown;if(!t&&W&&r){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Fd(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)&&r.delaySelUpdate()){e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)Dp(e);else{let{anchor:r,head:i}=n,a,o;Sp&&!(n instanceof L)&&(n.$from.parent.inlineContent||(a=Cp(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=Cp(e,n.to))),e.docView.setSelection(r,i,e,t),Sp&&(a&&Tp(a),o&&Tp(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&Ep(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}var Sp=af||W&&rf<63;function Cp(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(af&&i&&i.contentEditable==`false`)return wp(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return wp(i);if(a)return wp(a)}}function wp(e){return e.contentEditable=`true`,af&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Tp(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function Ep(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!bp(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function Dp(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,B(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&$d&&ef<=11&&(n.disabled=!0,n.disabled=!1)}function Op(e,t){if(t instanceof R){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(kp(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else kp(e)}function kp(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function Ap(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||L.between(t,n,r)}function jp(e){return e.editable&&!e.hasFocus()?!1:Mp(e)}function Mp(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return Rd(e.dom,t.anchorNode)&&(e.editable||Rd(e.dom,t.focusNode))}catch{return!1}}function Np(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Fd(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Pp(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&I.findFrom(a,t)}function Fp(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Ip(e,t,n){let r=e.state.selection;if(r instanceof L){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return Fp(e,new L(r.$anchor,a))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=Pp(e.state,t);return n&&n instanceof R?Fp(e,n):!1}if(!sf||n.indexOf(`m`)<0){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?R.isSelectable(i)?Fp(e,new R(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):Fp(e,new L(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1}}else if(r instanceof R&&r.node.isInline)return Fp(e,new L(t>0?r.$to:r.$from));else{let n=Pp(e.state,t);return n?Fp(e,n):!1}}function Lp(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`):H(e)&&e.contentEditable==`false`}function Rp(e,t){return t<0?zp(e):Bp(e)}function zp(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(tf&&H(n)&&r<V(n)&&Lp(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(!H(n))break;let e=n.childNodes[r-1];if(Lp(e,-1))i=n,a=--r;else if(U(e))n=e,r=n.nodeValue.length;else break}else if(Vp(n))break;else{let t=n.previousSibling;for(;t&&Lp(t,-1);)i=n.parentNode,a=B(t),t=t.previousSibling;if(t)n=t,r=V(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?Wp(e,n,r):i&&Wp(e,i,a)}function Bp(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=V(n),a,o;for(;;)if(r<i){if(!H(n))break;if(Lp(n.childNodes[r],1))a=n,o=++r;else break}else if(Vp(n))break;else{let t=n.nextSibling;for(;t&&Lp(t,1);)a=t.parentNode,o=B(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=V(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&Wp(e,a,o)}function Vp(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Hp(e,t){for(;e&&t==e.childNodes.length&&!Hd(e);)t=B(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(U(n))return n;if(H(n)&&n.contentEditable==`false`)break;e=n,t=0}}function Up(e,t){for(;e&&!t&&!Hd(e);)t=B(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(U(n))return n;if(H(n)&&n.contentEditable==`false`)break;e=n,t=e.childNodes.length}}function Wp(e,t,n){if(!U(t)){let e,r;(r=Hp(t,n))?(t=r,n=0):(e=Up(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection(),i=e.domSelectionRange();if(!r)return;Ud(i)?r.collapse(t,n):r.extend&&(r.collapse(i.anchorNode,i.anchorOffset),r.extend(t,n)),e.domObserver.setCurSelection();let{state:a}=e;setTimeout(()=>{e.state==a&&xp(e)},50)}function Gp(e,t){let n=e.state.doc.resolve(t);if(!(W||cf)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?`ltr`:`rtl`}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?`ltr`:`rtl`}}let r=e.dom;for(let t=n.depth;t>0;t--)if(n.node(t).isBlock){r=e.nodeDOM(n.before(t))||r;break}return getComputedStyle(r).direction==`rtl`?`rtl`:`ltr`}function Kp(e,t,n){let r=e.state.selection;if(r instanceof L&&!r.empty||n.indexOf(`s`)>-1||sf&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=Pp(e.state,t);if(n&&n instanceof R)return Fp(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof Pl?I.near(n,t):I.findFrom(n,t);return o?Fp(e,o):!1}return!1}function qp(e,t){if(!(e.state.selection instanceof L))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function Jp(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Yp(e){if(!af||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&H(t)&&n==0&&t.firstChild&&H(t.firstChild)&&t.firstChild.contentEditable==`false`){let n=t.firstChild;Jp(e,n,`true`),setTimeout(()=>Jp(e,n,`false`),20)}return!1}function Xp(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function Zp(e,t){let n=t.keyCode,r=Xp(t);if(n==8||sf&&n==72&&r==`c`)return qp(e,-1)||Rp(e,-1);if(n==46&&!t.shiftKey||sf&&n==68&&r==`c`)return qp(e,1)||Rp(e,1);if(n==13||n==27)return!0;if(n==37||sf&&n==66&&r==`c`){let t=n==37?Gp(e,e.state.selection.from)==`ltr`?-1:1:-1;return Ip(e,t,r)||Rp(e,t)}if(n==39||sf&&n==70&&r==`c`){let t=n==39?Gp(e,e.state.selection.from)==`ltr`?1:-1:1;return Ip(e,t,r)||Rp(e,t)}return n==38||sf&&n==80&&r==`c`?Kp(e,-1,r)||Rp(e,-1):n==40||sf&&n==78&&r==`c`?Yp(e)||Kp(e,1,r)||Rp(e,1):!(r!=(sf?`m`:`c`)||n!=66&&n!=73&&n!=89&&n!=90)}function Qp(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||sc.fromSchema(e.state.schema),s=cm(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&H(l)&&(u=sm[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&H(l)&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
46
+
47
+ `),slice:t}}function $p(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new P(M.from(e.state.schema.text(t.replace(/\r\n?/g,`
48
+ `))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=sc.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=dm(n),uf&&fm(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&!H(e);)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||qs.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!em.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=pm(om(s,+u[1],+u[2]),u[4]);else if(s=P.maxOpen(tm(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=om(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var em=/^(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 tm(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&rm(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=im(a[a.length-1],i.length));let n=nm(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return M.from(a)}return e}function nm(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,M.from(e));return e}function rm(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=rm(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(M.from(nm(n,e,i+1))))}}function im(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,im(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(M.empty,!0);return e.copy(n.append(r))}function am(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=am(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(M.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function om(e,t,n){return t<e.openStart&&(e=new P(am(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new P(am(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var sm={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 cm(){return document.implementation.createHTMLDocument(`title`)}var lm=null;function um(e){let t=window.trustedTypes;if(!t)return e;if(!lm){if(lm=t.defaultPolicy)try{return lm.createHTML(e)}catch{}lm=t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e})}return lm.createHTML(e)}function dm(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=cm(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),a;if((a=i&&sm[i[1].toLowerCase()])&&(e=a.map(e=>`<`+e+`>`).join(``)+e+a.map(e=>`</`+e+`>`).reverse().join(``)),r.innerHTML=um(e),a)for(let e=0;e<a.length;e++)r=r.querySelector(a[e])||r;for(let e=0;e<n.styleSheets.length;e++){let t=n.styleSheets[e];for(let e=0;e<t.rules.length;e++){let n=t.rules[e];if(n instanceof CSSStyleRule){let e=r.querySelectorAll(n.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=n.style.cssText}}}return r}function fm(e){let t=e.querySelectorAll(W?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function pm(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;try{i=M.from(t.create(r[e+1],i))}catch{break}a++,o++}return new P(i,a,o)}var mm={},hm={},gm={touchstart:!0,touchmove:!0},_m=class{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 vm(e){for(let t in mm){let n=mm[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{Cm(e,t)&&!Sm(e,t)&&(e.editable||!(t.type in hm))&&n(e,t)},gm[t]?{passive:!0}:void 0)}af&&e.dom.addEventListener(`input`,()=>null),xm(e)}function ym(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function bm(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function xm(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Sm(e,t))})}function Sm(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function Cm(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function wm(e,t){!Sm(e,t)&&mm[t.type]&&(e.editable||!(t.type in hm))&&mm[t.type](e,t)}function Tm(e,t){let{input:n}=e;return n.lastKeyDispatched||e.composing?!1:(n.lastKeyDispatched=!0,typeof t==`string`&&(t=Wd(t==`Backspace`?8:13,t)),e.someProp(`handleKeyDown`,n=>n(e,t)))}hm.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Hm(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),e.input.lastKeyDispatched=!1,!(lf&&W&&n.keyCode==13))){if(n.keyCode!=229&&e.domObserver.forceFlush(),of&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(Tm(e,`Enter`),e.input.lastIOSEnter=0)},200)}else Tm(e,n)||Zp(e,n)?n.preventDefault():ym(e,`key`)}},hm.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},hm.keypress=(e,t)=>{let n=t;if(Hm(e)||!n.charCode||n.ctrlKey&&!n.altKey||sf&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof L)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function Em(e){return{left:e.clientX,top:e.clientY}}function Dm(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Om(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function km(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta(`pointer`,!0),e.dispatch(r)}function Am(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&R.isSelectable(r)?(km(e,new R(n)),!0):!1}function jm(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof R&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(R.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i!=null&&(km(e,R.create(e.state.doc,i)),!0)}function Mm(e,t,n,r,i){return Om(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?jm(e,n):Am(e,n))}function Nm(e,t,n,r){return Om(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Pm(e,t,n,r){return Om(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Fm(e,n,r)}function Fm(e,t,n){if(n.button!=0)return!1;let r=Im(e,t,!0),i=e.state.doc;return r?(km(e,r),r instanceof L&&i.eq(e.state.doc)&&(e.input.mouseDown=new Vm(e,r)),!0):!1}function Im(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?L.create(r,0,r.content.size):null;let i=r.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e),a=i.before(e);if(t.inlineContent)return L.create(r,a+1,a+1+t.content.size);if(n&&R.isSelectable(t))return R.create(r,a)}return null}function Lm(e){return Jm(e)}var Rm=sf?`metaKey`:`ctrlKey`;mm.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Lm(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&Dm(n,e.input.lastClick)&&!n[Rm]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let o=e.posAtCoords(Em(n));o&&(a==`singleClick`?e.input.mouseDown=new Bm(e,o,n,!!r):(a==`doubleClick`?Nm:Pm)(e,o.pos,o.inside,n)?n.preventDefault():ym(e,`pointer`))};var zm=class{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}},Bm=class extends zm{constructor(e,t,n,r){super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[Rm],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&H(s.nodeDOM)?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof R&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!(!this.target||this.target.draggable),setUneditable:!!(this.target&&tf&&!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()),ym(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||xp(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Em(e))),this.updateAllowDefault(e),this.allowDefault||!t?ym(this.view,`pointer`):Mm(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||af&&this.mightDrag&&!this.mightDrag.node.isAtom||W&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(km(this.view,I.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ym(this.view,`pointer`)}move(e){this.updateAllowDefault(e),ym(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}},Vm=class extends zm{constructor(e,t){super(e),this.startSelection=t,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(),ym(this.view,`pointer`);let t=this.view.posAtCoords(Em(e)),n=t&&Im(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,i=this.startSelection,[a,o]=n.from<i.from?[i.to,n.from]:[i.from,n.to];km(this.view,L.create(r,a,o))}};mm.touchstart=e=>{e.input.lastTouch=Date.now(),Lm(e),ym(e,`pointer`)},mm.touchmove=e=>{e.input.lastTouch=Date.now(),ym(e,`pointer`)},mm.contextmenu=e=>Lm(e);function Hm(e,t){return e.composing?!0:af&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Um=lf?5e3:-1;hm.compositionstart=hm.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof L&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||W&&cf&&Wm(e)))e.markCursor=e.state.storedMarks||n.marks(),Jm(e,!0),e.markCursor=null;else if(Jm(e,!t.selection.empty),tf&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&H(n)&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(U(t)){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}Gm(e,Um)};function Wm(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!H(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return H(r)&&r.contentEditable==`false`}hm.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Gm(e,20))};function Gm(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Jm(e),t))}function Km(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function qm(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=zd(t.focusNode,t.focusOffset),r=Bd(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function Jm(e,t=!1){if(!(lf&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Km(e),t||e.docView&&e.docView.dirty){let n=yp(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Ym(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var Xm=$d&&ef<15||of&&df<604;mm.copy=hm.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Xm?null:n.clipboardData,{dom:o,text:s}=Qp(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Ym(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function Zm(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Qm(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.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=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?$m(e,r.value,null,i,t):$m(e,r.textContent,r.innerHTML,i,t)},50)}function $m(e,t,n,r,i){let a=$p(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||P.empty)))return!0;if(!a)return!1;let o=Zm(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function eh(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}hm.paste=(e,t)=>{let n=t;if(e.composing&&!lf)return;let r=Xm?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&$m(e,eh(r),r.getData(`text/html`),i,n)?n.preventDefault():Qm(e,n)};var th=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},nh=sf?`altKey`:`ctrlKey`;function rh(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[nh]:!n}mm.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(Em(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof R?i.to-1:i.to))){if(r&&r.mightDrag)o=R.create(e.state.doc,r.mightDrag.pos);else if(n.target&&H(n.target)){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=R.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Qp(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!W||rf>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Xm?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Xm||n.dataTransfer.setData(`text/plain`,c),e.dragging=new th(l,rh(e,n),o)},mm.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},hm.dragover=hm.dragenter=(e,t)=>t.preventDefault(),hm.drop=(e,t)=>{try{ih(e,t,e.dragging)}finally{e.dragging=null}};function ih(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Em(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=$p(e,eh(t.dataTransfer),Xm?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&rh(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||P.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?sl(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&R.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new R(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(Ap(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}mm.focus=e=>{if(e.input.lastFocus=Date.now(),!e.focused){e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0;let t=e.domSelectionRange();if(!e.domObserver.currentSelection.eq(t)){let{focusNode:n,focusOffset:r}=t;setTimeout(()=>{let t=e.domSelectionRange();t.focusNode==n&&t.focusOffset==r&&e.docView&&e.hasFocus()&&xp(e)},20)}}},mm.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},mm.beforeinput=(e,t)=>{if(lf&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||e.domObserver.pendingRecords().length||(e.dom.blur(),e.focus(),Tm(e,`Backspace`)))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in hm)mm[e]=hm[e];function ah(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var oh=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}},sh=class e{constructor(e,t){this.toDOM=e,this.spec=t||fh,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new uh(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&ah(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},ch=class e{constructor(e,t){this.attrs=e,this.spec=t||fh}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new uh(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&ah(this.attrs,t.attrs)&&ah(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},lh=class e{constructor(e,t){this.attrs=e,this.spec=t||fh}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new uh(i.pos-n,a.pos-n,this)}valid(e,t,n){let r=n.nodeAt(t.from);return!!r&&!r.isText&&t.from+r.nodeSize==t.to}eq(t){return this==t||t instanceof e&&ah(this.attrs,t.attrs)&&ah(this.spec,t.spec)}destroy(){}},uh=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new sh(n,r))}static inline(t,n,r,i){return new e(t,n,new ch(r,i))}static node(t,n,r,i){return new e(t,n,new lh(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof ch}get widget(){return this.type instanceof sh}},dh=[],fh={},ph=class e{constructor(e,t){this.local=e.length?e:dh,this.children=t.length?t:dh}static create(e,t){return t.length?xh(t,e,0,fh):mh}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==mh||e.maps.length==0?this:this.mapInner(e,t,0,0,n||fh)}mapInner(t,n,r,i,a){let o;if(this.local.length){let e=new oh(n.content);for(let s=0;s<this.local.length;s++){let c=this.local[s].map(t,r,i);c&&c.type.valid(n,c,e)?(o||=[]).push(c):a.onRemove&&a.onRemove(this.local[s].spec)}}return this.children.length?gh(this.children,o||[],t,n,r,i,a):o?new e(o.sort(Sh),dh):mh}add(t,n){return n.length?this==mh?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=yh(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,xh(s,e,o+1,fh)),a+=3}});let o=_h(a?bh(n):n,-r);if(o.length){let e=new oh(t.content);for(let n=0;n<o.length;n++)o[n].type.valid(t,o[n],e)||o.splice(n--,1)}return new e(o.length?this.local.concat(o).sort(Sh):this.local,i||this.children)}remove(e){return e.length==0||this==mh?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==mh?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):mh}forChild(t,n){if(this==mh)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof ch){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(Sh),dh);return r?new hh([t,r]):t}return r||mh}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return Ch(this.localsInner(e))}localsInner(e){if(this==mh)return dh;if(e.inlineContent||!this.local.some(ch.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof ch||t.push(this.local[e]);return t}forEachSet(e){e(this)}};ph.empty=new ph([],[]),ph.removeOverlap=Ch;var mh=ph.empty,hh=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,fh));return e.from(r)}forChild(t,n){if(n.isLeaf)return ph.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=mh&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length){if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}}return t?Ch(n?t:t.sort(Sh)):dh}static from(t){switch(t.length){case 0:return mh;case 1:return t[0];default:return new e(t.every(e=>e instanceof ph)?t:t.reduce((e,t)=>e.concat(t instanceof ph?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function gh(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==mh?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=xh(vh(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new ph(t.sort(Sh),s)}function _h(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new uh(i.from+t,i.to+t,i.type))}return n}function vh(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function yh(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function bh(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function xh(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=yh(e,t,o+n);if(s){a=!0;let e=xh(s,t,n+o+1,r);e!=mh&&i.push(o,o+t.nodeSize,e)}});let o=_h(a?bh(e):e,-n).sort(Sh);if(o.length){let e=new oh(t.content);for(let n=0;n<o.length;n++)o[n].type.valid(t,o[n],e)||(r.onRemove&&r.onRemove(o[n].spec),o.splice(n--,1))}return o.length||i.length?new ph(o,i):mh}function Sh(e,t){return e.from-t.from||e.to-t.to}function Ch(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from)a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),wh(t,i+1,a.copy(r.to,a.to)));else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),wh(t,i,r.copy(a.from,r.to)));break}}}return t}function wh(e,t,n){for(;t<e.length&&Sh(n,e[t])>0;)t++;e.splice(t,0,n)}function Th(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=mh&&t.push(r)}),e.cursorWrapper&&t.push(ph.create(e.state.doc,[e.cursorWrapper.deco])),hh.from(t)}var Eh={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Dh=$d&&ef<=11,Oh=class{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}},kh=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Oh,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);$d&&ef<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():af&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Dh&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.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,Eh)),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 t=0;t<e.length;t++)this.queue.push(e[t]);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(jp(this.view)){if(this.suppressingSelectionUpdates)return xp(this.view);if($d&&ef<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Fd(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 t=new Set,n;for(let n=e.focusNode;n;n=jd(n))t.add(n);for(let r=e.anchorNode;r;r=jd(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:U(n)?n.parentNode:n}))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 t=this.pendingRecords();t.length&&(this.queue=[]);let n,r=!1;!this.suppressingSelectionUpdates&&jp(e)&&(n=e.domSelectionRange(),r=!this.currentSelection.eq(n)&&!this.ignoreSelectionChange(n));let i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||W&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(e=>e.type==`childList`&&e.removedNodes.length))){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&H(t);){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(tf&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Fh(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ud(n)&&(c=yp(e))&&c.eq(I.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,xp(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),Mh(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Ih(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):n&&!this.currentSelection.eq(n)&&xp(e),n&&this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),U(r)&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if($d&&ef<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?B(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?B(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}return e.type==`attributes`?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Ah=new WeakMap,jh=!1;function Mh(e){if(!Ah.has(e)&&(Ah.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=tf,jh)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.`),jh=!0}}function Nh(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return Fd(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Ph(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Nh(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?Nh(e,n):null}function Fh(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Ih(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||!H(e)||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function Lh(e,t,n,r){let{node:i,fromOffset:a,toOffset:o,from:s,to:c}=e.docView.parseRange(t,n),l=e.domSelectionRange(),u,d=l.anchorNode;if(d&&Rd(e.dom,d)&&(u=[{node:d,offset:l.anchorOffset}],Ud(l)||u.push({node:l.focusNode,offset:l.focusOffset})),W&&e.input.lastKeyCode===8)for(let e=o;e>a;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){o=e;break}if(!n||n.size)break}let f=e.state.doc,p=e.someProp(`domParser`)||qs.fromSchema(e.state.schema),m=f.resolve(s),h=null,g=p.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:a,to:o,preserveWhitespace:m.parent.type.whitespace!=`pre`||`full`,findPositions:u,ruleFromNode:Rh(r),context:m});if(u&&u[0].pos!=null){let e=u[0].pos,t=u[1]&&u[1].pos;t??=e,h={anchor:e+s,head:t+s}}return{doc:g,sel:h,from:s,to:c}}var Rh=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName==`BR`&&t.parentNode){if(af&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}if(t.parentNode.lastChild==t||af&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName==`IMG`&&t.getAttribute(`mark-placeholder`))return{ignore:!0};return null},zh=/^(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 Bh(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=yp(e,t);if(n&&!e.state.selection.eq(n)){if(W&&lf&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&Tm(e,`Enter`))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=Lh(e,t,n,i),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=Kh(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(of&&e.input.lastIOSEnter>Date.now()-225||lf)&&i.some(e=>H(e)&&!zh.test(e.nodeName))&&(!m||m.endA>=m.endB)&&Tm(e,`Enter`)){e.input.lastIOSEnter=0;return}if(!m){if(r&&c instanceof L&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Vh(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof L&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),$d&&ef<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((of&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&Wh(l.doc,h.pos,g.pos))&&Tm(e,`Enter`)){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&(v?m.endA>m.start&&m.endB==m.start:Uh(u,m.start,m.endA,h,g))&&Tm(e,`Backspace`)){lf&&W&&e.domObserver.suppressSelectionUpdates();return}W&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),lf&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>Tm(e,`Enter`),20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Vh(e,n.doc,l.sel);t&&!(W&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1)||$d&&t.empty&&t.head==y)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},S;if(v){if(h.pos==g.pos){$d&&ef<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>xp(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=Hh(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x())}else e.dispatch(x())}function Vh(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Ap(e,t.resolve(n.anchor),t.resolve(n.head))}function Hh(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(M.from(l).eq(e))return{mark:s,type:o}}function Uh(e,t,n,r,i){if(n-t<=i.pos-r.pos||Gh(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.inlineContent){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(Gh(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Gh(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Wh(e,t,n){let r=0,i=0;return e.nodesBetween(t,n,(e,a)=>{e.isTextblock&&a>=t&&a<n?r++:(e.isText?/\S/.test(e.text.slice(Math.max(0,t-a),Math.min(e.nodeSize,n-a))):e.isLeaf)&&i++}),i==0&&r==1}function Gh(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function Kh(e,t,n,r,i){let a=e.findDiffStart(t,n),o=n+e.size,s=n+t.size;if(a==null)return null;let{a:c,b:l}=e.findDiffEnd(t,o,s);if(i==`end`){let e=Math.max(0,a-Math.min(c,l));r-=c+e-a}if(c<a&&o<s){let e=r<=a&&r>=c?a-r:0;a-=e,l=a+(l-c),c=a}else if(l<a){let e=r<=a&&r>=l?a-r:0;a-=e,c=a+(c-l),l=a}return{start:a,endA:c,endB:l}}var qh=class{constructor(e,t){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 _m,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(eg),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=Xh(this),Yh(this),this.nodeViews=Qh(this),this.docView=$f(this.state.doc,Jh(this),Th(this),this.dom,this),this.domObserver=new kh(this,(e,t,n,r)=>Bh(this,e,t,n,r)),this.domObserver.start(),vm(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 t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&xm(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(eg),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Km(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Qh(this);$h(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&xm(this),this.editable=Xh(this),Yh(this);let o=Th(this),s=Jh(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&gf(this);if(i){this.domObserver.stop();let t=l&&($d||W)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Zh(n.selection,e.selection);if(l){let n=W?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=qm(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=$f(e.doc,s,o,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}let i=this.input.mouseDown;t||!(i&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Np(this)&&i.delaySelUpdate())?xp(this,t):(Op(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&vf(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&Rd(this.dom,e)&&!this.someProp(`handleScrollToSelection`,e=>e(this))){if(this.state.selection instanceof R){let t=this.docView.domAfterPos(this.state.selection.from);H(t)&&hf(this,t.getBoundingClientRect(),e)}else hf(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 e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new th(e.slice,e.move,r<0?void 0:R.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if($d){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&&xf(this.dom),xp(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return kf(this,e)}coordsAtPos(e,t=1){return Nf(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Uf(this,t||this.state,e)}pasteHTML(e,t){return $m(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return $m(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Qp(this,e)}destroy(){this.docView&&(bm(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Th(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Pd())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return wm(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?af&&this.root.nodeType===11&&Gd(this.dom.ownerDocument)==this.dom&&Ph(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};qh.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Jh(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[uh.node(0,e.state.doc.content.size,t)]}function Yh(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:uh.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Xh(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Zh(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function Qh(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function $h(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function eg(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}function tg(e,t){return e.meta={package:`@milkdown/core`,group:`System`,...t},e}var ng={text:(e,t,n,r)=>{let i=e.value??``,a=r.after??``,o=/^[\r\n]/.test(a);if(o&&t?.children.at(-1)!==e)return n.safe(i,r);let s=i.length;for(;s>0&&(i[s-1]===` `||i[s-1]===` `);)s--;let c=i.slice(s),l=o?a:c+a;return n.safe(i.slice(0,s),{...r,after:l})+c},strong:(e,t,n,r)=>{let i=e.marker||n.options.strong||`*`,a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i+i),a(),s},emphasis:(e,t,n,r)=>{let i=e.marker||n.options.emphasis||`*`,a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i),a(),s}},rg=T({},`editorView`),ig=T({},`editorState`),ag=T([],`initTimer`),og=T({},`editor`),sg=T([],`inputRules`),cg=T([],`prosePlugins`),lg=T([],`remarkPlugins`),ug=T([],`nodeView`),dg=T([],`markView`),fg=T(Po().use(Qr).use(io),`remark`),pg=T({handlers:ng,encode:[]},`remarkStringifyOptions`),mg=Qe(`ConfigReady`);function hg(e){let t=t=>(t.record(mg),async()=>(await e(t),t.done(mg),()=>{t.clearTimer(mg)}));return tg(t,{displayName:`Config`}),t}var gg=Qe(`InitReady`);function _g(e){let t=t=>(t.inject(og,e).inject(cg,[]).inject(lg,[]).inject(sg,[]).inject(ug,[]).inject(dg,[]).inject(pg,{handlers:ng,encode:[]}).inject(fg,Po().use(Qr).use(io)).inject(ag,[mg]).record(gg),async()=>{await t.waitTimers(ag);let e=t.get(pg);return t.set(fg,Po().use(Qr).use(io,e)),t.done(gg),()=>{t.remove(og).remove(cg).remove(lg).remove(sg).remove(ug).remove(dg).remove(pg).remove(fg).remove(ag).clearTimer(gg)}});return tg(t,{displayName:`Init`}),t}var vg=Qe(`SchemaReady`),yg=T([],`schemaTimer`),bg=T({},`schema`),xg=T([],`nodes`),Sg=T([],`marks`);function Cg(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var wg=e=>(e.inject(bg,{}).inject(xg,[]).inject(Sg,[]).inject(yg,[gg]).record(vg),async()=>{await e.waitTimers(yg);let t=e.get(fg),n=e.get(lg).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(fg,n);let r=new Us({nodes:Object.fromEntries(e.get(xg).map(([e,t])=>[e,Cg(t)])),marks:Object.fromEntries(e.get(Sg).map(([e,t])=>[e,Cg(t)]))});return e.set(bg,r),e.done(vg),()=>{e.remove(bg).remove(xg).remove(Sg).remove(yg).clearTimer(vg)}});tg(wg,{displayName:`Schema`});var Tg=class{constructor(){this.#e=new We,this.#t=null,this.setCtx=e=>{this.#t=e},this.chain=()=>{if(this.#t==null)throw Ve();let e=this.#t,t=[],n=this.get.bind(this),r={run:()=>{let n=Ou(...t),r=e.get(rg);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:i.bind(this)};function i(e,i){let a=n(e);return t.push(a(i)),r}return r}}#e;#t;get ctx(){return this.#t}create(e,t){let n=e.create(this.#e.sliceMap);return n.set(t),n}get(e){return this.#e.get(e).get()}remove(e){return this.#e.remove(e)}call(e,t){if(this.#t==null)throw Ve();let n=this.get(e)(t),r=this.#t.get(rg);return n(r.state,r.dispatch,r)}inline(e){if(this.#t==null)throw Ve();let t=this.#t.get(rg);return e(t.state,t.dispatch,t)}};function Eg(e=`cmdKey`){return T((()=>()=>!1),e)}var G=T(new Tg,`commands`),Dg=T([vg],`commandsTimer`),Og=Qe(`CommandsReady`),kg=e=>{let t=new Tg;return t.setCtx(e),e.inject(G,t).inject(Dg,[vg]).record(Og),async()=>(await e.waitTimers(Dg),e.done(Og),()=>{e.remove(G).remove(Dg).clearTimer(Og)})};tg(kg,{displayName:`Commands`});function Ag(e){return e.Backspace=Ou(Iu,Ql,tu,iu),e}var jg=class{constructor(){this.#e=null,this.#t=[],this.setCtx=e=>{this.#e=e},this.add=e=>(this.#t.push(e),()=>{this.#t=this.#t.filter(t=>t!==e)}),this.addObjectKeymap=e=>{let t=[];return Object.entries(e).forEach(([e,n])=>{if(typeof n==`function`){let r={key:e,onRun:()=>n};this.#t.push(r),t.push(()=>{this.#t=this.#t.filter(e=>e!==r)})}else this.#t.push(n),t.push(()=>{this.#t=this.#t.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{let e=Ag(Nu);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#t.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,r)=>{let i=this.#e;if(i==null)throw Fe();return Ou(...n.map(e=>e.onRun(i)))(e,t,r)}]}))}}#e;#t;get ctx(){return this.#e}},Mg=T(new jg,`keymap`),Ng=T([vg],`keymapTimer`),Pg=Qe(`KeymapReady`),Fg=e=>{let t=new jg;return t.setCtx(e),e.inject(Mg,t).inject(Ng,[vg]).record(Pg),async()=>(await e.waitTimers(Ng),e.done(Pg),()=>{e.remove(Mg).remove(Ng).clearTimer(Pg)})},Ig=Qe(`ParserReady`),Lg=(()=>{throw Fe()}),Rg=T(Lg,`parser`),zg=T([],`parserTimer`),Bg=e=>(e.inject(Rg,Lg).inject(zg,[vg]).record(Ig),async()=>{await e.waitTimers(zg);let t=e.get(fg),n=e.get(bg);return e.set(Rg,Ed.create(n,t)),e.done(Ig),()=>{e.remove(Rg).remove(zg).clearTimer(Ig)}});tg(Bg,{displayName:`Parser`});var Vg=Qe(`SerializerReady`),Hg=T([],`serializerTimer`),Ug=(()=>{throw Fe()}),Wg=T(Ug,`serializer`),Gg=e=>(e.inject(Wg,Ug).inject(Hg,[vg]).record(Vg),async()=>{await e.waitTimers(Hg);let t=e.get(fg),n=e.get(bg);return e.set(Wg,Ad.create(n,t)),e.done(Vg),()=>{e.remove(Wg).remove(Hg).clearTimer(Vg)}});tg(Gg,{displayName:`Serializer`});var Kg=T(``,`defaultValue`),qg=T(e=>e,`stateOptions`),Jg=T([],`editorStateTimer`),Yg=Qe(`EditorStateReady`);function Xg(e,t,n){if(typeof e==`string`)return t(e);if(e.type===`html`)return qs.fromSchema(n).parse(e.dom);if(e.type===`json`)return _s.fromJSON(n,e.value);throw Me(e)}var Zg=new Zl(`MILKDOWN_STATE_TRACKER`),Qg=e=>(e.inject(Kg,``).inject(ig,{}).inject(qg,e=>e).inject(Jg,[Ig,Vg,Og,Pg]).record(Yg),async()=>{await e.waitTimers(Jg);let t=e.get(bg),n=e.get(Rg),r=e.get(sg),i=e.get(qg),a=e.get(cg),o=Xg(e.get(Kg),n,t),s=e.get(Mg),c=s.addBaseKeymap(),l=[...a,new Jl({key:Zg,state:{init:()=>{},apply:(t,n,r,i)=>{e.set(ig,i)}}}),Zu({rules:r}),xd(s.build())];e.set(cg,l);let u=i({schema:t,doc:o,plugins:l}),d=Kl.create(u);return e.set(ig,d),e.done(Yg),()=>{c(),e.remove(Kg).remove(ig).remove(qg).remove(Jg).clearTimer(Yg)}});tg(Qg,{displayName:`EditorState`});var $g=T([],`pasteRule`),e_=T([vg],`pasteRuleTimer`),t_=Qe(`PasteRuleReady`),n_=e=>(e.inject($g,[]).inject(e_,[vg]).record(t_),async()=>(await e.waitTimers(e_),e.done(t_),()=>{e.remove($g).remove(e_).clearTimer(t_)}));tg(n_,{displayName:`PasteRule`});var r_=Qe(`EditorViewReady`),i_=T([],`editorViewTimer`),a_=T({},`editorViewOptions`),o_=T(null,`root`),s_=T(null,`rootDOM`),c_=T({},`rootAttrs`);function l_(e,t){let n=document.createElement(`div`);n.className=`milkdown`,e.appendChild(n),t.set(s_,n);let r=t.get(c_);return Object.entries(r).forEach(([e,t])=>n.setAttribute(e,t)),n}function u_(e){e.classList.add(`editor`),e.setAttribute(`role`,`textbox`)}var d_=new Zl(`MILKDOWN_VIEW_CLEAR`),f_=e=>(e.inject(o_,document.body).inject(rg,{}).inject(a_,{}).inject(s_,null).inject(c_,{}).inject(i_,[Yg,t_]).record(r_),async()=>{await e.wait(gg);let t=e.get(o_)||document.body,n=typeof t==`string`?document.querySelector(t):t;e.update(cg,t=>[new Jl({key:d_,view:t=>{let r=n?l_(n,e):void 0;return(()=>{if(r&&n){let e=t.dom;n.replaceChild(r,e),r.appendChild(e)}})(),{destroy:()=>{r?.parentNode&&r?.parentNode.replaceChild(t.dom,r),r?.remove()}}}}),...t]),await e.waitTimers(i_);let r=e.get(ig),i=e.get(a_),a=new qh(n,{state:r,nodeViews:Object.fromEntries(e.get(ug)),markViews:Object.fromEntries(e.get(dg)),transformPasted:(t,n,r)=>(e.get($g).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...i});return u_(a.dom),e.set(rg,a),e.done(r_),()=>{a?.destroy(),e.remove(o_).remove(rg).remove(a_).remove(s_).remove(c_).remove(i_).clearTimer(r_)}});tg(f_,{displayName:`EditorView`});var p_=class e{constructor(){this.#e=!1,this.#t=`Idle`,this.#n=[],this.#r=()=>void 0,this.#i=new We,this.#a=new Ye,this.#o=new Map,this.#s=new Map,this.#c=new Je(this.#i,this.#a),this.#l=()=>{let e=hg(async e=>{await Promise.all(this.#n.map(t=>Promise.resolve(t(e))))}),t=[wg,Bg,Gg,kg,Fg,n_,Qg,f_,_g(this),e];this.#u(t,this.#s)},this.#u=(e,t)=>{e.forEach(e=>{let n=this.#c.produce(this.#e?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})},this.#d=(e,t=!1)=>Promise.all([e].flat().map(async e=>{let n=this.#o.get(e)?.cleanup;return t?this.#o.delete(e):this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof n==`function`?n():n})),this.#f=async()=>{await Promise.all([...this.#s.entries()].map(async([e,{cleanup:t}])=>typeof t==`function`?t():t)),this.#s.clear()},this.#p=e=>{this.#t=e,this.#r(e)},this.#m=e=>[...e.entries()].map(async([t,n])=>{let{ctx:r,handler:i}=n;if(!i)return;let a=await i();e.set(t,{ctx:r,handler:i,cleanup:a})}),this.enableInspector=(e=!0)=>(this.#e=e,this),this.onStatusChange=e=>(this.#r=e,this),this.config=e=>(this.#n.push(e),this),this.removeConfig=e=>(this.#n=this.#n.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(e=>{this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#t===`Created`&&this.#u(t,this.#o),this},this.remove=async e=>this.#t===`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(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#d([e].flat(),!0),this),this.create=async()=>(this.#t===`OnCreate`||(this.#t===`Created`&&await this.destroy(),this.#p(`OnCreate`),this.#l(),this.#u([...this.#o.keys()],this.#o),await Promise.all([this.#m(this.#s),this.#m(this.#o)].flat()),this.#p(`Created`)),this),this.destroy=async(e=!1)=>this.#t===`Destroyed`||this.#t===`OnDestroy`?this:this.#t===`OnCreate`?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#n=[]),this.#p(`OnDestroy`),await this.#d([...this.#o.keys()],e),await this.#f(),this.#p(`Destroyed`),this),this.action=e=>e(this.#c),this.inspect=()=>this.#e?[...this.#s.values(),...this.#o.values()].map(({ctx:e})=>e?.inspector?.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 e}#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;get ctx(){return this.#c}get status(){return this.#t}},m_=200,K=function(){};K.prototype.append=function(e){return e.length?(e=K.from(e),!this.length&&e||e.length<m_&&this.leafAppend(e)||this.length<m_&&e.leafPrepend(this)||this.appendInner(e)):this},K.prototype.prepend=function(e){return e.length?K.from(e).append(this):this},K.prototype.appendInner=function(e){return new g_(this,e)},K.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?K.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},K.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},K.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},K.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},K.from=function(e){return e instanceof K?e:e&&e.length?new h_(e):K.empty};var h_=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=m_)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=m_)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(K);K.empty=new h_([]);var g_=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(K),__=500,v_=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,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,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step)i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);else{if(i){u.push(new b_(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new b_(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1}},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new b_(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>S_&&(s=y_(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new Tc;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new b_(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],i=this.items.length-n,a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new b_(i,o,l))}else r.push(new b_(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new b_(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>__&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new b_(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(K.from(i.reverse()),a)}};v_.empty=new v_(K.empty,0);function y_(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var b_=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},x_=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},S_=20;function C_(e,t,n,r){let i=n.getMeta(j_),a;if(i)return i.historyState;n.getMeta(M_)&&(e=new x_(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(j_))return o.getMeta(j_).redo?new x_(e.done.addTransform(n,void 0,r,A_(t)),e.undone,T_(n.mapping.maps),e.prevTime,e.prevComposition):new x_(e.done,e.undone.addTransform(n,void 0,r,A_(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!w_(n,e.prevRanges)),s=o?E_(e.prevRanges,n.mapping):T_(n.mapping.maps);return new x_(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,A_(t)),v_.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new x_(e.done.rebased(n,a),e.undone.rebased(n,a),E_(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new x_(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),E_(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function w_(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function T_(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function E_(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function D_(e,t,n){let r=A_(t),i=j_.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new x_(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(j_,{redo:n,historyState:c})}var O_=!1,k_=null;function A_(e){let t=e.plugins;if(k_!=t){O_=!1,k_=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){O_=!0;break}}return O_}var j_=new Zl(`history`),M_=new Zl(`closeHistory`);function N_(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Jl({key:j_,state:{init(){return new x_(v_.empty,v_.empty,null,0,-1)},apply(t,n,r){return C_(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?F_:n==`historyRedo`?I_:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function P_(e,t){return(n,r)=>{let i=j_.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=D_(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var F_=P_(!1,!0),I_=P_(!0,!0),L_=e=>crypto.getRandomValues(new Uint8Array(e)),R_=(e,t,n)=>{let r=256-256%e.length;if(r===256){let r=e.length-1;return(i=t)=>{if(!i)return``;let a=``;for(;;){let t=n(i),o=i|=0;for(;o--;)if(a+=e[t[o]&r],a.length>=i)return a}}}return(i=t)=>{if(!i)return``;let a=``,o=Math.ceil(409.6*i/r);for(;;){let t=n(o),s=o;for(;s--;)if(t[s]<r&&(a+=e[t[s]%e.length],a.length>=i))return a}}};((e,t=21)=>R_(e,t|0,L_))(`abcedfghicklmn`,10);function z_(e,t,n){let r=e.findIndex(([e])=>e===t);if(r===-1)return[...e,n];let i=e.slice();return i[r]=n,i}function q(e,t){let n=Eg(e),r=i=>async()=>{r.key=n,await i.wait(Og);let a=t(i);return i.get(G).create(n,a),r.run=t=>i.get(G).call(e,t),()=>{i.get(G).remove(n)}};return r}function B_(e){let t=n=>async()=>{await n.wait(vg);let r=e(n);return n.update(sg,e=>[...e,r]),t.inputRule=r,()=>{n.update(sg,e=>e.filter(e=>e!==r))}};return t}function V_(e){let t=n=>async()=>{await n.wait(vg);let r=e(n);return n.update($g,e=>[...e,r]),t.pasteRule=r,()=>{n.update($g,e=>e.filter(e=>e!==r))}};return t}function H_(e,t){let n=r=>async()=>{let i=t(r);return r.update(Sg,t=>z_(t,e,[e,i])),n.id=e,n.schema=i,()=>{r.update(Sg,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{let n=t.get(bg).marks[e];if(!n)throw Ue(e);return n},n}function U_(e,t){let n=r=>async()=>{let i=t(r);return r.update(xg,t=>z_(t,e,[e,i])),n.id=e,n.schema=i,()=>{r.update(xg,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{let n=t.get(bg).nodes[e];if(!n)throw He(e);return n},n}function W_(e){let t,n=n=>async()=>(await n.wait(vg),t=e(n),n.update(cg,e=>[...e,t]),()=>{n.update(cg,e=>e.filter(e=>e!==t))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function G_(e){let t=n=>async()=>{await n.wait(Pg);let r=n.get(Mg),i=e(n),a=r.addObjectKeymap(i);return t.keymap=i,()=>{a()}};return t}function K_(e,t){let n=T(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}function J(e,t){let n=K_(t,e),r=U_(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.node=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>J(e,n(t)),i}function q_(e,t){let n=K_(t,e),r=H_(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.mark=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>q_(e,n(t)),i}function J_(e,t){let n=K_(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),r=G_(e=>{let r=e.get(n.key),i=Object.entries(t).flatMap(([e,{command:t}])=>{let n=r[e],i=[n.shortcuts].flat(),a=n.priority;return i.map(e=>[e,{key:e,onRun:t,priority:a}])});return Object.fromEntries(i)}),i=[n,r];return i.ctx=n,i.shortcuts=r,i.key=n.key,i.keymap=r.keymap,i}var Y_=(e,t=()=>({}))=>K_(t,`${e}Attr`),X_=(e,t=()=>({}))=>K_(t,`${e}Attr`);function Z_(e,t,n){let r=K_(n??{},e),i=e=>async()=>{await e.wait(gg);let n={plugin:t(e),options:e.get(r.key)};return e.update(lg,e=>[...e,n]),()=>{e.update(lg,e=>e.filter(e=>e!==n))}},a=[r,i];return a.id=e,a.plugin=i,a.options=r,a}function Q_(e,t){return n=>n.get(G).call(e,t)}function $_(e,t){return Object.assign(e,{meta:{package:`@milkdown/plugin-history`,...t}}),e}var e1=q(`Undo`,()=>()=>F_);$_(e1,{displayName:`Command<undo>`});var t1=q(`Redo`,()=>()=>I_);$_(t1,{displayName:`Command<redo>`});var n1=K_({},`historyProviderConfig`);$_(n1,{displayName:`Ctx<historyProviderConfig>`});var r1=W_(e=>N_(e.get(n1.key)));$_(r1,{displayName:`Ctx<historyProviderPlugin>`});var i1=J_(`historyKeymap`,{Undo:{shortcuts:`Mod-z`,command:e=>{let t=e.get(G);return()=>t.call(e1.key)}},Redo:{shortcuts:[`Mod-y`,`Shift-Mod-z`],command:e=>{let t=e.get(G);return()=>t.call(t1.key)}}});$_(i1.ctx,{displayName:`KeymapCtx<history>`}),$_(i1.shortcuts,{displayName:`Keymap<history>`});var a1=[n1,r1,i1,e1,t1].flat();function o1(e,t){return e instanceof zs?t==e:e.indexOf(t)>-1}function s1(e,t){return function(n,r){let{$from:i,$to:a,node:o}=n.selection;if(o&&o.isBlock||i.depth<2||!i.sameParent(a))return!1;let s=i.node(-1);if(!o1(e,s.type))return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||!o1(e,i.node(-3).type)||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let e=M.empty,t=i.index(-1)?1:i.index(-2)?2:3;for(let n=i.depth-t;n>=i.depth-3;n--)e=M.from(i.node(n).copy(e));let a=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;e=e.append(M.from(i.node(-3).type.createAndFill()));let o=i.before(i.depth-(t-1)),s=n.tr.replace(o,i.after(-a),new P(e,4-t,0)),c=-1;s.doc.nodesBetween(o,s.doc.content.size,(e,t)=>{if(c>-1)return!1;e.isTextblock&&e.content.size==0&&(c=t+1)}),c>-1&&s.setSelection(I.near(s.doc.resolve(c))),r(s.scrollIntoView())}return!0}let c=a.pos==i.end()?s.contentMatchAt(0).defaultType:null,l=n.tr.delete(i.pos,a.pos),u=c?[t?{type:s.type,attrs:t}:null,{type:c}]:void 0;return el(l.doc,i.pos,2,u)?(r&&r(l.split(i.pos,2,u).scrollIntoView()),!0):!1}}function c1(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&o1(e,t.firstChild.type));return a?n?o1(e,r.node(a.depth-1).type)?l1(t,n,a):u1(t,n,a):!0:!1}}function l1(e,t,n){let r=e.tr,i=n.end,a=n.$to.end(n.depth),o=n.parent.child(n.endIndex-1).type;i<a&&(r.step(new Ic(i-1,a,i,a,new P(M.from(o.create(null,n.parent.copy())),1,0),1,!0)),n=new hs(r.doc.resolve(n.$from.pos),r.doc.resolve(a),n.depth));let s=Hc(n);if(s==null)return!1;r.lift(n,s);let c=r.doc.resolve(r.mapping.map(i,-1)-1);return nl(r.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&r.join(c.pos),t(r.scrollIntoView()),!0}function u1(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?M.empty:M.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new Ic(d-+!!s,f+ +!!c,d+1,f-1,new P((s?M.empty:M.from(i.copy(M.empty))).append(c?M.empty:M.from(i.copy(M.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function d1(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&o1(e,t.firstChild.type));if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(!o1(e,c.type))return!1;if(n){let e=c.lastChild&&c.lastChild.type==s.type,r=M.from(e?c.lastChild.lastChild.type.create():null),i=new P(M.from(c.type.create(null,M.from(s.type.create(null,r)))),e?3:1,0),o=a.start,l=a.end;n(t.tr.step(new Ic(o-(e?3:1),l,o,l,i,1,!0)).scrollIntoView())}return!0}}function f1(e){let t=new Map;if(!e||!e.type)throw Error(`mdast-util-definitions expected node`);return $i(e,`definition`,function(e){let n=p1(e.identifier);n&&!t.get(n)&&t.set(n,e)}),n;function n(e){let n=p1(e);return t.get(n)}}function p1(e){return String(e||``).toUpperCase()}function m1(){return function(e){let t=f1(e);$i(e,function(e,n,r){if(e.type===`definition`&&r!==void 0&&typeof n==`number`)return r.children.splice(n,1),[Xi,n];if(e.type===`imageReference`||e.type===`linkReference`){let i=t(e.identifier);if(i&&r&&typeof n==`number`)return r.children[n]=e.type===`imageReference`?{type:`image`,url:i.url,title:i.title,alt:e.alt}:{type:`link`,url:i.url,title:i.title,children:e.children},[Xi,n]}})}}function h1(e){let t={...e};return t.position&&={start:{...t.position.start},end:{...t.position.end}},delete t.children,t}var g1=`<br />`,_1=/^<br\s*\/?\s*>$/i,v1=e=>typeof e==`string`&&_1.test(e.trim());function y1(e,t){if(!(t.childCount>=1&&t.lastChild?.type.name===`hardbreak`)){e.next(t.content);return}let n=[];t.content.forEach((e,r,i)=>{i!==t.childCount-1&&n.push(e)}),e.next(M.fromArray(n))}function Y(e,t){return Object.assign(e,{meta:{package:`@milkdown/preset-commonmark`,...t}}),e}var b1=X_(`emphasis`);Y(b1,{displayName:`Attr<emphasis>`,group:`Emphasis`});var x1=q_(`emphasis`,e=>({attrs:{marker:{default:e.get(pg).emphasis||`*`,validate:`string`}},parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style`,getAttrs:e=>e===`italic`}],toDOM:t=>[`em`,e.get(b1.key)(t)],parseMarkdown:{match:e=>e.type===`emphasis`,runner:(e,t,n)=>{e.hasMark(n)?e.next(t.children):(e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n))}},toMarkdown:{match:e=>e.type.name===`emphasis`,runner:(e,t)=>{e.withMark(t,`emphasis`,void 0,{marker:t.attrs.marker})}}}));Y(x1.mark,{displayName:`MarkSchema<emphasis>`,group:`Emphasis`}),Y(x1.ctx,{displayName:`MarkSchemaCtx<emphasis>`,group:`Emphasis`});var S1=q(`ToggleEmphasis`,e=>()=>Du(x1.type(e)));Y(S1,{displayName:`Command<toggleEmphasisCommand>`,group:`Emphasis`});var C1=B_(e=>td(/(?:^|[^*])\*([^*]+)\*$/,x1.type(e),{getAttr:()=>({marker:`*`}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith(`*`)?{}:{fullMatch:e.slice(1),start:t+1}}));Y(C1,{displayName:`InputRule<emphasis>|Star`,group:`Emphasis`});var w1=B_(e=>td(/\b_(?![_\s])(.*?[^_\s])_$/,x1.type(e),{getAttr:()=>({marker:`_`}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith(`_`)?{}:{fullMatch:e.slice(1),start:t+1}}));Y(w1,{displayName:`InputRule<emphasis>|Underscore`,group:`Emphasis`});var T1=J_(`emphasisKeymap`,{ToggleEmphasis:{shortcuts:`Mod-i`,command:e=>{let t=e.get(G);return()=>t.call(S1.key)}}});Y(T1.ctx,{displayName:`KeymapCtx<emphasis>`,group:`Emphasis`}),Y(T1.shortcuts,{displayName:`Keymap<emphasis>`,group:`Emphasis`});var E1=X_(`strong`);Y(E1,{displayName:`Attr<strong>`,group:`Strong`});var D1=q_(`strong`,e=>({attrs:{marker:{default:e.get(pg).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:t=>[`strong`,e.get(E1.key)(t)],parseMarkdown:{match:e=>e.type===`strong`,runner:(e,t,n)=>{e.hasMark(n)?e.next(t.children):(e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n))}},toMarkdown:{match:e=>e.type.name===`strong`,runner:(e,t)=>{e.withMark(t,`strong`,void 0,{marker:t.attrs.marker})}}}));Y(D1.mark,{displayName:`MarkSchema<strong>`,group:`Strong`}),Y(D1.ctx,{displayName:`MarkSchemaCtx<strong>`,group:`Strong`});var O1=q(`ToggleStrong`,e=>()=>Du(D1.type(e)));Y(O1,{displayName:`Command<toggleStrongCommand>`,group:`Strong`});var k1=B_(e=>td(/(?<![\w:/])(?:\*\*|__)([^*_]+?)(?:\*\*|__)(?![\w/])$/,D1.type(e),{getAttr:e=>({marker:e[0].startsWith(`*`)?`*`:`_`})}));Y(k1,{displayName:`InputRule<strong>`,group:`Strong`});var A1=J_(`strongKeymap`,{ToggleBold:{shortcuts:[`Mod-b`],command:e=>{let t=e.get(G);return()=>t.call(O1.key)}}});Y(A1.ctx,{displayName:`KeymapCtx<strong>`,group:`Strong`}),Y(A1.shortcuts,{displayName:`Keymap<strong>`,group:`Strong`});var j1=X_(`inlineCode`);Y(j1,{displayName:`Attr<inlineCode>`,group:`InlineCode`});var M1=q_(`inlineCode`,e=>({priority:100,code:!0,inclusive:!1,parseDOM:[{tag:`code`}],toDOM:t=>[`code`,e.get(j1.key)(t)],parseMarkdown:{match:e=>e.type===`inlineCode`,runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`inlineCode`,runner:(e,t,n)=>(e.withMark(t,`inlineCode`,n.text||``),!0)}}));Y(M1.mark,{displayName:`MarkSchema<inlineCode>`,group:`InlineCode`}),Y(M1.ctx,{displayName:`MarkSchemaCtx<inlineCode>`,group:`InlineCode`});var N1=q(`ToggleInlineCode`,e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(r.empty)return!1;let{from:a,to:o}=r;return t.doc.rangeHasMark(a,o,M1.type(e))?(n?.(i.removeMark(a,o,M1.type(e))),!0):(Object.keys(t.schema.marks).filter(e=>e!==M1.type.name).map(e=>t.schema.marks[e]).forEach(e=>{i.removeMark(a,o,e)}),n?.(i.addMark(a,o,M1.type(e).create())),!0)});Y(N1,{displayName:`Command<toggleInlineCodeCommand>`,group:`InlineCode`});var P1=B_(e=>td(/(?:`)([^`]+)(?:`)$/,M1.type(e)));Y(P1,{displayName:`InputRule<inlineCodeInputRule>`,group:`InlineCode`});var F1=J_(`inlineCodeKeymap`,{ToggleInlineCode:{shortcuts:`Mod-e`,command:e=>{let t=e.get(G);return()=>t.call(N1.key)}}});Y(F1.ctx,{displayName:`KeymapCtx<inlineCode>`,group:`InlineCode`}),Y(F1.shortcuts,{displayName:`Keymap<inlineCode>`,group:`InlineCode`});var I1=new Set([`http:`,`https:`,`mailto:`,`tel:`,`ftp:`]);function L1(e){return e<=32||e>=127&&e<=160||e>=8203&&e<=8205||e===8232||e===8233||e===65279}function R1(e){let t=``;for(let n of e)L1(n.codePointAt(0)??0)||(t+=n);return t}function z1(e){if(typeof e!=`string`)return``;let t=e.trim();if(!t)return``;let n=R1(t),r=/^([a-z][a-z0-9+.-]*):/i.exec(n)?.[1];return!r||I1.has(`${r.toLowerCase()}:`)?t:``}var B1=X_(`link`);Y(B1,{displayName:`Attr<link>`,group:`Link`});var V1=q_(`link`,e=>({attrs:{href:{validate:`string`},title:{default:null,validate:`string|null`}},parseDOM:[{tag:`a[href]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Be(e);return{href:e.getAttribute(`href`),title:e.getAttribute(`title`)}}}],toDOM:t=>[`a`,{...e.get(B1.key)(t),...t.attrs,href:z1(t.attrs.href)}],parseMarkdown:{match:e=>e.type===`link`,runner:(e,t,n)=>{let r=t.url,i=t.title;e.openMark(n,{href:r,title:i}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`link`,runner:(e,t)=>{e.withMark(t,`link`,void 0,{title:t.attrs.title,url:t.attrs.href})}}}));Y(V1.mark,{displayName:`MarkSchema<link>`,group:`Link`});var H1=q(`ToggleLink`,e=>(t={})=>Du(V1.type(e),t));Y(H1,{displayName:`Command<toggleLinkCommand>`,group:`Link`});var U1=q(`UpdateLink`,e=>(t={})=>(n,r)=>{if(!r)return!1;let i,a=-1,{selection:o}=n,{from:s,to:c}=o;if(n.doc.nodesBetween(s,s===c?c+1:c,(t,n)=>{if(V1.type(e).isInSet(t.marks))return i=t,a=n,!1}),!i)return!1;let l=i.marks.find(({type:t})=>t===V1.type(e));if(!l)return!1;let u=a,d=a+i.nodeSize,{tr:f}=n,p=V1.type(e).create({...l.attrs,...t});return p?(r(f.removeMark(u,d,l).addMark(u,d,p).setSelection(new L(f.selection.$anchor)).scrollIntoView()),!0):!1});Y(U1,{displayName:`Command<updateLinkCommand>`,group:`Link`});var W1=U_(`doc`,()=>({content:`block+`,parseMarkdown:{match:({type:e})=>e===`root`,runner:(e,t,n)=>{e.injectRoot(t,n)}},toMarkdown:{match:e=>e.type.name===`doc`,runner:(e,t)=>{e.openNode(`root`);let n=t.childCount>0?t.child(t.childCount-1):null,r=n?.type.name===`paragraph`&&n.content.size===0?t.content.cut(0,t.content.size-n.nodeSize):t.content;e.next(r)}}}));Y(W1,{displayName:`NodeSchema<doc>`,group:`Doc`});var G1=Object.freeze([`root`,`blockquote`,`listItem`,`footnoteDefinition`]),K1=new Set([`paragraph`,`heading`,`tableCell`,`link`,`linkReference`,`emphasis`,`strong`,`delete`,`footnote`]),q1=K_(G1,`blockContainerTypes`);Y(q1,{displayName:`Ctx<blockContainerTypes>`,group:`Remark`});var J1=new Set;function Y1(e){let t=e.isInjected(q1.key)?e.get(q1.key):G1,n=new Set;for(let e of t)K1.has(e)?J1.has(e)||(J1.add(e),console.warn(`[milkdown/preset-commonmark] "${e}" holds phrasing content and cannot be a block container; it is ignored in blockContainerTypes.`)):n.add(e);return n}var X1=new Set([`paragraph`,`tableCell`]);function Z1(e,t){return Zi(e,e=>e.type===`html`&&v1(e.value),(e,n)=>{let r=n[n.length-1];if(r){if(X1.has(r.type))r.children.length===1&&(r.children=[]);else if(t.has(r.type)){let t=e;return t.children=[],delete t.value,t.type=`paragraph`,Xi}}})}var Q1=Z_(`remark-preserve-empty-line`,e=>()=>t=>Z1(t,Y1(e)));Y(Q1.plugin,{displayName:`Remark<remarkPreserveEmptyLine>`,group:`Remark`}),Y(Q1.options,{displayName:`RemarkConfig<remarkPreserveEmptyLine>`,group:`Remark`});var $1=Y_(`paragraph`);Y($1,{displayName:`Attr<paragraph>`,group:`Paragraph`});var e0=J(`paragraph`,e=>({content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM:t=>[`p`,e.get($1.key)(t),0],parseMarkdown:{match:e=>e.type===`paragraph`,runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||``),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`paragraph`,runner:(t,n)=>{t.openNode(`paragraph`),(!n.content||n.content.size===0)&&t0(e)?t.addNode(`html`,void 0,g1):y1(t,n),t.closeNode()}}}));function t0(e){return e.isInjected(Q1.options.key)}Y(e0.node,{displayName:`NodeSchema<paragraph>`,group:`Paragraph`}),Y(e0.ctx,{displayName:`NodeSchemaCtx<paragraph>`,group:`Paragraph`});var n0=q(`TurnIntoText`,e=>()=>wu(e0.type(e)));Y(n0,{displayName:`Command<turnIntoTextCommand>`,group:`Paragraph`});var r0=J_(`paragraphKeymap`,{TurnIntoText:{shortcuts:`Mod-Alt-0`,command:e=>{let t=e.get(G);return()=>t.call(n0.key)}}});Y(r0.ctx,{displayName:`KeymapCtx<paragraph>`,group:`Paragraph`}),Y(r0.shortcuts,{displayName:`Keymap<paragraph>`,group:`Paragraph`});var i0=[,,,,,,].fill(0).map((e,t)=>t+1);function a0(e){return e.textContent.toLowerCase().trim().replace(/\s+/g,`-`)}var o0=K_(a0,`headingIdGenerator`);Y(o0,{displayName:`Ctx<HeadingIdGenerator>`,group:`Heading`});var s0=Y_(`heading`);Y(s0,{displayName:`Attr<heading>`,group:`Heading`});var c0=J(`heading`,e=>{let t=e.get(o0.key);return{content:`inline*`,group:`block`,defining:!0,attrs:{id:{default:``,validate:`string`},level:{default:1,validate:`number`}},parseDOM:i0.map(e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw Be(t);return{level:e,id:t.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...e.get(s0.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>e===`heading`,runner:(e,t,n)=>{let r=t.depth;e.openNode(n,{level:r}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`heading`,runner:(e,t)=>{e.openNode(`heading`,void 0,{depth:t.attrs.level}),y1(e,t),e.closeNode()}}}});Y(c0.node,{displayName:`NodeSchema<heading>`,group:`Heading`}),Y(c0.ctx,{displayName:`NodeSchemaCtx<heading>`,group:`Heading`});var l0=B_(e=>Ru(/^(?<hashes>#+)\s$/,c0.type(e),t=>{let n=t.groups?.hashes?.length||0,{$from:r}=e.get(rg).state.selection,i=r.node();if(i.type.name===`heading`){let e=Number(i.attrs.level)+Number(n);return e>6&&(e=6),{level:e}}return{level:n}}));Y(l0,{displayName:`InputRule<wrapInHeadingInputRule>`,group:`Heading`});var u0=q(`WrapInHeading`,e=>t=>(t??=1,t<1?wu(e0.type(e)):wu(c0.type(e),{level:t})));Y(u0,{displayName:`Command<wrapInHeadingCommand>`,group:`Heading`});var d0=q(`DowngradeHeading`,e=>()=>(t,n,r)=>{let{$from:i}=t.selection,a=i.node();if(a.type!==c0.type(e)||!t.selection.empty||i.parentOffset!==0)return!1;let o=a.attrs.level-1;return o?(n?.(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...a.attrs,level:o})),!0):wu(e0.type(e))(t,n,r)});Y(d0,{displayName:`Command<downgradeHeadingCommand>`,group:`Heading`});var f0=J_(`headingKeymap`,{TurnIntoH1:{shortcuts:`Mod-Alt-1`,command:e=>{let t=e.get(G);return()=>t.call(u0.key,1)}},TurnIntoH2:{shortcuts:`Mod-Alt-2`,command:e=>{let t=e.get(G);return()=>t.call(u0.key,2)}},TurnIntoH3:{shortcuts:`Mod-Alt-3`,command:e=>{let t=e.get(G);return()=>t.call(u0.key,3)}},TurnIntoH4:{shortcuts:`Mod-Alt-4`,command:e=>{let t=e.get(G);return()=>t.call(u0.key,4)}},TurnIntoH5:{shortcuts:`Mod-Alt-5`,command:e=>{let t=e.get(G);return()=>t.call(u0.key,5)}},TurnIntoH6:{shortcuts:`Mod-Alt-6`,command:e=>{let t=e.get(G);return()=>t.call(u0.key,6)}},DowngradeHeading:{shortcuts:[`Delete`,`Backspace`],command:e=>{let t=e.get(G);return()=>t.call(d0.key)}}});Y(f0.ctx,{displayName:`KeymapCtx<heading>`,group:`Heading`}),Y(f0.shortcuts,{displayName:`Keymap<heading>`,group:`Heading`});var p0=Y_(`blockquote`);Y(p0,{displayName:`Attr<blockquote>`,group:`Blockquote`});var m0=J(`blockquote`,e=>({content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM:t=>[`blockquote`,e.get(p0.key)(t),0],parseMarkdown:{match:({type:e})=>e===`blockquote`,runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`blockquote`,runner:(e,t)=>{e.openNode(`blockquote`).next(t.content).closeNode()}}}));Y(m0.node,{displayName:`NodeSchema<blockquote>`,group:`Blockquote`}),Y(m0.ctx,{displayName:`NodeSchemaCtx<blockquote>`,group:`Blockquote`});var h0=B_(e=>Lu(/^\s*>\s$/,m0.type(e)));Y(h0,{displayName:`InputRule<wrapInBlockquoteInputRule>`,group:`Blockquote`});var g0=q(`WrapInBlockquote`,e=>()=>Cu(m0.type(e)));Y(g0,{displayName:`Command<wrapInBlockquoteCommand>`,group:`Blockquote`});var _0=J_(`blockquoteKeymap`,{WrapInBlockquote:{shortcuts:`Mod-Shift-b`,command:e=>{let t=e.get(G);return()=>t.call(g0.key)}}});Y(_0.ctx,{displayName:`KeymapCtx<blockquote>`,group:`Blockquote`}),Y(_0.shortcuts,{displayName:`Keymap<blockquote>`,group:`Blockquote`});var v0=Y_(`codeBlock`,()=>({pre:{},code:{}}));Y(v0,{displayName:`Attr<codeBlock>`,group:`CodeBlock`});var y0=J(`code_block`,e=>({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 Be(e);return{language:e.dataset.language}}}],toDOM:t=>{let n=e.get(v0.key)(t),r=t.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,t,n)=>{let r=t.lang??``,i=t.value;e.openNode(n,{language:r}),i&&e.addText(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`code_block`,runner:(e,t)=>{e.addNode(`code`,void 0,t.content.firstChild?.text||``,{lang:t.attrs.language})}}}));Y(y0.node,{displayName:`NodeSchema<codeBlock>`,group:`CodeBlock`}),Y(y0.ctx,{displayName:`NodeSchemaCtx<codeBlock>`,group:`CodeBlock`});var b0=B_(e=>Ru(/^```(?<language>[a-z]*)?[\s\n]$/,y0.type(e),e=>({language:e.groups?.language??``})));Y(b0,{displayName:`InputRule<createCodeBlockInputRule>`,group:`CodeBlock`});var x0=q(`CreateCodeBlock`,e=>(t=``)=>wu(y0.type(e),{language:t}));Y(x0,{displayName:`Command<createCodeBlockCommand>`,group:`CodeBlock`}),Y(q(`UpdateCodeBlockLanguage`,()=>({pos:e,language:t}={pos:-1,language:``})=>(n,r)=>e>=0&&(r?.(n.tr.setNodeAttribute(e,`language`,t)),!0)),{displayName:`Command<updateCodeBlockLanguageCommand>`,group:`CodeBlock`});var S0=J_(`codeBlockKeymap`,{CreateCodeBlock:{shortcuts:`Mod-Alt-c`,command:e=>{let t=e.get(G);return()=>t.call(x0.key)}}});Y(S0.ctx,{displayName:`KeymapCtx<codeBlock>`,group:`CodeBlock`}),Y(S0.shortcuts,{displayName:`Keymap<codeBlock>`,group:`CodeBlock`});var C0=Y_(`image`);Y(C0,{displayName:`Attr<image>`,group:`Image`});var w0=J(`image`,e=>({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 Be(e);return{src:e.getAttribute(`src`)||``,alt:e.getAttribute(`alt`)||``,title:e.getAttribute(`title`)||e.getAttribute(`alt`)||``}}}],toDOM:t=>[`img`,{...e.get(C0.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>e===`image`,runner:(e,t,n)=>{let r=t.url,i=t.alt??``,a=t.title??``;e.addNode(n,{src:r,alt:i,title:a})}},toMarkdown:{match:e=>e.type.name===`image`,runner:(e,t)=>{e.addNode(`image`,void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));Y(w0.node,{displayName:`NodeSchema<image>`,group:`Image`}),Y(w0.ctx,{displayName:`NodeSchemaCtx<image>`,group:`Image`});var T0=q(`InsertImage`,e=>(t={})=>(n,r)=>{if(!r)return!0;let{src:i=``,alt:a=``,title:o=``}=t,s=w0.type(e).create({src:i,alt:a,title:o});return s&&r(n.tr.replaceSelectionWith(s).scrollIntoView()),!0});Y(T0,{displayName:`Command<insertImageCommand>`,group:`Image`});var E0=q(`UpdateImage`,e=>(t={})=>(n,r)=>{let i=sd(n.selection,w0.type(e));if(!i)return!1;let{node:a,pos:o}=i,s={...a.attrs},{src:c,alt:l,title:u}=t;return c!==void 0&&(s.src=c),l!==void 0&&(s.alt=l),u!==void 0&&(s.title=u),r?.(n.tr.setNodeMarkup(o,void 0,s).scrollIntoView()),!0});Y(E0,{displayName:`Command<updateImageCommand>`,group:`Image`}),Y(B_(e=>new Pu(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,n,r,i)=>{let[a,o,s=``,c]=n;return a?t.tr.replaceWith(r,i,w0.type(e).create({src:s,alt:o,title:c})):null})),{displayName:`InputRule<insertImageInputRule>`,group:`Image`});var D0=Y_(`hardbreak`,e=>({"data-type":`hardbreak`,"data-is-inline":e.attrs.isInline}));Y(D0,{displayName:`Attr<hardbreak>`,group:`Hardbreak`});var O0=J(`hardbreak`,e=>({inline:!0,group:`inline`,attrs:{isInline:{default:!1,validate:`boolean`}},selectable:!1,parseDOM:[{tag:`br`},{tag:`span[data-type="hardbreak"]`,getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?[`span`,e.get(D0.key)(t),` `]:[`br`,e.get(D0.key)(t)],parseMarkdown:{match:({type:e})=>e===`break`,runner:(e,t,n)=>{e.addNode(n,{isInline:!!t.data?.isInline})}},leafText:()=>`
49
+ `,toMarkdown:{match:e=>e.type.name===`hardbreak`,runner:(e,t)=>{t.attrs.isInline?e.addNode(`text`,void 0,`
50
+ `):e.addNode(`break`)}}}));Y(O0.node,{displayName:`NodeSchema<hardbreak>`,group:`Hardbreak`}),Y(O0.ctx,{displayName:`NodeSchemaCtx<hardbreak>`,group:`Hardbreak`});var k0=q(`InsertHardbreak`,e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(!(r instanceof L))return!1;if(r.empty){let e=r.$from.node();if(e.childCount>0&&e.lastChild?.type.name===`hardbreak`)return n?.(i.replaceRangeWith(r.to-1,r.to,t.schema.node(`paragraph`)).setSelection(I.near(i.doc.resolve(r.to))).scrollIntoView()),!0}return n?.(i.setMeta(`hardbreak`,!0).replaceSelectionWith(O0.type(e).create(),!1).scrollIntoView()),!0});Y(k0,{displayName:`Command<insertHardbreakCommand>`,group:`Hardbreak`});var A0=J_(`hardbreakKeymap`,{InsertHardbreak:{shortcuts:`Shift-Enter`,command:e=>{let t=e.get(G);return()=>t.call(k0.key)}}});Y(A0.ctx,{displayName:`KeymapCtx<hardbreak>`,group:`Hardbreak`}),Y(A0.shortcuts,{displayName:`Keymap<hardbreak>`,group:`Hardbreak`});var j0=Y_(`hr`);Y(j0,{displayName:`Attr<hr>`,group:`Hr`});var M0=J(`hr`,e=>({group:`block`,parseDOM:[{tag:`hr`}],toDOM:t=>[`hr`,e.get(j0.key)(t)],parseMarkdown:{match:({type:e})=>e===`thematicBreak`,runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>e.type.name===`hr`,runner:e=>{e.addNode(`thematicBreak`)}}}));Y(M0.node,{displayName:`NodeSchema<hr>`,group:`Hr`}),Y(M0.ctx,{displayName:`NodeSchemaCtx<hr>`,group:`Hr`});var N0=B_(e=>new Pu(/^(?:---|___\s|\*\*\*\s)$/,(t,n,r,i)=>{let{tr:a}=t;return n[0]&&a.replaceWith(r-1,i,M0.type(e).create()),a}));Y(N0,{displayName:`InputRule<insertHrInputRule>`,group:`Hr`});var P0=q(`InsertHr`,e=>()=>(t,n)=>{if(!n)return!0;let r=e0.node.type(e).create(),{tr:i,selection:a}=t,{from:o}=a,s=M0.type(e).create();if(!s)return!0;let c=i.replaceSelectionWith(s).insert(o,r),l=I.findFrom(c.doc.resolve(o),1,!0);return l&&n(c.setSelection(l).scrollIntoView()),!0});Y(P0,{displayName:`Command<insertHrCommand>`,group:`Hr`});var F0=Y_(`bulletList`);Y(F0,{displayName:`Attr<bulletList>`,group:`BulletList`});var I0=J(`bullet_list`,e=>({content:`listItem+`,group:`block`,attrs:{spread:{default:!1,validate:`boolean`}},parseDOM:[{tag:`ul`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Be(e);return{spread:e.dataset.spread===`true`}}}],toDOM:t=>[`ul`,{...e.get(F0.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e===`list`&&!t,runner:(e,t,n)=>{let r=t.spread??!1;e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`bullet_list`,runner:(e,t)=>{e.openNode(`list`,void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));Y(I0.node,{displayName:`NodeSchema<bulletList>`,group:`BulletList`}),Y(I0.ctx,{displayName:`NodeSchemaCtx<bulletList>`,group:`BulletList`});var L0=B_(e=>Lu(/^\s*([-+*])\s$/,I0.type(e)));Y(L0,{displayName:`InputRule<wrapInBulletListInputRule>`,group:`BulletList`});var R0=q(`WrapInBulletList`,e=>()=>Cu(I0.type(e)));Y(R0,{displayName:`Command<wrapInBulletListCommand>`,group:`BulletList`});var z0=J_(`bulletListKeymap`,{WrapInBulletList:{shortcuts:`Mod-Alt-8`,command:e=>{let t=e.get(G);return()=>t.call(R0.key)}}});Y(z0.ctx,{displayName:`KeymapCtx<bulletListKeymap>`,group:`BulletList`}),Y(z0.shortcuts,{displayName:`Keymap<bulletListKeymap>`,group:`BulletList`});var B0=Y_(`orderedList`);Y(B0,{displayName:`Attr<orderedList>`,group:`OrderedList`});var V0=J(`ordered_list`,e=>({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 Be(e);return{spread:e.dataset.spread===`true`,order:e.hasAttribute(`start`)?Number(e.getAttribute(`start`)):1}}}],toDOM:t=>[`ol`,{...e.get(B0.key)(t),...t.attrs.order===1?{}:{start:t.attrs.order},"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e===`list`&&!!t,runner:(e,t,n)=>{let r=t.spread??!0;e.openNode(n,{spread:r,order:t.start??1}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`ordered_list`,runner:(e,t)=>{e.openNode(`list`,void 0,{ordered:!0,start:t.attrs.order??1,spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));Y(V0.node,{displayName:`NodeSchema<orderedList>`,group:`OrderedList`}),Y(V0.ctx,{displayName:`NodeSchemaCtx<orderedList>`,group:`OrderedList`});var H0=B_(e=>Lu(/^\s*(\d+)\.\s$/,V0.type(e),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));Y(H0,{displayName:`InputRule<wrapInOrderedListInputRule>`,group:`OrderedList`});var U0=q(`WrapInOrderedList`,e=>()=>Cu(V0.type(e)));Y(U0,{displayName:`Command<wrapInOrderedListCommand>`,group:`OrderedList`});var W0=J_(`orderedListKeymap`,{WrapInOrderedList:{shortcuts:`Mod-Alt-7`,command:e=>{let t=e.get(G);return()=>t.call(U0.key)}}});Y(W0.ctx,{displayName:`KeymapCtx<orderedList>`,group:`OrderedList`}),Y(W0.shortcuts,{displayName:`Keymap<orderedList>`,group:`OrderedList`});var G0=Y_(`listItem`);Y(G0,{displayName:`Attr<listItem>`,group:`ListItem`});var K0=J(`list_item`,e=>({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 Be(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread===`true`}}}],toDOM:t=>[`li`,{...e.get(G0.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e})=>e===`listItem`,runner:(e,t,n)=>{let r=t.label==null?`•`:`${t.label}.`,i=t.label==null?`bullet`:`ordered`,a=t.spread??!0;e.openNode(n,{label:r,listType:i,spread:a}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`list_item`,runner:(e,t)=>{e.openNode(`listItem`,void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));Y(K0.node,{displayName:`NodeSchema<listItem>`,group:`ListItem`}),Y(K0.ctx,{displayName:`NodeSchemaCtx<listItem>`,group:`ListItem`});var q0=q(`SinkListItem`,e=>()=>d1(K0.type(e)));Y(q0,{displayName:`Command<sinkListItemCommand>`,group:`ListItem`});var J0=q(`LiftListItem`,e=>()=>c1(K0.type(e)));Y(J0,{displayName:`Command<liftListItemCommand>`,group:`ListItem`});var Y0=q(`SplitListItem`,e=>()=>(t,n,r)=>s1(K0.type(e))(t,n&&(e=>{let{$from:r}=t.selection;if(r.parent.content.size===0&&r.node(-1).childCount===r.indexAfter(-1)){let{$from:t}=e.selection;e.setNodeMarkup(t.before(-1),void 0,r.node(-3).attrs)}n(e)}),r));Y(Y0,{displayName:`Command<splitListItemCommand>`,group:`ListItem`});function X0(e){return(t,n,r)=>{let{selection:i}=t;if(!(i instanceof L))return!1;let{empty:a,$from:o}=i;return!a||o.parentOffset!==0||o.node(-1).type!==K0.type(e)?!1:eu(t,n,r)}}var Z0=q(`LiftFirstListItem`,e=>()=>X0(e));Y(Z0,{displayName:`Command<liftFirstListItemCommand>`,group:`ListItem`});var Q0=J_(`listItemKeymap`,{NextListItem:{shortcuts:`Enter`,command:e=>{let t=e.get(G);return()=>t.call(Y0.key)}},SinkListItem:{shortcuts:[`Tab`,`Mod-]`],command:e=>{let t=e.get(G);return()=>t.call(q0.key)}},LiftListItem:{shortcuts:[`Shift-Tab`,`Mod-[`],command:e=>{let t=e.get(G);return()=>t.call(J0.key)}},LiftFirstListItem:{shortcuts:[`Backspace`,`Delete`],command:e=>{let t=e.get(G);return()=>t.call(Z0.key)}}});Y(Q0.ctx,{displayName:`KeymapCtx<listItem>`,group:`ListItem`}),Y(Q0.shortcuts,{displayName:`Keymap<listItem>`,group:`ListItem`});var $0=U_(`text`,()=>({group:`inline`,parseMarkdown:{match:({type:e})=>e===`text`,runner:(e,t)=>{e.addText(t.value)}},toMarkdown:{match:e=>e.type.name===`text`,runner:(e,t)=>{e.addNode(`text`,void 0,t.text)}}}));Y($0,{displayName:`NodeSchema<text>`,group:`Text`});var ev=Y_(`html`);Y(ev,{displayName:`Attr<html>`,group:`Html`});var tv=J(`html`,e=>({atom:!0,group:`inline`,inline:!0,attrs:{value:{default:``,validate:`string`}},toDOM:t=>{let n=document.createElement(`span`),r={...e.get(ev.key)(t),"data-value":t.attrs.value,"data-type":`html`};return n.textContent=t.attrs.value,[`span`,r,t.attrs.value]},parseDOM:[{tag:`span[data-type="html"]`,getAttrs:e=>({value:e.dataset.value??``})}],parseMarkdown:{match:({type:e})=>e===`html`,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>e.type.name===`html`,runner:(e,t)=>{e.addNode(`html`,void 0,t.attrs.value)}}}));Y(tv.node,{displayName:`NodeSchema<html>`,group:`Html`}),Y(tv.ctx,{displayName:`NodeSchemaCtx<html>`,group:`Html`});var nv=[W1,$1,e0,o0,s0,c0,D0,O0,p0,m0,v0,y0,j0,M0,C0,w0,F0,I0,B0,V0,G0,K0,b1,x1,E1,D1,j1,M1,B1,V1,ev,tv,$0].flat(),rv=[h0,L0,H0,b0,N0,l0].flat(),iv=[C1,w1,P1,k1],av=[n0,g0,u0,d0,x0,k0,P0,T0,E0,U0,R0,q0,Y0,J0,Z0,S1,N1,O1,H1,U1,q(`IsMarkSelected`,()=>e=>t=>{if(!e)return!1;let{doc:n,selection:r}=t;return n.rangeHasMark(r.from,r.to,e)}),q(`IsNoteSelected`,()=>e=>t=>e?cd(t,e).hasNode:!1),q(`ClearTextInCurrentBlock`,()=>()=>(e,t)=>{let n=e.tr,{$from:r,$to:i}=n.selection,{pos:a}=r,{pos:o}=i,s=a-r.node().content.size;return s<0?!1:(n=n.deleteRange(s,o),t?.(n),!0)}),q(`SetBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr,{from:o,to:s}=a.selection;try{a.setBlockType(o,s,r,i)}catch{return!1}return n?.(a),!0}),q(`WrapInBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr;try{let{$from:e,$to:t}=a.selection,n=e.blockRange(t),o=n&&Wc(n,r,i);if(!o)return!1;a=a.wrap(n,o)}catch{return!1}return n?.(a),!0}),q(`AddBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr;try{let e=r instanceof _s?r:r.createAndFill(i);if(!e)return!1;a.replaceSelectionWith(e)}catch{return!1}return n?.(a),!0}),q(`SelectTextNearPos`,()=>e=>(t,n)=>{let{pos:r}=e??{};if(r==null)return!1;let i=(e,t,n)=>Math.min(Math.max(e,t),n),a=t.tr;try{let e=t.doc.resolve(i(r,0,t.doc.content.size));a.setSelection(L.near(e))}catch{return!1}return n?.(a.scrollIntoView()),!0})],ov=[_0,S0,A0,f0,Q0,W0,z0,r0,T1,F1,A1].flat(),sv=Z_(`remarkAddOrderInList`,()=>()=>e=>{$i(e,`list`,e=>{if(e.ordered){let t=e.start??1;e.children.forEach((e,n)=>{e.label=n+t})}})});Y(sv.plugin,{displayName:`Remark<remarkAddOrderInListPlugin>`,group:`Remark`}),Y(sv.options,{displayName:`RemarkConfig<remarkAddOrderInListPlugin>`,group:`Remark`});var cv=Z_(`remarkLineBreak`,()=>()=>e=>{let t=/(?<![\t ])[\t ]*(?:\r?\n|\r)/g;$i(e,`text`,(e,n,r)=>{if(!e.value||typeof e.value!=`string`)return;let i=[],a=0;t.lastIndex=0;let o=t.exec(e.value);for(;o;){let n=o.index;a!==n&&i.push({type:`text`,value:e.value.slice(a,n)}),i.push({type:`break`,data:{isInline:!0}}),a=n+o[0].length,o=t.exec(e.value)}if(i.length>0&&r&&typeof n==`number`)return a<e.value.length&&i.push({type:`text`,value:e.value.slice(a)}),r.children.splice(n,1,...i),n+i.length})});Y(cv.plugin,{displayName:`Remark<remarkLineBreak>`,group:`Remark`}),Y(cv.options,{displayName:`RemarkConfig<remarkLineBreak>`,group:`Remark`});var lv=Z_(`remarkInlineLink`,()=>m1);Y(lv.plugin,{displayName:`Remark<remarkInlineLinkPlugin>`,group:`Remark`}),Y(lv.options,{displayName:`RemarkConfig<remarkInlineLinkPlugin>`,group:`Remark`});var uv=e=>!!e.children,dv=e=>e.type===`html`;function fv(e,t){return n(e,0,null)[0];function n(e,r,i){if(uv(e)){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i){let a=n(i,r,e);if(a)for(let e=0,n=a.length;e<n;e++){let n=a[e];n&&t.push(n)}}}e.children=t}return t(e,r,i)}}var pv=Z_(`remarkHTMLTransformer`,e=>()=>t=>{let n=Y1(e);fv(t,(e,t,r)=>(dv(e)&&r&&n.has(r.type)&&(e.children=[h1(e)],delete e.value,e.type=`paragraph`),[e]))});Y(pv.plugin,{displayName:`Remark<remarkHtmlTransformer>`,group:`Remark`}),Y(pv.options,{displayName:`RemarkConfig<remarkHtmlTransformer>`,group:`Remark`});var mv=Z_(`remarkMarker`,()=>()=>(e,t)=>{let n=e=>t.value.charAt(e.position.start.offset);$i(e,e=>[`strong`,`emphasis`].includes(e.type),e=>{e.marker=n(e)})});Y(mv.plugin,{displayName:`Remark<remarkMarker>`,group:`Remark`}),Y(mv.options,{displayName:`RemarkConfig<remarkMarker>`,group:`Remark`});var hv=W_(()=>{let e=!1,t=new Jl({key:new Zl(`MILKDOWN_INLINE_NODES_CURSOR`),state:{init(){return!1},apply(e){if(!e.selection.empty)return!1;let t=e.selection.$from,n=t.nodeBefore,r=t.nodeAfter;return!!(n&&r&&n.isInline&&!n.isText&&r.isInline&&!r.isText)}},props:{handleDOMEvents:{compositionend:(n,r)=>e?(e=!1,requestAnimationFrame(()=>{if(t.getState(n.state)){let e=n.state.selection.from;r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||``,e))}}),!0):!1,compositionstart:n=>(t.getState(n.state)&&(e=!0),!1),beforeinput:(n,r)=>{if(t.getState(n.state)&&r instanceof InputEvent&&r.data&&!e){let e=n.state.selection.from;return r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||``,e)),!0}return!1}},decorations(e){if(t.getState(e)){let t=e.selection.$from.pos,n=document.createElement(`span`),r=uh.widget(t,n,{side:-1}),i=document.createElement(`span`),a=uh.widget(t,i);return setTimeout(()=>{n.contentEditable=`true`,i.contentEditable=`true`}),ph.create(e.doc,[r,a])}return ph.empty}}});return t});Y(hv,{displayName:`Prose<inlineNodesCursorPlugin>`,group:`Prose`});var gv=W_(e=>new Jl({key:new Zl(`MILKDOWN_HARDBREAK_MARKS`),appendTransaction:(t,n,r)=>{if(!t.length)return;let i=O0.type(e),a;return t.forEach((e,n)=>{e.steps.forEach((e,o)=>{if(!(e instanceof kc))return;let s=(e,r)=>t.slice(n).reduce((e,t,n)=>(n===0?t.mapping.slice(o+1):t.mapping).map(e,r),e),c=s(e.from,-1),l=s(e.to,1);r.doc.nodesBetween(c,l,(e,t)=>{e.type!==i||e.attrs.isInline||e.marks.length&&(a??=r.tr,a.setNodeMarkup(t,i,e.attrs,[]))})})}),a}}));Y(gv,{displayName:`Prose<hardbreakClearMarkPlugin>`,group:`Prose`});var _v=K_([`table`,`code_block`],`hardbreakFilterNodes`);Y(_v,{displayName:`Ctx<hardbreakFilterNodes>`,group:`Prose`});var vv=W_(e=>{let t=e.get(_v.key);return new Jl({key:new Zl(`MILKDOWN_HARDBREAK_FILTER`),filterTransaction:(e,n)=>{let r=e.getMeta(`hardbreak`),[i]=e.steps;if(r&&i instanceof Fc){let e=n.doc.resolve(i.from),r=e.depth,a=!0;for(;r>0;)t.includes(e.node(r).type.name)&&(a=!1),r--;return a}return!0}})});Y(vv,{displayName:`Prose<hardbreakFilterPlugin>`,group:`Prose`});var yv=W_(e=>{let t=new Zl(`MILKDOWN_HEADING_ID`),n=n=>{if(n.composing)return;let r=e.get(o0.key),i=n.state.tr.setMeta(`addToHistory`,!1),a=!1,o={};n.state.doc.descendants((n,s)=>{if(n.type===c0.type(e)){if(n.textContent.trim().length===0)return;let e=n.attrs,c=r(n);o[c]?(o[c]+=1,c+=`-#${o[c]}`):o[c]=1,e.id!==c&&(a=!0,i.setMeta(t,!0).setNodeMarkup(s,void 0,{...e,id:c}))}}),a&&n.dispatch(i)};return new Jl({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})});Y(yv,{displayName:`Prose<syncHeadingIdPlugin>`,group:`Prose`});var bv=W_(e=>new Jl({key:new Zl(`MILKDOWN_KEEP_LIST_ORDER`),appendTransaction:(t,n,r)=>{if(!r.selection||t.some(e=>e.getMeta(`addToHistory`)===!1||!e.isGeneric))return null;let i=V0.type(e),a=I0.type(e),o=K0.type(e),s=(e,t,n=1)=>{let r=!1,i=`${t+n}.`;return e.label!==i&&(e.label=i,r=!0),r},c=r.tr,l=!1;return r.doc.descendants((e,t,n,r)=>{if(e.type===a){let n=e.maybeChild(0);n?.type===o&&n.attrs.listType===`ordered`&&(l=!0,c.setNodeMarkup(t,i,{spread:!0}),e.descendants((e,n,r,i)=>{if(e.type===o){let r={...e.attrs};(s(r,i)||r.listType!==`ordered`)&&(r.listType=`ordered`,c=c.setNodeMarkup(t+1+n,void 0,r))}return!1}))}else if(e.type===o&&n?.type===i){let i={...e.attrs},a=!1;i.listType!==`ordered`&&(i.listType=`ordered`,a=!0),n?.maybeChild(0)&&(a=s(i,r,n?.attrs.order??1)),a&&(c=c.setNodeMarkup(t,void 0,i),l=!0)}}),l?c.setMeta(`addToHistory`,!1):null}}));Y(bv,{displayName:`Prose<syncListOrderPlugin>`,group:`Prose`});var xv=[nv,rv,iv,av,ov,[gv,_v,vv,hv,q1,sv,lv,cv,pv,mv,Q1,yv,bv].flat()].flat(),Sv,Cv;if(typeof WeakMap<`u`){let e=new WeakMap;Sv=t=>e.get(t),Cv=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;Sv=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},Cv=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var X=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o||t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return Sv(e)||Cv(e,wv(e))}};function wv(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=Tv(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new X(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&Ev(s,o,e),s}function Tv(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function Ev(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r==null||c.colwidth&&c.colwidth[n]==r||((s||=Dv(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function Dv(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Ov(e,t){if(typeof e==`string`)return{};let n=e.getAttribute(`data-colwidth`),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(`,`).map(e=>Number(e)):null,i=Number(e.getAttribute(`colspan`)||1),a={colspan:i,rowspan:Number(e.getAttribute(`rowspan`)||1),colwidth:r&&r.length==i?r:null};for(let n in t){let r=t[n].getFromDOM,i=r&&r(e);i!=null&&(a[n]=i)}return a}function kv(e,t){let n={};e.attrs.colspan!=1&&(n.colspan=e.attrs.colspan),e.attrs.rowspan!=1&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n[`data-colwidth`]=e.attrs.colwidth.join(`,`));for(let r in t){let i=t[r].setDOMAttr;i&&i(e.attrs[r],n)}return n}function Av(e){if(e!==null){if(!Array.isArray(e))throw TypeError(`colwidth must be null or an array`);for(let t of e)if(typeof t!=`number`)throw TypeError(`colwidth must be null or an array of numbers`)}}function jv(e){let t=e.cellAttributes||{},n={colspan:{default:1,validate:`number`},rowspan:{default:1,validate:`number`},colwidth:{default:null,validate:Av}};for(let e in t)n[e]={default:t[e].default,validate:t[e].validate};return{table:{content:`table_row+`,tableRole:`table`,isolating:!0,group:e.tableGroup,parseDOM:[{tag:`table`}],toDOM(){return[`table`,[`tbody`,0]]}},table_row:{content:`(table_cell | table_header)*`,tableRole:`row`,parseDOM:[{tag:`tr`}],toDOM(){return[`tr`,0]}},table_cell:{content:e.cellContent,attrs:n,tableRole:`cell`,isolating:!0,parseDOM:[{tag:`td`,getAttrs:e=>Ov(e,t)}],toDOM(e){return[`td`,kv(e,t),0]}},table_header:{content:e.cellContent,attrs:n,tableRole:`header_cell`,isolating:!0,parseDOM:[{tag:`th`,getAttrs:e=>Ov(e,t)}],toDOM(e){return[`th`,kv(e,t),0]}}}}function Mv(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var Nv=new Zl(`selectingCells`);function Pv(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function Fv(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function Iv(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=Pv(t.$head)||Lv(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function Lv(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function Rv(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function zv(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Bv(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Vv(e,t,n){let r=e.node(-1),i=X.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function Hv(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function Uv(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function Wv(e,t,n){let r=Mv(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var Z=class e extends I{constructor(e,t=e){let n=e.node(-1),r=X.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new kl(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(Rv(r)&&Rv(i)&&Bv(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return L.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=X.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=Hv(e,0,l)),u>0&&(e=Hv(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(M.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new P(M.from(o),1,1)}replace(e,t=P.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?P.empty:t)}let i=I.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new P(M.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=X.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=X.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=X.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=X.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new Gv(this.$anchorCell.pos,this.$headCell.pos)}};Z.prototype.visible=!1,I.jsonID(`cell`,Z);var Gv=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&Bv(t,n)?new Z(t,n):I.near(n,1)}};function Kv(e){if(!(e.selection instanceof Z))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(uh.node(n,n+e.nodeSize,{class:`selectedCell`}))}),ph.create(e.doc,t)}function qv({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function Jv({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function Yv(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof R&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=Z.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=Z.rowSelection(e,e)}else if(!n){let e=X.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=Z.create(i,t+1,n)}}else r instanceof L&&qv(r)?a=L.create(i,r.from):r instanceof L&&Jv(r)&&(a=L.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var Xv=new Zl(`fix-tables`);function Zv(e,t,n,r){let i=e.childCount,a=t.childCount;e:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue e}r(a,n),s<i&&e.child(s).sameMarkup(a)?Zv(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Qv(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=$v(e,t,r,n))};return t?t.doc!=e.doc&&Zv(t.doc,e.doc,0,r):e.doc.descendants(r),n}function $v(e,t,n,r){let i=X.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e<i.height;e++)a.push(0);for(let e=0;e<i.problems.length;e++){let o=i.problems[e];if(o.type==`collision`){let e=t.nodeAt(o.pos);if(!e)continue;let i=e.attrs;for(let e=0;e<i.rowspan;e++)a[o.row+e]+=o.n;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,Hv(i,i.colspan-o.n,o.n))}else if(o.type==`missing`)a[o.row]+=o.n;else if(o.type==`overlong_rowspan`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-o.n})}else if(o.type==`colwidth mismatch`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,colwidth:o.colwidth})}else if(o.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let o,s;for(let e=0;e<a.length;e++)a[e]&&(o??=e,s=e);for(let c=0,l=n+1;c<i.height;c++){let n=t.child(c),i=l+n.nodeSize,u=a[c];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n<u;n++){let n=Mv(e.schema)[t].createAndFill();n&&a.push(n)}let d=(c==0||o==c-1)&&s==c?l+1:i-1;r.insert(r.mapping.map(d),a)}l=i}return r.setMeta(Xv,{fixTables:!0})}function ey(e){let t=X.get(e),n=[],r=t.height,i=t.width;for(let a=0;a<r;a++){let r=[];for(let n=0;n<i;n++){let o=a*i+n,s=t.map[o];if(a>0){let e=o-i;if(s===t.map[e]){r.push(null);continue}}if(n>0){let e=o-1;if(s===t.map[e]){r.push(null);continue}}r.push(e.nodeAt(s))}n.push(r)}return n}function ty(e,t){let n=[],r=X.get(e),i=r.height,a=r.width;for(let o=0;o<i;o++){let i=e.child(o),s=[];for(let n=0;n<a;n++){let i=t[o][n];if(!i)continue;let a=r.map[o*r.width+n],c=e.nodeAt(a);if(!c)continue;let l=c.type.createChecked(i.attrs,i.content,i.marks);s.push(l)}let c=i.type.createChecked(i.attrs,s,i.marks);n.push(c)}return e.type.createChecked(e.attrs,n,e.marks)}function ny(e,t,n,r){let i=t[0]>n[0]?-1:1,a=e.splice(t[0],t.length),o=+(a.length%2==0),s;return s=r===-1&&i===1?n[0]-1:r===1&&i===-1?n[n.length-1]-o+1:i===-1?n[0]:n[n.length-1]-o,e.splice(s,0,...a),e}function ry(e){return iy(e=>e.type.spec.tableRole===`table`,e)}function iy(e,t){for(let n=t.depth;n>=0;--n){let r=t.node(n);if(e(r))return{node:r,pos:n===0?0:t.before(n),start:t.start(n),depth:n}}return null}function ay(e,t){let n=ry(t.$from);if(!n)return;let r=X.get(n.node);if(!(e<0||e>r.width-1))return r.cellsInRect({left:e,right:e+1,top:0,bottom:r.height}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function oy(e,t){let n=ry(t.$from);if(!n)return;let r=X.get(n.node);if(!(e<0||e>r.height-1))return r.cellsInRect({left:0,right:r.width,top:e,bottom:e+1}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function sy(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=ay(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=ay(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;e.node.attrs.colspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=ay(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=ay(r,e.selection),s=oy(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=ay(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function cy(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=oy(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=oy(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;e.node.attrs.rowspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=oy(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=oy(r,e.selection),s=ay(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=oy(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function ly(e){return e[0].map((t,n)=>e.map(e=>e[n]))}function uy(e){let{tr:t,originIndex:n,targetIndex:r,select:i,pos:a}=e,o=ry(t.doc.resolve(a));if(!o)return!1;let s=sy(t,n)?.indexes,c=sy(t,r)?.indexes;if(!s||!c||s.includes(r))return!1;let l=dy(o.node,s,c,0);if(t.replaceWith(o.pos,o.pos+o.node.nodeSize,l),!i)return!0;let u=X.get(l),d=o.start,f=r,p=u.positionAt(u.height-1,f,l),m=t.doc.resolve(d+p),h=u.positionAt(0,f,l),g=t.doc.resolve(d+h);return t.setSelection(Z.colSelection(m,g)),!0}function dy(e,t,n,r){let i=ly(ey(e));return i=ny(i,t,n,r),i=ly(i),ty(e,i)}function fy(e){let{tr:t,originIndex:n,targetIndex:r,select:i,pos:a}=e,o=ry(t.doc.resolve(a));if(!o)return!1;let s=cy(t,n)?.indexes,c=cy(t,r)?.indexes;if(!s||!c||s.includes(r))return!1;let l=py(o.node,s,c,0);if(t.replaceWith(o.pos,o.pos+o.node.nodeSize,l),!i)return!0;let u=X.get(l),d=o.start,f=r,p=u.positionAt(f,u.width-1,l),m=t.doc.resolve(d+p),h=u.positionAt(f,0,l),g=t.doc.resolve(d+h);return t.setSelection(Z.rowSelection(m,g)),!0}function py(e,t,n,r){let i=ey(e);return i=ny(i,t,n,r),ty(e,i)}function my(e){let t=e.selection,n=Iv(e),r=n.node(-1),i=n.start(-1),a=X.get(r);return{...t instanceof Z?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function hy(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;Wv(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,Uv(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?Mv(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function gy(e,t){if(!Fv(e))return!1;if(t){let n=my(e);t(hy(e.tr,n,n.left))}return!0}function _y(e,t){if(!Fv(e))return!1;if(t){let n=my(e);t(hy(e.tr,n,n.right))}return!0}function vy(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,Hv(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function yy(e,t){if(!Fv(e))return!1;if(t){let n=my(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;vy(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=X.get(e)}t(r)}return!0}function by(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function xy(e,t){if(!Fv(e))return!1;if(t){let n=my(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;by(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=X.get(n.table)}t(r)}return!0}function Sy(e,t){return function(n,r){if(!Fv(n))return!1;let i=Iv(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof Z?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function Cy(e){return function(t,n){if(!Fv(t))return!1;if(n){let r=Mv(t.schema),i=my(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function wy(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function Ty(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?Cy(e):function(t,n){if(!Fv(t))return!1;if(n){let r=Mv(t.schema),i=my(t),a=t.tr,o=wy(`row`,i,r),s=wy(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}Ty(`row`,{useDeprecatedLogic:!0}),Ty(`column`,{useDeprecatedLogic:!0}),Ty(`cell`,{useDeprecatedLogic:!0});function Ey(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function Dy(e){return function(t,n){if(!Fv(t))return!1;let r=Ey(Iv(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(L.between(e,zv(e))).scrollIntoView())}return!0}}function Oy(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function ky(e,t){let n=e.selection;if(!(n instanceof Z))return!1;if(t){let r=e.tr,i=Mv(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new P(i,0,0))}),r.docChanged&&t(r)}return!0}function Ay(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return fy({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function jy(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return uy({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function My(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e<t.childCount;e++){let i=t.child(e).content,a=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(a||c)&&(i=Py(Mv(o).row,new P(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?Py(Mv(o).row,new P(t,n,r)).content:t);else return null;return Ny(o,s)}function Ny(e,t){let n=[];for(let e=0;e<t.length;e++){let r=t[e];for(let t=r.childCount-1;t>=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t<e+i;t++)n[t]=(n[t]||0)+a}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(M.empty),n[i]<r){let a=Mv(e).cell.createAndFill(),o=[];for(let e=n[i];e<r;e++)o.push(a);t[i]=t[i].append(M.from(o))}return{height:t.length,width:r,rows:t}}function Py(e,t){let n=e.createAndFill();return new Dl(n).replace(0,n.content.size,t).doc}function Fy({width:e,height:t,rows:n},r,i){if(e!=r){let t=[],i=[];for(let e=0;e<n.length;e++){let a=n[e],o=[];for(let n=t[e]||0,i=0;n<r;i++){let s=a.child(i%a.childCount);n+s.attrs.colspan>r&&(s=s.type.createChecked(Hv(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}i.push(M.from(o))}n=i,e=r}if(t!=i){let e=[];for(let r=0,a=0;r<i;r++,a++){let o=[],s=n[a%t];for(let e=0;e<s.childCount;e++){let t=s.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(M.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function Iy(e,t,n,r,i,a,o){let s=Mv(e.doc.type.schema),c,l;if(i>t.width)for(let a=0,u=0;a<t.height;a++){let d=n.child(a);u+=d.nodeSize;let f=[],p;p=d.lastChild==null||d.lastChild.type==s.cell?c||=s.cell.createAndFill():l||=s.header_cell.createAndFill();for(let e=t.width;e<i;e++)f.push(p);e.insert(e.mapping.slice(o).map(u-1+r),f)}if(a>t.height){let u=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){let i=e>=t.width?!1:n.nodeAt(t.map[r+e]).type==s.header_cell;u.push(i?l||=s.header_cell.createAndFill():c||=s.cell.createAndFill())}let d=s.row.create(null,M.from(u)),f=[];for(let e=t.height;e<a;e++)f.push(d);e.insert(e.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(c||l)}function Ly(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function Ry(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,Hv(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(Hv(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function zy(e,t,n,r,i){let a=n?e.doc.nodeAt(n-1):e.doc;if(!a)throw Error(`No table found`);let o=X.get(a),{top:s,left:c}=r,l=c+i.width,u=s+i.height,d=e.tr,f=0;function p(){if(a=n?d.doc.nodeAt(n-1):d.doc,!a)throw Error(`No table found`);o=X.get(a),f=d.mapping.maps.length}Iy(d,o,a,n,l,u,f)&&p(),Ly(d,o,a,n,c,l,s,f)&&p(),Ly(d,o,a,n,c,l,u,f)&&p(),Ry(d,o,a,n,s,u,c,f)&&p(),Ry(d,o,a,n,s,u,l,f)&&p();for(let e=s;e<u;e++){let t=o.positionAt(e,c,a),r=o.positionAt(e,l,a);d.replace(d.mapping.slice(f).map(t+n),d.mapping.slice(f).map(r+n),new P(i.rows[e-s],0,0))}p(),d.setSelection(new Z(d.doc.resolve(n+o.positionAt(s,c,a)),d.doc.resolve(n+o.positionAt(u-1,l-1,a)))),t(d)}var By=Sd({ArrowLeft:Hy(`horiz`,-1),ArrowRight:Hy(`horiz`,1),ArrowUp:Hy(`vert`,-1),ArrowDown:Hy(`vert`,1),"Shift-ArrowLeft":Uy(`horiz`,-1),"Shift-ArrowRight":Uy(`horiz`,1),"Shift-ArrowUp":Uy(`vert`,-1),"Shift-ArrowDown":Uy(`vert`,1),Backspace:ky,"Mod-Backspace":ky,Delete:ky,"Mod-Delete":ky});function Vy(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function Hy(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof Z)return Vy(n,r,I.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=qy(i,e,t);if(o==null)return!1;if(e==`horiz`)return Vy(n,r,I.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=Vv(i,e,t),s;return s=a?I.near(a,1):t<0?I.near(n.doc.resolve(i.before(-1)),-1):I.near(n.doc.resolve(i.after(-1)),1),Vy(n,r,s)}}}function Uy(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof Z)o=a;else{let r=qy(i,e,t);if(r==null)return!1;o=new Z(n.doc.resolve(r))}let s=Vv(o.$headCell,e,t);return s?Vy(n,r,new Z(o.$anchorCell,s)):!1}}function Wy(e,t){let n=Pv(e.state.doc.resolve(t));return n?(e.dispatch(e.state.tr.setSelection(new Z(n))),!0):!1}function Gy(e,t,n){if(!Fv(e.state))return!1;let r=My(n),i=e.state.selection;if(i instanceof Z){r||={width:1,height:1,rows:[M.from(Py(Mv(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=X.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=Fy(r,o.right-o.left,o.bottom-o.top),zy(e.state,e.dispatch,a,o,r),!0}if(r){let t=Iv(e.state),n=t.start(-1);return zy(e.state,e.dispatch,n,X.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function Ky(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=Jy(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof Z)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=Pv(e.state.selection.$anchor))!=null&&Yy(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=Yy(e,n),i=Nv.getState(e.state)==null;if(!r||!Bv(t,r)){if(i)r=t;else return}let a=new Z(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(Nv,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),Nv.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(Nv,-1))}function o(r){let o=r,s=Nv.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(Jy(e,o.target)!=n&&(c=Yy(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function qy(e,t,n){if(!(e.state.selection instanceof L))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function Jy(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function Yy(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Pv(e.state.doc.resolve(r))||Pv(e.state.doc.resolve(i))}var Xy=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),Zy(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type&&(this.node=e,Zy(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function Zy(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var Qy=new Zl(`tableColumnResizing`);function $y({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=Xy,lastColumnResizable:i=!0}={}){let a=new Jl({key:Qy,state:{init(e,t){var i;let o=(i=a.spec)==null||(i=i.props)==null?void 0:i.nodeViews,s=Mv(t.schema).table.name;return r&&o&&(o[s]=(e,t)=>new r(e,n,t)),new e2(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=Qy.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{t2(t,n,e,i)},mouseleave:e=>{n2(e)},mousedown:(e,r)=>{r2(e,r,t,n)}},decorations:e=>{let t=Qy.getState(e);if(t&&t.activeHandle>-1)return f2(e,t.activeHandle)},nodeViews:{}}});return a}var e2=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(Qy);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return Rv(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function t2(e,t,n,r){if(!e.editable)return;let i=Qy.getState(e.state);if(i&&!i.dragging){let a=a2(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=o2(e,t,`left`,n):i-t.clientX<=n&&(o=o2(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=X.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}c2(e,o)}}}function n2(e){if(!e.editable)return;let t=Qy.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&c2(e,-1)}function r2(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=Qy.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=i2(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(Qy,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=Qy.getState(e.state);r?.dragging&&(l2(e,r.activeHandle,s2(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(Qy,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=Qy.getState(e.state);if(i&&i.dragging){let a=s2(i.dragging,t,n);u2(e,i.activeHandle,a,r)}}return u2(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function i2(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function a2(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function o2(e,t,n,r){let i=n==`right`?-r:r,a=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!a)return-1;let{pos:o}=a,s=Pv(e.state.doc.resolve(o));if(!s)return-1;if(n==`right`)return s.pos;let c=X.get(s.node(-1)),l=s.start(-1),u=c.map.indexOf(s.pos-l);return u%c.width==0?-1:l+c.map[u-1]}function s2(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function c2(e,t){e.dispatch(e.state.tr.setMeta(Qy,{setHandle:t}))}function l2(e,t,n){let r=e.state.doc.resolve(t),i=r.node(-1),a=X.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,c=e.state.tr;for(let e=0;e<a.height;e++){let t=e*a.width+s;if(e&&a.map[t]==a.map[t-a.width])continue;let r=a.map[t],l=i.nodeAt(r).attrs,u=l.colspan==1?0:s-a.colCount(r);if(l.colwidth&&l.colwidth[u]==n)continue;let d=l.colwidth?l.colwidth.slice():d2(l.colspan);d[u]=n,c.setNodeMarkup(o+r,null,{...l,colwidth:d})}c.docChanged&&e.dispatch(c)}function u2(e,t,n,r){let i=e.state.doc.resolve(t),a=i.node(-1),o=i.start(-1),s=X.get(a).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,c=e.domAtPos(i.start(-1)).node;for(;c&&c.nodeName!=`TABLE`;)c=c.parentNode;c&&Zy(a,c.firstChild,c,r,s,n)}function d2(e){return Array(e).fill(0)}function f2(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return ph.empty;let a=X.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<a.height;t++){let r=s+t*a.width;if((s==a.width-1||a.map[r]!=a.map[r+1])&&(t==0||a.map[r]!=a.map[r-a.width])){let t=a.map[r],s=o+t+i.nodeAt(t).nodeSize-1,c=document.createElement(`div`);c.className=`column-resize-handle`,Qy.getState(e)?.dragging&&n.push(uh.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:`column-resize-dragging`})),n.push(uh.widget(s,c))}}return ph.create(e.doc,n)}function p2({allowTableNodeSelection:e=!1}={}){return new Jl({key:Nv,state:{init(){return null},apply(e,t){let n=e.getMeta(Nv);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:Kv,handleDOMEvents:{mousedown:Ky},createSelectionBetween(e){return Nv.getState(e.state)==null?null:e.state.selection},handleTripleClick:Wy,handleKeyDown:By,handlePaste:Gy},appendTransaction(t,n,r){return Yv(r,Qv(r,n),e)}})}var m2=typeof navigator<`u`?navigator:null,h2=m2&&m2.userAgent||``,g2=/Edge\/(\d+)/.exec(h2),_2=/MSIE \d/.exec(h2),v2=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(h2),y2=!(_2||v2||g2)&&!!m2&&/Apple Computer/.test(m2.vendor),b2=new Zl(`safari-ime-span`),x2=!1,S2={key:b2,props:{decorations:C2,handleDOMEvents:{compositionstart:()=>{x2=!0},compositionend:()=>{x2=!1}}}};function C2(e){let{$from:t,$to:n,to:r}=e.selection;if(x2&&t.sameParent(n)){let t=uh.widget(r,w2,{ignoreSelection:!0,key:`safari-ime-span`});return ph.create(e.doc,[t])}}function w2(e){let t=e.dom.ownerDocument.createElement(`span`);return t.className=`ProseMirror-safari-ime-span`,t}var T2=new Jl(y2?S2:{key:b2});function E2(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function D2(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function O2(e,t,n){let r=$r((n||{}).ignore||[]),i=k2(t),a=-1;for(;++a<i.length;)Zi(e,o);function o(e,t,n){if(e.type===`text`&&typeof n==`number`)return s(e,t,n);if(r(e,n,t[t.length-1]))return Xi}function s(e,t,n){let r=t[t.length-1],o=i[a][0],s=i[a][1],c=0,l=!1,u=[];o.lastIndex=0;let d=o.exec(e.value);for(;d;){let n=d.index,r={index:d.index,input:d.input,stack:[...t,e]},i=s(...d,r);if(typeof i==`string`&&(i=i.length>0?{type:`text`,value:i}:void 0),i===!1)o.lastIndex=n+1;else{if(c!==n&&f({type:`text`,value:e.value.slice(c,n)}),Array.isArray(i))for(let e of i)f(e);else i&&f(i);c=n+d[0].length,l=!0}if(!o.global)break;d=o.exec(e.value)}return l?(c<e.value.length&&f({type:`text`,value:e.value.slice(c)}),r.children.splice(n,1,...u)):u=[e],n+u.length;function f(e){let t=u[u.length-1];t&&t.type===`text`&&e.type===`text`?t.value+=e.value:u.push(e)}}}function k2(e){if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let t=[],n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([A2(e[0]),j2(e[1])])}return t}function A2(e){return typeof e==`string`?new RegExp(D2(e),`g`):e}function j2(e){return typeof e==`function`?e:function(){return e}}var M2=`phrasing`,N2=[`autolink`,`link`,`image`,`label`];function P2(){return{transforms:[H2],enter:{literalAutolink:I2,literalAutolinkEmail:L2,literalAutolinkHttp:L2,literalAutolinkWww:L2},exit:{literalAutolink:V2,literalAutolinkEmail:B2,literalAutolinkHttp:R2,literalAutolinkWww:z2}}}function F2(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:M2,notInConstruct:N2},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:M2,notInConstruct:N2},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:M2,notInConstruct:N2}]}}function I2(e){this.enter({type:`link`,title:null,url:``,children:[],position:void 0},e)}function L2(e){this.config.enter.autolinkProtocol.call(this,e)}function R2(e){this.config.exit.autolinkProtocol.call(this,e)}function z2(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function B2(e){this.config.exit.autolinkEmail.call(this,e)}function V2(e){this.exit(e)}function H2(e){O2(e,[[/(?<![\da-z])(https?:\/\/|www(?=\.))([\w-]*\.[\w\-.]*)([^\t\n\r ]*)/gi,U2],[/(?<![\w+\-.@])xmpp:([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)(\/(?:[\w\-/]|\.(?=[\dA-Za-z]))*)?/g,K2],[/(?<![\w+\-.@])mailto:([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)/g,G2],[/(?<![\w+\-.]|(?:^|[^\d@A-Za-z])(?:mailto|xmpp):)([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)/g,W2]],{ignore:[`link`,`linkReference`]})}function U2(e,t,n,r,i){if(!Y2(i))return!1;let a=``;if(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),vt(n.charCodeAt(0))||!q2(n))return!1;let o=J2(n+r),s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0],position:void 0}],position:void 0};return o[1]?[s,{type:`text`,value:o[1],position:void 0}]:s}function W2(e,t,n){return!/[\d\-_]$/.test(n)&&{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n,position:void 0}],position:void 0}}function G2(e,t,n){if(/[\d\-_]$/.test(n))return!1;let r=`mailto:`+t+`@`+n;return{type:`link`,title:null,url:r,children:[{type:`text`,value:r,position:void 0}],position:void 0}}function K2(e,t,n,r,i){if(/[\d\-_]$/.test(n)||r&&(!/[A-Za-z]$/.test(r)||i.input.charAt(i.index+e.length)===`@`))return!1;let a=`xmpp:`+t+`@`+n+(r||``);return{type:`link`,title:null,url:a,children:[{type:`text`,value:a,position:void 0}],position:void 0}}function q2(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[\dA-Za-z]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[\dA-Za-z]/.test(t[t.length-2])))}function J2(e){let t=e.length;for(;t>0;){let n=e.charCodeAt(t-1);if(n===33||n===34||n===38||n===39||n===41||n===44||n===46||n===58||n===59||n===60||n===62||n===63||n===93||n===125)t--;else break}if(t===e.length)return[e,void 0];let n=e.slice(t);e=e.slice(0,t);let r=n.indexOf(`)`),i=E2(e,`(`),a=E2(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function Y2(e){let t=e.input.charCodeAt(e.index-1);return e.index===0||yt(t)||vt(t)}a4.peek=i4;function X2(){this.buffer()}function Z2(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Q2(){this.buffer()}function $2(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function e4(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=dt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function t4(e){this.exit(e)}function n4(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=dt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function r4(e){this.exit(e)}function i4(){return`[`}function a4(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function o4(){return{enter:{gfmFootnoteCallString:X2,gfmFootnoteCall:Z2,gfmFootnoteDefinitionLabelString:Q2,gfmFootnoteDefinition:$2},exit:{gfmFootnoteCallString:e4,gfmFootnoteCall:t4,gfmFootnoteDefinitionLabelString:n4,gfmFootnoteDefinition:r4}}}function s4(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:a4},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
51
+ `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?l4:c4))),s(),o}}function c4(e,t,n){return t===0?e:l4(e,t,n)}function l4(e,t,n){return(n?``:` `)+e}var u4=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];h4.attention=g4,h4.peek=_4;function d4(){return{canContainEols:[`delete`],enter:{strikethrough:p4},exit:{strikethrough:m4}}}function f4(){return{handlers:{delete:h4},unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:u4}]}}function p4(e){this.enter({type:`delete`,children:[],position:void 0},e)}function m4(e){this.exit(e)}function h4(e,t,n,r){let i=n.createTracker(r),a=n.stack.includes(`strikethrough`)?`~`:`~~`,o=n.enter(`strikethrough`),s=i.move(a);return s+=n.containerPhrasing(e,{...i.current(),before:s,after:`~`}),s+=i.move(a),o(),s}function g4(){return{construct:`strikethrough`,markers:[`~`],sizes:[2,1]}}function _4(){return`~`}function v4(e){return e.length}function y4(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||v4,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=b4(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=x4(r[d]);else{let e=x4(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u],r=n.fillRows===!1?Math.max(1,o[u===1?0:u].length):l;d=-1;let i=[];for(;++d<r;){let o=e[d]||``,s=``,l=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];if(n===114)s=` `.repeat(e);else if(n===99){let t=e/2;e%2?(s=` `.repeat(t+.5),l=` `.repeat(t-.5)):(s=` `.repeat(t),l=s)}else l=` `.repeat(e)}n.delimiterStart!==!1&&!d&&i.push(`|`),n.padding===!1||n.alignDelimiters===!1&&o===``||n.delimiterStart===!1&&!d||i.push(` `),n.alignDelimiters!==!1&&i.push(s),i.push(o),n.alignDelimiters!==!1&&i.push(l),n.padding!==!1&&i.push(` `),(n.delimiterEnd!==!1||d!==r-1)&&i.push(`|`)}m.push(n.delimiterEnd===!1?i.join(``).replace(/ +$/,``):i.join(``))}return m.join(`
52
+ `)}function b4(e){return e==null?``:String(e)}function x4(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function S4(){return{enter:{table:C4,tableData:D4,tableHeader:D4,tableRow:T4},exit:{codeText:O4,table:w4,tableData:E4,tableHeader:E4,tableRow:E4}}}function C4(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[],position:void 0},e),this.data.inTable=!0}function w4(e){this.exit(e),this.data.inTable=void 0}function T4(e){this.enter({type:`tableRow`,children:[],position:void 0},e)}function E4(e){this.exit(e)}function D4(e){this.enter({type:`tableCell`,children:[],position:void 0},e)}function O4(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,k4));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function k4(e,t){return t===`|`?t:e}function A4(e){let{tableCellPadding:t,tablePipeAlign:n,stringLength:r}=e||{},i=t?` `:`|`;return{handlers:{inlineCode:d,table:a,tableCell:s,tableRow:o},join:[j4],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 a(e,t,n,r){let i=l(e,n,r),a=i[0];if(a){let t=e.align?e.align.length:0,n=-1;if(!t)for(;++n<i.length;)i[n].length>t&&(t=i[n].length);for(;a.length<t;)a.push(``)}return c(i,e.align)}function o(e,t,n,r){let i=c([u(e,n,r)]);return i.slice(0,i.indexOf(`
54
+ `))}function s(e,t,n,r){let a=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:i,after:i});return o(),a(),s}function c(e,i){return y4(e,{align:i,alignDelimiters:n,fillRows:!1,padding:t,stringLength:r})}function l(e,t,n){let{children:r}=e,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=u(r[i],t,n);return o(),a}function u(e,t,n){let{children:r}=e,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=s(r[i],e,t,n);return o(),a}function d(e,t,n){let r=Na.inlineCode(e,t,n);if(!n.stack.includes(`tableCell`))return r;let i=[],a=0,o=r.indexOf(`|`);for(;o!==-1;){let e=o;for(;e>a&&r.charCodeAt(e-1)===92;)e--;i.push(r.slice(a,o)),(o-e)%2==0&&i.push(`\\`),a=o,o=r.indexOf(`|`,o+1)}return i.push(r.slice(a)),i.join(``)}}function j4(e,t,n,r){if(e.type===`table`&&n.type===`listItem`&&n.spread===!1&&(t.type===`definition`||t.type===`heading`&&M4(t,r)||t.type===`paragraph`||t.type===`table`))return 1}function M4(e,t){let n=!1;return $i(e,function(e){if(e.type===`break`||`value`in e&&/\r?\n|\r/.test(e.value))return n=!0,!1}),!!((!e.depth||e.depth<3)&&et(e)&&(t.options.setext||n))}function N4(){return{exit:{taskListCheckValueChecked:F4,taskListCheckValueUnchecked:F4,paragraph:I4}}}function P4(){return{handlers:{paragraph:L4},join:[R4]}}function F4(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function I4(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start={...n.position.start}))}}this.exit(e)}function L4(e,t,n,r){if(!t||t.type!==`listItem`||z4(t)!==e)return Na.paragraph(e,t,n,r);let i=`[`+(t.checked?`x`:` `)+`] `,a=n.createTracker(r);return a.move(i),i+Na.paragraph(e.children.length>0?e:{type:`paragraph`,children:[{type:`text`,value:` `}]},t,n,{...r,...a.current()})}function R4(e,t,n){if(e.type!==`definition`||n.type!==`listItem`)return;let r=z4(n);if(r&&n.children.indexOf(e)<n.children.indexOf(r))return 0}function z4(e){if(typeof e.checked==`boolean`)for(let t of e.children){if(t.type===`paragraph`)return t;if(t.type!==`definition`)return}}function B4(){return[P2(),o4(),d4(),S4(),N4()]}function V4(e){return{extensions:[F2(),s4(e),f4(),A4(e),P4()]}}var H4={tokenize:n3,partial:!0},U4={tokenize:r3,partial:!0},W4={tokenize:i3,partial:!0},G4={tokenize:a3,partial:!0},K4={tokenize:o3,partial:!0},q4={name:`wwwAutolink`,tokenize:e3,previous:s3},J4={name:`protocolAutolink`,tokenize:t3,previous:c3},Y4={name:`emailAutolink`,tokenize:$4,previous:l3},X4={};function Z4(){return{text:X4}}for(var Q4=48;Q4<123;)X4[Q4]=Y4,Q4++,Q4===58?Q4=65:Q4===91&&(Q4=97);X4[43]=Y4,X4[45]=Y4,X4[46]=Y4,X4[95]=Y4,X4[72]=[Y4,J4],X4[104]=[Y4,J4],X4[87]=[Y4,q4],X4[119]=[Y4,q4];function $4(e,t,n){let r=this,i,a;return o;function o(t){return!u3(t)||!l3.call(r,r.previous)||d3(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return u3(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(K4,u,l)(t):t===45||t===95||ft(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&E(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function e3(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!s3.call(r,r.previous)||d3(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(H4,e.attempt(U4,e.attempt(W4,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function t3(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&c3.call(r,r.previous)&&!d3(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(E(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||mt(t)||O(t)||yt(t)||vt(t)?n(t):e.attempt(U4,e.attempt(W4,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function n3(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function r3(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(G4,c,s)(t):t===null||O(t)||yt(t)||t!==45&&vt(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function i3(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(G4,t,a)(o):o===null||O(o)||yt(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function a3(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||O(o)||yt(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||O(e)||yt(e)?t(e):r(e)}function a(e){return E(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):E(t)?(e.consume(t),o):n(t)}}function o3(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return ft(e)?n(e):t(e)}}function s3(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||O(e)}function c3(e){return!E(e)}function l3(e){return!(e===47||u3(e))}function u3(e){return e===43||e===45||e===46||e===95||ft(e)}function d3(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var f3={tokenize:b3,partial:!0};function p3(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:_3,continuation:{tokenize:v3},exit:y3}},text:{91:{name:`gfmFootnoteCall`,tokenize:g3},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:m3,resolveTo:h3}}}}function m3(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=dt(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function h3(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function g3(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||O(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(dt(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return O(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function _3(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||O(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=dt(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return O(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),A(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function v3(e,t,n){return e.check(Rt,t,e.attempt(f3,t,n))}function y3(e){e.exit(`gfmFootnoteDefinition`)}function b3(e,t,n){let r=this;return A(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function x3(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&it(o,o.length,0,jt(s,e.slice(r+1,n),t)),it(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),it(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=At(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=At(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var S3=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){C3(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function C3(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function w3(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function T3(){return{flow:{null:{name:`table`,tokenize:E3,resolveAll:D3}}}}function E3(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):D(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):k(t)?A(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||O(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,k(t)?A(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return k(t)?A(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||D(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return k(t)?A(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||D(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),ee(t)}function ee(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),ee):n===null||D(n)?(e.exit(`tableRow`),t(n)):k(n)?A(e,ee,`whitespace`)(n):(e.enter(`data`),te(n))}function te(t){return t===null||t===124||O(t)?(e.exit(`data`),ee(t)):(e.consume(t),t===92?ne:te)}function ne(t){return t===92||t===124?(e.consume(t),te):te(t)}}function D3(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new S3;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(k3(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=O3(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=O3(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=O3(f,t,o,i,n,d)):(o[0]=o[1],d=O3(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&k3(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=w3(t.events,n))}return e}function O3(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},A3(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=A3(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=A3(t.events,n[2]),a=A3(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},A3(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function k3(e,t,n,r,i){let a=[],o=A3(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function A3(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var j3={name:`tasklistCheck`,tokenize:N3};function M3(){return{text:{91:j3}}}function N3(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return O(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return D(r)?t(r):k(r)?e.check({tokenize:P3},t,n)(r):n(r)}}function P3(e,t,n){return A(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function F3(e){return st([Z4(),p3(),x3(e),T3(),M3()])}var I3={};function L3(e){let t=this,n=e||I3,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(F3(n)),a.push(B4()),o.push(V4(n))}function Q(e,t){return Object.assign(e,{meta:{package:`@milkdown/preset-gfm`,...t}}),e}var R3=X_(`strike_through`);Q(R3,{displayName:`Attr<strikethrough>`,group:`Strikethrough`});var z3=q_(`strike_through`,e=>({parseDOM:[{tag:`del`},{style:`text-decoration`,getAttrs:e=>e===`line-through`}],toDOM:t=>[`del`,e.get(R3.key)(t)],parseMarkdown:{match:e=>e.type===`delete`,runner:(e,t,n)=>{e.hasMark(n)?e.next(t.children):(e.openMark(n),e.next(t.children),e.closeMark(n))}},toMarkdown:{match:e=>e.type.name===`strike_through`,runner:(e,t)=>{e.withMark(t,`delete`)}}}));Q(z3.mark,{displayName:`MarkSchema<strikethrough>`,group:`Strikethrough`}),Q(z3.ctx,{displayName:`MarkSchemaCtx<strikethrough>`,group:`Strikethrough`});var B3=q(`ToggleStrikeThrough`,e=>()=>Du(z3.type(e)));Q(B3,{displayName:`Command<ToggleStrikethrough>`,group:`Strikethrough`});var V3=B_(e=>td(/(?<![\w:/])(~{1,2})(.+?)\1(?!\w|\/)$/,z3.type(e)));Q(V3,{displayName:`InputRule<strikethrough>`,group:`Strikethrough`});var H3=J_(`strikeThroughKeymap`,{ToggleStrikethrough:{shortcuts:`Mod-Alt-x`,command:e=>{let t=e.get(G);return()=>t.call(B3.key)}}});Q(H3.ctx,{displayName:`KeymapCtx<strikethrough>`,group:`Strikethrough`}),Q(H3.shortcuts,{displayName:`Keymap<strikethrough>`,group:`Strikethrough`});function U3(e,t){let n=t.content.firstChild;if(t.childCount!==1||n?.type.name!==`paragraph`){e.next(t.content);return}let r=n.lastChild,i=r?.type.name===`hardbreak`?n.content.cut(0,n.content.size-r.nodeSize):n.content;e.next(i)}var W3=jv({tableGroup:`block`,cellContent:`paragraph`,cellAttributes:{alignment:{default:`left`,getFromDOM:e=>e.style.textAlign||`left`,setDOMAttr:(e,t)=>{t.style=`text-align: ${e||`left`}`}}}}),G3=J(`table`,()=>({...W3.table,content:`table_header_row table_row+`,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`table`,runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,t)=>({...e,align:r,isHeader:t===0}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table`,runner:(e,t)=>{let n=t.content.firstChild?.content;if(!n)return;let r=[];n.forEach(e=>{r.push(e.attrs.alignment)}),e.openNode(`table`,void 0,{align:r}),e.next(t.content),e.closeNode()}}}));Q(G3.node,{displayName:`NodeSchema<table>`,group:`Table`}),Q(G3.ctx,{displayName:`NodeSchemaCtx<table>`,group:`Table`});var K3=J(`table_header_row`,()=>({...W3.table_row,disableDropCursor:!0,content:`(table_header)*`,parseDOM:[{tag:`tr[data-is-header]`},{tag:`tr`,getAttrs:e=>e instanceof HTMLElement&&e.querySelector(`th`)?{}:!1}],toDOM(){return[`tr`,{"data-is-header":!0},0]},parseMarkdown:{match:e=>!!(e.type===`tableRow`&&e.isHeader),runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,n)=>({...e,align:r[n],isHeader:t.isHeader}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_header_row`,runner:(e,t)=>{t.content.size!==0&&(e.openNode(`tableRow`,void 0,{isHeader:!0}),e.next(t.content),e.closeNode())}}}));Q(K3.node,{displayName:`NodeSchema<tableHeaderRow>`,group:`Table`}),Q(K3.ctx,{displayName:`NodeSchemaCtx<tableHeaderRow>`,group:`Table`});var q3=J(`table_row`,()=>({...W3.table_row,disableDropCursor:!0,content:`(table_cell)*`,parseMarkdown:{match:e=>e.type===`tableRow`,runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,t)=>({...e,align:r[t]}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_row`,runner:(e,t)=>{t.content.size!==0&&(e.openNode(`tableRow`),e.next(t.content),e.closeNode())}}}));Q(q3.node,{displayName:`NodeSchema<tableRow>`,group:`Table`}),Q(q3.ctx,{displayName:`NodeSchemaCtx<tableRow>`,group:`Table`});var J3=J(`table_cell`,()=>({...W3.table_cell,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`tableCell`&&!e.isHeader,runner:(e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode()}},toMarkdown:{match:e=>e.type.name===`table_cell`,runner:(e,t)=>{e.openNode(`tableCell`),U3(e,t),e.closeNode()}}}));Q(J3.node,{displayName:`NodeSchema<tableCell>`,group:`Table`}),Q(J3.ctx,{displayName:`NodeSchemaCtx<tableCell>`,group:`Table`});var Y3=J(`table_header`,()=>({...W3.table_header,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`tableCell`&&!!e.isHeader,runner:(e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}),e.openNode(e.schema.nodes.paragraph),e.next(t.children),e.closeNode(),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_header`,runner:(e,t)=>{e.openNode(`tableCell`),U3(e,t),e.closeNode()}}}));Q(Y3.node,{displayName:`NodeSchema<tableHeader>`,group:`Table`}),Q(Y3.ctx,{displayName:`NodeSchemaCtx<tableHeader>`,group:`Table`});function X3(e,t=3,n=3){let r=Array(n).fill(0).map(()=>J3.type(e).createAndFill()),i=Array(n).fill(0).map(()=>Y3.type(e).createAndFill()),a=Array(t).fill(0).map((t,n)=>n===0?K3.type(e).create(null,i):q3.type(e).create(null,r));return G3.type(e).create(null,a)}function Z3(e){return(t,n)=>r=>{n??=r.selection.from;let i=r.doc.resolve(n),a=od(e=>e.type.name===`table`)(i),o=a?{node:a.node,from:a.start}:void 0,s=e===`row`;if(o){let e=X.get(o.node);if(t>=0&&t<(s?e.height:e.width)){let n=e.positionAt(s?t:e.height-1,s?e.width-1:t,o.node),i=r.doc.resolve(o.from+n),a=s?Z.rowSelection:Z.colSelection,c=e.positionAt(s?t:0,s?0:t,o.node),l=r.doc.resolve(o.from+c);return nd(r.setSelection(a(i,l)))}}return r}}var Q3=Z3(`row`),$3=Z3(`col`);function e6(e,t,{map:n,tableStart:r,table:i},a){let o=Array(a).fill(0).reduce((e,t,n)=>e+i.child(n).nodeSize,r),s=Array(n.width).fill(0).map((t,r)=>{let a=i.nodeAt(n.map[r]);return J3.type(e).createAndFill({alignment:a?.attrs.alignment})});return t.insert(o,q3.type(e).create(null,s)),t}function t6(e){let t=ry(e.$from);if(!t)return;let n=X.get(t.node);return n.cellsInRect({left:0,right:n.width,top:0,bottom:n.height}).map(e=>{let n=t.node.nodeAt(e),r=e+t.start;return{pos:r,start:r+1,node:n}})}function n6(e){let t=t6(e.selection);if(t&&t[0]){let n=e.doc.resolve(t[0].pos),r=t[t.length-1];if(r){let t=e.doc.resolve(r.pos);return nd(e.setSelection(new Z(t,n)))}}return e}var r6=q(`GoToPrevTableCell`,()=>()=>Dy(-1));Q(r6,{displayName:`Command<goToPrevTableCellCommand>`,group:`Table`});var i6=q(`GoToNextTableCell`,()=>()=>Dy(1));Q(i6,{displayName:`Command<goToNextTableCellCommand>`,group:`Table`});var a6=q(`ExitTable`,e=>()=>(t,n)=>{if(!Fv(t))return!1;let{$head:r}=t.selection,i=ad(r,G3.type(e));if(!i)return!1;let{to:a}=i,o=t.tr.replaceWith(a,a,e0.type(e).createAndFill());return o.setSelection(I.near(o.doc.resolve(a),1)).scrollIntoView(),n?.(o),!0});Q(a6,{displayName:`Command<breakTableCommand>`,group:`Table`});var o6=q(`InsertTable`,e=>({row:t,col:n}={})=>(r,i)=>{let{selection:a,tr:o}=r,{from:s}=a,c=X3(e,t,n),l=o.replaceSelectionWith(c),u=I.findFrom(l.doc.resolve(s),1,!0);return u&&l.setSelection(u),i?.(l),!0});Q(o6,{displayName:`Command<insertTableCommand>`,group:`Table`});var s6=q(`MoveRow`,()=>({from:e,to:t,pos:n}={})=>Ay({from:e??0,to:t??0,pos:n}));Q(s6,{displayName:`Command<moveRowCommand>`,group:`Table`});var c6=q(`MoveCol`,()=>({from:e,to:t,pos:n}={})=>jy({from:e??0,to:t??0,pos:n}));Q(c6,{displayName:`Command<moveColCommand>`,group:`Table`});var l6=q(`SelectRow`,()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.(Q3(e.index,e.pos)(r))});Q(l6,{displayName:`Command<selectRowCommand>`,group:`Table`});var u6=q(`SelectCol`,()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.($3(e.index,e.pos)(r))});Q(u6,{displayName:`Command<selectColCommand>`,group:`Table`});var d6=q(`SelectTable`,()=>()=>(e,t)=>{let{tr:n}=e;return!!t?.(n6(n))});Q(d6,{displayName:`Command<selectTableCommand>`,group:`Table`});var f6=q(`DeleteSelectedCells`,()=>()=>(e,t)=>{let{selection:n}=e;if(!(n instanceof Z))return!1;let r=n.isRowSelection(),i=n.isColSelection();return r&&i?Oy(e,t):i?yy(e,t):xy(e,t)});Q(f6,{displayName:`Command<deleteSelectedCellsCommand>`,group:`Table`});var p6=q(`AddColBefore`,()=>()=>gy);Q(p6,{displayName:`Command<addColBeforeCommand>`,group:`Table`});var m6=q(`AddColAfter`,()=>()=>_y);Q(m6,{displayName:`Command<addColAfterCommand>`,group:`Table`});var h6=q(`AddRowBefore`,e=>()=>(t,n)=>{if(!Fv(t))return!1;if(n){let r=my(t);n(e6(e,t.tr,r,r.top))}return!0});Q(h6,{displayName:`Command<addRowBeforeCommand>`,group:`Table`});var g6=q(`AddRowAfter`,e=>()=>(t,n)=>{if(!Fv(t))return!1;if(n){let r=my(t);n(e6(e,t.tr,r,r.bottom))}return!0});Q(g6,{displayName:`Command<addRowAfterCommand>`,group:`Table`});var _6=q(`SetAlign`,()=>(e=`left`)=>Sy(`alignment`,e));Q(_6,{displayName:`Command<setAlignCommand>`,group:`Table`});var v6=B_(e=>new Pu(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(t,n,r,i)=>{let a=t.doc.resolve(r);if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),G3.type(e)))return null;let o=X3(e,Math.max(Number(n.groups?.row??0),2),Number(n.groups?.col)),s=t.tr.replaceRangeWith(r,i,o);return s.setSelection(L.create(s.doc,r+3)).scrollIntoView()}));Q(v6,{displayName:`InputRule<insertTableInputRule>`,group:`Table`});var y6=V_(e=>({run:(t,n,r)=>{if(r)return t;function i(t){let n=t.childCount,r=t.lastChild?.childCount??0;if(n===0||r===0)return e0.type(e).create();let i=t.firstChild;if(!(r>0&&i&&i.childCount===0))return t;if(n>=3){let r=t.child(1),a=[];for(let t=0;t<r.childCount;t++){let n=r.child(t);a.push(Y3.type(e).create(n.attrs,n.content,n.marks))}let o=i.type.create(i.attrs,a),s=[];for(let e=2;e<n;e++)s.push(t.child(e));return t.type.create(t.attrs,[o,...s])}let a=Array(r).fill(0).map(()=>Y3.type(e).createAndFill()),o=new P(M.from(a),0,0),s=i.replace(0,0,o);return t.replace(0,i.nodeSize,new P(M.from(s),0,0))}function a(t){let n=q3.type(e),r=[],a=[],o=!1;function s(){if(a.length===0)return;let t=K3.type(e).createAndFill(),n=G3.type(e).create(null,[t,...a]);r.push(i(n)),a=[]}return t.forEach(e=>{e.type===n?(o=!0,a.push(e)):(s(),r.push(e))}),s(),o?M.from(r):t}function o(t){let n=a(t),r=n!==t,s=[];return n.forEach(t=>{if(t.type===G3.type(e)){let e=i(t);e!==t&&(r=!0),s.push(e)}else if(t.childCount>0){let e=o(t.content);e===t.content?s.push(t):(r=!0,s.push(t.copy(e)))}else s.push(t)}),r?M.from(s):t}function s(t){let n=[],r=[];t.forEach(e=>r.push(e));for(let t=0;t<r.length;t++){let i=r[t],a=r[t+1];i.type===e0.type(e)&&i.content.size===0&&a&&a.type===G3.type(e)||n.push(i)}return n.length<r.length?M.from(n):t}let c=o(t.content);return c=s(c),new P(M.from(c),t.openStart,t.openEnd)}}));Q(y6,{displayName:`PasteRule<table>`,group:`Table`});var b6=J_(`tableKeymap`,{NextCell:{priority:100,shortcuts:[`Mod-]`,`Tab`],command:e=>{let t=e.get(G);return()=>t.call(i6.key)}},PrevCell:{shortcuts:[`Mod-[`,`Shift-Tab`],command:e=>{let t=e.get(G);return()=>t.call(r6.key)}},ExitTable:{shortcuts:[`Mod-Enter`,`Enter`],command:e=>{let t=e.get(G);return()=>t.call(a6.key)}}});Q(b6.ctx,{displayName:`KeymapCtx<table>`,group:`Table`}),Q(b6.shortcuts,{displayName:`Keymap<table>`,group:`Table`});var x6=`footnote_definition`,S6=`footnoteDefinition`,C6=J(`footnote_definition`,()=>({group:`block`,content:`block+`,defining:!0,attrs:{label:{default:``,validate:`string`}},parseDOM:[{tag:`dl[data-type="${x6}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Be(e);return{label:e.dataset.label}},contentElement:`dd`}],toDOM:e=>{let t=e.attrs.label;return[`dl`,{"data-label":t,"data-type":x6},[`dt`,t],[`dd`,0]]},parseMarkdown:{match:({type:e})=>e===S6,runner:(e,t,n)=>{e.openNode(n,{label:t.label}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===x6,runner:(e,t)=>{e.openNode(S6,void 0,{label:t.attrs.label,identifier:t.attrs.label}).next(t.content).closeNode()}}}));Q(C6.ctx,{displayName:`NodeSchemaCtx<footnodeDef>`,group:`footnote`}),Q(C6.node,{displayName:`NodeSchema<footnodeDef>`,group:`footnote`});var w6=`footnote_reference`,T6=J(`footnote_reference`,()=>({group:`inline`,inline:!0,atom:!0,attrs:{label:{default:``,validate:`string`}},parseDOM:[{tag:`sup[data-type="${w6}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Be(e);return{label:e.dataset.label}}}],toDOM:e=>{let t=e.attrs.label;return[`sup`,{"data-label":t,"data-type":w6},t]},parseMarkdown:{match:({type:e})=>e===`footnoteReference`,runner:(e,t,n)=>{e.addNode(n,{label:t.label})}},toMarkdown:{match:e=>e.type.name===w6,runner:(e,t)=>{e.addNode(`footnoteReference`,void 0,void 0,{label:t.attrs.label,identifier:t.attrs.label})}}}));Q(T6.ctx,{displayName:`NodeSchemaCtx<footnodeRef>`,group:`footnote`}),Q(T6.node,{displayName:`NodeSchema<footnodeRef>`,group:`footnote`});var E6=K0.extendSchema(e=>t=>{let n=e(t);return{...n,attrs:{...n.attrs,checked:{default:null,validate:`boolean|null`}},parseDOM:[{tag:`li[data-item-type="task"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Be(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread===`true`,checked:e.dataset.checked?e.dataset.checked===`true`:null}}},...n?.parseDOM||[]],toDOM:e=>n.toDOM&&e.attrs.checked==null?n.toDOM(e):[`li`,{"data-item-type":`task`,"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread,"data-checked":e.attrs.checked},0],parseMarkdown:{match:({type:e})=>e===`listItem`,runner:(e,t,r)=>{if(t.checked==null){n.parseMarkdown.runner(e,t,r);return}let i=t.label==null?`•`:`${t.label}.`,a=t.checked==null?null:!!t.checked,o=t.label==null?`bullet`:`ordered`,s=t.spread??!0;e.openNode(r,{label:i,listType:o,spread:s,checked:a}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`list_item`,runner:(e,t)=>{if(t.attrs.checked==null){n.toMarkdown.runner(e,t);return}let r=t.attrs.label,i=t.attrs.listType,a=t.attrs.spread,o=t.attrs.checked;e.openNode(`listItem`,void 0,{label:r,listType:i,spread:a,checked:o}),e.next(t.content),e.closeNode()}}}});Q(E6.node,{displayName:`NodeSchema<taskListItem>`,group:`ListItem`}),Q(E6.ctx,{displayName:`NodeSchemaCtx<taskListItem>`,group:`ListItem`});var D6=B_(()=>new Pu(/^\[(?<checked>\s|x)\]\s$/,(e,t,n,r)=>{let i=e.doc.resolve(n),a=0,o=i.node(a);for(;o&&o.type.name!==`list_item`;)a--,o=i.node(a);if(!o||o.attrs.checked!=null)return null;let s=t.groups?.checked===`x`,c=i.before(a),l=e.tr;return l.deleteRange(n,r).setNodeMarkup(c,void 0,{...o.attrs,checked:s}),l}));Q(D6,{displayName:`InputRule<wrapInTaskListInputRule>`,group:`ListItem`});var O6=[H3,b6].flat(),k6=[v6,D6],A6=[V3],j6=[y6],M6=W_(()=>T2);Q(M6,{displayName:`Prose<autoInsertSpanPlugin>`,group:`Prose`}),Q(W_(()=>$y({})),{displayName:`Prose<columnResizingPlugin>`,group:`Prose`});var N6=W_(()=>p2({allowTableNodeSelection:!0}));Q(N6,{displayName:`Prose<tableEditingPlugin>`,group:`Prose`});var P6=Z_(`remarkGFM`,()=>L3);Q(P6.plugin,{displayName:`Remark<remarkGFMPlugin>`,group:`Remark`}),Q(P6.options,{displayName:`RemarkConfig<remarkGFMPlugin>`,group:`Remark`});var F6=new Zl(`MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN`);function I6(e,t){let n=0;return t.forEach((t,r,i)=>{t===e&&(n=i)}),n}function L6(e,t){let n=e.content.findDiffStart(t.content);if(n==null)return null;let r=e.content.findDiffEnd(t.content);return r?{from:n,to:Math.max(r.b,n)}:null}var R6=W_(()=>new Jl({key:F6,appendTransaction:(e,t,n)=>{if(t.doc===n.doc)return;let r=L6(t.doc,n.doc);if(!r)return;let i,a=(e,t)=>{if(e.type.name!==`table_cell`)return;let r=n.doc.resolve(t),a=r.node(r.depth),o=r.node(r.depth-1).firstChild;if(!o)return;let s=I6(e,a),c=o.maybeChild(s);if(!c)return;let l=c.attrs.alignment;l!==e.attrs.alignment&&(i||=n.tr,i.setNodeMarkup(t,void 0,{...e.attrs,alignment:l}))};return n.doc.nodesBetween(r.from,r.to,(e,t)=>e.type.name!==`table`||(n.doc.nodesBetween(t,t+e.nodeSize,a),!1)),i}}));Q(R6,{displayName:`Prose<keepTableAlignPlugin>`,group:`Prose`});var z6=[R6,M6,P6,N6].flat(),B6=[[E6,G3,K3,q3,Y3,J3,C6,T6,R3,z3].flat(),k6,j6,A6,O6,[i6,r6,a6,o6,s6,c6,l6,u6,d6,f6,h6,g6,p6,m6,_6,B3],z6].flat(),V6=y0.extendSchema(e=>t=>{let n=e(t);return{...n,attrs:{...n.attrs,meta:{default:``,validate:`string`}},parseDOM:[{tag:`pre`,preserveWhitespace:`full`,getAttrs:e=>({language:e instanceof HTMLElement?e.dataset.language??``:``,meta:e instanceof HTMLElement?e.dataset.meta??``:``})}],toDOM:e=>{let n=t.get(v0.key)(e),r=e.attrs.language,i=e.attrs.meta;return[`pre`,{...n.pre,...r?{"data-language":r}:{},...i?{"data-meta":i}:{}},[`code`,n.code,0]]},parseMarkdown:{match:({type:e})=>e===`code`,runner:(e,t,n)=>{e.openNode(n,{language:typeof t.lang==`string`?t.lang:``,meta:typeof t.meta==`string`?t.meta:``}),typeof t.value==`string`&&t.value&&e.addText(t.value),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`code_block`,runner:(e,t)=>{e.addNode(`code`,void 0,t.content.firstChild?.text??``,{lang:t.attrs.language,meta:t.attrs.meta||null})}}}});function H6(e,t,n){let r=e.elements[0],i=(0,z.useRef)(null),a=(0,z.useRef)(e);a.current=e;let o=(0,z.useRef)(n);o.current=n;let s=(0,z.useRef)(t?.text??``),c=(0,z.useRef)(!1),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)(``);return(0,z.useEffect)(()=>{if(!r||!t)return;let e=!1,n=r.innerHTML,l=r.ownerDocument,d=l.createElement(`div`);d.className=`live-markdown-root`,d.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),a.current.onClose())});let p=l.createElement(`style`);p.textContent=`.live-markdown-root .ProseMirror{outline:none;min-height:1em;white-space:pre-wrap;overflow-wrap:break-word}.live-markdown-root .ProseMirror-selectednode{outline:2px solid currentColor}.live-markdown-root .ProseMirror p:first-child{margin-top:0}.live-markdown-root .ProseMirror p:last-child{margin-bottom:0}`;let g=r.firstElementChild?.tagName===`H2`?r.firstElementChild:null;r.replaceChildren(...g?[g]:[],p,d);let v=p_.make().config(n=>{n.set(o_,d),n.set(Kg,t.text),n.update(a_,l=>({...l,dispatchTransaction(l){if(this.updateState(this.state.apply(l)),!e&&i.current&&o.current(this.state),e||!i.current||!l.docChanged)return;c.current=!0,s.current=n.get(Wg)(this.state.doc).trimEnd();let u=a.current;u.onBody(_(t,s.current));for(let e of u.elements)e!==r&&h(e,s.current,u.target.kind===`section`?u.target.heading:null);u.onPatched()}}))}).use(xv).use(V6).use(B6).use(a1);return v.create().then(()=>{e?v.destroy():(i.current=v,v.action(e=>{let t=e.get(rg);t.dom.setAttribute(`aria-label`,m(a.current.target)),t.dom.setAttribute(`role`,`textbox`),t.dom.setAttribute(`aria-multiline`,`true`),o.current(t.state),t.focus()}),u(!0),a.current.onPatched())}).catch(()=>{e||(i.current=null,v.destroy(),r.innerHTML=n,f(`This content could not be opened visually. Use Structure mode to edit its Markdown.`))}),()=>{e=!0,i.current=null,v.destroy(),c.current?(r.innerHTML=n,h(r,s.current,a.current.target.kind===`section`?a.current.target.heading:null)):r.innerHTML=n}},[r,t]),{engine:i,text:s,changed:c,ready:l,error:d}}function U6(e){let{from:t,to:n,empty:r,$from:i}=e.selection,a=[],o=(t,n)=>{let r=e.doc.resolve(t),i=Array.from({length:r.depth},(e,t)=>r.node(t+1).type.name);a.push({bold:n.some(e=>e.type.name===`strong`),italic:n.some(e=>e.type.name===`emphasis`),strike:n.some(e=>e.type.name===`strike_through`),link:n.some(e=>e.type.name===`link`),bullet:i.includes(`bullet_list`),ordered:i.includes(`ordered_list`),quote:i.includes(`blockquote`),style:r.parent.type.name===`heading`?String(r.parent.attrs.level):r.parent.type.name===`paragraph`?`0`:r.parent.type.name})};r?o(t,e.storedMarks??i.marks()):e.doc.nodesBetween(t,n,(e,n)=>{e.isText&&o(Math.max(t,n),e.marks)}),a.length===0&&o(t,i.marks());let s=e=>a.every(t=>t[e])?!0:a.some(t=>t[e])?`mixed`:!1,c=a[0]?.style??`0`;return{bold:s(`bold`),italic:s(`italic`),strike:s(`strike`),link:s(`link`),bullet:s(`bullet`),ordered:s(`ordered`),quote:s(`quote`),style:a.every(e=>e.style===c)?c:`mixed`}}var $=i();function W6(e,t){return[{icon:ae,label:`Bold`,pressed:e.bold,action:e=>e.action(Q_(O1.key))},{icon:w,label:`Italic`,pressed:e.italic,action:e=>e.action(Q_(S1.key))},{icon:_e,label:`Strikethrough`,pressed:e.strike,action:e=>e.action(Q_(B3.key))},{icon:de,label:`Bullet list`,block:!0,pressed:e.bullet,action:e=>e.action(Q_(R0.key))},{icon:le,label:`Numbered list`,block:!0,pressed:e.ordered,action:e=>e.action(Q_(U0.key))},{icon:pe,label:`Quote`,block:!0,pressed:e.quote,action:e=>e.action(Q_(g0.key))},{icon:se,label:`Link`,pressed:e.link,action:e=>{t(e.action(e=>{let t=e.get(rg).state.selection.$from.marks().find(e=>e.type.name===`link`);return typeof t?.attrs.href==`string`?t.attrs.href:``}))}},{icon:De,label:`Undo`,action:e=>e.action(Q_(e1.key))},{icon:he,label:`Redo`,action:e=>e.action(Q_(t1.key))}]}function G6(e){let{formatting:t,table:n,ready:r,run:i}=e,a=W6(t,e.setLink);return(0,$.jsxs)(`div`,{className:`live-context-actions live-formatting`,role:`toolbar`,"aria-label":`Text formatting`,children:[(0,$.jsxs)(`select`,{"aria-label":`Text style`,disabled:!r||n!==null,title:n?`Table cells support text formatting; headings belong outside the table.`:void 0,value:t.style,onChange:e=>{let t=Number(e.target.value);i(e=>e.action(t===0?Q_(n0.key):Q_(u0.key,t)))},children:[t.style===`mixed`&&(0,$.jsx)(`option`,{value:`mixed`,disabled:!0,children:`Mixed styles`}),![`0`,`3`,`4`,`mixed`].includes(t.style)&&(0,$.jsx)(`option`,{value:t.style,disabled:!0,children:/^\d$/.test(t.style)?`Heading ${t.style}`:`Code block`}),(0,$.jsx)(`option`,{value:`0`,children:`Paragraph`}),(0,$.jsx)(`option`,{value:`3`,children:`Heading`}),(0,$.jsx)(`option`,{value:`4`,children:`Subheading`})]}),a.map(e=>{let{icon:t,label:a,action:o}=e;return(0,$.jsx)(l,{icon:t,label:a,size:`sm`,disabled:!r||n!==null&&`block`in e,"aria-pressed":`pressed`in e?e.pressed:void 0,onPointerDown:e=>e.preventDefault(),onClick:()=>i(o)},a)})]})}function K6(e){let{link:t,setLink:n,run:r}=e,i=e.input;return(0,$.jsxs)(`form`,{className:`live-link-form`,onSubmit:e=>{e.preventDefault(),r(e=>e.action(Q_(H1.key,{href:t.trim()}))),n(null)},children:[(0,$.jsxs)(`label`,{children:[`Link URL`,(0,$.jsx)(`input`,{ref:i,type:`text`,value:t,placeholder:`https://…`,onChange:e=>n(e.target.value)})]}),(0,$.jsx)(c,{size:`sm`,type:`submit`,children:`Apply link`}),(0,$.jsx)(c,{size:`sm`,variant:`ghost`,onClick:()=>{n(null),r(()=>void 0)},children:`Back`})]})}function q6(e){if(!Fv(e))return null;let t=my(e),n=[];for(let e=t.left;e<t.right;e++)n.push(t.table.firstChild?.child(e).attrs.alignment??`left`);let r=n[0];return{position:t.tableStart,row:t.top,lastRow:t.bottom-1,column:t.left,lastColumn:t.right-1,canDeleteRow:t.top>0&&t.map.height-(t.bottom-t.top)>=2,canDeleteColumn:t.map.width-(t.right-t.left)>=1,alignment:n.every(e=>e===r)&&(r===`left`||r===`center`||r===`right`)?r:`mixed`}}function J6(e,t,n){if(!Fv(e.state))return;let r=my(e.state),i=r.map.map[t*r.map.width+n];if(i===void 0)return;let a=e.state.doc.resolve(r.tableStart+i+1);e.dispatch(e.state.tr.setSelection(L.near(a)))}function Y6(e,t){e.action(e=>{let n=e.get(rg),r=q6(n.state);if(r)switch(t){case`row-before`:r.row>0&&(Q_(h6.key)(e),J6(n,r.row,r.column));break;case`row-after`:Q_(g6.key)(e),J6(n,r.lastRow+1,r.column);break;case`column-before`:Q_(p6.key)(e),J6(n,r.row,r.column);break;case`column-after`:Q_(m6.key)(e),J6(n,r.row,r.lastColumn+1);break;case`delete-row`:r.canDeleteRow&&xy(n.state,n.dispatch);break;case`delete-column`:r.canDeleteColumn&&yy(n.state,n.dispatch);break;case`delete-table`:Oy(n.state,n.dispatch);break;default:{let{table:e,tableStart:r,left:i,right:a}=my(n.state),o=n.state.tr;e.forEach((e,n)=>{e.forEach((e,s,c)=>{c>=i&&c<a&&o.setNodeMarkup(r+n+1+s,void 0,{...e.attrs,alignment:t})})}),n.dispatch(o)}}})}function X6({table:e,onAction:t}){let[n,r]=(0,z.useState)(!1),i=(0,z.useId)(),a=(0,z.useRef)(null),o=(0,z.useRef)(null);(0,z.useEffect)(()=>{n&&o.current?.querySelector(`button:not(:disabled)`)?.focus()},[n]);let s=e=>{r(!1),t(e)},u=(e,t)=>e===t?String(e+1):`${e+1}–${t+1}`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(c,{ref:a,className:`live-table-trigger`,size:`sm`,variant:`ghost`,icon:ye,"aria-expanded":n,"aria-controls":i,onPointerDown:e=>e.preventDefault(),onClick:()=>r(e=>!e),onKeyDown:e=>{e.key===`Escape`&&n&&(e.preventDefault(),e.stopPropagation(),r(!1))},children:[`Table`,n?(0,$.jsx)(f,{className:`ui-button-icon`,"aria-hidden":`true`}):(0,$.jsx)(x,{className:`ui-button-icon`,"aria-hidden":`true`})]}),n&&(0,$.jsxs)(`fieldset`,{ref:o,id:i,className:`live-table-panel`,"aria-label":`Table actions`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),r(!1),a.current?.focus())},children:[(0,$.jsxs)(`fieldset`,{className:`live-table-group`,"aria-label":`Row actions`,children:[(0,$.jsx)(`strong`,{children:e.row===0&&e.lastRow===0?`Header row`:`Row ${u(e.row,e.lastRow)}`}),(0,$.jsx)(c,{icon:re,size:`sm`,variant:`ghost`,"aria-label":`Insert row above`,disabled:e.row===0,title:e.row===0?`The header stays first. Insert a row below it.`:void 0,onClick:()=>s(`row-before`),children:`Above`}),(0,$.jsx)(c,{icon:y,size:`sm`,variant:`ghost`,"aria-label":`Insert row below`,onClick:()=>s(`row-after`),children:`Below`}),(0,$.jsx)(l,{icon:S,size:`sm`,label:`Delete row`,disabled:!e.canDeleteRow,title:e.canDeleteRow?`Delete row`:`Keep the header and one content row. You can delete the whole table.`,onClick:()=>s(`delete-row`)})]}),(0,$.jsxs)(`fieldset`,{className:`live-table-group`,"aria-label":`Column actions`,children:[(0,$.jsxs)(`strong`,{children:[`Column `,u(e.column,e.lastColumn)]}),(0,$.jsx)(c,{icon:b,size:`sm`,variant:`ghost`,"aria-label":`Insert column left`,onClick:()=>s(`column-before`),children:`Left`}),(0,$.jsx)(c,{icon:te,size:`sm`,variant:`ghost`,"aria-label":`Insert column right`,onClick:()=>s(`column-after`),children:`Right`}),(0,$.jsx)(l,{icon:S,size:`sm`,label:`Delete column`,disabled:!e.canDeleteColumn,title:e.canDeleteColumn?`Delete column`:`Keep one column, or delete the whole table.`,onClick:()=>s(`delete-column`)})]}),(0,$.jsxs)(`fieldset`,{className:`live-table-group`,"aria-label":`Column alignment`,children:[(0,$.jsx)(`strong`,{children:`Align column`}),[{alignment:`left`,icon:Te},{alignment:`center`,icon:xe},{alignment:`right`,icon:Ce}].map(({alignment:t,icon:n})=>(0,$.jsx)(l,{icon:n,size:`sm`,label:`Align column ${t}`,"aria-pressed":e.alignment===t,onClick:()=>s(t)},t))]}),(0,$.jsxs)(`div`,{className:`live-table-footer`,children:[(0,$.jsx)(`span`,{className:`side-note`,children:`Tab moves between cells. Undo restores deletions.`}),(0,$.jsx)(c,{size:`sm`,variant:`ghost`,icon:S,className:`live-context-cancel`,onClick:()=>s(`delete-table`),children:`Delete table`})]})]})]})}function Z6(e){let[t]=(0,z.useState)(()=>g(e.target,e.draft.body)),n=e.elements[0],r=(0,z.useRef)(new Map(e.elements.map(e=>[e,e.innerHTML]))),[i,a]=(0,z.useState)({bold:!1,italic:!1,strike:!1,link:!1,bullet:!1,ordered:!1,quote:!1,style:`0`}),[c,u]=(0,z.useState)(null),f=e=>{let t=q6(e);u(e=>JSON.stringify(e)===JSON.stringify(t)?e:t);let n=U6(e);a(e=>Object.keys(n).every(t=>e[t]===n[t])?e:n)},[m,h]=(0,z.useState)(null),y=(0,z.useRef)(null);(0,z.useEffect)(()=>{m!==null&&y.current?.focus()},[m]);let b=(0,z.useRef)(null),x=d({...e,toolbar:!0},p(b)),{engine:S,text:ee,changed:te,ready:ne,error:re}=H6(e,t,f),C=e=>{let t=S.current;t&&(e(t),t.action(e=>e.get(rg).focus()))};return(0,$.jsxs)(`fieldset`,{ref:b,className:`live-context live-context--markdown`,"aria-label":`Editing ${v(e.target)}`,style:{top:x.top,left:x.left,width:x.width??void 0},onKeyDown:t=>{t.key===`Escape`&&(t.preventDefault(),e.onClose())},children:[(0,$.jsx)(`strong`,{children:v(e.target)}),c&&ne&&(0,$.jsx)(X6,{table:c,onAction:e=>C(t=>Y6(t,e))},c.position),re?(0,$.jsx)(`span`,{role:`alert`,children:re}):(0,$.jsx)(G6,{formatting:i,table:c,ready:ne,run:C,setLink:h}),m!==null&&(0,$.jsx)(K6,{link:m,input:y,setLink:h,run:C}),(0,$.jsxs)(`div`,{className:`live-context-actions`,children:[(0,$.jsx)(l,{icon:s,label:`Cancel this element’s edit`,className:`live-context-cancel`,size:`sm`,onPointerDown:e=>e.preventDefault(),onClick:()=>{if(t){ee.current=t.text,e.onBody(_(t,t.text)),te.current=!1;for(let[e,t]of r.current)e!==n&&(e.innerHTML=t)}e.onClose()}}),(0,$.jsx)(l,{icon:o,label:`Done editing`,className:`live-context-done`,size:`sm`,onPointerDown:e=>e.preventDefault(),onClick:e.onClose})]})]})}export{Z6 as LiveMarkdownEditor};