inlaycms 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +330 -1
  2. package/assets/admin/admin.css +1 -1
  3. package/assets/admin/admin.js +1 -1
  4. package/assets/admin/editor.js +59 -44
  5. package/dist/adapters/admin/screens/redirects.js +12 -3
  6. package/dist/adapters/admin/views/layout.js +27 -7
  7. package/dist/adapters/cli/remote.js +9 -1
  8. package/dist/adapters/mcp/tools/redirects.js +16 -2
  9. package/dist/adapters/site/assets.d.ts +11 -0
  10. package/dist/adapters/site/assets.js +71 -0
  11. package/dist/adapters/site/cache.d.ts +2 -1
  12. package/dist/adapters/site/cache.js +6 -1
  13. package/dist/adapters/site/context.d.ts +6 -0
  14. package/dist/adapters/site/context.js +38 -13
  15. package/dist/adapters/site/head.d.ts +30 -7
  16. package/dist/adapters/site/head.js +145 -20
  17. package/dist/adapters/site/headers.d.ts +5 -0
  18. package/dist/adapters/site/headers.js +31 -0
  19. package/dist/adapters/site/plugin.d.ts +2 -0
  20. package/dist/adapters/site/plugin.js +32 -9
  21. package/dist/adapters/site/public.js +7 -24
  22. package/dist/adapters/site/render.d.ts +5 -0
  23. package/dist/adapters/site/render.js +23 -8
  24. package/dist/adapters/site/routes.d.ts +6 -0
  25. package/dist/adapters/site/routes.js +8 -3
  26. package/dist/adapters/site/seo.d.ts +20 -0
  27. package/dist/adapters/site/seo.js +45 -0
  28. package/dist/adapters/site/sitemap.d.ts +1 -1
  29. package/dist/adapters/site/sitemap.js +1 -1
  30. package/dist/config.js +3 -2
  31. package/dist/core/agent/format.js +1 -1
  32. package/dist/core/agent/schema.js +3 -0
  33. package/dist/core/boot.js +7 -0
  34. package/dist/core/check.js +6 -1
  35. package/dist/core/content/dry-run.d.ts +7 -6
  36. package/dist/core/content/dry-run.js +8 -8
  37. package/dist/core/content/publish.d.ts +1 -1
  38. package/dist/core/content/publish.js +5 -3
  39. package/dist/core/content/read.d.ts +3 -0
  40. package/dist/core/content/reader.js +3 -2
  41. package/dist/core/content/refs.js +1 -1
  42. package/dist/core/content/search.js +2 -2
  43. package/dist/core/content/shipped-images.d.ts +32 -0
  44. package/dist/core/content/shipped-images.js +62 -0
  45. package/dist/core/content/shipped-input.d.ts +9 -3
  46. package/dist/core/content/shipped-input.js +165 -28
  47. package/dist/core/content/shipped.js +8 -3
  48. package/dist/core/content/validate.js +7 -1
  49. package/dist/core/core.d.ts +5 -1
  50. package/dist/core/core.js +5 -4
  51. package/dist/core/db/connection.d.ts +6 -0
  52. package/dist/core/db/connection.js +13 -1
  53. package/dist/core/db/migrate.js +2 -0
  54. package/dist/core/db/migrations/0007_published_at.d.ts +3 -0
  55. package/dist/core/db/migrations/0007_published_at.js +16 -0
  56. package/dist/core/db/schema.d.ts +1 -0
  57. package/dist/core/export/export.js +3 -1
  58. package/dist/core/export/format.d.ts +8 -1
  59. package/dist/core/export/format.js +3 -2
  60. package/dist/core/export/read.js +7 -0
  61. package/dist/core/export/stage.d.ts +1 -1
  62. package/dist/core/export/stage.js +24 -1
  63. package/dist/core/fields/builtins.d.ts +28 -0
  64. package/dist/core/fields/builtins.js +103 -11
  65. package/dist/core/fields/define.d.ts +6 -0
  66. package/dist/core/fields/widgets.d.ts +7 -0
  67. package/dist/core/fields/widgets.js +76 -28
  68. package/dist/core/messages/en.d.ts +70 -6
  69. package/dist/core/messages/en.js +70 -6
  70. package/dist/core/redirects/collapse.d.ts +17 -1
  71. package/dist/core/redirects/collapse.js +19 -3
  72. package/dist/core/redirects/redirects.d.ts +13 -12
  73. package/dist/core/redirects/redirects.js +141 -53
  74. package/dist/core/redirects/rule.d.ts +25 -0
  75. package/dist/core/redirects/rule.js +55 -0
  76. package/dist/core/registry/define.d.ts +40 -0
  77. package/dist/core/registry/define.js +3 -0
  78. package/dist/core/registry/registry.d.ts +21 -0
  79. package/dist/core/registry/registry.js +114 -6
  80. package/dist/core/registry/render.d.ts +37 -1
  81. package/dist/core/registry/route.d.ts +4 -0
  82. package/dist/core/release/bundle.js +30 -5
  83. package/dist/core/release/manifest.d.ts +14 -0
  84. package/dist/core/release/manifest.js +42 -17
  85. package/dist/core/release/markdown-file.d.ts +21 -0
  86. package/dist/core/release/markdown-file.js +172 -0
  87. package/dist/core/release/pack.js +2 -2
  88. package/dist/core/release/read.js +4 -1
  89. package/dist/core/release/site-dir.d.ts +4 -0
  90. package/dist/core/release/site-dir.js +8 -0
  91. package/dist/core/report.d.ts +8 -2
  92. package/dist/core/richtext/html.d.ts +3 -1
  93. package/dist/core/richtext/html.js +16 -4
  94. package/dist/core/richtext/inline.d.ts +22 -0
  95. package/dist/core/richtext/inline.js +33 -0
  96. package/dist/core/richtext/markdown.d.ts +16 -1
  97. package/dist/core/richtext/markdown.js +137 -14
  98. package/dist/core/richtext/schema.d.ts +16 -4
  99. package/dist/core/richtext/schema.js +71 -1
  100. package/dist/core/site/live.d.ts +1 -0
  101. package/dist/core/site/live.js +1 -0
  102. package/dist/core/site/paths.d.ts +6 -0
  103. package/dist/core/site/paths.js +13 -0
  104. package/dist/core/site/resolve.d.ts +1 -1
  105. package/dist/core/site/resolve.js +119 -30
  106. package/dist/core/site/sitemap.d.ts +1 -1
  107. package/dist/core/site/sitemap.js +4 -0
  108. package/dist/core/types.d.ts +28 -3
  109. package/dist/host/app.d.ts +5 -0
  110. package/dist/host/app.js +8 -0
  111. package/dist/host/dev.js +3 -7
  112. package/dist/host/diff.d.ts +19 -1
  113. package/dist/host/diff.js +32 -2
  114. package/dist/index.d.ts +2 -2
  115. package/dist/markdown-modules.d.ts +8 -0
  116. package/dist/markdown-modules.js +1 -0
  117. package/dist/site.d.ts +8 -3
  118. package/dist/site.js +6 -0
  119. package/dist/testing.d.ts +22 -0
  120. package/dist/testing.js +155 -0
  121. package/package.json +6 -1
@@ -1,36 +1,36 @@
1
- var Mt="editor-form";async function js(n,e){try{let t=await n.json(),r=typeof t=="object"&&t!==null?t.message:void 0;return typeof r=="string"&&r!==""?r:e}catch{return e}}async function Mu(n,e,t){return n.type==="opaqueredirect"||n.status===401?{kind:"error",message:e}:n.status===200?{kind:"page",html:await n.text()}:n.status===422?{kind:"incomplete",message:await js(n,t)}:n.status===500?{kind:"error",message:await js(n,t)}:{kind:"error",message:t}}function vu(n){let e=new URLSearchParams;for(let[t,r]of new FormData(n))e.append(t,typeof r=="string"?r:r.name);return e}function Cu(n){let e,t=null,r=0;async function i(){e=void 0;let s=n.getForm();if(!s)return;t?.abort();let o=new AbortController;t=o;let l=++r;n.onStart();let a;try{let c=await n.fetch(n.url,{method:"POST",body:vu(s),redirect:"manual",credentials:"same-origin",signal:o.signal});a=await Mu(c,n.signedOutMessage,n.failedMessage)}catch{a={kind:"error",message:n.failedMessage}}l!==r||o.signal.aborted||(t=null,n.onResult(a))}return{schedule(){e!==void 0&&clearTimeout(e),e=setTimeout(()=>{i()},n.delay)},dispose(){e!==void 0&&clearTimeout(e),e=void 0,r++,t?.abort(),t=null}}}function Eu(n,e){try{return new URL(n.location.href).searchParams.get("n")===String(e)}catch{return!1}}function Tu(n){let e=0;function t(r){let i=++e,s=n.back(),o=()=>{if(i!==e){s.removeEventListener("load",o);return}let c=s.contentWindow,u=s.contentDocument;if(!c||!u||!Eu(c,i))return;s.removeEventListener("load",o),u.open(),c.history.replaceState(null,"",n.pagePath),u.write(r),u.close();let d=[...u.querySelectorAll('link[rel~="stylesheet"]')].filter(y=>y.sheet===null),f=d.length,h=!1,p,m=()=>{if(!h){h=!0,clearTimeout(p);for(let y of d)y.removeEventListener("load",g),y.removeEventListener("error",g);i===e&&n.onSwap()}},g=()=>{f--,f===0&&m()};if(f===0){m();return}for(let y of d)y.addEventListener("load",g),y.addEventListener("error",g);p=setTimeout(m,n.fallbackMs)};s.addEventListener("load",o);let l=`${n.blankUrl}${n.blankUrl.includes("?")?"&":"?"}n=${i}`,a=s.contentWindow;a?a.location.replace(l):s.src=l}return{write:t,cancel(){e++}}}var Au=/^inlay:slot (.+)$/,Nu=/^\/inlay:slot (.+)$/;function Gs(n){let e=new Map,t=n.createTreeWalker(n,128);for(let r=t.nextNode();r;r=t.nextNode()){let i=Au.exec(r.nodeValue??"")?.[1];if(i===void 0)continue;let s=e.get(i)??[];for(let o=r.nextSibling;o&&!(o.nodeType===8&&Nu.exec(o.nodeValue??"")?.[1]===i);o=o.nextSibling)o.nodeType===1&&s.push(o);e.set(i,s)}return e}function Ou(n,e){for(let[t,r]of Gs(n))if(r.some(i=>i.contains(e)))return t;return null}function Du(n,e){return!(e>0)||!(n>0)?1:Math.min(1,n/e)}var Bn=n=>n instanceof Element&&n.closest(`#${Mt}`)!==null;function Iu(n){let e=n.detail,t=n.target;return t instanceof Element&&t.id===Mt||e?.target instanceof Element&&e.target.id===Mt}var qr=!1;function Jr(){let n=document.getElementById("save-state"),e=n?.dataset.textUnsaved;if(!n||e===void 0||qr)return;qr=!0;let t=document.createElement("span");t.className="inline-block h-2 w-2 rounded-full bg-warning",t.setAttribute("aria-hidden","true");let r=document.createElement("span");r.className="inline-flex items-center gap-1.5",r.append(t,e),n.replaceChildren(r)}function Ru(n){let e=n.detail,t=e?.elt instanceof Element&&Bn(e.elt)||e?.target instanceof Element&&e.target.id===Mt,r=document.getElementById(Mt);if(!t||!r||!(e?.formData instanceof FormData))return;let i=[...r.querySelectorAll("details[data-item]")].filter(o=>o.open).map(o=>o.dataset.item??""),s=[...r.querySelectorAll("details[data-card]")].filter(o=>!o.open).map(o=>o.dataset.card??"");e.formData.set("_open",i.filter(o=>o!=="").join(",")),e.formData.set("_closed",s.filter(o=>o!=="").join(","))}var zn=()=>{};document.addEventListener("input",n=>{Bn(n.target)&&(Jr(),zn())});document.addEventListener("change",n=>{Bn(n.target)&&(Jr(),zn())});document.addEventListener("htmx:afterSwap",n=>{Iu(n)&&(Jr(),zn())});document.addEventListener("htmx:configRequest",Ru);document.addEventListener("inlay:saved",()=>{qr=!1});var Xs={desktop:1280,tablet:768,phone:390},Ws=n=>n!=null&&Object.hasOwn(Xs,n),jr="inlay.preview.device",Ks="inlay.preview.hidden",qs="inlay-preview-highlight",Wr="opacity-60";function Kr(n){try{return localStorage.getItem(n)}catch{return null}}function Js(n,e){try{localStorage.setItem(n,e)}catch{}}var _s=()=>window.matchMedia?.("(width < 64rem)").matches===!0,Pu=['input:not([type="hidden"]):not([disabled])',"textarea:not([disabled])","select:not([disabled])",'[contenteditable="true"]',"button:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");function Lu(n){let{pane:e,workspace:t,stage:r,device:i,first:s,status:o,announce:l,scaleText:a,hideButton:c,showButton:u}=n,d=s.dataset.previewUrl??s.getAttribute("src")??"",f=s.dataset.pagePath??"/",h={updating:o.dataset.textUpdating??"",ready:o.dataset.textReady??"",signedOut:o.dataset.textSignedOut??"",failed:o.dataset.textFailed??""},p=s.dataset.blankUrl??`${d}/blank`,m=s,g=s.cloneNode(!1);g.removeAttribute("id"),g.setAttribute("aria-hidden","true"),g.tabIndex=-1,g.style.visibility="hidden",g.src=p;let y=g,x=null,w=Ws(Kr(jr))?Kr(jr):"desktop",v=!1,I=S=>{o.textContent=S,o.title=S},H=S=>{I(S),l&&(l.textContent=S)};function A(S){let O=m.contentDocument;if(!O||(O.getElementById(qs)?.remove(),x===null))return;let F=Gs(O).get(x)??[],$e=O.defaultView;if(F.length===0||!$e)return;let pe=1/0,Fe=1/0,Vr=-1/0,Hr=-1/0;for(let wu of F){let Ln=wu.getBoundingClientRect();pe=Math.min(pe,Ln.top),Fe=Math.min(Fe,Ln.left),Vr=Math.max(Vr,Ln.right),Hr=Math.max(Hr,Ln.bottom)}let Pn=O.createElement("div");Pn.id=qs,Pn.setAttribute("aria-hidden","true"),Object.assign(Pn.style,{position:"absolute",top:`${pe+$e.scrollY-4}px`,left:`${Fe+$e.scrollX-4}px`,width:`${Vr-Fe+8}px`,height:`${Hr-pe+8}px`,outline:"3px solid #1d4ed8",borderRadius:"4px",pointerEvents:"none",zIndex:"2147483647",margin:"0"}),O.documentElement.append(Pn),S&&F[0]?.scrollIntoView({block:"nearest"})}function R(S){let O=S!==x;x=S;for(let F of document.querySelectorAll("details[data-card]"))F.classList.toggle("is-active",S!==null&&F.dataset.card===S);A(O)}function z(S){let O=[...document.querySelectorAll("details[data-card]")].find(pe=>pe.dataset.card===S);if(!O)return;O.open=!0,_s()&&en("edit"),O.scrollIntoView({block:"start",behavior:"smooth"}),(O.querySelector(":scope > :not(summary)")??O).querySelector(Pu)?.focus({preventScroll:!0}),R(S)}function $(S){S.onclick=O=>{O.preventDefault();let F=O.target===null?null:Ou(S,O.target);F!==null&&z(F)},S.onsubmit=O=>O.preventDefault()}document.addEventListener("focusin",S=>{if(!Bn(S.target))return;let F=S.target.closest("details[data-card]")?.dataset.card;R(F===void 0||F==="fields"?null:F)});function xe(){he=!0;let S=y;S.contentWindow?.scrollTo(0,m.contentWindow?.scrollY??0),S.contentDocument&&$(S.contentDocument),S.style.visibility="",S.removeAttribute("aria-hidden"),S.removeAttribute("tabindex"),S.id="preview-frame",S.classList.remove(Wr),m.style.visibility="hidden",m.setAttribute("aria-hidden","true"),m.tabIndex=-1,m.removeAttribute("id"),m.classList.remove(Wr),y=m,m=S,A(!1),Xe||I(h.ready),l&&(l.textContent="")}let Ge=Tu({blankUrl:p,pagePath:f,back:()=>y,onSwap:xe,fallbackMs:1e3});s.after(g);let Xe=!1;function fe(S){if(Xe=!1,S.kind==="page"){Ge.write(S.html);return}Ge.cancel(),S.kind==="incomplete"&&m.classList.add(Wr),H(S.message)}let Ee=new URL(d,location.href).pathname,he=!1;function Ye(){if(he)return;let S=s.contentWindow,O=s.contentDocument;if(he=!0,!S||!O){H(h.failed);return}if(S.location.pathname!==Ee){O.open(),O.write("<!doctype html><title></title>"),O.close(),H(h.signedOut);return}S.history.replaceState(null,"",f),$(O),A(!1),I(h.ready)}s.contentDocument?.readyState==="complete"&&s.contentWindow?.location.href!=="about:blank"?Ye():s.addEventListener("load",Ye,{once:!0});let Yt=Cu({url:d,getForm:()=>{let S=document.getElementById(Mt);return S instanceof HTMLFormElement?S:null},delay:400,fetch:(...S)=>window.fetch(...S),signedOutMessage:h.signedOut,failedMessage:h.failed,onStart:()=>{Xe=!0,I(h.updating)},onResult:fe}),In=()=>t.classList.contains("no-preview")&&!_s();zn=()=>{In()?v=!0:Yt.schedule()};let Zt=()=>{v&&(v=!1,Yt.schedule())};function xt(){let S=getComputedStyle(r),O=r.clientWidth-parseFloat(S.paddingLeft||"0")-parseFloat(S.paddingRight||"0"),F=r.clientHeight-parseFloat(S.paddingTop||"0")-parseFloat(S.paddingBottom||"0");if(O<=0||F<=0)return;let $e=Xs[w],pe=Du(O,$e);for(let Fe of[m,y])Fe.style.width=`${$e}px`,Fe.style.height=`${F/pe}px`,Fe.style.transform=`scale(${pe})`;i.style.width=`${$e*pe}px`,i.style.height=`${F}px`,a&&(a.textContent=pe<1?`${Math.round(pe*100)}%`:""),requestAnimationFrame(()=>A(!1))}let Rn=[...e.querySelectorAll("button[data-device]")];function Ze(S){w=S;for(let O of Rn){let F=O.dataset.device===S;O.setAttribute("aria-pressed",String(F)),O.classList.toggle("btn-active",F)}xt()}for(let S of Rn)S.addEventListener("click",()=>{let O=S.dataset.device;Ws(O)&&(Js(jr,O),Ze(O))});typeof ResizeObserver=="function"&&new ResizeObserver(()=>xt()).observe(r);function wt(S,O){t.classList.toggle("no-preview",S),u&&(u.hidden=!S),Js(Ks,S?"1":"0"),O&&(S?u:c)?.focus(),S||(xt(),Zt())}c?.addEventListener("click",()=>wt(!0,!0)),u?.addEventListener("click",()=>wt(!1,!0));let Qt=[...document.querySelectorAll("[data-view-btn]")];function en(S){t.dataset.view=S;for(let O of Qt){let F=O.dataset.viewBtn===S;O.setAttribute("aria-pressed",String(F)),O.classList.toggle("btn-active",F)}S==="preview"&&(requestAnimationFrame(xt),Zt())}for(let S of Qt)S.addEventListener("click",()=>en(S.dataset.viewBtn??"edit"));Kr(Ks)==="1"&&wt(!0,!1),en(t.dataset.view??"edit"),Ze(w)}function Us(){let n=document.getElementById("preview-pane"),e=document.getElementById("workspace"),t=document.getElementById("preview-stage"),r=document.getElementById("preview-device"),i=document.getElementById("preview-frame"),s=document.getElementById("preview-status");!n||!e||!t||!r||!(i instanceof HTMLIFrameElement)||!s||Lu({pane:n,workspace:e,stage:t,device:r,first:i,status:s,announce:document.getElementById("preview-announce"),scaleText:document.getElementById("preview-scale"),hideButton:document.getElementById("preview-hide"),showButton:document.getElementById("preview-show")})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Us):Us();var Ys=Object.defineProperty,Zs=(n,e)=>{let t={};for(var r in n)Ys(t,r,{get:n[r],enumerable:!0});return e||Ys(t,Symbol.toStringTag,{value:"Module"}),t};function te(n){this.content=n}te.prototype={constructor:te,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new te(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new te(t)},addToStart:function(n,e){return new te([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new te(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new te(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=te.from(n),n.size?new te(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=te.from(n),n.size?new te(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=te.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};te.from=function(n){if(n instanceof te)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new te(e)};var _r=te;function co(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){let o=i.text,l=s.text,a=0;for(;o[a]==l[a];a++)t++;return a&&a<o.length&&a<l.length&&ho(o.charCodeAt(a-1))&&fo(o.charCodeAt(a))&&t--,t}if(i.content.size||s.content.size){let o=co(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function uo(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=o.text,u=l.text,d=c.length,f=u.length;for(;d>0&&f>0&&c[d-1]==u[f-1];)d--,f--,t--,r--;return d&&f&&d<c.length&&ho(c.charCodeAt(d-1))&&fo(c.charCodeAt(d))&&(t++,r++),{a:t,b:r}}if(o.content.size||l.content.size){let c=uo(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function fo(n){return n>=56320&&n<57344}function ho(n){return n>=55296&&n<56320}var b=class n{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new n(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new n(r,i)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new n(i,s)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.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 new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return co(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return uo(this,e,t,r)}findIndex(e){if(e==0)return $n(0,e);if(e==this.size)return $n(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?$n(t+1,s):$n(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return n.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new n(t||e,r)}static from(e){if(!e)return n.empty;if(e instanceof n)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new n([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};b.empty=new b([],0);var Ur={index:0,offset:0};function $n(n,e){return Ur.index=n,Ur.offset=e,Ur}function Hn(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Hn(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Hn(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}var D=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||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&&Hn(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 new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};D.none=[];var Ve=class extends Error{},k=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=mo(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(po(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return n.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(b.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new n(e,r,i)}};k.empty=new k(b.empty,0,0);function po(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(po(s.content,e-i-1,t-i-1)))}function mo(n,e,t,r,i,s){let{index:o,offset:l}=n.findIndex(e),a=n.maybeChild(o);if(l==e||a.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=mo(a.content,e-l-1,t,o==0?r-1:0,o==n.childCount-1?i-1:0,a);return c&&n.replaceChild(o,a.copy(c))}function Bu(n,e,t){if(t.openStart>n.depth)throw new Ve("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Ve("Inconsistent open depths");return go(n,e,t,0)}function go(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=go(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return et(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=zu(t,n);return et(s,bo(n,o,l,e,r))}else return et(s,jn(n,e,r))}function yo(n,e){if(!e.type.compatibleContent(n.type))throw new Ve("Cannot join "+e.type.name+" onto "+n.type.name)}function Gr(n,e,t){let r=n.node(t);return yo(r,e.node(t)),r}function Qe(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function tn(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Qe(n.nodeAfter,r),s++));for(let l=s;l<o;l++)Qe(i.child(l),r);e&&e.depth==t&&e.textOffset&&Qe(e.nodeBefore,r)}function et(n,e){if(!n.type.validContent(e))throw new Ve("Invalid content for node "+n.type.name);return n.copy(e)}function bo(n,e,t,r,i){let s=n.depth>i&&Gr(n,e,i+1),o=r.depth>i&&Gr(t,r,i+1),l=[];return tn(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(yo(s,o),Qe(et(s,bo(n,e,t,r,i+1)),l)):(s&&Qe(et(s,jn(n,e,i+1)),l),tn(e,t,i,l),o&&Qe(et(o,jn(t,r,i+1)),l)),tn(r,null,i,l),new b(l)}function jn(n,e,t){let r=[];if(tn(null,n,t,r),n.depth>t){let i=Gr(n,e,t+1);Qe(et(i,jn(n,e,t+1)),r)}return tn(e,null,t,r),new b(r)}function zu(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(b.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}var Wn=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,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 new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}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 r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return D.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}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 r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new tt(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new n(t,r,s)}static resolveCached(e,t){let r=Qs.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==t)return o}else Qs.set(e,r=new Xr);let i=r.elts[r.i]=n.resolve(e,t);return r.i=(r.i+1)%$u,i}},Xr=class{constructor(){this.elts=[],this.i=0}},$u=12,Qs=new WeakMap,tt=class{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Fu=Object.create(null),be=class n{constructor(e,t,r,i=D.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||b.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,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Hn(this.attrs,t||e.defaultAttrs||Fu)&&D.sameSet(this.marks,r||D.none)}copy(e=null){return e==this.content?this:new n(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.content,e)}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,r=!1){if(e==t)return k.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new k(c,i.depth-o,s.depth-o)}replace(e,t,r){return Bu(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Wn.resolveCached(this,e)}resolveNoCache(e){return Wn.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),ko(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=b.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);return o?o.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),eo(this.type.attrs,this.attrs,"node",this.type.name);let e=D.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];eo(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!D.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.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(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=b.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,r)}};be.prototype.text=void 0;var Yr=class n extends be{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ko(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(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 ko(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}function eo(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${r}`);for(let i in n)n[i].validate&&n[i].validate(e[i])}var nt=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Zr(e,t);if(r.next==null)return n.empty;let i=So(r);r.next&&r.err("Unexpected trailing text");let s=Ju(qu(i));return _u(s,r),s}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,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type: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 r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return b.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let f=s(d,l.concat(u));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
2
- `)}};nt.empty=new nt(!0);var Zr=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 new SyntaxError(e+" (in content expression '"+this.string+"')")}};function So(n){let e=[];do e.push(Vu(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Vu(n){let e=[];do e.push(Hu(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Hu(n){let e=Ku(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=ju(n,e);else break;return e}function to(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function ju(n,e){let t=to(n),r=t;return n.eat(",")&&(n.next!="}"?r=to(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Wu(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function Ku(n){if(n.eat("(")){let e=So(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Wu(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function qu(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=t();i(s(o.expr,a),u),a=u}if(o.max==-1)i(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=t();r(a,u),i(s(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function xo(n,e){return e-n}function no(n,e){let t=[];return r(e),t.sort(xo);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&r(a)}}}function Ju(n){let e=Object.create(null);return t(no(n,0));function t(r){let i=[];r.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);no(n,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new nt(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(xo);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function _u(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function wo(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Mo(n,e){let t=Object.create(null);for(let r in n){let i=n[r],s=e&&e[r];if(s===void 0)if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r);else i.validate&&i.validate(s);t[r]=s}return t}function vo(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Qr(n,r,e[r]);return t}var Ct=class n{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=vo(e,r.attrs),this.defaultAttrs=wo(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==nt.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:Mo(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new be(this,this.computeAttrs(e),b.from(t),D.setFrom(r))}createChecked(e=null,t,r){return t=b.from(t),this.checkContent(t),new be(this,this.computeAttrs(e),t,D.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=b.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(b.empty,!0);return s?new be(this,e,t.append(s),D.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let 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 r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:D.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,o)=>r[s]=new n(s,t,o));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Uu(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}var Qr=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Uu(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},rn=class n{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=vo(e,i.attrs),this.excluded=null;let s=wo(this.attrs);this.instance=s?new D(this,s):null}create(e=null){return!e&&this.instance?this.instance:new D(this,Mo(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new n(s,i++,t,o)),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}},rt=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=_r.from(e.nodes),t.marks=_r.from(e.marks||{}),this.nodes=Ct.compile(this.spec.nodes,this),this.marks=rn.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=nt.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?ro(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:ro(this,o.split(" "))}this.nodeFromJSON=i=>be.fromJSON(this,i),this.markFromJSON=i=>D.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Ct){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Yr(r,r.defaultAttrs,e,D.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 new RangeError("Unknown node type: "+e);return t}};function ro(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],o=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Gu(n){return n.tag!=null}function Xu(n){return n.style!=null}var Te=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(Gu(i))this.tags.push(i);else if(Xu(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Kn(this,t,!1);return r.addAll(e,D.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Kn(this,t,!0);return r.addAll(e,D.none,t.from,t.to),k.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(Qu(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=so(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=so(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Co={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},Yu={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Eo={ol:!0,ul:!0},sn=1,ei=2,nn=4;function io(n,e,t){return e!=null?(e?sn:0)|(e==="full"?ei:0):n&&n.whitespace=="pre"?sn|ei:t&~nn}var vt=class{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=D.none,this.match=s||(o&nn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(b.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&sn)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=b.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(b.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&&!Co.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Kn=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=io(null,t.preserveWhitespace,0)|(r?nn:0);i?s=new vt(i.type,i.attrs,D.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new vt(null,null,D.none,!0,null,o):s=new vt(e.schema.topNodeType,null,D.none,!0,null,o),this.nodes=[s],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 r=e.nodeValue,i=this.top,s=i.options&ei?"full":this.localPreserveWS||(i.options&sn)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
3
- `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Eo.hasOwnProperty(o)&&this.parser.normalizeLists&&Zu(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Yu.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Co.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(s),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
- `),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 r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=D.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):oo(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,r,i){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,i)),s}enterInner(e,t,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=io(e,s,o.options);o.options&nn&&o.content.length==0&&(l|=nn);let a=D.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):oo(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new vt(e,t,a,i,null,l)),this.open++,r}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;this.localPreserveWS&&(this.nodes[t].options|=sn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].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,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].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("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function Zu(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Eo.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Qu(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function so(n){let e={};for(let t in n)e[t]=n[t];return e}function oo(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&o(u))return!0}};if(o(i.contentMatch))return!0}}var Ae=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Fn(t).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,t);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){if(e.isText)return Fn(t).createTextNode(e.text);let{dom:r,contentDOM:i}=Vn(Fn(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&Vn(Fn(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:Vn(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=lo(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return lo(e.marks)}};function lo(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Fn(n){return n.document||window.document}var ao=new WeakMap;function ed(n){let e=ao.get(n);return e===void 0&&ao.set(n,e=td(n)),e}function td(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function Vn(n,e,t,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=ed(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(n.createTextNode(f));else{let{dom:h,contentDOM:p}=Vn(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var Do=65535,Io=Math.pow(2,16);function nd(n,e){return n+e*Io}function To(n){return n&Do}function rd(n){return(n-(n&Do))/Io}var Ro=1,Po=2,qn=4,Lo=8,an=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Lo)>0}get deletedBefore(){return(this.delInfo&(Ro|qn))>0}get deletedAfter(){return(this.delInfo&(Po|qn))>0}get deletedAcross(){return(this.delInfo&qn)>0}},Ne=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=To(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+rd(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+i+(f<0?0:u);if(r)return h;let p=e==(t<0?a:d)?null:nd(l/3,e-a),m=0;return c&&(m|=e==a?Po:e==d?Ro:qn,(t<0?e!=a:e!=d)&&(m|=Lo)),new an(h,m,p)}i+=u-c}return r?e+i:new an(e+i,0,null)}touches(e,t){let r=0,i=To(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],u=this.ranges[i+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?n.empty:new n(e<0?[0,-e,0]:[0,0,e])}};Ne.empty=new Ne([]);var cn=class n{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new n(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i: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=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new an(e,i,null)}},ti=Object.create(null),j=class{getMap(){return Ne.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ti[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in ti)throw new RangeError("Duplicate use of step JSON ID "+e);return ti[e]=t,t.prototype.jsonID=e,t}},X=class n{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new n(e,null)}static fail(e){return new n(null,e)}static fromReplace(e,t,r,i){try{return n.ok(e.replace(t,r,i))}catch(s){if(s instanceof Ve)return n.fail(s.message);throw s}}};function si(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(si(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return b.fromArray(r)}var un=class n extends j{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new k(si(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return X.fromReplace(e,this.from,this.to,s)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,i)=>{if(r.isInline&&r.isAtom){let s=this.mark.addToSet(r.marks);if(!D.sameSet(s,r.marks)){let o=Math.max(this.from,i),l=Math.min(this.to,i+r.nodeSize);Jn(He,o,l,this.mark,t);for(let a of r.marks)a.isInSet(s)||Jn(n,o,l,a,t)}}}),t.length==1?t[0]:new dn(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};j.jsonID("addMark",un);var He=class n extends j{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new k(si(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return X.fromReplace(e,this.from,this.to,r)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,i)=>{r.isInline&&r.isAtom&&this.mark.isInSet(r.marks)&&Jn(un,Math.max(this.from,i),Math.min(this.to,i+r.nodeSize),this.mark,t)}),t.length==1?t[0]:new dn(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};j.jsonID("removeMark",He);function Jn(n,e,t,r,i){let s=i.length?i[i.length-1]:null;s&&s instanceof n&&s.to==e&&s.mark.eq(r)?i[i.length-1]=new n(s.from,t,r):i.push(new n(e,t,r))}var dn=class n extends j{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let r=t.apply(e);if(!r.doc)return r;e=r.doc}return new X(e,null)}invert(e){return new n(this.steps.map(t=>t.invert(e)))}map(e){let t=[];for(let r of this.steps){let i=r.map(e);i&&t.push(i)}return t.length?new n(t):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,t){if(!Array.isArray(t.steps)||!t.steps.every(r=>r.stepType=="addMark"||r.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new n(t.steps.map(r=>j.fromJSON(e,r)))}};j.jsonID("markSet",dn);var fn=class n extends j{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return X.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return X.fromReplace(e,this.pos,this.pos+1,new k(b.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new n(this.pos,t.marks[i]);return new n(this.pos,this.mark)}}return new Et(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};j.jsonID("addNodeMark",fn);var Et=class n extends j{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return X.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return X.fromReplace(e,this.pos,this.pos+1,new k(b.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new fn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};j.jsonID("removeNodeMark",Et);var Y=class n extends j{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&ri(e,this.from,this.to)?X.fail("Structure replace would overwrite content"):X.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ne([this.from,this.to-this.from,this.slice.size])}invert(e){return new n(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&n.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new n(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof n)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?k.empty:new k(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new n(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?k.empty:new k(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new n(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new n(t.from,t.to,k.fromJSON(e,t.slice),!!t.structure)}};Y.MAP_BIAS=1;j.jsonID("replace",Y);var K=class n extends j{constructor(e,t,r,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(ri(e,this.from,this.gapFrom)||ri(e,this.gapTo,this.to)))return X.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return X.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?X.fromReplace(e,this.from,this.to,r):X.fail("Content does not fit in gap")}getMap(){return new Ne([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new n(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new n(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}};j.jsonID("replaceAround",K);function ri(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function id(n,e,t,r){let i=[];n.doc.nodesBetween(e,t,(s,o,l)=>{if(!s.isInline)return;let a=s.marks;if(!r.isInSet(a)&&l.type.allowsMarkType(r.type)){let c=Math.max(o,e),u=Math.min(o+s.nodeSize,t);Jn(un,c,u,r,i)}}),i.forEach(s=>n.step(s))}function sd(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline||!o.isAtom)return;s++;let a=null;if(r instanceof rn){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&d.eq(i[h].style)&&(f=p)}f?(f.to=c,f.step=s):i.push({style:d,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>n.step(new He(o.from,o.to,o.style)))}function oi(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new Y(l,u,k.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new He(l,u,c.marks[f]));if(i&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new k(b.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new Y(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(b.empty,!0);n.replace(l,l,new k(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function od(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Oe(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,s=0;;--r){let o=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-s;if(r<n.depth&&o.canReplace(l,a,t))return r;if(r==0||o.type.spec.isolating||!od(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function ld(n,e,t){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),a=o,c=l,u=b.empty,d=0;for(let p=s,m=!1;p>t;p--)m||r.index(p)>0?(m=!0,u=b.from(r.node(p).copy(u)),d++):a--;let f=b.empty,h=0;for(let p=s,m=!1;p>t;p--)m||i.after(p+1)<i.end(p)?(m=!0,f=b.from(i.node(p).copy(f)),h++):c++;n.step(new K(a,c,o,l,new k(u.append(f),d,h),u.size-d,!0))}function Nt(n,e,t=null,r=n){let i=ad(n,e),s=i&&cd(r,e);return s?i.map(Ao).concat({type:e,attrs:t}).concat(s.map(Ao)):null}function Ao(n){return{type:n,attrs:null}}function ad(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(r,i,o)?s:null}function cd(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function ud(n,e,t){let r=b.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=b.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new K(i,s,i,s,new k(r,0,0),t.length,!0))}function dd(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,a)&&fd(n.doc,n.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&zo(n,o,l,s),oi(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),d=u.map(l,1),f=u.map(l+o.nodeSize,1);return n.step(new K(d,f,d+1,f-1,new k(b.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&Bo(n,o,l,s),!1}})}function Bo(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function zo(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
5
- `))}})}function fd(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function hd(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new K(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new k(b.from(o),0,0),1,!0))}function me(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,o=r&&r[r.length-1]||i.parent;if(s<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 c=i.depth-1,u=t-2;c>s;c--,u--){let d=i.node(c),f=i.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function pd(n,e,t=1,r){let i=n.doc.resolve(e),s=b.empty,o=b.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=b.from(i.node(l).copy(s));let u=r&&r[c];o=b.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}n.step(new Y(e,e,new k(s.append(o),t,t),!0))}function ke(n,e){let t=n.resolve(e),r=t.index();return $o(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function md(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function $o(n,e){return!!(n&&e&&!n.isLeaf&&md(n,e))}function Ot(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):t>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&$o(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function gd(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(i);u&&!d?r=!1:!u&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);zo(n,u.node(),u.before(),l)}o.inlineContent&&oi(n,e+t-1,o,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new Y(c,a.map(e+t,-1),k.empty,!0)),r===!0){let u=n.doc.resolve(c);Bo(n,u.node(),u.before(),n.steps.length)}return n}function yd(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function Gn(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(s==1)u=c.canReplace(a,a,i);else{let d=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function hn(n,e,t=e,r=k.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return Fo(i,s,r)?new Y(e,t,r):new ii(i,s,r).fit()}function Fo(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var ii=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=b.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=b.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new k(s,o,l);return e>-1?new K(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Y(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=No(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(o?c.matchType(o.type)||(d=c.fillBefore(b.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:d};if(t==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced;return Oo(e,-1)<=t?!1:(this.unplaced.size>1&&Oo(e,1)>r&&r++,this.unplaced=new k(e,t+1,r),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=No(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new k(on(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new k(on(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[t];if(i){for(let m=0;m<i.childCount;m++)u.push(i.child(m));d=d.matchFragment(i)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let m=l.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(d=g,u.push(Vo(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=ln(this.placed,t,b.from(u)),this.frontier[t].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?k.empty:new k(on(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new k(on(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!ni(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:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=ni(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=ni(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:s?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=ln(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=ln(this.placed,this.depth,b.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(b.empty,!0);t.childCount&&(this.placed=ln(this.placed,this.frontier.length,t))}};function on(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(on(n.firstChild.content,e-1,t)))}function ln(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(ln(n.lastChild.content,e-1,t)))}function No(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Vo(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Vo(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(b.empty,!0)))),n.copy(r)}function ni(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!bd(t,s.content,o)?l:null}function bd(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function kd(n){return n.spec.defining||n.spec.definingForContent}function Oo(n,e){for(let t=0;;t++){let r=e<0?n.firstChild:n.lastChild;if(!r||r.isAtom)return t;n=r.content}}function Sd(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(Fo(i,s,r))return n.step(new Y(e,t,r));let o=jo(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let f=i.depth,h=i.pos-1;f>0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=kd(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],y=!0;g<0&&(y=!1,g=-g);let x=i.node(g-1),w=i.index(g-1);if(x.canReplaceWith(w,w,p.type,p.marks))return n.replace(i.before(g),y?s.after(g):t,new k(Ho(r.content,0,r.openStart,h),h,r.openEnd))}}let d=n.steps.length;for(let f=o.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let h=o[f];h<0||(e=i.before(h),t=s.after(h))}}function Ho(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(Ho(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(b.empty,!0))}return n}function xd(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=yd(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new k(b.from(r),0,0))}function wd(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let o=r.sharedDepth(t),l=!1;for(let a=r.depth;a>o;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>o;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=i.depth;a>0&&t==i.start(a);a--)t=i.before(a);r=n.doc.resolve(e),i=n.doc.resolve(t)}}let s=jo(r,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&i.end(o)-t!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function jo(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}var _n=class n extends j{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return X.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return X.fromReplace(e,this.pos,this.pos+1,new k(b.from(i),0,t.isLeaf?0:1))}getMap(){return Ne.empty}invert(e){return new n(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}};j.jsonID("attr",_n);var Un=class n extends j{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return X.ok(r)}getMap(){return Ne.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};j.jsonID("docAttr",Un);var Tt=class extends Error{};Tt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Tt.prototype=Object.create(Error.prototype);Tt.prototype.constructor=Tt;Tt.prototype.name="TransformError";var At=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new cn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Tt(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 r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((s,o,l,a)=>{e=Math.min(e,l),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,r=k.empty){let i=hn(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new k(b.from(r),0,0))}delete(e,t){return this.replace(e,t,k.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Sd(this,e,t,r),this}replaceRangeWith(e,t,r){return xd(this,e,t,r),this}deleteRange(e,t){return wd(this,e,t),this}lift(e,t){return ld(this,e,t),this}join(e,t=1){return gd(this,e,t),this}wrap(e,t){return ud(this,e,t),this}setBlockType(e,t=e,r,i=null){return dd(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return hd(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new _n(e,t,r)),this}setDocAttribute(e,t){return this.step(new Un(e,t)),this}addNodeMark(e,t){return this.step(new fn(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof D)t.isInSet(r.marks)&&this.step(new Et(e,t));else{let i=r.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new Et(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,r){return pd(this,e,t,r),this}addMark(e,t,r){return id(this,e,t,r),this}removeMark(e,t,r){return sd(this,e,t,r),this}clearIncompatible(e,t,r){return oi(this,e,t,r),this}};var li=Object.create(null),N=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Yn(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=k.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?k.empty:t),l==0&&qo(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),qo(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new C(e):Dt(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?Dt(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Dt(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new oe(e.node(0))}static atStart(e){return Dt(e,e,0,0,1)||new oe(e)}static atEnd(e){return Dt(e,e,e.content.size,e.childCount,-1)||new oe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=li[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in li)throw new RangeError("Duplicate use of selection JSON ID "+e);return li[e]=t,t.prototype.jsonID=e,t}getBookmark(){return C.between(this.$anchor,this.$head).getBookmark()}};N.prototype.visible=!0;var Yn=class{constructor(e,t){this.$from=e,this.$to=t}},Wo=!1;function Ko(n){!Wo&&!n.parent.inlineContent&&(Wo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var C=class n extends N{constructor(e,t=e){Ko(e),Ko(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return N.near(r);let i=e.resolve(t.map(this.anchor));return new n(i.parent.inlineContent?i:r,r)}replace(e,t=k.empty){if(super.replace(e,t),t==k.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Zn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=N.findFrom(t,r,!0)||N.findFrom(t,-r,!0);if(s)t=s.$head;else return N.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(N.findFrom(e,-r,!0)||N.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new n(e,t)}};N.jsonID("text",C);var Zn=class n{constructor(e,t){this.anchor=e,this.head=t}map(e){return new n(e.map(this.anchor),e.map(this.head))}resolve(e){return C.between(e.resolve(this.anchor),e.resolve(this.head))}},T=class n extends N{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?N.near(s):new n(s)}content(){return new k(b.from(this.node),0,0)}eq(e){return e instanceof n&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ci(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new n(e.resolve(t.anchor))}static create(e,t){return new n(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};T.prototype.visible=!1;N.jsonID("node",T);var ci=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Zn(r,r):new n(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&T.isSelectable(r)?new T(t):N.near(t)}},oe=class n extends N{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=k.empty){if(t==k.empty){e.delete(0,e.doc.content.size);let r=N.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new n(e)}map(e){return new n(e)}eq(e){return e instanceof n}getBookmark(){return Md}};N.jsonID("all",oe);var Md={map(){return this},resolve(n){return new oe(n)}};function Dt(n,e,t,r,i,s=!1){if(e.inlineContent)return C.create(n,t);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&T.isSelectable(l))return T.create(n,t-(i<0?l.nodeSize:0))}else{let a=Dt(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function qo(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof Y||i instanceof K))return;let s=n.mapping.maps[r],o;s.forEach((l,a,c,u)=>{o==null&&(o=u)}),n.setSelection(N.near(n.doc.resolve(o),t))}var Jo=1,Xn=2,_o=4,ui=class extends At{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Jo)&~Xn,this.storedMarks=null,this}get selectionSet(){return(this.updated&Jo)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Xn,this}ensureMarks(e){return D.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&Xn)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Xn,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||D.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(N.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|=_o,this}get scrolledIntoView(){return(this.updated&_o)>0}};function Uo(n,e){return!e||!n?n:n.bind(e)}var it=class{constructor(e,t,r){this.name=e,this.init=Uo(t.init,r),this.apply=Uo(t.apply,r)}},vd=[new it("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new it("selection",{init(n,e){return n.selection||N.atStart(e.doc)},apply(n){return n.selection}}),new it("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new it("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],pn=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=vd.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new it(r.key,r.spec.state,r))})}},st=class n{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 r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=i?i[o].n:0,c=i?i[o].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<o?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),s=!0}i&&(i[o]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new ui(this)}static create(e){let t=new pn(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new n(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new pn(this.schema,e.plugins),r=t.fields,i=new n(t);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new pn(e.schema,e.plugins),s=new n(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=be.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=N.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=c.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}};function Go(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Go(i,e,{})),t[r]=i}return t}var P=class{constructor(e){this.spec=e,this.props={},e.props&&Go(e.props,this,this.props),this.key=e.key?e.key.key:Xo("plugin")}getState(e){return e[this.key]}},ai=Object.create(null);function Xo(n){return n in ai?n+"$"+ ++ai[n]:(ai[n]=0,n+"$")}var W=class{constructor(e="key"){this.key=Xo(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Zo=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Qo(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var fi=(n,e,t)=>{let r=Qo(n,t);if(!r)return!1;let i=pi(r);if(!i){let o=r.blockRange(),l=o&&Oe(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(ol(n,i,e,-1))return!0;if(r.parent.content.size==0&&(It(s,"end")||T.isSelectable(s)))for(let o=r.depth;;o--){let l=hn(n.doc,r.before(o),r.after(o),k.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(It(s,"end")?N.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):T.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},Qn=(n,e,t)=>{let r=Qo(n,t);if(!r)return!1;let i=pi(r);return i?el(n,i,e):!1},er=(n,e,t)=>{let r=tl(n,t);if(!r)return!1;let i=yi(r);return i?el(n,i,e):!1};function el(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=hn(n.doc,s,a,k.empty);if(!c||c.from!=s||c instanceof Y&&c.slice.size>=a-s)return!1;if(t){let u=n.tr.step(c);u.setSelection(C.create(u.doc,s)),t(u.scrollIntoView())}return!0}function It(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}var hi=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=pi(r)}let o=s&&s.nodeBefore;return!o||!T.isSelectable(o)?!1:(e&&e(n.tr.setSelection(T.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function pi(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function tl(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}var mi=(n,e,t)=>{let r=tl(n,t);if(!r)return!1;let i=yi(r);if(!i)return!1;let s=i.nodeAfter;if(ol(n,i,e,1))return!0;if(r.parent.content.size==0&&(It(s,"start")||T.isSelectable(s))){let o=hn(n.doc,r.before(),r.after(),k.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(It(s,"start")?N.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):T.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},gi=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=yi(r)}let o=s&&s.nodeAfter;return!o||!T.isSelectable(o)?!1:(e&&e(n.tr.setSelection(T.create(n.doc,s.pos)).scrollIntoView()),!0)};function yi(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}var nl=(n,e)=>{let t=n.selection,r=t instanceof T,i;if(r){if(t.node.isTextblock||!ke(n.doc,t.from))return!1;i=t.from}else if(i=Ot(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(T.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},rl=(n,e)=>{let t=n.selection,r;if(t instanceof T){if(t.node.isTextblock||!ke(n.doc,t.to))return!1;r=t.to}else if(r=Ot(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},il=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&Oe(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},bi=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
6
- `).scrollIntoView()),!0)};function ki(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var Si=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=ki(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(N.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},xi=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof oe||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=ki(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(C.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},wi=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(me(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Oe(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Cd(n){return(e,t)=>{if(e.selection instanceof T&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!me(e.doc,h.pos)?!1:(t&&t(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof C||e.selection instanceof oe)&&r.deleteSelection();let{$from:i}=r.selection,s=r.steps.length,o=[],l,a,c=!1,u=!1;for(let h=i.depth;;h--)if(i.node(h).isBlock){c=i.end(h)==i.pos+(i.depth-h),u=i.start(h)==i.pos-(i.depth-h),a=ki(i.node(h-1).contentMatchAt(i.indexAfter(h-1)));let m=n&&n(i.parent,c,i);o.unshift(m||(c&&a?{type:a}:null)),l=h;break}else{if(h==1)return!1;o.unshift(null)}let d=i.pos,f=me(r.doc,d,o.length,o);if(f||(o[0]=a?{type:a}:null,f=me(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!c&&u&&i.node(l).type!=a){let h=r.mapping.slice(s),p=h.map(i.before(l)),m=r.doc.resolve(p);a&&i.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(h.map(i.before(l)),a)}return t&&t(r.scrollIntoView()),!0}}var Ed=Cd();var sl=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(T.create(n.doc,i))),!0)},Td=(n,e)=>(e&&e(n.tr.setSelection(new oe(n.doc))),!0);function Ad(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||ke(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function ol(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Ad(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=b.empty;for(let y=o.length-1;y>=0;y--)p=b.from(o[y].create(null,p));p=b.from(i.copy(p));let m=n.tr.step(new K(e.pos-1,h,e.pos,h,new k(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&ke(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:N.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Oe(d);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(d,f).scrollIntoView()),!0;if(c&&It(s,"start",!0)&&It(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let y=b.empty;for(let w=p.length-1;w>=0;w--)y=b.from(p[w].copy(y));let x=n.tr.step(new K(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new k(y,p.length,0),0,!0));t(x.scrollIntoView())}return!0}}return!1}function ll(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(C.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}var Mi=ll(-1),vi=ll(1);function al(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&Nt(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Ci(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function Ei(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}var di=Ei(Zo,fi,hi),Yo=Ei(Zo,mi,gi),je={Enter:Ei(bi,xi,wi,Ed),"Mod-Enter":Si,Backspace:di,"Mod-Backspace":di,"Shift-Backspace":di,Delete:Yo,"Mod-Delete":Yo,"Mod-a":Td},Nd={"Ctrl-h":je.Backspace,"Alt-Backspace":je["Mod-Backspace"],"Ctrl-d":je.Delete,"Ctrl-Alt-Backspace":je["Mod-Delete"],"Alt-Delete":je["Mod-Delete"],"Alt-d":je["Mod-Delete"],"Ctrl-a":Mi,"Ctrl-e":vi};for(let n in je)Nd[n]=je[n];var Fy=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;function cl(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s);if(!o)return!1;let l=r?t.tr:null;return Od(l,o,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Od(n,e,t,r=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);s=new tt(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new tt(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=Nt(s,t,r,e);return l?(n&&Dd(n,e,l,i,t),!0):!1}function Dd(n,e,t,r,i){let s=b.empty;for(let u=t.length-1;u>=0;u--)s=b.from(t[u].type.create(t[u].attrs,s));n.step(new K(e.start-(r?2:0),e.end,e.start,e.end,new k(s,0,0),t.length,!0));let o=0;for(let u=0;u<t.length;u++)t[u].type==i&&(o=u+1);let l=t.length-o,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&l&&me(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function tr(n,e){return n instanceof Ct?e==n:n.indexOf(e)>-1}function ul(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&tr(n,o.firstChild.type));return s?t?tr(n,r.node(s.depth-1).type)?Id(e,t,s):Rd(e,t,s):!0:!1}}function Id(n,e,t){let r=n.tr,i=t.end,s=t.$to.end(t.depth),o=t.parent.child(t.endIndex-1).type;i<s&&(r.step(new K(i-1,s,i,s,new k(b.from(o.create(null,t.parent.copy())),1,0),1,!0)),t=new tt(r.doc.resolve(t.$from.pos),r.doc.resolve(s),t.depth));let l=Oe(t);if(l==null)return!1;r.lift(t,l);let a=r.doc.resolve(r.mapping.map(i,-1)-1);return ke(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function Rd(n,e,t){let r=n.tr,i=t.parent;for(let h=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),o=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?b.empty:b.from(i))))return!1;let d=s.pos,f=d+o.nodeSize;return r.step(new K(d-(l?1:0),f+(a?1:0),d+1,f-1,new k((l?b.empty:b.from(i.copy(b.empty))).append(a?b.empty:b.from(i.copy(b.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function dl(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&tr(n,c.firstChild.type));if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(!tr(n,a.type))return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=b.from(c?a.lastChild.lastChild.type.create():null),d=new k(b.from(a.type.create(null,b.from(l.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new K(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}var Z=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Bt=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},Di=null,Ie=function(n,e,t){let r=Di||(Di=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Pd=function(){Di=null},ht=function(n,e,t,r){return t&&(fl(n,e,t,r,-1)||fl(n,e,t,r,1))},Ld=/^(img|br|input|textarea|hr)$/i;function fl(n,e,t,r,i){for(var s;;){if(n==t&&e==r)return!0;if(e==(i<0?0:re(n))){let o=n.parentNode;if(!o||!E(o)||vn(n)||Ld.test(n.nodeName)||n.contentEditable=="false")return!1;e=Z(n)+(i<0?0:1),n=o}else if(E(n)){let o=n.childNodes[e+(i<0?-1:0)];if(E(o)&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else n=o,e=i<0?re(n):0}else return!1}}function re(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function E(n){return n.nodeType==1}function U(n){return n.nodeType==3}function pt(n,e){return e?n.contains(E(e)?e:e.parentNode):!1}function Bd(n,e){for(;;){if(U(n)&&e)return n;if(E(n)&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=re(n)}else if(n.parentNode&&!vn(n))e=Z(n),n=n.parentNode;else return null}}function zd(n,e){for(;;){if(U(n)&&e<n.nodeValue.length)return n;if(E(n)&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!vn(n))e=Z(n)+1,n=n.parentNode;else return null}}function $d(n,e,t){for(let r=e==0,i=e==re(n);r||i;){if(n==t)return!0;let s=Z(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==re(n)}}function vn(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}var fr=function(n){return n.focusNode&&ht(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function ot(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Fd(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Vd(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(re(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(re(r.startContainer),r.startOffset)}}}var we=typeof navigator<"u"?navigator:null,hl=typeof document<"u"?document:null,_e=we&&we.userAgent||"",Ii=/Edge\/(\d+)/.exec(_e),jl=/MSIE \d/.exec(_e),Ri=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(_e),ue=!!(jl||Ri||Ii),qe=jl?document.documentMode:Ri?+Ri[1]:Ii?+Ii[1]:0,de=!ue&&/gecko\/(\d+)/i.test(_e);de&&+(/Firefox\/(\d+)/.exec(_e)||[0,0])[1];var Pi=!ue&&/Chrome\/(\d+)/.exec(_e),Q=!!Pi,Wl=Pi?+Pi[1]:0,ie=!ue&&!!we&&/Apple Computer/.test(we.vendor),zt=ie&&(/Mobile\/\w+/.test(_e)||!!we&&we.maxTouchPoints>2),ge=zt||(we?/Mac/.test(we.platform):!1),Kl=we?/Win/.test(we.platform):!1,Re=/Android \d/.test(_e),hr=!!hl&&"webkitFontSmoothing"in hl.documentElement.style,Hd=hr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function jd(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function De(n,e){return typeof n=="number"?n:n[e]}function Wd(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function pl(n,e,t){if(!Li(e)&&e.left==0)return;let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(!E(o)){o=Bt(o);continue}let l=o==s.body,a=l?jd(s):Wd(o),c=0,u=0;if(e.top<a.top+De(r,"top")?u=-(a.top-e.top+De(i,"top")):e.bottom>a.bottom-De(r,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+De(i,"top")-a.top:e.bottom-a.bottom+De(i,"bottom")),e.left<a.left+De(r,"left")?c=-(a.left-e.left+De(i,"left")):e.right>a.right-De(r,"right")&&(c=e.right-a.right+De(i,"right")),c||u)if(l)s.defaultView.scrollBy(c,u);else{let f=o.scrollLeft,h=o.scrollTop;u&&(o.scrollTop+=u),c&&(o.scrollLeft+=c);let p=o.scrollLeft-f,m=o.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}let d=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(d))break;o=d=="absolute"?o.offsetParent:Bt(o)}}function Kd(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=n.root.elementFromPoint(s,o);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:ql(n.dom)}}function ql(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Bt(r));return e}function qd({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Jl(t,r==0?0:r-e)}function Jl(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:s}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}var Rt=null;function Jd(n){if(n.setActive)return n.setActive();if(Rt)return n.focus(Rt);let e=ql(n);n.focus(Rt==null?{get preventScroll(){return Rt={preventScroll:!0},!0}}:void 0),Rt||(Rt=!1,Jl(e,0))}function _l(n,e){let t,r=2e8,i,s=0,o=e.top,l=e.top,a,c;for(let u=n.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(E(u))f=u.getClientRects();else if(U(u))f=Ie(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){t=u,r=m,i=m&&U(t)?{left:p.right<e.left?p.right:p.left,top:e.top}:e,E(u)&&m&&(s=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!t&&a&&(t=a,i=c,r=0),t&&U(t)?_d(t,i):!t||r?{node:n,offset:s}:_l(t,i)}function _d(n,e){let t=n.nodeValue.length,r=document.createRange(),i;for(let s=0;s<t;s++){r.setEnd(n,s+1),r.setStart(n,s);let o=We(r,1);if(o.top!=o.bottom&&Yi(e,o)){i={node:n,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:n,offset:0}}function Yi(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Ud(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Gd(n,e,t){let{node:r,offset:i}=_l(e,t),s=-1;if(E(r)&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function Xd(n,e,t,r){let i=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0),a;if(!l)return null;if(E(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>r.left||a.top>r.top?i=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function Ul(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let o=n.childNodes[s];if(E(o)){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Yi(e,c))return Ul(o,e,c)}}if((s=(s+1)%r)==i)break}return n}function Yd(n,e){let t=n.dom.ownerDocument,r,i=0,s=Vd(t,e.left,e.top);s&&({node:r,offset:i}=s);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!o||!n.dom.contains(o)){let c=n.dom.getBoundingClientRect();if(!Yi(e,c)||(o=Ul(n.dom,e,c),!o))return null}if(ie)for(let c=o;r&&c;c=Bt(c))c.draggable&&(r=void 0);if(o=Ud(o,e),r){if(de&&E(r)&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}let c;hr&&i&&E(r)&&E(c=r.childNodes[i-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&E(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||!E(r)||r.childNodes[i-1].nodeName!="BR")&&(l=Xd(n,r,i,e))}l==null&&(l=Gd(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Li(n){return n.top<n.bottom||n.left<n.right}function We(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Li(r))return r}return Array.prototype.find.call(t,Li)||n.getBoundingClientRect()}var Zd=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Gl(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=hr||de;if(U(r))if(o&&(Zd.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let a=We(Ie(r,i,i),t);if(de&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=We(Ie(r,i-1,i-1),-1);if(c.top==a.top){let u=We(Ie(r,i,i+1),-1);if(u.top!=a.top)return mn(u,u.left<c.left)}}return a}else{let a=i,c=i,u=t<0?1:-1;return t<0&&!i?(c++,u=-1):t>=0&&i==r.nodeValue.length?(a--,u=1):t<0?a--:c++,mn(We(Ie(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==re(r))){let a=r.childNodes[i-1];if(E(a))return Ti(a.getBoundingClientRect(),!1)}if(s==null&&i<re(r)){let a=r.childNodes[i];if(E(a))return Ti(a.getBoundingClientRect(),!0)}return Ti(r.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==re(r))){let a=r.childNodes[i-1],c=U(a)?Ie(a,re(a)-(o?0:1)):E(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return mn(We(c,1),!1)}if(s==null&&i<re(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?U(a)?Ie(a,0,o?0:1):E(a)?a:null:null;if(c)return mn(We(c,-1),!0)}return mn(We(U(r)?Ie(r):r,-t),t>=0)}function mn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Ti(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Xl(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function Qd(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Xl(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Gl(n,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(E(l))a=l.getClientRects();else if(U(l))a=Ie(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}var ef=/[\u0590-\u08ac]/;function tf(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=n.domSelection();return l?!ef.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Xl(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!pt(h,p)||a==p&&c==m;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}var ml=null,gl=null,yl=!1;function nf(n,e,t){return ml==e&&gl==t?yl:(ml=e,gl=t,yl=t=="up"||t=="down"?Qd(n,e,t):tf(n,e,t))}var ye=0,bl=1,lt=2,Se=3,mt=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=ye,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){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,r=this.posAtStart;;t++){let i=this.children[t];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&pt(this.contentDOM,e))if(r<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>Z(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let s=e.compareDocumentPosition(this.contentDOM);s&16?i=t>Array.from(e.childNodes).findIndex(o=>o.contains(this.contentDOM)):i=!(s&4)}else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||s.node))if(r&&(o=s.nodeDOM)&&!(E(o)?pt(o,e):o==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.size;if(l>e){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(;r>0;r--){let s=this.children[r-1];if(s.size||!(s instanceof ir||s instanceof nr&&s.side>=0))break}if(t<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Z(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Z(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(i==-1&&e<=c){let u=o+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=o;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=Z(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){s=Z(d.dom);break}t+=d.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}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:r}=this.domFromPos(e,0);if(!E(t)||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(s>p&&o<g)return m.setSelection(e-p-m.border,t-p-m.border,r,i);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((de||ie)&&e==t){let{node:h,offset:p}=l;if(U(h)){if(d=!!(p&&h.nodeValue[p-1]==`
7
- `),d&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:Z(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=h.childNodes[p-1];d=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(de&&u.focusNode&&u.focusNode!=a.node&&E(u.focusNode)){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||d&&ie)&&ht(l.node,l.offset,u.anchorNode,u.anchorOffset)&&ht(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(d&&de)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&t>=r:e<o&&t>r){let l=r+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?lt:bl,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Se:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?lt:Se}r=o}this.dirty=lt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?lt:bl;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},nr=class extends mt{constructor(e,t,r,i){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){let l=E(o)?o:document.createElement("span");l!=o&&(l.appendChild(o),o=l),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==ye&&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}},Bi=class extends mt{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},ct=class n extends mt{constructor(e,t,r,i,s){super(e,[],r,i),this.mark=t,this.spec=s}static create(e,t,r,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,r);return(!o||!o.dom)&&(o=Ae.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Se||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Se&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ye){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=ye}}slice(e,t,r){let i=n.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;t<o&&(s=Vi(s,t,o,r)),e>0&&(s=Vi(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Je=class n extends mt{constructor(e,t,r,i,s,o,l){super(e,[],s,o),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,t,r,i,s,o){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(!U(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Ae.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Ql(u,r,t),c?a=new zi(e,t,r,i,u,d||null,f,c):t.isText?new rr(e,t,r,i,u,f):new n(e,t,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 r=this.children.length-1;r>=0;r--){let i=this.children[r];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement){let r=e&&e.find(i=>E(i)&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));r?t.contentElement=r:t.getContent=()=>b.empty}}return t}matchesNode(e,t,r){return this.dirty==ye&&e.eq(this.node)&&sr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Fi(this,o&&o.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;lf(this.node,this.innerDeco,(d,f,h)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,e,f):d.type.side>=0&&!h&&a.syncToMarks(f==this.node.childCount?D.none:this.node.child(f).marks,r,e,f),a.placeWidget(d,e,i)},(d,f,h,p)=>{a.syncToMarks(d.marks,r,e,p),u&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(d,f,h,p)||l&&e.state.selection.from>i&&e.state.selection.to<i+d.nodeSize&&(m=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(d,f,h,m,e)||a.updateNextNode(d,f,h,e,p,i)||a.addNode(d,f,h,e,i),i+=d.nodeSize,c&&(u=d.isAtom&&!d.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==lt)&&(o&&this.protectLocalComposition(e,o),Yl(this.contentDOM,this.children,e),zt&&af(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof C)||r<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=cf(this.node.content,o,r-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new Bi(this,s,t,i);e.input.compositionNodes.push(o),this.children=Vi(this.children,r,r+i.length,e,o)}update(e,t,r,i){return this.dirty==Se||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=ye}updateOuterDeco(e){if(sr(e,this.outerDeco))return;let t=!E(this.nodeDOM),r=this.dom;this.dom=Zl(this.dom,this.nodeDOM,$i(this.outerDeco,this.node,t),$i(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){E(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){E(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 kl(n,e,t,r,i){Ql(r,e,n);let s=new Je(void 0,n,e,t,r,r,r);return s.contentDOM&&s.updateChildren(i,0),s}var rr=class n extends Je{constructor(e,t,r,i,s,o){super(e,t,r,i,s,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==Se||this.dirty!=ye&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ye||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=ye,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,s,s)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Se)}get domAtom(){return!1}isText(e){return this.node.text==e}},ir=class extends mt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ye&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},zi=class extends Je{constructor(e,t,r,i,s,o,l,a){super(e,t,r,i,s,o,l),this.spec=a}update(e,t,r,i){if(this.dirty==Se)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Yl(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==n){for(;l!=r;)r=Sl(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(o instanceof ct){let a=r?r.previousSibling:n.lastChild;Yl(o.contentDOM,o.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Sl(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}var yn=function(n){n&&(this.nodeName=n)};yn.prototype=Object.create(null);var at=[new yn];function $i(n,e,t){if(n.length==0)return at;let r=t?at[0]:new yn,i=[r];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&i.push(r=new yn(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(r=new yn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return i}function Zl(n,e,t,r){if(t==at&&r==at)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=n&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=at[0]),i=a}rf(i,l||at[0],o)}return i}function rf(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.add(i[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function Ql(n,e,t){return Zl(n,n,at,$i(e,t,!E(n)))}function sr(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Sl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var Fi=class{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=sf(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,i){let s=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;s<l&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=ye,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[o])&&!this.isLocked(d.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof ct&&u.dirty!=Se&&u.mark.type==e[o].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[o])&&(u.mark=e[o],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=ct.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,i,s){let o=this.top.children[i];return o.dirty==Se&&o.dom==o.contentDOM&&(o.dirty=lt),o.update(e,t,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,r,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Je){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Se&&sr(t,a.outerDeco));if(!f&&a.update(e,t,r,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,t,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=lt,d.updateChildren(i,o+1),d.dirty=ye),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!sr(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Je.create(this.top,t,r,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,i,s){let o=Je.create(this.top,e,t,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new nr(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof ct;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof rr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ie||Q)&&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 r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new ir(this.top,[],r,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||E(e)&&e.contains(this.lock.parentNode))}};function sf(n,e){let t=e,r=t.children.length,i=n.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof ct)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function of(n,e){return n.type.side-e.type.side}function lf(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,i,e.forChild(s,u),c),s+=u.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let u,d;for(;o<i.length&&i[o].to==s;){let g=i[o++];g.widget&&(u?(d||(d=[u])).push(g):u=g)}if(u)if(d){d.sort(of);for(let g=0;g<d.length;g++)t(d[g],c,!!a)}else t(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<n.childCount)h=c,f=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let g=p;o<i.length&&i[o].from<g&&(g=i[o].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=f.cut(g-s),f=f.cut(0,g-s),p=g,h=-1)}else for(;o<i.length&&i[o].to<p;)o++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,m,e.forChild(s,f),h),s=p}}function af(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function cf(n,e,t,r){for(let i=0,s=0;i<n.childCount&&s<=r;){let o=n.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<n.childCount;){let c=n.child(i++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Vi(n,e,t,r,i){let s=[];for(let o=0,l=0;o<n.length;o++){let a=n[o],c=l,u=l+=a.size;c>=t||u<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),i&&(s.push(i),i=void 0),u>t&&s.push(a.slice(t-c,a.size,r)))}return s}function Zi(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(fr(t)){for(a=o;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&T.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&$d(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;c=new T(o==d?l:r.resolve(d))}else if(de&&e=="key"&&o>n.state.selection.to&&E(t.focusNode)&&t.focusOffset==t.focusNode.childNodes.length&&i&&i.posAtStart>n.state.selection.to)for(let d=t.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){c=N.findFrom(r.resolve(i.posAtStart),1);break}if(d==i.dom||d.nextSibling||!d.parentNode||!E(d.parentNode))break}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=o,f=o;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);d=Math.min(d,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,o]=f==n.state.selection.anchor?[f,d]:[d,f],l=r.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=Qi(n,u,l,d)}return c}function ea(n){return n.editable?n.hasFocus():na(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Le(n,e=!1){let t=n.state.selection;if(ta(n,t),!ea(n))return;let r=n.input.mouseDown;if(!e&&Q&&r){let i=n.domSelectionRange(),s=n.domObserver.currentSelection;if(i.anchorNode&&s.anchorNode&&ht(i.anchorNode,i.anchorOffset,s.anchorNode,s.anchorOffset)&&r.delaySelUpdate()){n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)df(n);else{let{anchor:i,head:s}=t,o,l;xl&&!(t instanceof C)&&(t.$from.parent.inlineContent||(o=wl(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=wl(n,t.to))),n.docView.setSelection(i,s,n,e),xl&&(o&&Ml(o),l&&Ml(l)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&uf(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}var xl=ie||Q&&Wl<63;function wl(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(ie&&i&&i.contentEditable=="false")return Ai(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Ai(i);if(s)return Ai(s)}}function Ai(n){return n.contentEditable="true",ie&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ml(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function uf(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!ea(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function df(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,Z(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&ue&&qe<=11&&(t.disabled=!0,t.disabled=!1)}function ta(n,e){if(e instanceof T){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(vl(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else vl(n)}function vl(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Qi(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||C.between(e,t,r)}function Cl(n){return n.editable&&!n.hasFocus()?!1:na(n)}function na(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return pt(n.dom,e.anchorNode)&&(n.editable||pt(n.dom,e.focusNode))}catch{return!1}}function ff(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return ht(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Hi(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&N.findFrom(s,e)}function Ke(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function El(n,e,t){let r=n.state.selection;if(r instanceof C)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Ke(n,new C(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Hi(n.state,e);return i&&i instanceof T?Ke(n,i):!1}else if(!ge||t.indexOf("m")<0){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?T.isSelectable(s)?Ke(n,new T(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):Ke(n,new C(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1}}else return!1;else{if(r instanceof T&&r.node.isInline)return Ke(n,new C(e>0?r.$to:r.$from));{let i=Hi(n.state,e);return i?Ke(n,i):!1}}}function bn(n,e){let t=n.pmViewDesc;return t?t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR"):E(n)&&n.contentEditable=="false"}function Pt(n,e){return e<0?hf(n):pf(n)}function hf(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(de&&E(t)&&r<re(t)&&bn(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(!E(t))break;let l=t.childNodes[r-1];if(bn(l,-1))i=t,s=--r;else if(U(l))t=l,r=t.nodeValue.length;else break}else{if(ra(t))break;{let l=t.previousSibling;for(;l&&bn(l,-1);)i=t.parentNode,s=Z(l),l=l.previousSibling;if(l)t=l,r=re(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?ji(n,t,r):i&&ji(n,i,s)}function pf(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=re(t),s,o;for(;;)if(r<i){if(!E(t))break;let l=t.childNodes[r];if(bn(l,1))s=t,o=++r;else break}else{if(ra(t))break;{let l=t.nextSibling;for(;l&&bn(l,1);)s=l.parentNode,o=Z(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=re(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&ji(n,s,o)}function ra(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function mf(n,e){for(;n&&e==n.childNodes.length&&!vn(n);)e=Z(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(U(t))return t;if(E(t)&&t.contentEditable=="false")break;n=t,e=0}}function gf(n,e){for(;n&&!e&&!vn(n);)e=Z(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(U(t))return t;if(E(t)&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function ji(n,e,t){if(!U(e)){let o,l;(l=mf(e,t))?(e=l,t=0):(o=gf(e,t))&&(e=o,t=o.nodeValue.length)}let r=n.domSelection(),i=n.domSelectionRange();if(!r)return;fr(i)?r.collapse(e,t):r.extend&&(r.collapse(i.anchorNode,i.anchorOffset),r.extend(e,t)),n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&Le(n)},50)}function Tl(n,e){let t=n.state.doc.resolve(e);if(!(Q||Kl)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),l=(o.top+o.bottom)/2;if(l>s.top&&l<s.bottom&&Math.abs(o.left-s.left)>1)return o.left<s.left?"ltr":"rtl"}if(e<t.end()){let o=n.coordsAtPos(e+1),l=(o.top+o.bottom)/2;if(l>s.top&&l<s.bottom&&Math.abs(o.left-s.left)>1)return o.left>s.left?"ltr":"rtl"}}let r=n.dom;for(let s=t.depth;s>0;s--)if(t.node(s).isBlock){r=n.nodeDOM(t.before(s))||r;break}return getComputedStyle(r).direction=="rtl"?"rtl":"ltr"}function Al(n,e,t){let r=n.state.selection;if(r instanceof C&&!r.empty||t.indexOf("s")>-1||ge&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Hi(n.state,e);if(o&&o instanceof T)return Ke(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof oe?N.near(o,e):N.findFrom(o,e);return l?Ke(n,l):!1}return!1}function Nl(n,e){if(!(n.state.selection instanceof C))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function Ol(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function yf(n){if(!ie||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&E(e)&&t==0&&e.firstChild&&E(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Ol(n,r,"true"),setTimeout(()=>Ol(n,r,"false"),20)}return!1}function bf(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function kf(n,e){let t=e.keyCode,r=bf(e);if(t==8||ge&&t==72&&r=="c")return Nl(n,-1)||Pt(n,-1);if(t==46&&!e.shiftKey||ge&&t==68&&r=="c")return Nl(n,1)||Pt(n,1);if(t==13||t==27)return!0;if(t==37||ge&&t==66&&r=="c"){let i=t==37?Tl(n,n.state.selection.from)=="ltr"?-1:1:-1;return El(n,i,r)||Pt(n,i)}else if(t==39||ge&&t==70&&r=="c"){let i=t==39?Tl(n,n.state.selection.from)=="ltr"?1:-1:1;return El(n,i,r)||Pt(n,i)}else{if(t==38||ge&&t==80&&r=="c")return Al(n,-1,r)||Pt(n,-1);if(t==40||ge&&t==78&&r=="c")return yf(n)||Al(n,1,r)||Pt(n,1);if(r==(ge?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function es(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||Ae.fromSchema(n.state.schema),l=ca(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&E(c)&&(u=aa[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&E(c)&&c.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
8
-
9
- `);return{dom:a,text:f,slice:e}}function ia(n,e,t,r,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=!!e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,s||r,n)}),s)return l=new k(b.from(n.state.schema.text(e.replace(/\r\n?/g,`
10
- `))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let d=n.someProp("clipboardTextParser",f=>f(e,i,r,n));if(d)l=d;else{let f=i.marks(),{schema:h}=n.state,p=Ae.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),o=Mf(t),hr&&vf(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=o.firstChild;for(;f&&!E(f);)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Te.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Sf.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Cf(Dl(l,+u[1],+u[2]),u[4]);else if(l=k.maxOpen(xf(l.content,i),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=Dl(l,d,f)}return n.someProp("transformPasted",d=>{l=d(l,n,a)}),l}var Sf=/^(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 xf(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&oa(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=la(o[o.length-1],s.length));let u=sa(l,a);o.push(u),i=i.matchType(u.type),s=a}}),o)return b.from(o)}return n}function sa(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,b.from(n));return n}function oa(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=oa(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(b.from(sa(t,n,i+1))))}}function la(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,la(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(b.empty,!0);return n.copy(t.append(r))}function Wi(n,e,t,r,i,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),i<r-1&&(l=Wi(l,e,t,r,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(b.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function Dl(n,e,t){return e<n.openStart&&(n=new k(Wi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new k(Wi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var aa={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 ca(){return document.implementation.createHTMLDocument("title")}var gn=null;function wf(n){let e=window.trustedTypes;if(!e)return n;if(!gn){if(gn=e.defaultPolicy)try{return gn.createHTML(n)}catch{}gn=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return gn.createHTML(n)}function Mf(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=ca(),r=t.body,i=/<([a-z][^>\s]+)/i.exec(n),s;if((s=i&&aa[i[1].toLowerCase()])&&(n=s.map(o=>"<"+o+">").join("")+n+s.map(o=>"</"+o+">").reverse().join("")),r.innerHTML=wf(n),s)for(let o=0;o<s.length;o++)r=r.querySelector(s[o])||r;for(let o=0;o<t.styleSheets.length;o++){let l=t.styleSheets[o];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return r}function vf(n){let e=n.querySelectorAll(Q?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Cf(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{i=b.from(a.create(r[l+1],i))}catch{break}s++,o++}return new k(i,s,o)}var le={},ae={},Ef={touchstart:!0,touchmove:!0},Ki=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,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 Tf(n){for(let e in le){let t=le[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Nf(n,r)&&!ts(n,r)&&(n.editable||!(r.type in ae))&&t(n,r)},Ef[e]?{passive:!0}:void 0)}ie&&n.dom.addEventListener("input",()=>null),qi(n)}function Pe(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Af(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function qi(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>ts(n,r))})}function ts(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Nf(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Of(n,e){!ts(n,e)&&le[e.type]&&(n.editable||!(e.type in ae))&&le[e.type](n,e)}ae.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!fa(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Re&&Q&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),zt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,ot(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||kf(n,t)?t.preventDefault():Pe(n,"key")};ae.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};ae.keypress=(n,e)=>{let t=e;if(fa(n)||!t.charCode||t.ctrlKey&&!t.altKey||ge&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof C)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i,s))&&n.dispatch(s()),t.preventDefault()}};function Cn(n){return{left:n.clientX,top:n.clientY}}function Df(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ns(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function En(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function If(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&T.isSelectable(r)?(En(n,new T(t)),!0):!1}function Rf(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof T&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(T.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(En(n,T.create(n.state.doc,i)),!0):!1}function Pf(n,e,t,r,i){return ns(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Rf(n,t):If(n,t))}function Lf(n,e,t,r){return ns(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Bf(n,e,t,r){return ns(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||zf(n,t,r)}function zf(n,e,t){if(t.button!=0)return!1;let r=ua(n,e,!0),i=n.state.doc;return r?(En(n,r),r instanceof C&&i.eq(n.state.doc)&&(n.input.mouseDown=new _i(n,r)),!0):!1}function ua(n,e,t){let r=n.state.doc;if(e==-1)return r.inlineContent?C.create(r,0,r.content.size):null;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)return C.create(r,l+1,l+1+o.content.size);if(t&&T.isSelectable(o))return T.create(r,l)}return null}function rs(n){return lr(n)}var da=ge?"metaKey":"ctrlKey";le.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=rs(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&Df(t,n.input.lastClick)&&!t[da]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let o=n.posAtCoords(Cn(t));o&&(s=="singleClick"?n.input.mouseDown=new Ji(n,o,t,!!r):(s=="doubleClick"?Lf:Bf)(n,o.pos,o.inside,t)?t.preventDefault():Pe(n,"pointer"))};var or=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}},Ji=class extends or{constructor(e,t,r,i){super(e),this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[da],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,o=u.depth?u.before():0}let l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&E(a.nodeDOM)?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof T&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&de&&!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()),Pe(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||Le(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(Cn(e))),this.updateAllowDefault(e),this.allowDefault||!t?Pe(this.view,"pointer"):Pf(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ie&&this.mightDrag&&!this.mightDrag.node.isAtom||Q&&!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)?(En(this.view,N.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Pe(this.view,"pointer")}move(e){this.updateAllowDefault(e),Pe(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}},_i=class extends or{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(),Pe(this.view,"pointer");let t=this.view.posAtCoords(Cn(e)),r=t&&ua(this.view,t.inside,!1);if(!r)return;let{doc:i}=this.view.state,s=this.startSelection,[o,l]=r.from<s.from?[s.to,r.from]:[s.from,r.to];En(this.view,C.create(i,o,l))}};le.touchstart=n=>{n.input.lastTouch=Date.now(),rs(n),Pe(n,"pointer")};le.touchmove=n=>{n.input.lastTouch=Date.now(),Pe(n,"pointer")};le.contextmenu=n=>rs(n);function fa(n,e){return n.composing?!0:ie&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var $f=Re?5e3:-1;ae.compositionstart=ae.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof C&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Q&&Kl&&Ff(n)))n.markCursor=n.state.storedMarks||t.marks(),lr(n,!0),n.markCursor=null;else if(lr(n,!e.selection.empty),de&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&E(i)&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(U(o)){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}ha(n,$f)};function Ff(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||!E(e)||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return E(r)&&r.contentEditable=="false"}ae.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,ha(n,20))};function ha(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>lr(n),e))}function pa(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Vf(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Bd(e.focusNode,e.focusOffset),r=zd(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function lr(n,e=!1){if(!(Re&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),pa(n),e||n.docView&&n.docView.dirty){let t=Zi(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Hf(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var kn=ue&&qe<15||zt&&Hd<604;le.copy=ae.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=kn?null:t.clipboardData,o=r.content(),{dom:l,text:a}=es(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Hf(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function jf(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Wf(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Sn(n,r.value,null,i,e):Sn(n,r.textContent,r.innerHTML,i,e)},50)}function Sn(n,e,t,r,i){let s=ia(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||k.empty)))return!0;if(!s)return!1;let o=jf(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ma(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ae.paste=(n,e)=>{let t=e;if(n.composing&&!Re)return;let r=kn?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Sn(n,ma(r),r.getData("text/html"),i,t)?t.preventDefault():Wf(n,t)};var ar=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Kf=ge?"altKey":"ctrlKey";function ga(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[Kf]}le.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(Cn(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof T?i.to-1:i.to))){if(r&&r.mightDrag)o=T.create(n.state.doc,r.mightDrag.pos);else if(t.target&&E(t.target)){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(o=T.create(n.state.doc,d.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:u}=es(n,l);(!t.dataTransfer.files.length||!Q||Wl>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(kn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",kn||t.dataTransfer.setData("text/plain",c),n.dragging=new ar(u,ga(n,t),o)};le.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};ae.dragover=ae.dragenter=(n,e)=>e.preventDefault();ae.drop=(n,e)=>{try{qf(n,e,n.dragging)}finally{n.dragging=null}};function qf(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Cn(e));if(!r)return;let i=n.state.doc.resolve(r.pos),s=t&&t.slice;s?n.someProp("transformPasted",h=>{s=h(s,n,!1)}):s=ia(n,ma(e.dataTransfer),kn?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&ga(n,e));if(n.someProp("handleDrop",h=>h(n,e,s||k.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Gn(n.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=n.state.tr;if(o){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,s.content.firstChild):a.replaceRange(c,c,s),a.doc.eq(d))return;let f=a.doc.resolve(c);if(u&&T.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new T(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),a.setSelection(Qi(n,f,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}le.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Le(n)},20))};le.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};le.beforeinput=(n,e)=>{if(Re&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,ot(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in ae)le[n]=ae[n];function xn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var wn=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}},cr=class n{constructor(e,t){this.toDOM=e,this.spec=t||dt,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new ce(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&xn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},ut=class n{constructor(e,t){this.attrs=e,this.spec=t||dt}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new ce(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&xn(this.attrs,e.attrs)&&xn(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},Ui=class n{constructor(e,t){this.attrs=e,this.spec=t||dt}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new ce(s.pos-r,o.pos-r,this)}valid(e,t,r){let i=r.nodeAt(t.from);return!!i&&!i.isText&&t.from+i.nodeSize==t.to}eq(e){return this==e||e instanceof n&&xn(this.attrs,e.attrs)&&xn(this.spec,e.spec)}destroy(){}},ce=class n{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new n(e,t,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,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new n(e,e,new cr(t,r))}static inline(e,t,r,i){return new n(e,t,new ut(r,i))}static node(e,t,r,i){return new n(e,t,new Ui(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof ut}get widget(){return this.type instanceof cr}},Lt=[],dt={},B=class n{constructor(e,t){this.local=e.length?e:Lt,this.children=t.length?t:Lt}static create(e,t){return t.length?dr(t,e,0,dt):ne}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==ne||e.maps.length==0?this:this.mapInner(e,t,0,0,r||dt)}mapInner(e,t,r,i,s){let o;if(this.local.length){let l=new wn(t.content);for(let a=0;a<this.local.length;a++){let c=this.local[a].map(e,r,i);c&&c.type.valid(t,c,l)?(o||(o=[])).push(c):s.onRemove&&s.onRemove(this.local[a].spec)}}return this.children.length?Jf(this.children,o||[],e,t,r,i,s):o?new n(o.sort(ft),Lt):ne}add(e,t){return t.length?this==ne?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=ba(t,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,u,c+1):i.splice(s,0,a,a+l.nodeSize,dr(u,l,c+1,dt)),s+=3}});let o=ya(s?ka(t):t,-r);if(o.length){let l=new wn(e.content);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a],l)||o.splice(a--,1)}return new n(o.length?this.local.concat(o).sort(ft):this.local,i||this.children)}remove(e){return e.length==0||this==ne?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+t,a=r[s+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(o,l+1);c!=ne?r[s+2]=c:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new n(i,r):ne}forChild(e,t){if(this==ne)return this;if(t.isLeaf)return n.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof ut){let c=Math.max(s,a.from)-s,u=Math.min(o,a.to)-s;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new n(i.sort(ft),Lt);return r?new ur([l,r]):l}return r||ne}eq(e){if(this==e)return!0;if(!(e instanceof n)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return is(this.localsInner(e))}localsInner(e){if(this==ne)return Lt;if(e.inlineContent||!this.local.some(ut.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof ut||t.push(this.local[r]);return t}forEachSet(e){e(this)}};B.empty=new B([],[]);B.removeOverlap=is;var ne=B.empty,ur=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(i=>i.map(e,t,dt));return n.from(r)}forChild(e,t){if(t.isLeaf)return B.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=ne&&(s instanceof n?r=r.concat(s.members):r.push(s))}return n.from(r)}eq(e){if(!(e instanceof n)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?is(r?t:t.sort(ft)):Lt}static from(e){switch(e.length){case 0:return ne;case 1:return e[0];default:return new n(e.every(t=>t instanceof B)?e:e.reduce((t,r)=>t.concat(r instanceof B?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Jf(n,e,t,r,i,s,o){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let d=0;t.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let y=0;y<l.length;y+=3){let x=l[y+1];if(x<0||f>x+u-d)continue;let w=l[y]+u-d;h>=w?l[y+1]=f<=w?-2:-1:f>=u&&g&&(l[y]+=g,l[y+1]+=g)}d+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),d=u-i;if(d<0||d>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+s,-1),h=f-i,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let y=l[c+2].mapInner(t,g,u+1,n[c]+s+1,o);y!=ne?(l[c]=d,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=_f(l,n,e,t,i,s,o),u=dr(c,r,0,o);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new B(e.sort(ft),l)}function ya(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new ce(i.from+e,i.to+e,i.type))}return t}function _f(n,e,t,r,i,s,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,i,c);d?t.push(d):o.onRemove&&o.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function ba(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<r&&((i||(i=[])).push(o),n[s]=null);return i}function ka(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function dr(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let c=ba(n,l,a+t);if(c){s=!0;let u=dr(c,l,t+a+1,r);u!=ne&&i.push(a,a+l.nodeSize,u)}});let o=ya(s?ka(n):n,-t).sort(ft);if(o.length){let l=new wn(e.content);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a],l)||(r.onRemove&&r.onRemove(o[a].spec),o.splice(a--,1))}return o.length||i.length?new B(o,i):ne}function ft(n,e){return n.from-e.from||n.to-e.to}function is(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),Il(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Il(e,i,r.copy(s.from,r.to)));break}}}return e}function Il(n,e,t){for(;e<n.length&&ft(t,n[e])>0;)e++;n.splice(e,0,t)}function Ni(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ne&&e.push(r)}),n.cursorWrapper&&e.push(B.create(n.state.doc,[n.cursorWrapper.deco])),ur.from(e)}var Uf={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Gf=ue&&qe<=11,Gi=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}},Xi=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Gi,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);ue&&qe<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():ie&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Gf&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Uf)),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(Cl(this.view)){if(this.suppressingSelectionUpdates)return Le(this.view);if(ue&&qe<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ht(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,r;for(let s=e.focusNode;s;s=Bt(s))t.add(s);for(let s=e.anchorNode;s;s=Bt(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:U(r)?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r,i=!1;!this.suppressingSelectionUpdates&&Cl(e)&&(r=e.domSelectionRange(),i=!this.currentSelection.eq(r)&&!this.ignoreSelectionChange(r));let s=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let d=this.registerMutation(t[u],a);d&&(s=s<0?d.from:Math.min(d.from,s),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Q&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&E(d);){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(de&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||Zf(e,d)!=h)&&f.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&fr(r)&&(c=Zi(e))&&c.eq(N.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Le(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Xf(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Qf(e,a)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):r&&!this.currentSelection.eq(r)&&Le(e),r&&this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];t.push(d),U(d)&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(ue&&qe<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let o=i&&i.parentNode==e.target?Z(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?Z(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Rl=new WeakMap,Pl=!1;function Xf(n){if(!Rl.has(n)&&(Rl.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=de,Pl)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."),Pl=!0}}function Ll(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return ht(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Yf(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Ll(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Ll(n,t):null}function Zf(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Qf(n,e){var t;let{focusNode:r,focusOffset:i}=n.domSelectionRange();for(let s of e)if(((t=s.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||!E(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),r==s&&n.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function eh(n,e,t,r){let{node:i,fromOffset:s,toOffset:o,from:l,to:a}=n.docView.parseRange(e,t),c=n.domSelectionRange(),u,d=c.anchorNode;if(d&&pt(n.dom,d)&&(u=[{node:d,offset:c.anchorOffset}],fr(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Q&&n.input.lastKeyCode===8)for(let y=o;y>s;y--){let x=i.childNodes[y-1],w=x.pmViewDesc;if(x.nodeName=="BR"&&!w){o=y;break}if(!w||w.size)break}let f=n.state.doc,h=n.someProp("domParser")||Te.fromSchema(n.state.schema),p=f.resolve(l),m=null,g=h.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:th(r),context:p});if(u&&u[0].pos!=null){let y=u[0].pos,x=u[1]&&u[1].pos;x==null&&(x=y),m={anchor:y+l,head:x+l}}return{doc:g,sel:m,from:l,to:a}}var th=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(ie&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||ie&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},nh=/^(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 rh(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let A=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,R=Zi(n,A);if(R&&!n.state.selection.eq(R)){if(Q&&Re&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",$=>$(n,ot(13,"Enter"))))return;let z=n.state.tr.setSelection(R);A=="pointer"?z.setMeta("pointer",!0):A=="key"&&z.scrollIntoView(),s&&z.setMeta("composition",s),n.dispatch(z)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=eh(n,e,t,i),u=n.state.doc,d=u.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=lh(d.content,c.doc.content,c.from,f,h);if(p&&n.input.domChangeCount++,(zt&&n.input.lastIOSEnter>Date.now()-225||Re)&&i.some(A=>E(A)&&!nh.test(A.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",A=>A(n,ot(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof C&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let A=Bl(n,n.state.doc,c.sel);if(A&&!A.eq(n.state.selection)){let R=n.state.tr.setSelection(A);s&&R.setMeta("composition",s),n.dispatch(R)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof C&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ue&&qe<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=u.resolve(p.start),x=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((zt&&n.input.lastIOSEnter>Date.now()-225&&(!x||i.some(A=>A.nodeName=="DIV"||A.nodeName=="P"))||!x&&oh(c.doc,m.pos,g.pos))&&n.someProp("handleKeyDown",A=>A(n,ot(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&(x?p.endA>p.start&&p.endB==p.start:sh(u,p.start,p.endA,m,g))&&n.someProp("handleKeyDown",A=>A(n,ot(8,"Backspace")))){Re&&Q&&n.domObserver.suppressSelectionUpdates();return}Q&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),Re&&!x&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(A){return A(n,ot(13,"Enter"))})},20));let w=p.start,v=p.endA,I=A=>{let R=A||n.state.tr.replace(w,v,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let z=Bl(n,R.doc,c.sel);z&&!(Q&&n.composing&&z.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(z.head==w||z.head==R.mapping.map(v)-1)||ue&&z.empty&&z.head==w)&&R.setSelection(z)}return s&&R.setMeta("composition",s),R.scrollIntoView()},H;if(x)if(m.pos==g.pos){ue&&qe<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Le(n),20));let A=I(n.state.tr.delete(w,v)),R=u.resolve(p.start).marksAcross(u.resolve(p.endA));R&&A.ensureMarks(R),n.dispatch(A)}else if(p.endA==p.endB&&(H=ih(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let A=I(n.state.tr);H.type=="add"?A.addMark(w,v,H.mark):A.removeMark(w,v,H.mark),n.dispatch(A)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let A=m.parent.textBetween(m.parentOffset,g.parentOffset),R=()=>I(n.state.tr.insertText(A,w,v));n.someProp("handleTextInput",z=>z(n,w,v,A,R))||n.dispatch(R())}else n.dispatch(I());else n.dispatch(I())}function Bl(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Qi(n,e.resolve(t.anchor),e.resolve(t.head))}function ih(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,o,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<t.length;u++)s=t[u].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(b.from(c).eq(n))return{mark:l,type:o}}function sh(n,e,t,r,i){if(t-e<=i.pos-r.pos||Oi(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.inlineContent){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=n.resolve(Oi(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Oi(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function oh(n,e,t){let r=0,i=0;return n.nodesBetween(e,t,(s,o)=>{s.isTextblock&&o>=e&&o<t?r++:(s.isText?/\S/.test(s.text.slice(Math.max(0,e-o),Math.min(s.nodeSize,t-o))):s.isLeaf)&&i++}),i==0&&r==1}function Oi(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function lh(n,e,t,r,i){let s=n.findDiffStart(e,t),o=t+n.size,l=t+e.size;if(s==null)return null;let{a,b:c}=n.findDiffEnd(e,o,l);if(i=="end"){let u=Math.max(0,s-Math.min(a,c));r-=a+u-s}if(a<s&&o<l){let u=r<=s&&r>=a?s-r:0;s-=u,c=s+(c-a),a=s}else if(c<s){let u=r<=s&&r>=c?s-r:0;s-=u,a=s+(a-c),c=s}return{start:s,endA:a,endB:c}}var Mn=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 Ki,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Hl),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=Fl(this),$l(this),this.nodeViews=Vl(this),this.docView=kl(this.state.doc,zl(this),Ni(this),this.dom,this),this.domObserver=new Xi(this,(r,i,s,o)=>rh(this,r,i,s,o)),this.domObserver.start(),Tf(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&&qi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Hl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(pa(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Vl(this);ch(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&qi(this),this.editable=Fl(this),$l(this);let a=Ni(this),c=zl(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(i.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Kd(this);if(o){this.domObserver.stop();let h=d&&(ue||Q)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&ah(i.selection,e.selection);if(d){let m=Q?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Vf(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=kl(e.doc,c,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let p=this.input.mouseDown;h||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&ff(this)&&p.delaySelUpdate())?Le(this,h):(ta(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&qd(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!pt(this.dom,e))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof T){let t=this.docView.domAfterPos(this.state.selection.from);E(t)&&pl(this,t.getBoundingClientRect(),e)}else pl(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 t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&s<this.state.doc.content.size&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new ar(e.slice,e.move,i<0?void 0:T.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(ue){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&&Jd(this.dom),Le(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Yd(this,e)}coordsAtPos(e,t=1){return Gl(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,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return nf(this,t||this.state,e)}pasteHTML(e,t){return Sn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Sn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return es(this,e)}destroy(){this.docView&&(Af(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ni(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 Of(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?ie&&this.root.nodeType===11&&Fd(this.dom.ownerDocument)==this.dom&&Yf(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Mn.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function zl(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ce.node(0,n.state.doc.content.size,e)]}function $l(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ce.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Fl(n){return!n.someProp("editable",e=>e(n.state)===!1)}function ah(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Vl(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function ch(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function Hl(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Be={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:"'"},mr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},uh=typeof navigator<"u"&&/Mac/.test(navigator.platform),dh=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(q=0;q<10;q++)Be[48+q]=Be[96+q]=String(q);var q;for(q=1;q<=24;q++)Be[q+111]="F"+q;var q;for(q=65;q<=90;q++)Be[q]=String.fromCharCode(q+32),mr[q]=String.fromCharCode(q);var q;for(pr in Be)mr.hasOwnProperty(pr)||(mr[pr]=Be[pr]);var pr;function Sa(n){var e=uh&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||dh&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?mr:Be)[n.keyCode]||n.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 fh=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),hh=typeof navigator<"u"&&/Win/.test(navigator.platform);function ph(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))fh?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function mh(n){let e=Object.create(null);for(let t in n)e[ph(t)]=n[t];return e}function ss(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function xa(n){return new P({props:{handleKeyDown:ls(n)}})}function ls(n){let e=mh(n);return function(t,r){let i=Sa(r),s,o=e[ss(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[ss(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(hh&&r.ctrlKey&&r.altKey)&&(s=Be[r.keyCode])&&s!=i){let l=e[ss(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var gr=200,ee=function(){};ee.prototype.append=function(e){return e.length?(e=ee.from(e),!this.length&&e||e.length<gr&&this.leafAppend(e)||this.length<gr&&e.leafPrepend(this)||this.appendInner(e)):this};ee.prototype.prepend=function(e){return e.length?ee.from(e).append(this):this};ee.prototype.appendInner=function(e){return new gh(this,e)};ee.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ee.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ee.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ee.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ee.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,r),i};ee.from=function(e){return e instanceof ee?e:e&&e.length?new wa(e):ee.empty};var wa=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a<o;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var a=s-1;a>=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=gr)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=gr)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ee);ee.empty=new wa([]);var gh=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ee),as=ee;var yh=500,yt=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,u.push(d);return}if(i){u.push(new Me(d.map));let h=d.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Me(p,void 0,void 0,c.length+u.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(s)):d.selection,a=new n(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,r,i){let s=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new Me(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?s.pop():l=l.slice(0,l.length-1)),s.push(f),t&&(o++,t=void 0),i||(a=f)}let c=o-r.depth;return c>kh&&(l=bh(l,c),o-=c),new n(l.append(s),o)}remapping(e,t){let r=new cn;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new Me(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let r=[],i=this.items.length-t,s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=t;this.items.forEach(f=>{let h=s.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(s.slice(a+1,h));g&&l++,r.push(new Me(p,m,g))}else r.push(new Me(p))},i);let c=[];for(let f=t;f<o;f++)c.push(new Me(s.maps[f]));let u=this.items.slice(0,i).append(c).append(r),d=new n(u,l);return d.emptyItemCount()>yh&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=o.selection&&o.selection.map(t.slice(r));u&&s++;let d=new Me(c.invert(),a,u),f,h=i.length-1;(f=i.length&&i[h].merge(d))?i[h]=f:i.push(d)}}else o.map&&r--},this.items.length,0),new n(as.from(i.reverse()),s)}};yt.empty=new yt(as.empty,0);function bh(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}var Me=class n{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},ve=class{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}},kh=20;function Sh(n,e,t,r){let i=t.getMeta(gt),s;if(i)return i.historyState;t.getMeta(Ea)&&(n=new ve(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(gt))return o.getMeta(gt).redo?new ve(n.done.addTransform(t,void 0,r,yr(e)),n.undone,Ma(t.mapping.maps),n.prevTime,n.prevComposition):new ve(n.done,n.undone.addTransform(t,void 0,r,yr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!xh(t,n.prevRanges)),c=o?cs(n.prevRanges,t.mapping):Ma(t.mapping.maps);return new ve(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,yr(e)),yt.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new ve(n.done.rebased(t,s),n.undone.rebased(t,s),cs(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new ve(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),cs(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function xh(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function Ma(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,s,o)=>e.push(s,o));return e}function cs(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),s=e.map(n[r+1],-1);i<=s&&t.push(i,s)}return t}function wh(n,e,t){let r=yr(e),i=gt.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),a=new ve(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(gt,{redo:t,historyState:a})}var us=!1,va=null;function yr(n){let e=n.plugins;if(va!=e){us=!1,va=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){us=!0;break}}return us}function Ca(n){return n.setMeta(Ea,!0)}var gt=new W("history"),Ea=new W("closeHistory");function Ta(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new P({key:gt,state:{init(){return new ve(yt.empty,yt.empty,null,0,-1)},apply(e,t,r){return Sh(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?ds:r=="historyRedo"?fs:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function br(n,e){return(t,r)=>{let i=gt.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=wh(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}var ds=br(!1,!0),fs=br(!0,!0),p0=br(!1,!1),m0=br(!0,!1);function Tr(n){let{state:e,transaction:t}=n,{selection:r}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,s=t.storedMarks,t}}}var jt=class Ua{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:r}=this,{view:i}=t,{tr:s}=r,o=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{let d=a(...u)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:r,editor:i,state:s}=this,{view:o}=i,l=[],a=!!e,c=e||s.tr,u=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{let g=this.buildProps(c,t),y=h(...m)(g);return l.push(y),d}])),run:u};return d}static createFakeChain(){let e=new Proxy({},{get:(t,r)=>{if(r!=="then")return r==="run"?()=>!1:()=>e}});return e}createCan(e){let{rawCommands:t,state:r}=this,i=!1,s=e||r.tr,o=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}static createFallbackCan(){let e=Ua.createFakeChain();return new Proxy({chain:()=>e},{get:(t,r)=>{if(r!=="then")return r==="chain"?t.chain:()=>!1}})}buildProps(e,t=!0){let{rawCommands:r,editor:i,state:s}=this,{view:o}=i,l={tr:e,editor:i,view:o,state:Tr({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}},Mh=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{if(!n.isDestroyed){var t;e.dom.blur(),(t=window)===null||t===void 0||(t=t.getSelection())===null||t===void 0||t.removeAllRanges()}}),!0),vh=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),Ch=()=>({state:n,tr:e,dispatch:t})=>{let{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:s,$to:o})=>{n.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;let{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;let p=Oe(h);if(l.type.isTextblock){let{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},Eh=n=>e=>n(e),Th=()=>({state:n,dispatch:e})=>xi(n,e),Ah=(n,e)=>({editor:t,tr:r})=>{let{state:i}=t,s=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);let o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new C(r.doc.resolve(Math.max(o-1,0)))),!0},Nh=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;let i=n.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){let o=i.before(s),l=i.after(s);n.delete(o,l).scrollIntoView()}return!0}return!1};function J(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var Oh=n=>({tr:e,state:t,dispatch:r})=>{let i=J(n,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){let l=s.before(o),a=s.after(o);e.delete(l,a).scrollIntoView()}return!0}return!1},Dh=n=>({tr:e,dispatch:t})=>{let{from:r,to:i}=n;return t&&e.delete(r,i),!0},Ih=n=>n.content?/^text(\*|\+)/.test(n.content):!1,Aa=(n,e,t)=>{if(!n.parent.isInline||t==="left"&&n.pos>n.start()||t==="right"&&n.pos<n.end())return n.pos;let r=e.nodes[n.parent.type.name].spec;return Ih(r)?t==="left"?n.start()-1:n.end()+1:n.pos},Rh=(n,e,t)=>({from:Aa(n,t,"left"),to:Aa(e,t,"right")}),Ph=()=>({state:n,dispatch:e})=>{if(n.selection.empty)return!1;if(e){let t=n.tr,{ranges:r}=n.selection,i=n.selection instanceof C?n.selection.$from.marksAcross(n.selection.$to):null,s=t.steps.length;r.forEach(o=>{let l=t.mapping.slice(s),a=t.doc.resolve(l.map(o.$from.pos)),c=t.doc.resolve(l.map(o.$to.pos)),{from:u,to:d}=Rh(a,c,n.schema);t.deleteRange(u,d)}),t.selection.empty||t.setSelection(C.near(t.doc.resolve(t.selection.from))),i&&t.ensureMarks(i),t.scrollIntoView(),e(t)}return!0},Lh=()=>({commands:n})=>n.keyboardShortcut("Enter"),Bh=()=>({state:n,dispatch:e})=>Si(n,e);function ys(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function Cr(n,e,t={strict:!0}){let r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:ys(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function Ga(n,e,t={}){return n.find(r=>r.type===e&&Cr(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function Na(n,e,t={}){return!!Ga(n,e,t)}function bs(n,e,t){if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if((!r.node||!r.node.marks.some(a=>a.type===e))&&(r=n.parent.childBefore(n.parentOffset)),!r.node||!r.node.marks.some(a=>a.type===e))return;if(!t){let a=r.node.marks.find(c=>c.type===e);a&&(t=a.attrs)}if(!Ga([...r.node.marks],e,t))return;let i=r.index,s=n.start()+r.offset,o=i+1,l=s+r.node.nodeSize;for(;i>0&&Na([...n.parent.child(i-1).marks],e,t);)i-=1,s-=n.parent.child(i).nodeSize;for(;o<n.parent.childCount&&Na([...n.parent.child(o).marks],e,t);)l+=n.parent.child(o).nodeSize,o+=1;return{from:s,to:l}}function ze(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var zh=(n,e)=>({tr:t,state:r,dispatch:i})=>{let s=ze(n,r.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:u}=l;if(i){let d=bs(a,s,e);if(d&&d.from<=c&&d.to>=u){let f=C.create(o,d.from,d.to);t.setSelection(f)}}return!0},$h=n=>e=>{let t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function Xa(n){return n instanceof C}function bt(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function hs(n,e=null){if(!e)return null;let t=N.atStart(n),r=N.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;let i=t.from,s=r.to;return e==="all"?C.create(n,bt(0,i,s),bt(n.content.size,i,s)):C.create(n,bt(e,i,s),bt(e,i,s))}function Oa(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function Er(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Fh(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Vh=(n=null,e={})=>({editor:t,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};let o=()=>{(Er()||Oa())&&r.dom.focus(),Fh()&&!Er()&&!Oa()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};try{if(r.hasFocus()&&n===null||n===!1)return!0}catch{return!1}if(s&&n===null&&!Xa(t.state.selection))return o(),!0;let l=hs(i.doc,n)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},Hh=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),jh=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),Ya=n=>{let e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){let r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&Ya(r)}return n};function kr(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Ya(t)}function Za(n){return typeof n?.nodesBetween=="function"}function Wt(n,e,t){if(Za(n))return n;let r=typeof n=="object"&&n!==null;t={slice:!0,parseOptions:{},...t};let i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return b.fromArray(n.map(o=>e.nodeFromJSON(o)));let s=e.nodeFromJSON(n);return t.errorOnInvalidContent&&s.check(),s}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),Wt("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="",a=new rt({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Te.fromSchema(a).parseSlice(kr(n),t.parseOptions):Te.fromSchema(a).parse(kr(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let s=Te.fromSchema(e);return t.slice?s.parseSlice(kr(n),t.parseOptions).content:s.parse(kr(n),t.parseOptions)}return Wt("",e,t)}function Qa(n){return!("type"in n)}function ec(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof Y||i instanceof K))return;let s=n.mapping.maps[r],o=0;s.forEach((l,a,c,u)=>{o===0&&(o=u)}),n.setSelection(N.near(n.doc.resolve(o),t))}var Wh=(n,e,t)=>({tr:r,dispatch:i,editor:s})=>{if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l,a=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Wt(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{var o;l=Wt(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:u,to:d}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0,p=Qa(l)?l.content:[l];if(p.forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),u===d&&h){let{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,d+=1)}let m;if(f)Array.isArray(e)?m=e.map(g=>g.text||"").join(""):Za(e)?m=p.map(g=>{var y;return(y=g.text)!==null&&y!==void 0?y:""}).join(""):typeof e=="object"&&e&&e.text?m=e.text:m=e,r.insertText(m,u,d);else{m=b.from(p);let g=r.doc.resolve(u),y=g.node(),x=g.parentOffset===0,w=y.isText||y.isTextblock,v=y.content.size>0;x&&w&&v&&h&&(u=Math.max(0,u-1)),r.replaceWith(u,d,p)}t.updateSelection&&ec(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0};function tc(n){for(let e=0;e<n.edgeCount;e+=1){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var Kh=(n={})=>({tr:e,dispatch:t,editor:r})=>{let{pos:i,attrs:s,content:o,updateSelection:l=!0}=n,a;typeof i=="number"?a=e.doc.resolve(i):i?a=i:a=e.selection.$from;let c=tc(a.parent.contentMatchAt(a.index()));if(!c)return!1;let u=Object.keys(c.spec.attrs||{}),d=s?Object.fromEntries(Object.entries(s).filter(([h])=>u.includes(h))):{},f;if(o){let h=Wt(o,r.schema);f=c.createAndFill(d,h)}else f=c.createAndFill(d);return f?(t&&(e.insert(a.pos,f),l&&ec(e,e.steps.length-1,-1)),!0):!1},qh=()=>({state:n,dispatch:e})=>nl(n,e),Jh=()=>({state:n,dispatch:e})=>rl(n,e),_h=()=>({state:n,dispatch:e})=>fi(n,e),Uh=()=>({state:n,dispatch:e})=>mi(n,e),nc=(n,e)=>{let t=n.resolve(e),r=t.nodeBefore,i=t.nodeAfter;return!r||!i?!1:!r.type.spec.isolating&&!i.type.spec.isolating},Gh=()=>({state:n,dispatch:e,tr:t})=>{try{let r=Ot(n.doc,n.selection.$from.pos,-1);return r==null||!nc(n.doc,r)?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Xh=()=>({state:n,dispatch:e,tr:t})=>{try{let r=Ot(n.doc,n.selection.$from.pos,1);return r==null||!nc(n.doc,r)?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Yh=()=>({state:n,dispatch:e})=>Qn(n,e),Zh=()=>({state:n,dispatch:e})=>er(n,e);function rc(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Qh(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t==="Space"&&(t=" ");let r,i,s,o;for(let l=0;l<e.length-1;l+=1){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Er()||rc()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}var ep=n=>({editor:e,view:t,tr:r,dispatch:i})=>{let s=Qh(n).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{let u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function Ce(n,e,t={}){let{from:r,to:i,empty:s}=n.selection,o=e?J(e,n.schema):null,l=[];n.doc.nodesBetween(r,i,(u,d)=>{if(u.isText)return;let f=Math.max(r,d),h=Math.min(i,d+u.nodeSize);l.push({node:u,from:f,to:h})});let a=i-r,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>Cr(u.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=a}var tp=(n,e={})=>({state:t,dispatch:r})=>Ce(t,J(n,t.schema),e)?il(t,r):!1,np=()=>({state:n,dispatch:e})=>wi(n,e),rp=n=>({state:e,dispatch:t})=>{let r=J(n,e.schema);return ul(r)(e,t)},ip=()=>({state:n,dispatch:e})=>bi(n,e);function Ar(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Da(n,e){let t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}var sp=(n,e)=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null,l=Ar(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(s=J(n,r.schema)),l==="mark"&&(o=ze(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{s&&s===u.type&&(a=!0,i&&t.setNodeMarkup(d,void 0,Da(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(f=>{o===f.type&&(a=!0,i&&t.addMark(d,d+u.nodeSize,o.create(Da(f.attrs,e))))})})}),a},op=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),lp=()=>({tr:n,dispatch:e})=>{if(e){let t=new oe(n.doc);n.setSelection(t)}return!0},ap=()=>({state:n,dispatch:e})=>hi(n,e),cp=()=>({state:n,dispatch:e})=>gi(n,e),up=()=>({state:n,dispatch:e})=>sl(n,e),dp=()=>({state:n,dispatch:e})=>vi(n,e),fp=()=>({state:n,dispatch:e})=>Mi(n,e);function ps(n,e,t={},r={}){return Wt(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var hp=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{let{doc:a}=s;if(r.preserveWhitespace!=="full"){let c=ps(n,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});if(o){let u=Qa(c)?c.content:[c];s.replaceWith(0,a.content.size,u).setMeta("preventUpdate",!t)}return!0}return o&&s.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},n,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function ic(n,e){let t=ze(e,n.schema),{from:r,to:i,empty:s}=n.selection,o=[];s?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,a=>{o.push(...a.marks)});let l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function pp(n,e){let t=new At(n);return e.forEach(r=>{r.steps.forEach(i=>{t.step(i)})}),t}function mp(n,e){for(let t=n.depth;t>0;t-=1){let r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Nr(n){return e=>mp(e.$from,n)}function M(n,e,t){return n.config[e]===void 0&&n.parent?M(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?M(n.parent,e,t):null}):n.config[e]}function ks(n){return n.map(e=>{let t=M(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e,...ks(t())]:e}).flat(10)}function Ss(n,e){let t=Ae.fromSchema(e).serializeFragment(n),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(t),r.innerHTML}function sc(n,e){let t=new Map;for(let i of n){var r;let s=(r=t.get(i.type))!==null&&r!==void 0?r:new Map;s.set(i.name,i),t.set(i.type,s)}return[...Object.values(e.nodes),...Object.values(e.marks)].flatMap(i=>{var s;return Object.entries((s=i.spec.attrs)!==null&&s!==void 0?s:{}).map(([o,l])=>{var a;let c=(a=t.get(i.name))===null||a===void 0?void 0:a.get(o),u=Object.hasOwn(l,"default");return{type:i.name,name:o,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...c?.attribute,default:l.default,isRequired:!u,validate:l.validate}}})})}var gp={content:"string",marks:"string",group:"string",inline:"boolean",atom:"boolean",selectable:"boolean",draggable:"boolean",code:"boolean",whitespace:["pre","normal"],definingAsContext:"boolean",definingForContent:"boolean",defining:"boolean",isolating:"boolean",linebreakReplacement:"boolean"},yp={inclusive:"boolean",excludes:"string",group:"string",spanning:"boolean",code:"boolean"};function bp(n,e,t){return Object.fromEntries(Object.entries(e).flatMap(([r,i])=>{let s=n[r];if(s===void 0)return[];if(!(typeof i=="string"?typeof s===i:typeof s=="string"&&i.includes(s)))throw new RangeError(`Invalid schemaSpec field '${t}.${r}'`);return[[r,s]]}))}function Ia(n,e,t,r){return{...Object.fromEntries(Object.entries(e).filter(([i])=>i!=="attrs"&&!Object.hasOwn(r,i))),...bp(t,r,n),attrs:t.attrs}}function Ra(n,e,t){for(let r of Object.keys(e))if(!Object.hasOwn(n,r))throw new RangeError(`schemaSpec requires a local ${t} extension named '${r}'`);for(let r of Object.keys(n))if(!Object.hasOwn(e,r))throw new RangeError(`Local ${t} extension '${r}' is not in schemaSpec`)}function kp(n,e){Ra(n.nodes,e.nodes,"node"),Ra(n.marks,e.marks,"mark");let t=e.spec.nodes,r=e.spec.marks;return e.spec.nodes.forEach((i,s)=>{t=t.update(i,Ia(i,n.nodes[i],s,gp))}),e.spec.marks.forEach((i,s)=>{r=r.update(i,Ia(i,n.marks[i],s,yp))}),{topNode:e.topNodeType.name,nodes:t,marks:r}}function oc(n){let e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}function Kt(n){return{baseExtensions:n.filter(e=>e.type==="extension"),nodeExtensions:n.filter(e=>e.type==="node"),markExtensions:n.filter(e=>e.type==="mark")}}function xs(n){let e=[],{nodeExtensions:t,markExtensions:r}=Kt(n),i=[...t,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=t.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...o,...l];return n.forEach(c=>{let u=M(c,"addGlobalAttributes",{name:c.name,options:c.options,storage:c.storage,extensions:i});u&&u().forEach(d=>{let f;Array.isArray(d.types)?f=d.types:d.types==="*"?f=a:d.types==="nodes"?f=o:d.types==="marks"?f=l:f=[],f.forEach(h=>{Object.entries(d.attributes).forEach(([p,m])=>{e.push({type:h,name:p,attribute:{...s,...m}})})})})}),i.forEach(c=>{let u=M(c,"addAttributes",{name:c.name,options:c.options,storage:c.storage});if(!u)return;let d=u();Object.entries(d).forEach(([f,h])=>{let p={...s,...h};typeof p?.default=="function"&&(p.default=p.default()),p?.isRequired&&p?.default===void 0&&delete p.default,e.push({type:c.name,name:f,attribute:p})})}),e}function ms(n){return typeof n=="function"}function L(n,e=void 0,...t){return ms(n)?e?n.bind(e)(...t):n(...t):n}function Sp(n={}){return Object.keys(n).length===0&&n.constructor===Object}function xp(n){let e=[],t="",r=!1,i=!1,s=0,o=n.length;for(let l=0;l<o;l+=1){let a=n[l];if(a==="'"&&!i){r=!r,t+=a;continue}if(a==='"'&&!r){i=!i,t+=a;continue}if(!r&&!i){if(a==="("){s+=1,t+=a;continue}if(a===")"&&s>0){s-=1,t+=a;continue}if(a===";"&&s===0){e.push(t),t="";continue}}t+=a}return t&&e.push(t),e}function Pa(n){let e=[],t=xp(n||""),r=t.length;for(let i=0;i<r;i+=1){let s=t[i],o=s.indexOf(":");if(o===-1)continue;let l=s.slice(0,o).trim(),a=s.slice(o+1).trim();l&&a&&e.push([l,a])}return e}function G(...n){return n.filter(e=>!!e).reduce((e,t)=>{let r={...e};return Object.entries(t).forEach(([i,s])=>{if(i==="__proto__"){Object.defineProperty(r,i,{configurable:!0,enumerable:!0,value:s,writable:!0});return}if(!r[i]){r[i]=s;return}if(i==="class"){let o=s?String(s).split(" "):[],l=r[i]?r[i].split(" "):[],a=o.filter(c=>!l.includes(c));r[i]=[...l,...a].join(" ")}else if(i==="style"){let o=new Map([...Pa(r[i]),...Pa(s)]);r[i]=Array.from(o.entries()).map(([l,a])=>`${l}: ${a}`).join("; ")}else r[i]=s}),r},{})}function qt(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>G(t,r),{})}function wp(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function La(n,e){return"style"in n?n:{...n,getAttrs:t=>{let r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;let i=e.reduce((s,o)=>{let l=o.attribute.parseHTML?o.attribute.parseHTML(t):wp(t.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function Ba(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Sp(t)?!1:t!=null))}function za(n){var e,t;let r={};return!(!(n==null||(e=n.attribute)===null||e===void 0)&&e.isRequired)&&"default"in(n?.attribute||{})&&(r.default=n.attribute.default),(n==null||(t=n.attribute)===null||t===void 0?void 0:t.validate)!==void 0&&(r.validate=n.attribute.validate),[n.name,r]}function $a(n,e,t=xs(n)){var r;let{nodeExtensions:i,markExtensions:s}=Kt(n);return{topNode:(r=i.find(o=>M(o,"topNode")))===null||r===void 0?void 0:r.name,nodes:Object.fromEntries(i.map(o=>{let l=t.filter(h=>h.type===o.name),a={name:o.name,options:o.options,storage:o.storage,editor:e},c=Ba({...n.reduce((h,p)=>{let m=M(p,"extendNodeSchema",a);return{...h,...m?m(o):{}}},{}),content:L(M(o,"content",a)),marks:L(M(o,"marks",a)),group:L(M(o,"group",a)),inline:L(M(o,"inline",a)),atom:L(M(o,"atom",a)),selectable:L(M(o,"selectable",a)),draggable:L(M(o,"draggable",a)),code:L(M(o,"code",a)),whitespace:L(M(o,"whitespace",a)),linebreakReplacement:L(M(o,"linebreakReplacement",a)),defining:L(M(o,"defining",a)),isolating:L(M(o,"isolating",a)),attrs:Object.fromEntries(l.map(za))}),u=L(M(o,"parseHTML",a));u&&(c.parseDOM=u.map(h=>La(h,l)));let d=M(o,"renderHTML",a);d&&(c.toDOM=h=>d({node:h,HTMLAttributes:qt(h,l)}));let f=M(o,"renderText",a);return f&&(c.toText=f),[o.name,c]})),marks:Object.fromEntries(s.map(o=>{let l=t.filter(f=>f.type===o.name),a={name:o.name,options:o.options,storage:o.storage,editor:e},c=Ba({...n.reduce((f,h)=>{let p=M(h,"extendMarkSchema",a);return{...f,...p?p(o):{}}},{}),inclusive:L(M(o,"inclusive",a)),excludes:L(M(o,"excludes",a)),group:L(M(o,"group",a)),spanning:L(M(o,"spanning",a)),code:L(M(o,"code",a)),attrs:Object.fromEntries(l.map(za))}),u=L(M(o,"parseHTML",a));u&&(c.parseDOM=u.map(f=>La(f,l)));let d=M(o,"renderHTML",a);return d&&(c.toDOM=f=>d({mark:f,HTMLAttributes:qt(f,l)})),[o.name,c]}))}}function lc(n,e,t){if(t===void 0)return new rt($a(n,e));let r=oc(n.filter(o=>o.type!=="extension").map(o=>o.name));if(r.length)throw new RangeError(`Duplicate local schema types: ${r.join(", ")}`);let i=new rt(t),s=$a(n,e,sc(xs(n),i));return new rt(kp(s,i))}function Nn(n){return n.sort((t,r)=>{let i=M(t,"priority")||100,s=M(r,"priority")||100;return i>s?-1:i<s?1:0})}function ws(n){let e=Nn(ks(n)),t=oc(e.map(r=>r.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function ac(n,e){return lc(ws(n),e)}function cc(n,e,t){let{from:r,to:i}=e,{blockSeparator:s=`
11
-
12
- `,textSerializers:o={}}=t||{},l="";return n.nodesBetween(r,i,(a,c,u,d)=>{a.isBlock&&c>r&&(l+=s);let f=o?.[a.type.name];if(f)return u&&(l+=f({node:a,pos:c,parent:u,index:d,range:e})),!1;if(a.isText){var h;l+=a==null||(h=a.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,i-c)}}),l}function Mp(n,e){return cc(n,{from:0,to:n.content.size},e)}function uc(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function vp(n,e){let t=J(e,n.schema),{from:r,to:i}=n.selection,s=[];n.doc.nodesBetween(r,i,l=>{s.push(l)});let o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function Cp(n,e){let t=Ar(typeof e=="string"?e:e.name,n.schema);return t==="node"?vp(n,e):t==="mark"?ic(n,e):{}}function Ep(n,e=JSON.stringify){let t={};return n.filter(r=>{let i=e(r);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function Tp(n){let e=Ep(n);return e.length===1?e:e.filter((t,r)=>!e.filter((i,s)=>s!==r).some(i=>t.oldRange.from>=i.oldRange.from&&t.oldRange.to<=i.oldRange.to&&t.newRange.from>=i.newRange.from&&t.newRange.to<=i.newRange.to))}function Or(n){let{mapping:e,steps:t}=n,r=[],i=e.invert();return e.maps.forEach((s,o)=>{let l=[];if(s.ranges.length)s.forEach((c,u)=>{l.push({from:c,to:u})});else{let{from:c,to:u}=t[o];if(c===void 0||u===void 0)return;l.push({from:c,to:u})}let a=e.slice(o);l.forEach(({from:c,to:u})=>{let d=a.map(c,-1),f=a.map(u),h=i.map(d,-1),p=i.map(f);r.push({oldRange:{from:h,to:p},newRange:{from:d,to:f}})})}),Tp(r)}function dc(n,e,t){let r=[];return n===e?t.resolve(n).marks().forEach(i=>{let s=bs(t.resolve(n),i.type);s&&r.push({mark:i,...s})}):t.nodesBetween(n,e,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var fc=(n,e,t,r=20)=>{let i=n.doc.resolve(t),s=r,o=null;for(;s>0&&o===null;){let l=i.node(s);l?.type.name===e?o=l:s-=1}return[o,s]},hc=n=>{let e=n.depth-1;if(e<0)return null;let t=n.index(e);return t===0?null:n.node(e).child(t-1)};function $t(n,e){return e.nodes[n]||e.marks[n]||null}function vr(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{let i=n.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var Ap=(n,e=500)=>{let t="",r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,l)=>{var a,c;let u=((a=(c=i.type.spec).toText)===null||a===void 0?void 0:a.call(c,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-s))}),t};function gs(n,e,t={}){let{empty:r,ranges:i}=n.selection,s=e?ze(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>s?s.name===u.type.name:!0).find(u=>Cr(u.attrs,t,{strict:!1}));let o=0,l=[];if(i.forEach(({$from:u,$to:d})=>{let f=u.pos,h=d.pos;n.doc.nodesBetween(f,h,(p,m)=>{if(s&&p.inlineContent&&!p.type.allowsMarkType(s))return!1;if(!p.isText&&!p.marks.length)return;let g=Math.max(f,m),y=Math.min(h,m+p.nodeSize),x=y-g;o+=x,l.push(...p.marks.map(w=>({mark:w,from:g,to:y})))})}),o===0)return!1;let a=l.filter(u=>s?s.name===u.mark.type.name:!0).filter(u=>Cr(u.mark.attrs,t,{strict:!1})).reduce((u,d)=>u+d.to-d.from,0),c=l.filter(u=>s?u.mark.type!==s&&u.mark.type.excludes(s):!0).reduce((u,d)=>u+d.to-d.from,0);return(a>0?a+c:a)>=o}function Np(n,e,t={}){if(!e)return Ce(n,null,t)||gs(n,null,t);let r=Ar(e,n.schema);return r==="node"?Ce(n,e,t):r==="mark"?gs(n,e,t):!1}var pc=(n,e)=>{let{$from:t,$to:r,$anchor:i}=n.selection;if(e){let s=Nr(l=>l.type.name===e)(n.selection);if(!s)return!1;let o=n.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},mc=n=>{let{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Fa(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Tn(n,e){let{nodeExtensions:t}=Kt(e),r=t.find(s=>s.name===n);if(!r)return!1;let i=L(M(r,"group",{name:r.name,options:r.options,storage:r.storage}));return typeof i!="string"?!1:i.split(" ").includes("list")}function Jt(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){if(t){if(n.type.name==="hardBreak")return!0;if(n.isText){var r;return!/\S/.test((r=n.text)!==null&&r!==void 0?r:"")}}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(s=>{i!==!1&&(Jt(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function gc(n){return n instanceof T}function Op(n){if(n===null||typeof n!="object")return!1;let e=n;return!(typeof e.apply!="function"||typeof e.getMap!="function"||typeof e.invert!="function"||typeof e.map!="function"||typeof e.merge!="function"||typeof e.toJSON!="function")}function Dp(n){if(n===null||typeof n!="object")return!1;let e=n;if(!Op(e))return!1;let t=e.toJSON();return!(t===null||typeof t!="object"||t.stepType!=="replace")}var yc=class bc{constructor(e){this.position=e}static fromJSON(e){return new bc(e.position)}toJSON(){return{position:this.position}}};function Ip(n,e){let t=e.mapping.mapResult(n.position);return{position:new yc(t.pos),mapResult:t}}function Rp(n){return new yc(n)}function Pp(n,e,t){let{selection:r}=e,i=null;if(Xa(r)&&(i=r.$cursor),i){var s;let l=(s=n.storedMarks)!==null&&s!==void 0?s:i.marks();return i.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(a=>a.type.excludes(t)))}let{ranges:o}=r;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){let h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}var Lp=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let{selection:s}=t,{empty:o,ranges:l}=s,a=ze(n,r.schema);if(i)if(o){let c=ic(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{let u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{let p=Math.max(h,u),m=Math.min(h+f.nodeSize,d);f.marks.find(g=>g.type===a)?f.marks.forEach(g=>{a===g.type&&t.addMark(p,m,a.create({...g.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return Pp(r,t,a)},Bp=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),zp=(n,e={})=>({state:t,dispatch:r,chain:i})=>{let s=J(n,t.schema),o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>Ci(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Ci(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},$p=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,i=bt(n,0,r.content.size),s=T.create(r,i);e.setSelection(s)}return!0},Fp=(n,e)=>({tr:t,state:r,dispatch:i})=>{let{selection:s}=r,o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),i&&t.doc.nodesBetween(o,l,(a,c)=>{a.isText||t.setNodeMarkup(c,void 0,{...a.attrs,dir:n})}),!0},Vp=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,{from:i,to:s}=typeof n=="number"?{from:n,to:n}:n,o=C.atStart(r).from,l=C.atEnd(r).to,a=bt(i,o,l),c=bt(s,o,l),u=C.create(r,a,c);e.setSelection(u)}return!0},Hp=n=>({state:e,dispatch:t})=>{let r=J(n,e.schema);return dl(r)(e,t)};function Va(n,e){let t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){let r=t.filter(i=>e?.includes(i.type.name));n.tr.ensureMarks(r)}}var jp=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{let{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,u=vr(c,l.node().type.name,l.node().attrs);if(s instanceof T&&s.node.isBlock)return!l.parentOffset||!me(o,l.pos)?!1:(r&&(n&&Va(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:tc(l.node(-1).contentMatchAt(l.indexAfter(-1))),h=d&&f?[{type:f,attrs:u}]:void 0,p=s instanceof C&&!s.empty?st.create({doc:e.doc,selection:s}).tr.deleteSelection():null,m=p?p.doc:e.doc,g=p?p.mapping.map(l.pos):l.pos,y=me(m,g,1,h);if(!h&&!y&&me(m,g,1,f?[{type:f}]:void 0)&&(y=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(y){let x=e.steps.length;if(s instanceof C&&e.deleteSelection(),e.split(e.mapping.slice(x).map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f){let w=e.mapping.slice(x).map(l.before()),v=e.doc.resolve(w);l.node(-1).canReplaceWith(v.index(),v.index()+1,f)&&e.setNodeMarkup(e.mapping.slice(x).map(l.before()),f)}}n&&Va(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return y},Wp=(n,e={})=>({tr:t,state:r,dispatch:i,editor:s})=>{let o=J(n,r.schema),{$from:l,$to:a}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;let u=l.node(-1);if(u.type!==o)return!1;let d=s.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){var f;let v=b.empty,I=l.index(-1)?1:l.index(-2)?2:3;for(let xe=l.depth-I;xe>=l.depth-3;xe-=1)v=b.from(l.node(xe).copy(v));let H=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,A={...vr(d,l.node().type.name,l.node().attrs),...e},R=((f=o.contentMatch.defaultType)===null||f===void 0?void 0:f.createAndFill(A))||void 0;v=v.append(b.from(o.createAndFill(null,R)||void 0));let z=l.before(l.depth-(I-1));t.replace(z,l.after(-H),new k(v,4-I,0));let $=-1;t.doc.nodesBetween(z,t.doc.content.size,(xe,Ge)=>{if($>-1)return!1;xe.isTextblock&&xe.content.size===0&&($=Ge+1)}),$>-1&&t.setSelection(C.near(t.doc.resolve($))),t.scrollIntoView()}return!0}let h=a.pos===l.end()?u.contentMatchAt(0).defaultType:null,p={...vr(d,u.type.name,u.attrs),...e},m={...vr(d,l.node().type.name,l.node().attrs),...e},g=l.parentOffset===0&&l.index(-1)===0,y=l.before(-1);t.delete(l.pos,a.pos);let x=g?u.attrs:p,w=h?[{type:o,attrs:x},{type:h,attrs:m}]:[{type:o,attrs:x}];if(!me(t.doc,l.pos,2))return!1;if(i){let{selection:v,storedMarks:I}=r,{splittableMarks:H}=s.extensionManager,A=I||v.$to.parentOffset&&v.$from.marks();if(t.split(l.pos,2,w).scrollIntoView(),g&&t.setNodeMarkup(y,void 0,p),!A||!i)return!0;let R=A.filter(z=>H.includes(z.type.name));t.ensureMarks(R)}return!0};function kc(n,e,t){if(!n.validContent(e))return null;try{return n.create(t,e)}catch{return null}}function Ms(n,e){if(n.pendingContent.length===0)return!0;let t=kc(e,b.from(n.pendingContent));return t?(n.items.push(t),n.pendingContent=[],!0):!1}function Kp(n,e,t){return t.validContent(b.from([...e.pendingContent,n]))?(e.pendingContent.push(n),!0):!Ms(e,t)||!t.validContent(b.from(n))?!1:(e.pendingContent.push(n),!0)}function qp(n,e,t,r){let i=r(n,t);if(!i)return!1;let s=kc(t.listType,b.from(i),n.attrs);return s?t.itemType.validContent(b.from([...e.pendingContent,s]))?(e.pendingContent.push(s),!0):Ms(e,t.itemType)?(e.items.push(...i),!0):!1:!1}function Jp(n,e,t){let r={items:[],pendingContent:[]};for(let i=0;i<n.childCount;i+=1){let s=n.child(i);if(!(e.isListNode(s)?qp(s,r,e,t):Kp(s,r,e.itemType)))return null}return Ms(r,e.itemType)?r.items:null}function Sc(n,e){let t=[];for(let r=0;r<n.childCount;r+=1){let i=Jp(n.child(r),e,Sc);if(!i)return null;t.push(...i)}return t}function Ha(n,e){let t=null;return n.descendants((r,i)=>r!==e?!0:(t=i,!1)),t}function ja(n){return!n||n==="1"?null:n}function xc(n,e){return ja(n)===ja(e)}var Sr=(n,e)=>{let t=Nr(s=>s.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;let i=n.doc.nodeAt(r);return!(t.node.type===i?.type&&ke(n.doc,t.pos))||!xc(t.node.attrs.type,i?.attrs.type)||n.join(t.pos),!0},xr=(n,e)=>{let t=Nr(s=>s.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;let i=n.doc.nodeAt(r);return!(t.node.type===i?.type&&ke(n.doc,r))||!xc(t.node.attrs.type,i?.attrs.type)||n.join(r),!0};function _p(n){let e=n.doc,t=e.firstChild;if(!t)return null;let r=e.resolve(1),i=e.resolve(t.nodeSize-1);return C.between(r,i)}var Up=(n,e,t,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,h=J(n,o.schema),p=J(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:x}=m,w=y.blockRange(x),v=g||m.$to.parentOffset&&m.$from.marks();if(!w)return!1;let I=Nr(fe=>Tn(fe.type.name,d))(m),H=m.from===0&&m.to===o.doc.content.size,A=o.doc.content.content,R=A.length===1?A[0]:null,z=H&&R&&Tn(R.type.name,d)?{node:R,pos:0,depth:0}:null,$=I??z,xe=!!I&&w.depth>=1&&w.depth-I.depth<=1,Ge=!!z;if((xe||Ge)&&$){if($.node.type===h)return H&&Ge?a().command(({tr:fe,dispatch:Ee})=>{let he=_p(fe);return he?(fe.setSelection(he),Ee&&Ee(fe),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(Tn($.node.type.name,d)&&h.validContent($.node.content))return a().command(()=>(s.setNodeMarkup($.pos,h),!0)).command(()=>Sr(s,h)).command(()=>xr(s,h)).run();if(Tn($.node.type.name,d)){var Xe;let fe=(Xe=$.node.firstChild)===null||Xe===void 0?void 0:Xe.type;if(fe&&fe!==p){let Ee=Sc($.node,{listType:h,itemType:p,isListNode:Ye=>Tn(Ye.type.name,d)}),he=Ee?b.from(Ee):null;return!he||!h.validContent(he)?!1:a().command(()=>{let{$anchor:Ye,$head:Yt}=s.selection,In=Ye.parent,Zt=Yt.parent,xt=Ye.parentOffset,Rn=Yt.parentOffset,Ze;try{Ze=h.create(r,he)}catch{return!1}if(s.replaceWith($.pos,$.pos+$.node.nodeSize,Ze),In.inlineContent&&Zt.inlineContent){let wt=Ha(Ze,In),Qt=Ha(Ze,Zt);if(wt!==null&&Qt!==null){let en=$.pos+wt+2+xt,S=$.pos+Qt+2+Rn;s.setSelection(C.create(s.doc,en,S))}}return!0}).command(()=>Sr(s,h)).command(()=>xr(s,h)).run()}}}return!t||!v||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Sr(s,h)).command(()=>xr(s,h)).run():a().command(()=>{let fe=u().wrapInList(h,r),Ee=v.filter(he=>f.includes(he.type.name));return s.ensureMarks(Ee),fe?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Sr(s,h)).command(()=>xr(s,h)).run()},Gp=(n,e={},t={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:s=!1}=t,o=ze(n,r.schema);return gs(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},Xp=(n,e,t={})=>({state:r,commands:i})=>{let s=J(n,r.schema),o=J(e,r.schema),l=Ce(r,s,t),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?i.setNode(o,a):i.setNode(s,{...a,...t})},Yp=(n,e={})=>({state:t,commands:r})=>{let i=J(n,t.schema);return Ce(t,i,e)?r.lift(i):r.wrapIn(i,e)},Zp=()=>({state:n,dispatch:e})=>{let t=n.plugins;for(let r=0;r<t.length;r+=1){let i=t[r],s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){let o=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},Qp=(n={})=>({tr:e,dispatch:t,editor:r})=>{let{ignoreClearable:i=!1}=n,{selection:s}=e,{empty:o,ranges:l}=s;if(o)return!0;let{nonClearableMarks:a}=r.extensionManager;if(t){let c=Object.values(r.schema.marks).filter(u=>i||!a.includes(u.name));l.forEach(u=>{for(let d of c)e.removeMark(u.$from.pos,u.$to.pos,d)})}return!0},em=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let{extendEmptyMarkRange:s=!1}=e,{selection:o}=t,l=ze(n,r.schema),{$from:a,empty:c,ranges:u}=o;if(!i)return!0;if(c&&s){var d;let{from:f,to:h}=o,p=bs(a,l,(d=a.marks().find(m=>m.type===l))===null||d===void 0?void 0:d.attrs);p&&(f=p.from,h=p.to),t.removeMark(f,h,l)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,l)});return t.removeStoredMark(l),!0},tm=n=>({tr:e,state:t,dispatch:r})=>{let{selection:i}=t,s,o;return typeof n=="number"?(s=n,o=n):n&&"from"in n&&"to"in n?(s=n.from,o=n.to):(s=i.from,o=i.to),r&&e.doc.nodesBetween(s,o,(l,a)=>{if(l.isText)return;let c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},nm=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null,l=Ar(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(s=J(n,r.schema)),l==="mark"&&(o=ze(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{let u=c.$from.pos,d=c.$to.pos,f,h,p,m;t.selection.empty?r.doc.nodesBetween(u,d,(g,y)=>{s&&s===g.type&&(a=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),f=y,h=g)}):r.doc.nodesBetween(u,d,(g,y)=>{y<u&&s&&s===g.type&&(a=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),f=y,h=g),y>=u&&y<=d&&(s&&s===g.type&&(a=!0,i&&t.setNodeMarkup(y,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(x=>{if(o===x.type&&(a=!0,i)){let w=Math.max(y,u),v=Math.min(y+g.nodeSize,d);t.addMark(w,v,o.create({...x.attrs,...e}))}}))}),h&&(f!==void 0&&i&&t.setNodeMarkup(f,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&i&&t.addMark(p,m,o.create({...g.attrs,...e}))}))}),a},Vt=new W("__tiptap_decorations__"),rm=n=>({tr:e,dispatch:t})=>(t&&e.setMeta(Vt,{type:"force",name:n}),!0),im=(n,e={})=>({state:t,dispatch:r})=>{let i=J(n,t.schema);return al(i,e)(t,r)},sm=(n,e={})=>({state:t,dispatch:r})=>{let i=J(n,t.schema);return cl(i,e)(t,r)},om=Zs({blur:()=>Mh,clearContent:()=>vh,clearNodes:()=>Ch,command:()=>Eh,createParagraphNear:()=>Th,cut:()=>Ah,deleteCurrentNode:()=>Nh,deleteNode:()=>Oh,deleteRange:()=>Dh,deleteSelection:()=>Ph,enter:()=>Lh,exitCode:()=>Bh,extendMarkRange:()=>zh,first:()=>$h,focus:()=>Vh,forEach:()=>Hh,insertContent:()=>jh,insertContentAt:()=>Wh,insertDefaultBlock:()=>Kh,joinBackward:()=>_h,joinDown:()=>Jh,joinForward:()=>Uh,joinItemBackward:()=>Gh,joinItemForward:()=>Xh,joinTextblockBackward:()=>Yh,joinTextblockForward:()=>Zh,joinUp:()=>qh,keyboardShortcut:()=>ep,lift:()=>tp,liftEmptyBlock:()=>np,liftListItem:()=>rp,newlineInCode:()=>ip,resetAttributes:()=>sp,scrollIntoView:()=>op,selectAll:()=>lp,selectNodeBackward:()=>ap,selectNodeForward:()=>cp,selectParentNode:()=>up,selectTextblockEnd:()=>dp,selectTextblockStart:()=>fp,setContent:()=>hp,setMark:()=>Lp,setMeta:()=>Bp,setNode:()=>zp,setNodeSelection:()=>$p,setTextDirection:()=>Fp,setTextSelection:()=>Vp,sinkListItem:()=>Hp,splitBlock:()=>jp,splitListItem:()=>Wp,toggleList:()=>Up,toggleMark:()=>Gp,toggleNode:()=>Xp,toggleWrap:()=>Yp,undoInputRule:()=>Zp,unsetAllMarks:()=>Qp,unsetMark:()=>em,unsetTextDirection:()=>tm,updateAttributes:()=>nm,updateDecorations:()=>rm,wrapIn:()=>im,wrapInList:()=>sm}),Ht=new WeakMap;function lm(n,e){var t;Ht.set(n,((t=Ht.get(n))!==null&&t!==void 0?t:0)+1);try{return e()}finally{var r;let i=((r=Ht.get(n))!==null&&r!==void 0?r:1)-1;i>0?Ht.set(n,i):Ht.delete(n)}}function am(n){return Ht.has(n)}var cm=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){let t=this.callbacks[n];return t&&t.forEach(r=>r.apply(this,e)),this}off(n,e){let t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(r=>r!==e):delete this.callbacks[n]),this}once(n,e){let t=(...r)=>{this.off(n,t),e.apply(this,r)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},wc=typeof process<"u"&&!1;function um(n){return n.kind==="widget"}function Mc(n,e){let t=[],r=new Set;for(let i of n)i.kind==="widget"&&um(i)&&r.add(i.key),t.push(i.toPMDecoration(e));return{decorations:t,widgetKeys:r}}function dm(n,e,t){let{decorations:r,widgetKeys:i}=Mc(e,t);return{set:B.create(n,r),widgetKeys:i}}function vc({position:n,from:e,to:t,docSize:r}){return n<e?!1:n<t?!0:n===t&&t===r}function fm({decorations:n,from:e,to:t,docSize:r,extensionName:i,warnedExtensions:s}){return n.filter(o=>vc({position:o.anchor,from:e,to:t,docSize:r})?!0:(o.anchor===t||s.has(i)||(s.add(i),console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${e}, ${t}). It was ignored.`)),!1))}function Cc(n){var e;let t=(e=n.spec)===null||e===void 0?void 0:e.key;return typeof t=="string"?t:void 0}function hm(n){let e=new Map,t=new Map;for(let o of n.find()){var r,i,s;let l=Cc(o);if(!l)continue;let a=(r=o.spec.extensionName)!==null&&r!==void 0?r:"unknown",c=(i=e.get(l))!==null&&i!==void 0?i:new Set;c.add(a),e.set(l,c),t.set(l,((s=t.get(l))!==null&&s!==void 0?s:0)+1)}return Array.from(e,([o,l])=>({key:o,extensions:l})).filter(({key:o})=>{var l;return((l=t.get(o))!==null&&l!==void 0?l:0)>1})}function Ec(n){return n.jsonID==="attr"}function pm(n){let e=!1;if(n.getMap().forEach(()=>{e=!0}),e||Ec(n))return!0;let t=n;return typeof t.from=="number"&&typeof t.to=="number"}function mm(n,e){let t=null,r=0,i=0;for(let s=0;s<n.childCount&&!(i>e.to);s+=1){let o=i+n.child(s).nodeSize;o>=e.from&&(t===null&&(t=i),r=o),i=o}return t===null?null:{from:t,to:r}}function gm(n,e){if(n.steps.some(s=>!pm(s)))return{type:"full"};let t=Or(n).map(({newRange:s})=>s);n.steps.forEach((s,o)=>{if(!Ec(s))return;let l=n.mapping.slice(o);t.push({from:l.map(s.pos,-1),to:l.map(s.pos+1)})});let r=[];for(let s of t){let o=mm(e,s);o&&r.push(o)}r.sort((s,o)=>s.from-o.from);let i=[];for(let s of r){let o=i[i.length-1];o&&s.from<=o.to?o.to=Math.max(o.to,s.to):i.push({...s})}return{type:"ranges",ranges:i}}function Tc(n,e,t,r){return n.map(e,t,{onRemove:i=>{let s=i?.key;typeof s=="string"&&r.delete(s)}})}function ym(n,e,t){var r,i;let s=(r=e.decorationSetsByExtension[n])!==null&&r!==void 0?r:B.empty,o=new Set((i=e.widgetKeysByExtension[n])!==null&&i!==void 0?i:[]);return{set:Tc(s,t.mapping,t.doc,o),widgetKeys:o}}function Wa(n,e){let t=Object.values(e).flatMap(r=>r.find());return B.create(n,t)}function Ka(n){let e=new Set;for(let t of Object.values(n))for(let r of t)e.add(r);return e}function bm(n,e){var t;switch((t=e.update)!==null&&t!==void 0?t:"document"){case"document":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${n}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!e.createInRange)throw new Error(`[tiptap error]: Extension "${n}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${n}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(e.shouldUpdate)throw new Error(`[tiptap error]: Extension "${n}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension "${n}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function km(n,e,t){return t?!0:n.update==="manual"?!1:n.shouldUpdate?n.shouldUpdate(e):e.tr.docChanged}var Sm=new Set;var xm=class{constructor(n){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let t=Vt.getState(e);t&&this.warnDuplicateWidgetKeys(t)},this.editor=n.editor,this.entries=this.resolveEntries(n.entries),this.entries.forEach(({name:e,spec:t})=>bm(e,t)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on("beforeTransaction",this.handleBeforeTransaction)}destroy(){this.editor.off("beforeTransaction",this.handleBeforeTransaction)}liveWidgetKeys(){var n,e;return(n=(e=Vt.getState(this.editor.state))===null||e===void 0?void 0:e.widgetKeys)!==null&&n!==void 0?n:Sm}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(n){let e=[];for(let{name:t,addDecorations:r}of n){let i=r();i&&e.push({name:t,spec:i})}return e}createPlugin(){let{editor:n,entries:e}=this;return new P({key:Vt,state:{init:(t,r)=>{let i={},s={};for(let{name:l,spec:a}of e){let{set:c,widgetKeys:u}=this.buildFullSet(l,a,r);i[l]=c,s[l]=u}let o={decorationSetsByExtension:i,widgetKeysByExtension:s,mergedDecorationSet:this.buildMergedSet(r.doc,i),widgetKeys:Ka(s)};return this.warnDuplicateWidgetKeys(o),o},apply:(t,r,i,s)=>{let o=t.getMeta(Vt),l=o?.type==="force"&&!o.name,a=o?.type==="force"?o.name:void 0,c={},u={},d=new Set;return lm(n,()=>{for(let{name:f,spec:h}of e){let p=l||a===f;if(km(h,{editor:n,tr:t,oldState:i,newState:s},p))if(h.update==="changedRanges"&&t.docChanged&&!p){let m=this.applyChangedRangesRecompute(f,h,r,t,s);c[f]=m.set,u[f]=m.widgetKeys,d.add(f)}else{let{set:m,widgetKeys:g}=this.buildFullSet(f,h,s);c[f]=m,u[f]=g,d.add(f)}else{let m=ym(f,r,t);c[f]=m.set,u[f]=m.widgetKeys}}}),d.size===0&&!t.docChanged?r:{decorationSetsByExtension:c,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:e,previous:r,tr:t,decorationSetsByExtension:c,recomputedNames:d}),widgetKeys:Ka(u)}}},props:{decorations(t){var r,i;return(r=(i=Vt.getState(t))===null||i===void 0?void 0:i.mergedDecorationSet)!==null&&r!==void 0?r:B.empty}}})}applyChangedRangesRecompute(n,e,t,r,i){let s=gm(r,i.doc);return s.type==="full"?this.buildFullSet(n,e,i):this.rebuildRanges(n,e,t,r,i,s.ranges)}rebuildRanges(n,e,t,r,i,s){var o,l;let a=(o=t.decorationSetsByExtension[n])!==null&&o!==void 0?o:B.empty,c=new Set((l=t.widgetKeysByExtension[n])!==null&&l!==void 0?l:[]),u=Tc(a,r.mapping,r.doc,c),d=i.doc.content.size;for(let{from:f,to:h}of s){let p=u.find(f,h).filter(y=>vc({position:y.from,from:f,to:h,docSize:d}));for(let y of p){let x=Cc(y);x&&c.delete(x)}u=u.remove(p);let{decorations:m,widgetKeys:g}=Mc(fm({decorations:this.runCreate(n,"createInRange",()=>e.createInRange({editor:this.editor,state:i,view:this.mountedView,from:f,to:h})),from:f,to:h,docSize:d,extensionName:n,warnedExtensions:this.warnedOutOfRangeExtensions}),n);u=u.add(i.doc,m);for(let y of g)c.add(y)}return{set:u,widgetKeys:c}}buildFullSet(n,e,t){let r=this.runCreate(n,"create",()=>e.create({editor:this.editor,state:t,view:this.mountedView}));return dm(t.doc,r,n)}runCreate(n,e,t){try{return t()}catch(r){return console.error(`[tiptap error]: Extension "${n}" threw in \`addDecorations().${e}()\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(n){if(!wc)return;if(n.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let e=hm(n.mergedDecorationSet),t=new Set(e.map(({key:r})=>r));for(let{key:r,extensions:i}of e){if(this.warnedWidgetKeys.has(r))continue;let s=Array.from(i).map(o=>`"${o}"`).join(", ");console.warn(`[tiptap warn]: Duplicate widget decoration key "${r}" in extension${i.size===1?"":"s"} ${s}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=t}buildMergedSet(n,e){let t=Object.keys(e);return t.length===1?e[t[0]]:Wa(n,e)}mergeAfterApply({entries:n,previous:e,tr:t,decorationSetsByExtension:r,recomputedNames:i}){return n.length===1?r[n[0].name]:i.size===0?e.mergedDecorationSet.map(t.mapping,t.doc):Wa(t.doc,r)}};function wm(n,e,t){let r=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(r!==null)return r;let i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}function Mm(n){return typeof n=="number"}function vm(n){return Object.prototype.toString.call(n).slice(8,-1)}function wr(n){return vm(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Cm(n,e){return n.replace(/^[ \t]*/,t=>{let i=0;for(let s of t)i+=s===" "?4-i%4:1;return" ".repeat(Math.max(0,i-e))})}function Em(n,e){let t=`text
1
+ var Pt="editor-form";async function Os(n,e){try{let t=await n.json(),r=typeof t=="object"&&t!==null?t.message:void 0;return typeof r=="string"&&r!==""?r:e}catch{return e}}async function Ku(n,e,t){return n.type==="opaqueredirect"||n.status===401?{kind:"error",message:e}:n.status===200?{kind:"page",html:await n.text()}:n.status===422?{kind:"incomplete",message:await Os(n,t)}:n.status===500?{kind:"error",message:await Os(n,t)}:{kind:"error",message:t}}function _u(n){let e=new URLSearchParams;for(let[t,r]of new FormData(n))e.append(t,typeof r=="string"?r:r.name);return e}function qu(n){let e,t=null,r=0;async function o(){e=void 0;let i=n.getForm();if(!i)return;t?.abort();let s=new AbortController;t=s;let l=++r;n.onStart();let a;try{let c=await n.fetch(n.url,{method:"POST",body:_u(i),redirect:"manual",credentials:"same-origin",signal:s.signal});a=await Ku(c,n.signedOutMessage,n.failedMessage)}catch{a={kind:"error",message:n.failedMessage}}l!==r||s.signal.aborted||(t=null,n.onResult(a))}return{schedule(){e!==void 0&&clearTimeout(e),e=setTimeout(()=>{o()},n.delay)},dispose(){e!==void 0&&clearTimeout(e),e=void 0,r++,t?.abort(),t=null}}}function Ju(n,e){try{return new URL(n.location.href).searchParams.get("n")===String(e)}catch{return!1}}function Uu(n){let e=0;function t(r){let o=++e,i=n.back(),s=()=>{if(o!==e){i.removeEventListener("load",s);return}let c=i.contentWindow,d=i.contentDocument;if(!c||!d||!Ju(c,o))return;i.removeEventListener("load",s),d.open(),c.history.replaceState(null,"",n.pagePath),d.write(r),d.close();let u=[...d.querySelectorAll('link[rel~="stylesheet"]')].filter(y=>y.sheet===null),f=u.length,h=!1,p,m=()=>{if(!h){h=!0,clearTimeout(p);for(let y of u)y.removeEventListener("load",g),y.removeEventListener("error",g);o===e&&n.onSwap()}},g=()=>{f--,f===0&&m()};if(f===0){m();return}for(let y of u)y.addEventListener("load",g),y.addEventListener("error",g);p=setTimeout(m,n.fallbackMs)};i.addEventListener("load",s);let l=`${n.blankUrl}${n.blankUrl.includes("?")?"&":"?"}n=${o}`,a=i.contentWindow;a?a.location.replace(l):i.src=l}return{write:t,cancel(){e++}}}var Gu=/^inlay:slot (.+)$/,Xu=/^\/inlay:slot (.+)$/;function zs(n){let e=new Map,t=n.createTreeWalker(n,128);for(let r=t.nextNode();r;r=t.nextNode()){let o=Gu.exec(r.nodeValue??"")?.[1];if(o===void 0)continue;let i=e.get(o)??[];for(let s=r.nextSibling;s&&!(s.nodeType===8&&Xu.exec(s.nodeValue??"")?.[1]===o);s=s.nextSibling)s.nodeType===1&&i.push(s);e.set(o,i)}return e}function Yu(n,e){for(let[t,r]of zs(n))if(r.some(o=>o.contains(e)))return t;return null}function Zu(n,e){return!(e>0)||!(n>0)?1:Math.min(1,n/e)}var Yn=n=>n instanceof Element&&n.closest(`#${Pt}`)!==null;function Qu(n){let e=n.detail,t=n.target;return t instanceof Element&&t.id===Pt||e?.target instanceof Element&&e.target.id===Pt}var po=!1;function mo(){let n=document.getElementById("save-state"),e=n?.dataset.textUnsaved;if(!n||e===void 0||po)return;po=!0;let t=document.createElement("span");t.className="inline-block h-2 w-2 rounded-full bg-warning",t.setAttribute("aria-hidden","true");let r=document.createElement("span");r.className="inline-flex items-center gap-1.5",r.append(t,e),n.replaceChildren(r)}function ef(n){let e=n.detail,t=e?.elt instanceof Element&&Yn(e.elt)||e?.target instanceof Element&&e.target.id===Pt,r=document.getElementById(Pt);if(!t||!r||!(e?.formData instanceof FormData))return;let o=[...r.querySelectorAll("details[data-item]")].filter(s=>s.open).map(s=>s.dataset.item??""),i=[...r.querySelectorAll("details[data-card]")].filter(s=>!s.open).map(s=>s.dataset.card??"");e.formData.set("_open",o.filter(s=>s!=="").join(",")),e.formData.set("_closed",i.filter(s=>s!=="").join(","))}var Zn=()=>{};document.addEventListener("input",n=>{Yn(n.target)&&(mo(),Zn())});document.addEventListener("change",n=>{Yn(n.target)&&(mo(),Zn())});document.addEventListener("htmx:afterSwap",n=>{Qu(n)&&(mo(),Zn())});document.addEventListener("htmx:configRequest",ef);document.addEventListener("inlay:saved",()=>{po=!1});var $s={desktop:1280,tablet:768,phone:390},Ds=n=>n!=null&&Object.hasOwn($s,n),uo="inlay.preview.device",Rs="inlay.preview.hidden",Is="inlay-preview-highlight",fo="opacity-60";function ho(n){try{return localStorage.getItem(n)}catch{return null}}function Ps(n,e){try{localStorage.setItem(n,e)}catch{}}var Ls=()=>window.matchMedia?.("(width < 64rem)").matches===!0,tf=['input:not([type="hidden"]):not([disabled])',"textarea:not([disabled])","select:not([disabled])",'[contenteditable="true"]',"button:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");function nf(n){let{pane:e,workspace:t,stage:r,device:o,first:i,status:s,announce:l,scaleText:a,hideButton:c,showButton:d}=n,u=i.dataset.previewUrl??i.getAttribute("src")??"",f=i.dataset.pagePath??"/",h={updating:s.dataset.textUpdating??"",ready:s.dataset.textReady??"",signedOut:s.dataset.textSignedOut??"",failed:s.dataset.textFailed??""},p=i.dataset.blankUrl??`${u}/blank`,m=i,g=i.cloneNode(!1);g.removeAttribute("id"),g.setAttribute("aria-hidden","true"),g.tabIndex=-1,g.style.visibility="hidden",g.src=p;let y=g,k=null,S=Ds(ho(uo))?ho(uo):"desktop",v=!1,D=x=>{s.textContent=x,s.title=x},$=x=>{D(x),l&&(l.textContent=x)};function E(x){let O=m.contentDocument;if(!O||(O.getElementById(Is)?.remove(),k===null))return;let _=zs(O).get(k)??[],_e=O.defaultView;if(_.length===0||!_e)return;let be=1/0,qe=1/0,ao=-1/0,co=-1/0;for(let ju of _){let Xn=ju.getBoundingClientRect();be=Math.min(be,Xn.top),qe=Math.min(qe,Xn.left),ao=Math.max(ao,Xn.right),co=Math.max(co,Xn.bottom)}let Gn=O.createElement("div");Gn.id=Is,Gn.setAttribute("aria-hidden","true"),Object.assign(Gn.style,{position:"absolute",top:`${be+_e.scrollY-4}px`,left:`${qe+_e.scrollX-4}px`,width:`${ao-qe+8}px`,height:`${co-be+8}px`,outline:"3px solid #1d4ed8",borderRadius:"4px",pointerEvents:"none",zIndex:"2147483647",margin:"0"}),O.documentElement.append(Gn),x&&_[0]?.scrollIntoView({block:"nearest"})}function R(x){let O=x!==k;k=x;for(let _ of document.querySelectorAll("details[data-card]"))_.classList.toggle("is-active",x!==null&&_.dataset.card===x);E(O)}function V(x){let O=[...document.querySelectorAll("details[data-card]")].find(be=>be.dataset.card===x);if(!O)return;O.open=!0,Ls()&&pn("edit"),O.scrollIntoView({block:"start",behavior:"smooth"}),(O.querySelector(":scope > :not(summary)")??O).querySelector(tf)?.focus({preventScroll:!0}),R(x)}function W(x){x.onclick=O=>{O.preventDefault();let _=O.target===null?null:Yu(x,O.target);_!==null&&V(_)},x.onsubmit=O=>O.preventDefault()}document.addEventListener("focusin",x=>{if(!Yn(x.target))return;let _=x.target.closest("details[data-card]")?.dataset.card;R(_===void 0||_==="fields"?null:_)});function Ee(){ye=!0;let x=y;x.contentWindow?.scrollTo(0,m.contentWindow?.scrollY??0),x.contentDocument&&W(x.contentDocument),x.style.visibility="",x.removeAttribute("aria-hidden"),x.removeAttribute("tabindex"),x.id="preview-frame",x.classList.remove(fo),m.style.visibility="hidden",m.setAttribute("aria-hidden","true"),m.tabIndex=-1,m.removeAttribute("id"),m.classList.remove(fo),y=m,m=x,E(!1),it||D(h.ready),l&&(l.textContent="")}let ot=Uu({blankUrl:p,pagePath:f,back:()=>y,onSwap:Ee,fallbackMs:1e3});i.after(g);let it=!1;function ge(x){if(it=!1,x.kind==="page"){ot.write(x.html);return}ot.cancel(),x.kind==="incomplete"&&m.classList.add(fo),$(x.message)}let Re=new URL(u,location.href).pathname,ye=!1;function st(){if(ye)return;let x=i.contentWindow,O=i.contentDocument;if(ye=!0,!x||!O){$(h.failed);return}if(x.location.pathname!==Re){O.open(),O.write("<!doctype html><title></title>"),O.close(),$(h.signedOut);return}x.history.replaceState(null,"",f),W(O),E(!1),D(h.ready)}i.contentDocument?.readyState==="complete"&&i.contentWindow?.location.href!=="about:blank"?st():i.addEventListener("load",st,{once:!0});let un=qu({url:u,getForm:()=>{let x=document.getElementById(Pt);return x instanceof HTMLFormElement?x:null},delay:400,fetch:(...x)=>window.fetch(...x),signedOutMessage:h.signedOut,failedMessage:h.failed,onStart:()=>{it=!0,D(h.updating)},onResult:ge}),Jn=()=>t.classList.contains("no-preview")&&!Ls();Zn=()=>{Jn()?v=!0:un.schedule()};let fn=()=>{v&&(v=!1,un.schedule())};function Rt(){let x=getComputedStyle(r),O=r.clientWidth-parseFloat(x.paddingLeft||"0")-parseFloat(x.paddingRight||"0"),_=r.clientHeight-parseFloat(x.paddingTop||"0")-parseFloat(x.paddingBottom||"0");if(O<=0||_<=0)return;let _e=$s[S],be=Zu(O,_e);for(let qe of[m,y])qe.style.width=`${_e}px`,qe.style.height=`${_/be}px`,qe.style.transform=`scale(${be})`;o.style.width=`${_e*be}px`,o.style.height=`${_}px`,a&&(a.textContent=be<1?`${Math.round(be*100)}%`:""),requestAnimationFrame(()=>E(!1))}let Un=[...e.querySelectorAll("button[data-device]")];function lt(x){S=x;for(let O of Un){let _=O.dataset.device===x;O.setAttribute("aria-pressed",String(_)),O.classList.toggle("btn-active",_)}Rt()}for(let x of Un)x.addEventListener("click",()=>{let O=x.dataset.device;Ds(O)&&(Ps(uo,O),lt(O))});typeof ResizeObserver=="function"&&new ResizeObserver(()=>Rt()).observe(r);function It(x,O){t.classList.toggle("no-preview",x),d&&(d.hidden=!x),Ps(Rs,x?"1":"0"),O&&(x?d:c)?.focus(),x||(Rt(),fn())}c?.addEventListener("click",()=>It(!0,!0)),d?.addEventListener("click",()=>It(!1,!0));let hn=[...document.querySelectorAll("[data-view-btn]")];function pn(x){t.dataset.view=x;for(let O of hn){let _=O.dataset.viewBtn===x;O.setAttribute("aria-pressed",String(_)),O.classList.toggle("btn-active",_)}x==="preview"&&(requestAnimationFrame(Rt),fn())}for(let x of hn)x.addEventListener("click",()=>pn(x.dataset.viewBtn??"edit"));ho(Rs)==="1"&&It(!0,!1),pn(t.dataset.view??"edit"),lt(S)}function Bs(){let n=document.getElementById("preview-pane"),e=document.getElementById("workspace"),t=document.getElementById("preview-stage"),r=document.getElementById("preview-device"),o=document.getElementById("preview-frame"),i=document.getElementById("preview-status");!n||!e||!t||!r||!(o instanceof HTMLIFrameElement)||!i||nf({pane:n,workspace:e,stage:t,device:r,first:o,status:i,announce:document.getElementById("preview-announce"),scaleText:document.getElementById("preview-scale"),hideButton:document.getElementById("preview-hide"),showButton:document.getElementById("preview-show")})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Bs):Bs();var Fs=Object.defineProperty,Hs=(n,e)=>{let t={};for(var r in n)Fs(t,r,{get:n[r],enumerable:!0});return e||Fs(t,Symbol.toStringTag,{value:"Module"}),t};function oe(n){this.content=n}oe.prototype={constructor:oe,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),i=r.content.slice();return o==-1?i.push(t||n,e):(i[o+1]=e,t&&(i[o]=t)),new oe(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new oe(t)},addToStart:function(n,e){return new oe([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new oe(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),i=r.find(n);return o.splice(i==-1?o.length:i,0,e,t),new oe(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=oe.from(n),n.size?new oe(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=oe.from(n),n.size?new oe(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=oe.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};oe.from=function(n){if(n instanceof oe)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new oe(e)};var go=oe;function Ys(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),i=e.child(r);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){let s=o.text,l=i.text,a=0;for(;s[a]==l[a];a++)t++;return a&&a<s.length&&a<l.length&&el(s.charCodeAt(a-1))&&Qs(s.charCodeAt(a))&&t--,t}if(o.content.size||i.content.size){let s=Ys(o.content,i.content,t+1);if(s!=null)return s}t+=o.nodeSize}}function Zs(n,e,t,r){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:r};let s=n.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=s.text,d=l.text,u=c.length,f=d.length;for(;u>0&&f>0&&c[u-1]==d[f-1];)u--,f--,t--,r--;return u&&f&&u<c.length&&el(c.charCodeAt(u-1))&&Qs(c.charCodeAt(u))&&(t++,r++),{a:t,b:r}}if(s.content.size||l.content.size){let c=Zs(s.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function Qs(n){return n>=56320&&n<57344}function el(n){return n>=55296&&n<56320}var b=class n{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,i){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),r,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let i="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new n(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),o+=l.nodeSize),s=a}return new n(r,o)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new n(o,i)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.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 new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return Ys(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Zs(this,e,t,r)}findIndex(e){if(e==0)return Qn(0,e);if(e==this.size)return Qn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let o=this.child(t),i=r+o.nodeSize;if(i>=e)return i==e?Qn(t+1,i):Qn(t,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return n.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(t||(t=e.slice(0,o)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new n(t||e,r)}static from(e){if(!e)return n.empty;if(e instanceof n)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new n([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};b.empty=new b([],0);var yo={index:0,offset:0};function Qn(n,e){return yo.index=n,yo.offset=e,yo}function nr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!nr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!nr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}var P=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||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&&nr(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 new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}};P.none=[];var Je=class extends Error{},w=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=nl(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(tl(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return n.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(b.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new n(e,r,o)}};w.empty=new w(b.empty,0,0);function tl(n,e,t){let{index:r,offset:o}=n.findIndex(e),i=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(o==e||i.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(tl(i.content,e-o-1,t-o-1)))}function nl(n,e,t,r,o,i){let{index:s,offset:l}=n.findIndex(e),a=n.maybeChild(s);if(l==e||a.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=nl(a.content,e-l-1,t,s==0?r-1:0,s==n.childCount-1?o-1:0,a);return c&&n.replaceChild(s,a.copy(c))}function rf(n,e,t){if(t.openStart>n.depth)throw new Je("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Je("Inconsistent open depths");return rl(n,e,t,0)}function rl(n,e,t,r){let o=n.index(r),i=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let s=rl(n,e,t,r+1);return i.copy(i.content.replaceChild(o,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return ct(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=of(t,n);return ct(i,il(n,s,l,e,r))}else return ct(i,rr(n,e,r))}function ol(n,e){if(!e.type.compatibleContent(n.type))throw new Je("Cannot join "+e.type.name+" onto "+n.type.name)}function bo(n,e,t){let r=n.node(t);return ol(r,e.node(t)),r}function at(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function mn(n,e,t,r){let o=(e||n).node(t),i=0,s=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(at(n.nodeAfter,r),i++));for(let l=i;l<s;l++)at(o.child(l),r);e&&e.depth==t&&e.textOffset&&at(e.nodeBefore,r)}function ct(n,e){if(!n.type.validContent(e))throw new Je("Invalid content for node "+n.type.name);return n.copy(e)}function il(n,e,t,r,o){let i=n.depth>o&&bo(n,e,o+1),s=r.depth>o&&bo(t,r,o+1),l=[];return mn(null,n,o,l),i&&s&&e.index(o)==t.index(o)?(ol(i,s),at(ct(i,il(n,e,t,r,o+1)),l)):(i&&at(ct(i,rr(n,e,o+1)),l),mn(e,t,o,l),s&&at(ct(s,rr(t,r,o+1)),l)),mn(r,null,o,l),new b(l)}function rr(n,e,t){let r=[];if(mn(null,n,t,r),n.depth>t){let o=bo(n,e,t+1);at(ct(o,rr(n,e,t+1)),r)}return mn(e,null,t,r),new b(r)}function of(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)o=e.node(i).copy(b.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}var or=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,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 new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}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 r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return P.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}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 r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new dt(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,i=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new n(t,r,i)}static resolveCached(e,t){let r=Vs.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==t)return s}else Vs.set(e,r=new wo);let o=r.elts[r.i]=n.resolve(e,t);return r.i=(r.i+1)%sf,o}},wo=class{constructor(){this.elts=[],this.i=0}},sf=12,Vs=new WeakMap,dt=class{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},lf=Object.create(null),xe=class n{constructor(e,t,r,o=P.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||b.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,r,o=0){this.content.nodesBetween(e,t,r,o,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,r,o){return this.content.textBetween(e,t,r,o)}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,r){return this.type==e&&nr(this.attrs,t||e.defaultAttrs||lf)&&P.sameSet(this.marks,r||P.none)}copy(e=null){return e==this.content?this:new n(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.content,e)}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,r=!1){if(e==t)return w.empty;let o=this.resolve(e),i=this.resolve(t),s=r?0:o.sharedDepth(t),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new w(c,o.depth-s,i.depth-s)}replace(e,t,r){return rf(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return or.resolveCached(this,e)}resolveNoCache(e){return or.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}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()+")"),sl(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=b.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Ws(this.type.attrs,this.attrs,"node",this.type.name);let e=P.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];Ws(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!P.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.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(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=b.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,o,r)}};xe.prototype.text=void 0;var ko=class n extends xe{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):sl(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(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 sl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}function Ws(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${r}`);for(let o in n)n[o].validate&&n[o].validate(e[o])}var ut=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new So(e,t);if(r.next==null)return n.empty;let o=ll(r);r.next&&r.err("Unexpected trailing text");let i=pf(hf(o));return mf(i,r),i}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,r=e.childCount){let o=this;for(let i=t;o&&i<r;i++)o=o.matchType(e.child(i).type);return o}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 r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!t||a.validEnd))return b.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:d,next:u}=s.next[c];if(!(d.isText||d.hasRequiredAttrs())&&o.indexOf(u)==-1){o.push(u);let f=i(u,l.concat(d));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
2
+ `)}};ut.empty=new ut(!0);var So=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 new SyntaxError(e+" (in content expression '"+this.string+"')")}};function ll(n){let e=[];do e.push(af(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function af(n){let e=[];do e.push(cf(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function cf(n){let e=ff(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=df(n,e);else break;return e}function js(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function df(n,e){let t=js(n),r=t;return n.eat(",")&&(n.next!="}"?r=js(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function uf(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let i in t){let s=t[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function ff(n){if(n.eat("(")){let e=ll(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=uf(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function hf(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let d=t();o(i(s.expr,a),d),a=d}if(s.max==-1)o(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let d=t();r(a,d),o(i(s.expr,a),d),a=d}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function al(n,e){return e-n}function Ks(n,e){let t=[];return r(e),t.sort(al);function r(o){let i=n[o];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(o);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&t.indexOf(a)==-1&&r(a)}}}function pf(n){let e=Object.create(null);return t(Ks(n,0));function t(r){let o=[];r.forEach(s=>{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<o.length;d++)o[d][0]==l&&(c=o[d][1]);Ks(n,a).forEach(d=>{c||o.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new ut(r.indexOf(n.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(al);i.next.push({type:o[s][0],next:e[l.join(",")]||t(l)})}return i}}function mf(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],i=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function cl(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function dl(n,e){let t=Object.create(null);for(let r in n){let o=n[r],i=e&&e[r];if(i===void 0)if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r);else o.validate&&o.validate(i);t[r]=i}return t}function ul(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new xo(n,r,e[r]);return t}var Bt=class n{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=ul(e,r.attrs),this.defaultAttrs=cl(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ut.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:dl(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new xe(this,this.computeAttrs(e),b.from(t),P.setFrom(r))}createChecked(e=null,t,r){return t=b.from(t),this.checkContent(t),new xe(this,this.computeAttrs(e),t,P.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=b.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(b.empty,!0);return i?new xe(this,e,t.append(i),P.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let 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 r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:P.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,s)=>r[i]=new n(i,t,s));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function gf(n,e,t){let r=t.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}var xo=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?gf(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},yn=class n{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=ul(e,o.attrs),this.excluded=null;let i=cl(this.attrs);this.instance=i?new P(this,i):null}create(e=null){return!e&&this.instance?this.instance:new P(this,dl(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new n(i,o++,t,s)),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}},ft=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=go.from(e.nodes),t.marks=go.from(e.marks||{}),this.nodes=Bt.compile(this.spec.nodes,this),this.marks=yn.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=ut.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?_s(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:_s(this,s.split(" "))}this.nodeFromJSON=o=>xe.fromJSON(this,o),this.markFromJSON=o=>P.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Bt){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,o)}text(e,t){let r=this.nodes.text;return new ko(r,r.defaultAttrs,e,P.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 new RangeError("Unknown node type: "+e);return t}};function _s(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],i=n.marks[o],s=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function yf(n){return n.tag!=null}function bf(n){return n.style!=null}var Ie=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(yf(o))this.tags.push(o);else if(bf(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new ir(this,t,!1);return r.addAll(e,P.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new ir(this,t,!0);return r.addAll(e,P.none,t.from,t.to),w.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(Sf(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,t,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<i)break}t.splice(s,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Js(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Js(s)),s.node||s.ignore||s.mark||(s.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},fl={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},wf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},hl={ol:!0,ul:!0},bn=1,Co=2,gn=4;function qs(n,e,t){return e!=null?(e?bn:0)|(e==="full"?Co:0):n&&n.whitespace=="pre"?bn|Co:t&~gn}var Lt=class{constructor(e,t,r,o,i,s){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=P.none,this.match=i||(s&gn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(b.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&bn)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let t=b.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(b.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&&!fl.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},ir=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,i,s=qs(null,t.preserveWhitespace,0)|(r?gn:0);o?i=new Lt(o.type,o.attrs,P.none,!0,t.topMatch||o.type.contentMatch,s):r?i=new Lt(null,null,P.none,!0,null,s):i=new Lt(e.schema.topNodeType,null,P.none,!0,null,s),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 r=e.nodeValue,o=this.top,i=o.options&Co?"full":this.localPreserveWS||(o.options&bn)>0,{schema:s}=this.parser;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
3
+ `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(s.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=o.content[o.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;hl.hasOwnProperty(s)&&this.parser.normalizeLists&&kf(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:wf.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(fl.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(i),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
+ `),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 r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=r.getPropertyValue(i);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(i,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let i,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,t);this.findAtPoint(e,i)}findPlace(e,t,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)t=this.enterInner(o[s],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let o=this.findPlace(e,t,r);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=P.none;for(let l of o.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Us(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,t,r,o){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,o)),i}enterInner(e,t,r,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=qs(e,i,s.options);s.options&gn&&s.content.length==0&&(l|=gn);let a=P.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):Us(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Lt(e,t,a,o,null,l)),this.open++,r}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;this.localPreserveWS&&(this.nodes[t].options|=bn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].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,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].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("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let d=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function kf(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&hl.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Sf(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Js(n){let e={};for(let t in n)e[t]=n[t];return e}function Us(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let i=[],s=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&s(d))return!0}};if(s(o.contentMatch))return!0}}var Pe=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=er(t).createDocumentFragment());let o=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let l=0,a=0;for(;l<i.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)o=i.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],d=this.serializeMark(c,s.isInline,t);d&&(i.push([c,o]),o.appendChild(d.dom),o=d.contentDOM||d.dom)}}o.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){if(e.isText)return er(t).createTextNode(e.text);let{dom:r,contentDOM:o}=tr(er(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&tr(er(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return typeof t=="string"?{dom:e.createTextNode(t)}:tr(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Gs(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Gs(e.marks)}};function Gs(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function er(n){return n.document||window.document}var Xs=new WeakMap;function xf(n){let e=Xs.get(n);return e===void 0&&Xs.set(n,e=Cf(n)),e}function Cf(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function tr(n,e,t,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=xf(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=o.indexOf(" ");s>0&&(t=o.slice(0,s),o=o.slice(s+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(n.createTextNode(f));else{let{dom:h,contentDOM:p}=tr(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var bl=65535,wl=Math.pow(2,16);function vf(n,e){return n+e*wl}function pl(n){return n&bl}function Mf(n){return(n-(n&bl))/wl}var kl=1,Sl=2,sr=4,xl=8,Sn=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&xl)>0}get deletedBefore(){return(this.delInfo&(kl|sr))>0}get deletedAfter(){return(this.delInfo&(Sl|sr))>0}get deletedAcross(){return(this.delInfo&sr)>0}},Le=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=pl(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+Mf(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+s],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,h=a+o+(f<0?0:d);if(r)return h;let p=e==(t<0?a:u)?null:vf(l/3,e-a),m=0;return c&&(m|=e==a?Sl:e==u?kl:sr,(t<0?e!=a:e!=u)&&(m|=xl)),new Sn(h,m,p)}o+=d-c}return r?e+o:new Sn(e+o,0,null)}touches(e,t){let r=0,o=pl(t),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[o+t],d=this.ranges[o+r];e(l,l+c,a,a+d),i+=d-c}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?n.empty:new n(e<0?[0,-e,0]:[0,0,e])}};Le.empty=new Le([]);var xn=class n{constructor(e,t,r=0,o=e?e.length:0){this.mirror=t,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new n(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let o=e.getMirror(t);this.appendMap(e._maps[t],o!=null&&o<t?r+o: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=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e._maps[t].invert(),o!=null&&o>t?r-o-1:void 0)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new Sn(e,o,null)}},vo=Object.create(null),J=class{getMap(){return Le.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=vo[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in vo)throw new RangeError("Duplicate use of step JSON ID "+e);return vo[e]=t,t.prototype.jsonID=e,t}},Q=class n{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new n(e,null)}static fail(e){return new n(null,e)}static fromReplace(e,t,r,o){try{return n.ok(e.replace(t,r,o))}catch(i){if(i instanceof Je)return n.fail(i.message);throw i}}};function Ao(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let i=n.child(o);i.content.size&&(i=i.copy(Ao(i.content,e,i))),i.isInline&&(i=e(i,t,o)),r.push(i)}return b.fromArray(r)}var Cn=class n extends J{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new w(Ao(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),t.openStart,t.openEnd);return Q.fromReplace(e,this.from,this.to,i)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,o)=>{if(r.isInline&&r.isAtom){let i=this.mark.addToSet(r.marks);if(!P.sameSet(i,r.marks)){let s=Math.max(this.from,o),l=Math.min(this.to,o+r.nodeSize);lr(Ue,s,l,this.mark,t);for(let a of r.marks)a.isInSet(i)||lr(n,s,l,a,t)}}}),t.length==1?t[0]:new vn(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};J.jsonID("addMark",Cn);var Ue=class n extends J{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new w(Ao(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return Q.fromReplace(e,this.from,this.to,r)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,o)=>{r.isInline&&r.isAtom&&this.mark.isInSet(r.marks)&&lr(Cn,Math.max(this.from,o),Math.min(this.to,o+r.nodeSize),this.mark,t)}),t.length==1?t[0]:new vn(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};J.jsonID("removeMark",Ue);function lr(n,e,t,r,o){let i=o.length?o[o.length-1]:null;i&&i instanceof n&&i.to==e&&i.mark.eq(r)?o[o.length-1]=new n(i.from,t,r):o.push(new n(e,t,r))}var vn=class n extends J{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let r=t.apply(e);if(!r.doc)return r;e=r.doc}return new Q(e,null)}invert(e){return new n(this.steps.map(t=>t.invert(e)))}map(e){let t=[];for(let r of this.steps){let o=r.map(e);o&&t.push(o)}return t.length?new n(t):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,t){if(!Array.isArray(t.steps)||!t.steps.every(r=>r.stepType=="addMark"||r.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new n(t.steps.map(r=>J.fromJSON(e,r)))}};J.jsonID("markSet",vn);var Mn=class n extends J{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Q.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Q.fromReplace(e,this.pos,this.pos+1,new w(b.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new n(this.pos,t.marks[o]);return new n(this.pos,this.mark)}}return new zt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};J.jsonID("addNodeMark",Mn);var zt=class n extends J{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Q.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Q.fromReplace(e,this.pos,this.pos+1,new w(b.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Mn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};J.jsonID("removeNodeMark",zt);var ee=class n extends J{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&Eo(e,this.from,this.to)?Q.fail("Structure replace would overwrite content"):Q.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Le([this.from,this.to-this.from,this.slice.size])}invert(e){return new n(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&n.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new n(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof n)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?w.empty:new w(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new n(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?w.empty:new w(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new n(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new n(t.from,t.to,w.fromJSON(e,t.slice),!!t.structure)}};ee.MAP_BIAS=1;J.jsonID("replace",ee);var U=class n extends J{constructor(e,t,r,o,i,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Eo(e,this.from,this.gapFrom)||Eo(e,this.gapTo,this.to)))return Q.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Q.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?Q.fromReplace(e,this.from,this.to,r):Q.fail("Content does not fit in gap")}getMap(){return new Le([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new n(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||i>r.pos?null:new n(t.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,w.fromJSON(e,t.slice),t.insert,!!t.structure)}};J.jsonID("replaceAround",U);function Eo(n,e,t){let r=n.resolve(e),o=t-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function Ef(n,e,t,r){let o=[];n.doc.nodesBetween(e,t,(i,s,l)=>{if(!i.isInline)return;let a=i.marks;if(!r.isInSet(a)&&l.type.allowsMarkType(r.type)){let c=Math.max(s,e),d=Math.min(s+i.nodeSize,t);lr(Cn,c,d,r,o)}}),o.forEach(i=>n.step(i))}function Tf(n,e,t,r){let o=[],i=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline||!s.isAtom)return;i++;let a=null;if(r instanceof yn){let c=s.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],f;for(let h=0;h<o.length;h++){let p=o[h];p.step==i-1&&u.eq(o[h].style)&&(f=p)}f?(f.to=c,f.step=i):o.push({style:u,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(s=>n.step(new Ue(s.from,s.to,s.style)))}function No(n,e,t,r=t.contentMatch,o=!0){let i=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,u=r.matchType(c.type);if(!u)s.push(new ee(l,d,w.empty));else{r=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new Ue(l,d,c.marks[f]));if(o&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new w(b.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new ee(l+f.index,l+f.index+f[0].length,p))}}l=d}if(!r.validEnd){let a=r.fillBefore(b.empty,!0);n.replace(l,l,new w(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function Af(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Be(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,o=0,i=0;;--r){let s=n.$from.node(r),l=n.$from.index(r)+o,a=n.$to.indexAfter(r)-i;if(r<n.depth&&s.canReplace(l,a,t))return r;if(r==0||s.type.spec.isolating||!Af(s,l,a))break;l&&(o=1),a<s.childCount&&(i=1)}return null}function Nf(n,e,t){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),l=o.after(i+1),a=s,c=l,d=b.empty,u=0;for(let p=i,m=!1;p>t;p--)m||r.index(p)>0?(m=!0,d=b.from(r.node(p).copy(d)),u++):a--;let f=b.empty,h=0;for(let p=i,m=!1;p>t;p--)m||o.after(p+1)<o.end(p)?(m=!0,f=b.from(o.node(p).copy(f)),h++):c++;n.step(new U(a,c,s,l,new w(d.append(f),u,h),d.size-u,!0))}function Ft(n,e,t=null,r=n){let o=Of(n,e),i=o&&Df(r,e);return i?o.map(ml).concat({type:e,attrs:t}).concat(i.map(ml)):null}function ml(n){return{type:n,attrs:null}}function Of(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return t.canReplaceWith(r,o,s)?i:null}function Df(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function Rf(n,e,t){let r=b.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=b.from(t[s].type.create(t[s].attrs,r))}let o=e.start,i=e.end;n.step(new U(o,i,o,i,new w(r,0,0),t.length,!0))}function If(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&Pf(n.doc,n.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&vl(n,s,l,i),No(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let d=n.mapping.slice(i),u=d.map(l,1),f=d.map(l+s.nodeSize,1);return n.step(new U(u,f,u+1,f-1,new w(b.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Cl(n,s,l,i),!1}})}function Cl(n,e,t,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+i+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function vl(n,e,t,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+i);n.replaceWith(s,s+1,e.type.schema.text(`
5
+ `))}})}function Pf(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function Lf(n,e,t,r,o){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let s=t.create(r,null,o||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,s);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new U(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new w(b.from(s),0,0),1,!0))}function we(n,e,t=1,r){let o=n.resolve(e),i=o.depth-t,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,d=t-2;c>i;c--,d--){let u=o.node(c),f=o.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=r&&r[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!m.type.validContent(h))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function Bf(n,e,t=1,r){let o=n.doc.resolve(e),i=b.empty,s=b.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){i=b.from(o.node(l).copy(i));let d=r&&r[c];s=b.from(d?d.type.create(d.attrs,s):o.node(l).copy(s))}n.step(new ee(e,e,new w(i.append(s),t,t),!0))}function Ce(n,e){let t=n.resolve(e),r=t.index();return Ml(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function zf(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),s=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function Ml(n,e){return!!(n&&e&&!n.isLeaf&&zf(n,e))}function Ht(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let i,s,l=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):t>0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&Ml(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function $f(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(e-t),s=i.node().type;if(o&&s.inlineContent){let d=s.whitespace=="pre",u=!!s.contentMatch.matchType(o);d&&!u?r=!1:!d&&u&&(r=!0)}let l=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);vl(n,d.node(),d.before(),l)}s.inlineContent&&No(n,e+t-1,s,i.node().contentMatchAt(i.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new ee(c,a.map(e+t,-1),w.empty,!0)),r===!0){let d=n.doc.resolve(c);Cl(n,d.node(),d.before(),n.steps.length)}return n}function Ff(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,t))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,t))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function dr(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let i=0;i<t.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),d=!1;if(i==1)d=c.canReplace(a,a,o);else{let u=c.contentMatchAt(a).findWrapping(o.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function En(n,e,t=e,r=w.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),i=n.resolve(t);return El(o,i,r)?new ee(e,t,r):new To(o,i,r).fit()}function El(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var To=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=b.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=b.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new w(i,s,l);return e>-1?new U(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new ee(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=gl(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(s?c.matchType(s.type)||(u=c.fillBefore(b.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(t==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced;return yl(e,-1)<=t?!1:(this.unplaced.size>1&&yl(e,1)>r&&r++,this.unplaced=new w(e,t+1,r),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=gl(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new w(wn(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new w(wn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,d=[],{match:u,type:f}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)d.push(o.child(m));u=u.matchFragment(o)}let h=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,d.push(Tl(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=kn(this.placed,t,b.from(d)),this.frontier[t].match=u,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?w.empty:new w(wn(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new w(wn(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Mo(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:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=Mo(e,t,o,r,i);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Mo(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:s,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=kn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=kn(this.placed,this.depth,b.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(b.empty,!0);t.childCount&&(this.placed=kn(this.placed,this.frontier.length,t))}};function wn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(wn(n.firstChild.content,e-1,t)))}function kn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(kn(n.lastChild.content,e-1,t)))}function gl(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Tl(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Tl(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(b.empty,!0)))),n.copy(r)}function Mo(n,e,t,r,o){let i=n.node(e),s=o?n.indexAfter(e):n.index(e);if(s==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!Hf(t,i.content,s)?l:null}function Hf(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Vf(n){return n.spec.defining||n.spec.definingForContent}function yl(n,e){for(let t=0;;t++){let r=e<0?n.firstChild:n.lastChild;if(!r||r.isAtom)return t;n=r.content}}function Wf(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),i=n.doc.resolve(t);if(El(o,i,r))return n.step(new ee(e,t,r));let s=Nl(o,i);s[s.length-1]==0&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let f=o.depth,h=o.pos-1;f>0;f--,h--){let p=o.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(f)>-1?l=f:o.before(f)==h&&s.splice(1,0,-f)}let a=s.indexOf(l),c=[],d=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f],p=Vf(h.type);if(p&&!h.sameMarkup(o.node(Math.abs(l)-1)))d=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+d+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<s.length;m++){let g=s[(m+a)%s.length],y=!0;g<0&&(y=!1,g=-g);let k=o.node(g-1),S=o.index(g-1);if(k.canReplaceWith(S,S,p.type,p.marks))return n.replace(o.before(g),y?i.after(g):t,new w(Al(r.content,0,r.openStart,h),h,r.openEnd))}}let u=n.steps.length;for(let f=s.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>u));f--){let h=s[f];h<0||(e=o.before(h),t=i.after(h))}}function Al(n,e,t,r,o){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(Al(i.content,e+1,t,r,i)))}if(e>r){let i=o.contentMatchAt(0),s=i.fillBefore(n).append(n);n=s.append(i.matchFragment(s).fillBefore(b.empty,!0))}return n}function jf(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=Ff(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new w(b.from(r),0,0))}function Kf(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let s=r.sharedDepth(t),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=o.depth;a>s;a--)o.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=o.depth;a>0&&t==o.start(a);a--)t=o.before(a);r=n.doc.resolve(e),o=n.doc.resolve(t)}}let i=Nl(r,o);for(let s=0;s<i.length;s++){let l=i[s],a=s==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&o.end(s)-t!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function Nl(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let i=n.start(o);if(i<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&t.push(o)}return t}var ar=class n extends J{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return Q.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return Q.fromReplace(e,this.pos,this.pos+1,new w(b.from(o),0,t.isLeaf?0:1))}getMap(){return Le.empty}invert(e){return new n(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}};J.jsonID("attr",ar);var cr=class n extends J{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return Q.ok(r)}getMap(){return Le.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};J.jsonID("docAttr",cr);var $t=class extends Error{};$t=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};$t.prototype=Object.create(Error.prototype);$t.prototype.constructor=$t;$t.prototype.name="TransformError";var Ge=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new xn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new $t(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 r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(e=o.map(e,1),t=o.map(t,-1)),o.forEach((i,s,l,a)=>{e=Math.min(e,l),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,r=w.empty){let o=En(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new w(b.from(r),0,0))}delete(e,t){return this.replace(e,t,w.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Wf(this,e,t,r),this}replaceRangeWith(e,t,r){return jf(this,e,t,r),this}deleteRange(e,t){return Kf(this,e,t),this}lift(e,t){return Nf(this,e,t),this}join(e,t=1){return $f(this,e,t),this}wrap(e,t){return Rf(this,e,t),this}setBlockType(e,t=e,r,o=null){return If(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return Lf(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new ar(e,t,r)),this}setDocAttribute(e,t){return this.step(new cr(e,t)),this}addNodeMark(e,t){return this.step(new Mn(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof P)t.isInSet(r.marks)&&this.step(new zt(e,t));else{let o=r.marks,i,s=[];for(;i=t.isInSet(o);)s.push(new zt(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,r){return Bf(this,e,t,r),this}addMark(e,t,r){return Ef(this,e,t,r),this}removeMark(e,t,r){return Tf(this,e,t,r),this}clearIncompatible(e,t,r){return No(this,e,t,r),this}};var Oo=Object.create(null),T=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Wt(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=w.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?w.empty:t),l==0&&Rl(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:l}=o[i],a=e.mapping.slice(r),c=a.map(s.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),Rl(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new C(e):Vt(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let i=e.depth-1;i>=0;i--){let s=t<0?Vt(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):Vt(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new de(e.node(0))}static atStart(e){return Vt(e,e,0,0,1)||new de(e)}static atEnd(e){return Vt(e,e,e.content.size,e.childCount,-1)||new de(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Oo[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Oo)throw new RangeError("Duplicate use of selection JSON ID "+e);return Oo[e]=t,t.prototype.jsonID=e,t}getBookmark(){return C.between(this.$anchor,this.$head).getBookmark()}};T.prototype.visible=!0;var Wt=class{constructor(e,t){this.$from=e,this.$to=t}},Ol=!1;function Dl(n){!Ol&&!n.parent.inlineContent&&(Ol=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var C=class n extends T{constructor(e,t=e){Dl(e),Dl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return T.near(r);let o=e.resolve(t.map(this.anchor));return new n(o.parent.inlineContent?o:r,r)}replace(e,t=w.empty){if(super.replace(e,t),t==w.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new fr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let i=T.findFrom(t,r,!0)||T.findFrom(t,-r,!0);if(i)t=i.$head;else return T.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(T.findFrom(e,-r,!0)||T.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new n(e,t)}};T.jsonID("text",C);var fr=class n{constructor(e,t){this.anchor=e,this.head=t}map(e){return new n(e.map(this.anchor),e.map(this.head))}resolve(e){return C.between(e.resolve(this.anchor),e.resolve(this.head))}},A=class n extends T{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),i=e.resolve(o);return r?T.near(i):new n(i)}content(){return new w(b.from(this.node),0,0)}eq(e){return e instanceof n&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ro(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new n(e.resolve(t.anchor))}static create(e,t){return new n(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};A.prototype.visible=!1;T.jsonID("node",A);var Ro=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new fr(r,r):new n(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&A.isSelectable(r)?new A(t):T.near(t)}},de=class n extends T{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=w.empty){if(t==w.empty){e.delete(0,e.doc.content.size);let r=T.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new n(e)}map(e){return new n(e)}eq(e){return e instanceof n}getBookmark(){return _f}};T.jsonID("all",de);var _f={map(){return this},resolve(n){return new de(n)}};function Vt(n,e,t,r,o,i=!1){if(e.inlineContent)return C.create(n,t);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&A.isSelectable(l))return A.create(n,t-(o<0?l.nodeSize:0))}else{let a=Vt(n,l,t+o,o<0?l.childCount:0,o,i);if(a)return a}t+=l.nodeSize*o}return null}function Rl(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof ee||o instanceof U))return;let i=n.mapping.maps[r],s;i.forEach((l,a,c,d)=>{s==null&&(s=d)}),n.setSelection(T.near(n.doc.resolve(s),t))}var Il=1,ur=2,Pl=4,Io=class extends Ge{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Il)&~ur,this.storedMarks=null,this}get selectionSet(){return(this.updated&Il)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ur,this}ensureMarks(e){return P.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&ur)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~ur,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||P.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(t);i=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(T.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|=Pl,this}get scrolledIntoView(){return(this.updated&Pl)>0}};function Ll(n,e){return!e||!n?n:n.bind(e)}var ht=class{constructor(e,t,r){this.name=e,this.init=Ll(t.init,r),this.apply=Ll(t.apply,r)}},qf=[new ht("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new ht("selection",{init(n,e){return n.selection||T.atStart(e.doc)},apply(n){return n.selection}}),new ht("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new ht("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],Tn=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=qf.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new ht(r.key,r.spec.state,r))})}},pt=class n{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 r=0;r<this.config.plugins.length;r++)if(r!=t){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),o=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=o?o[s].n:0,c=o?o[s].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(d&&r.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!o){o=[];for(let u=0;u<this.config.plugins.length;u++)o.push(u<s?{state:r,n:t.length}:{state:this,n:0})}t.push(d),r=r.applyInner(d),i=!0}o&&(o[s]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new Io(this)}static create(e){let t=new Tn(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new n(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new Tn(this.schema,e.plugins),r=t.fields,o=new n(t);for(let i=0;i<r.length;i++){let s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[i].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Tn(e.schema,e.plugins),i=new n(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=xe.fromJSON(e.schema,t.doc);else if(s.name=="selection")i.selection=T.fromJSON(i.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[s.name]=c.fromJSON.call(a,e,t[l],i);return}}i[s.name]=s.init(e,i)}}),i}};function Bl(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Bl(o,e,{})),t[r]=o}return t}var I=class{constructor(e){this.spec=e,this.props={},e.props&&Bl(e.props,this,this.props),this.key=e.key?e.key.key:zl("plugin")}getState(e){return e[this.key]}},Do=Object.create(null);function zl(n){return n in Do?n+"$"+ ++Do[n]:(Do[n]=0,n+"$")}var F=class{constructor(e="key"){this.key=zl(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Fl=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Hl(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var Lo=(n,e,t)=>{let r=Hl(n,t);if(!r)return!1;let o=zo(r);if(!o){let s=r.blockRange(),l=s&&Be(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Jl(n,o,e,-1))return!0;if(r.parent.content.size==0&&(jt(i,"end")||A.isSelectable(i)))for(let s=r.depth;;s--){let l=En(n.doc,r.before(s),r.after(s),w.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(jt(i,"end")?T.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):A.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},hr=(n,e,t)=>{let r=Hl(n,t);if(!r)return!1;let o=zo(r);return o?Vl(n,o,e):!1},pr=(n,e,t)=>{let r=Wl(n,t);if(!r)return!1;let o=Ho(r);return o?Vl(n,o,e):!1};function Vl(n,e,t){let r=e.nodeBefore,o=r,i=e.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let d=o.lastChild;if(!d)return!1;o=d}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=En(n.doc,i,a,w.empty);if(!c||c.from!=i||c instanceof ee&&c.slice.size>=a-i)return!1;if(t){let d=n.tr.step(c);d.setSelection(C.create(d.doc,i)),t(d.scrollIntoView())}return!0}function jt(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}var Bo=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=zo(r)}let s=i&&i.nodeBefore;return!s||!A.isSelectable(s)?!1:(e&&e(n.tr.setSelection(A.create(n.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function zo(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Wl(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}var $o=(n,e,t)=>{let r=Wl(n,t);if(!r)return!1;let o=Ho(r);if(!o)return!1;let i=o.nodeAfter;if(Jl(n,o,e,1))return!0;if(r.parent.content.size==0&&(jt(i,"start")||A.isSelectable(i))){let s=En(n.doc,r.before(),r.after(),w.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=n.tr.step(s);l.setSelection(jt(i,"start")?T.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):A.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},Fo=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=Ho(r)}let s=i&&i.nodeAfter;return!s||!A.isSelectable(s)?!1:(e&&e(n.tr.setSelection(A.create(n.doc,i.pos)).scrollIntoView()),!0)};function Ho(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}var jl=(n,e)=>{let t=n.selection,r=t instanceof A,o;if(r){if(t.node.isTextblock||!Ce(n.doc,t.from))return!1;o=t.from}else if(o=Ht(n.doc,t.from,-1),o==null)return!1;if(e){let i=n.tr.join(o);r&&i.setSelection(A.create(i.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},Kl=(n,e)=>{let t=n.selection,r;if(t instanceof A){if(t.node.isTextblock||!Ce(n.doc,t.to))return!1;r=t.to}else if(r=Ht(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},_l=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),i=o&&Be(o);return i==null?!1:(e&&e(n.tr.lift(o,i).scrollIntoView()),!0)},Vo=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
6
+ `).scrollIntoView()),!0)};function Wo(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var jo=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),i=t.indexAfter(-1),s=Wo(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(T.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Ko=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof de||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=Wo(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=n.tr.insert(s,i.createAndFill());l.setSelection(C.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},_o=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(we(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),o=r&&Be(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function Jf(n){return(e,t)=>{if(e.selection instanceof A&&e.selection.node.isBlock){let{$from:h}=e.selection;return!h.parentOffset||!we(e.doc,h.pos)?!1:(t&&t(e.tr.split(h.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof C||e.selection instanceof de)&&r.deleteSelection();let{$from:o}=r.selection,i=r.steps.length,s=[],l,a,c=!1,d=!1;for(let h=o.depth;;h--)if(o.node(h).isBlock){c=o.end(h)==o.pos+(o.depth-h),d=o.start(h)==o.pos-(o.depth-h),a=Wo(o.node(h-1).contentMatchAt(o.indexAfter(h-1)));let m=n&&n(o.parent,c,o);s.unshift(m||(c&&a?{type:a}:null)),l=h;break}else{if(h==1)return!1;s.unshift(null)}let u=o.pos,f=we(r.doc,u,s.length,s);if(f||(s[0]=a?{type:a}:null,f=we(r.doc,u,s.length,s)),!f)return!1;if(r.split(u,s.length,s),!c&&d&&o.node(l).type!=a){let h=r.mapping.slice(i),p=h.map(o.before(l)),m=r.doc.resolve(p);a&&o.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(h.map(o.before(l)),a)}return t&&t(r.scrollIntoView()),!0}}var Uf=Jf();var ql=(n,e)=>{let{$from:t,to:r}=n.selection,o,i=t.sharedDepth(r);return i==0?!1:(o=t.before(i),e&&e(n.tr.setSelection(A.create(n.doc,o))),!0)},Gf=(n,e)=>(e&&e(n.tr.setSelection(new de(n.doc))),!0);function Xf(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||Ce(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Jl(n,e,t,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Xf(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(t){let h=e.pos+i.nodeSize,p=b.empty;for(let y=s.length-1;y>=0;y--)p=b.from(s[y].create(null,p));p=b.from(o.copy(p));let m=n.tr.step(new U(e.pos-1,h,e.pos,h,new w(p,1,0),s.length,!0)),g=m.doc.resolve(h+2*s.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Ce(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&a?null:T.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&Be(u);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(u,f).scrollIntoView()),!0;if(c&&jt(i,"start",!0)&&jt(o,"end")){let h=o,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let y=b.empty;for(let S=p.length-1;S>=0;S--)y=b.from(p[S].copy(y));let k=n.tr.step(new U(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new w(y,p.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function Ul(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(t&&t(e.tr.setSelection(C.create(e.doc,n<0?o.start(i):o.end(i)))),!0):!1}}var qo=Ul(-1),Jo=Ul(1);function Gl(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i),l=s&&Ft(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Uo(n,e=null){return function(t,r){let o=!1;for(let i=0;i<t.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(s,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let d=t.doc.resolve(c),u=d.index();o=d.parent.canReplaceWith(u,u+1,n)}})}if(!o)return!1;if(r){let i=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[s];i.setBlockType(l,a,n,e)}r(i.scrollIntoView())}return!0}}function Go(...n){return function(e,t,r){for(let o=0;o<n.length;o++)if(n[o](e,t,r))return!0;return!1}}var Po=Go(Fl,Lo,Bo),$l=Go(Fl,$o,Fo),Xe={Enter:Go(Vo,Ko,_o,Uf),"Mod-Enter":jo,Backspace:Po,"Mod-Backspace":Po,"Shift-Backspace":Po,Delete:$l,"Mod-Delete":$l,"Mod-a":Gf},Yf={"Ctrl-h":Xe.Backspace,"Alt-Backspace":Xe["Mod-Backspace"],"Ctrl-d":Xe.Delete,"Ctrl-Alt-Backspace":Xe["Mod-Delete"],"Alt-Delete":Xe["Mod-Delete"],"Alt-d":Xe["Mod-Delete"],"Ctrl-a":qo,"Ctrl-e":Jo};for(let n in Xe)Yf[n]=Xe[n];var mw=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;function Xl(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i);if(!s)return!1;let l=r?t.tr:null;return Zf(l,s,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Zf(n,e,t,r=null){let o=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new dt(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new dt(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=Ft(i,t,r,e);return l?(n&&Qf(n,e,l,o,t),!0):!1}function Qf(n,e,t,r,o){let i=b.empty;for(let d=t.length-1;d>=0;d--)i=b.from(t[d].type.create(t[d].attrs,i));n.step(new U(e.start-(r?2:0),e.end,e.start,e.end,new w(i,0,0),t.length,!0));let s=0;for(let d=0;d<t.length;d++)t[d].type==o&&(s=d+1);let l=t.length-s,a=e.start+t.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,f=!0;d<u;d++,f=!1)!f&&l&&we(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function mr(n,e){return n instanceof Bt?e==n:n.indexOf(e)>-1}function Yl(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,s=>s.childCount>0&&mr(n,s.firstChild.type));return i?t?mr(n,r.node(i.depth-1).type)?eh(e,t,i):th(e,t,i):!0:!1}}function eh(n,e,t){let r=n.tr,o=t.end,i=t.$to.end(t.depth),s=t.parent.child(t.endIndex-1).type;o<i&&(r.step(new U(o-1,i,o,i,new w(b.from(s.create(null,t.parent.copy())),1,0),1,!0)),t=new dt(r.doc.resolve(t.$from.pos),r.doc.resolve(i),t.depth));let l=Be(t);if(l==null)return!1;r.lift(t,l);let a=r.doc.resolve(r.mapping.map(o,-1)-1);return Ce(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function th(n,e,t){let r=n.tr,o=t.parent;for(let h=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(t.start),s=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,s.content.append(a?b.empty:b.from(o))))return!1;let u=i.pos,f=u+s.nodeSize;return r.step(new U(u-(l?1:0),f+(a?1:0),u+1,f-1,new w((l?b.empty:b.from(o.copy(b.empty))).append(a?b.empty:b.from(o.copy(b.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Zl(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&mr(n,c.firstChild.type));if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(!mr(n,a.type))return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=b.from(c?a.lastChild.lastChild.type.create():null),u=new w(b.from(a.type.create(null,b.from(l.type.create(null,d)))),c?3:1,0),f=i.start,h=i.end;t(e.tr.step(new U(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}var te=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Jt=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},ei=null,$e=function(n,e,t){let r=ei||(ei=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},nh=function(){ei=null},xt=function(n,e,t,r){return t&&(Ql(n,e,t,r,-1)||Ql(n,e,t,r,1))},rh=/^(img|br|input|textarea|hr)$/i;function Ql(n,e,t,r,o){for(var i;;){if(n==t&&e==r)return!0;if(e==(o<0?0:se(n))){let s=n.parentNode;if(!s||!N(s)||zn(n)||rh.test(n.nodeName)||n.contentEditable=="false")return!1;e=te(n)+(o<0?0:1),n=s}else if(N(n)){let s=n.childNodes[e+(o<0?-1:0)];if(N(s)&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else n=s,e=o<0?se(n):0}else return!1}}function se(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function N(n){return n.nodeType==1}function Y(n){return n.nodeType==3}function Ct(n,e){return e?n.contains(N(e)?e:e.parentNode):!1}function oh(n,e){for(;;){if(Y(n)&&e)return n;if(N(n)&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=se(n)}else if(n.parentNode&&!zn(n))e=te(n),n=n.parentNode;else return null}}function ih(n,e){for(;;){if(Y(n)&&e<n.nodeValue.length)return n;if(N(n)&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!zn(n))e=te(n)+1,n=n.parentNode;else return null}}function sh(n,e,t){for(let r=e==0,o=e==se(n);r||o;){if(n==t)return!0;let i=te(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,o=o&&i==se(n)}}function zn(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}var Er=function(n){return n.focusNode&&xt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function mt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function lh(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ah(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(se(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(se(r.startContainer),r.startOffset)}}}var Te=typeof navigator<"u"?navigator:null,ea=typeof document<"u"?document:null,tt=Te&&Te.userAgent||"",ti=/Edge\/(\d+)/.exec(tt),Na=/MSIE \d/.exec(tt),ni=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(tt),he=!!(Na||ni||ti),Qe=Na?document.documentMode:ni?+ni[1]:ti?+ti[1]:0,pe=!he&&/gecko\/(\d+)/i.test(tt);pe&&+(/Firefox\/(\d+)/.exec(tt)||[0,0])[1];var ri=!he&&/Chrome\/(\d+)/.exec(tt),ne=!!ri,Oa=ri?+ri[1]:0,le=!he&&!!Te&&/Apple Computer/.test(Te.vendor),Ut=le&&(/Mobile\/\w+/.test(tt)||!!Te&&Te.maxTouchPoints>2),ke=Ut||(Te?/Mac/.test(Te.platform):!1),Da=Te?/Win/.test(Te.platform):!1,Fe=/Android \d/.test(tt),Tr=!!ea&&"webkitFontSmoothing"in ea.documentElement.style,ch=Tr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function dh(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function ze(n,e){return typeof n=="number"?n:n[e]}function uh(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function ta(n,e,t){if(!oi(e)&&e.left==0)return;let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(!N(s)){s=Jt(s);continue}let l=s==i.body,a=l?dh(i):uh(s),c=0,d=0;if(e.top<a.top+ze(r,"top")?d=-(a.top-e.top+ze(o,"top")):e.bottom>a.bottom-ze(r,"bottom")&&(d=e.bottom-e.top>a.bottom-a.top?e.top+ze(o,"top")-a.top:e.bottom-a.bottom+ze(o,"bottom")),e.left<a.left+ze(r,"left")?c=-(a.left-e.left+ze(o,"left")):e.right>a.right-ze(r,"right")&&(c=e.right-a.right+ze(o,"right")),c||d)if(l)i.defaultView.scrollBy(c,d);else{let f=s.scrollLeft,h=s.scrollTop;d&&(s.scrollTop+=d),c&&(s.scrollLeft+=c);let p=s.scrollLeft-f,m=s.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}let u=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(u))break;s=u=="absolute"?s.offsetParent:Jt(s)}}function fh(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(i,s);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Ra(n.dom)}}function Ra(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Jt(r));return e}function hh({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Ia(t,r==0?0:r-e)}function Ia(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:i}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}var Kt=null;function ph(n){if(n.setActive)return n.setActive();if(Kt)return n.focus(Kt);let e=Ra(n);n.focus(Kt==null?{get preventScroll(){return Kt={preventScroll:!0},!0}}:void 0),Kt||(Kt=!1,Ia(e,0))}function Pa(n,e){let t,r=2e8,o,i=0,s=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(N(d))f=d.getClientRects();else if(Y(d))f=$e(d).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){t=d,r=m,o=m&&Y(t)?{left:p.right<e.left?p.right:p.left,top:e.top}:e,N(d)&&m&&(i=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!t&&a&&(t=a,o=c,r=0),t&&Y(t)?mh(t,o):!t||r?{node:n,offset:i}:Pa(t,o)}function mh(n,e){let t=n.nodeValue.length,r=document.createRange(),o;for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=Ye(r,1);if(s.top!=s.bottom&&ki(e,s)){o={node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),o||{node:n,offset:0}}function ki(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function gh(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function yh(n,e,t){let{node:r,offset:o}=Pa(e,t),i=-1;if(N(r)&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,o,i)}function bh(n,e,t,r){let o=-1;for(let i=e,s=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0),a;if(!l)return null;if(N(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function La(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=o;;){let s=n.childNodes[i];if(N(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(ki(e,c))return La(s,e,c)}}if((i=(i+1)%r)==o)break}return n}function wh(n,e){let t=n.dom.ownerDocument,r,o=0,i=ah(t,e.left,e.top);i&&({node:r,offset:o}=i);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s)){let c=n.dom.getBoundingClientRect();if(!ki(e,c)||(s=La(n.dom,e,c),!s))return null}if(le)for(let c=s;r&&c;c=Jt(c))c.draggable&&(r=void 0);if(s=gh(s,e),r){if(pe&&N(r)&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let d=r.childNodes[o],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&o++}let c;Tr&&o&&N(r)&&N(c=r.childNodes[o-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&N(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||!N(r)||r.childNodes[o-1].nodeName!="BR")&&(l=bh(n,r,o,e))}l==null&&(l=yh(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function oi(n){return n.top<n.bottom||n.left<n.right}function Ye(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(oi(r))return r}return Array.prototype.find.call(t,oi)||n.getBoundingClientRect()}var kh=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ba(n,e,t){let{node:r,offset:o,atom:i}=n.docView.domFromPos(e,t<0?-1:1),s=Tr||pe;if(Y(r))if(s&&(kh.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=Ye($e(r,o,o),t);if(pe&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=Ye($e(r,o-1,o-1),-1);if(c.top==a.top){let d=Ye($e(r,o,o+1),-1);if(d.top!=a.top)return An(d,d.left<c.left)}}return a}else{let a=o,c=o,d=t<0?1:-1;return t<0&&!o?(c++,d=-1):t>=0&&o==r.nodeValue.length?(a--,d=1):t<0?a--:c++,An(Ye($e(r,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(t<0||o==se(r))){let a=r.childNodes[o-1];if(N(a))return Xo(a.getBoundingClientRect(),!1)}if(i==null&&o<se(r)){let a=r.childNodes[o];if(N(a))return Xo(a.getBoundingClientRect(),!0)}return Xo(r.getBoundingClientRect(),t>=0)}if(i==null&&o&&(t<0||o==se(r))){let a=r.childNodes[o-1],c=Y(a)?$e(a,se(a)-(s?0:1)):N(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return An(Ye(c,1),!1)}if(i==null&&o<se(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?Y(a)?$e(a,0,s?0:1):N(a)?a:null:null;if(c)return An(Ye(c,-1),!0)}return An(Ye(Y(r)?$e(r):r,-t),t>=0)}function An(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Xo(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function za(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function Sh(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return za(n,e,()=>{let{node:i}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=Ba(n,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(N(l))a=l.getClientRects();else if(Y(l))a=$e(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}var xh=/[\u0590-\u08ac]/;function Ch(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=n.domSelection();return l?!xh.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:s:za(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!Ct(h,p)||a==p&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}var na=null,ra=null,oa=!1;function vh(n,e,t){return na==e&&ra==t?oa:(na=e,ra=t,oa=t=="up"||t=="down"?Sh(n,e,t):Ch(n,e,t))}var Se=0,ia=1,gt=2,ve=3,vt=class{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.dirty=Se,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){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,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=o.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,r){if(this.contentDOM&&Ct(this.contentDOM,e))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>te(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let i=e.compareDocumentPosition(this.contentDOM);i&16?o=t>Array.from(e.childNodes).findIndex(s=>s.contains(this.contentDOM)):o=!(i&4)}else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!t||i.node))if(r&&(s=i.nodeDOM)&&!(N(s)?Ct(s,e):s==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],i=r+o.size;if(r==e&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(e<i)return o.descAt(e-r-o.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>e){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(;r>0;r--){let i=this.children[r-1];if(i.size||!(i instanceof br||i instanceof gr&&i.side>=0))break}if(t<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&t&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?te(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?te(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(o==-1&&e<=c){let d=s+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=s;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=te(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=te(u.dom);break}t+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,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:r}=this.domFromPos(e,0);if(!N(t)||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,o=!1){let i=Math.min(e,t),s=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(i>p&&s<g)return m.setSelection(e-p-m.border,t-p-m.border,r,o);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((pe||le)&&e==t){let{node:h,offset:p}=l;if(Y(h)){if(u=!!(p&&h.nodeValue[p-1]==`
7
+ `),u&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:te(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=h.childNodes[p-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(pe&&d.focusNode&&d.focusNode!=a.node&&N(d.focusNode)){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(o=!0)}if(!(o||u&&le)&&xt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&xt(a.node,a.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(u&&pe)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){let i=this.children[o],s=r+i.size;if(r==s?e<=s&&t>=r:e<s&&t>r){let l=r+i.border,a=s-i.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?gt:ia,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=ve:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?gt:ve}r=s}this.dirty=gt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?gt:ia;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},gr=class extends vt{constructor(e,t,r,o){let i,s=t.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let l=N(s)?s:document.createElement("span");l!=s&&(l.appendChild(s),s=l),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Se&&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}},ii=class extends vt{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},bt=class n extends vt{constructor(e,t,r,o,i){super(e,[],r,o),this.mark=t,this.spec=i}static create(e,t,r,o){let i=o.nodeViews[t.type.name],s=i&&i(t,o,r);return(!s||!s.dom)&&(s=Pe.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&ve||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ve&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Se){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Se}}slice(e,t,r){let o=n.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;t<s&&(i=ci(i,t,s,r)),e>0&&(i=ci(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},et=class n extends vt{constructor(e,t,r,o,i,s,l){super(e,[],i,s),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,i,s){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(!Y(d))throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Pe.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=Ha(d,r,t),c?a=new si(e,t,r,o,d,u||null,f,c):t.isText?new yr(e,t,r,o,d,f):new n(e,t,r,o,d,u||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 r=this.children.length-1;r>=0;r--){let o=this.children[r];if(this.dom.contains(o.dom.parentNode)){t.contentElement=o.dom.parentNode;break}}if(!t.contentElement){let r=e&&e.find(o=>N(o)&&e.indexOf(o.parentNode)<0&&this.dom.contains(o));r?t.contentElement=r:t.getContent=()=>b.empty}}return t}matchesNode(e,t,r){return this.dirty==Se&&e.eq(this.node)&&wr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new ai(this,s&&s.node,e),c=this.node.inlineContent,d=c&&this.node.isBlock;Ah(this.node,this.innerDeco,(u,f,h)=>{u.spec.marks?a.syncToMarks(u.spec.marks,r,e,f):u.type.side>=0&&!h&&a.syncToMarks(f==this.node.childCount?P.none:this.node.child(f).marks,r,e,f),a.placeWidget(u,e,o)},(u,f,h,p)=>{a.syncToMarks(u.marks,r,e,p),d&&u.isAtom&&!u.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(u,f,h,p)||l&&e.state.selection.from>o&&e.state.selection.to<o+u.nodeSize&&(m=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(u,f,h,m,e)||a.updateNextNode(u,f,h,e,p,o)||a.addNode(u,f,h,e,o),o+=u.nodeSize,c&&(d=u.isAtom&&!u.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==gt)&&(s&&this.protectLocalComposition(e,s),$a(this.contentDOM,this.children,e),Ut&&Nh(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof C)||r<t||o>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 s=i.nodeValue,l=Oh(this.node.content,s,r-t,o-t);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){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 s=new ii(this,i,t,o);e.input.compositionNodes.push(s),this.children=ci(this.children,r,r+o.length,e,s)}update(e,t,r,o){return this.dirty==ve||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o),!0)}updateInner(e,t,r,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Se}updateOuterDeco(e){if(wr(e,this.outerDeco))return;let t=!N(this.nodeDOM),r=this.dom;this.dom=Fa(this.dom,this.nodeDOM,li(this.outerDeco,this.node,t),li(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){N(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){N(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 sa(n,e,t,r,o){Ha(r,e,n);let i=new et(void 0,n,e,t,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}var yr=class n extends et{constructor(e,t,r,o,i,s){super(e,t,r,o,i,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.dirty==ve||this.dirty!=Se&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Se||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=Se,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let o=this.node.cut(e,t),i=document.createTextNode(o.text);return new n(this.parent,o,this.outerDeco,this.innerDeco,i,i)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ve)}get domAtom(){return!1}isText(e){return this.node.text==e}},br=class extends vt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Se&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},si=class extends et{constructor(e,t,r,o,i,s,l,a){super(e,t,r,o,i,s,l),this.spec=a}update(e,t,r,o){if(this.dirty==ve)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,r);return i&&this.updateInner(e,t,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,o){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,o)}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 $a(n,e,t){let r=n.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==n){for(;l!=r;)r=la(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(s instanceof bt){let a=r?r.previousSibling:n.lastChild;$a(s.contentDOM,s.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=la(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}var On=function(n){n&&(this.nodeName=n)};On.prototype=Object.create(null);var yt=[new On];function li(n,e,t){if(n.length==0)return yt;let r=t?yt[0]:new On,o=[r];for(let i=0;i<n.length;i++){let s=n[i].type.attrs;if(s){s.nodeName&&o.push(r=new On(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&o.length==1&&o.push(r=new On(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function Fa(n,e,t,r){if(t==yt&&r==yt)return e;let o=e;for(let i=0;i<r.length;i++){let s=r[i],l=t[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=yt[0]),o=a}Mh(o,l||yt[0],s)}return o}function Mh(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&n.classList.add(o[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Ha(n,e,t){return Fa(n,n,yt,li(e,t,!N(n)))}function wr(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function la(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var ai=class{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Eh(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,o){let i=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=Se,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;o<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let d=this.index;d<c;d++){let u=this.top.children[d];if(u.matchesMark(e[s])&&!this.isLocked(u.dom)){a=d;break}}if(a<0&&this.index<this.top.children.length){let d=this.top.children[this.index];d instanceof bt&&d.dirty!=ve&&d.mark.type==e[s].type&&d.spec.update&&!this.isLocked(d.dom)&&d.spec.update(e[s])&&(d.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let d=bt.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,o,i){let s=this.top.children[o];return s.dirty==ve&&s.dom==s.contentDOM&&(s.dirty=gt),s.update(e,t,r,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof et){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,u,f=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=ve&&wr(t,a.outerDeco));if(!f&&a.update(e,t,r,o))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(a,e,t,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=gt,u.updateChildren(o,s+1),u.dirty=Se),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,i,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!wr(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=et.create(this.top,t,r,o,i,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,o,i){let s=et.create(this.top,e,t,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new gr(this.top,e,t,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof bt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof yr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((le||ne)&&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 r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new br(this.top,[],r,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||N(e)&&e.contains(this.lock.parentNode))}};function Eh(n,e){let t=e,r=t.children.length,o=n.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof bt)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function Th(n,e){return n.type.side-e.type.side}function Ah(n,e,t,r){let o=e.locals(n),i=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,o,e.forChild(i,d),c),i+=d.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,u;for(;s<o.length&&o[s].to==i;){let g=o[s++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(Th);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<n.childCount)h=c,f=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let p=i+f.nodeSize;if(f.isText){let g=p;s<o.length&&o[s].from<g&&(g=o[s].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=f.cut(g-i),f=f.cut(0,g-i),p=g,h=-1)}else for(;s<o.length&&o[s].to<p;)s++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,m,e.forChild(i,f),h),i=p}}function Nh(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Oh(n,e,t,r){for(let o=0,i=0;o<n.childCount&&i<=r;){let s=n.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<n.childCount;){let c=n.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function ci(n,e,t,r,o){let i=[];for(let s=0,l=0;s<n.length;s++){let a=n[s],c=l,d=l+=a.size;c>=t||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),o&&(i.push(o),o=void 0),d>t&&i.push(a.slice(t-c,a.size,r)))}return i}function Si(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),i=o&&o.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Er(t)){for(a=s;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&A.isSelectable(o.node)&&o.parent&&!(o.node.isInline&&sh(t.focusNode,t.focusOffset,o.dom))){let u=o.posBefore;c=new A(s==u?l:r.resolve(u))}else if(pe&&e=="key"&&s>n.state.selection.to&&N(t.focusNode)&&t.focusOffset==t.focusNode.childNodes.length&&o&&o.posAtStart>n.state.selection.to)for(let u=t.focusNode;;u=u.parentNode){if(getComputedStyle(u).overflow!="visible"){c=T.findFrom(r.resolve(o.posAtStart),1);break}if(u==o.dom||u.nextSibling||!u.parentNode||!N(u.parentNode))break}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=s,f=s;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);u=Math.min(u,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,s]=f==n.state.selection.anchor?[f,u]:[u,f],l=r.resolve(s)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=xi(n,d,l,u)}return c}function Va(n){return n.editable?n.hasFocus():ja(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Ve(n,e=!1){let t=n.state.selection;if(Wa(n,t),!Va(n))return;let r=n.input.mouseDown;if(!e&&ne&&r){let o=n.domSelectionRange(),i=n.domObserver.currentSelection;if(o.anchorNode&&i.anchorNode&&xt(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Rh(n);else{let{anchor:o,head:i}=t,s,l;aa&&!(t instanceof C)&&(t.$from.parent.inlineContent||(s=ca(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=ca(n,t.to))),n.docView.setSelection(o,i,n,e),aa&&(s&&da(s),l&&da(l)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Dh(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}var aa=le||ne&&Oa<63;function ca(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(le&&o&&o.contentEditable=="false")return Yo(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return Yo(o);if(i)return Yo(i)}}function Yo(n){return n.contentEditable="true",le&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function da(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Dh(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Va(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Rh(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,te(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&he&&Qe<=11&&(t.disabled=!0,t.disabled=!1)}function Wa(n,e){if(e instanceof A){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ua(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ua(n)}function ua(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function xi(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||C.between(e,t,r)}function fa(n){return n.editable&&!n.hasFocus()?!1:ja(n)}function ja(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return Ct(n.dom,e.anchorNode)&&(n.editable||Ct(n.dom,e.focusNode))}catch{return!1}}function Ih(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return xt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function di(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),i=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return i&&T.findFrom(i,e)}function Ze(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ha(n,e,t){let r=n.state.selection;if(r instanceof C)if(t.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=n.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return Ze(n,new C(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=di(n.state,e);return o&&o instanceof A?Ze(n,o):!1}else if(!ke||t.indexOf("m")<0){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?A.isSelectable(i)?Ze(n,new A(e<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):Ze(n,new C(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof A&&r.node.isInline)return Ze(n,new C(e>0?r.$to:r.$from));{let o=di(n.state,e);return o?Ze(n,o):!1}}}function Dn(n,e){let t=n.pmViewDesc;return t?t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR"):N(n)&&n.contentEditable=="false"}function _t(n,e){return e<0?Ph(n):Lh(n)}function Ph(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,i,s=!1;for(pe&&N(t)&&r<se(t)&&Dn(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!N(t))break;let l=t.childNodes[r-1];if(Dn(l,-1))o=t,i=--r;else if(Y(l))t=l,r=t.nodeValue.length;else break}else{if(Ka(t))break;{let l=t.previousSibling;for(;l&&Dn(l,-1);)o=t.parentNode,i=te(l),l=l.previousSibling;if(l)t=l,r=se(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?ui(n,t,r):o&&ui(n,o,i)}function Lh(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=se(t),i,s;for(;;)if(r<o){if(!N(t))break;let l=t.childNodes[r];if(Dn(l,1))i=t,s=++r;else break}else{if(Ka(t))break;{let l=t.nextSibling;for(;l&&Dn(l,1);)i=l.parentNode,s=te(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=se(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}i&&ui(n,i,s)}function Ka(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Bh(n,e){for(;n&&e==n.childNodes.length&&!zn(n);)e=te(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(Y(t))return t;if(N(t)&&t.contentEditable=="false")break;n=t,e=0}}function zh(n,e){for(;n&&!e&&!zn(n);)e=te(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(Y(t))return t;if(N(t)&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function ui(n,e,t){if(!Y(e)){let s,l;(l=Bh(e,t))?(e=l,t=0):(s=zh(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection(),o=n.domSelectionRange();if(!r)return;Er(o)?r.collapse(e,t):r.extend&&(r.collapse(o.anchorNode,o.anchorOffset),r.extend(e,t)),n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&Ve(n)},50)}function pa(n,e){let t=n.state.doc.resolve(e);if(!(ne||Da)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}let r=n.dom;for(let i=t.depth;i>0;i--)if(t.node(i).isBlock){r=n.nodeDOM(t.before(i))||r;break}return getComputedStyle(r).direction=="rtl"?"rtl":"ltr"}function ma(n,e,t){let r=n.state.selection;if(r instanceof C&&!r.empty||t.indexOf("s")>-1||ke&&t.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=di(n.state,e);if(s&&s instanceof A)return Ze(n,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof de?T.near(s,e):T.findFrom(s,e);return l?Ze(n,l):!1}return!1}function ga(n,e){if(!(n.state.selection instanceof C))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let s=n.state.tr;return e<0?s.delete(t.pos-i.nodeSize,t.pos):s.delete(t.pos,t.pos+i.nodeSize),n.dispatch(s),!0}return!1}function ya(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function $h(n){if(!le||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&N(e)&&t==0&&e.firstChild&&N(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;ya(n,r,"true"),setTimeout(()=>ya(n,r,"false"),20)}return!1}function Fh(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Hh(n,e){let t=e.keyCode,r=Fh(e);if(t==8||ke&&t==72&&r=="c")return ga(n,-1)||_t(n,-1);if(t==46&&!e.shiftKey||ke&&t==68&&r=="c")return ga(n,1)||_t(n,1);if(t==13||t==27)return!0;if(t==37||ke&&t==66&&r=="c"){let o=t==37?pa(n,n.state.selection.from)=="ltr"?-1:1:-1;return ha(n,o,r)||_t(n,o)}else if(t==39||ke&&t==70&&r=="c"){let o=t==39?pa(n,n.state.selection.from)=="ltr"?1:-1:1;return ha(n,o,r)||_t(n,o)}else{if(t==38||ke&&t==80&&r=="c")return ma(n,-1,r)||_t(n,-1);if(t==40||ke&&t==78&&r=="c")return $h(n)||ma(n,1,r)||_t(n,1);if(r==(ke?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ci(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=n.someProp("clipboardSerializer")||Pe.fromSchema(n.state.schema),l=Xa(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&N(c)&&(d=Ga[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let p=l.createElement(d[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&N(c)&&c.setAttribute("data-pm-slice",`${o} ${i}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
8
+
9
+ `);return{dom:a,text:f,slice:e}}function _a(n,e,t,r,o){let i=o.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=!!e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,i||r,n)}),i)return l=new w(b.from(n.state.schema.text(e.replace(/\r\n?/g,`
10
+ `))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let u=n.someProp("clipboardTextParser",f=>f(e,o,r,n));if(u)l=u;else{let f=o.marks(),{schema:h}=n.state,p=Pe.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),s=Kh(t),Tr&&_h(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=s.firstChild;for(;f&&!N(f);)f=f.nextSibling;if(!f)break;s=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Ie.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Vh.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=qh(ba(l,+d[1],+d[2]),d[4]);else if(l=w.maxOpen(Wh(l.content,o),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=ba(l,u,f)}return n.someProp("transformPasted",u=>{l=u(l,n,a)}),l}var Vh=/^(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 Wh(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),i,s=[];if(n.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&Ja(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Ua(s[s.length-1],i.length));let d=qa(l,a);s.push(d),o=o.matchType(d.type),i=a}}),s)return b.from(s)}return n}function qa(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,b.from(n));return n}function Ja(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let i=Ja(n,e,t,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(b.from(qa(t,n,o+1))))}}function Ua(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Ua(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(b.empty,!0);return n.copy(t.append(r))}function fi(n,e,t,r,o,i){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(i=0),o<r-1&&(l=fi(l,e,t,r,o+1,i)),o>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(b.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function ba(n,e,t){return e<n.openStart&&(n=new w(fi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new w(fi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var Ga={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 Xa(){return document.implementation.createHTMLDocument("title")}var Nn=null;function jh(n){let e=window.trustedTypes;if(!e)return n;if(!Nn){if(Nn=e.defaultPolicy)try{return Nn.createHTML(n)}catch{}Nn=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return Nn.createHTML(n)}function Kh(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Xa(),r=t.body,o=/<([a-z][^>\s]+)/i.exec(n),i;if((i=o&&Ga[o[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=jh(n),i)for(let s=0;s<i.length;s++)r=r.querySelector(i[s])||r;for(let s=0;s<t.styleSheets.length;s++){let l=t.styleSheets[s];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let d=r.querySelectorAll(c.selectorText);for(let u=0;u<d.length;u++)d[u].style.cssText+=c.style.cssText}}}return r}function _h(n){let e=n.querySelectorAll(ne?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function qh(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:i,openEnd:s}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{o=b.from(a.create(r[l+1],o))}catch{break}i++,s++}return new w(o,i,s)}var ue={},fe={},Jh={touchstart:!0,touchmove:!0},hi=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,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 Uh(n){for(let e in ue){let t=ue[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Xh(n,r)&&!vi(n,r)&&(n.editable||!(r.type in fe))&&t(n,r)},Jh[e]?{passive:!0}:void 0)}le&&n.dom.addEventListener("input",()=>null),pi(n)}function He(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Gh(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function pi(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>vi(n,r))})}function vi(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Xh(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Yh(n,e){!vi(n,e)&&ue[e.type]&&(n.editable||!(e.type in fe))&&ue[e.type](n,e)}fe.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Qa(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Fe&&ne&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Ut&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,mt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Hh(n,t)?t.preventDefault():He(n,"key")};fe.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};fe.keypress=(n,e)=>{let t=e;if(Qa(n)||!t.charCode||t.ctrlKey&&!t.altKey||ke&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof C)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode),i=()=>n.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o,i))&&n.dispatch(i()),t.preventDefault()}};function $n(n){return{left:n.clientX,top:n.clientY}}function Zh(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Mi(n,e,t,r,o){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(n.someProp(e,l=>s>i.depth?l(n,t,i.nodeAfter,i.before(s),o,!0):l(n,t,i.node(s),i.before(s),o,!1)))return!0;return!1}function Fn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Qh(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&A.isSelectable(r)?(Fn(n,new A(t)),!0):!1}function ep(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof A&&(r=t.node);let i=n.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(A.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?o=i.before(t.$from.depth):o=i.before(s);break}}return o!=null?(Fn(n,A.create(n.state.doc,o)),!0):!1}function tp(n,e,t,r,o){return Mi(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(o?ep(n,t):Qh(n,t))}function np(n,e,t,r){return Mi(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function rp(n,e,t,r){return Mi(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||op(n,t,r)}function op(n,e,t){if(t.button!=0)return!1;let r=Ya(n,e,!0),o=n.state.doc;return r?(Fn(n,r),r instanceof C&&o.eq(n.state.doc)&&(n.input.mouseDown=new gi(n,r)),!0):!1}function Ya(n,e,t){let r=n.state.doc;if(e==-1)return r.inlineContent?C.create(r,0,r.content.size):null;let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)return C.create(r,l+1,l+1+s.content.size);if(t&&A.isSelectable(s))return A.create(r,l)}return null}function Ei(n){return Sr(n)}var Za=ke?"metaKey":"ctrlKey";ue.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Ei(n),o=Date.now(),i="singleClick";o-n.input.lastClick.time<500&&Zh(t,n.input.lastClick)&&!t[Za]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:i,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let s=n.posAtCoords($n(t));s&&(i=="singleClick"?n.input.mouseDown=new mi(n,s,t,!!r):(i=="doubleClick"?np:rp)(n,s.pos,s.inside,t)?t.preventDefault():He(n,"pointer"))};var kr=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}},mi=class extends kr{constructor(e,t,r,o){super(e),this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[Za],this.allowDefault=r.shiftKey;let i,s;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),s=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,s=d.depth?d.before():0}let l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&N(a.nodeDOM)?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof A&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&pe&&!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()),He(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||Ve(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($n(e))),this.updateAllowDefault(e),this.allowDefault||!t?He(this.view,"pointer"):tp(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||le&&this.mightDrag&&!this.mightDrag.node.isAtom||ne&&!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)?(Fn(this.view,T.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):He(this.view,"pointer")}move(e){this.updateAllowDefault(e),He(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}},gi=class extends kr{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(),He(this.view,"pointer");let t=this.view.posAtCoords($n(e)),r=t&&Ya(this.view,t.inside,!1);if(!r)return;let{doc:o}=this.view.state,i=this.startSelection,[s,l]=r.from<i.from?[i.to,r.from]:[i.from,r.to];Fn(this.view,C.create(o,s,l))}};ue.touchstart=n=>{n.input.lastTouch=Date.now(),Ei(n),He(n,"pointer")};ue.touchmove=n=>{n.input.lastTouch=Date.now(),He(n,"pointer")};ue.contextmenu=n=>Ei(n);function Qa(n,e){return n.composing?!0:le&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var ip=Fe?5e3:-1;fe.compositionstart=fe.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof C&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ne&&Da&&sp(n)))n.markCursor=n.state.storedMarks||t.marks(),Sr(n,!0),n.markCursor=null;else if(Sr(n,!e.selection.empty),pe&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&N(o)&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(Y(s)){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}n.input.composing=!0}ec(n,ip)};function sp(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||!N(e)||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return N(r)&&r.contentEditable=="false"}fe.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,ec(n,20))};function ec(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Sr(n),e))}function tc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function lp(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=oh(e.focusNode,e.focusOffset),r=ih(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function Sr(n,e=!1){if(!(Fe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),tc(n),e||n.docView&&n.docView.dirty){let t=Si(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function ap(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var Rn=he&&Qe<15||Ut&&ch<604;ue.copy=fe.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let i=Rn?null:t.clipboardData,s=r.content(),{dom:l,text:a}=Ci(n,s);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):ap(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function cp(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function dp(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?In(n,r.value,null,o,e):In(n,r.textContent,r.innerHTML,o,e)},50)}function In(n,e,t,r,o){let i=_a(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,i||w.empty)))return!0;if(!i)return!1;let s=cp(i),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function nc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}fe.paste=(n,e)=>{let t=e;if(n.composing&&!Fe)return;let r=Rn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&In(n,nc(r),r.getData("text/html"),o,t)?t.preventDefault():dp(n,t)};var xr=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},up=ke?"altKey":"ctrlKey";function rc(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[up]}ue.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords($n(t)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof A?o.to-1:o.to))){if(r&&r.mightDrag)s=A.create(n.state.doc,r.mightDrag.pos);else if(t.target&&N(t.target)){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(s=A.create(n.state.doc,u.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:d}=Ci(n,l);(!t.dataTransfer.files.length||!ne||Oa>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Rn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Rn||t.dataTransfer.setData("text/plain",c),n.dragging=new xr(d,rc(n,t),s)};ue.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};fe.dragover=fe.dragenter=(n,e)=>e.preventDefault();fe.drop=(n,e)=>{try{fp(n,e,n.dragging)}finally{n.dragging=null}};function fp(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords($n(e));if(!r)return;let o=n.state.doc.resolve(r.pos),i=t&&t.slice;i?n.someProp("transformPasted",h=>{i=h(i,n,!1)}):i=_a(n,nc(e.dataTransfer),Rn?null:e.dataTransfer.getData("text/html"),!1,o);let s=!!(t&&rc(n,e));if(n.someProp("handleDrop",h=>h(n,e,i||w.empty,s))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?dr(n.state.doc,o.pos,i):o.pos;l==null&&(l=o.pos);let a=n.state.tr;if(s){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,u=a.doc;if(d?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(u))return;let f=a.doc.resolve(c);if(d&&A.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new A(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),a.setSelection(xi(n,f,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}ue.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Ve(n)},20))};ue.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};ue.beforeinput=(n,e)=>{if(Fe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,mt(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in fe)ue[n]=fe[n];function Pn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var Ln=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}},Cr=class n{constructor(e,t){this.toDOM=e,this.spec=t||kt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:i,deleted:s}=e.mapResult(t.from+o,this.side<0?-1:1);return s?null:new Z(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Pn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},wt=class n{constructor(e,t){this.attrs=e,this.spec=t||kt}map(e,t,r,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new Z(i,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&Pn(this.attrs,e.attrs)&&Pn(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},yi=class n{constructor(e,t){this.attrs=e,this.spec=t||kt}map(e,t,r,o){let i=e.mapResult(t.from+o,1);if(i.deleted)return null;let s=e.mapResult(t.to+o,-1);return s.deleted||s.pos<=i.pos?null:new Z(i.pos-r,s.pos-r,this)}valid(e,t,r){let o=r.nodeAt(t.from);return!!o&&!o.isText&&t.from+o.nodeSize==t.to}eq(e){return this==e||e instanceof n&&Pn(this.attrs,e.attrs)&&Pn(this.spec,e.spec)}destroy(){}},Z=class n{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new n(e,t,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,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new n(e,e,new Cr(t,r))}static inline(e,t,r,o){return new n(e,t,new wt(r,o))}static node(e,t,r,o){return new n(e,t,new yi(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof wt}get widget(){return this.type instanceof Cr}},qt=[],kt={},L=class n{constructor(e,t){this.local=e.length?e:qt,this.children=t.length?t:qt}static create(e,t){return t.length?Mr(t,e,0,kt):ie}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,o+l,i)}}map(e,t,r){return this==ie||e.maps.length==0?this:this.mapInner(e,t,0,0,r||kt)}mapInner(e,t,r,o,i){let s;if(this.local.length){let l=new Ln(t.content);for(let a=0;a<this.local.length;a++){let c=this.local[a].map(e,r,o);c&&c.type.valid(t,c,l)?(s||(s=[])).push(c):i.onRemove&&i.onRemove(this.local[a].spec)}}return this.children.length?hp(this.children,s||[],e,t,r,o,i):s?new n(s.sort(St),qt):ie}add(e,t){return t.length?this==ie?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,i=0;e.forEach((l,a)=>{let c=a+r,d;if(d=ic(t,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,d,c+1):o.splice(i,0,a,a+l.nodeSize,Mr(d,l,c+1,kt)),i+=3}});let s=oc(i?sc(t):t,-r);if(s.length){let l=new Ln(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||s.splice(a--,1)}return new n(s.length?this.local.concat(s).sort(St):this.local,o||this.children)}remove(e){return e.length==0||this==ie?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+t,a=r[i+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(s||(s=[])).push(u));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,l+1);c!=ie?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<e.length;i++)if(s=e[i])for(let l=0;l<o.length;l++)o[l].eq(s,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new n(o,r):ie}forChild(e,t){if(this==ie)return this;if(t.isLeaf)return n.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,s=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>i&&a.type instanceof wt){let c=Math.max(i,a.from)-i,d=Math.min(s,a.to)-i;c<d&&(o||(o=[])).push(a.copy(c,d))}}if(o){let l=new n(o.sort(St),qt);return r?new vr([l,r]):l}return r||ie}eq(e){if(this==e)return!0;if(!(e instanceof n)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ti(this.localsInner(e))}localsInner(e){if(this==ie)return qt;if(e.inlineContent||!this.local.some(wt.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof wt||t.push(this.local[r]);return t}forEachSet(e){e(this)}};L.empty=new L([],[]);L.removeOverlap=Ti;var ie=L.empty,vr=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(o=>o.map(e,t,kt));return n.from(r)}forChild(e,t){if(t.isLeaf)return L.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,t);i!=ie&&(i instanceof n?r=r.concat(i.members):r.push(i))}return n.from(r)}eq(e){if(!(e instanceof n)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let s=0;s<i.length;s++)t.push(i[s])}}return t?Ti(r?t:t.sort(St)):qt}static from(e){switch(e.length){case 0:return ie;case 1:return e[0];default:return new n(e.every(t=>t instanceof L)?e:e.reduce((t,r)=>t.concat(r instanceof L?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function hp(n,e,t,r,o,i,s){let l=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let u=0;t.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let y=0;y<l.length;y+=3){let k=l[y+1];if(k<0||f>k+d-u)continue;let S=l[y]+d-u;h>=S?l[y+1]=f<=S?-2:-1:f>=d&&g&&(l[y]+=g,l[y+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+i),u=d-o;if(u<0||u>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+i,-1),h=f-o,{index:p,offset:m}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&m==u&&m+g.nodeSize==h){let y=l[c+2].mapInner(t,g,d+1,n[c]+i+1,s);y!=ie?(l[c]=u,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=pp(l,n,e,t,o,i,s),d=Mr(c,r,0,s);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let h=d.children[u];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new L(e.sort(St),l)}function oc(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new Z(o.from+e,o.to+e,o.type))}return t}function pp(n,e,t,r,o,i,s){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,o,c);u?t.push(u):s.onRemove&&s.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function ic(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let i=0,s;i<n.length;i++)(s=n[i])&&s.from>t&&s.to<r&&((o||(o=[])).push(s),n[i]=null);return o}function sc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Mr(n,e,t,r){let o=[],i=!1;e.forEach((l,a)=>{let c=ic(n,l,a+t);if(c){i=!0;let d=Mr(c,l,t+a+1,r);d!=ie&&o.push(a,a+l.nodeSize,d)}});let s=oc(i?sc(n):n,-t).sort(St);if(s.length){let l=new Ln(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1))}return s.length||o.length?new L(s,o):ie}function St(n,e){return n.from-e.from||n.to-e.to}function Ti(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let i=e[o];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[o]=i.copy(i.from,r.to),wa(e,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),wa(e,o,r.copy(i.from,r.to)));break}}}return e}function wa(n,e,t){for(;e<n.length&&St(t,n[e])>0;)e++;n.splice(e,0,t)}function Zo(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ie&&e.push(r)}),n.cursorWrapper&&e.push(L.create(n.state.doc,[n.cursorWrapper.deco])),vr.from(e)}var mp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},gp=he&&Qe<=11,bi=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}},wi=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new bi,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);he&&Qe<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():le&&e.composing&&r.some(o=>o.type=="childList"&&o.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),gp&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,mp)),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(fa(this.view)){if(this.suppressingSelectionUpdates)return Ve(this.view);if(he&&Qe<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&xt(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,r;for(let i=e.focusNode;i;i=Jt(i))t.add(i);for(let i=e.anchorNode;i;i=Jt(i))if(t.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:Y(r)?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r,o=!1;!this.suppressingSelectionUpdates&&fa(e)&&(r=e.domSelectionRange(),o=!this.currentSelection.eq(r)&&!this.ignoreSelectionChange(r));let i=-1,s=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(i=i<0?u.from:Math.min(u.from,i),s=s<0?u.to:Math.max(u.to,s),u.typeOver&&(l=!0))}if(a.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||ne&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(d=>d.type=="childList"&&d.removedNodes.length))){for(let d of a)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;for(;u&&N(u);){if(u.contentEditable=="false"){d.parentNode.removeChild(d);break}u=u.firstChild}}}else if(pe&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||wp(e,u)!=h)&&f.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Er(r)&&(c=Si(e))&&c.eq(T.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ve(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,s),yp(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,kp(e,a)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):r&&!this.currentSelection.eq(r)&&Ve(e),r&&this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),Y(u)&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,i=e.nextSibling;if(he&&Qe<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(o=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f)}let s=o&&o.parentNode==e.target?te(o)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=i&&i.parentNode==e.target?te(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},ka=new WeakMap,Sa=!1;function yp(n){if(!ka.has(n)&&(ka.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=pe,Sa)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."),Sa=!0}}function xa(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return xt(s.node,s.offset,o,i)&&([t,r,o,i]=[o,i,t,r]),{anchorNode:t,anchorOffset:r,focusNode:o,focusOffset:i}}function bp(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return xa(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?xa(n,t):null}function wp(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function kp(n,e){var t;let{focusNode:r,focusOffset:o}=n.domSelectionRange();for(let i of e)if(((t=i.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=i.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!N(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&n.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}function Sp(n,e,t,r){let{node:o,fromOffset:i,toOffset:s,from:l,to:a}=n.docView.parseRange(e,t),c=n.domSelectionRange(),d,u=c.anchorNode;if(u&&Ct(n.dom,u)&&(d=[{node:u,offset:c.anchorOffset}],Er(c)||d.push({node:c.focusNode,offset:c.focusOffset})),ne&&n.input.lastKeyCode===8)for(let y=s;y>i;y--){let k=o.childNodes[y-1],S=k.pmViewDesc;if(k.nodeName=="BR"&&!S){s=y;break}if(!S||S.size)break}let f=n.state.doc,h=n.someProp("domParser")||Ie.fromSchema(n.state.schema),p=f.resolve(l),m=null,g=h.parse(o,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:xp(r),context:p});if(d&&d[0].pos!=null){let y=d[0].pos,k=d[1]&&d[1].pos;k==null&&(k=y),m={anchor:y+l,head:k+l}}return{doc:g,sel:m,from:l,to:a}}var xp=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(le&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||le&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},Cp=/^(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 vp(n,e,t,r,o){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let E=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,R=Si(n,E);if(R&&!n.state.selection.eq(R)){if(ne&&Fe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",W=>W(n,mt(13,"Enter"))))return;let V=n.state.tr.setSelection(R);E=="pointer"?V.setMeta("pointer",!0):E=="key"&&V.scrollIntoView(),i&&V.setMeta("composition",i),n.dispatch(V)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Sp(n,e,t,o),d=n.state.doc,u=d.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=Ap(u.content,c.doc.content,c.from,f,h);if(p&&n.input.domChangeCount++,(Ut&&n.input.lastIOSEnter>Date.now()-225||Fe)&&o.some(E=>N(E)&&!Cp.test(E.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",E=>E(n,mt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof C&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let E=Ca(n,n.state.doc,c.sel);if(E&&!E.eq(n.state.selection)){let R=n.state.tr.setSelection(E);i&&R.setMeta("composition",i),n.dispatch(R)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof C&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),he&&Qe<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=d.resolve(p.start),k=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((Ut&&n.input.lastIOSEnter>Date.now()-225&&(!k||o.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!k&&Tp(c.doc,m.pos,g.pos))&&n.someProp("handleKeyDown",E=>E(n,mt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&(k?p.endA>p.start&&p.endB==p.start:Ep(d,p.start,p.endA,m,g))&&n.someProp("handleKeyDown",E=>E(n,mt(8,"Backspace")))){Fe&&ne&&n.domObserver.suppressSelectionUpdates();return}ne&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),Fe&&!k&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(E){return E(n,mt(13,"Enter"))})},20));let S=p.start,v=p.endA,D=E=>{let R=E||n.state.tr.replace(S,v,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let V=Ca(n,R.doc,c.sel);V&&!(ne&&n.composing&&V.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(V.head==S||V.head==R.mapping.map(v)-1)||he&&V.empty&&V.head==S)&&R.setSelection(V)}return i&&R.setMeta("composition",i),R.scrollIntoView()},$;if(k)if(m.pos==g.pos){he&&Qe<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ve(n),20));let E=D(n.state.tr.delete(S,v)),R=d.resolve(p.start).marksAcross(d.resolve(p.endA));R&&E.ensureMarks(R),n.dispatch(E)}else if(p.endA==p.endB&&($=Mp(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let E=D(n.state.tr);$.type=="add"?E.addMark(S,v,$.mark):E.removeMark(S,v,$.mark),n.dispatch(E)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let E=m.parent.textBetween(m.parentOffset,g.parentOffset),R=()=>D(n.state.tr.insertText(E,S,v));n.someProp("handleTextInput",V=>V(n,S,v,E,R))||n.dispatch(R())}else n.dispatch(D());else n.dispatch(D())}function Ca(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:xi(n,e.resolve(t.anchor),e.resolve(t.head))}function Mp(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,i=r,s,l,a;for(let d=0;d<r.length;d++)o=r[d].removeFromSet(o);for(let d=0;d<t.length;d++)i=t[d].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s="add",a=d=>d.mark(l.addToSet(d.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(b.from(c).eq(n))return{mark:l,type:s}}function Ep(n,e,t,r,o){if(t-e<=o.pos-r.pos||Qo(r,!0,!1)<o.pos)return!1;let i=n.resolve(e);if(!r.parent.inlineContent){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=n.resolve(Qo(i,!0,!0));return!s.parent.isTextblock||s.pos>t||Qo(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Tp(n,e,t){let r=0,o=0;return n.nodesBetween(e,t,(i,s)=>{i.isTextblock&&s>=e&&s<t?r++:(i.isText?/\S/.test(i.text.slice(Math.max(0,e-s),Math.min(i.nodeSize,t-s))):i.isLeaf)&&o++}),o==0&&r==1}function Qo(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function Ap(n,e,t,r,o){let i=n.findDiffStart(e,t),s=t+n.size,l=t+e.size;if(i==null)return null;let{a,b:c}=n.findDiffEnd(e,s,l);if(o=="end"){let d=Math.max(0,i-Math.min(a,c));r-=a+d-i}if(a<i&&s<l){let d=r<=i&&r>=a?i-r:0;i-=d,c=i+(c-a),a=i}else if(c<i){let d=r<=i&&r>=c?i-r:0;i-=d,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}var Bn=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 hi,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Aa),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=Ea(this),Ma(this),this.nodeViews=Ta(this),this.docView=sa(this.state.doc,va(this),Zo(this),this.dom,this),this.domObserver=new wi(this,(r,o,i,s)=>vp(this,r,o,i,s)),this.domObserver.start(),Uh(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&&pi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Aa),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(tc(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Ta(this);Op(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&pi(this),this.editable=Ea(this),Ma(this);let a=Zo(this),c=va(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(o.selection))&&(s=!0);let f=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&fh(this);if(s){this.domObserver.stop();let h=u&&(he||ne)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Np(o.selection,e.selection);if(u){let m=ne?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=lp(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=sa(e.doc,c,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let p=this.input.mouseDown;h||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ih(this)&&p.delaySelUpdate())?Ve(this,h):(Wa(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&hh(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!Ct(this.dom,e))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof A){let t=this.docView.domAfterPos(this.state.selection.from);N(t)&&ta(this,t.getBoundingClientRect(),e)}else ta(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 t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new xr(e.slice,e.move,o<0?void 0:A.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=t?t(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(he){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&&ph(this.dom),Ve(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return wh(this,e)}coordsAtPos(e,t=1){return Ba(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,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return vh(this,t||this.state,e)}pasteHTML(e,t){return In(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return In(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ci(this,e)}destroy(){this.docView&&(Gh(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Zo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,nh())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Yh(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?le&&this.root.nodeType===11&&lh(this.dom.ownerDocument)==this.dom&&bp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Bn.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function va(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Z.node(0,n.state.doc.content.size,e)]}function Ma(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Z.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Ea(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Np(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ta(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Op(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function Aa(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var We={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:"'"},Nr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Dp=typeof navigator<"u"&&/Mac/.test(navigator.platform),Rp=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(G=0;G<10;G++)We[48+G]=We[96+G]=String(G);var G;for(G=1;G<=24;G++)We[G+111]="F"+G;var G;for(G=65;G<=90;G++)We[G]=String.fromCharCode(G+32),Nr[G]=String.fromCharCode(G);var G;for(Ar in We)Nr.hasOwnProperty(Ar)||(Nr[Ar]=We[Ar]);var Ar;function lc(n){var e=Dp&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Rp&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Nr:We)[n.keyCode]||n.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 Ip=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Pp=typeof navigator<"u"&&/Win/.test(navigator.platform);function Lp(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,i,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Ip?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),s&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function Bp(n){let e=Object.create(null);for(let t in n)e[Lp(t)]=n[t];return e}function Ai(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function ac(n){return new I({props:{handleKeyDown:Hn(n)}})}function Hn(n){let e=Bp(n);return function(t,r){let o=lc(r),i,s=e[Ai(o,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[Ai(o,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Pp&&r.ctrlKey&&r.altKey)&&(i=We[r.keyCode])&&i!=o){let l=e[Ai(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Or=200,re=function(){};re.prototype.append=function(e){return e.length?(e=re.from(e),!this.length&&e||e.length<Or&&this.leafAppend(e)||this.length<Or&&e.leafPrepend(this)||this.appendInner(e)):this};re.prototype.prepend=function(e){return e.length?re.from(e).append(this):this};re.prototype.appendInner=function(e){return new zp(this,e)};re.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?re.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};re.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};re.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};re.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},t,r),o};re.from=function(e){return e instanceof re?e:e&&e.length?new cc(e):re.empty};var cc=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Or)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Or)return new e(o.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(re);re.empty=new cc([]);var zp=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(re),Ni=re;var $p=500,Et=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;t&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){o||(o=this.remapping(r,f+1),i=o.maps.length),i--,d.push(u);return}if(o){d.push(new Ae(u.map));let h=u.step.map(o.slice(i)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new Ae(p,void 0,void 0,c.length+d.length))),i--,p&&o.appendMap(p,i)}else s.maybeStep(u.step);if(u.selection)return l=o?u.selection.map(o.slice(i)):u.selection,a=new n(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new Ae(e.mapping.maps[d],u,t),h;(h=a&&a.merge(f))&&(f=h,d?i.pop():l=l.slice(0,l.length-1)),i.push(f),t&&(s++,t=void 0),o||(a=f)}let c=s-r.depth;return c>Hp&&(l=Fp(l,c),s-=c),new n(l.append(i),s)}remapping(e,t){let r=new xn;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new Ae(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let r=[],o=this.items.length-t,i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},o);let a=t;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=i.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(i.slice(a+1,h));g&&l++,r.push(new Ae(p,m,g))}else r.push(new Ae(p))},o);let c=[];for(let f=t;f<s;f++)c.push(new Ae(i.maps[f]));let d=this.items.slice(0,o).append(c).append(r),u=new n(d,l);return u.emptyItemCount()>$p&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let d=s.selection&&s.selection.map(t.slice(r));d&&i++;let u=new Ae(c.invert(),a,d),f,h=o.length-1;(f=o.length&&o[h].merge(u))?o[h]=f:o.push(u)}}else s.map&&r--},this.items.length,0),new n(Ni.from(o.reverse()),i)}};Et.empty=new Et(Ni.empty,0);function Fp(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}var Ae=class n{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},Ne=class{constructor(e,t,r,o,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},Hp=20;function Vp(n,e,t,r){let o=t.getMeta(Mt),i;if(o)return o.historyState;t.getMeta(hc)&&(n=new Ne(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(Mt))return s.getMeta(Mt).redo?new Ne(n.done.addTransform(t,void 0,r,Dr(e)),n.undone,dc(t.mapping.maps),n.prevTime,n.prevComposition):new Ne(n.done,n.undone.addTransform(t,void 0,r,Dr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Wp(t,n.prevRanges)),c=s?Oi(n.prevRanges,t.mapping):dc(t.mapping.maps);return new Ne(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Dr(e)),Et.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new Ne(n.done.rebased(t,i),n.undone.rebased(t,i),Oi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Ne(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Oi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Wp(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&o>=e[i]&&(t=!0)}),t}function dc(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,i,s)=>e.push(i,s));return e}function Oi(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let o=e.map(n[r],1),i=e.map(n[r+1],-1);o<=i&&t.push(o,i)}return t}function jp(n,e,t){let r=Dr(e),o=Mt.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),o,r),a=new Ne(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(Mt,{redo:t,historyState:a})}var Di=!1,uc=null;function Dr(n){let e=n.plugins;if(uc!=e){Di=!1,uc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Di=!0;break}}return Di}function fc(n){return n.setMeta(hc,!0)}var Mt=new F("history"),hc=new F("closeHistory");function pc(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new I({key:Mt,state:{init(){return new Ne(Et.empty,Et.empty,null,0,-1)},apply(e,t,r){return Vp(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,o=r=="historyUndo"?Ri:r=="historyRedo"?Ii:null;return!o||!e.editable?!1:(t.preventDefault(),o(e.state,e.dispatch))}}}})}function Rr(n,e){return(t,r)=>{let o=Mt.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let i=jp(o,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}var Ri=Rr(!1,!0),Ii=Rr(!0,!0),Kw=Rr(!1,!1),_w=Rr(!0,!1);function Vr(n){let{state:e,transaction:t}=n,{selection:r}=t,{doc:o}=t,{storedMarks:i}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=t.selection,o=t.doc,i=t.storedMarks,t}}}var Qt=class Lc{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:r}=this,{view:o}=t,{tr:i}=r,s=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...d)=>{let u=a(...d)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l=[],a=!!e,c=e||i.tr,d=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),l.every(f=>f===!0)),u={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{let g=this.buildProps(c,t),y=h(...m)(g);return l.push(y),u}])),run:d};return u}static createFakeChain(){let e=new Proxy({},{get:(t,r)=>{if(r!=="then")return r==="run"?()=>!1:()=>e}});return e}createCan(e){let{rawCommands:t,state:r}=this,o=!1,i=e||r.tr,s=this.buildProps(i,o);return{...Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,o)}}static createFallbackCan(){let e=Lc.createFakeChain();return new Proxy({chain:()=>e},{get:(t,r)=>{if(r!=="then")return r==="chain"?t.chain:()=>!1}})}buildProps(e,t=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l={tr:e,editor:o,view:s,state:Vr({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...d)=>c(...d)(l)]))}};return l}},Kp=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{if(!n.isDestroyed){var t;e.dom.blur(),(t=window)===null||t===void 0||(t=t.getSelection())===null||t===void 0||t.removeAllRanges()}}),!0),_p=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),qp=()=>({state:n,tr:e,dispatch:t})=>{let{selection:r}=e,{ranges:o}=r;return t&&o.forEach(({$from:i,$to:s})=>{n.doc.nodesBetween(i.pos,s.pos,(l,a)=>{if(l.type.isText)return;let{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),f=c.resolve(d.map(a+l.nodeSize)),h=u.blockRange(f);if(!h)return;let p=Be(h);if(l.type.isTextblock){let{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},Jp=n=>e=>n(e),Up=()=>({state:n,dispatch:e})=>Ko(n,e),Gp=(n,e)=>({editor:t,tr:r})=>{let{state:o}=t,i=o.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);let s=r.mapping.map(e);return r.insert(s,i.content),r.setSelection(new C(r.doc.resolve(Math.max(s-1,0)))),!0},Xp=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;let o=n.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(e){let s=o.before(i),l=o.after(i);n.delete(s,l).scrollIntoView()}return!0}return!1};function X(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var Yp=n=>({tr:e,state:t,dispatch:r})=>{let o=X(n,t.schema),i=e.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){let l=i.before(s),a=i.after(s);e.delete(l,a).scrollIntoView()}return!0}return!1},Zp=n=>({tr:e,dispatch:t})=>{let{from:r,to:o}=n;return t&&e.delete(r,o),!0},Qp=n=>n.content?/^text(\*|\+)/.test(n.content):!1,mc=(n,e,t)=>{if(!n.parent.isInline||t==="left"&&n.pos>n.start()||t==="right"&&n.pos<n.end())return n.pos;let r=e.nodes[n.parent.type.name].spec;return Qp(r)?t==="left"?n.start()-1:n.end()+1:n.pos},em=(n,e,t)=>({from:mc(n,t,"left"),to:mc(e,t,"right")}),tm=()=>({state:n,dispatch:e})=>{if(n.selection.empty)return!1;if(e){let t=n.tr,{ranges:r}=n.selection,o=n.selection instanceof C?n.selection.$from.marksAcross(n.selection.$to):null,i=t.steps.length;r.forEach(s=>{let l=t.mapping.slice(i),a=t.doc.resolve(l.map(s.$from.pos)),c=t.doc.resolve(l.map(s.$to.pos)),{from:d,to:u}=em(a,c,n.schema);t.deleteRange(d,u)}),t.selection.empty||t.setSelection(C.near(t.doc.resolve(t.selection.from))),o&&t.ensureMarks(o),t.scrollIntoView(),e(t)}return!0},nm=()=>({commands:n})=>n.keyboardShortcut("Enter"),rm=()=>({state:n,dispatch:e})=>jo(n,e);function $i(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function Fr(n,e,t={strict:!0}){let r=Object.keys(e);return r.length?r.every(o=>t.strict?e[o]===n[o]:$i(e[o])?e[o].test(n[o]):e[o]===n[o]):!0}function Bc(n,e,t={}){return n.find(r=>r.type===e&&Fr(Object.fromEntries(Object.keys(t).map(o=>[o,r.attrs[o]])),t))}function gc(n,e,t={}){return!!Bc(n,e,t)}function Fi(n,e,t){if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if((!r.node||!r.node.marks.some(a=>a.type===e))&&(r=n.parent.childBefore(n.parentOffset)),!r.node||!r.node.marks.some(a=>a.type===e))return;if(!t){let a=r.node.marks.find(c=>c.type===e);a&&(t=a.attrs)}if(!Bc([...r.node.marks],e,t))return;let o=r.index,i=n.start()+r.offset,s=o+1,l=i+r.node.nodeSize;for(;o>0&&gc([...n.parent.child(o-1).marks],e,t);)o-=1,i-=n.parent.child(o).nodeSize;for(;s<n.parent.childCount&&gc([...n.parent.child(s).marks],e,t);)l+=n.parent.child(s).nodeSize,s+=1;return{from:i,to:l}}function je(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var om=(n,e)=>({tr:t,state:r,dispatch:o})=>{let i=je(n,r.schema),{doc:s,selection:l}=t,{$from:a,from:c,to:d}=l;if(o){let u=Fi(a,i,e);if(u&&u.from<=c&&u.to>=d){let f=C.create(s,u.from,u.to);t.setSelection(f)}}return!0},im=n=>e=>{let t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function zc(n){return n instanceof C}function Tt(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function Pi(n,e=null){if(!e)return null;let t=T.atStart(n),r=T.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;let o=t.from,i=r.to;return e==="all"?C.create(n,Tt(0,o,i),Tt(n.content.size,o,i)):C.create(n,Tt(e,o,i),Tt(e,o,i))}function yc(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function Hr(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function sm(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var lm=(n=null,e={})=>({editor:t,view:r,tr:o,dispatch:i})=>{e={scrollIntoView:!0,...e};let s=()=>{(Hr()||yc())&&r.dom.focus(),sm()&&!Hr()&&!yc()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};try{if(r.hasFocus()&&n===null||n===!1)return!0}catch{return!1}if(i&&n===null&&!zc(t.state.selection))return s(),!0;let l=Pi(o.doc,n)||t.state.selection,a=t.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},am=(n,e)=>t=>n.every((r,o)=>e(r,{...t,index:o})),cm=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),$c=n=>{let e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){let r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&$c(r)}return n};function Ir(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return $c(t)}function Fc(n){return typeof n?.nodesBetween=="function"}function en(n,e,t){if(Fc(n))return n;let r=typeof n=="object"&&n!==null;t={slice:!0,parseOptions:{},...t};let o=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return b.fromArray(n.map(s=>e.nodeFromJSON(s)));let i=e.nodeFromJSON(n);return t.errorOnInvalidContent&&i.check(),i}catch(i){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",i),en("",e,t)}if(o){if(t.errorOnInvalidContent){let s=!1,l="",a=new ft({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Ie.fromSchema(a).parseSlice(Ir(n),t.parseOptions):Ie.fromSchema(a).parse(Ir(n),t.parseOptions),t.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=Ie.fromSchema(e);return t.slice?i.parseSlice(Ir(n),t.parseOptions).content:i.parse(Ir(n),t.parseOptions)}return en("",e,t)}function Hc(n){return!("type"in n)}function Vc(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof ee||o instanceof U))return;let i=n.mapping.maps[r],s=0;i.forEach((l,a,c,d)=>{s===0&&(s=d)}),n.setSelection(T.near(n.doc.resolve(s),t))}var dm=(n,e,t)=>({tr:r,dispatch:o,editor:i})=>{if(o){t={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l,a=g=>{i.emit("contentError",{editor:i,error:g,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{en(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{var s;l=en(e,i.schema,{parseOptions:c,errorOnInvalidContent:(s=t.errorOnInvalidContent)!==null&&s!==void 0?s:i.options.enableContentCheck})}catch(g){return a(g),!1}let{from:d,to:u}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0,p=Hc(l)?l.content:[l];if(p.forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),d===u&&h){let{parent:g}=r.doc.resolve(d);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(d-=1,u+=1)}let m;if(f)Array.isArray(e)?m=e.map(g=>g.text||"").join(""):Fc(e)?m=p.map(g=>{var y;return(y=g.text)!==null&&y!==void 0?y:""}).join(""):typeof e=="object"&&e&&e.text?m=e.text:m=e,r.insertText(m,d,u);else{m=b.from(p);let g=r.doc.resolve(d),y=g.node(),k=g.parentOffset===0,S=y.isText||y.isTextblock,v=y.content.size>0;k&&S&&v&&h&&(d=Math.max(0,d-1)),r.replaceWith(d,u,p)}t.updateSelection&&Vc(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:m}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:m})}return!0};function Wc(n){for(let e=0;e<n.edgeCount;e+=1){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var um=(n={})=>({tr:e,dispatch:t,editor:r})=>{let{pos:o,attrs:i,content:s,updateSelection:l=!0}=n,a;typeof o=="number"?a=e.doc.resolve(o):o?a=o:a=e.selection.$from;let c=Wc(a.parent.contentMatchAt(a.index()));if(!c)return!1;let d=Object.keys(c.spec.attrs||{}),u=i?Object.fromEntries(Object.entries(i).filter(([h])=>d.includes(h))):{},f;if(s){let h=en(s,r.schema);f=c.createAndFill(u,h)}else f=c.createAndFill(u);return f?(t&&(e.insert(a.pos,f),l&&Vc(e,e.steps.length-1,-1)),!0):!1},fm=()=>({state:n,dispatch:e})=>jl(n,e),hm=()=>({state:n,dispatch:e})=>Kl(n,e),pm=()=>({state:n,dispatch:e})=>Lo(n,e),mm=()=>({state:n,dispatch:e})=>$o(n,e),jc=(n,e)=>{let t=n.resolve(e),r=t.nodeBefore,o=t.nodeAfter;return!r||!o?!1:!r.type.spec.isolating&&!o.type.spec.isolating},gm=()=>({state:n,dispatch:e,tr:t})=>{try{let r=Ht(n.doc,n.selection.$from.pos,-1);return r==null||!jc(n.doc,r)?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},ym=()=>({state:n,dispatch:e,tr:t})=>{try{let r=Ht(n.doc,n.selection.$from.pos,1);return r==null||!jc(n.doc,r)?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},bm=()=>({state:n,dispatch:e})=>hr(n,e),wm=()=>({state:n,dispatch:e})=>pr(n,e);function Kc(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function km(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t==="Space"&&(t=" ");let r,o,i,s;for(let l=0;l<e.length-1;l+=1){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Hr()||Kc()?s=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),o&&(t=`Ctrl-${t}`),s&&(t=`Meta-${t}`),i&&(t=`Shift-${t}`),t}var Sm=n=>({editor:e,view:t,tr:r,dispatch:o})=>{let i=km(n).split(/-(?!$)/),s=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{let d=c.map(r.mapping);d&&o&&r.maybeStep(d)}),!0};function Oe(n,e,t={}){let{from:r,to:o,empty:i}=n.selection,s=e?X(e,n.schema):null,l=[];n.doc.nodesBetween(r,o,(d,u)=>{if(d.isText)return;let f=Math.max(r,u),h=Math.min(o,u+d.nodeSize);l.push({node:d,from:f,to:h})});let a=o-r,c=l.filter(d=>s?s.name===d.node.type.name:!0).filter(d=>Fr(d.node.attrs,t,{strict:!1}));return i?!!c.length:c.reduce((d,u)=>d+u.to-u.from,0)>=a}var xm=(n,e={})=>({state:t,dispatch:r})=>Oe(t,X(n,t.schema),e)?_l(t,r):!1,Cm=()=>({state:n,dispatch:e})=>_o(n,e),vm=n=>({state:e,dispatch:t})=>{let r=X(n,e.schema);return Yl(r)(e,t)},Mm=()=>({state:n,dispatch:e})=>Vo(n,e);function Wr(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function bc(n,e){let t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,o)=>(t.includes(o)||(r[o]=n[o]),r),{})}var Em=(n,e)=>({tr:t,state:r,dispatch:o})=>{let i=null,s=null,l=Wr(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(i=X(n,r.schema)),l==="mark"&&(s=je(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,u)=>{i&&i===d.type&&(a=!0,o&&t.setNodeMarkup(u,void 0,bc(d.attrs,e))),s&&d.marks.length&&d.marks.forEach(f=>{s===f.type&&(a=!0,o&&t.addMark(u,u+d.nodeSize,s.create(bc(f.attrs,e))))})})}),a},Tm=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Am=()=>({tr:n,dispatch:e})=>{if(e){let t=new de(n.doc);n.setSelection(t)}return!0},Nm=()=>({state:n,dispatch:e})=>Bo(n,e),Om=()=>({state:n,dispatch:e})=>Fo(n,e),Dm=()=>({state:n,dispatch:e})=>ql(n,e),Rm=()=>({state:n,dispatch:e})=>Jo(n,e),Im=()=>({state:n,dispatch:e})=>qo(n,e);function Li(n,e,t={},r={}){return en(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var Pm=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{let{doc:a}=i;if(r.preserveWhitespace!=="full"){let c=Li(n,o.schema,r,{errorOnInvalidContent:e??o.options.enableContentCheck});if(s){let d=Hc(c)?c.content:[c];i.replaceWith(0,a.content.size,d).setMeta("preventUpdate",!t)}return!0}return s&&i.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},n,{parseOptions:r,errorOnInvalidContent:e??o.options.enableContentCheck})};function _c(n,e){let t=je(e,n.schema),{from:r,to:o,empty:i}=n.selection,s=[];i?(n.storedMarks&&s.push(...n.storedMarks),s.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});let l=s.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function Lm(n,e){let t=new Ge(n);return e.forEach(r=>{r.steps.forEach(o=>{t.step(o)})}),t}function rn(n,e){for(let t=n.depth;t>0;t-=1){let r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function jr(n){return e=>rn(e.$from,n)}function M(n,e,t){return n.config[e]===void 0&&n.parent?M(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?M(n.parent,e,t):null}):n.config[e]}function Hi(n){return n.map(e=>{let t=M(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e,...Hi(t())]:e}).flat(10)}function Vi(n,e){let t=Pe.fromSchema(e).serializeFragment(n),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(t),r.innerHTML}function qc(n,e){let t=new Map;for(let o of n){var r;let i=(r=t.get(o.type))!==null&&r!==void 0?r:new Map;i.set(o.name,o),t.set(o.type,i)}return[...Object.values(e.nodes),...Object.values(e.marks)].flatMap(o=>{var i;return Object.entries((i=o.spec.attrs)!==null&&i!==void 0?i:{}).map(([s,l])=>{var a;let c=(a=t.get(o.name))===null||a===void 0?void 0:a.get(s),d=Object.hasOwn(l,"default");return{type:o.name,name:s,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...c?.attribute,default:l.default,isRequired:!d,validate:l.validate}}})})}var Bm={content:"string",marks:"string",group:"string",inline:"boolean",atom:"boolean",selectable:"boolean",draggable:"boolean",code:"boolean",whitespace:["pre","normal"],definingAsContext:"boolean",definingForContent:"boolean",defining:"boolean",isolating:"boolean",linebreakReplacement:"boolean"},zm={inclusive:"boolean",excludes:"string",group:"string",spanning:"boolean",code:"boolean"};function $m(n,e,t){return Object.fromEntries(Object.entries(e).flatMap(([r,o])=>{let i=n[r];if(i===void 0)return[];if(!(typeof o=="string"?typeof i===o:typeof i=="string"&&o.includes(i)))throw new RangeError(`Invalid schemaSpec field '${t}.${r}'`);return[[r,i]]}))}function wc(n,e,t,r){return{...Object.fromEntries(Object.entries(e).filter(([o])=>o!=="attrs"&&!Object.hasOwn(r,o))),...$m(t,r,n),attrs:t.attrs}}function kc(n,e,t){for(let r of Object.keys(e))if(!Object.hasOwn(n,r))throw new RangeError(`schemaSpec requires a local ${t} extension named '${r}'`);for(let r of Object.keys(n))if(!Object.hasOwn(e,r))throw new RangeError(`Local ${t} extension '${r}' is not in schemaSpec`)}function Fm(n,e){kc(n.nodes,e.nodes,"node"),kc(n.marks,e.marks,"mark");let t=e.spec.nodes,r=e.spec.marks;return e.spec.nodes.forEach((o,i)=>{t=t.update(o,wc(o,n.nodes[o],i,Bm))}),e.spec.marks.forEach((o,i)=>{r=r.update(o,wc(o,n.marks[o],i,zm))}),{topNode:e.topNodeType.name,nodes:t,marks:r}}function Jc(n){let e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}function tn(n){return{baseExtensions:n.filter(e=>e.type==="extension"),nodeExtensions:n.filter(e=>e.type==="node"),markExtensions:n.filter(e=>e.type==="mark")}}function Wi(n){let e=[],{nodeExtensions:t,markExtensions:r}=tn(n),o=[...t,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},s=t.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...s,...l];return n.forEach(c=>{let d=M(c,"addGlobalAttributes",{name:c.name,options:c.options,storage:c.storage,extensions:o});d&&d().forEach(u=>{let f;Array.isArray(u.types)?f=u.types:u.types==="*"?f=a:u.types==="nodes"?f=s:u.types==="marks"?f=l:f=[],f.forEach(h=>{Object.entries(u.attributes).forEach(([p,m])=>{e.push({type:h,name:p,attribute:{...i,...m}})})})})}),o.forEach(c=>{let d=M(c,"addAttributes",{name:c.name,options:c.options,storage:c.storage});if(!d)return;let u=d();Object.entries(u).forEach(([f,h])=>{let p={...i,...h};typeof p?.default=="function"&&(p.default=p.default()),p?.isRequired&&p?.default===void 0&&delete p.default,e.push({type:c.name,name:f,attribute:p})})}),e}function Bi(n){return typeof n=="function"}function B(n,e=void 0,...t){return Bi(n)?e?n.bind(e)(...t):n(...t):n}function Hm(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Vm(n){let e=[],t="",r=!1,o=!1,i=0,s=n.length;for(let l=0;l<s;l+=1){let a=n[l];if(a==="'"&&!o){r=!r,t+=a;continue}if(a==='"'&&!r){o=!o,t+=a;continue}if(!r&&!o){if(a==="("){i+=1,t+=a;continue}if(a===")"&&i>0){i-=1,t+=a;continue}if(a===";"&&i===0){e.push(t),t="";continue}}t+=a}return t&&e.push(t),e}function Sc(n){let e=[],t=Vm(n||""),r=t.length;for(let o=0;o<r;o+=1){let i=t[o],s=i.indexOf(":");if(s===-1)continue;let l=i.slice(0,s).trim(),a=i.slice(s+1).trim();l&&a&&e.push([l,a])}return e}function j(...n){return n.filter(e=>!!e).reduce((e,t)=>{let r={...e};return Object.entries(t).forEach(([o,i])=>{if(o==="__proto__"){Object.defineProperty(r,o,{configurable:!0,enumerable:!0,value:i,writable:!0});return}if(!r[o]){r[o]=i;return}if(o==="class"){let s=i?String(i).split(" "):[],l=r[o]?r[o].split(" "):[],a=s.filter(c=>!l.includes(c));r[o]=[...l,...a].join(" ")}else if(o==="style"){let s=new Map([...Sc(r[o]),...Sc(i)]);r[o]=Array.from(s.entries()).map(([l,a])=>`${l}: ${a}`).join("; ")}else r[o]=i}),r},{})}function nn(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>j(t,r),{})}function Wm(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function xc(n,e){return"style"in n?n:{...n,getAttrs:t=>{let r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;let o=e.reduce((i,s)=>{let l=s.attribute.parseHTML?s.attribute.parseHTML(t):Wm(t.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function Cc(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Hm(t)?!1:t!=null))}function vc(n){var e,t;let r={};return!(!(n==null||(e=n.attribute)===null||e===void 0)&&e.isRequired)&&"default"in(n?.attribute||{})&&(r.default=n.attribute.default),(n==null||(t=n.attribute)===null||t===void 0?void 0:t.validate)!==void 0&&(r.validate=n.attribute.validate),[n.name,r]}function Mc(n,e,t=Wi(n)){var r;let{nodeExtensions:o,markExtensions:i}=tn(n);return{topNode:(r=o.find(s=>M(s,"topNode")))===null||r===void 0?void 0:r.name,nodes:Object.fromEntries(o.map(s=>{let l=t.filter(h=>h.type===s.name),a={name:s.name,options:s.options,storage:s.storage,editor:e},c=Cc({...n.reduce((h,p)=>{let m=M(p,"extendNodeSchema",a);return{...h,...m?m(s):{}}},{}),content:B(M(s,"content",a)),marks:B(M(s,"marks",a)),group:B(M(s,"group",a)),inline:B(M(s,"inline",a)),atom:B(M(s,"atom",a)),selectable:B(M(s,"selectable",a)),draggable:B(M(s,"draggable",a)),code:B(M(s,"code",a)),whitespace:B(M(s,"whitespace",a)),linebreakReplacement:B(M(s,"linebreakReplacement",a)),defining:B(M(s,"defining",a)),isolating:B(M(s,"isolating",a)),attrs:Object.fromEntries(l.map(vc))}),d=B(M(s,"parseHTML",a));d&&(c.parseDOM=d.map(h=>xc(h,l)));let u=M(s,"renderHTML",a);u&&(c.toDOM=h=>u({node:h,HTMLAttributes:nn(h,l)}));let f=M(s,"renderText",a);return f&&(c.toText=f),[s.name,c]})),marks:Object.fromEntries(i.map(s=>{let l=t.filter(f=>f.type===s.name),a={name:s.name,options:s.options,storage:s.storage,editor:e},c=Cc({...n.reduce((f,h)=>{let p=M(h,"extendMarkSchema",a);return{...f,...p?p(s):{}}},{}),inclusive:B(M(s,"inclusive",a)),excludes:B(M(s,"excludes",a)),group:B(M(s,"group",a)),spanning:B(M(s,"spanning",a)),code:B(M(s,"code",a)),attrs:Object.fromEntries(l.map(vc))}),d=B(M(s,"parseHTML",a));d&&(c.parseDOM=d.map(f=>xc(f,l)));let u=M(s,"renderHTML",a);return u&&(c.toDOM=f=>u({mark:f,HTMLAttributes:nn(f,l)})),[s.name,c]}))}}function Uc(n,e,t){if(t===void 0)return new ft(Mc(n,e));let r=Jc(n.filter(s=>s.type!=="extension").map(s=>s.name));if(r.length)throw new RangeError(`Duplicate local schema types: ${r.join(", ")}`);let o=new ft(t),i=Mc(n,e,qc(Wi(n),o));return new ft(Fm(i,o))}function jn(n){return n.sort((t,r)=>{let o=M(t,"priority")||100,i=M(r,"priority")||100;return o>i?-1:o<i?1:0})}function ji(n){let e=jn(Hi(n)),t=Jc(e.map(r=>r.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Gc(n,e){return Uc(ji(n),e)}function Xc(n,e,t){let{from:r,to:o}=e,{blockSeparator:i=`
11
+
12
+ `,textSerializers:s={}}=t||{},l="";return n.nodesBetween(r,o,(a,c,d,u)=>{a.isBlock&&c>r&&(l+=i);let f=s?.[a.type.name];if(f)return d&&(l+=f({node:a,pos:c,parent:d,index:u,range:e})),!1;if(a.isText){var h;l+=a==null||(h=a.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,o-c)}}),l}function jm(n,e){return Xc(n,{from:0,to:n.content.size},e)}function Yc(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Km(n,e){let t=X(e,n.schema),{from:r,to:o}=n.selection,i=[];n.doc.nodesBetween(r,o,l=>{i.push(l)});let s=i.reverse().find(l=>l.type.name===t.name);return s?{...s.attrs}:{}}function _m(n,e){let t=Wr(typeof e=="string"?e:e.name,n.schema);return t==="node"?Km(n,e):t==="mark"?_c(n,e):{}}function qm(n,e=JSON.stringify){let t={};return n.filter(r=>{let o=e(r);return Object.prototype.hasOwnProperty.call(t,o)?!1:t[o]=!0})}function Jm(n){let e=qm(n);return e.length===1?e:e.filter((t,r)=>!e.filter((o,i)=>i!==r).some(o=>t.oldRange.from>=o.oldRange.from&&t.oldRange.to<=o.oldRange.to&&t.newRange.from>=o.newRange.from&&t.newRange.to<=o.newRange.to))}function Kr(n){let{mapping:e,steps:t}=n,r=[],o=e.invert();return e.maps.forEach((i,s)=>{let l=[];if(i.ranges.length)i.forEach((c,d)=>{l.push({from:c,to:d})});else{let{from:c,to:d}=t[s];if(c===void 0||d===void 0)return;l.push({from:c,to:d})}let a=e.slice(s);l.forEach(({from:c,to:d})=>{let u=a.map(c,-1),f=a.map(d),h=o.map(u,-1),p=o.map(f);r.push({oldRange:{from:h,to:p},newRange:{from:u,to:f}})})}),Jm(r)}function Zc(n,e,t){let r=[];return n===e?t.resolve(n).marks().forEach(o=>{let i=Fi(t.resolve(n),o.type);i&&r.push({mark:o,...i})}):t.nodesBetween(n,e,(o,i)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}var Qc=(n,e,t,r=20)=>{let o=n.doc.resolve(t),i=r,s=null;for(;i>0&&s===null;){let l=o.node(i);l?.type.name===e?s=l:i-=1}return[s,i]},ed=n=>{let e=n.depth-1;if(e<0)return null;let t=n.index(e);return t===0?null:n.node(e).child(t-1)};function Gt(n,e){return e.nodes[n]||e.marks[n]||null}function $r(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{let o=n.find(i=>i.type===e&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}var Um=(n,e=500)=>{let t="",r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(o,i,s,l)=>{var a,c;let d=((a=(c=o.type.spec).toText)===null||a===void 0?void 0:a.call(c,{node:o,pos:i,parent:s,index:l}))||o.textContent||"%leaf%";t+=o.isAtom&&!o.isText?d:d.slice(0,Math.max(0,r-i))}),t};function zi(n,e,t={}){let{empty:r,ranges:o}=n.selection,i=e?je(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(d=>i?i.name===d.type.name:!0).find(d=>Fr(d.attrs,t,{strict:!1}));let s=0,l=[];if(o.forEach(({$from:d,$to:u})=>{let f=d.pos,h=u.pos;n.doc.nodesBetween(f,h,(p,m)=>{if(i&&p.inlineContent&&!p.type.allowsMarkType(i))return!1;if(!p.isText&&!p.marks.length)return;let g=Math.max(f,m),y=Math.min(h,m+p.nodeSize),k=y-g;s+=k,l.push(...p.marks.map(S=>({mark:S,from:g,to:y})))})}),s===0)return!1;let a=l.filter(d=>i?i.name===d.mark.type.name:!0).filter(d=>Fr(d.mark.attrs,t,{strict:!1})).reduce((d,u)=>d+u.to-u.from,0),c=l.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):!0).reduce((d,u)=>d+u.to-u.from,0);return(a>0?a+c:a)>=s}function Gm(n,e,t={}){if(!e)return Oe(n,null,t)||zi(n,null,t);let r=Wr(e,n.schema);return r==="node"?Oe(n,e,t):r==="mark"?zi(n,e,t):!1}var td=(n,e)=>{let{$from:t,$to:r,$anchor:o}=n.selection;if(e){let i=jr(l=>l.type.name===e)(n.selection);if(!i)return!1;let s=n.doc.resolve(i.pos+1);return o.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},nd=n=>{let{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Ec(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Vn(n,e){let{nodeExtensions:t}=tn(e),r=t.find(i=>i.name===n);if(!r)return!1;let o=B(M(r,"group",{name:r.name,options:r.options,storage:r.storage}));return typeof o!="string"?!1:o.split(" ").includes("list")}function on(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){if(t){if(n.type.name==="hardBreak")return!0;if(n.isText){var r;return!/\S/.test((r=n.text)!==null&&r!==void 0?r:"")}}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let o=!0;return n.content.forEach(i=>{o!==!1&&(on(i,{ignoreWhitespace:t,checkChildren:e})||(o=!1))}),o}return!1}function rd(n){return n instanceof A}function Xm(n){if(n===null||typeof n!="object")return!1;let e=n;return!(typeof e.apply!="function"||typeof e.getMap!="function"||typeof e.invert!="function"||typeof e.map!="function"||typeof e.merge!="function"||typeof e.toJSON!="function")}function Ym(n){if(n===null||typeof n!="object")return!1;let e=n;if(!Xm(e))return!1;let t=e.toJSON();return!(t===null||typeof t!="object"||t.stepType!=="replace")}var od=class id{constructor(e){this.position=e}static fromJSON(e){return new id(e.position)}toJSON(){return{position:this.position}}};function Zm(n,e){let t=e.mapping.mapResult(n.position);return{position:new od(t.pos),mapResult:t}}function Qm(n){return new od(n)}function eg(n,e,t){let{selection:r}=e,o=null;if(zc(r)&&(o=r.$cursor),o){var i;let l=(i=n.storedMarks)!==null&&i!==void 0?i:o.marks();return o.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(a=>a.type.excludes(t)))}let{ranges:s}=r;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){let h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(d.marks)||!d.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}var tg=(n,e={})=>({tr:t,state:r,dispatch:o})=>{let{selection:i}=t,{empty:s,ranges:l}=i,a=je(n,r.schema);if(o)if(s){let c=_c(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{let d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{let p=Math.max(h,d),m=Math.min(h+f.nodeSize,u);f.marks.find(g=>g.type===a)?f.marks.forEach(g=>{a===g.type&&t.addMark(p,m,a.create({...g.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return eg(r,t,a)},ng=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),rg=(n,e={})=>({state:t,dispatch:r,chain:o})=>{let i=X(n,t.schema),s;return t.selection.$anchor.sameParent(t.selection.$head)&&(s=t.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>Uo(i,{...s,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Uo(i,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},og=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,o=Tt(n,0,r.content.size),i=A.create(r,o);e.setSelection(i)}return!0},ig=(n,e)=>({tr:t,state:r,dispatch:o})=>{let{selection:i}=r,s,l;return typeof e=="number"?(s=e,l=e):e&&"from"in e&&"to"in e?(s=e.from,l=e.to):(s=i.from,l=i.to),o&&t.doc.nodesBetween(s,l,(a,c)=>{a.isText||t.setNodeMarkup(c,void 0,{...a.attrs,dir:n})}),!0},sg=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,{from:o,to:i}=typeof n=="number"?{from:n,to:n}:n,s=C.atStart(r).from,l=C.atEnd(r).to,a=Tt(o,s,l),c=Tt(i,s,l),d=C.create(r,a,c);e.setSelection(d)}return!0},lg=n=>({state:e,dispatch:t})=>{let r=X(n,e.schema);return Zl(r)(e,t)};function Tc(n,e){let t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){let r=t.filter(o=>e?.includes(o.type.name));n.tr.ensureMarks(r)}}var ag=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:o})=>{let{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=o.extensionManager.attributes,d=$r(c,l.node().type.name,l.node().attrs);if(i instanceof A&&i.node.isBlock)return!l.parentOffset||!we(s,l.pos)?!1:(r&&(n&&Tc(t,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let u=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:Wc(l.node(-1).contentMatchAt(l.indexAfter(-1))),h=u&&f?[{type:f,attrs:d}]:void 0,p=i instanceof C&&!i.empty?pt.create({doc:e.doc,selection:i}).tr.deleteSelection():null,m=p?p.doc:e.doc,g=p?p.mapping.map(l.pos):l.pos,y=we(m,g,1,h);if(!h&&!y&&we(m,g,1,f?[{type:f}]:void 0)&&(y=!0,h=f?[{type:f,attrs:d}]:void 0),r){if(y){let k=e.steps.length;if(i instanceof C&&e.deleteSelection(),e.split(e.mapping.slice(k).map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f){let S=e.mapping.slice(k).map(l.before()),v=e.doc.resolve(S);l.node(-1).canReplaceWith(v.index(),v.index()+1,f)&&e.setNodeMarkup(e.mapping.slice(k).map(l.before()),f)}}n&&Tc(t,o.extensionManager.splittableMarks),e.scrollIntoView()}return y},cg=(n,e={})=>({tr:t,state:r,dispatch:o,editor:i})=>{let s=X(n,r.schema),{$from:l,$to:a}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;let d=l.node(-1);if(d.type!==s)return!1;let u=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==s||l.index(-2)!==l.node(-2).childCount-1)return!1;if(o){var f;let v=b.empty,D=l.index(-1)?1:l.index(-2)?2:3;for(let Ee=l.depth-D;Ee>=l.depth-3;Ee-=1)v=b.from(l.node(Ee).copy(v));let $=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,E={...$r(u,l.node().type.name,l.node().attrs),...e},R=((f=s.contentMatch.defaultType)===null||f===void 0?void 0:f.createAndFill(E))||void 0;v=v.append(b.from(s.createAndFill(null,R)||void 0));let V=l.before(l.depth-(D-1));t.replace(V,l.after(-$),new w(v,4-D,0));let W=-1;t.doc.nodesBetween(V,t.doc.content.size,(Ee,ot)=>{if(W>-1)return!1;Ee.isTextblock&&Ee.content.size===0&&(W=ot+1)}),W>-1&&t.setSelection(C.near(t.doc.resolve(W))),t.scrollIntoView()}return!0}let h=a.pos===l.end()?d.contentMatchAt(0).defaultType:null,p={...$r(u,d.type.name,d.attrs),...e},m={...$r(u,l.node().type.name,l.node().attrs),...e},g=l.parentOffset===0&&l.index(-1)===0,y=l.before(-1);t.delete(l.pos,a.pos);let k=g?d.attrs:p,S=h?[{type:s,attrs:k},{type:h,attrs:m}]:[{type:s,attrs:k}];if(!we(t.doc,l.pos,2))return!1;if(o){let{selection:v,storedMarks:D}=r,{splittableMarks:$}=i.extensionManager,E=D||v.$to.parentOffset&&v.$from.marks();if(t.split(l.pos,2,S).scrollIntoView(),g&&t.setNodeMarkup(y,void 0,p),!E||!o)return!0;let R=E.filter(V=>$.includes(V.type.name));t.ensureMarks(R)}return!0};function sd(n,e,t){if(!n.validContent(e))return null;try{return n.create(t,e)}catch{return null}}function Ki(n,e){if(n.pendingContent.length===0)return!0;let t=sd(e,b.from(n.pendingContent));return t?(n.items.push(t),n.pendingContent=[],!0):!1}function dg(n,e,t){return t.validContent(b.from([...e.pendingContent,n]))?(e.pendingContent.push(n),!0):!Ki(e,t)||!t.validContent(b.from(n))?!1:(e.pendingContent.push(n),!0)}function ug(n,e,t,r){let o=r(n,t);if(!o)return!1;let i=sd(t.listType,b.from(o),n.attrs);return i?t.itemType.validContent(b.from([...e.pendingContent,i]))?(e.pendingContent.push(i),!0):Ki(e,t.itemType)?(e.items.push(...o),!0):!1:!1}function fg(n,e,t){let r={items:[],pendingContent:[]};for(let o=0;o<n.childCount;o+=1){let i=n.child(o);if(!(e.isListNode(i)?ug(i,r,e,t):dg(i,r,e.itemType)))return null}return Ki(r,e.itemType)?r.items:null}function ld(n,e){let t=[];for(let r=0;r<n.childCount;r+=1){let o=fg(n.child(r),e,ld);if(!o)return null;t.push(...o)}return t}function Ac(n,e){let t=null;return n.descendants((r,o)=>r!==e?!0:(t=o,!1)),t}function Nc(n){return!n||n==="1"?null:n}function ad(n,e){return Nc(n)===Nc(e)}var Pr=(n,e)=>{let t=jr(i=>i.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;let o=n.doc.nodeAt(r);return!(t.node.type===o?.type&&Ce(n.doc,t.pos))||!ad(t.node.attrs.type,o?.attrs.type)||n.join(t.pos),!0},Lr=(n,e)=>{let t=jr(i=>i.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;let o=n.doc.nodeAt(r);return!(t.node.type===o?.type&&Ce(n.doc,r))||!ad(t.node.attrs.type,o?.attrs.type)||n.join(r),!0};function hg(n){let e=n.doc,t=e.firstChild;if(!t)return null;let r=e.resolve(1),o=e.resolve(t.nodeSize-1);return C.between(r,o)}var pg=(n,e,t,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:c,can:d})=>{let{extensions:u,splittableMarks:f}=o.extensionManager,h=X(n,s.schema),p=X(e,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:k}=m,S=y.blockRange(k),v=g||m.$to.parentOffset&&m.$from.marks();if(!S)return!1;let D=jr(ge=>Vn(ge.type.name,u))(m),$=m.from===0&&m.to===s.doc.content.size,E=s.doc.content.content,R=E.length===1?E[0]:null,V=$&&R&&Vn(R.type.name,u)?{node:R,pos:0,depth:0}:null,W=D??V,Ee=!!D&&S.depth>=1&&S.depth-D.depth<=1,ot=!!V;if((Ee||ot)&&W){if(W.node.type===h)return $&&ot?a().command(({tr:ge,dispatch:Re})=>{let ye=hg(ge);return ye?(ge.setSelection(ye),Re&&Re(ge),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(Vn(W.node.type.name,u)&&h.validContent(W.node.content))return a().command(()=>(i.setNodeMarkup(W.pos,h),!0)).command(()=>Pr(i,h)).command(()=>Lr(i,h)).run();if(Vn(W.node.type.name,u)){var it;let ge=(it=W.node.firstChild)===null||it===void 0?void 0:it.type;if(ge&&ge!==p){let Re=ld(W.node,{listType:h,itemType:p,isListNode:st=>Vn(st.type.name,u)}),ye=Re?b.from(Re):null;return!ye||!h.validContent(ye)?!1:a().command(()=>{let{$anchor:st,$head:un}=i.selection,Jn=st.parent,fn=un.parent,Rt=st.parentOffset,Un=un.parentOffset,lt;try{lt=h.create(r,ye)}catch{return!1}if(i.replaceWith(W.pos,W.pos+W.node.nodeSize,lt),Jn.inlineContent&&fn.inlineContent){let It=Ac(lt,Jn),hn=Ac(lt,fn);if(It!==null&&hn!==null){let pn=W.pos+It+2+Rt,x=W.pos+hn+2+Un;i.setSelection(C.create(i.doc,pn,x))}}return!0}).command(()=>Pr(i,h)).command(()=>Lr(i,h)).run()}}}return!t||!v||!l?a().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Pr(i,h)).command(()=>Lr(i,h)).run():a().command(()=>{let ge=d().wrapInList(h,r),Re=v.filter(ye=>f.includes(ye.type.name));return i.ensureMarks(Re),ge?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Pr(i,h)).command(()=>Lr(i,h)).run()},mg=(n,e={},t={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:i=!1}=t,s=je(n,r.schema);return zi(r,s,e)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,e)},gg=(n,e,t={})=>({state:r,commands:o})=>{let i=X(n,r.schema),s=X(e,r.schema),l=Oe(r,i,t),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,{...a,...t})},yg=(n,e={})=>({state:t,commands:r})=>{let o=X(n,t.schema);return Oe(t,o,e)?r.lift(o):r.wrapIn(o,e)},bg=()=>({state:n,dispatch:e})=>{let t=n.plugins;for(let r=0;r<t.length;r+=1){let o=t[r],i;if(o.spec.isInputRules&&(i=o.getState(n))){if(e){let s=n.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,n.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},wg=(n={})=>({tr:e,dispatch:t,editor:r})=>{let{ignoreClearable:o=!1}=n,{selection:i}=e,{empty:s,ranges:l}=i;if(s)return!0;let{nonClearableMarks:a}=r.extensionManager;if(t){let c=Object.values(r.schema.marks).filter(d=>o||!a.includes(d.name));l.forEach(d=>{for(let u of c)e.removeMark(d.$from.pos,d.$to.pos,u)})}return!0},kg=(n,e={})=>({tr:t,state:r,dispatch:o})=>{let{extendEmptyMarkRange:i=!1}=e,{selection:s}=t,l=je(n,r.schema),{$from:a,empty:c,ranges:d}=s;if(!o)return!0;if(c&&i){var u;let{from:f,to:h}=s,p=Fi(a,l,(u=a.marks().find(m=>m.type===l))===null||u===void 0?void 0:u.attrs);p&&(f=p.from,h=p.to),t.removeMark(f,h,l)}else d.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,l)});return t.removeStoredMark(l),!0},Sg=n=>({tr:e,state:t,dispatch:r})=>{let{selection:o}=t,i,s;return typeof n=="number"?(i=n,s=n):n&&"from"in n&&"to"in n?(i=n.from,s=n.to):(i=o.from,s=o.to),r&&e.doc.nodesBetween(i,s,(l,a)=>{if(l.isText)return;let c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},xg=(n,e={})=>({tr:t,state:r,dispatch:o})=>{let i=null,s=null,l=Wr(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(i=X(n,r.schema)),l==="mark"&&(s=je(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{let d=c.$from.pos,u=c.$to.pos,f,h,p,m;t.selection.empty?r.doc.nodesBetween(d,u,(g,y)=>{i&&i===g.type&&(a=!0,p=Math.max(y,d),m=Math.min(y+g.nodeSize,u),f=y,h=g)}):r.doc.nodesBetween(d,u,(g,y)=>{y<d&&i&&i===g.type&&(a=!0,p=Math.max(y,d),m=Math.min(y+g.nodeSize,u),f=y,h=g),y>=d&&y<=u&&(i&&i===g.type&&(a=!0,o&&t.setNodeMarkup(y,void 0,{...g.attrs,...e})),s&&g.marks.length&&g.marks.forEach(k=>{if(s===k.type&&(a=!0,o)){let S=Math.max(y,d),v=Math.min(y+g.nodeSize,u);t.addMark(S,v,s.create({...k.attrs,...e}))}}))}),h&&(f!==void 0&&o&&t.setNodeMarkup(f,void 0,{...h.attrs,...e}),s&&h.marks.length&&h.marks.forEach(g=>{s===g.type&&o&&t.addMark(p,m,s.create({...g.attrs,...e}))}))}),a},Yt=new F("__tiptap_decorations__"),Cg=n=>({tr:e,dispatch:t})=>(t&&e.setMeta(Yt,{type:"force",name:n}),!0),vg=(n,e={})=>({state:t,dispatch:r})=>{let o=X(n,t.schema);return Gl(o,e)(t,r)},Mg=(n,e={})=>({state:t,dispatch:r})=>{let o=X(n,t.schema);return Xl(o,e)(t,r)},Eg=Hs({blur:()=>Kp,clearContent:()=>_p,clearNodes:()=>qp,command:()=>Jp,createParagraphNear:()=>Up,cut:()=>Gp,deleteCurrentNode:()=>Xp,deleteNode:()=>Yp,deleteRange:()=>Zp,deleteSelection:()=>tm,enter:()=>nm,exitCode:()=>rm,extendMarkRange:()=>om,first:()=>im,focus:()=>lm,forEach:()=>am,insertContent:()=>cm,insertContentAt:()=>dm,insertDefaultBlock:()=>um,joinBackward:()=>pm,joinDown:()=>hm,joinForward:()=>mm,joinItemBackward:()=>gm,joinItemForward:()=>ym,joinTextblockBackward:()=>bm,joinTextblockForward:()=>wm,joinUp:()=>fm,keyboardShortcut:()=>Sm,lift:()=>xm,liftEmptyBlock:()=>Cm,liftListItem:()=>vm,newlineInCode:()=>Mm,resetAttributes:()=>Em,scrollIntoView:()=>Tm,selectAll:()=>Am,selectNodeBackward:()=>Nm,selectNodeForward:()=>Om,selectParentNode:()=>Dm,selectTextblockEnd:()=>Rm,selectTextblockStart:()=>Im,setContent:()=>Pm,setMark:()=>tg,setMeta:()=>ng,setNode:()=>rg,setNodeSelection:()=>og,setTextDirection:()=>ig,setTextSelection:()=>sg,sinkListItem:()=>lg,splitBlock:()=>ag,splitListItem:()=>cg,toggleList:()=>pg,toggleMark:()=>mg,toggleNode:()=>gg,toggleWrap:()=>yg,undoInputRule:()=>bg,unsetAllMarks:()=>wg,unsetMark:()=>kg,unsetTextDirection:()=>Sg,updateAttributes:()=>xg,updateDecorations:()=>Cg,wrapIn:()=>vg,wrapInList:()=>Mg}),Zt=new WeakMap;function Tg(n,e){var t;Zt.set(n,((t=Zt.get(n))!==null&&t!==void 0?t:0)+1);try{return e()}finally{var r;let o=((r=Zt.get(n))!==null&&r!==void 0?r:1)-1;o>0?Zt.set(n,o):Zt.delete(n)}}function Ag(n){return Zt.has(n)}var Ng=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){let t=this.callbacks[n];return t&&t.forEach(r=>r.apply(this,e)),this}off(n,e){let t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(r=>r!==e):delete this.callbacks[n]),this}once(n,e){let t=(...r)=>{this.off(n,t),e.apply(this,r)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},cd=typeof process<"u"&&!1;function Og(n){return n.kind==="widget"}function dd(n,e){let t=[],r=new Set;for(let o of n)o.kind==="widget"&&Og(o)&&r.add(o.key),t.push(o.toPMDecoration(e));return{decorations:t,widgetKeys:r}}function Dg(n,e,t){let{decorations:r,widgetKeys:o}=dd(e,t);return{set:L.create(n,r),widgetKeys:o}}function ud({position:n,from:e,to:t,docSize:r}){return n<e?!1:n<t?!0:n===t&&t===r}function Rg({decorations:n,from:e,to:t,docSize:r,extensionName:o,warnedExtensions:i}){return n.filter(s=>ud({position:s.anchor,from:e,to:t,docSize:r})?!0:(s.anchor===t||i.has(o)||(i.add(o),console.warn(`[tiptap warn]: Extension "${o}" returned a decoration outside the requested range [${e}, ${t}). It was ignored.`)),!1))}function fd(n){var e;let t=(e=n.spec)===null||e===void 0?void 0:e.key;return typeof t=="string"?t:void 0}function Ig(n){let e=new Map,t=new Map;for(let s of n.find()){var r,o,i;let l=fd(s);if(!l)continue;let a=(r=s.spec.extensionName)!==null&&r!==void 0?r:"unknown",c=(o=e.get(l))!==null&&o!==void 0?o:new Set;c.add(a),e.set(l,c),t.set(l,((i=t.get(l))!==null&&i!==void 0?i:0)+1)}return Array.from(e,([s,l])=>({key:s,extensions:l})).filter(({key:s})=>{var l;return((l=t.get(s))!==null&&l!==void 0?l:0)>1})}function hd(n){return n.jsonID==="attr"}function Pg(n){let e=!1;if(n.getMap().forEach(()=>{e=!0}),e||hd(n))return!0;let t=n;return typeof t.from=="number"&&typeof t.to=="number"}function Lg(n,e){let t=null,r=0,o=0;for(let i=0;i<n.childCount&&!(o>e.to);i+=1){let s=o+n.child(i).nodeSize;s>=e.from&&(t===null&&(t=o),r=s),o=s}return t===null?null:{from:t,to:r}}function Bg(n,e){if(n.steps.some(i=>!Pg(i)))return{type:"full"};let t=Kr(n).map(({newRange:i})=>i);n.steps.forEach((i,s)=>{if(!hd(i))return;let l=n.mapping.slice(s);t.push({from:l.map(i.pos,-1),to:l.map(i.pos+1)})});let r=[];for(let i of t){let s=Lg(e,i);s&&r.push(s)}r.sort((i,s)=>i.from-s.from);let o=[];for(let i of r){let s=o[o.length-1];s&&i.from<=s.to?s.to=Math.max(s.to,i.to):o.push({...i})}return{type:"ranges",ranges:o}}function pd(n,e,t,r){return n.map(e,t,{onRemove:o=>{let i=o?.key;typeof i=="string"&&r.delete(i)}})}function zg(n,e,t){var r,o;let i=(r=e.decorationSetsByExtension[n])!==null&&r!==void 0?r:L.empty,s=new Set((o=e.widgetKeysByExtension[n])!==null&&o!==void 0?o:[]);return{set:pd(i,t.mapping,t.doc,s),widgetKeys:s}}function Oc(n,e){let t=Object.values(e).flatMap(r=>r.find());return L.create(n,t)}function Dc(n){let e=new Set;for(let t of Object.values(n))for(let r of t)e.add(r);return e}function $g(n,e){var t;switch((t=e.update)!==null&&t!==void 0?t:"document"){case"document":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${n}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!e.createInRange)throw new Error(`[tiptap error]: Extension "${n}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${n}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(e.shouldUpdate)throw new Error(`[tiptap error]: Extension "${n}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension "${n}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function Fg(n,e,t){return t?!0:n.update==="manual"?!1:n.shouldUpdate?n.shouldUpdate(e):e.tr.docChanged}var Hg=new Set;var Vg=class{constructor(n){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let t=Yt.getState(e);t&&this.warnDuplicateWidgetKeys(t)},this.editor=n.editor,this.entries=this.resolveEntries(n.entries),this.entries.forEach(({name:e,spec:t})=>$g(e,t)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on("beforeTransaction",this.handleBeforeTransaction)}destroy(){this.editor.off("beforeTransaction",this.handleBeforeTransaction)}liveWidgetKeys(){var n,e;return(n=(e=Yt.getState(this.editor.state))===null||e===void 0?void 0:e.widgetKeys)!==null&&n!==void 0?n:Hg}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(n){let e=[];for(let{name:t,addDecorations:r}of n){let o=r();o&&e.push({name:t,spec:o})}return e}createPlugin(){let{editor:n,entries:e}=this;return new I({key:Yt,state:{init:(t,r)=>{let o={},i={};for(let{name:l,spec:a}of e){let{set:c,widgetKeys:d}=this.buildFullSet(l,a,r);o[l]=c,i[l]=d}let s={decorationSetsByExtension:o,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(r.doc,o),widgetKeys:Dc(i)};return this.warnDuplicateWidgetKeys(s),s},apply:(t,r,o,i)=>{let s=t.getMeta(Yt),l=s?.type==="force"&&!s.name,a=s?.type==="force"?s.name:void 0,c={},d={},u=new Set;return Tg(n,()=>{for(let{name:f,spec:h}of e){let p=l||a===f;if(Fg(h,{editor:n,tr:t,oldState:o,newState:i},p))if(h.update==="changedRanges"&&t.docChanged&&!p){let m=this.applyChangedRangesRecompute(f,h,r,t,i);c[f]=m.set,d[f]=m.widgetKeys,u.add(f)}else{let{set:m,widgetKeys:g}=this.buildFullSet(f,h,i);c[f]=m,d[f]=g,u.add(f)}else{let m=zg(f,r,t);c[f]=m.set,d[f]=m.widgetKeys}}}),u.size===0&&!t.docChanged?r:{decorationSetsByExtension:c,widgetKeysByExtension:d,mergedDecorationSet:this.mergeAfterApply({entries:e,previous:r,tr:t,decorationSetsByExtension:c,recomputedNames:u}),widgetKeys:Dc(d)}}},props:{decorations(t){var r,o;return(r=(o=Yt.getState(t))===null||o===void 0?void 0:o.mergedDecorationSet)!==null&&r!==void 0?r:L.empty}}})}applyChangedRangesRecompute(n,e,t,r,o){let i=Bg(r,o.doc);return i.type==="full"?this.buildFullSet(n,e,o):this.rebuildRanges(n,e,t,r,o,i.ranges)}rebuildRanges(n,e,t,r,o,i){var s,l;let a=(s=t.decorationSetsByExtension[n])!==null&&s!==void 0?s:L.empty,c=new Set((l=t.widgetKeysByExtension[n])!==null&&l!==void 0?l:[]),d=pd(a,r.mapping,r.doc,c),u=o.doc.content.size;for(let{from:f,to:h}of i){let p=d.find(f,h).filter(y=>ud({position:y.from,from:f,to:h,docSize:u}));for(let y of p){let k=fd(y);k&&c.delete(k)}d=d.remove(p);let{decorations:m,widgetKeys:g}=dd(Rg({decorations:this.runCreate(n,"createInRange",()=>e.createInRange({editor:this.editor,state:o,view:this.mountedView,from:f,to:h})),from:f,to:h,docSize:u,extensionName:n,warnedExtensions:this.warnedOutOfRangeExtensions}),n);d=d.add(o.doc,m);for(let y of g)c.add(y)}return{set:d,widgetKeys:c}}buildFullSet(n,e,t){let r=this.runCreate(n,"create",()=>e.create({editor:this.editor,state:t,view:this.mountedView}));return Dg(t.doc,r,n)}runCreate(n,e,t){try{return t()}catch(r){return console.error(`[tiptap error]: Extension "${n}" threw in \`addDecorations().${e}()\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(n){if(!cd)return;if(n.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let e=Ig(n.mergedDecorationSet),t=new Set(e.map(({key:r})=>r));for(let{key:r,extensions:o}of e){if(this.warnedWidgetKeys.has(r))continue;let i=Array.from(o).map(s=>`"${s}"`).join(", ");console.warn(`[tiptap warn]: Duplicate widget decoration key "${r}" in extension${o.size===1?"":"s"} ${i}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=t}buildMergedSet(n,e){let t=Object.keys(e);return t.length===1?e[t[0]]:Oc(n,e)}mergeAfterApply({entries:n,previous:e,tr:t,decorationSetsByExtension:r,recomputedNames:o}){return n.length===1?r[n[0].name]:o.size===0?e.mergedDecorationSet.map(t.mapping,t.doc):Oc(t.doc,r)}};function Wg(n,e,t){let r=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(r!==null)return r;let o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),o.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(o),o}function jg(n){return typeof n=="number"}function Kg(n){return Object.prototype.toString.call(n).slice(8,-1)}function Br(n){return Kg(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function md(n){return typeof n=="string"&&n.trim().length>0&&!/[;{}]/.test(n)}function _g(n,e){return n.replace(/^[ \t]*/,t=>{let o=0;for(let i of t)o+=i===" "?4-o%4:1;return" ".repeat(Math.max(0,o-e))})}function qg(n,e){let t=`text
13
13
  ${n}
14
- `,r=e(t)[0];return(r?.type==="paragraph"||r?.type==="text")&&r.raw===t}function Tm(n,e,t){var r;let i=e.split(`
15
- `),s=(r=t.isParagraphContinuation)!==null&&r!==void 0?r:(l=>Em(l,t.blockTokens)),o=0;for(let l of i){if(!l.trim()||!s(l))break;o+=1}return{mainContent:[n,...i.slice(0,o).map(l=>l.trimStart())].join(`
16
- `),nestedContent:i.slice(o).join(`
17
- `)}}function vs(n,e,t){let r=n.split(`
18
- `),i=[],s="",o=0,l=e.baseIndentSize||2;for(;o<r.length;){let u=r[o],d=u.match(e.itemPattern);if(!d){if(i.length>0)break;if(u.trim()===""){o+=1,s=`${s}${u}
19
- `;continue}else return}let f=e.extractItemData(d),{indentLevel:h,mainContent:p}=f;s=`${s}${u}
20
- `;let m=[p];for(o+=1;o<r.length;){var a;let w=r[o];if(w.trim()===""){var c;let v=r.slice(o+1).findIndex(I=>I.trim()!=="");if(v===-1)break;if((((c=r[o+1+v].match(/^(\s*)/))===null||c===void 0||(c=c[1])===null||c===void 0?void 0:c.length)||0)>h){m.push(w),s=`${s}${w}
21
- `,o+=1;continue}else break}if((((a=w.match(/^(\s*)/))===null||a===void 0||(a=a[1])===null||a===void 0?void 0:a.length)||0)>h)m.push(w),s=`${s}${w}
22
- `,o+=1;else break}let g,y=m.slice(1);if(y.length>0){let w=Tm(p,y.map(I=>Cm(I,h+l)).join(`
23
- `),t);f.mainContent=w.mainContent;let v=w.nestedContent;v.trim()&&(e.customNestedParser?g=e.customNestedParser(v):g=t.blockTokens(v))}let x=e.createToken(f,g);i.push(x)}if(i.length!==0)return{items:i,raw:s.slice(0,n.length)}}var qa=4;function Ja(n){let e=0;for(let t of n)e=t===" "?e+qa-e%qa:e+1;return e}function Cs(n,e,t,r,i){if(!n||!Array.isArray(n.content))return"";let s=typeof t=="function"?t(r):t,[o,...l]=n.content,a=e.renderChildren([o]),c=`${s}${i?.indentMainContent?a.split(`
24
- `).map((u,d)=>d===0?u:e.indent(u)).join(`
25
- `):a}`;return l&&l.length>0&&l.forEach((u,d)=>{var f,h;let p=(f=(h=e.renderChild)===null||h===void 0?void 0:h.call(e,u,d+1))!==null&&f!==void 0?f:e.renderChildren([u]);if(p!=null){let m=y=>{if(!i?.alignNestedToPrefix)return e.indent(y);let x=e.indent(""),w=Ja(s);return(Ja(x)>=w?x:" ".repeat(w))+y},g=p.split(`
14
+ `,r=e(t)[0];return(r?.type==="paragraph"||r?.type==="text")&&r.raw===t}function Jg(n,e,t){var r;let o=e.split(`
15
+ `),i=(r=t.isParagraphContinuation)!==null&&r!==void 0?r:(l=>qg(l,t.blockTokens)),s=0;for(let l of o){if(!l.trim()||!i(l))break;s+=1}return{mainContent:[n,...o.slice(0,s).map(l=>l.trimStart())].join(`
16
+ `),nestedContent:o.slice(s).join(`
17
+ `)}}function _i(n,e,t){let r=n.split(`
18
+ `),o=[],i="",s=0,l=e.baseIndentSize||2;for(;s<r.length;){let d=r[s],u=d.match(e.itemPattern);if(!u){if(o.length>0)break;if(d.trim()===""){s+=1,i=`${i}${d}
19
+ `;continue}else return}let f=e.extractItemData(u),{indentLevel:h,mainContent:p}=f;i=`${i}${d}
20
+ `;let m=[p];for(s+=1;s<r.length;){var a;let S=r[s];if(S.trim()===""){var c;let v=r.slice(s+1).findIndex(D=>D.trim()!=="");if(v===-1)break;if((((c=r[s+1+v].match(/^(\s*)/))===null||c===void 0||(c=c[1])===null||c===void 0?void 0:c.length)||0)>h){m.push(S),i=`${i}${S}
21
+ `,s+=1;continue}else break}if((((a=S.match(/^(\s*)/))===null||a===void 0||(a=a[1])===null||a===void 0?void 0:a.length)||0)>h)m.push(S),i=`${i}${S}
22
+ `,s+=1;else break}let g,y=m.slice(1);if(y.length>0){let S=Jg(p,y.map(D=>_g(D,h+l)).join(`
23
+ `),t);f.mainContent=S.mainContent;let v=S.nestedContent;v.trim()&&(e.customNestedParser?g=e.customNestedParser(v):g=t.blockTokens(v))}let k=e.createToken(f,g);o.push(k)}if(o.length!==0)return{items:o,raw:i.slice(0,n.length)}}var Rc=4;function Ic(n){let e=0;for(let t of n)e=t===" "?e+Rc-e%Rc:e+1;return e}function qi(n,e,t,r,o){if(!n||!Array.isArray(n.content))return"";let i=typeof t=="function"?t(r):t,[s,...l]=n.content,a=e.renderChildren([s]),c=`${i}${o?.indentMainContent?a.split(`
24
+ `).map((d,u)=>u===0?d:e.indent(d)).join(`
25
+ `):a}`;return l&&l.length>0&&l.forEach((d,u)=>{var f,h;let p=(f=(h=e.renderChild)===null||h===void 0?void 0:h.call(e,d,u+1))!==null&&f!==void 0?f:e.renderChildren([d]);if(p!=null){let m=y=>{if(!o?.alignNestedToPrefix)return e.indent(y);let k=e.indent(""),S=Ic(i);return(Ic(k)>=S?k:" ".repeat(S))+y},g=p.split(`
26
26
  `).map(y=>m(y||"")).join(`
27
- `);c+=u.type==="paragraph"?`
27
+ `);c+=d.type==="paragraph"?`
28
28
 
29
29
  ${g}`:`
30
- ${g}`}}),c}function Ac(n,e){let t={...n};return wr(n)&&wr(e)&&Object.keys(e).forEach(r=>{wr(e[r])&&wr(n[r])?t[r]=Ac(n[r],e[r]):t[r]=e[r]}),t}function Am(n,e,t={}){let{state:r}=e,{doc:i,tr:s}=r,o=n;i.descendants((l,a)=>{let c=s.mapping.map(a),u=s.mapping.map(a)+l.nodeSize,d=null;if(l.marks.forEach(h=>{if(h!==o)return!1;d=h}),!d)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==d.attrs[h]&&(f=!0)}),f){let h=n.type.create({...n.attrs,...t});s.removeMark(c,u,n.type),s.addMark(c,u,h)}}),s.docChanged&&e.view.dispatch(s)}var Es=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!==null&&e!==void 0?e:!0}},Nm=(n,e)=>{if(ys(e))return e.exec(n);let t=e(n);if(!t)return null;let r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Om(n){let{editor:e,from:t,to:r,text:i,insertText:s}=n;if(!s)return{inputTransaction:null,tr:e.view.state.tr};let o=e.view.state.tr.insertText(i,t,r);return{inputTransaction:o,tr:st.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function Dm(n){let{editor:e,from:t,to:r,text:i,rule:s,match:o,plugin:l,insertText:a}=n,{view:c}=e,{inputTransaction:u,tr:d}=Om({editor:e,from:t,to:r,text:i,insertText:a}),f=u?t+i.length:r,h=Tr({state:c.state,transaction:d}),p={from:t-(o[0].length-i.length),to:f},{commands:m,chain:g,can:y}=new jt({editor:e,state:h});return s.handler({state:h,range:p,match:o,commands:m,chain:g,can:y})===null||!d.steps.length?!1:(u&&(c.dispatch(u),!c.state.doc.eq(u.doc))||(Ca(d),d.setMeta("inputRule",!0),s.undoable&&d.setMeta(l,{transform:d,from:t,to:f,text:i}),c.dispatch(d)),!0)}function Im(n,e,t){let r=e[0].length-t.length;if(r<=0)return!0;let i=n.parentOffset-r;return i>=0&&n.parent.textBetween(i,n.parentOffset)===e[0].slice(0,r)}function Mr(n){var e;let{editor:t,from:r,to:i,text:s,rules:o,plugin:l,insertText:a}=n,{view:c}=t;if(c.composing)return!1;let u=c.state.doc.resolve(r);if(u.parent.type.spec.code||!((e=u.nodeBefore||u.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let d=Ap(u)+s;for(let f of o){let h=Nm(d,f.find);if(!(!h||!Im(u,h,s))&&Dm({editor:t,from:r,to:i,text:s,rule:f,match:h,plugin:l,insertText:a}))return!0}return!1}function Rm(n){let{editor:e,rules:t}=n,r=new P({state:{init(){return null},apply(i,s,o){let l=i.getMeta(r);if(l)return l;let a=i.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:c}=a;typeof c=="string"?c=c:c=Ss(b.from(c),o.schema);let{from:u}=a,d=u+c.length;Mr({editor:e,from:u,to:d,text:c,rules:t,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return Mr({editor:e,from:s,to:o,text:l,rules:t,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{let{$cursor:s}=i.state.selection;s&&Mr({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;let{$cursor:o}=i.state.selection;return o?Mr({editor:e,from:o.pos,to:o.pos,text:`
31
- `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}var Ts=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...L(M(this,"addOptions",{name:this.name}))}}get storage(){return{...L(M(this,"addStorage",{name:this.name,options:this.options}))}}configure(n={}){let e=this.extend({...this.config,addOptions:()=>Ac(this.options,n)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(n={}){let e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},kt=class Nc extends Ts{constructor(...e){super(...e),this.type="mark"}static create(e={}){let t=typeof e=="function"?e():e;return new Nc(t)}static handleExit({editor:e,mark:t}){let{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){let s=i.marks();if(!s.find(l=>l?.type.name===t.name))return!1;let o=s.find(l=>l?.type.name===t.name);return o&&r.removeStoredMark(o),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e=="function"?e():e;return super.extend(t)}},Pm=class{constructor(n){this.find=n.find,this.handler=n.handler}},Lm=(n,e,t)=>{if(ys(e))return[...n.matchAll(e)];let r=e(n,t);return r?r.map(i=>{let s=[i.text];return s.index=i.index,s.input=n,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function Bm(n){let{editor:e,state:t,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=n,{commands:a,chain:c,can:u}=new jt({editor:e,state:t}),d=[];return t.doc.nodesBetween(r,i,(f,h)=>{var p,m,g,y;if(!((p=f.type)===null||p===void 0||(p=p.spec)===null||p===void 0)&&p.code||!(f.isText||f.isTextblock||f.isInline))return;let x=(m=(g=(y=f.content)===null||y===void 0?void 0:y.size)!==null&&g!==void 0?g:f.nodeSize)!==null&&m!==void 0?m:0,w=Math.max(r,h),v=Math.min(i,h+x);if(w>=v)return;let I=f.isText?f.text||"":f.textBetween(w-h,v-h,void 0,"\uFFFC");Lm(I,s.find,o).forEach(H=>{if(H.index===void 0)return;let A=w+H.index+1,R=A+H[0].length,z={from:t.tr.mapping.map(A),to:t.tr.mapping.map(R)},$=s.handler({state:t,range:z,match:H,commands:a,chain:c,can:u,pasteEvent:o,dropEvent:l});d.push($)})}),d.every(f=>f!==null)}var Ft=null,zm=n=>{var e;let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function $m(n){let{editor:e,rules:t}=n,r=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:c,from:u,to:d,rule:f,pasteEvt:h})=>{let p=c.tr,m=Tr({state:c,transaction:p});if(!(!Bm({editor:e,state:m,from:Math.max(u-1,0),to:d.b-1,rule:f,pasteEvent:h,dropEvent:l})||!p.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,p}};return e.on("destroy",()=>{Ft===e&&(Ft=null)}),t.map(c=>new P({view(u){let d=h=>{var p;r=!((p=u.dom.parentElement)===null||p===void 0)&&p.contains(h.target)?u.dom.parentElement:null,r&&(Ft=e)},f=()=>{Ft&&(Ft=null)};return window.addEventListener("dragstart",d),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",d),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(u,d)=>{if(s=r===u.dom.parentElement,l=d,!s){let f=Ft;f?.isEditable&&setTimeout(()=>{if(f.isDestroyed)return;let h=f.state.selection;h&&f.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(u,d)=>{var f;let h=(f=d.clipboardData)===null||f===void 0?void 0:f.getData("text/html");return o=d,i=!!h?.includes("data-pm-slice"),!1}}},appendTransaction:(u,d,f)=>{let h=u[0],p=h.getMeta("uiEvent")==="paste"&&!i,m=h.getMeta("uiEvent")==="drop"&&!s,g=h.getMeta("applyPasteRules"),y=!!g;if(!p&&!m&&!y)return;if(y){let{text:v}=g;typeof v=="string"?v=v:v=Ss(b.from(v),f.schema);let{from:I}=g,H=I+v.length,A=zm(v);return a({rule:c,state:f,from:I,to:{b:H},pasteEvt:A})}let x=d.doc.content.findDiffStart(f.doc.content),w=d.doc.content.findDiffEnd(f.doc.content);if(!(!Mm(x)||!w||x===w.b))return a({rule:c,state:f,from:x,to:w,pasteEvt:o})}}))}var Dr=class{constructor(n,e){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=e,this.baseExtensions=n,this.extensions=ws(n),this.hasSchemaSpec=e.options.schemaSpec!==void 0,this.schema=lc(this.extensions,e,e.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{let t=M(e,"addCommands",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:$t(e.name,this.schema)});return t?{...n,...t()}:n},{})}get plugins(){let{editor:n}=this,e=Nn([...this.extensions].reverse()).flatMap(r=>{let i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:n,type:$t(r.name,this.schema)},s=[],o=M(r,"addKeyboardShortcuts",i),l={};if(r.type==="mark"&&M(r,"exitable",i)&&(l.ArrowRight=()=>kt.handleExit({editor:n,mark:r})),o){let f=Object.fromEntries(Object.entries(o()).map(([h,p])=>[h,()=>p({editor:n})]));l={...l,...f}}let a=xa(l);s.push(a);let c=M(r,"addInputRules",i);if(Fa(r,n.options.enableInputRules)&&c){let f=c();if(f&&f.length){let h=Rm({editor:n,rules:f}),p=Array.isArray(h)?h:[h];s.push(...p)}}let u=M(r,"addPasteRules",i);if(Fa(r,n.options.enablePasteRules)&&u){let f=u();if(f&&f.length){let h=$m({editor:n,rules:f});s.push(...h)}}let d=M(r,"addProseMirrorPlugins",i);if(d){let f=d();s.push(...f)}return s}),t=this.createDecorationPlugin();return t&&e.push(t),e}createDecorationPlugin(){var n;let{editor:e}=this;(n=this.decorationManager)===null||n===void 0||n.destroy();let t=[];return this.extensions.forEach(r=>{let i=M(r,"addDecorations",{name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:$t(r.name,this.schema)});i&&t.push({name:r.name,addDecorations:i})}),this.decorationManager=new xm({editor:e,entries:t}),this.decorationManager.plugin}get attributes(){let n=xs(this.extensions);return this.hasSchemaSpec?sc(n,this.schema):n}get nodeViews(){let{editor:n}=this,{nodeExtensions:e}=Kt(this.extensions);return Object.fromEntries(e.filter(t=>!!M(t,"addNodeView")).map(t=>{let r=this.attributes.filter(l=>l.type===t.name),i=M(t,"addNodeView",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:J(t.name,this.schema)});if(!i)return[];let s=i();if(!s)return[];let o=(l,a,c,u,d)=>{let f=qt(l,r);return s({node:l,view:a,getPos:c,decorations:u,innerDecorations:d,editor:n,extension:t,HTMLAttributes:f})};return[t.name,o]}))}dispatchTransaction(n){let{editor:e}=this;return Nn([...this.extensions].reverse()).reduceRight((t,r)=>{let i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:$t(r.name,this.schema)},s=M(r,"dispatchTransaction",i);return s?o=>{s.call(i,{transaction:o,next:t})}:t},n)}transformPastedHTML(n){let{editor:e}=this;return Nn([...this.extensions]).reduce((t,r)=>{let i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:$t(r.name,this.schema)},s=M(r,"transformPastedHTML",i);return s?(o,l)=>{let a=t(o,l);return s.call(i,a)}:t},n||(t=>t))}get markViews(){let{editor:n}=this,{markExtensions:e}=Kt(this.extensions);return Object.fromEntries(e.filter(t=>!!M(t,"addMarkView")).map(t=>{let r=this.attributes.filter(o=>o.type===t.name),i=M(t,"addMarkView",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:ze(t.name,this.schema)});if(!i)return[];let s=(o,l,a)=>{let c=qt(o,r);return i()({mark:o,view:l,inline:a,editor:n,extension:t,HTMLAttributes:c,updateAttributes:u=>{Am(o,n,u)}})};return[t.name,s]}))}destroy(){var n;(n=this.decorationManager)===null||n===void 0||n.destroy(),this.extensions.forEach(e=>{let t=e;for(;t.parent;){let r=t.parent;r.child===t&&(r.child=null),t=r}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:$t(e.name,this.schema)};if(e.type==="mark"){var r,i;(!((r=L(M(e,"keepOnSplit",t)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(e.name),!((i=L(M(e,"clearable",t)))!==null&&i!==void 0)||i||this.nonClearableMarks.push(e.name)}let s=M(e,"onBeforeCreate",t),o=M(e,"onCreate",t),l=M(e,"onUpdate",t),a=M(e,"onSelectionUpdate",t),c=M(e,"onTransaction",t),u=M(e,"onFocus",t),d=M(e,"onBlur",t),f=M(e,"onDestroy",t);s&&this.editor.on("beforeCreate",s),o&&this.editor.on("create",o),l&&this.editor.on("update",l),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};Dr.resolve=ws;Dr.sort=Nn;Dr.flatten=ks;var V=class Oc extends Ts{constructor(...e){super(...e),this.type="extension"}static create(e={}){let t=typeof e=="function"?e():e;return new Oc(t)}configure(e){return super.configure(e)}extend(e){let t=typeof e=="function"?e():e;return super.extend(t)}},Fm=V.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new P({key:new W("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,s=uc(t),{blockSeparator:o}=this.options,l={...o!==void 0?{blockSeparator:o}:{},textSerializers:s};return[...i.ranges].sort((a,c)=>a.$from.pos-c.$from.pos).map(({$from:a,$to:c})=>cc(r,{from:a.pos,to:c.pos},l)).join(o??`
30
+ ${g}`}}),c}function gd(n,e){let t={...n};return Br(n)&&Br(e)&&Object.keys(e).forEach(r=>{Br(e[r])&&Br(n[r])?t[r]=gd(n[r],e[r]):t[r]=e[r]}),t}function Ug(n,e,t={}){let{state:r}=e,{doc:o,tr:i}=r,s=n;o.descendants((l,a)=>{let c=i.mapping.map(a),d=i.mapping.map(a)+l.nodeSize,u=null;if(l.marks.forEach(h=>{if(h!==s)return!1;u=h}),!u)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==u.attrs[h]&&(f=!0)}),f){let h=n.type.create({...n.attrs,...t});i.removeMark(c,d,n.type),i.addMark(c,d,h)}}),i.docChanged&&e.view.dispatch(i)}var Ji=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!==null&&e!==void 0?e:!0}},Gg=(n,e)=>{if($i(e))return e.exec(n);let t=e(n);if(!t)return null;let r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Xg(n){let{editor:e,from:t,to:r,text:o,insertText:i}=n;if(!i)return{inputTransaction:null,tr:e.view.state.tr};let s=e.view.state.tr.insertText(o,t,r);return{inputTransaction:s,tr:pt.create({doc:s.doc,selection:s.selection,storedMarks:s.storedMarks}).tr}}function Yg(n){let{editor:e,from:t,to:r,text:o,rule:i,match:s,plugin:l,insertText:a}=n,{view:c}=e,{inputTransaction:d,tr:u}=Xg({editor:e,from:t,to:r,text:o,insertText:a}),f=d?t+o.length:r,h=Vr({state:c.state,transaction:u}),p={from:t-(s[0].length-o.length),to:f},{commands:m,chain:g,can:y}=new Qt({editor:e,state:h});return i.handler({state:h,range:p,match:s,commands:m,chain:g,can:y})===null||!u.steps.length?!1:(d&&(c.dispatch(d),!c.state.doc.eq(d.doc))||(fc(u),u.setMeta("inputRule",!0),i.undoable&&u.setMeta(l,{transform:u,from:t,to:f,text:o}),c.dispatch(u)),!0)}function Zg(n,e,t){let r=e[0].length-t.length;if(r<=0)return!0;let o=n.parentOffset-r;return o>=0&&n.parent.textBetween(o,n.parentOffset)===e[0].slice(0,r)}function zr(n){var e;let{editor:t,from:r,to:o,text:i,rules:s,plugin:l,insertText:a}=n,{view:c}=t;if(c.composing)return!1;let d=c.state.doc.resolve(r);if(d.parent.type.spec.code||!((e=d.nodeBefore||d.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let u=Um(d)+i;for(let f of s){let h=Gg(u,f.find);if(!(!h||!Zg(d,h,i))&&Yg({editor:t,from:r,to:o,text:i,rule:f,match:h,plugin:l,insertText:a}))return!0}return!1}function Qg(n){let{editor:e,rules:t}=n,r=new I({state:{init(){return null},apply(o,i,s){let l=o.getMeta(r);if(l)return l;let a=o.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:c}=a;typeof c=="string"?c=c:c=Vi(b.from(c),s.schema);let{from:d}=a,u=d+c.length;zr({editor:e,from:d,to:u,text:c,rules:t,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,l){return zr({editor:e,from:i,to:s,text:l,rules:t,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{let{$cursor:i}=o.state.selection;i&&zr({editor:e,from:i.pos,to:i.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!=="Enter")return!1;let{$cursor:s}=o.state.selection;return s?zr({editor:e,from:s.pos,to:s.pos,text:`
31
+ `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}var Ui=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...B(M(this,"addOptions",{name:this.name}))}}get storage(){return{...B(M(this,"addStorage",{name:this.name,options:this.options}))}}configure(n={}){let e=this.extend({...this.config,addOptions:()=>gd(this.options,n)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(n={}){let e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},At=class yd extends Ui{constructor(...e){super(...e),this.type="mark"}static create(e={}){let t=typeof e=="function"?e():e;return new yd(t)}static handleExit({editor:e,mark:t}){let{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){let i=o.marks();if(!i.find(l=>l?.type.name===t.name))return!1;let s=i.find(l=>l?.type.name===t.name);return s&&r.removeStoredMark(s),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e=="function"?e():e;return super.extend(t)}},ey=class{constructor(n){this.find=n.find,this.handler=n.handler}},ty=(n,e,t)=>{if($i(e))return[...n.matchAll(e)];let r=e(n,t);return r?r.map(o=>{let i=[o.text];return i.index=o.index,i.input=n,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(o.replaceWith)),i}):[]};function ny(n){let{editor:e,state:t,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=n,{commands:a,chain:c,can:d}=new Qt({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,o,(f,h)=>{var p,m,g,y;if(!((p=f.type)===null||p===void 0||(p=p.spec)===null||p===void 0)&&p.code||!(f.isText||f.isTextblock||f.isInline))return;let k=(m=(g=(y=f.content)===null||y===void 0?void 0:y.size)!==null&&g!==void 0?g:f.nodeSize)!==null&&m!==void 0?m:0,S=Math.max(r,h),v=Math.min(o,h+k);if(S>=v)return;let D=f.isText?f.text||"":f.textBetween(S-h,v-h,void 0,"\uFFFC");ty(D,i.find,s).forEach($=>{if($.index===void 0)return;let E=S+$.index+1,R=E+$[0].length,V={from:t.tr.mapping.map(E),to:t.tr.mapping.map(R)},W=i.handler({state:t,range:V,match:$,commands:a,chain:c,can:d,pasteEvent:s,dropEvent:l});u.push(W)})}),u.every(f=>f!==null)}var Xt=null,ry=n=>{var e;let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function oy(n){let{editor:e,rules:t}=n,r=null,o=!1,i=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:c,from:d,to:u,rule:f,pasteEvt:h})=>{let p=c.tr,m=Vr({state:c,transaction:p});if(!(!ny({editor:e,state:m,from:Math.max(d-1,0),to:u.b-1,rule:f,pasteEvent:h,dropEvent:l})||!p.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,p}};return e.on("destroy",()=>{Xt===e&&(Xt=null)}),t.map(c=>new I({view(d){let u=h=>{var p;r=!((p=d.dom.parentElement)===null||p===void 0)&&p.contains(h.target)?d.dom.parentElement:null,r&&(Xt=e)},f=()=>{Xt&&(Xt=null)};return window.addEventListener("dragstart",u),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",u),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(d,u)=>{if(i=r===d.dom.parentElement,l=u,!i){let f=Xt;f?.isEditable&&setTimeout(()=>{if(f.isDestroyed)return;let h=f.state.selection;h&&f.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(d,u)=>{var f;let h=(f=u.clipboardData)===null||f===void 0?void 0:f.getData("text/html");return s=u,o=!!h?.includes("data-pm-slice"),!1}}},appendTransaction:(d,u,f)=>{let h=d[0],p=h.getMeta("uiEvent")==="paste"&&!o,m=h.getMeta("uiEvent")==="drop"&&!i,g=h.getMeta("applyPasteRules"),y=!!g;if(!p&&!m&&!y)return;if(y){let{text:v}=g;typeof v=="string"?v=v:v=Vi(b.from(v),f.schema);let{from:D}=g,$=D+v.length,E=ry(v);return a({rule:c,state:f,from:D,to:{b:$},pasteEvt:E})}let k=u.doc.content.findDiffStart(f.doc.content),S=u.doc.content.findDiffEnd(f.doc.content);if(!(!jg(k)||!S||k===S.b))return a({rule:c,state:f,from:k,to:S,pasteEvt:s})}}))}var _r=class{constructor(n,e){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=e,this.baseExtensions=n,this.extensions=ji(n),this.hasSchemaSpec=e.options.schemaSpec!==void 0,this.schema=Uc(this.extensions,e,e.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{let t=M(e,"addCommands",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Gt(e.name,this.schema)});return t?{...n,...t()}:n},{})}get plugins(){let{editor:n}=this,e=jn([...this.extensions].reverse()).flatMap(r=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:n,type:Gt(r.name,this.schema)},i=[],s=M(r,"addKeyboardShortcuts",o),l={};if(r.type==="mark"&&M(r,"exitable",o)&&(l.ArrowRight=()=>At.handleExit({editor:n,mark:r})),s){let f=Object.fromEntries(Object.entries(s()).map(([h,p])=>[h,()=>p({editor:n})]));l={...l,...f}}let a=ac(l);i.push(a);let c=M(r,"addInputRules",o);if(Ec(r,n.options.enableInputRules)&&c){let f=c();if(f&&f.length){let h=Qg({editor:n,rules:f}),p=Array.isArray(h)?h:[h];i.push(...p)}}let d=M(r,"addPasteRules",o);if(Ec(r,n.options.enablePasteRules)&&d){let f=d();if(f&&f.length){let h=oy({editor:n,rules:f});i.push(...h)}}let u=M(r,"addProseMirrorPlugins",o);if(u){let f=u();i.push(...f)}return i}),t=this.createDecorationPlugin();return t&&e.push(t),e}createDecorationPlugin(){var n;let{editor:e}=this;(n=this.decorationManager)===null||n===void 0||n.destroy();let t=[];return this.extensions.forEach(r=>{let o=M(r,"addDecorations",{name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Gt(r.name,this.schema)});o&&t.push({name:r.name,addDecorations:o})}),this.decorationManager=new Vg({editor:e,entries:t}),this.decorationManager.plugin}get attributes(){let n=Wi(this.extensions);return this.hasSchemaSpec?qc(n,this.schema):n}get nodeViews(){let{editor:n}=this,{nodeExtensions:e}=tn(this.extensions);return Object.fromEntries(e.filter(t=>!!M(t,"addNodeView")).map(t=>{let r=this.attributes.filter(l=>l.type===t.name),o=M(t,"addNodeView",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:X(t.name,this.schema)});if(!o)return[];let i=o();if(!i)return[];let s=(l,a,c,d,u)=>{let f=nn(l,r);return i({node:l,view:a,getPos:c,decorations:d,innerDecorations:u,editor:n,extension:t,HTMLAttributes:f})};return[t.name,s]}))}dispatchTransaction(n){let{editor:e}=this;return jn([...this.extensions].reverse()).reduceRight((t,r)=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Gt(r.name,this.schema)},i=M(r,"dispatchTransaction",o);return i?s=>{i.call(o,{transaction:s,next:t})}:t},n)}transformPastedHTML(n){let{editor:e}=this;return jn([...this.extensions]).reduce((t,r)=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:Gt(r.name,this.schema)},i=M(r,"transformPastedHTML",o);return i?(s,l)=>{let a=t(s,l);return i.call(o,a)}:t},n||(t=>t))}get markViews(){let{editor:n}=this,{markExtensions:e}=tn(this.extensions);return Object.fromEntries(e.filter(t=>!!M(t,"addMarkView")).map(t=>{let r=this.attributes.filter(s=>s.type===t.name),o=M(t,"addMarkView",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:je(t.name,this.schema)});if(!o)return[];let i=(s,l,a)=>{let c=nn(s,r);return o()({mark:s,view:l,inline:a,editor:n,extension:t,HTMLAttributes:c,updateAttributes:d=>{Ug(s,n,d)}})};return[t.name,i]}))}destroy(){var n;(n=this.decorationManager)===null||n===void 0||n.destroy(),this.extensions.forEach(e=>{let t=e;for(;t.parent;){let r=t.parent;r.child===t&&(r.child=null),t=r}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Gt(e.name,this.schema)};if(e.type==="mark"){var r,o;(!((r=B(M(e,"keepOnSplit",t)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(e.name),!((o=B(M(e,"clearable",t)))!==null&&o!==void 0)||o||this.nonClearableMarks.push(e.name)}let i=M(e,"onBeforeCreate",t),s=M(e,"onCreate",t),l=M(e,"onUpdate",t),a=M(e,"onSelectionUpdate",t),c=M(e,"onTransaction",t),d=M(e,"onFocus",t),u=M(e,"onBlur",t),f=M(e,"onDestroy",t);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),l&&this.editor.on("update",l),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),d&&this.editor.on("focus",d),u&&this.editor.on("blur",u),f&&this.editor.on("destroy",f)})}};_r.resolve=ji;_r.sort=jn;_r.flatten=Hi;var z=class bd extends Ui{constructor(...e){super(...e),this.type="extension"}static create(e={}){let t=typeof e=="function"?e():e;return new bd(t)}configure(e){return super.configure(e)}extend(e){let t=typeof e=="function"?e():e;return super.extend(t)}},iy=z.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new I({key:new F("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:o}=e,i=Yc(t),{blockSeparator:s}=this.options,l={...s!==void 0?{blockSeparator:s}:{},textSerializers:i};return[...o.ranges].sort((a,c)=>a.$from.pos-c.$from.pos).map(({$from:a,$to:c})=>Xc(r,{from:a.pos,to:c.pos},l)).join(s??`
32
32
 
33
- `)}}})]}}),Vm=V.create({name:"commands",addCommands(){return{...om}}}),Hm=V.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r;let i=()=>{var s,o,l;if((s=(o=this.editor.options.coreExtensionOptions)===null||o===void 0||(o=o.delete)===null||o===void 0||(l=o.filterTransaction)===null||l===void 0?void 0:l.call(o,n))!==null&&s!==void 0?s:n.getMeta("y-sync$"))return;let a=pp(n.before,[n,...e]);Or(a).forEach(u=>{a.mapping.mapResult(u.oldRange.from).deletedAfter&&a.mapping.mapResult(u.oldRange.to).deletedBefore&&a.before.nodesBetween(u.oldRange.from,u.oldRange.to,(d,f)=>{let h=f+d.nodeSize-2,p=u.oldRange.from<=f&&h<=u.oldRange.to;this.editor.emit("delete",{type:"node",node:d,from:f,to:h,newFrom:a.mapping.map(f),newTo:a.mapping.map(h),deletedRange:u.oldRange,newRange:u.newRange,partial:!p,editor:this.editor,transaction:n,combinedTransform:a})})});let c=a.mapping;a.steps.forEach((u,d)=>{if(u instanceof He){var f,h;let p=c.slice(d).map(u.from,-1),m=c.slice(d).map(u.to),g=c.invert().map(p,-1),y=c.invert().map(m),x=p>0?(f=a.doc.nodeAt(p-1))===null||f===void 0?void 0:f.marks.some(v=>v.eq(u.mark)):!1,w=(h=a.doc.nodeAt(m))===null||h===void 0?void 0:h.marks.some(v=>v.eq(u.mark));this.editor.emit("delete",{type:"mark",mark:u.mark,from:u.from,to:u.to,deletedRange:{from:g,to:y},newRange:{from:p,to:m},partial:!!(w||x),editor:this.editor,transaction:n,combinedTransform:a})}})};!((t=(r=this.editor.options.coreExtensionOptions)===null||r===void 0||(r=r.delete)===null||r===void 0?void 0:r.async)!==null&&t!==void 0)||t?setTimeout(i,0):i()}}),jm=V.create({name:"drop",addProseMirrorPlugins(){return[new P({key:new W("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),Wm=V.create({name:"editable",addProseMirrorPlugins(){return[new P({key:new W("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Km=new W("focusEvents"),qm=V.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:n}=this;return[new P({key:Km,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;let r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;let r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Jm=V.create({name:"keymap",addKeyboardShortcuts(){let n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,y=m&&p.parent.childCount===1?g===d.pos:N.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!y||y&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Er()||rc()?s:i},addProseMirrorPlugins(){return[new P({key:new W("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(h=>h.getMeta("composition")))return;let r=n.some(h=>h.docChanged)&&!e.doc.eq(t.doc),i=n.some(h=>h.getMeta("preventClearDocument"));if(!r||i)return;let{empty:s,from:o,to:l}=e.selection,a=N.atStart(e.doc).from,c=N.atEnd(e.doc).to;if(s||!(o===a&&l===c)||!Jt(t.doc))return;let u=t.tr,d=Tr({state:t,transaction:u}),{commands:f}=new jt({editor:this.editor,state:d});if(f.clearNodes(),!!u.steps.length)return u}})]}}),_m=V.create({name:"paste",addProseMirrorPlugins(){return[new P({key:new W("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Um=V.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new P({key:new W("tabindex"),props:{attributes:()=>{var n;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(n=this.options.value)!==null&&n!==void 0?n:"0"}}}})]}}),Gm=V.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:n}=Kt(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new P({key:new W("textDirection"),props:{attributes:()=>{let n=this.options.direction;return n?{dir:n}:{}}}})]}});var _a=!1;function Xm(n){if(_a)return;_a=!0;let e;try{let t=Y.fromJSON(n,{from:0,to:0});if(!Dp(t))return;e=t.slice.content}catch{return}e instanceof b||console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.")}var Ym=class An{get name(){return this.node.type.name}constructor(e,t,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new An(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new An(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new An(e,this.editor)}get children(){let e=[];return this.node.content.forEach((t,r)=>{let i=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,o=t.isInline,l=this.pos+r+(s?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;let a=this.resolvedPos.doc.resolve(l);if(!i&&!o&&a.depth<=this.depth)return;let c=new An(a,this.editor,i,i||o?t:null);i&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(t).length>0){let s=i.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){let a=o[l];if(s[a]!==t[a])break}}else r=i;i=i.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;let s=Object.keys(t);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.every(l=>t[l]===o.node.attrs[l])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,t,r))))}),i}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},Zm=`.ProseMirror {
33
+ `)}}})]}}),sy=z.create({name:"commands",addCommands(){return{...Eg}}}),ly=z.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r;let o=()=>{var i,s,l;if((i=(s=this.editor.options.coreExtensionOptions)===null||s===void 0||(s=s.delete)===null||s===void 0||(l=s.filterTransaction)===null||l===void 0?void 0:l.call(s,n))!==null&&i!==void 0?i:n.getMeta("y-sync$"))return;let a=Lm(n.before,[n,...e]);Kr(a).forEach(d=>{a.mapping.mapResult(d.oldRange.from).deletedAfter&&a.mapping.mapResult(d.oldRange.to).deletedBefore&&a.before.nodesBetween(d.oldRange.from,d.oldRange.to,(u,f)=>{let h=f+u.nodeSize-2,p=d.oldRange.from<=f&&h<=d.oldRange.to;this.editor.emit("delete",{type:"node",node:u,from:f,to:h,newFrom:a.mapping.map(f),newTo:a.mapping.map(h),deletedRange:d.oldRange,newRange:d.newRange,partial:!p,editor:this.editor,transaction:n,combinedTransform:a})})});let c=a.mapping;a.steps.forEach((d,u)=>{if(d instanceof Ue){var f,h;let p=c.slice(u).map(d.from,-1),m=c.slice(u).map(d.to),g=c.invert().map(p,-1),y=c.invert().map(m),k=p>0?(f=a.doc.nodeAt(p-1))===null||f===void 0?void 0:f.marks.some(v=>v.eq(d.mark)):!1,S=(h=a.doc.nodeAt(m))===null||h===void 0?void 0:h.marks.some(v=>v.eq(d.mark));this.editor.emit("delete",{type:"mark",mark:d.mark,from:d.from,to:d.to,deletedRange:{from:g,to:y},newRange:{from:p,to:m},partial:!!(S||k),editor:this.editor,transaction:n,combinedTransform:a})}})};!((t=(r=this.editor.options.coreExtensionOptions)===null||r===void 0||(r=r.delete)===null||r===void 0?void 0:r.async)!==null&&t!==void 0)||t?setTimeout(o,0):o()}}),ay=z.create({name:"drop",addProseMirrorPlugins(){return[new I({key:new F("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),cy=z.create({name:"editable",addProseMirrorPlugins(){return[new I({key:new F("editable"),props:{editable:()=>this.editor.options.editable}})]}}),dy=new F("focusEvents"),uy=z.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:n}=this;return[new I({key:dy,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;let r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;let r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),fy=z.create({name:"keymap",addKeyboardShortcuts(){let n=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,p=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,m=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,y=m&&p.parent.childCount===1?g===u.pos:T.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},i={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Hr()||Kc()?i:o},addProseMirrorPlugins(){return[new I({key:new F("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(h=>h.getMeta("composition")))return;let r=n.some(h=>h.docChanged)&&!e.doc.eq(t.doc),o=n.some(h=>h.getMeta("preventClearDocument"));if(!r||o)return;let{empty:i,from:s,to:l}=e.selection,a=T.atStart(e.doc).from,c=T.atEnd(e.doc).to;if(i||!(s===a&&l===c)||!on(t.doc))return;let d=t.tr,u=Vr({state:t,transaction:d}),{commands:f}=new Qt({editor:this.editor,state:u});if(f.clearNodes(),!!d.steps.length)return d}})]}}),hy=z.create({name:"paste",addProseMirrorPlugins(){return[new I({key:new F("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),py=z.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new I({key:new F("tabindex"),props:{attributes:()=>{var n;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(n=this.options.value)!==null&&n!==void 0?n:"0"}}}})]}}),my=z.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:n}=tn(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new I({key:new F("textDirection"),props:{attributes:()=>{let n=this.options.direction;return n?{dir:n}:{}}}})]}});var Pc=!1;function gy(n){if(Pc)return;Pc=!0;let e;try{let t=ee.fromJSON(n,{from:0,to:0});if(!Ym(t))return;e=t.slice.content}catch{return}e instanceof b||console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.")}var yy=class Wn{get name(){return this.node.type.name}constructor(e,t,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=o}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Wn(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Wn(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Wn(e,this.editor)}get children(){let e=[];return this.node.content.forEach((t,r)=>{let o=t.isBlock&&!t.isTextblock,i=t.isAtom&&!t.isText,s=t.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;let a=this.resolvedPos.doc.resolve(l);if(!o&&!s&&a.depth<=this.depth)return;let c=new Wn(a,this.editor,o,o||s?t:null);o&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(t).length>0){let i=o.node.attrs,s=Object.keys(t);for(let l=0;l<s.length;l+=1){let a=s[l];if(i[a]!==t[a])break}}else r=o;o=o.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;let i=Object.keys(t);return this.children.forEach(s=>{r&&o.length>0||(s.node.type.name===e&&i.every(l=>t[l]===s.node.attrs[l])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(e,t,r))))}),o}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},by=`.ProseMirror {
34
34
  position: relative;
35
35
  }
36
36
 
@@ -100,26 +100,41 @@ img.ProseMirror-separator {
100
100
 
101
101
  .ProseMirror-focused .ProseMirror-gapcursor {
102
102
  display: block;
103
- }`,Dc=class extends cm{constructor(n={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Ip,createMappablePosition:Rp},this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:i})=>this.options.onDrop(t,r,i)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),this.on("delete",this.options.onDelete);let e=this.createDoc();if(!this.editorState){let t=hs(e,this.options.autofocus);this.editorState=st.create({doc:e,schema:this.schema,selection:t||void 0})}Xm(this.schema),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let n=this.editorView.dom;n?.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(n){console.warn("Failed to remove CSS element:",n)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():jt.createFakeChain()}can(){return this.commandManager?this.commandManager.can():jt.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=wm(Zm,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return wc&&!this.hasWarnedStaleDecorationRead&&am(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,e){let t=ms(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;let e=this.state.plugins,t=e;if([].concat(n).forEach(i=>{let s=typeof i=="string"?`${i}$`:i.key;t=t.filter(o=>!o.key.startsWith(s))}),e.length===t.length)return;let r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}createExtensionManager(){var n,e;let t=[...this.options.enableCoreExtensions?[Wm,Fm.configure({blockSeparator:(n=this.options.coreExtensionOptions)===null||n===void 0||(n=n.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),Vm,qm,Jm,Um.configure({value:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.tabindex)===null||e===void 0?void 0:e.value}),jm,_m,Hm,Gm.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r?.type));this.extensionManager=new Dr(t,this)}createCommandManager(){this.commandManager=new jt({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=ps(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;let t=ps(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=st.create({doc:t,schema:this.schema,selection:hs(t,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return n}getEditorViewAttributes(){var n;let e=(n=this.options.editorProps)===null||n===void 0?void 0:n.attributes;return ms(e)?t=>({role:"textbox",...e(t)}):{role:"textbox",...e}}createView(n){let{editorProps:e,enableExtensionDispatchTransaction:t}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),i=t?this.extensionManager.dispatchTransaction(r):r,s=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(s);this.editorView=new Mn(n,{...e,attributes:this.getEditorViewAttributes(),dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();let a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;let e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(c=>{var u;return(u=this.capturedTransaction)===null||u===void 0?void 0:u.step(c)});return}let{state:e,transactions:t}=this.state.applyTransaction(n),r=!this.state.selection.eq(e.selection),i=t.includes(n),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});let o=t.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=o?.getMeta("focus"),a=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),a&&this.emit("blur",{editor:this,event:a.event,transaction:o}),!(n.getMeta("preventUpdate")||!t.some(c=>c.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return Cp(this.state,n)}isActive(n,e){let t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return Np(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Ss(this.state.doc.content,this.schema)}getText(n){let{blockSeparator:e=`
103
+ }`,wd=class extends Ng{constructor(n={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Zm,createMappablePosition:Qm},this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:o})=>this.options.onDrop(t,r,o)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),this.on("delete",this.options.onDelete);let e=this.createDoc();if(!this.editorState){let t=Pi(e,this.options.autofocus);this.editorState=pt.create({doc:e,schema:this.schema,selection:t||void 0})}gy(this.schema),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let n=this.editorView.dom;n?.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(n){console.warn("Failed to remove CSS element:",n)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():Qt.createFakeChain()}can(){return this.commandManager?this.commandManager.can():Qt.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=Wg(by,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return cd&&!this.hasWarnedStaleDecorationRead&&Ag(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,e){let t=Bi(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;let e=this.state.plugins,t=e;if([].concat(n).forEach(o=>{let i=typeof o=="string"?`${o}$`:o.key;t=t.filter(s=>!s.key.startsWith(i))}),e.length===t.length)return;let r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}createExtensionManager(){var n,e;let t=[...this.options.enableCoreExtensions?[cy,iy.configure({blockSeparator:(n=this.options.coreExtensionOptions)===null||n===void 0||(n=n.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),sy,uy,fy,py.configure({value:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.tabindex)===null||e===void 0?void 0:e.value}),ay,hy,ly,my.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r?.type));this.extensionManager=new _r(t,this)}createCommandManager(){this.commandManager=new Qt({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=Li(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;let t=Li(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=pt.create({doc:t,schema:this.schema,selection:Pi(t,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return n}getEditorViewAttributes(){var n;let e=(n=this.options.editorProps)===null||n===void 0?void 0:n.attributes;return Bi(e)?t=>({role:"textbox",...e(t)}):{role:"textbox",...e}}createView(n){let{editorProps:e,enableExtensionDispatchTransaction:t}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),o=t?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,s=this.extensionManager.transformPastedHTML(i);this.editorView=new Bn(n,{...e,attributes:this.getEditorViewAttributes(),dispatchTransaction:o,transformPastedHTML:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();let a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;let e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(c=>{var d;return(d=this.capturedTransaction)===null||d===void 0?void 0:d.step(c)});return}let{state:e,transactions:t}=this.state.applyTransaction(n),r=!this.state.selection.eq(e.selection),o=t.includes(n),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!o)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});let s=t.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=s?.getMeta("focus"),a=s?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:s}),a&&this.emit("blur",{editor:this,event:a.event,transaction:s}),!(n.getMeta("preventUpdate")||!t.some(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return _m(this.state,n)}isActive(n,e){let t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return Gm(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Vi(this.state.doc.content,this.schema)}getText(n){let{blockSeparator:e=`
104
104
 
105
- `,textSerializers:t={}}=n||{};return Mp(this.state.doc,{blockSeparator:e,textSerializers:{...uc(this.schema),...t}})}get isEmpty(){return Jt(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var n,e;return(n=(e=this.editorView)===null||e===void 0?void 0:e.isDestroyed)!==null&&n!==void 0?n:!0}$node(n,e){var t;return((t=this.$doc)===null||t===void 0?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)===null||t===void 0?void 0:t.querySelectorAll(n,e))||null}$pos(n){let e=this.state.doc.resolve(n),t=n>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new Ym(e,this,!1,t)}get $doc(){return this.$pos(0)}};function _t(n){return new Es({find:n.find,handler:({state:e,range:t,match:r})=>{let i=L(n.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:s}=e,o=r[r.length-1],l=r[0];if(o){let a=l.search(/\S/),c=t.from+l.indexOf(o),u=c+o.length;if(dc(t.from,t.to,e.doc).filter(f=>f.mark.type.excluded.find(h=>h===n.type&&h!==f.mark.type)).filter(f=>f.to>c).length)return null;u<t.to&&s.delete(u,t.to),c>t.from&&s.delete(t.from+a,c);let d=t.from+a+o.length;s.addMark(t.from+a,d,n.type.create(i||{})),s.removeStoredMark(n.type)}},undoable:n.undoable})}function Ic(n){return new Es({find:n.find,handler:({state:e,range:t,match:r})=>{let i=e.doc.resolve(t.from),s=L(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)},undoable:n.undoable})}function Ue(n){return new Es({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{let s=L(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),l=o.doc.resolve(t.from).blockRange(),a=l&&Nt(l,n.type,s);if(!a)return null;if(o.wrap(l,a),n.keepMarks&&n.editor){let{selection:u,storedMarks:d}=e,{splittableMarks:f}=n.editor.extensionManager,h=d||u.$to.parentOffset&&u.$from.marks();if(h){let p=h.filter(m=>f.includes(m.type.name));o.ensureMarks(p)}}if(n.keepAttributes){let u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(u,s).run()}let c=o.doc.resolve(t.from-1).nodeBefore;c&&c.type===n.type&&ke(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,c))&&o.join(t.from-1)},undoable:n.undoable})}var _=class Rc extends Ts{constructor(...e){super(...e),this.type="node"}static create(e={}){let t=typeof e=="function"?e():e;return new Rc(t)}configure(e){return super.configure(e)}extend(e){let t=typeof e=="function"?e():e;return super.extend(t)}};function Ut(n){return new Pm({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{let s=L(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;let{tr:o}=e,l=r[r.length-1],a=r[0],c=t.to;if(l){let u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(dc(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(p=>p===n.type&&p!==h.mark.type)).filter(h=>h.to>d).length)return null;f<t.to&&o.delete(f,t.to),d>t.from&&o.delete(t.from+u,d),c=t.from+u+l.length,o.addMark(t.from+u,c,n.type.create(s||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(n.type)}}})}var Pc=new WeakSet,Lc=new WeakSet;function St(n){let e=n;return Pc.add(e),e}function As(n){return Array.isArray(n)&&Pc.has(n)}function Bc(n){return n.flatMap(e=>e==null?[]:Array.isArray(e)&&Lc.has(e)&&!As(e)?Bc(e):[e])}function Qm(n,e){if(n==="slot")return 0;if(n instanceof Function){let i=n(e);return Array.isArray(i)&&!As(i)&&!Lc.has(i)?St(i):i}let{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(t)){if(As(t))return St([n,r,t]);if(t.length===0)return St([n,r]);let i=Bc(t);return i.length===0?St([n,r]):St([n,r,...i])}return t!=null?St([n,r,t]):St([n,r])}var Gt=(n,e)=>Qm(n,e);var eg=(n,e)=>{var t;let{state:r}=n,{selection:i}=r;if(!i.empty)return!1;let{$from:s}=i;if(s.parentOffset!==0)return!1;let o=s.depth-1;if(o<0)return!1;let l=s.node(o),a=s.index(o);if(a===0)return!1;if(l.type===e)return n.commands.lift(e.name);let c=l.child(a-1);if(c.type!==e||!(!((t=c.lastChild)===null||t===void 0)&&t.isTextblock))return!1;let u=s.before()-1-1;return n.commands.command(({tr:d,dispatch:f})=>{if(!f)return!0;let h=s.parent.content,p=new k(h,0,0);return d.replace(u,s.after(),p),d.setSelection(C.create(d.doc,u+h.size)),d.scrollIntoView(),f(d),!0})},tg=/^\s*>\s$/,zc=_.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return Gt("blockquote",{...G(this.options.HTMLAttributes,n),children:Gt("slot",{})})},parseMarkdown:(n,e)=>{var t;let r=(t=e.parseBlockChildren)!==null&&t!==void 0?t:e.parseChildren;return e.createNode("blockquote",void 0,r(n.tokens||[]))},renderMarkdown:(n,e)=>{if(!n.content)return"";let t=">",r=[];return n.content.forEach((i,s)=>{var o,l;let a=((o=(l=e.renderChild)===null||l===void 0?void 0:l.call(e,i,s))!==null&&o!==void 0?o:e.renderChildren([i])).split(`
105
+ `,textSerializers:t={}}=n||{};return jm(this.state.doc,{blockSeparator:e,textSerializers:{...Yc(this.schema),...t}})}get isEmpty(){return on(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var n,e;return(n=(e=this.editorView)===null||e===void 0?void 0:e.isDestroyed)!==null&&n!==void 0?n:!0}$node(n,e){var t;return((t=this.$doc)===null||t===void 0?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)===null||t===void 0?void 0:t.querySelectorAll(n,e))||null}$pos(n){let e=this.state.doc.resolve(n),t=n>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new yy(e,this,!1,t)}get $doc(){return this.$pos(0)}};function sn(n){return new Ji({find:n.find,handler:({state:e,range:t,match:r})=>{let o=B(n.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:i}=e,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\S/),c=t.from+l.indexOf(s),d=c+s.length;if(Zc(t.from,t.to,e.doc).filter(f=>f.mark.type.excluded.find(h=>h===n.type&&h!==f.mark.type)).filter(f=>f.to>c).length)return null;d<t.to&&i.delete(d,t.to),c>t.from&&i.delete(t.from+a,c);let u=t.from+a+s.length;i.addMark(t.from+a,u,n.type.create(o||{})),i.removeStoredMark(n.type)}},undoable:n.undoable})}function kd(n){return new Ji({find:n.find,handler:({state:e,range:t,match:r})=>{let o=e.doc.resolve(t.from),i=B(n.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,i)},undoable:n.undoable})}function nt(n){return new Ji({find:n.find,handler:({state:e,range:t,match:r,chain:o})=>{let i=B(n.getAttributes,void 0,r)||{},s=e.tr.delete(t.from,t.to),l=s.doc.resolve(t.from).blockRange(),a=l&&Ft(l,n.type,i);if(!a)return null;if(s.wrap(l,a),n.keepMarks&&n.editor){let{selection:d,storedMarks:u}=e,{splittableMarks:f}=n.editor.extensionManager,h=u||d.$to.parentOffset&&d.$from.marks();if(h){let p=h.filter(m=>f.includes(m.type.name));s.ensureMarks(p)}}if(n.keepAttributes){let d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(d,i).run()}let c=s.doc.resolve(t.from-1).nodeBefore;c&&c.type===n.type&&Ce(s.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,c))&&s.join(t.from-1)},undoable:n.undoable})}var K=class Sd extends Ui{constructor(...e){super(...e),this.type="node"}static create(e={}){let t=typeof e=="function"?e():e;return new Sd(t)}configure(e){return super.configure(e)}extend(e){let t=typeof e=="function"?e():e;return super.extend(t)}};function ln(n){return new ey({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:o})=>{let i=B(n.getAttributes,void 0,r,o);if(i===!1||i===null)return null;let{tr:s}=e,l=r[r.length-1],a=r[0],c=t.to;if(l){let d=a.search(/\S/),u=t.from+a.indexOf(l),f=u+l.length;if(Zc(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(p=>p===n.type&&p!==h.mark.type)).filter(h=>h.to>u).length)return null;f<t.to&&s.delete(f,t.to),u>t.from&&s.delete(t.from+d,u),c=t.from+d+l.length,s.addMark(t.from+d,c,n.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||s.removeStoredMark(n.type)}}})}var xd=new WeakSet,Cd=new WeakSet;function Nt(n){let e=n;return xd.add(e),e}function Gi(n){return Array.isArray(n)&&xd.has(n)}function vd(n){return n.flatMap(e=>e==null?[]:Array.isArray(e)&&Cd.has(e)&&!Gi(e)?vd(e):[e])}function wy(n,e){if(n==="slot")return 0;if(n instanceof Function){let o=n(e);return Array.isArray(o)&&!Gi(o)&&!Cd.has(o)?Nt(o):o}let{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(t)){if(Gi(t))return Nt([n,r,t]);if(t.length===0)return Nt([n,r]);let o=vd(t);return o.length===0?Nt([n,r]):Nt([n,r,...o])}return t!=null?Nt([n,r,t]):Nt([n,r])}var an=(n,e)=>wy(n,e);var ky=(n,e)=>{var t;let{state:r}=n,{selection:o}=r;if(!o.empty)return!1;let{$from:i}=o;if(i.parentOffset!==0)return!1;let s=i.depth-1;if(s<0)return!1;let l=i.node(s),a=i.index(s);if(a===0)return!1;if(l.type===e)return n.commands.lift(e.name);let c=l.child(a-1);if(c.type!==e||!(!((t=c.lastChild)===null||t===void 0)&&t.isTextblock))return!1;let d=i.before()-1-1;return n.commands.command(({tr:u,dispatch:f})=>{if(!f)return!0;let h=i.parent.content,p=new w(h,0,0);return u.replace(d,i.after(),p),u.setSelection(C.create(u.doc,d+h.size)),u.scrollIntoView(),f(u),!0})},Sy=/^\s*>\s$/,Md=K.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return an("blockquote",{...j(this.options.HTMLAttributes,n),children:an("slot",{})})},parseMarkdown:(n,e)=>{var t;let r=(t=e.parseBlockChildren)!==null&&t!==void 0?t:e.parseChildren;return e.createNode("blockquote",void 0,r(n.tokens||[]))},renderMarkdown:(n,e)=>{if(!n.content)return"";let t=">",r=[];return n.content.forEach((o,i)=>{var s,l;let a=((s=(l=e.renderChild)===null||l===void 0?void 0:l.call(e,o,i))!==null&&s!==void 0?s:e.renderChildren([o])).split(`
106
106
  `).map(c=>c.trim()===""?t:`${t} ${c}`);r.push(a.join(`
107
107
  `))}),r.join(`
108
108
  ${t}
109
- `)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>eg(this.editor,this.type)}},addInputRules(){return[Ue({find:tg,type:this.type})]}});var ng=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,rg=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,ig=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,sg=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,$c=kt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return Gt("strong",{...G(this.options.HTMLAttributes,n),children:Gt("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[_t({find:ng,type:this.type}),_t({find:ig,type:this.type})]},addPasteRules(){return[Ut({find:rg,type:this.type}),Ut({find:sg,type:this.type})]}});var Fc=_.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
109
+ `)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>ky(this.editor,this.type)}},addInputRules(){return[nt({find:Sy,type:this.type})]}});var xy=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Cy=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,vy=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,My=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Ed=At.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return an("strong",{...j(this.options.HTMLAttributes,n),children:an("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[sn({find:xy,type:this.type}),sn({find:vy,type:this.type})]},addPasteRules(){return[ln({find:Cy,type:this.type}),ln({find:My,type:this.type})]}});var Xi=K.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
110
110
 
111
- `):""});var Vc=_.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",G(this.options.HTMLAttributes,n)]},renderText(){return`
111
+ `):""});var Td=K.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",j(this.options.HTMLAttributes,n)]},renderText(){return`
112
112
  `},renderMarkdown:()=>`
113
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{let{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;let{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){let d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var Hc=_.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,G(this.options.HTMLAttributes,e),0]},parseMarkdown(n,e){let t=n.depth||1;return this.options.levels.includes(t)?e.createNode("heading",{level:t},e.parseInline(n.tokens||[])):e.createNode("paragraph",void 0,e.parseInline(n.tokens||[]))},renderMarkdown:(n,e)=>{var t;let r=!((t=n.attrs)===null||t===void 0)&&t.level?parseInt(n.attrs.level,10):1,i="#".repeat(r);return n.content?`${i} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Ic({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var og=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,lg=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,ag=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,cg=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,jc=kt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",G(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[_t({find:og,type:this.type}),_t({find:ag,type:this.type})]},addPasteRules(){return[Ut({find:lg,type:this.type}),Ut({find:cg,type:this.type})]}});var ug="listItem",Wc="textStyle",Kc=/^\s*([-+*])\s$/,Ns=_.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",G(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
114
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ug,this.editor.getAttributes(Wc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Ue({find:Kc,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Ue({find:Kc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Wc),editor:this.editor})),[n]}}),dg=(n,e,t)=>{let{selection:r}=n;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let s=-1;for(let h=i.depth;h>0;h-=1)if(i.node(h).type.name===e){s=h;break}if(s<0)return null;let o=i.node(s),l=i.index(s);if(l+1>=o.childCount)return null;let a=o.child(l+1);if(!t.includes(a.type.name))return null;let c=n.schema.nodes[e],u=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(u=!0)}),!u)return null;let d=n.doc.resolve(i.after()).nodeAfter;if(!d||!t.includes(d.type.name))return null;let f=[];return d.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:s,nestedList:d,nestedListPos:i.after(),insertPos:i.after(s),items:f}},fg=(n,e,t,r)=>{let i=dg(n,t,r);if(!i)return!1;let{selection:s}=n,{nestedList:o,nestedListPos:l,insertPos:a,items:c}=i,u=n.tr;u.delete(l,l+o.nodeSize);let d=u.mapping.map(a);return u.insert(d,b.from(c)),u.setSelection(s.map(u.doc,u.mapping)),e&&e(u),!0},hg=(n,e,t)=>fg(n.state,n.view.dispatch,e,t),Qc=(n,e)=>V.create({name:`${n}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let t=()=>hg(this.editor,n,e);return{Delete:t,"Mod-Delete":t}}}),eu=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],Ir="abcdefghijklmnopqrstuvwxyz",tu=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function Lr(n){let e=n,t="";for(let[r,i]of eu)for(;e>=r;)t+=i,e-=r;return t}function Os(n){return Lr(n).toUpperCase()}function nu(n){let e=n.toLowerCase(),t=0,r=0;for(;t<e.length;){let i=!1;for(let[s,o]of eu)if(e.startsWith(o,t)){r+=s,t+=o.length,i=!0;break}if(!i)return 0}return r}function pg(n){if(!/^[ivxlcdmIVXLCDM]+$/.test(n))return!1;let e=nu(n);return e<=0?!1:(n===n.toLowerCase()?Lr(e):Os(e))===n}function mg(n){let e=n.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){let t=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(t+1)*26+r+1}return 0}function Rr(n){if(n<=26)return Ir[n-1];let e=Math.floor((n-1)/26)-1,t=(n-1)%26;return e<0?Ir[t]:Ir[e]+Ir[t]}function Br(n){if(!(!n||/^\d+$/.test(n))){if(pg(n))return n===n.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(n))return"a";if(/^[A-Z]{1,2}$/.test(n))return"A"}}function Ds(n){if(/^\d+$/.test(n))return parseInt(n,10);let e=Br(n);if(e==="i"||e==="I")return nu(n);if(e==="a"||e==="A"){let r=mg(n);return r>0?r:1}let t=parseInt(n,10);return Number.isNaN(t)?1:t}function gg(n,e){if(n==="numeric")return String(e);switch(n){case"a":return Rr(e);case"A":return Rr(e).toUpperCase();case"i":return Lr(e);case"I":return Os(e);default:return String(e)}}function yg(n){var e;if(n.length===0)return!1;let t=(e=Br(n[0]))!==null&&e!==void 0?e:"numeric",r=Ds(n[0]);if(r<1)return!1;for(let i=0;i<n.length;i++){let s=gg(t,r+i);if(n[i]!==s)return!1}return!0}function bg(n){return{type:Br(n),start:Ds(n)}}function kg(n){let{type:e,start:t}=bg(n),r={};return e&&(r.type=e),t!==1&&(r.start=t),r}function Sg(n,e,t=". "){let r=e+1;if(!n||n==="1")return`${r}${t}`;switch(n){case"a":return`${Rr(r)}${t}`;case"A":return`${Rr(r).toUpperCase()}${t}`;case"i":return`${Lr(r)}${t}`;case"I":return`${Os(r)}${t}`;default:return`${r}${t}`}}function xg(n){return!n[0]||n[0].type==="paragraph"?n:[{type:"paragraph",content:[]},...n]}function wg(n){var e,t;let r=(e=n.content)===null||e===void 0?void 0:e[0];return r?.type==="paragraph"&&!(!((t=r.content)===null||t===void 0)&&t.length)}var Mg="&nbsp;",qc=1,vg=n=>{var e;return((e=n?.level)!==null&&e!==void 0?e:qc)>qc};function Cg(n){var e,t;let r=(e=n.tokens)===null||e===void 0?void 0:e[0];return!!(n.text&&((t=n.tokens)===null||t===void 0?void 0:t.length)===1&&r?.type==="list"&&r.ordered&&r.raw===n.text)}function Eg(n,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(n)):e.parseInline([{type:"text",raw:n,text:n}])}var Is=_.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",G(this.options.HTMLAttributes,n),0]},markdownTokenName:"list_item",parseMarkdown:(n,e)=>{var t;if(n.type!=="list_item")return[];let r=(t=e.parseBlockChildren)!==null&&t!==void 0?t:e.parseChildren,i=[];if(n.tokens&&n.tokens.length>0){if(Cg(n))return{type:"listItem",content:[{type:"paragraph",content:Eg(n.text||"",e)}]};let[o,...l]=n.tokens;if(o.type==="heading"){var s;return{type:"listItem",content:[{type:"paragraph",content:e.parseInline((s=o.tokens)!==null&&s!==void 0?s:[])},...l.length>0?r(l):[]]}}if(n.tokens.some(a=>a.type==="paragraph"))i=r(n.tokens);else if(o.type==="text"&&o.tokens&&o.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(o.tokens)}],n.tokens.length>1){let a=r(n.tokens.slice(1));i.push(...a)}}else i=r(n.tokens)}return i.length===0&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:xg(i)}},renderMarkdown:(n,e,t)=>{let r=o=>{if(o.parentType==="bulletList")return"- ";if(o.parentType==="orderedList"){var l,a;let c=((l=o.meta)===null||l===void 0||(l=l.parentAttrs)===null||l===void 0?void 0:l.start)||1;return Sg((a=o.meta)===null||a===void 0||(a=a.parentAttrs)===null||a===void 0?void 0:a.type,c-1+(o.index||0),". ")}return"- "},i=Cs(n,e,r,t,{alignNestedToPrefix:t?.parentType==="orderedList"});if(!wg(n)||!vg(t))return i;let s=r(t);return`${s}${Mg}${i.slice(s.length)}`},addExtensions(){return[Qc(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Rs=(n,e)=>{let{$from:t}=e.selection,r=J(n,e.schema),i=null,s=t.depth,o=t.pos,l=null;for(;s>0&&l===null;)i=t.node(s),i.type===r?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},ru=(n,e)=>{let t=Rs(n,e);if(!t)return!1;let[,r]=fc(e,n,t.$pos.pos+4);return r},Tg=(n,e,t)=>{let{$anchor:r}=n.selection,i=Math.max(0,r.pos-2),s=n.doc.resolve(i).node();return!(!s||!t.includes(s.type.name))},Jc=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Ce(n.state,e)&&Tg(n.state,e,t)){let{$anchor:s}=n.state.selection,o=n.state.doc.resolve(s.before()-1),l=[];o.node().descendants((u,d)=>{u.type.name===e&&l.push({node:u,pos:d})});let a=l.at(-1);if(!a)return!1;let c=n.state.doc.resolve(o.start()+a.pos+1);return n.chain().command(({tr:u})=>{let d=c.end();return u.delete(s.before(),s.after()).insert(d,s.parent),u.setSelection(C.create(u.doc,d+1)),!0}).command(({state:u,dispatch:d})=>(Qn(u,d),!0)).run()}if(!Ce(n.state,e)||!mc(n.state))return!1;let{$from:r}=n.state.selection,i=r.depth-1;return r.node(i).type!==n.schema.nodes[e]||r.index(i)!==0?!1:n.chain().liftListItem(e).run()},Ag=(n,e)=>{let t=ru(n,e),r=Rs(n,e);return!r||!t?!1:t>r.depth},Ng=(n,e)=>{let t=ru(n,e),r=Rs(n,e);return!r||!t?!1:t<r.depth},_c=(n,e)=>!Ce(n.state,e)||!pc(n.state,e)||!n.state.selection.empty?!1:Ag(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():Ng(e,n.state)?n.commands.command(({state:t,dispatch:r})=>er(t,r)):n.commands.joinItemForward(),Og=(n,e,t)=>{let{state:r}=n,{selection:i}=r;if(!i.empty)return!1;let{$from:s}=i;if(s.parentOffset!==0||!s.parent.isTextblock||Ce(r,e))return!1;let o=hc(s);if(!o||!t.includes(o.type.name))return!1;let l=o.lastChild;if(!l||l.type.name!==e)return!1;let a=s.parent;if(!l.canReplace(l.childCount,l.childCount,b.from(a)))return!1;let c=s.before(),u=s.after(),d=c-2;return n.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(c,u).insert(d,b.from(a)),f.setSelection(C.create(f.doc,d+1)),f.scrollIntoView()),!0))};var Dg=V.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&_c(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&_c(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Jc(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Jc(n,t,r)&&(e=!0)}),e},Tab:({editor:n})=>{for(let{itemName:e,wrapperNames:t}of this.options.listTypes)if(n.state.schema.nodes[e]!==void 0&&Og(n,e,t))return!0;return!1}}}}),Pr=new RegExp(`^(\\s*)(${tu})([.)])\\s+(.*)$`),Ig=/^\s/,Xt={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function Rg(n){return Pr.test(n.trimStart())}function Pg(n){let e=n.trimStart();return Xt.bulletItem.test(e)||Rg(e)||Xt.heading.test(e)||Xt.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||Xt.codeFence.test(e)||Xt.blockMath.test(e)}function Lg(n){return Object.values(Xt).some(e=>e.test(n))}function Bg(n){let e=[],t=[],r=!1;return n.forEach(i=>{if(r){t.push(i);return}if(i.trim()===""){r=!0,t.push(i);return}if(e.length>0&&Pg(i)){r=!0,t.push(i);return}e.push(i)}),{paragraphLines:e,blockLines:t}}function Uc(n){let e=[],t=0,r=0;for(;t<n.length;){let i=n[t],s=i.match(Pr);if(!s)break;let[,o,l,a,c]=s,u=o.length,d=parseInt(l,10),f=isNaN(d)?Br(l):void 0,h=isNaN(d)?Ds(l):d,p=[c],m=t+1,g=[i],y=!1;for(;m<n.length;){let x=n[m];if(x.match(Pr))break;if(x.trim()==="")g.push(x),p.push(""),y=!0,m+=1;else if(x.match(Ig)){let w=x.length-x.trimStart().length,v=u+l.length+1;g.push(x),p.push(x.slice(Math.min(w,v))),m+=1}else{if(y||Lg(x))break;g.push(x),p.push(x),m+=1}}e.push({indent:u,number:h,type:f,content:p.join(`
113
+ `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{let{selection:o,storedMarks:i}=t;if(o.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=i||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&s){let u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var Ad=K.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,j(this.options.HTMLAttributes,e),0]},parseMarkdown(n,e){let t=n.depth||1;return this.options.levels.includes(t)?e.createNode("heading",{level:t},e.parseInline(n.tokens||[])):e.createNode("paragraph",void 0,e.parseInline(n.tokens||[]))},renderMarkdown:(n,e)=>{var t;let r=!((t=n.attrs)===null||t===void 0)&&t.level?parseInt(n.attrs.level,10):1,o="#".repeat(r);return n.content?`${o} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>kd({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var Ey=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Ty=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Ay=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Ny=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Nd=At.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",j(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[sn({find:Ey,type:this.type}),sn({find:Ay,type:this.type})]},addPasteRules(){return[ln({find:Ty,type:this.type}),ln({find:Ny,type:this.type})]}});var Oy="listItem",Od="textStyle",Dd=/^\s*([-+*])\s$/,Yi=K.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",j(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
114
+ `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Oy,this.editor.getAttributes(Od)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=nt({find:Dd,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=nt({find:Dd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Od),editor:this.editor})),[n]}}),Dy=(n,e,t)=>{let{selection:r}=n;if(!r.empty)return null;let{$from:o}=r;if(!o.parent.isTextblock||o.parentOffset!==o.parent.content.size)return null;let i=-1;for(let h=o.depth;h>0;h-=1)if(o.node(h).type.name===e){i=h;break}if(i<0)return null;let s=o.node(i),l=o.index(i);if(l+1>=s.childCount)return null;let a=s.child(l+1);if(!t.includes(a.type.name))return null;let c=n.schema.nodes[e],d=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(d=!0)}),!d)return null;let u=n.doc.resolve(o.after()).nodeAfter;if(!u||!t.includes(u.type.name))return null;let f=[];return u.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:i,nestedList:u,nestedListPos:o.after(),insertPos:o.after(i),items:f}},Ry=(n,e,t,r)=>{let o=Dy(n,t,r);if(!o)return!1;let{selection:i}=n,{nestedList:s,nestedListPos:l,insertPos:a,items:c}=o,d=n.tr;d.delete(l,l+s.nodeSize);let u=d.mapping.map(a);return d.insert(u,b.from(c)),d.setSelection(i.map(d.doc,d.mapping)),e&&e(d),!0},Iy=(n,e,t)=>Ry(n.state,n.view.dispatch,e,t),Hd=(n,e)=>z.create({name:`${n}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let t=()=>Iy(this.editor,n,e);return{Delete:t,"Mod-Delete":t}}}),Vd=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],qr="abcdefghijklmnopqrstuvwxyz",Wd=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function Gr(n){let e=n,t="";for(let[r,o]of Vd)for(;e>=r;)t+=o,e-=r;return t}function Zi(n){return Gr(n).toUpperCase()}function jd(n){let e=n.toLowerCase(),t=0,r=0;for(;t<e.length;){let o=!1;for(let[i,s]of Vd)if(e.startsWith(s,t)){r+=i,t+=s.length,o=!0;break}if(!o)return 0}return r}function Py(n){if(!/^[ivxlcdmIVXLCDM]+$/.test(n))return!1;let e=jd(n);return e<=0?!1:(n===n.toLowerCase()?Gr(e):Zi(e))===n}function Ly(n){let e=n.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){let t=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(t+1)*26+r+1}return 0}function Jr(n){if(n<=26)return qr[n-1];let e=Math.floor((n-1)/26)-1,t=(n-1)%26;return e<0?qr[t]:qr[e]+qr[t]}function Xr(n){if(!(!n||/^\d+$/.test(n))){if(Py(n))return n===n.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(n))return"a";if(/^[A-Z]{1,2}$/.test(n))return"A"}}function Qi(n){if(/^\d+$/.test(n))return parseInt(n,10);let e=Xr(n);if(e==="i"||e==="I")return jd(n);if(e==="a"||e==="A"){let r=Ly(n);return r>0?r:1}let t=parseInt(n,10);return Number.isNaN(t)?1:t}function By(n,e){if(n==="numeric")return String(e);switch(n){case"a":return Jr(e);case"A":return Jr(e).toUpperCase();case"i":return Gr(e);case"I":return Zi(e);default:return String(e)}}function zy(n){var e;if(n.length===0)return!1;let t=(e=Xr(n[0]))!==null&&e!==void 0?e:"numeric",r=Qi(n[0]);if(r<1)return!1;for(let o=0;o<n.length;o++){let i=By(t,r+o);if(n[o]!==i)return!1}return!0}function $y(n){return{type:Xr(n),start:Qi(n)}}function Fy(n){let{type:e,start:t}=$y(n),r={};return e&&(r.type=e),t!==1&&(r.start=t),r}function Hy(n,e,t=". "){let r=e+1;if(!n||n==="1")return`${r}${t}`;switch(n){case"a":return`${Jr(r)}${t}`;case"A":return`${Jr(r).toUpperCase()}${t}`;case"i":return`${Gr(r)}${t}`;case"I":return`${Zi(r)}${t}`;default:return`${r}${t}`}}function Vy(n){return!n[0]||n[0].type==="paragraph"?n:[{type:"paragraph",content:[]},...n]}function Wy(n){var e,t;let r=(e=n.content)===null||e===void 0?void 0:e[0];return r?.type==="paragraph"&&!(!((t=r.content)===null||t===void 0)&&t.length)}var jy="&nbsp;",Rd=1,Ky=n=>{var e;return((e=n?.level)!==null&&e!==void 0?e:Rd)>Rd};function _y(n){var e,t;let r=(e=n.tokens)===null||e===void 0?void 0:e[0];return!!(n.text&&((t=n.tokens)===null||t===void 0?void 0:t.length)===1&&r?.type==="list"&&r.ordered&&r.raw===n.text)}function qy(n,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(n)):e.parseInline([{type:"text",raw:n,text:n}])}var es=K.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",j(this.options.HTMLAttributes,n),0]},markdownTokenName:"list_item",parseMarkdown:(n,e)=>{var t;if(n.type!=="list_item")return[];let r=(t=e.parseBlockChildren)!==null&&t!==void 0?t:e.parseChildren,o=[];if(n.tokens&&n.tokens.length>0){if(_y(n))return{type:"listItem",content:[{type:"paragraph",content:qy(n.text||"",e)}]};let[s,...l]=n.tokens;if(s.type==="heading"){var i;return{type:"listItem",content:[{type:"paragraph",content:e.parseInline((i=s.tokens)!==null&&i!==void 0?i:[])},...l.length>0?r(l):[]]}}if(n.tokens.some(a=>a.type==="paragraph"))o=r(n.tokens);else if(s.type==="text"&&s.tokens&&s.tokens.length>0){if(o=[{type:"paragraph",content:e.parseInline(s.tokens)}],n.tokens.length>1){let a=r(n.tokens.slice(1));o.push(...a)}}else o=r(n.tokens)}return o.length===0&&(o=[{type:"paragraph",content:[]}]),{type:"listItem",content:Vy(o)}},renderMarkdown:(n,e,t)=>{let r=s=>{if(s.parentType==="bulletList")return"- ";if(s.parentType==="orderedList"){var l,a;let c=((l=s.meta)===null||l===void 0||(l=l.parentAttrs)===null||l===void 0?void 0:l.start)||1;return Hy((a=s.meta)===null||a===void 0||(a=a.parentAttrs)===null||a===void 0?void 0:a.type,c-1+(s.index||0),". ")}return"- "},o=qi(n,e,r,t,{alignNestedToPrefix:t?.parentType==="orderedList"});if(!Wy(n)||!Ky(t))return o;let i=r(t);return`${i}${jy}${o.slice(i.length)}`},addExtensions(){return[Hd(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ts=(n,e)=>{let{$from:t}=e.selection,r=X(n,e.schema),o=null,i=t.depth,s=t.pos,l=null;for(;i>0&&l===null;)o=t.node(i),o.type===r?l=i:(i-=1,s-=1);return l===null?null:{$pos:e.doc.resolve(s),depth:l}},Kd=(n,e)=>{let t=ts(n,e);if(!t)return!1;let[,r]=Qc(e,n,t.$pos.pos+4);return r},Jy=(n,e,t)=>{let{$anchor:r}=n.selection,o=Math.max(0,r.pos-2),i=n.doc.resolve(o).node();return!(!i||!t.includes(i.type.name))},Id=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Oe(n.state,e)&&Jy(n.state,e,t)){let{$anchor:i}=n.state.selection,s=n.state.doc.resolve(i.before()-1),l=[];s.node().descendants((d,u)=>{d.type.name===e&&l.push({node:d,pos:u})});let a=l.at(-1);if(!a)return!1;let c=n.state.doc.resolve(s.start()+a.pos+1);return n.chain().command(({tr:d})=>{let u=c.end();return d.delete(i.before(),i.after()).insert(u,i.parent),d.setSelection(C.create(d.doc,u+1)),!0}).command(({state:d,dispatch:u})=>(hr(d,u),!0)).run()}if(!Oe(n.state,e)||!nd(n.state))return!1;let{$from:r}=n.state.selection,o=r.depth-1;return r.node(o).type!==n.schema.nodes[e]||r.index(o)!==0?!1:n.chain().liftListItem(e).run()},Uy=(n,e)=>{let t=Kd(n,e),r=ts(n,e);return!r||!t?!1:t>r.depth},Gy=(n,e)=>{let t=Kd(n,e),r=ts(n,e);return!r||!t?!1:t<r.depth},Pd=(n,e)=>!Oe(n.state,e)||!td(n.state,e)||!n.state.selection.empty?!1:Uy(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():Gy(e,n.state)?n.commands.command(({state:t,dispatch:r})=>pr(t,r)):n.commands.joinItemForward(),Xy=(n,e,t)=>{let{state:r}=n,{selection:o}=r;if(!o.empty)return!1;let{$from:i}=o;if(i.parentOffset!==0||!i.parent.isTextblock||Oe(r,e))return!1;let s=ed(i);if(!s||!t.includes(s.type.name))return!1;let l=s.lastChild;if(!l||l.type.name!==e)return!1;let a=i.parent;if(!l.canReplace(l.childCount,l.childCount,b.from(a)))return!1;let c=i.before(),d=i.after(),u=c-2;return n.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(c,d).insert(u,b.from(a)),f.setSelection(C.create(f.doc,u+1)),f.scrollIntoView()),!0))};var Yy=z.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Pd(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Pd(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Id(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Id(n,t,r)&&(e=!0)}),e},Tab:({editor:n})=>{for(let{itemName:e,wrapperNames:t}of this.options.listTypes)if(n.state.schema.nodes[e]!==void 0&&Xy(n,e,t))return!0;return!1}}}}),Ur=new RegExp(`^(\\s*)(${Wd})([.)])\\s+(.*)$`),Zy=/^\s/,cn={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function Qy(n){return Ur.test(n.trimStart())}function e0(n){let e=n.trimStart();return cn.bulletItem.test(e)||Qy(e)||cn.heading.test(e)||cn.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||cn.codeFence.test(e)||cn.blockMath.test(e)}function t0(n){return Object.values(cn).some(e=>e.test(n))}function n0(n){let e=[],t=[],r=!1;return n.forEach(o=>{if(r){t.push(o);return}if(o.trim()===""){r=!0,t.push(o);return}if(e.length>0&&e0(o)){r=!0,t.push(o);return}e.push(o)}),{paragraphLines:e,blockLines:t}}function Ld(n){let e=[],t=0,r=0;for(;t<n.length;){let o=n[t],i=o.match(Ur);if(!i)break;let[,s,l,a,c]=i,d=s.length,u=parseInt(l,10),f=isNaN(u)?Xr(l):void 0,h=isNaN(u)?Qi(l):u,p=[c],m=t+1,g=[o],y=!1;for(;m<n.length;){let k=n[m];if(k.match(Ur))break;if(k.trim()==="")g.push(k),p.push(""),y=!0,m+=1;else if(k.match(Zy)){let S=k.length-k.trimStart().length,v=d+l.length+1;g.push(k),p.push(k.slice(Math.min(S,v))),m+=1}else{if(y||t0(k))break;g.push(k),p.push(k),m+=1}}e.push({indent:d,number:h,type:f,content:p.join(`
115
115
  `).trim(),contentLines:p,raw:g.join(`
116
- `)}),r=m,t=m}return[e,r]}var zg=new RegExp(`^(${tu})([.)])\\s+(.+)$`);function $g(n){let e=n.split(`
117
- `).filter(r=>r.trim().length>0);if(e.length===0)return null;let t=[];for(let r of e){let i=r.trim().match(zg);if(!i)return null;t.push({marker:i[1],content:i[3]})}return yg(t.map(r=>r.marker))?{type:"orderedList",attrs:kg(t[0].marker),content:t.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function iu(n,e,t){let r=[],i=0;for(;i<n.length;){let s=n[i];if(s.indent===e){let{paragraphLines:o,blockLines:l}=Bg(s.contentLines),a=o.join(`
118
- `).trim(),c=[];a&&c.push({type:"paragraph",raw:a,tokens:t.inlineTokens(a)});let u=l.join(`
119
- `).trim();if(u){let h=t.blockTokens(u);c.push(...h)}let d=i+1,f=[];for(;d<n.length&&n[d].indent>e;)f.push(n[d]),d+=1;if(f.length>0){let h=iu(f,Math.min(...f.map(p=>p.indent)),t);c.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:h,raw:f.map(p=>p.raw).join(`
120
- `)})}r.push({type:"list_item",raw:s.raw,tokens:c}),i=d}else i+=1}return r}function Fg(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];let r=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){let s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{let s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var Vg=64;function Gc(n,e){let t=[],r=0;for(;t.length<e;){let i=n.indexOf(`
121
- `,r);if(i===-1)return t.push(n.slice(r)),t;t.push(n.slice(r,i)),r=i+1}return t}function Hg(n){let e=n.indexOf(`
122
- `),t=e===-1?n:n.slice(0,e);if(!Pr.test(t))return[[],0,[]];let r=Vg,i=Gc(n,r),s=Uc(i);for(;s[1]===i.length&&i.length===r;)r*=2,i=Gc(n,r),s=Uc(i);return[s[0],s[1],i]}var jg="listItem",Xc="textStyle",Yc=/^(\d+)\.\s$/;function Zc(n){let e=n.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}var Ps=_.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>{let e=n.getAttribute("type");if(e)return e;let t=n.getAttribute("style");if(t){let i=Zc(t);if(i)return i}let r=n.querySelector("li");if(r){let i=r.getAttribute("style");if(i){let s=Zc(i);if(s)return s}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){let{start:e,type:t,...r}=n,i=G(this.options.HTMLAttributes,r);return e!==1&&(i.start=e),t&&t!=="1"&&(i.type=t),["ol",i,0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];let t=n.start||1,r=n.typeMarker,i=n.items?Fg(n.items,e):[],s={};return t!==1&&(s.start=t),r&&(s.type=r),Object.keys(s).length>0?{type:"orderedList",attrs:s,content:i}:{type:"orderedList",content:i}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
123
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(n,e,t)=>{var r,i;let[s,o,l]=Hg(n);if(s.length===0)return;let a=iu(s,s[0].indent,t);if(a.length!==0)return{type:"list",ordered:!0,start:((r=s[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(i=s[0])===null||i===void 0?void 0:i.type,items:a,raw:l.slice(0,o).join(`
124
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(jg,this.editor.getAttributes(Xc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new P({props:{handlePaste:(n,e)=>{var t,r;let i=(t=e.clipboardData)===null||t===void 0?void 0:t.getData("text/html");if(i?.trim())return!1;let s=(r=e.clipboardData)===null||r===void 0?void 0:r.getData("text/plain");if(!s)return!1;let o=$g(s);if(!o)return!1;try{let l=n.state.schema.nodeFromJSON(o),a=n.state.tr.replaceSelectionWith(l);return n.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){let n=(t,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+t[1],e=Ue({find:Yc,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:n});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Ue({find:Yc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(Xc)}),joinPredicate:n,editor:this.editor})),[e]}}),Wg=/^\s*(\[([( |x])?\])\s$/,Kg="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",qg=(n,e,t)=>{var r;return(t==null||(r=t.checkboxLabel)===null||r===void 0?void 0:r.call(t,n,e))||`Task item checkbox for ${n.textContent||"empty task item"}`},Jg=_.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{let e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:n=>{var e;return(e=n.querySelector("div"))!==null&&e!==void 0?e:n}}]},renderHTML({node:n,HTMLAttributes:e}){return["li",G(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{let t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){let r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;let r=`- [${!((t=n.attrs)===null||t===void 0)&&t.checked?"x":" "}] `;return Cs(n,e,r,void 0,{indentMainContent:!0})},addExtensions(){return this.options.nested?[Qc(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{let i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");o.style.cssText=Kg;let c=d=>{let f=qg(d,d.attrs.checked,this.options.a11y);l.setAttribute("aria-label",f),o.textContent=f};c(n),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:f}=d.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{let p=t();if(typeof p!="number")return!1;let m=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...m?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,s.append(l,o),i.append(s,a),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:i,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;i.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);let f=r.extensionManager.attributes,h=qt(d,f),p=new Set(Object.keys(h)),m=this.options.HTMLAttributes;return u.forEach(g=>{p.has(g)||(g in m?i.setAttribute(g,m[g]):i.removeAttribute(g))}),Object.entries(h).forEach(([g,y])=>{y==null?g in m?i.setAttribute(g,m[g]):i.removeAttribute(g):i.setAttribute(g,y)}),u=p,!0}}}},addInputRules(){return[Ue({find:Wg,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),_g=_.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",G(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
125
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;let t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){let r=s=>{let o=vs(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);if(o){let l={type:"taskList",raw:o.raw,items:o.items},a=s.slice(o.raw.length);return a.trim()?[l,...t.blockTokens(a)]:[l]}return t.blockTokens(s)},i=vs(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:t.inlineTokens(s.mainContent),nestedTokens:o}),customNestedParser:r},t);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),ob=V.create({name:"listKit",addExtensions(){let n=[];return this.options.bulletList!==!1&&n.push(Ns.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(Is.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(Dg.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(Ps.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(Jg.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(_g.configure(this.options.taskList)),n}});var zr="&nbsp;",Ls="\xA0",su=_.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",G(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{let t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);let r=e.parseInline(t);return t.length===1&&t[0].type==="text"&&(t[0].raw===zr||t[0].text===zr||t[0].raw===Ls||t[0].text===Ls)&&r.length===1&&r[0].type==="text"&&(r[0].text===zr||r[0].text===Ls)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{if(!n)return"";let r=Array.isArray(n.content)?n.content:[];if(r.length===0){var i,s;let o=Array.isArray(t==null||(i=t.previousNode)===null||i===void 0?void 0:i.content)?t.previousNode.content:[];return(t==null||(s=t.previousNode)===null||s===void 0?void 0:s.type)==="paragraph"&&o.length===0?zr:""}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var ou=_.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""});function lu(n={}){return new P({view(e){return new Bs(e,n)}})}var Bs=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=d?p.bottom:p.top;d&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(!t||s)return null;let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Gn(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}return o}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var se=class n extends N{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):N.near(r)}content(){return k.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new zs(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Ug(e)||!Gg(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(n.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!T.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;let l=e.doc.resolve(i);if(n.valid(l))return l}return null}}};se.prototype.visible=!1;se.findFrom=se.findGapCursorFrom;N.jsonID("gapcursor",se);var zs=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return se.valid(t)?new se(t):N.near(t)}};function au(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function Ug(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||au(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Gg(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||au(i.type))return!0;if(i.inlineContent)return!1}}return!0}function cu(){return new P({props:{decorations:Qg,createSelectionBetween(n,e,t){return e.pos==t.pos&&se.valid(t)?new se(t):null},handleClick:Yg,handleKeyDown:Xg,handleDOMEvents:{beforeinput:Zg}}})}var Xg=ls({ArrowLeft:$r("horiz",-1),ArrowRight:$r("horiz",1),ArrowUp:$r("vert",-1),ArrowDown:$r("vert",1)});function $r(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof C){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=se.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new se(c))),!0):!1}}function Yg(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!se.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&T.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new se(r))),!0)}function Zg(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof se))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=b.empty;for(let o=r.length-1;o>=0;o--)i=b.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new k(i,0,0));return s.setSelection(C.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function Qg(n){if(!(n.selection instanceof se))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",B.create(n.doc,[ce.widget(n.selection.head,e,{key:"gapcursor"})])}var Ob=V.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{let e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){let t=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(t)}return e.nodeSize},this.storage.words=n=>{let e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new P({key:new W("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;let i=this.options.limit,s=this.options.autoTrim;if(i==null||i===0||s===!1){n=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let l=o-i,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let u=r.tr.deleteRange(a,c);return n=!0,u}n=!0},filterTransaction:(e,t)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let i=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;let o=e.selection.$head.pos,l=o-(s-r),a=o;return e.deleteRange(l,a),!(this.storage.characters({node:e.doc})>r)}})]}}),Db=V.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[lu(this.options)]}}),Ib=V.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new P({key:new W("focus"),props:{decorations:({doc:n,selection:e})=>{let{isEditable:t,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!t||!r)return B.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(!a.isText){if(!(i>=c&&i<=c+a.nodeSize-1))return!1;o+=1}});let l=0;return n.descendants((a,c)=>{if(a.isText||!(i>=c&&i<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(ce.node(c,c+a.nodeSize,{class:this.options.className}))}),B.create(n,s)}}})]}}),Rb=V.create({name:"gapCursor",addProseMirrorPlugins(){return[cu()]},extendNodeSchema(n){var e;let t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=L(M(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),fu="placeholder",uu=new W("tiptap__placeholder");function hu(n){let{editor:e,placeholder:t,dataAttribute:r,pos:i,node:s,isEmptyDoc:o,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=n,u=[a];return o&&u.push(c),ce.node(i,i+s.nodeSize,{class:u.join(" "),[r]:typeof t=="function"?t({editor:e,node:s,pos:i,hasAnchor:l}):t})}function pu(n,e){return typeof n=="function"?n(e):n}function mu({editor:n,options:e,dataAttribute:t,doc:r,selection:i,from:s,to:o}){let{anchor:l}=i,a=[],c=n.isEmpty;return r.nodesBetween(s,o,(u,d)=>{let f=l>=d&&l<=d+u.nodeSize,h=!u.isLeaf&&Jt(u);return u.type.isTextblock&&(f||!e.showOnlyCurrent)&&h&&a.push(hu({editor:n,isEmptyDoc:c,dataAttribute:t,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:pu(e.emptyNodeClass,{editor:n,node:u,pos:d,hasAnchor:f})},node:u,pos:d})),e.includeChildren}),a}function gu({editor:n,options:e,dataAttribute:t,doc:r,selection:i}){if(!(n.isEditable||!e.showOnlyWhenEditable))return null;let{anchor:s}=i,o=[],l=n.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){let a=r.resolve(s),c=a.depth>0?a.node(1):a.nodeAfter,u=a.depth>0?a.before(1):s;if(c&&c.type.isTextblock&&Jt(c)){let d=s>=u&&s<=u+c.nodeSize;o.push(hu({editor:n,isEmptyDoc:l,dataAttribute:t,hasAnchor:d,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:pu(e.emptyNodeClass,{editor:n,node:c,pos:u,hasAnchor:d})},node:c,pos:u}))}}else o.push(...mu({editor:n,options:e,dataAttribute:t,doc:r,selection:i,from:0,to:r.content.size}));return B.create(r,o)}function On(n,e){let t=n.resolve(e);if(t.depth===0){var r;let s=(r=t.nodeAfter)!==null&&r!==void 0?r:t.nodeBefore;if(!s)return{from:e,to:e};let o=t.nodeAfter?e:e-s.nodeSize;return{from:o,to:o+s.nodeSize}}let i=t.before(1);return{from:i,to:i+t.node(1).nodeSize}}function Dn(n,e){return{from:Math.max(0,e.from-1),to:Math.min(n.content.size,e.to-1)}}function ey(n,e,t){let r=[];return n.forEach((i,s)=>{let o=s,l=o+i.nodeSize,a=o+1,c=l+1;a<t&&c>e&&r.push({from:o,to:l})}),r}function ty(n){if(n.length===0)return[];let e=[...n].sort((r,i)=>r.from-i.from),t=[{...e[0]}];for(let r=1;r<e.length;r+=1){let i=t[t.length-1],s=e[r];s.from<=i.to?i.to=Math.max(i.to,s.to):t.push({...s})}return t}function ny(n,e){let t=ey(n,e.from,e.to);return t.push(Dn(n,On(n,e.from))),e.to>e.from?t.push(Dn(n,On(n,Math.min(e.to,n.content.size+1)-1))):e.from<n.content.size+1&&t.push(Dn(n,On(n,Math.min(e.from+1,n.content.size)))),t}function ry(n,e,t){let r=[];if(n.docChanged){let i=Or(n);for(let s of i)r.push(...ny(t.doc,s.newRange))}return n.selectionSet&&(r.push(Dn(t.doc,On(t.doc,n.mapping.map(e.selection.anchor)))),r.push(Dn(t.doc,On(t.doc,t.selection.anchor)))),ty(r)}function iy(n,e,t){let r=Math.max(0,Math.min(n,t.content.size));return{from:r,to:Math.max(r,Math.min(e,t.content.size))}}function sy({decorations:n,ranges:e,editor:t,options:r,dataAttribute:i,doc:s,selection:o}){let l=n;for(let a of e){let{from:c,to:u}=iy(a.from,a.to,s),d=l.find(c,u).filter(h=>h.from>=c&&h.to<=u);d.length&&(l=l.remove(d));let f=mu({editor:t,options:r,dataAttribute:i,doc:s,selection:o,from:c,to:u});f.length&&(l=l.add(s,f))}return l}function oy({editor:n,options:e,dataAttribute:t}){return{init(r,i){let s=gu({editor:n,options:e,dataAttribute:t,doc:i.doc,selection:i.selection});return s??B.empty},apply(r,i,s,o){return!r.docChanged&&!r.selectionSet?i:sy({decorations:i.map(r.mapping,r.doc),ranges:ry(r,s,o),editor:n,options:e,dataAttribute:t,doc:o.doc,selection:o.selection})}}}function ly(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function ay({editor:n,options:e}){let t=e.dataAttribute?`data-${ly(e.dataAttribute)}`:`data-${fu}`,r=e.showOnlyCurrent&&!e.includeChildren;return new P({key:uu,...r?{}:{state:oy({editor:n,options:e,dataAttribute:t})},props:{decorations:r?({doc:i,selection:s})=>gu({editor:n,options:e,dataAttribute:t,doc:i,selection:s}):i=>{var s;return e.showOnlyWhenEditable&&!n.isEditable?B.empty:(s=uu.getState(i))!==null&&s!==void 0?s:B.empty}}})}var Pb=V.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:fu,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[ay({editor:this.editor,options:this.options})]}});function $s(n,e){return!n.selection.empty&&!gc(n.selection)&&e.isEditable}function cy(n,e){return $s(n,e)&&!e.isFocused&&!e.view.dragging}function uy(){var n;(n=window.getSelection())===null||n===void 0||n.removeAllRanges()}function dy(n){n.focus()}var Lb=V.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:n,options:e}=this;return[new P({key:new W("selection"),props:{decorations(t){return cy(t,n)?B.create(t.doc,[ce.inline(t.selection.from,t.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(t){return $s(t.state,n)&&uy(),!1},focus(t){return $s(t.state,n)&&requestAnimationFrame(()=>{!n.isDestroyed&&t.hasFocus()&&dy(t)}),!1}}}})]}});function du({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var Bb=V.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;let e=new W(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)===null||n===void 0?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(t).includes(i.name));return[new P({key:e,appendTransaction:(i,s,o)=>{let{doc:l,tr:a,schema:c}=o,u=e.getState(o),d=l.content.size,f=c.nodes[t];if(!i.some(h=>h.getMeta("skipTrailingNode"))&&u)return a.insert(d,f.create())},state:{init:(i,s)=>{let o=s.tr.doc.lastChild;return!du({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;let o=i.doc.lastChild;return!du({node:o,types:r})}}})]}}),yu=V.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>ds(n,e),redo:()=>({state:n,dispatch:e})=>fs(n,e)}},addProseMirrorPlugins(){return[Ta(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var xu=["heading","bold","italic","link","bulletList","orderedList","blockquote","image","hardBreak"],Fs=/^[0-9a-f]{64}$/,Vs=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,bu="url:";function Fr(n){if(/[\u0000-\u001f\u007f]/.test(n))return!1;if(n.startsWith("/"))return!n.startsWith("//")&&!n.startsWith("/\\");try{return["http:","https:","mailto:","tel:"].includes(new URL(n).protocol)}catch{return!1}}var fy=_.create({name:"image",inline:!0,group:"inline",atom:!0,draggable:!0,addAttributes(){return{media:{default:null,parseHTML:n=>n.getAttribute("data-media"),renderHTML:()=>({})},alt:{default:null,parseHTML:n=>n.getAttribute("alt")||null,renderHTML:()=>({})}}},parseHTML(){return[{tag:"img[data-media]",getAttrs:n=>Fs.test(n.getAttribute("data-media")??"")?null:!1}]},renderHTML({node:n}){let e=typeof n.attrs.media=="string"&&Fs.test(n.attrs.media)?n.attrs.media:null;return["img",{src:e===null?null:`/media/${e}/640.webp`,alt:typeof n.attrs.alt=="string"?n.attrs.alt:"","data-media":e}]}}),hy=kt.create({name:"link",inclusive:!1,addAttributes(){return{href:{default:null,parseHTML:n=>{let e=n.getAttribute("href");return n.hasAttribute("data-document")||e===null||!Fr(e)?null:e},renderHTML:()=>({})},document:{default:null,parseHTML:n=>{let e=n.getAttribute("data-document");return e!==null&&Vs.test(e)?e:null},renderHTML:()=>({})}}},parseHTML(){return[{tag:"a[data-document]",getAttrs:n=>Vs.test(n.getAttribute("data-document")??"")?null:!1},{tag:"a[href]",getAttrs:n=>Fr(n.getAttribute("href")??"")?null:!1}]},renderHTML({mark:n}){let{href:e,document:t}=n.attrs;return typeof t=="string"?["a",{"data-document":t},0]:["a",{href:typeof e=="string"&&Fr(e)?e:null,rel:"noopener noreferrer nofollow"},0]}}),py=Hc.extend({content:"text*"}),my=Ps.extend({addAttributes(){let{start:n}=this.parent?.()??{};return n===void 0?{}:{start:n}}});function gy(n,e){let t=[Fc,su,ou,yu];return n.has("heading")&&e.length>0&&t.push(py.configure({levels:e})),n.has("bold")&&t.push($c),n.has("italic")&&t.push(jc),n.has("link")&&t.push(hy),n.has("bulletList")&&t.push(Ns),n.has("orderedList")&&t.push(my),(n.has("bulletList")||n.has("orderedList"))&&t.push(Is),n.has("blockquote")&&t.push(zc),n.has("hardBreak")&&t.push(Vc),n.has("image")&&t.push(fy),t}function yy(n,e){if(n==="")return null;let t;try{t=JSON.parse(n)}catch{return}if(typeof t!="object"||t===null)return;let r=t.content;if(t.type==="doc"&&(r===void 0||Array.isArray(r)&&r.length===0))return null;try{return ac(e).nodeFromJSON(t).check(),t}catch{return}}function by(n){try{let e=JSON.parse(n??"{}");return typeof e!="object"||e===null?{}:Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]=="string"))}catch{return{}}}function ku(n,e){n!==void 0&&window.InlayAdmin?.openPicker(n,e)}function ky(n,e){let t;if(e.value.startsWith(bu)){let i=e.value.slice(bu.length);if(!Fr(i))return;t={href:i,document:null}}else{if(!Vs.test(e.value))return;t={href:null,document:e.value}}let r=n.chain().focus();n.state.selection.empty?r.insertContent({type:"text",text:e.label,marks:[{type:"link",attrs:t}]}).run():r.setMark("link",t).run()}function Sy(n,e,t,r){let i=[];for(let s of xu)if(t.has(s))switch(s){case"heading":for(let o of r)i.push({command:`heading${o}`,run:()=>n.chain().focus().toggleHeading({level:o}).run(),active:()=>n.isActive("heading",{level:o})});break;case"bold":i.push({command:"bold",run:()=>n.chain().focus().toggleBold().run(),active:()=>n.isActive("bold")});break;case"italic":i.push({command:"italic",run:()=>n.chain().focus().toggleItalic().run(),active:()=>n.isActive("italic")});break;case"link":i.push({command:"link",run(){if(n.isActive("link")){n.chain().focus().extendMarkRange("link").unsetMark("link").run();return}ku(e.dataset.pickLink,o=>ky(n,o))},active:()=>n.isActive("link")});break;case"bulletList":i.push({command:"bulletList",run:()=>n.chain().focus().toggleBulletList().run(),active:()=>n.isActive("bulletList")});break;case"orderedList":i.push({command:"orderedList",run:()=>n.chain().focus().toggleOrderedList().run(),active:()=>n.isActive("orderedList")});break;case"blockquote":i.push({command:"blockquote",run:()=>n.chain().focus().toggleBlockquote().run(),active:()=>n.isActive("blockquote")});break;case"image":i.push({command:"image",run:()=>ku(e.dataset.pickImage,o=>{Fs.test(o.value)&&n.chain().focus().insertContent({type:"image",attrs:{media:o.value,alt:null}}).run()})});break;case"hardBreak":i.push({command:"hardBreak",run:()=>n.chain().focus().setHardBreak().run()});break}return i}function xy(n,e,t){let r=e.map((s,o)=>{let l=document.createElement("button");return l.type="button",l.className="btn btn-ghost btn-sm aria-pressed:btn-active",l.dataset.command=s.command,l.textContent=t[s.command]??s.command,l.tabIndex=o===0?0:-1,s.active&&l.setAttribute("aria-pressed","false"),l.addEventListener("click",()=>s.run()),l});n.replaceChildren(...r);let i=s=>{let o=r.length,l=r[(s%o+o)%o];if(l){for(let a of r)a.tabIndex=a===l?0:-1;l.focus()}};return n.addEventListener("keydown",s=>{let o=r.indexOf(s.target);if(o<0)return;let l={ArrowRight:o+1,ArrowDown:o+1,ArrowLeft:o-1,ArrowUp:o-1,Home:0,End:r.length-1}[s.key];l!==void 0&&(s.preventDefault(),i(l))}),()=>{e.forEach((s,o)=>{s.active&&r[o]?.setAttribute("aria-pressed",String(s.active()))})}}var Su=new WeakMap;function wy(n){let e=Su.get(n);if(e)return e;let t=new Set((n.dataset.features??"").split(" ").filter(p=>xu.includes(p))),r=(n.dataset.headings??"").split(" ").map(Number).filter(p=>Number.isInteger(p)&&p>=1&&p<=6),i=by(n.dataset.labels),s=n.querySelector("[data-richtext-mount]")??n,o=n.querySelector(':scope > input[type="hidden"]'),l=n.querySelector('[role="toolbar"]'),a=gy(t,r),c=yy(o?.value??"",a),u=c!==void 0,d=u&&!n.hasAttribute("data-readonly");if(!u){let p=n.querySelector("[data-richtext-error]");p&&(p.hidden=!1)}let f={role:"textbox","aria-multiline":"true"};for(let p of["aria-label","aria-describedby","aria-invalid"]){let m=s.getAttribute(p);m!==null&&(f[p]=m)}d||(f["aria-readonly"]="true");let h=new Dc({element:s,extensions:a,content:c,editable:d,editorProps:{attributes:f},onUpdate:({editor:p})=>{!o||!u||(o.value=JSON.stringify(p.getJSON()),o.dispatchEvent(new Event("change",{bubbles:!0})))}});if(Su.set(n,h),l&&d){let p=xy(l,Sy(h,n,t,r),i);h.on("transaction",p),p()}return h}function Hs(n){for(let e of n.querySelectorAll("[data-richtext]"))wy(e)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>Hs(document)):Hs(document);document.addEventListener("htmx:afterSwap",()=>Hs(document));export{wy as mountRichText};
116
+ `)}),r=m,t=m}return[e,r]}var r0=new RegExp(`^(${Wd})([.)])\\s+(.+)$`);function o0(n){let e=n.split(`
117
+ `).filter(r=>r.trim().length>0);if(e.length===0)return null;let t=[];for(let r of e){let o=r.trim().match(r0);if(!o)return null;t.push({marker:o[1],content:o[3]})}return zy(t.map(r=>r.marker))?{type:"orderedList",attrs:Fy(t[0].marker),content:t.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function _d(n,e,t){let r=[],o=0;for(;o<n.length;){let i=n[o];if(i.indent===e){let{paragraphLines:s,blockLines:l}=n0(i.contentLines),a=s.join(`
118
+ `).trim(),c=[];a&&c.push({type:"paragraph",raw:a,tokens:t.inlineTokens(a)});let d=l.join(`
119
+ `).trim();if(d){let h=t.blockTokens(d);c.push(...h)}let u=o+1,f=[];for(;u<n.length&&n[u].indent>e;)f.push(n[u]),u+=1;if(f.length>0){let h=_d(f,Math.min(...f.map(p=>p.indent)),t);c.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:h,raw:f.map(p=>p.raw).join(`
120
+ `)})}r.push({type:"list_item",raw:i.raw,tokens:c}),o=u}else o+=1}return r}function i0(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];let r=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(o=>{if(o.type==="paragraph"||o.type==="list"||o.type==="blockquote"||o.type==="code")r.push(...e.parseChildren([o]));else if(o.type==="text"&&o.tokens){let i=e.parseChildren([o]);r.push({type:"paragraph",content:i})}else{let i=e.parseChildren([o]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var s0=64;function Bd(n,e){let t=[],r=0;for(;t.length<e;){let o=n.indexOf(`
121
+ `,r);if(o===-1)return t.push(n.slice(r)),t;t.push(n.slice(r,o)),r=o+1}return t}function l0(n){let e=n.indexOf(`
122
+ `),t=e===-1?n:n.slice(0,e);if(!Ur.test(t))return[[],0,[]];let r=s0,o=Bd(n,r),i=Ld(o);for(;i[1]===o.length&&o.length===r;)r*=2,o=Bd(n,r),i=Ld(o);return[i[0],i[1],o]}var a0="listItem",zd="textStyle",$d=/^(\d+)\.\s$/;function Fd(n){let e=n.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}var ns=K.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>{let e=n.getAttribute("type");if(e)return e;let t=n.getAttribute("style");if(t){let o=Fd(t);if(o)return o}let r=n.querySelector("li");if(r){let o=r.getAttribute("style");if(o){let i=Fd(o);if(i)return i}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){let{start:e,type:t,...r}=n,o=j(this.options.HTMLAttributes,r);return e!==1&&(o.start=e),t&&t!=="1"&&(o.type=t),["ol",o,0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];let t=n.start||1,r=n.typeMarker,o=n.items?i0(n.items,e):[],i={};return t!==1&&(i.start=t),r&&(i.type=r),Object.keys(i).length>0?{type:"orderedList",attrs:i,content:o}:{type:"orderedList",content:o}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
123
+ `):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(n,e,t)=>{var r,o;let[i,s,l]=l0(n);if(i.length===0)return;let a=_d(i,i[0].indent,t);if(a.length!==0)return{type:"list",ordered:!0,start:((r=i[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(o=i[0])===null||o===void 0?void 0:o.type,items:a,raw:l.slice(0,s).join(`
124
+ `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(a0,this.editor.getAttributes(zd)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new I({props:{handlePaste:(n,e)=>{var t,r;let o=(t=e.clipboardData)===null||t===void 0?void 0:t.getData("text/html");if(o?.trim())return!1;let i=(r=e.clipboardData)===null||r===void 0?void 0:r.getData("text/plain");if(!i)return!1;let s=o0(i);if(!s)return!1;try{let l=n.state.schema.nodeFromJSON(s),a=n.state.tr.replaceSelectionWith(l);return n.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){let n=(t,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+t[1],e=nt({find:$d,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:n});return(this.options.keepMarks||this.options.keepAttributes)&&(e=nt({find:$d,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(zd)}),joinPredicate:n,editor:this.editor})),[e]}}),c0=/^\s*(\[([( |x])?\])\s$/,d0="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",u0=(n,e,t)=>{var r;return(t==null||(r=t.checkboxLabel)===null||r===void 0?void 0:r.call(t,n,e))||`Task item checkbox for ${n.textContent||"empty task item"}`},f0=K.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{let e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:n=>{var e;return(e=n.querySelector("div"))!==null&&e!==void 0?e:n}}]},renderHTML({node:n,HTMLAttributes:e}){return["li",j(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{let t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){let r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;let r=`- [${!((t=n.attrs)===null||t===void 0)&&t.checked?"x":" "}] `;return qi(n,e,r,void 0,{indentMainContent:!0})},addExtensions(){return this.options.nested?[Hd(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{let o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");s.style.cssText=d0;let c=u=>{let f=u0(u,u.attrs.checked,this.options.a11y);l.setAttribute("aria-label",f),s.textContent=f};c(n),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:f}=u.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{let p=t();if(typeof p!="number")return!1;let m=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...m?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,f])=>{o.setAttribute(u,f)}),o.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,i.append(l,s),o.append(i,a),Object.entries(e).forEach(([u,f])=>{o.setAttribute(u,f)});let d=new Set(Object.keys(e));return{dom:o,contentDOM:a,update:u=>{if(u.type!==this.type)return!1;o.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u);let f=r.extensionManager.attributes,h=nn(u,f),p=new Set(Object.keys(h)),m=this.options.HTMLAttributes;return d.forEach(g=>{p.has(g)||(g in m?o.setAttribute(g,m[g]):o.removeAttribute(g))}),Object.entries(h).forEach(([g,y])=>{y==null?g in m?o.setAttribute(g,m[g]):o.removeAttribute(g):o.setAttribute(g,y)}),d=p,!0}}}},addInputRules(){return[nt({find:c0,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),h0=K.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",j(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
125
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;let t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){let r=i=>{let s=_i(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);if(s){let l={type:"taskList",raw:s.raw,items:s.items},a=i.slice(s.raw.length);return a.trim()?[l,...t.blockTokens(a)]:[l]}return t.blockTokens(i)},o=_i(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,s)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:t.inlineTokens(i.mainContent),nestedTokens:s}),customNestedParser:r},t);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),Bk=z.create({name:"listKit",addExtensions(){let n=[];return this.options.bulletList!==!1&&n.push(Yi.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(es.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(Yy.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(ns.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(f0.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(h0.configure(this.options.taskList)),n}});var Yr="&nbsp;",rs="\xA0",is=K.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",j(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{let t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);let r=e.parseInline(t);return t.length===1&&t[0].type==="text"&&(t[0].raw===Yr||t[0].text===Yr||t[0].raw===rs||t[0].text===rs)&&r.length===1&&r[0].type==="text"&&(r[0].text===Yr||r[0].text===rs)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{if(!n)return"";let r=Array.isArray(n.content)?n.content:[];if(r.length===0){var o,i;let s=Array.isArray(t==null||(o=t.previousNode)===null||o===void 0?void 0:o.content)?t.previousNode.content:[];return(t==null||(i=t.previousNode)===null||i===void 0?void 0:i.type)==="paragraph"&&s.length===0?Yr:""}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var ls,as;if(typeof WeakMap<"u"){let n=new WeakMap;ls=e=>n.get(e),as=(e,t)=>(n.set(e,t),t)}else{let n=[],t=0;ls=r=>{for(let o=0;o<n.length;o+=2)if(n[o]==r)return n[o+1]},as=(r,o)=>(t==10&&(t=0),n[t++]=r,n[t++]=o)}var q=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){let t=this.map[e];if(t!=n)continue;let r=e%this.width,o=e/this.width|0,i=r+1,s=o+1;for(let l=1;i<this.width&&this.map[e+l]==t;l++)i++;for(let l=1;s<this.height&&this.map[e+this.width*l]==t;l++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){let{left:r,right:o,top:i,bottom:s}=this.findCell(n);return e=="horiz"?(t<0?r==0:o==this.width)?null:this.map[i*this.width+(t<0?r-1:o)]:(t<0?i==0:s==this.height)?null:this.map[r+this.width*(t<0?i-1:s)]}rectBetween(n,e){let{left:t,right:r,top:o,bottom:i}=this.findCell(n),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,s),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(n){let e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let o=n.left;o<n.right;o++){let i=r*this.width+o,s=this.map[i];t[s]||(t[s]=!0,!(o==n.left&&o&&this.map[i-1]==s||r==n.top&&r&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(n,e,t){for(let r=0,o=0;;r++){let i=o+t.child(r).nodeSize;if(r==n){let s=e+n*this.width,l=(n+1)*this.width;for(;s<l&&this.map[s]<o;)s++;return s==l?i-1:this.map[s]}o=i}}static get(n){return ls(n)||as(n,p0(n))}};function p0(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=m0(n),t=n.childCount,r=[],o=0,i=null,s=[];for(let c=0,d=e*t;c<d;c++)r[c]=0;for(let c=0,d=0;c<t;c++){let u=n.child(c);d++;for(let p=0;;p++){for(;o<r.length&&r[o]!=0;)o++;if(p==u.childCount)break;let m=u.child(p),{colspan:g,rowspan:y,colwidth:k}=m.attrs;for(let S=0;S<y;S++){if(S+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:y-S});break}let v=o+S*e;for(let D=0;D<g;D++){r[v+D]==0?r[v+D]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:g-D});let $=k&&k[D];if($){let E=(v+D)%e*2,R=s[E];R==null||R!=$&&s[E+1]==1?(s[E]=$,s[E+1]=1):R==$&&s[E+1]++}}}o+=g,d+=m.nodeSize}let f=(c+1)*e,h=0;for(;o<f;)r[o++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),d++}(e===0||t===0)&&(i||(i=[])).push({type:"zero_sized"});let l=new q(e,t,r,i),a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<t&&(a=!0);return a&&g0(l,s,n),l}function m0(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let o=n.child(r),i=0;if(t)for(let s=0;s<r;s++){let l=n.child(s);for(let a=0;a<l.childCount;a++){let c=l.child(a);s+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let s=0;s<o.childCount;s++){let l=o.child(s);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function g0(n,e,t){n.problems||(n.problems=[]);let r={};for(let o=0;o<n.map.length;o++){let i=n.map[o];if(r[i])continue;r[i]=!0;let s=t.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null,a=s.attrs;for(let c=0;c<a.colspan;c++){let d=e[(o+c)%n.width*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=y0(a)))[c]=d)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function y0(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function ae(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var rt=new F("selectingCells");function Ot(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function b0(n){for(let e=n.depth;e>0;e--){let t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Me(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function ro(n){let e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;let t=Ot(e.$head)||w0(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function w0(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function cs(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function k0(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function fs(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function tu(n,e,t){let r=n.node(-1),o=q.get(r),i=n.start(-1),s=o.nextCell(n.pos-i,e,t);return s==null?null:n.node(0).resolve(i+s)}function Dt(n,e,t=1){let r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function nu(n,e,t=1){let r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<t;o++)r.colwidth.splice(e,0,0)}return r}function S0(n,e,t){let r=ae(e.type.schema).header_cell;for(let o=0;o<n.height;o++)if(e.nodeAt(n.map[t+o*n.width]).type!=r)return!1;return!0}var H=class Ke extends T{constructor(e,t=e){let r=e.node(-1),o=q.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=o.cellsInRect(s).filter(d=>d!=t.pos-i);a.unshift(t.pos-i);let c=a.map(d=>{let u=r.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);let f=i+d+1;return new Wt(l.resolve(f),l.resolve(f+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(cs(r)&&cs(o)&&fs(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Ke.rowSelection(r,o):i&&this.isColSelection()?Ke.colSelection(r,o):new Ke(r,o)}return C.between(r,o)}content(){let e=this.$anchorCell.node(-1),t=q.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a<o.bottom;a++){let c=[];for(let d=a*t.width+o.left,u=o.left;u<o.right;u++,d++){let f=t.map[d];if(i[f])continue;i[f]=!0;let h=t.findCell(f),p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);let m=o.left-h.left,g=h.right-o.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=Dt(y,0,m)),g>0&&(y=Dt(y,y.colspan-g,g)),h.left<o.left){if(p=p.type.createAndFill(y),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(h.top<o.top||h.bottom>o.bottom){let y={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top<o.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}s.push(e.child(a).copy(b.from(c)))}let l=this.isColSelection()&&this.isRowSelection()?e:s;return new w(b.from(l),1,1)}replace(e,t=w.empty){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:l,$to:a}=o[s],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),s?w.empty:t)}let i=T.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new w(b.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=q.get(t),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(t.nodeAt(i[s]),o+i[s])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=e.node(-1),o=q.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+o.map[s.left])),l.bottom<o.height&&(t=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+o.map[l.left])),s.bottom<o.height&&(e=a.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new Ke(e,t)}isRowSelection(){let e=this.$anchorCell.node(-1),t=q.get(e),r=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-r),i=t.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;let s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==t.width}eq(e){return e instanceof Ke&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=e.node(-1),o=q.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+o.map[s.top*o.width])),l.right<o.width&&(t=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+o.map[l.top*o.width])),s.right<o.width&&(e=a.resolve(i+o.map[o.width*(s.top+1)-1]))),new Ke(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Ke(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Ke(e.resolve(t),e.resolve(r))}getBookmark(){return new x0(this.$anchorCell.pos,this.$headCell.pos)}};H.prototype.visible=!1;T.jsonID("cell",H);var x0=class ru{constructor(e,t){this.anchor=e,this.head=t}map(e){return new ru(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&fs(t,r)?new H(t,r):T.near(r,1)}};function C0(n){if(!(n.selection instanceof H))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push(Z.node(r,r+t.nodeSize,{class:"selectedCell"}))}),L.create(n.doc,e)}function v0({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function M0({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){let i=n.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function E0(n,e,t){let r=(e||n).selection,o=(e||n).doc,i,s;if(r instanceof A&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=H.create(o,r.from);else if(s=="row"){let l=o.resolve(r.from+1);i=H.rowSelection(l,l)}else if(!t){let l=q.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=H.create(o,a+1,c)}}else r instanceof C&&v0(r)?i=C.create(o,r.from):r instanceof C&&M0(r)&&(i=C.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var T0=new F("fix-tables");function ou(n,e,t,r){let o=n.childCount,i=e.childCount;e:for(let s=0,l=0;s<i;s++){let a=e.child(s);for(let c=l,d=Math.min(o,s+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<o&&n.child(l).sameMarkup(a)?ou(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function hs(n,e){let t,r=(o,i)=>{o.type.spec.tableRole=="table"&&(t=A0(n,o,i,t))};return e?e.doc!=n.doc&&ou(e.doc,n.doc,0,r):n.doc.descendants(r),t}function A0(n,e,t,r){let o=q.get(e);if(!o.problems)return r;r||(r=n.tr);let i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){let c=o.problems[a];if(c.type=="collision"){let d=e.nodeAt(c.pos);if(!d)continue;let u=d.attrs;for(let f=0;f<u.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Dt(u,u.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){let d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){let d=r.mapping.map(t);r.delete(d,d+e.nodeSize)}}let s,l;for(let a=0;a<i.length;a++)i[a]&&(s==null&&(s=a),l=a);for(let a=0,c=t+1;a<o.height;a++){let d=e.child(a),u=c+d.nodeSize,f=i[a];if(f>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);let p=[];for(let g=0;g<f;g++){let y=ae(n.schema)[h].createAndFill();y&&p.push(y)}let m=(a==0||s==a-1)&&l==a?c+1:u-1;r.insert(r.mapping.map(m),p)}c=u}return r.setMeta(T0,{fixTables:!0})}function De(n){let e=n.selection,t=ro(n),r=t.node(-1),o=t.start(-1),i=q.get(r);return{...e instanceof H?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(t.pos-o),tableStart:o,map:i,table:r}}function iu(n,{map:e,tableStart:t,table:r},o){let i=o>0?-1:0;S0(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){let l=s*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,nu(c.attrs,o-e.colCount(a))),s+=c.attrs.rowspan-1}else{let a=i==null?ae(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(s,o,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function su(n,e){if(!Me(n))return!1;if(e){let t=De(n);e(iu(n.tr,t,t.left))}return!0}function lu(n,e){if(!Me(n))return!1;if(e){let t=De(n);e(iu(n.tr,t,t.right))}return!0}function N0(n,{map:e,table:t,tableStart:r},o){let i=n.mapping.maps.length;for(let s=0;s<e.height;){let l=s*e.width+o,a=e.map[l],c=t.nodeAt(a),d=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(i).map(r+a),null,Dt(d,o-e.colCount(a)));else{let u=n.mapping.slice(i).map(r+a);n.delete(u,u+c.nodeSize)}s+=d.rowspan}}function au(n,e){if(!Me(n))return!1;if(e){let t=De(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;N0(r,t,o),o!=t.left;o--){let i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");t.table=i,t.map=q.get(i)}e(r)}return!0}function O0(n,e,t){var r;let o=ae(e.type.schema).header_cell;for(let i=0;i<n.width;i++)if(((r=e.nodeAt(n.map[i+t*n.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function cu(n,{map:e,tableStart:t,table:r},o){let i=t;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;let s=[],l=o>0?-1:0;O0(e,r,o+l)&&(l=o==0||o==e.height?null:0);for(let c=0,d=e.width*o;c<e.width;c++,d++)if(o>0&&o<e.height&&e.map[d]==e.map[d-e.width]){let u=e.map[d],f=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var a;let u=l==null?ae(r.type.schema).cell:(a=r.nodeAt(e.map[d+l*e.width]))===null||a===void 0?void 0:a.type,f=u?.createAndFill();f&&s.push(f)}return n.insert(i,ae(r.type.schema).row.create(null,s)),n}function du(n,e){if(!Me(n))return!1;if(e){let t=De(n);e(cu(n.tr,t,t.top))}return!0}function uu(n,e){if(!Me(n))return!1;if(e){let t=De(n);e(cu(n.tr,t,t.bottom))}return!0}function D0(n,{map:e,table:t,tableStart:r},o){let i=0;for(let c=0;c<o;c++)i+=t.child(c).nodeSize;let s=i+t.child(o).nodeSize,l=n.mapping.maps.length;n.delete(i+r,s+r);let a=new Set;for(let c=0,d=o*e.width;c<e.width;c++,d++){let u=e.map[d];if(!a.has(u)){if(a.add(u),o>0&&u==e.map[d-e.width]){let f=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o<e.height&&u==e.map[d+e.width]){let f=t.nodeAt(u),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(o+1,c,t);n.insert(n.mapping.slice(l).map(r+m),p),c+=h.colspan-1}}}}function fu(n,e){if(!Me(n))return!1;if(e){let t=De(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;D0(r,t,o),o!=t.top;o--){let i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");t.table=i,t.map=q.get(t.table)}e(r)}return!0}function qd(n){let e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function R0({width:n,height:e,map:t},r){let o=r.top*n+r.left,i=o,s=(r.bottom-1)*n+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[l]==t[l+1])return!0;i+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[o]==t[o-n]||r.bottom<e&&t[s]==t[s+n])return!0;o++,s++}return!1}function ps(n,e){let t=n.selection;if(!(t instanceof H)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=De(n),{map:o}=r;if(R0(o,r))return!1;if(e){let i=n.tr,s={},l=b.empty,a,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){let f=o.map[d*o.width+u],h=r.table.nodeAt(f);if(!(s[f]||!h))if(s[f]=!0,a==null)a=f,c=h;else{qd(h)||(l=l.append(h.content));let p=i.mapping.map(f+r.tableStart);i.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...nu(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){let d=a+1+c.content.size,u=qd(c)?a+1:d;i.replaceWith(u+r.tableStart,d+r.tableStart,l)}i.setSelection(new H(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function ms(n,e){let t=ae(n.schema);return I0(({node:r})=>t[r.type.spec.tableRole])(n,e)}function I0(n){return(e,t)=>{let r=e.selection,o,i;if(r instanceof H){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=b0(r.$from),!o)return!1;i=(s=Ot(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(t){let l=o.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let d=De(e),u=e.tr;for(let h=0;h<d.right-d.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=d.top;h<d.bottom;h++){let p=d.map.positionAt(h,d.left,d.table);h==d.top&&(p+=o.nodeSize);for(let m=d.left,g=0;m<d.right;m++,g++)m==d.left&&h==d.top||u.insert(f=u.mapping.map(p+d.tableStart,1),n({node:o,row:h,col:m}).createAndFill(a[g]))}u.setNodeMarkup(i,n({node:o,row:d.top,col:d.left}),a[0]),r instanceof H&&u.setSelection(new H(u.doc.resolve(r.$anchorCell.pos),f?u.doc.resolve(f):void 0)),t(u)}return!0}}function hu(n,e){return function(t,r){if(!Me(t))return!1;let o=ro(t);if(o.nodeAfter.attrs[n]===e)return!1;if(r){let i=t.tr;t.selection instanceof H?t.selection.forEachCell((s,l)=>{s.attrs[n]!==e&&i.setNodeMarkup(l,null,{...s.attrs,[n]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[n]:e}),r(i)}return!0}}function P0(n){return function(e,t){if(!Me(e))return!1;if(t){let r=ae(e.schema),o=De(e),i=e.tr,s=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<s.length;a++)i.setNodeMarkup(o.tableStart+s[a],r.header_cell,l[a].attrs);t(i)}return!0}}function Jd(n,e,t){let r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<r.length;o++){let i=e.table.nodeAt(r[o]);if(i&&i.type!==t.header_cell)return!1}return!0}function dn(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?P0(n):function(t,r){if(!Me(t))return!1;if(r){let o=ae(t.schema),i=De(t),s=t.tr,l=Jd("row",i,o),a=Jd("column",i,o),c=(n==="column"?l:n==="row"&&a)?1:0,d=n=="column"?{left:0,top:c,right:1,bottom:i.map.height}:n=="row"?{left:c,top:0,right:i.map.width,bottom:1}:i,u=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(d).forEach(f=>{let h=f+i.tableStart,p=s.doc.nodeAt(h);p&&s.setNodeMarkup(h,u,p.attrs)}),r(s)}return!0}}var _k=dn("row",{useDeprecatedLogic:!0}),qk=dn("column",{useDeprecatedLogic:!0}),pu=dn("cell",{useDeprecatedLogic:!0});function L0(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){let i=n.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),o=n.after();r<t.childCount;r++){let i=t.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function gs(n){return function(e,t){if(!Me(e))return!1;let r=L0(ro(e),n);if(r==null)return!1;if(t){let o=e.doc.resolve(r);t(e.tr.setSelection(C.between(o,k0(o))).scrollIntoView())}return!0}}function mu(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function Zr(n,e){let t=n.selection;if(!(t instanceof H))return!1;if(e){let r=n.tr,o=ae(n.schema).cell.createAndFill().content;t.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new w(o,0,0))}),r.docChanged&&e(r)}return!0}function B0(n){if(n.size===0)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;let o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,d=a?0:Math.max(0,t-1),u=a<e.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=ds(ae(s).row,new w(c,d,u)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||r?ds(ae(s).row,new w(e,t,r)).content:e);else return null;return z0(s,l)}function z0(n,e){let t=[];for(let o=0;o<e.length;o++){let i=e[o];for(let s=i.childCount-1;s>=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(b.empty),t[o]<r){let i=ae(n).cell.createAndFill(),s=[];for(let l=t[o];l<r;l++)s.push(i);e[o]=e[o].append(b.from(s))}return{height:e.length,width:r,rows:e}}function ds(n,e){let t=n.createAndFill();return new Ge(t).replace(0,t.content.size,e).doc}function $0({width:n,height:e,rows:t},r,o){if(n!=r){let i=[],s=[];for(let l=0;l<t.length;l++){let a=t[l],c=[];for(let d=i[l]||0,u=0;d<r;u++){let f=a.child(u%a.childCount);d+f.attrs.colspan>r&&(f=f.type.createChecked(Dt(f.attrs,f.attrs.colspan,d+f.attrs.colspan-r),f.content)),c.push(f),d+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}s.push(b.from(c))}t=s,n=r}if(e!=o){let i=[];for(let s=0,l=0;s<o;s++,l++){let a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);s+u.attrs.rowspan>o&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,o-u.attrs.rowspan)},u.content)),a.push(u)}i.push(b.from(a))}t=i,e=o}return{width:n,height:e,rows:t}}function F0(n,e,t,r,o,i,s){let l=n.doc.type.schema,a=ae(l),c,d;if(o>e.width)for(let u=0,f=0;u<e.height;u++){let h=t.child(u);f+=h.nodeSize;let p=[],m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)p.push(m);n.insert(n.mapping.slice(s).map(f-1+r),p)}if(i>e.height){let u=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){let g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,b.from(u)),h=[];for(let p=e.height;p<i;p++)h.push(f);n.insert(n.mapping.slice(s).map(r+t.nodeSize-2),h)}return!!(c||d)}function Ud(n,e,t,r,o,i,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=o;c<i;c++){let d=s*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;let f=t.nodeAt(u),{top:h,left:p}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,{...f.attrs,rowspan:s-h}),n.insert(n.mapping.slice(l).map(e.positionAt(s,p,t)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-s})),c+=f.attrs.colspan-1}}return a}function Gd(n,e,t,r,o,i,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=o;c<i;c++){let d=c*e.width+s,u=e.map[d];if(e.map[d-1]==u){a=!0;let f=t.nodeAt(u),h=e.colCount(u),p=n.mapping.slice(l).map(u+r);n.setNodeMarkup(p,null,Dt(f.attrs,s-h,f.attrs.colspan-(s-h))),n.insert(p+f.nodeSize,f.type.createAndFill(Dt(f.attrs,0,s-h))),c+=f.attrs.rowspan-1}}return a}function Xd(n,e,t,r,o){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let s=q.get(i),{top:l,left:a}=r,c=a+o.width,d=l+o.height,u=n.tr,f=0;function h(){if(i=t?u.doc.nodeAt(t-1):u.doc,!i)throw new Error("No table found");s=q.get(i),f=u.mapping.maps.length}F0(u,s,i,t,c,d,f)&&h(),Ud(u,s,i,t,a,c,l,f)&&h(),Ud(u,s,i,t,a,c,d,f)&&h(),Gd(u,s,i,t,l,d,a,f)&&h(),Gd(u,s,i,t,l,d,c,f)&&h();for(let p=l;p<d;p++){let m=s.positionAt(p,a,i),g=s.positionAt(p,c,i);u.replace(u.mapping.slice(f).map(m+t),u.mapping.slice(f).map(g+t),new w(o.rows[p-l],0,0))}h(),u.setSelection(new H(u.doc.resolve(t+s.positionAt(l,a,i)),u.doc.resolve(t+s.positionAt(d-1,c-1,i)))),e(u)}var H0=Hn({ArrowLeft:Qr("horiz",-1),ArrowRight:Qr("horiz",1),ArrowUp:Qr("vert",-1),ArrowDown:Qr("vert",1),"Shift-ArrowLeft":eo("horiz",-1),"Shift-ArrowRight":eo("horiz",1),"Shift-ArrowUp":eo("vert",-1),"Shift-ArrowDown":eo("vert",1),Backspace:Zr,"Mod-Backspace":Zr,Delete:Zr,"Mod-Delete":Zr});function to(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Qr(n,e){return(t,r,o)=>{if(!o)return!1;let i=t.selection;if(i instanceof H)return to(t,r,T.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;let s=gu(o,n,e);if(s==null)return!1;if(n=="horiz")return to(t,r,T.near(t.doc.resolve(i.head+e),e));{let l=t.doc.resolve(s),a=tu(l,n,e),c;return a?c=T.near(a,1):e<0?c=T.near(t.doc.resolve(l.before(-1)),-1):c=T.near(t.doc.resolve(l.after(-1)),1),to(t,r,c)}}}function eo(n,e){return(t,r,o)=>{if(!o)return!1;let i=t.selection,s;if(i instanceof H)s=i;else{let a=gu(o,n,e);if(a==null)return!1;s=new H(t.doc.resolve(a))}let l=tu(s.$headCell,n,e);return l?to(t,r,new H(s.$anchorCell,l)):!1}}function V0(n,e){let t=n.state.doc,r=Ot(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new H(r))),!0):!1}function W0(n,e,t){if(!Me(n.state))return!1;let r=B0(t),o=n.state.selection;if(o instanceof H){r||(r={width:1,height:1,rows:[b.from(ds(ae(n.state.schema).cell,t))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=q.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=$0(r,l.right-l.left,l.bottom-l.top),Xd(n.state,n.dispatch,s,l,r),!0}else if(r){let i=ro(n.state),s=i.start(-1);return Xd(n.state,n.dispatch,s,q.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function j0(n,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;let r=Yd(n,e.target),o;if(e.shiftKey&&n.state.selection instanceof H)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Ot(n.state.selection.$anchor))!=null&&((t=ss(n,e))===null||t===void 0?void 0:t.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(a,c){let d=ss(n,c),u=rt.getState(n.state)==null;if(!d||!fs(a,d))if(u)d=a;else return;let f=new H(a,d);if(u||!n.state.selection.eq(f)){let h=n.state.tr.setSelection(f);u&&h.setMeta(rt,a.pos),n.dispatch(h)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",l),rt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(rt,-1))}function l(a){let c=a,d=rt.getState(n.state),u;if(d!=null)u=n.state.doc.resolve(d);else if(Yd(n,c.target)!=r&&(u=ss(n,e),!u))return s();u&&i(u,c)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",l)}function gu(n,e,t){if(!(n.state.selection instanceof C))return null;let{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let s=r.before(o),l=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(l)?s:null}}return null}function Yd(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function ss(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});if(!t)return null;let{inside:r,pos:o}=t;return r>=0&&Ot(n.state.doc.resolve(r))||Ot(n.state.doc.resolve(o))}var K0=class{constructor(n,e){this.node=n,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),us(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!=this.node.type?!1:(this.node=n,us(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function us(n,e,t,r,o,i){let s=0,l=!0,a=e.firstChild,c=n.firstChild;if(c){for(let u=0,f=0;u<c.childCount;u++){let{colspan:h,colwidth:p}=c.child(u).attrs;for(let m=0;m<h;m++,f++){let g=o==f?i:p&&p[m],y=g?g+"px":"";if(s+=g||r,g||(l=!1),a)a.style.width!=y&&(a.style.width=y),a=a.nextSibling;else{let k=document.createElement("col");k.style.width=y,e.appendChild(k)}}}for(;a;){var d;let u=a.nextSibling;(d=a.parentNode)===null||d===void 0||d.removeChild(a),a=u}l?(t.style.width=s+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=s+"px")}}var me=new F("tableColumnResizing");function yu({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=K0,lastColumnResizable:o=!0}={}){let i=new I({key:me,state:{init(s,l){var a;let c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,d=ae(l.schema).table.name;return r&&c&&(c[d]=(u,f)=>new r(u,t,f)),new _0(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=me.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{q0(s,l,n,o)},mouseleave:s=>{J0(s)},mousedown:(s,l)=>{U0(s,l,e,t)}},decorations:s=>{let l=me.getState(s);if(l&&l.activeHandle>-1)return Q0(s,l.activeHandle)},nodeViews:{}}});return i}var _0=class no{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(me);if(r&&r.setHandle!=null)return new no(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new no(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return cs(e.doc.resolve(o))||(o=-1),new no(o,t.dragging)}return t}};function q0(n,e,t,r){if(!n.editable)return;let o=me.getState(n.state);if(o&&!o.dragging){let i=X0(e.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?s=Zd(n,e,"left",t):a-e.clientX<=t&&(s=Zd(n,e,"right",t))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=n.state.doc.resolve(s),a=l.node(-1),c=q.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}bu(n,s)}}}function J0(n){if(!n.editable)return;let e=me.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&bu(n,-1)}function U0(n,e,t,r){var o;if(!n.editable)return!1;let i=(o=n.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=me.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=n.state.doc.nodeAt(s.activeHandle),a=G0(n,s.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(me,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);let f=me.getState(n.state);f?.dragging&&(Y0(n,f.activeHandle,Qd(f.dragging,u,t)),n.dispatch(n.state.tr.setMeta(me,{setDragging:null})))}function d(u){if(!u.which)return c(u);let f=me.getState(n.state);if(f&&f.dragging){let h=Qd(f.dragging,u,t);eu(n,f.activeHandle,h,r)}}return eu(n,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function G0(n,e,{colspan:t,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=n.domAtPos(e),s=i.node.childNodes[i.offset].offsetWidth,l=t;if(r)for(let a=0;a<t;a++)r[a]&&(s-=r[a],l--);return s/l}function X0(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Zd(n,e,t,r){let o=t=="right"?-r:r,i=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;let{pos:s}=i,l=Ot(n.state.doc.resolve(s));if(!l)return-1;if(t=="right")return l.pos;let a=q.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Qd(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function bu(n,e){n.dispatch(n.state.tr.setMeta(me,{setHandle:e}))}function Y0(n,e,t){let r=n.state.doc.resolve(e),o=r.node(-1),i=q.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){let d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;let u=i.map[d],f=o.nodeAt(u).attrs,h=f.colspan==1?0:l-i.colCount(u);if(f.colwidth&&f.colwidth[h]==t)continue;let p=f.colwidth?f.colwidth.slice():Z0(f.colspan);p[h]=t,a.setNodeMarkup(s+u,null,{...f,colwidth:p})}a.docChanged&&n.dispatch(a)}function eu(n,e,t,r){let o=n.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),l=q.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=n.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&us(i,a.firstChild,a,r,l,t)}function Z0(n){return Array(n).fill(0)}function Q0(n,e){let t=[],r=n.doc.resolve(e),o=r.node(-1);if(!o)return L.empty;let i=q.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){let d=l+c*i.width;if((l==i.width-1||i.map[d]!=i.map[d+1])&&(c==0||i.map[d]!=i.map[d-i.width])){var a;let u=i.map[d],f=s+u+o.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((a=me.getState(n))===null||a===void 0)&&a.dragging&&t.push(Z.node(s+u,s+u+o.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),t.push(Z.widget(f,h))}}return L.create(n.doc,t)}function wu({allowTableNodeSelection:n=!1}={}){return new I({key:rt,state:{init(){return null},apply(e,t){let r=e.getMeta(rt);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:o,pos:i}=e.mapping.mapResult(t);return o?null:i}},props:{decorations:C0,handleDOMEvents:{mousedown:j0},createSelectionBetween(e){return rt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:V0,handleKeyDown:H0,handlePaste:W0},appendTransaction(e,t,r){return E0(r,hs(r,t),n)}})}function Kn(n){return n==="left"||n==="right"||n==="center"?n:null}function eb(n){let e=(n.style.textAlign||"").trim().toLowerCase(),t=(n.getAttribute("align")||"").trim().toLowerCase();return Kn(e||t)}function tb(n){return Kn(n?.align)}function vu(){return{default:null,parseHTML:n=>eb(n),renderHTML:n=>{let e=Kn(n.align);return md(e)?{style:`text-align: ${e}`}:{}}}}function nb(n){var e;let t=n.parentElement,r=n.closest("table");if(!t||!r)return null;let o=Array.from(t.children).indexOf(n),i=(e=r.querySelectorAll("colgroup > col")[o])===null||e===void 0?void 0:e.getAttribute("width");return i?[parseInt(i,10)]:null}function Mu(n){let e=n.getAttribute("colwidth");return e?e.split(",").map(t=>parseInt(t,10)):nb(n)}var rb=/[ \t\r\n\f]+/g;function Eu(n){var e;return n.children.length>0?!1:((e=n.textContent)!==null&&e!==void 0?e:"").replace(rb,"")===""}function Tu(n){let e=n.createAndFill();if(!e)throw new Error(`[tiptap error]: "${n.name}" has no default content to backfill.`);return e.content}function io(n,e,t){if(!(t in e))return;let r=e[t];(r===1||r==="1"||r===null||r===void 0)&&delete n[t]}var bs=K.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Mu},align:vu()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:n=>Eu(n)?{}:!1,getContent:(n,e)=>Tu(e.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:n}){let e=j(this.options.HTMLAttributes,n);return io(e,n,"colspan"),io(e,n,"rowspan"),["td",e,0]}}),ws=K.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Mu},align:vu()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:n=>Eu(n)?{}:!1,getContent:(n,e)=>Tu(e.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:n}){let e=j(this.options.HTMLAttributes,n);return io(e,n,"colspan"),io(e,n,"rowspan"),["th",e,0]}}),ks=K.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",j(this.options.HTMLAttributes,n),0]}});function ys(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function ku(n,e,t,r,o,i){let s=0,l=!0,a=e.firstChild,c=n.firstChild;if(c!==null)for(let f=0,h=0;f<c.childCount;f+=1){let{colspan:p,colwidth:m}=c.child(f).attrs;for(let g=0;g<p;g+=1,h+=1){let y=o===h?i:m&&m[g],k=y?`${y}px`:"";if(s+=y||r,y||(l=!1),a){if(a.style.width!==k){let[S,v]=ys(r,y);a.style.setProperty(S,v)}a=a.nextSibling}else{let S=document.createElement("col"),[v,D]=ys(r,y);S.style.setProperty(v,D),e.appendChild(S)}}}for(;a;){var d;let f=a.nextSibling;(d=a.parentNode)===null||d===void 0||d.removeChild(a),a=f}let u=n.attrs.style&&typeof n.attrs.style=="string"&&/\bwidth\s*:/i.test(n.attrs.style);l&&!u?(t.style.width=`${s}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${s}px`)}var ob=class{constructor(n,e,t,r={}){this.node=n,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(let[o,i]of Object.entries(r))i!=null&&(o==="style"?this.table.style.cssText=String(i):this.table.setAttribute(o,String(i)));n.attrs.style&&(this.table.style.cssText=n.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ku(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.sameMarkup(this.node)?(this.node=n,ku(n,this.colgroup,this.table,this.cellMinWidth),!0):!1}ignoreMutation(n){let e=n.target,t=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(t&&!r&&(n.type==="attributes"||n.type==="childList"||n.type==="characterData"))}};function ib(n,e,t,r){let o=0,i=!0,s=[],l=n.firstChild;if(!l)return{};for(let d=0,u=0;d<l.childCount;d+=1){let{colspan:f,colwidth:h}=l.child(d).attrs;for(let p=0;p<f;p+=1,u+=1){let m=t===u?r:h&&h[p];o+=m||e,m||(i=!1);let[g,y]=ys(e,m);s.push(["col",{style:`${g}: ${y}`}])}}let a=i?`${o}px`:"",c=i?"":`${o}px`;return{colgroup:["colgroup",{},...s],tableWidth:a,tableMinWidth:c}}function Su(n,e){return e?n.createChecked(null,e):n.createAndFill()}function sb(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;let e={};return Object.keys(n.nodes).forEach(t=>{let r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function lb(n,e,t,r,o){let i=sb(n),s=[],l=[];for(let c=0;c<t;c+=1){let d=Su(i.cell,o);if(d&&l.push(d),r){let u=Su(i.header_cell,o);u&&s.push(u)}}let a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?s:l));return i.table.createChecked(null,a)}function Au(n){return n instanceof H}var oo=({editor:n})=>{let{selection:e}=n.state;if(!Au(e))return!1;let t=0,r=rn(e.ranges[0].$from,o=>o.type.name==="table");return r?.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(t+=1)}),t!==e.ranges.length?!1:(n.commands.deleteTable(),!0)};function xu(n,e){let t=n.mapping.map(e),r=rn(n.selection.$from,s=>s.type.name==="table");if(r?.pos===t)return;let o=n.doc.nodeAt(t);if(!o)return;let i=t+o.nodeSize-1;n.setSelection(C.near(n.doc.resolve(i),-1))}function ab(n){let e="",t=0;for(;t<n.length;){if(n[t]==="\\"&&t+1<n.length){e+=n[t]+n[t+1],t+=2;continue}if(n[t]!=="`"){e+=n[t++];continue}let r=0;for(;t+r<n.length&&n[t+r]==="`";)r+=1;let o=t+r,i=!1;for(;o<n.length;){if(n[o]!=="`"){o+=1;continue}let s=0;for(;o+s<n.length&&n[o+s]==="`";)s+=1;if(s===r){let l=n.slice(t+r,o);e+=n.slice(t,t+r)+l.replace(/\\\||\|/g,a=>a==="|"?"\\|":a)+n.slice(o,o+r),t=o+r,i=!0;break}o+=s}i||(e+=n.slice(t,t+r),t+=r)}return e}function cb(n){return n.split(`
126
+ `).map(e=>!e.includes("|")||!e.includes("`")?e:ab(e)).join(`
127
+ `)}function db(n){return(n||"").replaceAll(""," ").replace(/\s+/g," ").trim()}function Cu(n,e){return e?n.split(e).join(`
128
+ `):n}function ub(n){return n.replace(/\\.|\|/g,e=>e==="|"?"\\|":e)}function fb(n,e,t={}){if(!n||!n.content||n.content.length===0)return"";let r=[];n.content.forEach(f=>{let h=[];f.content&&f.content.forEach(p=>{let m="";p.content&&Array.isArray(p.content)&&p.content.length>1?m=p.content.map(S=>Cu(e.renderChildren(S),t.cellLineSeparator)).join(`
129
+ `):m=Cu(p.content?e.renderChildren(p.content):"",t.cellLineSeparator);let g=ub(db(m.replace(/[ \t]*\r?\n[ \t]*/g,"<br>"))),y=p.type==="tableHeader",k=tb(p.attrs);h.push({text:g,isHeader:y,align:k})}),r.push(h)});let o=r.reduce((f,h)=>Math.max(f,h.length),0);if(o===0)return"";let i=Array.from({length:o}).fill(0);r.forEach(f=>{for(let p=0;p<o;p+=1){var h;let m=(((h=f[p])===null||h===void 0?void 0:h.text)||"").length;m>i[p]&&(i[p]=m),i[p]<3&&(i[p]=3)}});let s=(f,h)=>f+" ".repeat(Math.max(0,h-f.length)),l=r[0],a=l.some(f=>f.isHeader),c=Array.from({length:o}).fill(null);r.forEach(f=>{for(let p=0;p<o;p+=1){var h;!c[p]&&(!((h=f[p])===null||h===void 0)&&h.align)&&(c[p]=f[p].align)}});let d=`
130
+ `,u=Array.from({length:o}).map((f,h)=>a&&l[h]&&l[h].text||"");return d+=`| ${u.map((f,h)=>s(f,i[h])).join(" | ")} |
131
+ `,d+=`| ${i.map((f,h)=>{let p=Math.max(3,f),m=c[h];return m==="left"?`:${"-".repeat(p)}`:m==="right"?`${"-".repeat(p)}:`:m==="center"?`:${"-".repeat(p)}:`:"-".repeat(p)}).join(" | ")} |
132
+ `,(a?r.slice(1):r).forEach(f=>{d+=`| ${Array.from({length:o}).fill(0).map((h,p)=>s(f[p]&&f[p].text||"",i[p])).join(" | ")} |
133
+ `}),d}var hb=new F("preserveCellSelectionOnContextMenu");function pb(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});if(t)return t.pos;if(!(e.target instanceof Node))return null;try{return n.posAtDOM(e.target,0)}catch{return null}}function mb(n,e){let t=!1;return n.forEachCell((r,o)=>{e>=o&&e<o+r.nodeSize&&(t=!0)}),t}function gb(){return new I({key:hb,props:{handleDOMEvents:{mousedown(n,e){if(e.button!==2)return!1;let{selection:t}=n.state;if(!Au(t)||t.ranges.length<2)return!1;let r=pb(n,e);return r==null||!mb(t,r)?!1:(e.preventDefault(),!0)}}}})}var Ss=K.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:ob,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let{colgroup:t,tableWidth:r,tableMinWidth:o}=ib(n,this.options.cellMinWidth),i=e.style;function s(){return i||(r?`width: ${r}`:`min-width: ${o}`)}let l=["table",j(this.options.HTMLAttributes,e,{style:s()}),t,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(n,e)=>{let t=[],r=Array.isArray(n.align)?n.align:[];if(n.header){let o=[];n.header.forEach((i,s)=>{var l;let a=Kn((l=r[s])!==null&&l!==void 0?l:i.align),c=a?{align:a}:{};o.push(e.createNode("tableHeader",c,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),t.push(e.createNode("tableRow",{},o))}return n.rows&&n.rows.forEach(o=>{let i=[];o.forEach((s,l)=>{var a;let c=Kn((a=r[l])!==null&&a!==void 0?a:s.align),d=c?{align:c}:{};i.push(e.createNode("tableCell",d,[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),t.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,t)},renderMarkdown:(n,e)=>fb(n,e),markdownTokenizer:{name:"table",level:"block",start:n=>{let e=n.split(`
134
+ `);if(e.length<2)return-1;let t=e[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(t)||!t.includes("|")?-1:e[0].includes("|")?0:-1},tokenize(n,e,t){let r=n.indexOf(`
135
+
136
+ `),o=r>=0?n.slice(0,r):n,i=o.split(`
137
+ `);if(i.length<2)return;let s=i[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(s)||!s.includes("|"))return;let l=cb(o);if(l===o)return;let a=t.blockTokens(l)[0];if(a?.type!=="table"||!a.raw)return;let c=a.raw.split(`
138
+ `).length,d=n.split(`
139
+ `).slice(0,c).join(`
140
+ `);return{...a,raw:d}}},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=lb(i.schema,n,e,t);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(C.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>su(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>lu(n,e),deleteColumn:()=>({state:n,dispatch:e})=>{let t=rn(n.selection.$from,r=>r.type.name==="table");return au(n,e&&(r=>{t&&xu(r,t.pos),e(r)}))},addRowBefore:()=>({state:n,dispatch:e})=>du(n,e),addRowAfter:()=>({state:n,dispatch:e})=>uu(n,e),deleteRow:()=>({state:n,dispatch:e})=>{let t=rn(n.selection.$from,r=>r.type.name==="table");return fu(n,e&&(r=>{t&&xu(r,t.pos),e(r)}))},deleteTable:()=>({state:n,dispatch:e})=>mu(n,e),mergeCells:()=>({state:n,dispatch:e})=>ps(n,e),splitCell:()=>({state:n,dispatch:e})=>ms(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>dn("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>dn("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>pu(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>ps(n,e)?!0:ms(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>hu(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>gs(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>gs(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&hs(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){let r=H.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:oo,"Mod-Backspace":oo,Delete:oo,"Mod-Delete":oo}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[yu({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],wu({allowTableNodeSelection:this.options.allowTableNodeSelection}),gb()]},addNodeView(){let n=this.options.View;return n?({node:e,view:t,HTMLAttributes:r})=>{let o=j(this.options.HTMLAttributes,r);return new n(e,this.options.cellMinWidth,t,o)}:null},extendNodeSchema(n){let e={name:n.name,options:n.options,storage:n.storage};return{tableRole:B(M(n,"tableRole",e))}}}),tS=z.create({name:"tableKit",addExtensions(){let n=[];return this.options.table!==!1&&n.push(Ss.configure(this.options.table)),this.options.tableCell!==!1&&n.push(bs.configure(this.options.tableCell)),this.options.tableHeader!==!1&&n.push(ws.configure(this.options.tableHeader)),this.options.tableRow!==!1&&n.push(ks.configure(this.options.tableRow)),n}});var xs=K.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""});function Nu(n={}){return new I({view(e){return new Cs(e,n)}})}var Cs=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(t){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=u?p.bottom:p.top;u&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*s;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,t,e):o;if(!t||i)return null;let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=dr(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var ce=class n extends T{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):T.near(r)}content(){return w.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new vs(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!yb(e)||!bb(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)<l.childCount:e.index(s)>0){i=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=t;let a=e.doc.resolve(o);if(n.valid(a))return a}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!A.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*t),r=!1;continue e}break}i=s,o+=t;let l=e.doc.resolve(o);if(n.valid(l))return l}return null}}};ce.prototype.visible=!1;ce.findFrom=ce.findGapCursorFrom;T.jsonID("gapcursor",ce);var vs=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ce.valid(t)?new ce(t):T.near(t)}};function Ou(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function yb(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||Ou(o.type))return!0;if(o.inlineContent)return!1}}return!0}function bb(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||Ou(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Du(){return new I({props:{decorations:xb,createSelectionBetween(n,e,t){return e.pos==t.pos&&ce.valid(t)?new ce(t):null},handleClick:kb,handleKeyDown:wb,handleDOMEvents:{beforeinput:Sb}}})}var wb=Hn({ArrowLeft:so("horiz",-1),ArrowRight:so("horiz",1),ArrowUp:so("vert",-1),ArrowDown:so("vert",1)});function so(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof C){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ce.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new ce(c))),!0):!1}}function kb(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ce.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&A.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ce(r))),!0)}function Sb(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ce))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=b.empty;for(let s=r.length-1;s>=0;s--)o=b.from(r[s].createAndFill(null,o));let i=n.state.tr.replace(t.pos,t.pos,new w(o,0,0));return i.setSelection(C.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function xb(n){if(!(n.selection instanceof ce))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",L.create(n.doc,[Z.widget(n.selection.head,e,{key:"gapcursor"})])}var vS=z.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{let e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){let t=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(t)}return e.nodeSize},this.storage.words=n=>{let e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new I({key:new F("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;let o=this.options.limit,i=this.options.autoTrim;if(o==null||o===0||i===!1){n=!0;return}let s=this.storage.characters({node:r.doc});if(s>o){let l=s-o,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);let d=r.tr.deleteRange(a,c);return n=!0,d}n=!0},filterTransaction:(e,t)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let o=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!e.getMeta("paste"))return!1;let s=e.selection.$head.pos,l=s-(i-r),a=s;return e.deleteRange(l,a),!(this.storage.characters({node:e.doc})>r)}})]}}),MS=z.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Nu(this.options)]}}),ES=z.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new I({key:new F("focus"),props:{decorations:({doc:n,selection:e})=>{let{isEditable:t,isFocused:r}=this.editor,{anchor:o}=e,i=[];if(!t||!r)return L.create(n,[]);let s=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(!a.isText){if(!(o>=c&&o<=c+a.nodeSize-1))return!1;s+=1}});let l=0;return n.descendants((a,c)=>{if(a.isText||!(o>=c&&o<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(Z.node(c,c+a.nodeSize,{class:this.options.className}))}),L.create(n,i)}}})]}}),TS=z.create({name:"gapCursor",addProseMirrorPlugins(){return[Du()]},extendNodeSchema(n){var e;let t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=B(M(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),Pu="placeholder",Ru=new F("tiptap__placeholder");function Lu(n){let{editor:e,placeholder:t,dataAttribute:r,pos:o,node:i,isEmptyDoc:s,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=n,d=[a];return s&&d.push(c),Z.node(o,o+i.nodeSize,{class:d.join(" "),[r]:typeof t=="function"?t({editor:e,node:i,pos:o,hasAnchor:l}):t})}function Bu(n,e){return typeof n=="function"?n(e):n}function zu({editor:n,options:e,dataAttribute:t,doc:r,selection:o,from:i,to:s}){let{anchor:l}=o,a=[],c=n.isEmpty;return r.nodesBetween(i,s,(d,u)=>{let f=l>=u&&l<=u+d.nodeSize,h=!d.isLeaf&&on(d);return d.type.isTextblock&&(f||!e.showOnlyCurrent)&&h&&a.push(Lu({editor:n,isEmptyDoc:c,dataAttribute:t,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Bu(e.emptyNodeClass,{editor:n,node:d,pos:u,hasAnchor:f})},node:d,pos:u})),e.includeChildren}),a}function $u({editor:n,options:e,dataAttribute:t,doc:r,selection:o}){if(!(n.isEditable||!e.showOnlyWhenEditable))return null;let{anchor:i}=o,s=[],l=n.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){let a=r.resolve(i),c=a.depth>0?a.node(1):a.nodeAfter,d=a.depth>0?a.before(1):i;if(c&&c.type.isTextblock&&on(c)){let u=i>=d&&i<=d+c.nodeSize;s.push(Lu({editor:n,isEmptyDoc:l,dataAttribute:t,hasAnchor:u,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Bu(e.emptyNodeClass,{editor:n,node:c,pos:d,hasAnchor:u})},node:c,pos:d}))}}else s.push(...zu({editor:n,options:e,dataAttribute:t,doc:r,selection:o,from:0,to:r.content.size}));return L.create(r,s)}function _n(n,e){let t=n.resolve(e);if(t.depth===0){var r;let i=(r=t.nodeAfter)!==null&&r!==void 0?r:t.nodeBefore;if(!i)return{from:e,to:e};let s=t.nodeAfter?e:e-i.nodeSize;return{from:s,to:s+i.nodeSize}}let o=t.before(1);return{from:o,to:o+t.node(1).nodeSize}}function qn(n,e){return{from:Math.max(0,e.from-1),to:Math.min(n.content.size,e.to-1)}}function Cb(n,e,t){let r=[];return n.forEach((o,i)=>{let s=i,l=s+o.nodeSize,a=s+1,c=l+1;a<t&&c>e&&r.push({from:s,to:l})}),r}function vb(n){if(n.length===0)return[];let e=[...n].sort((r,o)=>r.from-o.from),t=[{...e[0]}];for(let r=1;r<e.length;r+=1){let o=t[t.length-1],i=e[r];i.from<=o.to?o.to=Math.max(o.to,i.to):t.push({...i})}return t}function Mb(n,e){let t=Cb(n,e.from,e.to);return t.push(qn(n,_n(n,e.from))),e.to>e.from?t.push(qn(n,_n(n,Math.min(e.to,n.content.size+1)-1))):e.from<n.content.size+1&&t.push(qn(n,_n(n,Math.min(e.from+1,n.content.size)))),t}function Eb(n,e,t){let r=[];if(n.docChanged){let o=Kr(n);for(let i of o)r.push(...Mb(t.doc,i.newRange))}return n.selectionSet&&(r.push(qn(t.doc,_n(t.doc,n.mapping.map(e.selection.anchor)))),r.push(qn(t.doc,_n(t.doc,t.selection.anchor)))),vb(r)}function Tb(n,e,t){let r=Math.max(0,Math.min(n,t.content.size));return{from:r,to:Math.max(r,Math.min(e,t.content.size))}}function Ab({decorations:n,ranges:e,editor:t,options:r,dataAttribute:o,doc:i,selection:s}){let l=n;for(let a of e){let{from:c,to:d}=Tb(a.from,a.to,i),u=l.find(c,d).filter(h=>h.from>=c&&h.to<=d);u.length&&(l=l.remove(u));let f=zu({editor:t,options:r,dataAttribute:o,doc:i,selection:s,from:c,to:d});f.length&&(l=l.add(i,f))}return l}function Nb({editor:n,options:e,dataAttribute:t}){return{init(r,o){let i=$u({editor:n,options:e,dataAttribute:t,doc:o.doc,selection:o.selection});return i??L.empty},apply(r,o,i,s){return!r.docChanged&&!r.selectionSet?o:Ab({decorations:o.map(r.mapping,r.doc),ranges:Eb(r,i,s),editor:n,options:e,dataAttribute:t,doc:s.doc,selection:s.selection})}}}function Ob(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function Db({editor:n,options:e}){let t=e.dataAttribute?`data-${Ob(e.dataAttribute)}`:`data-${Pu}`,r=e.showOnlyCurrent&&!e.includeChildren;return new I({key:Ru,...r?{}:{state:Nb({editor:n,options:e,dataAttribute:t})},props:{decorations:r?({doc:o,selection:i})=>$u({editor:n,options:e,dataAttribute:t,doc:o,selection:i}):o=>{var i;return e.showOnlyWhenEditable&&!n.isEditable?L.empty:(i=Ru.getState(o))!==null&&i!==void 0?i:L.empty}}})}var AS=z.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Pu,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[Db({editor:this.editor,options:this.options})]}});function Ms(n,e){return!n.selection.empty&&!rd(n.selection)&&e.isEditable}function Rb(n,e){return Ms(n,e)&&!e.isFocused&&!e.view.dragging}function Ib(){var n;(n=window.getSelection())===null||n===void 0||n.removeAllRanges()}function Pb(n){n.focus()}var NS=z.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:n,options:e}=this;return[new I({key:new F("selection"),props:{decorations(t){return Rb(t,n)?L.create(t.doc,[Z.inline(t.selection.from,t.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(t){return Ms(t.state,n)&&Ib(),!1},focus(t){return Ms(t.state,n)&&requestAnimationFrame(()=>{!n.isDestroyed&&t.hasFocus()&&Pb(t)}),!1}}}})]}});function Iu({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var OS=z.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;let e=new F(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)===null||n===void 0?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(t).includes(o.name));return[new I({key:e,appendTransaction:(o,i,s)=>{let{doc:l,tr:a,schema:c}=s,d=e.getState(s),u=l.content.size,f=c.nodes[t];if(!o.some(h=>h.getMeta("skipTrailingNode"))&&d)return a.insert(u,f.create())},state:{init:(o,i)=>{let s=i.tr.doc.lastChild;return!Iu({node:s,types:r})},apply:(o,i)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return i;let s=o.doc.lastChild;return!Iu({node:s,types:r})}}})]}}),Es=z.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Ri(n,e),redo:()=>({state:n,dispatch:e})=>Ii(n,e)}},addProseMirrorPlugins(){return[pc(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Wu=["heading","bold","italic","link","bulletList","orderedList","blockquote","image","hardBreak","table"],Ts=/^[0-9a-f]{64}$/,As=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Fu="url:";function lo(n){if(/[\u0000-\u001f\u007f]/.test(n))return!1;if(n.startsWith("/"))return!n.startsWith("//")&&!n.startsWith("/\\");try{return["http:","https:","mailto:","tel:"].includes(new URL(n).protocol)}catch{return!1}}var Lb=K.create({name:"image",inline:!0,group:"inline",atom:!0,draggable:!0,addAttributes(){return{media:{default:null,parseHTML:n=>n.getAttribute("data-media"),renderHTML:()=>({})},alt:{default:null,parseHTML:n=>n.getAttribute("alt")||null,renderHTML:()=>({})}}},parseHTML(){return[{tag:"img[data-media]",getAttrs:n=>Ts.test(n.getAttribute("data-media")??"")?null:!1}]},renderHTML({node:n}){let e=typeof n.attrs.media=="string"&&Ts.test(n.attrs.media)?n.attrs.media:null;return["img",{src:e===null?null:`/media/${e}/640.webp`,alt:typeof n.attrs.alt=="string"?n.attrs.alt:"","data-media":e}]}}),Bb=At.create({name:"link",inclusive:!1,addAttributes(){return{href:{default:null,parseHTML:n=>{let e=n.getAttribute("href");return n.hasAttribute("data-document")||e===null||!lo(e)?null:e},renderHTML:()=>({})},document:{default:null,parseHTML:n=>{let e=n.getAttribute("data-document");return e!==null&&As.test(e)?e:null},renderHTML:()=>({})}}},parseHTML(){return[{tag:"a[data-document]",getAttrs:n=>As.test(n.getAttribute("data-document")??"")?null:!1},{tag:"a[href]",getAttrs:n=>lo(n.getAttribute("href")??"")?null:!1}]},renderHTML({mark:n}){let{href:e,document:t}=n.attrs;return typeof t=="string"?["a",{"data-document":t},0]:["a",{href:typeof e=="string"&&lo(e)?e:null,rel:"noopener noreferrer nofollow"},0]}}),zb=Ad.extend({content:"text*"}),$b=ns.extend({addAttributes(){let{start:n}=this.parent?.()??{};return n===void 0?{}:{start:n}}}),Fb=ws.extend({content:"paragraph"}),Hb=bs.extend({content:"paragraph"}),Vb=z.create({name:"inlayTableKeys",priority:1e3,addKeyboardShortcuts(){let n=()=>this.editor.isActive("table");return{Enter:n,"Shift-Enter":n,"Mod-Enter":n}}}),Wb=Xi.extend({content:"paragraph"}),jb=z.create({name:"inlayInlineKeys",priority:1e3,addKeyboardShortcuts(){let n=()=>!0;return{Enter:n,"Shift-Enter":n,"Mod-Enter":n}}});function Kb(n,e){let t=[];n.content.descendants(i=>i.isTextblock?(t.push(i),!1):!0);let r=e.nodes.paragraph;if(t.length<2||!r)return n;let o=[];for(let i of t)i.childCount!==0&&(o.length>0&&o.push(e.text(" ")),i.content.forEach(s=>o.push(s)));return new w(b.from(r.create(null,o)),1,1)}function _b(n,e,t){let r=t?[Wb,jb,is,xs,Es]:[Xi,is,xs,Es];return n.has("heading")&&e.length>0&&r.push(zb.configure({levels:e})),n.has("bold")&&r.push(Ed),n.has("italic")&&r.push(Nd),n.has("link")&&r.push(Bb),n.has("bulletList")&&r.push(Yi),n.has("orderedList")&&r.push($b),(n.has("bulletList")||n.has("orderedList"))&&r.push(es),n.has("blockquote")&&r.push(Md),n.has("hardBreak")&&r.push(Td),n.has("image")&&r.push(Lb),n.has("table")&&r.push(Ss.configure({resizable:!1,allowTableNodeSelection:!1}),ks,Fb,Hb,Vb),r}function qb(n,e){if(n==="")return null;let t;try{t=JSON.parse(n)}catch{return}if(typeof t!="object"||t===null)return;let r=t.content;if(t.type==="doc"&&(r===void 0||Array.isArray(r)&&r.length===0))return null;try{return Gc(e).nodeFromJSON(t).check(),t}catch{return}}function Jb(n){try{let e=JSON.parse(n??"{}");return typeof e!="object"||e===null?{}:Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]=="string"))}catch{return{}}}function Hu(n,e){n!==void 0&&window.InlayAdmin?.openPicker(n,e)}function Ub(n,e){let t;if(e.value.startsWith(Fu)){let o=e.value.slice(Fu.length);if(!lo(o))return;t={href:o,document:null}}else{if(!As.test(e.value))return;t={href:null,document:e.value}}let r=n.chain().focus();n.state.selection.empty?r.insertContent({type:"text",text:e.label,marks:[{type:"link",attrs:t}]}).run():r.setMark("link",t).run()}function Gb(n){let{$from:e}=n.state.selection;for(let t=e.depth;t>0;t--)if(e.node(t).type.name==="tableRow")return e.index(t-1);return-1}function Xb(n,e,t,r){let o=[];for(let i of Wu)if(t.has(i))switch(i){case"heading":for(let s of r)o.push({command:`heading${s}`,run:()=>n.chain().focus().toggleHeading({level:s}).run(),active:()=>n.isActive("heading",{level:s})});break;case"bold":o.push({command:"bold",run:()=>n.chain().focus().toggleBold().run(),active:()=>n.isActive("bold")});break;case"italic":o.push({command:"italic",run:()=>n.chain().focus().toggleItalic().run(),active:()=>n.isActive("italic")});break;case"link":o.push({command:"link",run(){if(n.isActive("link")){n.chain().focus().extendMarkRange("link").unsetMark("link").run();return}Hu(e.dataset.pickLink,s=>Ub(n,s))},active:()=>n.isActive("link")});break;case"bulletList":o.push({command:"bulletList",run:()=>n.chain().focus().toggleBulletList().run(),active:()=>n.isActive("bulletList")});break;case"orderedList":o.push({command:"orderedList",run:()=>n.chain().focus().toggleOrderedList().run(),active:()=>n.isActive("orderedList")});break;case"blockquote":o.push({command:"blockquote",run:()=>n.chain().focus().toggleBlockquote().run(),active:()=>n.isActive("blockquote")});break;case"image":o.push({command:"image",run:()=>Hu(e.dataset.pickImage,s=>{Ts.test(s.value)&&n.chain().focus().insertContent({type:"image",attrs:{media:s.value,alt:null}}).run()}),enabled:()=>!n.isActive("table")});break;case"hardBreak":o.push({command:"hardBreak",run:()=>n.chain().focus().setHardBreak().run(),enabled:()=>!n.isActive("table")});break;case"table":{let s=()=>n.isActive("table");o.push({command:"table",run:()=>n.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),enabled:()=>n.state.selection.$from.depth===1},{command:"addRowAfter",run:()=>n.chain().focus().addRowAfter().run(),shown:s},{command:"addColumnAfter",run:()=>n.chain().focus().addColumnAfter().run(),shown:s},{command:"deleteRow",run:()=>n.chain().focus().deleteRow().run(),shown:()=>Gb(n)>0},{command:"deleteColumn",run(){n.chain().focus().deleteColumn().run()||n.chain().focus().deleteTable().run()},shown:s},{command:"deleteTable",run:()=>n.chain().focus().deleteTable().run(),shown:s});break}}return o}function Yb(n,e,t){let r=e.map((s,l)=>{let a=document.createElement("button");return a.type="button",a.className="btn btn-ghost btn-sm aria-pressed:btn-active",a.dataset.command=s.command,a.textContent=t[s.command]??s.command,a.tabIndex=l===0?0:-1,s.active&&a.setAttribute("aria-pressed","false"),a.addEventListener("click",()=>s.run()),a});n.replaceChildren(...r);let o=()=>r.filter(s=>!s.hidden&&!s.disabled),i=s=>{let l=o(),a=l.length,c=l[(s%a+a)%a];if(c){for(let d of r)d.tabIndex=d===c?0:-1;c.focus()}};return n.addEventListener("keydown",s=>{let l=o(),a=l.indexOf(s.target);if(a<0)return;let c={ArrowRight:a+1,ArrowDown:a+1,ArrowLeft:a-1,ArrowUp:a-1,Home:0,End:l.length-1}[s.key];c!==void 0&&(s.preventDefault(),i(c))}),()=>{e.forEach((l,a)=>{let c=r[a];c&&(l.active&&c.setAttribute("aria-pressed",String(l.active())),l.shown&&(c.hidden=!l.shown()),l.enabled&&(c.disabled=!l.enabled()))});let s=o();if(!s.some(l=>l.tabIndex===0))for(let l of r)l.tabIndex=l===s[0]?0:-1}}var Vu=new WeakMap;function Zb(n){let e=Vu.get(n);if(e)return e;let t=new Set((n.dataset.features??"").split(" ").filter(m=>Wu.includes(m))),r=(n.dataset.headings??"").split(" ").map(Number).filter(m=>Number.isInteger(m)&&m>=1&&m<=6),o=Jb(n.dataset.labels),i=n.querySelector("[data-richtext-mount]")??n,s=n.querySelector(':scope > input[type="hidden"]'),l=n.querySelector('[role="toolbar"]'),a=n.hasAttribute("data-inline"),c=_b(t,r,a),d=qb(s?.value??"",c),u=d!==void 0,f=u&&!n.hasAttribute("data-readonly");if(!u){let m=n.querySelector("[data-richtext-error]");m&&(m.hidden=!1)}let h={role:"textbox","aria-multiline":String(!a)};for(let m of["aria-label","aria-describedby","aria-invalid"]){let g=i.getAttribute(m);g!==null&&(h[m]=g)}f||(h["aria-readonly"]="true");let p=new wd({element:i,extensions:c,content:d,editable:f,editorProps:a?{attributes:h,transformPastedText:m=>m.replace(/\s*[\r\n]+\s*/g," "),transformPasted:(m,g)=>Kb(m,g.state.schema)}:{attributes:h},onUpdate:({editor:m})=>{!s||!u||(s.value=JSON.stringify(m.getJSON()),s.dispatchEvent(new Event("change",{bubbles:!0})))}});if(Vu.set(n,p),l&&f){let m=Yb(l,Xb(p,n,t,r),o);p.on("transaction",m),m()}return p}function Ns(n){for(let e of n.querySelectorAll("[data-richtext]"))Zb(e)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>Ns(document)):Ns(document);document.addEventListener("htmx:afterSwap",()=>Ns(document));export{Zb as mountRichText};