@grapesjs/studio-sdk-plugins 1.0.13 → 1.0.14-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,14 +1,14 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("grapesjs");const Hs="app.grapesjs.com",Fs="app-stage.grapesjs.com",Uo=[Hs,Fs,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],tc="license:check:start",nc="license:check:end",ic=()=>typeof window<"u",oc=({isDev:n,isStage:e})=>`${n?"":`https://${e?Fs:Hs}`}/api`,rc=()=>{const n=ic()&&window.location.hostname;return!!n&&(Uo.includes(n)||Uo.some(e=>n.endsWith(e)))},sc=n=>n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?"-":"")+e.toLowerCase()),lc=n=>typeof n<"u";function $s(n){return typeof n=="function"}async function ac({path:n,baseApiUrl:e,method:t="GET",headers:i={},params:o,body:r}){const l=`${e||oc({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...i}};r&&(a.body=JSON.stringify(r));const c=o?new URLSearchParams(o).toString():"",d=c?`?${c}`:"",h=await fetch(`${l}${d}`,a);if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return h.json()}var ee=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(ee||{}),Ws=(n=>(n.Info="info",n.Error="error",n.Success="success",n.Warning="warning",n))(Ws||{}),Y=(n=>(n.toastAdd="studio:toastAdd",n.dialogOpen="studio:dialogOpen",n.dialogClose="studio:dialogClose",n.sidebarLeftSet="studio:sidebarLeft:set",n.sidebarLeftGet="studio:sidebarLeft:get",n.sidebarLeftToggle="studio:sidebarLeft:toggle",n.sidebarRightSet="studio:sidebarRight:set",n.sidebarRightGet="studio:sidebarRight:get",n.sidebarRightToggle="studio:sidebarRight:toggle",n.sidebarTopSet="studio:sidebarTop:set",n.sidebarTopGet="studio:sidebarTop:get",n.sidebarTopToggle="studio:sidebarTop:toggle",n.sidebarBottomSet="studio:sidebarBottom:set",n.sidebarBottomGet="studio:sidebarBottom:get",n.sidebarBottomToggle="studio:sidebarBottom:toggle",n.symbolAdd="studio:symbolAdd",n.symbolDetach="studio:symbolDetach",n.symbolOverride="studio:symbolOverride",n.symbolPropagateStyles="studio:propagateStyles",n.getPagesConfig="studio:getPagesConfig",n.setPagesConfig="studio:setPagesConfig",n.getPageSettings="studio:getPageSettings",n.setPageSettings="studio:setPageSettings",n.projectFiles="studio:projectFiles",n.canvasReload="studio:canvasReload",n.getBlocksPanel="studio:getBlocksPanel",n.setBlocksPanel="studio:setBlocksPanel",n.getStateContextMenu="studio:getStateContextMenu",n.setStateContextMenu="studio:setStateContextMenu",n.contextMenuComponent="studio:contextMenuComponent",n.layoutAdd="studio:layoutAdd",n.layoutRemove="studio:layoutRemove",n.layoutToggle="studio:layoutToggle",n.getStateTheme="studio:getStateTheme",n.setStateTheme="studio:setStateTheme",n.assetProviderGet="studio:assetProviderGet",n.assetProviderAdd="studio:assetProviderAdd",n.assetProviderRemove="studio:assetProviderRemove",n))(Y||{}),_s=(n=>(n.dark="dark",n.light="light",n.auto="auto",n))(_s||{});const Zo={[ee.free]:0,[ee.startup]:10,[ee.business]:20,[ee.enterprise]:30};function cc(n){const e=n;return e.init=t=>i=>n(i,t),e}const Me=n=>cc(n);async function Ae({editor:n,plan:e,pluginName:t,licenseKey:i,cleanup:o}){let r="",s=!1;const l=rc(),a=d=>{console.warn("Cleanup plugin:",t,"Reason:",d),o()},c=(d={})=>{var m;const{error:h,sdkLicense:u}=d,f=(m=d.plan)==null?void 0:m.category;if(!(u||d.license)||h)a(h||"Invalid license");else if(f){const g=Zo[e],y=Zo[f];g>y&&a({pluginRequiredPlan:e,licensePlan:f})}};n.on(tc,d=>{r=d==null?void 0:d.baseApiUrl,s=!0}),n.on(nc,d=>{c(d)}),setTimeout(async()=>{if(!s){if(l)return;if(i){const d=await dc({licenseKey:i,pluginName:t,baseApiUrl:r});d&&c(d)}else a("The `licenseKey` option not provided")}},2e3)}async function dc(n){const{licenseKey:e,pluginName:t,baseApiUrl:i}=n;try{return(await ac({baseApiUrl:i,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const zn=(n,e)=>{var t;return!!((t=n==null?void 0:n.hasAttribute)!=null&&t.call(n,e))},mt=(n,e)=>{var t;return!!((t=n==null?void 0:n.classList)!=null&&t.contains(e))},hc=(n,e={})=>{var r;const t={},i=[],o=[];for(const s in n){const{value:l,...a}=n[s];i.push({id:s,name:s,changeProp:!0,category:e.category,...a}),t[s]=l,!lc(l)&&o.push(s);const{subTraits:c={}}=a;for(const d in a.subTraits)(r=c[d])==null||r.forEach(h=>{const u=h.id||h.name;t[u]=h.value})}return{propKeys:Object.keys(t),propsNoValues:o,props:t,traits:i}},uc=(n,e)=>{e.forEach(t=>{if(t.subTraits){const i=`${t.id||t.name}`,o=t.changeProp?`change:${i}`:`change:attributes:${i}`;n.on(o,()=>Yo(n,i)),Yo(n,i)}})},Yo=(n,e)=>{const t=n.getTrait(e),i=t.get("category"),o=t.get("subTraits")||{},s=(Object.values(o).flat()||[]).map(c=>c.id||c.name);n.removeTrait(s);const l=o[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:i,...c})),{at:a})},fc=(n,e)=>{e.forEach(t=>{const i=sc(t);i!==t&&n.has(i)&&n.set({[t]:n.get(i),[i]:void 0})})},Gi="gjs-plg-",Xo=(...n)=>n.map(e=>`[data-gjs-type="${e}"]`).join(","),pc="dialogComponent",mc=function(n,e={}){const{Blocks:t,Components:i}=n,{licenseKey:o}=e,r="gjs-plg-dialog",s="gjs-plg-dialog-overlay",l="gjs-plg-dialog-content",a="gjs-plg-dialog-close",c="gjs-plg-dialog-title",d="gjs-plg-dialog-body",h="gjs-plg-dialog-description",u="gjs-plg-dialog-placeholder";t.add(r,{label:"Dialog",media:`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("grapesjs");const Fr="app.grapesjs.com",$r="app-stage.grapesjs.com",Zo=[Fr,$r,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],tc="license:check:start",nc="license:check:end",ic=()=>typeof window<"u",oc=({isDev:n,isStage:e})=>`${n?"":`https://${e?$r:Fr}`}/api`,sc=()=>{const n=ic()&&window.location.hostname;return!!n&&(Zo.includes(n)||Zo.some(e=>n.endsWith(e)))},rc=n=>n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?"-":"")+e.toLowerCase()),lc=n=>typeof n<"u";function To(n){return typeof n=="function"}async function ac({path:n,baseApiUrl:e,method:t="GET",headers:i={},params:o,body:s}){const l=`${e||oc({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...i}};s&&(a.body=JSON.stringify(s));const c=o?new URLSearchParams(o).toString():"",d=c?`?${c}`:"",h=await fetch(`${l}${d}`,a);if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return h.json()}var Z=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(Z||{}),Wr=(n=>(n.Info="info",n.Error="error",n.Success="success",n.Warning="warning",n))(Wr||{}),X=(n=>(n.toastAdd="studio:toastAdd",n.dialogOpen="studio:dialogOpen",n.dialogClose="studio:dialogClose",n.sidebarLeftSet="studio:sidebarLeft:set",n.sidebarLeftGet="studio:sidebarLeft:get",n.sidebarLeftToggle="studio:sidebarLeft:toggle",n.sidebarRightSet="studio:sidebarRight:set",n.sidebarRightGet="studio:sidebarRight:get",n.sidebarRightToggle="studio:sidebarRight:toggle",n.sidebarTopSet="studio:sidebarTop:set",n.sidebarTopGet="studio:sidebarTop:get",n.sidebarTopToggle="studio:sidebarTop:toggle",n.sidebarBottomSet="studio:sidebarBottom:set",n.sidebarBottomGet="studio:sidebarBottom:get",n.sidebarBottomToggle="studio:sidebarBottom:toggle",n.symbolAdd="studio:symbolAdd",n.symbolDetach="studio:symbolDetach",n.symbolOverride="studio:symbolOverride",n.symbolPropagateStyles="studio:propagateStyles",n.getPagesConfig="studio:getPagesConfig",n.setPagesConfig="studio:setPagesConfig",n.getPageSettings="studio:getPageSettings",n.setPageSettings="studio:setPageSettings",n.projectFiles="studio:projectFiles",n.canvasReload="studio:canvasReload",n.getBlocksPanel="studio:getBlocksPanel",n.setBlocksPanel="studio:setBlocksPanel",n.getStateContextMenu="studio:getStateContextMenu",n.setStateContextMenu="studio:setStateContextMenu",n.contextMenuComponent="studio:contextMenuComponent",n.layoutAdd="studio:layoutAdd",n.layoutRemove="studio:layoutRemove",n.layoutToggle="studio:layoutToggle",n.getStateTheme="studio:getStateTheme",n.setStateTheme="studio:setStateTheme",n.assetProviderGet="studio:assetProviderGet",n.assetProviderAdd="studio:assetProviderAdd",n.assetProviderRemove="studio:assetProviderRemove",n))(X||{}),_r=(n=>(n.dark="dark",n.light="light",n.auto="auto",n))(_r||{});const Yo={[Z.free]:0,[Z.startup]:10,[Z.business]:20,[Z.enterprise]:30};function cc(n){const e=n;return e.init=t=>i=>n(i,t),e}const ve=n=>cc(n);async function Se({editor:n,plan:e,pluginName:t,licenseKey:i,cleanup:o}){let s="",r=!1;const l=sc(),a=d=>{console.warn("Cleanup plugin:",t,"Reason:",d),o()},c=(d={})=>{var m;const{error:h,sdkLicense:u}=d,f=(m=d.plan)==null?void 0:m.category;if(!(u||d.license)||h)a(h||"Invalid license");else if(f){const g=Yo[e],b=Yo[f];g>b&&a({pluginRequiredPlan:e,licensePlan:f})}};n.on(tc,d=>{s=d==null?void 0:d.baseApiUrl,r=!0}),n.on(nc,d=>{c(d)}),setTimeout(async()=>{if(!r){if(l)return;if(i){const d=await dc({licenseKey:i,pluginName:t,baseApiUrl:s});d&&c(d)}else a("The `licenseKey` option not provided")}},2e3)}async function dc(n){const{licenseKey:e,pluginName:t,baseApiUrl:i}=n;try{return(await ac({baseApiUrl:i,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const zn=(n,e)=>{var t;return!!((t=n==null?void 0:n.hasAttribute)!=null&&t.call(n,e))},mt=(n,e)=>{var t;return!!((t=n==null?void 0:n.classList)!=null&&t.contains(e))},hc=(n,e={})=>{var s;const t={},i=[],o=[];for(const r in n){const{value:l,...a}=n[r];i.push({id:r,name:r,changeProp:!0,category:e.category,...a}),t[r]=l,!lc(l)&&o.push(r);const{subTraits:c={}}=a;for(const d in a.subTraits)(s=c[d])==null||s.forEach(h=>{const u=h.id||h.name;t[u]=h.value})}return{propKeys:Object.keys(t),propsNoValues:o,props:t,traits:i}},uc=(n,e)=>{e.forEach(t=>{if(t.subTraits){const i=`${t.id||t.name}`,o=t.changeProp?`change:${i}`:`change:attributes:${i}`;n.on(o,()=>Xo(n,i)),Xo(n,i)}})},Xo=(n,e)=>{const t=n.getTrait(e),i=t.get("category"),o=t.get("subTraits")||{},r=(Object.values(o).flat()||[]).map(c=>c.id||c.name);n.removeTrait(r);const l=o[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:i,...c})),{at:a})},fc=(n,e)=>{e.forEach(t=>{const i=rc(t);i!==t&&n.has(i)&&n.set({[t]:n.get(i),[i]:void 0})})},Gi="gjs-plg-",Qo=(...n)=>n.map(e=>`[data-gjs-type="${e}"]`).join(","),pc="dialogComponent",mc=function(n,e={}){const{Blocks:t,Components:i}=n,{licenseKey:o}=e,s="gjs-plg-dialog",r="gjs-plg-dialog-overlay",l="gjs-plg-dialog-content",a="gjs-plg-dialog-close",c="gjs-plg-dialog-title",d="gjs-plg-dialog-body",h="gjs-plg-dialog-description",u="gjs-plg-dialog-placeholder";t.add(s,{label:"Dialog",media:`
2
2
  <svg viewBox="0 0 24 24">
3
3
  <path d="M4 4h16v10H8l-4 4V4z"></path>
4
4
  </svg>
5
- `,category:"Extra",content:{type:r},activate:!0,...e.block}),i.addType(r,{model:{defaults:{tagName:"div",attributes:{class:r,"data-type-role":r},components:[{type:s},{type:u}],draggable:Xo("wrapper"),droppable:Xo(r),styles:`
6
- .${r} {
5
+ `,category:"Extra",content:{type:s},activate:!0,...e.block}),i.addType(s,{model:{defaults:{tagName:"div",attributes:{class:s,"data-type-role":s},components:[{type:r},{type:u}],draggable:Qo("wrapper"),droppable:Qo(s),styles:`
6
+ .${s} {
7
7
  position: relative;
8
8
  z-index: 1;
9
9
  }
10
- `,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(p){var m;(m=p.getSelected())==null||m.trigger("active")}},{type:"checkbox",label:"Close when pressing X",name:"closeWhenPressingX",default:!0,changeProp:!0},{type:"checkbox",label:"Close when pressing ESC",name:"closeWhenPressingEsc",default:!0,changeProp:!0},{type:"checkbox",label:"Open when leaving the window",name:"openWhenLeavingWindow",default:!1,changeProp:!0},{type:"number",label:"Open when scrolling to level",name:"openWhenScrollingToLevel",default:0,changeProp:!0}],"script-props":["closeWhenPressingX","closeWhenPressingEsc","openWhenLeavingWindow","openWhenScrollingToLevel"],script:function(p){const m=this;function g(S){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),k=m.querySelector('[data-type-role="gjs-plg-dialog-close"]');function A(){v.style.display="none"}S?(m._onCloseWhenPressingX=A,k.addEventListener("click",m._onCloseWhenPressingX)):(k.removeEventListener("click",m._onCloseWhenPressingX),m._onCloseWhenPressingX=null)}function y(S){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function k(A){A.key==="Escape"&&(v.style.display="none")}S?(m._onCloseWhenPressingEsc=k,m.addEventListener("keydown",m._onCloseWhenPressingEsc)):(m.removeEventListener("keydown",m._onCloseWhenPressingEsc),m._onCloseWhenPressingEsc=null)}function x(S){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function k(){v.style.display="flex"}S?(m._onOpenWhenLeavingWindow=k,document.addEventListener("mouseleave",m._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",m._onOpenWhenLeavingWindow),m._onOpenWhenLeavingWindow=null)}function b(S){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function k(){const A=document.documentElement.scrollTop;S&&A>=Number(S)&&(v.style.display="flex")}S?(m._onOpenWhenScrollingToLevel=k,document.addEventListener("scroll",m._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",m._onOpenWhenScrollingToLevel),m._onOpenWhenScrollingToLevel=null)}g(p.closeWhenPressingX),y(p.closeWhenPressingEsc),x(p.openWhenLeavingWindow),b(p.openWhenScrollingToLevel)}},init(){this.on("active",this.handleOpenWhenClickPlaceholder)},handleOpenWhenClickPlaceholder(){this.view.el.querySelector('[data-type-role="gjs-plg-dialog-placeholder"]').addEventListener("click",()=>{const m=this.view.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');m.style.display="flex"})}},view:{onActive(){const p=this.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');p.style.display="flex"}}}),i.addType(s,{model:{defaults:{tagName:"div",attributes:{class:s,"data-type-role":s},components:{type:l},droppable:!1,draggable:!1,styles:`
11
- .${s} {
10
+ `,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(p){var m;(m=p.getSelected())==null||m.trigger("active")}},{type:"checkbox",label:"Close when pressing X",name:"closeWhenPressingX",default:!0,changeProp:!0},{type:"checkbox",label:"Close when pressing ESC",name:"closeWhenPressingEsc",default:!0,changeProp:!0},{type:"checkbox",label:"Open when leaving the window",name:"openWhenLeavingWindow",default:!1,changeProp:!0},{type:"number",label:"Open when scrolling to level",name:"openWhenScrollingToLevel",default:0,changeProp:!0}],"script-props":["closeWhenPressingX","closeWhenPressingEsc","openWhenLeavingWindow","openWhenScrollingToLevel"],script:function(p){const m=this;function g(v){const S=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),k=m.querySelector('[data-type-role="gjs-plg-dialog-close"]');function T(){S.style.display="none"}v?(m._onCloseWhenPressingX=T,k.addEventListener("click",m._onCloseWhenPressingX)):(k.removeEventListener("click",m._onCloseWhenPressingX),m._onCloseWhenPressingX=null)}function b(v){const S=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function k(T){T.key==="Escape"&&(S.style.display="none")}v?(m._onCloseWhenPressingEsc=k,m.addEventListener("keydown",m._onCloseWhenPressingEsc)):(m.removeEventListener("keydown",m._onCloseWhenPressingEsc),m._onCloseWhenPressingEsc=null)}function x(v){const S=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function k(){S.style.display="flex"}v?(m._onOpenWhenLeavingWindow=k,document.addEventListener("mouseleave",m._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",m._onOpenWhenLeavingWindow),m._onOpenWhenLeavingWindow=null)}function y(v){const S=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function k(){const T=document.documentElement.scrollTop;v&&T>=Number(v)&&(S.style.display="flex")}v?(m._onOpenWhenScrollingToLevel=k,document.addEventListener("scroll",m._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",m._onOpenWhenScrollingToLevel),m._onOpenWhenScrollingToLevel=null)}g(p.closeWhenPressingX),b(p.closeWhenPressingEsc),x(p.openWhenLeavingWindow),y(p.openWhenScrollingToLevel)}},init(){this.on("active",this.handleOpenWhenClickPlaceholder)},handleOpenWhenClickPlaceholder(){this.view.el.querySelector('[data-type-role="gjs-plg-dialog-placeholder"]').addEventListener("click",()=>{const m=this.view.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');m.style.display="flex"})}},view:{onActive(){const p=this.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');p.style.display="flex"}}}),i.addType(r,{model:{defaults:{tagName:"div",attributes:{class:r,"data-type-role":r},components:{type:l},droppable:!1,draggable:!1,styles:`
11
+ .${r} {
12
12
  position: fixed;
13
13
  top: 0;
14
14
  left: 0;
@@ -56,24 +56,24 @@
56
56
  .${h} {
57
57
  margin: 0;
58
58
  }
59
- `}}}),i.addType(u,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:u,"data-type-role":u},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){const{em:p,el:m}=this,g="core:preview",y=p.Commands.events;this.listenTo(p,`${y.runCommand}${g}`,()=>{m.style.display="none"}),this.listenTo(p,`${y.stopCommand}${g}`,()=>{m.style.display=""})}}}),Ae({editor:n,licenseKey:o,plan:ee.startup,pluginName:pc,cleanup:()=>{t.remove(r),i.removeType(r)}})},gc=Me(mc),yc={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},vi=`<svg viewBox="0 0 24 24">
59
+ `}}}),i.addType(u,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:u,"data-type-role":u},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){const{em:p,el:m}=this,g="core:preview",b=p.Commands.events;this.listenTo(p,`${b.runCommand}${g}`,()=>{m.style.display="none"}),this.listenTo(p,`${b.stopCommand}${g}`,()=>{m.style.display=""})}}}),Se({editor:n,licenseKey:o,plan:Z.startup,pluginName:pc,cleanup:()=>{t.remove(s),i.removeType(s)}})},gc=ve(mc),yc={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},Si=`<svg viewBox="0 0 24 24">
60
60
  <path d="M19 0H9C7.9 0 7 .9 7 2V18C7 19.1 7.9 20 9 20H19C20.1 20 21 19.1 21 18V2C21 .9 20.1 0 19 0M19 18H9V2H19V18M3 4V22C3 23.1 3.9 24 5 24H17V22H5V4H3M14 5L11 10L14 15L17 10L14 5Z" />
61
- </svg>`,Ks="layout-icon-picker",bc="icons-layout-",qs="icons-list-layout",js="gs-iconify-picker",To="__iconify_collection",wc="https://api.iconify.design",xi=new Map;let kn;const Sc=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function Js({collectionId:n,editor:e}){try{if(xi.has(n))return xi.get(n);const t=await fetch(Sc({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const i=await t.json();return xi.set(n,i),i}catch(t){console.error("Error fetching collection",t),e.runCommand(Y.toastAdd,Oc());return}}async function vc({collectionIds:n,editor:e}){try{if(kn)return kn;const t=n?`?prefixes=${n.join(",")}`:"",i=await fetch(`${wc}/collections${t}`);if(!i.ok)throw new Error(`Failed to fetch collections: ${i.statusText}`);return kn=await i.json(),kn}catch(t){console.error("Error fetching collections",t),e.runCommand(Y.toastAdd,Gs());return}}function Qo(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function xc({collectionIds:n,editor:e,component:t}){const i=await vc({collectionIds:n,editor:e});if(!i)return;const o=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},r=Object.entries(i).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),s=t.get("collectionId")??r[0].id;e.runCommand(Y.layoutToggle,{id:Ks,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[Tc({collectionsList:r,collectionId:s,editor:e,handleClick:o}),{id:qs,type:"column",grow:!0}]}});const l=await Js({collectionId:s,editor:e});l&&Ui({editor:e,collection:l,handleClick:o,collectionId:s})}function Cc({editor:n,collection:e}){n.em.set(To,e)}function kc(n){return n.em.get(To)}function Ui(n){const{editor:e}=n,t={id:bc,layout:Mc(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:qs}};e.runCommand(Y.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>e.runCommand(Y.layoutAdd,t),10)}function Tc(n){const{collectionsList:e,collectionId:t,editor:i,handleClick:o}=n,r=e.map(({id:s,name:l,total:a})=>({id:s,label:`${l} (${a})`})).sort((s,l)=>s.label.localeCompare(l.label));return{type:"column",style:{gap:10},className:`${js}__header`,children:[{type:"selectField",value:t,options:r,emptyState:"Select an icon collection",onChange:async({setState:s,value:l})=>{const a=await Js({collectionId:l,editor:i});a&&(s({value:l}),Cc({editor:i,collection:a}),Ui({editor:i,collection:a,handleClick:o,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${To}`]:({setState:s})=>s({value:""})},onInput:({setState:s,value:l,editor:a})=>{const c=kc(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([h])=>h.includes(l)));s({value:l}),Ui({editor:a,collection:c,handleClick:o,collectionId:l,collectionFiltered:{...c,icons:d}})}}]}}function Mc({collection:n,collectionFiltered:e,handleClick:t}){const{height:i=24,width:o=24,icons:r,prefix:s}=e||n,l=Object.entries(r).map(([a,{body:c}])=>({name:a,body:c}),{});return{type:"column",className:`${js}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>[{type:"custom",render:c=>{const{editor:d,addEl:h,removeEl:u}=c,f=document.createElementNS("http://www.w3.org/2000/svg","svg");f.setAttribute("xmlns","http://www.w3.org/2000/svg"),f.innerHTML=a.body,f.setAttribute("viewBox",`0 0 ${o} ${i}`);const{cssWidth:p,cssHeight:m}=Ac(o,i);f.style.cssText=`width: ${p}px; height: ${m}px; cursor: pointer;`,f.addEventListener("mouseover",()=>{f.style.border="2px solid currentColor",f.style.borderRadius="4px",f.style.padding="4px"}),f.addEventListener("mouseout",()=>{f.style.border="none"});const g=()=>{const y=f.cloneNode(!0);y.removeAttribute("style");const x=y.outerHTML;t({icon:x,collectionId:s,iconId:a.name}),d==null||d.runCommand(Y.layoutRemove,{id:Ks})};return f.addEventListener("click",g),h(f),()=>{f.removeEventListener("click",g),u(f)}}}]}}}function Ac(n,e){const t=n/e;let i=48,o=48;return t>1?o=48/t:t<1&&(i=48*t),{cssWidth:i,cssHeight:o}}function Gs(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:Ws.Error}}function Oc(){return{...Gs(),id:"toast-error-getCollection",content:"Error fetching collection"}}const Ec="iconifyComponent",Nc=function(n,e={}){var f;const{Components:t,Blocks:i}=n,{collections:o,extendIconComponent:r=!0,licenseKey:s,block:l={}}=e,a="icon",c="iconify",d="Iconify",h="data-type-iconify",u={events:()=>({dblclick:"onActive"}),onActive(){xc({collectionIds:o,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:vi,content:{type:c},category:"Extra",activate:!0,...l},isComponent:p=>zn(p,h),model:{defaults:{name:d,icon:vi,droppable:!1,attributes:{[h]:!0},resizable:yc,components:vi,style:{width:"50px",height:"50px"},traits:[Qo()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(p=>p.set({layerable:!1,locked:!0}))}},view:u}),r){const p=(f=t.getType(a))==null?void 0:f.model,[m,g,...y]=p.getDefaults().traits;t.addType(a,{model:{defaults:{traits:[m,g,Qo(),...y]}},view:u})}Ae({editor:n,licenseKey:s,plan:ee.startup,pluginName:Ec,cleanup:()=>{i.remove(c),t.removeType(c)}})},Dc=Me(Nc);function Us(n,e,t){let i,o,r,s,l;const a=e;function c(){const h=Date.now()-s;h<a&&h>=0?i=setTimeout(c,a-h):(i=null,l=n.apply(r,o),r=o=null)}const d=function(){return r=this,o=arguments,s=Date.now(),i||(i=setTimeout(c,a)),l};return d.clear=function(){i&&(clearTimeout(i),i=null)},d.flush=function(){i&&(l=n.apply(r,o),r=o=null,clearTimeout(i),i=null)},d}var T=(n=>(n.table="table",n.tableSettings="tableSettings",n.tableDelete="tableDelete",n.tableHead="tableHead",n.tableFoot="tableFoot",n.tableCellItems="tableCellItems",n.tableCellProperties="tableCellProperties",n.tableCellMerge="tableCellMerge",n.tableCellSplit="tableCellSplit",n.tableRowItems="tableRowItems",n.tableRowInsertBefore="tableRowInsertBefore",n.tableRowInsertAfter="tableRowInsertAfter",n.tableRowDelete="tableRowDelete",n.tableRowProperties="tableRowProperties",n.tableRowCut="tableRowCut",n.tableRowCopy="tableRowCopy",n.tableRowPasteBefore="tableRowPasteBefore",n.tableRowPasteAfter="tableRowPasteAfter",n.tableColumn="tableColumn",n.tableColumnItems="tableColumnItems",n.tableColumnInsertBefore="tableColumnInsertBefore",n.tableColumnInsertAfter="tableColumnInsertAfter",n.tableColumnDelete="tableColumnDelete",n.tableColumnCut="tableColumnCut",n.tableColumnCopy="tableColumnCopy",n.tableColumnPasteBefore="tableColumnPasteBefore",n.tableColumnPasteAfter="tableColumnPasteAfter",n))(T||{});const D={table:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableSettings:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 6v12h14V6H5z"/><path d="m14.4 8.6 1 1-2.3 2.4 2.3 2.4-1 1-2.4-2.3-2.4 2.3-1-1 2.3-2.4-2.3-2.4 1-1 2.4 2.3z"/></svg>',tableHead:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableFoot:'<svg viewBox="0 0 24 24" data-test="1" style="transform: rotate(180deg);"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableColumn:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm0 9h-4v5h4v-5Zm-6 0H9v5h4v-5Zm0-7H9v5h4V6Zm6 0h-4v5h4V6Z"/></svg>',tableCellItems:"",tableCellProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zm-8 9H5v5h6v-5zm8 0h-6v5h6v-5zm-8-7H5v5h6V6z"/></svg>',tableCellMerge:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zM5 16v2h3v-2H5zm14-5h-9v7h9v-7zm0-5h-4v3h4V6zM8 6H5v3h3V6zm5 0h-3v3h3V6zm-8 8h3v-3H5v3z"/></svg>',tableCellSplit:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM8 15.5H5V18h3v-2.5zm11-5h-9V18h9v-7.5zm-2.5 1 1 1-2 2 2 2-1 1-2-2-2 2-1-1 2-2-2-2 1-1 2 2 2-2zm-8.5-1H5v3h3v-3zM19 6h-4v2.5h4V6zM8 6H5v2.5h3V6zm5 0h-3v2.5h3V6z"/></svg>',tableRowItems:"",tableRowInsertBefore:'<svg viewBox="0 0 24 24"><path d="M6 4a1 1 0 1 1 0 2H5v6h14V6h-1a1 1 0 0 1 0-2h2c.6 0 1 .4 1 1v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-.6.4-1 1-1h2zm5 10H5v4h6v-4zm8 0h-6v4h6v-4zM12 3c.5 0 1 .4 1 .9V6h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 .1V8H9a1 1 0 0 1 0-2h2V4c0-.6.4-1 1-1z"/></svg>',tableRowInsertAfter:'<svg viewBox="0 0 24 24"><path d="M12 13c.5 0 1 .4 1 .9V16h2a1 1 0 0 1 .1 2H13v2a1 1 0 0 1-2 .1V18H9a1 1 0 0 1-.1-2H11v-2c0-.6.4-1 1-1zm6 7a1 1 0 0 1 0-2h1v-6H5v6h1a1 1 0 0 1 0 2H4a1 1 0 0 1-1-1V6c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v13c0 .5-.4 1-.9 1H18zM11 6H5v4h6V6zm8 0h-6v4h6V6z"/></svg>',tableRowDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm0 2H5v3h2.5v2H5v2h2.5v2H5v3h14v-3h-2.5v-2H19v-2h-2.5V9H19V6zm-4.7 1.8 1.2 1L13 12l2.6 3.3-1.2 1-2.3-3-2.3 3-1.2-1L11 12 8.5 8.7l1.2-1 2.3 3 2.3-3z"/></svg>',tableRowProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 15v3h6v-3H5zm14 0h-6v3h6v-3zm0-9h-6v3h6V6zM5 9h6V6H5v3z"/></svg>',tableRowCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M22 3v5H9l3 3 2-2h4l-4 4 1 1h.5c.4 0 .8 0 1.2.3.5.2.9.4 1.2.8.7.6 1 1.3 1 2.2.2.8 0 1.5-.6 2l-.8.5-1 .2c-.4 0-.8 0-1.2-.3a3.9 3.9 0 0 1-2.1-2.2c-.2-.5-.3-1-.2-1.5l-1-1-1 1c0 .5 0 1-.2 1.5-.1.5-.4 1-.9 1.4-.3.4-.7.6-1.2.8l-1.2.3c-.4 0-.7 0-1-.2-.3 0-.6-.3-.8-.5-.5-.5-.8-1.2-.7-2a3 3 0 0 1 1-2.2A3.7 3.7 0 0 1 8.6 14H9l1-1-4-4-.5-1a3.3 3.3 0 0 1 0-2c0-.4.3-.7.5-1l2 2V3h14zM8.5 15.3h-.3a2.6 2.6 0 0 0-.8.4 2.5 2.5 0 0 0-.9 1.1l-.1.4v.7l.2.5.5.2h.7a2.5 2.5 0 0 0 .8-.3L9 18l.4-.4.2-.4.1-.4v-.7a1 1 0 0 0-.2-.5 1 1 0 0 0-.4-.2h-.5zm7 0H15a1 1 0 0 0-.4.3 1 1 0 0 0-.2.5 1.5 1.5 0 0 0 0 .7v.4a2.8 2.8 0 0 0 .5.7h.1a2.8 2.8 0 0 0 .8.6l.4.1h.7l.5-.2.2-.5v-.7a2.6 2.6 0 0 0-.3-.8 2.4 2.4 0 0 0-.7-.7 2.5 2.5 0 0 0-.8-.3h-.3zM12 11.6c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zm8.5-7.1h-11v2h11v-2z"/></svg>',tableRowCopy:'<svg viewBox="0 0 24 24"><path d="M22 11v7H6v-7h16zm-2 2H8v3h12v-3zm-1-6v2H4v5H2V7h17z"/></svg>',tableRowPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h12v-4h2v4c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 7v5H8V8h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableRowPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V11h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h14c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 11v5H8v-5h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnItems:"",tableColumnInsertBefore:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a1 1 0 0 1-1-1v-2a1 1 0 0 1 2 0v1h8V6H5v1a1 1 0 1 1-2 0V5c0-.6.4-1 1-1h15zm0 9h-4v5h4v-5zM8 8c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H9v2a1 1 0 0 1-2 .1V13H5a1 1 0 0 1-.1-2H7V9c0-.6.4-1 1-1zm11-2h-4v5h4V6z"/></svg>',tableColumnInsertAfter:'<svg viewBox="0 0 24 24"><path d="M20 4c.6 0 1 .4 1 1v2a1 1 0 0 1-2 0V6h-8v12h8v-1a1 1 0 0 1 2 0v2c0 .5-.4 1-.9 1H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h15zM9 13H5v5h4v-5zm7-5c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H17v2a1 1 0 0 1-2 .1V13h-2a1 1 0 0 1-.1-2H15V9c0-.6.4-1 1-1zM9 6H5v5h4V6z"/></svg>',tableColumnDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm-4 4h-2V6h-2v2H9V6H5v12h4v-2h2v2h2v-2h2v2h4V6h-4v2zm.3.5 1 1.2-3 2.3 3 2.3-1 1.2L12 13l-3.3 2.6-1-1.2 3-2.3-3-2.3 1-1.2L12 11l3.3-2.5z"/></svg>',tableColumnCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M7.2 4.5a3 3 0 0 1 2.2 1A3.7 3.7 0 0 1 10.5 8v.5l1 1 4-4 1-.5a3.3 3.3 0 0 1 2 0c.4 0 .7.3 1 .5L17 8h4v13h-6V10l-1.5 1.5.5.5v4l-2.5-2.5-1 1v.5c0 .4 0 .8-.3 1.2-.2.5-.4.9-.8 1.2-.6.7-1.3 1-2.2 1-.8.2-1.5 0-2-.6l-.5-.8-.2-1c0-.4 0-.8.3-1.2A3.9 3.9 0 0 1 7 12.7c.5-.2 1-.3 1.5-.2l1-1-1-1c-.5 0-1 0-1.5-.2-.5-.1-1-.4-1.4-.9-.4-.3-.6-.7-.8-1.2L4.5 7c0-.4 0-.7.2-1 0-.3.3-.6.5-.8.5-.5 1.2-.8 2-.7zm12.3 5h-3v10h3v-10zM8 13.8h-.3l-.4.2a2.8 2.8 0 0 0-.7.4v.1a2.8 2.8 0 0 0-.6.8l-.1.4v.7l.2.5.5.2h.7a2.6 2.6 0 0 0 .8-.3 2.4 2.4 0 0 0 .7-.7 2.5 2.5 0 0 0 .3-.8 1.5 1.5 0 0 0 0-.8 1 1 0 0 0-.2-.4 1 1 0 0 0-.5-.2H8zm3.5-3.7c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zM7 5.8h-.4a1 1 0 0 0-.5.3 1 1 0 0 0-.2.5v.7a2.5 2.5 0 0 0 .3.8l.2.3h.1l.4.4.4.2.4.1h.7L9 9l.2-.4a1.6 1.6 0 0 0 0-.8 2.6 2.6 0 0 0-.3-.8 2.5 2.5 0 0 0-1.2-1l-.4-.1H7z"/></svg>',tableColumnCopy:'<svg viewBox="0 0 24 24"><path d="M17 6v16h-7V6h7zm-2 2h-3v12h3V8zm-2-6v2H8v15H6V2h7z"/></svg>',tableColumnPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V18c0 1-.8 2-1.9 2H11v-2h7V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v2H4V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm-2 7v12H4V8h6zM8.5 9.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h7v2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm8 7v12h-6V8h6zm-1.5 1.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>'},xe="table",Zs="thead",Ys="tfoot",Zi="tbody",se="row",B="cell",Mo="clipboardTable",Ic=[xe,Zs,Ys,Zi,se,B],ci=n=>n.em.get(Mo)||[],Pc=n=>n.every(e=>e.is(B)),Ao=(n,e)=>{const{editor:t,event:i,opts:o}=n,r=i.currentTarget||i.target,{x:s,y:l,width:a,height:c}=r.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:s,y:l,w:a,h:c},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...e};$s(o.openSettings)?o.openSettings({...n,layoutProps:d}):t.runCommand(Y.layoutToggle,d)},Rc=(n,{rows:e=1,cells:t=5,text:i}={})=>({type:n,components:Array.from(Array(e).keys()).map(o=>({type:se,components:Array.from(Array(t).keys()).map(r=>({type:B,components:i?{type:"text",content:$s(i)?i({y:o,x:r}):i}:void 0}))}))}),Xs="Table settings",Qs=n=>{const{component:e}=n;return e.is(xe)?e:e.closestType(xe)},Vc=n=>{var e;(e=Qs(n))==null||e.remove(n.opts)},Lc=n=>{const e=Qs(n);e&&(n.editor.select(e),Ao(n,{id:"tableSettings",header:{label:Xs}}))},el=n=>[{id:T.table,icon:D[T.table],label:"Table",items:[{id:T.tableSettings,label:Xs,icon:D[T.tableSettings],onClick:({event:t})=>Lc({...n,event:t})},{id:T.tableDelete,label:"Delete table",icon:D[T.tableDelete],onClick:()=>Vc(n)}]}],tl=({editor:n})=>{const e=ci(n);return e.length&&Pc(e)},er=({component:n,editor:e,after:t})=>{if(!n.is(B))return;const i=n.closestType(xe),o=n.closestType(se),r=n.index()+(t?1:0);i==null||i.findType(se).forEach(l=>l.append({type:B},{at:r}));const s=o==null?void 0:o.components().at(r);s&&e.select(s)},nl=({component:n,opts:e})=>{if(!n.is(B))return;const t=n.closestType(xe),i=n.index();t==null||t.findType(se).forEach(o=>{var r;return(r=o.components().at(i))==null?void 0:r.remove(e)})},il=({component:n,editor:e})=>{if(!n.is(B))return;const t=n.closestType(xe),i=n.index(),o=(t==null?void 0:t.findType(se).map(r=>r.components().at(i)))||[];o.length&&e.em.set(Mo,o)},tr=n=>{const{component:e,editor:t,after:i}=n;if(!e.is(B)||!tl(n))return;const o=ci(t),r=e.closestType(xe),s=e.index()+(i?1:0);r==null||r.findType(se).forEach((l,a)=>{const c=o[a],d=(c==null?void 0:c.clone())||{type:B};l.append(d,{at:s})})},zc=n=>{const{component:e}=n;e.is(B)&&(il(n),nl({...n,opts:{temporary:!0}}))},Bc=n=>{const e=tl(n);return[{id:T.tableColumnItems,icon:D[T.tableColumn],label:"Column",items:[{id:T.tableColumnInsertBefore,label:"Insert column before",icon:D[T.tableColumnInsertBefore],onClick:()=>er(n)},{id:T.tableColumnInsertAfter,label:"Insert column after",icon:D[T.tableColumnInsertAfter],onClick:()=>er({...n,after:!0})},{id:T.tableColumnDelete,label:"Delete column",icon:D[T.tableColumnDelete],onClick:()=>nl(n)},{id:T.tableColumnCut,label:"Cut column",icon:D[T.tableColumnCut],onClick:()=>zc(n)},{id:T.tableColumnCopy,label:"Copy column",icon:D[T.tableColumnCopy],onClick:()=>il(n)},{id:T.tableColumnPasteBefore,label:"Paste column before",icon:D[T.tableColumnPasteBefore],disabled:!e,onClick:()=>tr(n)},{id:T.tableColumnPasteAfter,label:"Paste column after",icon:D[T.tableColumnPasteAfter],disabled:!e,onClick:()=>tr({...n,after:!0})}]}]},ol="Row settings",Hc=n=>n.every(e=>e.is(se)),qt=n=>{const{component:e}=n,t=e.is(B),i=e.is(se);if(!(!t&&!i))return i?e:e.closestType(se)},nr=n=>{const{component:e,editor:t,after:i}=n,o=qt(n);if(!o)return;const r=o.index()+(i?1:0),s=o.components().length,l=Array.from(Array(s).keys()).map(()=>({type:B})),a=o.parent();if(a){const c=a.append({type:se,components:l},{at:r})[0];if(e.is(B)&&c){const d=e.index(),h=c.components().at(d);h&&t.select(h)}}},rl=n=>{var e;(e=qt(n))==null||e.remove(n.opts)},sl=n=>{const e=qt(n);e&&n.editor.em.set(Mo,[e])},ir=n=>{var l;const{editor:e,after:t}=n,i=qt(n);if(!i||!ll(n))return;const r=ci(e)[0],s=i.index()+(t?1:0);r&&((l=i.parent())==null||l.append(r.clone(),{at:s}))},Fc=n=>{qt(n)&&(sl(n),rl({...n,opts:{temporary:!0}}))},ll=({editor:n})=>{const e=ci(n);return e.length&&Hc(e)},$c=n=>{const e=qt(n);e&&(n.editor.select(e),Ao(n,{id:"tableRowSettings",header:{label:ol}}))},al=n=>{const e=ll(n);return[{id:T.tableRowItems,icon:D[T.tableRowProperties],label:"Row",items:[{id:T.tableRowInsertBefore,label:"Insert row before",icon:D[T.tableRowInsertBefore],onClick:()=>nr(n)},{id:T.tableRowInsertAfter,label:"Insert row after",icon:D[T.tableRowInsertAfter],onClick:()=>nr({...n,after:!0})},{id:T.tableRowDelete,label:"Delete row",icon:D[T.tableRowDelete],onClick:()=>rl(n)},{id:T.tableRowProperties,label:ol,icon:D[T.tableRowProperties],onClick:({event:i})=>$c({...n,event:i})},{id:T.tableRowCut,label:"Cut row",icon:D[T.tableRowCut],onClick:()=>Fc(n)},{id:T.tableRowCopy,label:"Copy row",icon:D[T.tableRowCopy],onClick:()=>sl(n)},{id:T.tableRowPasteBefore,label:"Paste row before",icon:D[T.tableRowPasteBefore],disabled:!e,onClick:()=>ir(n)},{id:T.tableRowPasteAfter,label:"Paste row after",icon:D[T.tableRowPasteAfter],disabled:!e,onClick:()=>ir({...n,after:!0})}]},...el(n)]},Oo=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),i=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:i}};function cl(n){const e=[];return n.components().forEach((t,i)=>{t.components().each((o,r)=>{const{rowspan:s,colspan:l}=Oo(o);if(e[i])for(;e[i][r];)r++;for(let a=i;a<i+s;a++){e[a]||(e[a]=[]);for(let c=r;c<r+l;c++)e[a][c]={real:a===i&&c===r,cell:o,rowspan:s,colspan:l}}})}),e}function Et(n,e,t){var i;return(i=n[t])==null?void 0:i[e]}const Yi=n=>n.closestType(se);function Wc(n,{x:e,y:t,rows:i,cols:o}){var l;let r=Yi(n[t][e].cell),s;for(let a=1;a<=i;a++)if(r=(l=r==null?void 0:r.parent())==null?void 0:l.components().at(r.index()+1),r){for(s=e;s>=0;s--){const{cell:c}=n[t+a][s],d=Yi(c);if(d===r){for(let h=1;h<=o;h++){const u=c.index();d.append({type:B},{at:u+1})}break}}if(s===-1){const d=r.components().at(0).index();for(let h=1;h<=o;h++)r.append({type:B},{at:d})}}}function dl(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const o=n[e][t].cell;if(o.em.selected.hasComponent(o)){const{rowspan:r,colspan:s}=Oo(o);if(s>1||r>1){o.addAttributes({colspan:1,rowspan:1});for(let l=0;l<s-1;l++){const a=o.index();Yi(o).append({type:B},{at:a+1})}Wc(n,{x:t,y:e,rows:r-1,cols:s})}}}}function _c(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const di=(n,e={})=>{var s;const t=cl(n),{em:i}=n;let o,r;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((s=e.selected)!=null&&s.includes(c.cell)||i.selected.hasComponent(c.cell)){const d={x:a,y:l};o||(o=d),r=d}}return{grid:t,startPos:o,endPos:r}};function Kc(n,e={}){const t=di(n),{startPos:i,endPos:o}=t;let{grid:r}=t;const{em:s}=n;if(!i||!o)return;const l=i.x,a=i.y,c=o.x,d=o.y,h=Et(r,l,a),u=Et(r,c,d);if(h&&u){dl(r),r=cl(n);const f=[],p=Et(r,l,a).cell;p.addAttributes({colspan:c-l+1,rowspan:d-a+1});for(let m=a;m<=d;m++)for(let g=l;g<=c;g++){const y=Et(r,g,m);if(!y)continue;const{cell:x}=y;x!==p&&f.push(x)}f.forEach(m=>{e.mergeContent&&p.append(m.components().models),m.remove()}),s.setSelected(p),_c(n)}}const hl="Cell settings",qc="Merge cells",jc="Split cell",Jc=n=>n.closestType(se),Bt=n=>{var e;return(e=Jc(n))==null?void 0:e.parent()},Gc=n=>{const e=n.editor.getSelectedAll(),t=Bt(e[0]),i=e[0];if(!t||!(i!=null&&i.is(B))||e.length>1)return!1;const{rowspan:o,colspan:r}=Oo(i);return!(r<2&&o<2)},Uc=n=>{const t=n.editor.getSelectedAll()[0],i=Bt(t),{grid:o}=di(i);dl(o)},ul=n=>{const e=n.editor.getSelectedAll(),t=Bt(e[0]);if(!t||e.length<2||e.some(l=>!l.is(B)||Bt(l)!==t))return!1;const{grid:i,startPos:o,endPos:r}=di(t),{em:s}=t;if(!o||!r)return!1;for(let l=o.y;l<=r.y;l++)for(let a=o.x;a<=r.x;a++){const c=Et(i,a,l);if(!c||!s.selected.hasComponent(c.cell))return!1}return!0},Zc=n=>{const{editor:e}=n;if(!ul(n))return;const t=e.getSelectedAll(),i=Bt(t[0]);Kc(i,{mergeContent:!0})},Yc=n=>{Ao(n,{id:"tableCellSettings",header:{label:hl}})},Xc=n=>[{id:T.tableCellItems,icon:D[T.tableCellProperties],label:"Cell",items:[{id:T.tableCellProperties,label:hl,icon:D[T.tableCellProperties],onClick:({event:t})=>Yc({...n,event:t})},{id:T.tableCellMerge,label:qc,icon:D[T.tableCellMerge],onClick:()=>Zc(n),disabled:!ul(n)},{id:T.tableCellSplit,label:jc,icon:D[T.tableCellSplit],onClick:()=>Uc(n),disabled:!Gc(n)}]},...Bc(n),...al(n)],Qc=n=>{const e=n[0]&&Bt(n[0]);if(!e)return;const{grid:t,startPos:i,endPos:o}=di(e,{selected:n});if(!i||!o)return;const r=[];for(let s=i.y;s<=o.y;s++)for(let l=i.x;l<=o.x;l++){const a=Et(t,l,s);a&&r.push(a.cell)}r.length&&e.em.setSelected(r,{fromCell:!0})},ed="tableComponent",td=function(n,e={}){const t={block:{},...e},{Components:i}=n,o={copyable:!1,emptyState:!0,highlightable:!1,stylable:["color","font-family","font-size","font-weight","line-height","text-align","vertical-align","background-color","border-width","border-style","border-color"]};i.addType(xe,{block:t.block&&{label:"Table",media:D.table,category:"Extra",content:{type:xe,style:{width:"100%"}},select:!0,...t.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:D.table,stylable:["width","height","margin","font-family","font-size","font-weight","line-height","text-align","background","background-color","border-width","border-style","border-color"],traits:[{type:"number",min:0,name:"cellspacing",label:"Cell spacing"},{type:"number",min:0,name:"cellpadding",label:"Cell padding"},{id:"tableCaption",type:"checkbox",label:"Caption",setValue({component:s,value:l,emitUpdate:a}){const c=s.find("caption")[0];l?!c&&s.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):c==null||c.remove(),a(),n.refresh({tools:!0})},getValue(s){return!!s.component.find("caption")[0]}}],components:Rc(Zi,{rows:5}),contextMenu:({items:s,editor:l,component:a})=>[...el({editor:l,component:a,opts:t}),...s]}}}),i.addType(Zs,{model:{defaults:{icon:D.tableHead,...o}}}),i.addType(Ys,{model:{defaults:{icon:D.tableFoot,...o}}}),i.addType(Zi,{model:{defaults:{icon:D.tableRowProperties,...o}}}),i.addType(se,{model:{defaults:{icon:D.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:s,editor:l,component:a})=>[...al({editor:l,component:a,opts:t}),...s]}}}),i.addType(B,{model:{defaults:{icon:D.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background-color","text-align","vertical-align","border-width","border-style","border-color"],traits:[{id:"tableCellType",type:"select",options:[{value:"td",name:"Cell"},{value:"th",name:"Header Cell"}],label:"Cell type",name:"tagName",changeProp:!0},{id:"tableCellScope",type:"select",options:[{value:!1,name:"None"},{value:"row",name:"Row"},{value:"col",name:"Column"},{value:"rowgroup",name:"Row group"},{value:"colgroup",name:"Column group"}],label:"Scope",name:"scope"}],contextMenu:({items:s,editor:l,component:a})=>[...Xc({editor:l,component:a,opts:t}),...s]}}});const r=Us((s,l)=>{var h;const a=n.getSelectedAll(),c=!!((h=l==null?void 0:l.event)!=null&&h.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(u=>u.is(B)?u:u.closestType(B)).filter(Boolean);d.length===a.length&&Qc(d)},0);n.on("component:select",r),Ae({editor:n,plan:ee.startup,licenseKey:t.licenseKey,pluginName:ed,cleanup:()=>{n.off("component:select",r),n.Blocks.remove(xe),Ic.forEach(s=>i.removeType(s))}})},nd=Me(td),or="page://",et="list-pages",St="list-pages-item",tt="list-pages-link",id=n=>n.components().reduce((e,t)=>{var s;const i=t.findFirstType(tt),o=(s=i==null?void 0:i.attributes.attributes)==null?void 0:s.href,r=o!=null&&o.startsWith(or)?o.replace(or,""):"";if(r&&i){const l=e[r];l?l.push(i):e[r]=[i]}return e},{}),od="listPagesComponent",Bn="data-type-role",rd="page_root",sd=n=>e=>e.is(n),ld=n=>(e,t)=>t.is(n),Ci=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,Bn))===n},ad=function(n,e={}){const{Blocks:t,Components:i,Pages:o}=n,{licenseKey:r,block:s={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${Gi}${et}`,h=`${Gi}${tt}`,u='<svg viewBox="0 0 24 24"><path d="M11 15H17V17H11V15M9 7H7V9H9V7M11 13H17V11H11V13M11 9H17V7H11V9M9 11H7V13H9V11M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H5V19H19V5M9 15H7V17H9V15Z"/></svg>',f='<svg viewBox="0 0 24 24"><path d="M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" /></svg>';i.addType(et,{block:s&&{label:l,media:u,category:"Extra",select:!0,...e.block},isComponent:Ci(et),model:{defaults:{tagName:"ul",name:l,[rd]:"",classes:d,attributes:{[Bn]:et},droppable:sd(St),styles:`
61
+ </svg>`,Kr="layout-icon-picker",bc="icons-layout-",qr="icons-list-layout",jr="gs-iconify-picker",Mo="__iconify_collection",wc="https://api.iconify.design",xi=new Map;let kn;const vc=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function Jr({collectionId:n,editor:e}){try{if(xi.has(n))return xi.get(n);const t=await fetch(vc({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const i=await t.json();return xi.set(n,i),i}catch(t){console.error("Error fetching collection",t),e.runCommand(X.toastAdd,Ec());return}}async function Sc({collectionIds:n,editor:e}){try{if(kn)return kn;const t=n?`?prefixes=${n.join(",")}`:"",i=await fetch(`${wc}/collections${t}`);if(!i.ok)throw new Error(`Failed to fetch collections: ${i.statusText}`);return kn=await i.json(),kn}catch(t){console.error("Error fetching collections",t),e.runCommand(X.toastAdd,Gr());return}}function es(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function xc({collectionIds:n,editor:e,component:t}){const i=await Sc({collectionIds:n,editor:e});if(!i)return;const o=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},s=Object.entries(i).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),r=t.get("collectionId")??s[0].id;e.runCommand(X.layoutToggle,{id:Kr,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[Tc({collectionsList:s,collectionId:r,editor:e,handleClick:o}),{id:qr,type:"column",grow:!0}]}});const l=await Jr({collectionId:r,editor:e});l&&Ui({editor:e,collection:l,handleClick:o,collectionId:r})}function Cc({editor:n,collection:e}){n.em.set(Mo,e)}function kc(n){return n.em.get(Mo)}function Ui(n){const{editor:e}=n,t={id:bc,layout:Mc(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:qr}};e.runCommand(X.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>e.runCommand(X.layoutAdd,t),10)}function Tc(n){const{collectionsList:e,collectionId:t,editor:i,handleClick:o}=n,s=e.map(({id:r,name:l,total:a})=>({id:r,label:`${l} (${a})`})).sort((r,l)=>r.label.localeCompare(l.label));return{type:"column",style:{gap:10},className:`${jr}__header`,children:[{type:"selectField",value:t,options:s,emptyState:"Select an icon collection",onChange:async({setState:r,value:l})=>{const a=await Jr({collectionId:l,editor:i});a&&(r({value:l}),Cc({editor:i,collection:a}),Ui({editor:i,collection:a,handleClick:o,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${Mo}`]:({setState:r})=>r({value:""})},onInput:({setState:r,value:l,editor:a})=>{const c=kc(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([h])=>h.includes(l)));r({value:l}),Ui({editor:a,collection:c,handleClick:o,collectionId:l,collectionFiltered:{...c,icons:d}})}}]}}function Mc({collection:n,collectionFiltered:e,handleClick:t}){const{height:i=24,width:o=24,icons:s,prefix:r}=e||n,l=Object.entries(s).map(([a,{body:c}])=>({name:a,body:c}),{});return{type:"column",className:`${jr}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>[{type:"custom",render:c=>{const{editor:d,addEl:h,removeEl:u}=c,f=document.createElementNS("http://www.w3.org/2000/svg","svg");f.setAttribute("xmlns","http://www.w3.org/2000/svg"),f.innerHTML=a.body,f.setAttribute("viewBox",`0 0 ${o} ${i}`);const{cssWidth:p,cssHeight:m}=Ac(o,i);f.style.cssText=`width: ${p}px; height: ${m}px; cursor: pointer;`,f.addEventListener("mouseover",()=>{f.style.border="2px solid currentColor",f.style.borderRadius="4px",f.style.padding="4px"}),f.addEventListener("mouseout",()=>{f.style.border="none"});const g=()=>{const b=f.cloneNode(!0);b.removeAttribute("style");const x=b.outerHTML;t({icon:x,collectionId:r,iconId:a.name}),d==null||d.runCommand(X.layoutRemove,{id:Kr})};return f.addEventListener("click",g),h(f),()=>{f.removeEventListener("click",g),u(f)}}}]}}}function Ac(n,e){const t=n/e;let i=48,o=48;return t>1?o=48/t:t<1&&(i=48*t),{cssWidth:i,cssHeight:o}}function Gr(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:Wr.Error}}function Ec(){return{...Gr(),id:"toast-error-getCollection",content:"Error fetching collection"}}const Oc="iconifyComponent",Nc=function(n,e={}){var f;const{Components:t,Blocks:i}=n,{collections:o,extendIconComponent:s=!0,licenseKey:r,block:l={}}=e,a="icon",c="iconify",d="Iconify",h="data-type-iconify",u={events:()=>({dblclick:"onActive"}),onActive(){xc({collectionIds:o,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:Si,content:{type:c},category:"Extra",activate:!0,...l},isComponent:p=>zn(p,h),model:{defaults:{name:d,icon:Si,droppable:!1,attributes:{[h]:!0},resizable:yc,components:Si,style:{width:"50px",height:"50px"},traits:[es()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(p=>p.set({layerable:!1,locked:!0}))}},view:u}),s){const p=(f=t.getType(a))==null?void 0:f.model,[m,g,...b]=p.getDefaults().traits;t.addType(a,{model:{defaults:{traits:[m,g,es(),...b]}},view:u})}Se({editor:n,licenseKey:r,plan:Z.startup,pluginName:Oc,cleanup:()=>{i.remove(c),t.removeType(c)}})},Dc=ve(Nc);function Ur(n,e,t){let i,o,s,r,l;const a=e;function c(){const h=Date.now()-r;h<a&&h>=0?i=setTimeout(c,a-h):(i=null,l=n.apply(s,o),s=o=null)}const d=function(){return s=this,o=arguments,r=Date.now(),i||(i=setTimeout(c,a)),l};return d.clear=function(){i&&(clearTimeout(i),i=null)},d.flush=function(){i&&(l=n.apply(s,o),s=o=null,clearTimeout(i),i=null)},d}var A=(n=>(n.table="table",n.tableSettings="tableSettings",n.tableDelete="tableDelete",n.tableHead="tableHead",n.tableFoot="tableFoot",n.tableCellItems="tableCellItems",n.tableCellProperties="tableCellProperties",n.tableCellMerge="tableCellMerge",n.tableCellSplit="tableCellSplit",n.tableRowItems="tableRowItems",n.tableRowInsertBefore="tableRowInsertBefore",n.tableRowInsertAfter="tableRowInsertAfter",n.tableRowDelete="tableRowDelete",n.tableRowProperties="tableRowProperties",n.tableRowCut="tableRowCut",n.tableRowCopy="tableRowCopy",n.tableRowPasteBefore="tableRowPasteBefore",n.tableRowPasteAfter="tableRowPasteAfter",n.tableColumn="tableColumn",n.tableColumnItems="tableColumnItems",n.tableColumnInsertBefore="tableColumnInsertBefore",n.tableColumnInsertAfter="tableColumnInsertAfter",n.tableColumnDelete="tableColumnDelete",n.tableColumnCut="tableColumnCut",n.tableColumnCopy="tableColumnCopy",n.tableColumnPasteBefore="tableColumnPasteBefore",n.tableColumnPasteAfter="tableColumnPasteAfter",n))(A||{});const D={table:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableSettings:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 6v12h14V6H5z"/><path d="m14.4 8.6 1 1-2.3 2.4 2.3 2.4-1 1-2.4-2.3-2.4 2.3-1-1 2.3-2.4-2.3-2.4 1-1 2.4 2.3z"/></svg>',tableHead:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableFoot:'<svg viewBox="0 0 24 24" data-test="1" style="transform: rotate(180deg);"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableColumn:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm0 9h-4v5h4v-5Zm-6 0H9v5h4v-5Zm0-7H9v5h4V6Zm6 0h-4v5h4V6Z"/></svg>',tableCellItems:"",tableCellProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zm-8 9H5v5h6v-5zm8 0h-6v5h6v-5zm-8-7H5v5h6V6z"/></svg>',tableCellMerge:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zM5 16v2h3v-2H5zm14-5h-9v7h9v-7zm0-5h-4v3h4V6zM8 6H5v3h3V6zm5 0h-3v3h3V6zm-8 8h3v-3H5v3z"/></svg>',tableCellSplit:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM8 15.5H5V18h3v-2.5zm11-5h-9V18h9v-7.5zm-2.5 1 1 1-2 2 2 2-1 1-2-2-2 2-1-1 2-2-2-2 1-1 2 2 2-2zm-8.5-1H5v3h3v-3zM19 6h-4v2.5h4V6zM8 6H5v2.5h3V6zm5 0h-3v2.5h3V6z"/></svg>',tableRowItems:"",tableRowInsertBefore:'<svg viewBox="0 0 24 24"><path d="M6 4a1 1 0 1 1 0 2H5v6h14V6h-1a1 1 0 0 1 0-2h2c.6 0 1 .4 1 1v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-.6.4-1 1-1h2zm5 10H5v4h6v-4zm8 0h-6v4h6v-4zM12 3c.5 0 1 .4 1 .9V6h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 .1V8H9a1 1 0 0 1 0-2h2V4c0-.6.4-1 1-1z"/></svg>',tableRowInsertAfter:'<svg viewBox="0 0 24 24"><path d="M12 13c.5 0 1 .4 1 .9V16h2a1 1 0 0 1 .1 2H13v2a1 1 0 0 1-2 .1V18H9a1 1 0 0 1-.1-2H11v-2c0-.6.4-1 1-1zm6 7a1 1 0 0 1 0-2h1v-6H5v6h1a1 1 0 0 1 0 2H4a1 1 0 0 1-1-1V6c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v13c0 .5-.4 1-.9 1H18zM11 6H5v4h6V6zm8 0h-6v4h6V6z"/></svg>',tableRowDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm0 2H5v3h2.5v2H5v2h2.5v2H5v3h14v-3h-2.5v-2H19v-2h-2.5V9H19V6zm-4.7 1.8 1.2 1L13 12l2.6 3.3-1.2 1-2.3-3-2.3 3-1.2-1L11 12 8.5 8.7l1.2-1 2.3 3 2.3-3z"/></svg>',tableRowProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 15v3h6v-3H5zm14 0h-6v3h6v-3zm0-9h-6v3h6V6zM5 9h6V6H5v3z"/></svg>',tableRowCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M22 3v5H9l3 3 2-2h4l-4 4 1 1h.5c.4 0 .8 0 1.2.3.5.2.9.4 1.2.8.7.6 1 1.3 1 2.2.2.8 0 1.5-.6 2l-.8.5-1 .2c-.4 0-.8 0-1.2-.3a3.9 3.9 0 0 1-2.1-2.2c-.2-.5-.3-1-.2-1.5l-1-1-1 1c0 .5 0 1-.2 1.5-.1.5-.4 1-.9 1.4-.3.4-.7.6-1.2.8l-1.2.3c-.4 0-.7 0-1-.2-.3 0-.6-.3-.8-.5-.5-.5-.8-1.2-.7-2a3 3 0 0 1 1-2.2A3.7 3.7 0 0 1 8.6 14H9l1-1-4-4-.5-1a3.3 3.3 0 0 1 0-2c0-.4.3-.7.5-1l2 2V3h14zM8.5 15.3h-.3a2.6 2.6 0 0 0-.8.4 2.5 2.5 0 0 0-.9 1.1l-.1.4v.7l.2.5.5.2h.7a2.5 2.5 0 0 0 .8-.3L9 18l.4-.4.2-.4.1-.4v-.7a1 1 0 0 0-.2-.5 1 1 0 0 0-.4-.2h-.5zm7 0H15a1 1 0 0 0-.4.3 1 1 0 0 0-.2.5 1.5 1.5 0 0 0 0 .7v.4a2.8 2.8 0 0 0 .5.7h.1a2.8 2.8 0 0 0 .8.6l.4.1h.7l.5-.2.2-.5v-.7a2.6 2.6 0 0 0-.3-.8 2.4 2.4 0 0 0-.7-.7 2.5 2.5 0 0 0-.8-.3h-.3zM12 11.6c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zm8.5-7.1h-11v2h11v-2z"/></svg>',tableRowCopy:'<svg viewBox="0 0 24 24"><path d="M22 11v7H6v-7h16zm-2 2H8v3h12v-3zm-1-6v2H4v5H2V7h17z"/></svg>',tableRowPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h12v-4h2v4c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 7v5H8V8h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableRowPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V11h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h14c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 11v5H8v-5h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnItems:"",tableColumnInsertBefore:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a1 1 0 0 1-1-1v-2a1 1 0 0 1 2 0v1h8V6H5v1a1 1 0 1 1-2 0V5c0-.6.4-1 1-1h15zm0 9h-4v5h4v-5zM8 8c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H9v2a1 1 0 0 1-2 .1V13H5a1 1 0 0 1-.1-2H7V9c0-.6.4-1 1-1zm11-2h-4v5h4V6z"/></svg>',tableColumnInsertAfter:'<svg viewBox="0 0 24 24"><path d="M20 4c.6 0 1 .4 1 1v2a1 1 0 0 1-2 0V6h-8v12h8v-1a1 1 0 0 1 2 0v2c0 .5-.4 1-.9 1H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h15zM9 13H5v5h4v-5zm7-5c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H17v2a1 1 0 0 1-2 .1V13h-2a1 1 0 0 1-.1-2H15V9c0-.6.4-1 1-1zM9 6H5v5h4V6z"/></svg>',tableColumnDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm-4 4h-2V6h-2v2H9V6H5v12h4v-2h2v2h2v-2h2v2h4V6h-4v2zm.3.5 1 1.2-3 2.3 3 2.3-1 1.2L12 13l-3.3 2.6-1-1.2 3-2.3-3-2.3 1-1.2L12 11l3.3-2.5z"/></svg>',tableColumnCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M7.2 4.5a3 3 0 0 1 2.2 1A3.7 3.7 0 0 1 10.5 8v.5l1 1 4-4 1-.5a3.3 3.3 0 0 1 2 0c.4 0 .7.3 1 .5L17 8h4v13h-6V10l-1.5 1.5.5.5v4l-2.5-2.5-1 1v.5c0 .4 0 .8-.3 1.2-.2.5-.4.9-.8 1.2-.6.7-1.3 1-2.2 1-.8.2-1.5 0-2-.6l-.5-.8-.2-1c0-.4 0-.8.3-1.2A3.9 3.9 0 0 1 7 12.7c.5-.2 1-.3 1.5-.2l1-1-1-1c-.5 0-1 0-1.5-.2-.5-.1-1-.4-1.4-.9-.4-.3-.6-.7-.8-1.2L4.5 7c0-.4 0-.7.2-1 0-.3.3-.6.5-.8.5-.5 1.2-.8 2-.7zm12.3 5h-3v10h3v-10zM8 13.8h-.3l-.4.2a2.8 2.8 0 0 0-.7.4v.1a2.8 2.8 0 0 0-.6.8l-.1.4v.7l.2.5.5.2h.7a2.6 2.6 0 0 0 .8-.3 2.4 2.4 0 0 0 .7-.7 2.5 2.5 0 0 0 .3-.8 1.5 1.5 0 0 0 0-.8 1 1 0 0 0-.2-.4 1 1 0 0 0-.5-.2H8zm3.5-3.7c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zM7 5.8h-.4a1 1 0 0 0-.5.3 1 1 0 0 0-.2.5v.7a2.5 2.5 0 0 0 .3.8l.2.3h.1l.4.4.4.2.4.1h.7L9 9l.2-.4a1.6 1.6 0 0 0 0-.8 2.6 2.6 0 0 0-.3-.8 2.5 2.5 0 0 0-1.2-1l-.4-.1H7z"/></svg>',tableColumnCopy:'<svg viewBox="0 0 24 24"><path d="M17 6v16h-7V6h7zm-2 2h-3v12h3V8zm-2-6v2H8v15H6V2h7z"/></svg>',tableColumnPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V18c0 1-.8 2-1.9 2H11v-2h7V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v2H4V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm-2 7v12H4V8h6zM8.5 9.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h7v2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm8 7v12h-6V8h6zm-1.5 1.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>'},ke="table",Zr="thead",Yr="tfoot",Zi="tbody",re="row",B="cell",Ao="clipboardTable",Ic=[ke,Zr,Yr,Zi,re,B],ci=n=>n.em.get(Ao)||[],Pc=n=>n.every(e=>e.is(B)),Eo=(n,e)=>{const{editor:t,event:i,opts:o}=n,s=i.currentTarget||i.target,{x:r,y:l,width:a,height:c}=s.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:r,y:l,w:a,h:c},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...e};To(o.openSettings)?o.openSettings({...n,layoutProps:d}):t.runCommand(X.layoutToggle,d)},Rc=(n,{rows:e=1,cells:t=5,text:i}={})=>({type:n,components:Array.from(Array(e).keys()).map(o=>({type:re,components:Array.from(Array(t).keys()).map(s=>({type:B,components:i?{type:"text",content:To(i)?i({y:o,x:s}):i}:void 0}))}))}),Xr="Table settings",Qr=n=>{const{component:e}=n;return e.is(ke)?e:e.closestType(ke)},Vc=n=>{var e;(e=Qr(n))==null||e.remove(n.opts)},Lc=n=>{const e=Qr(n);e&&(n.editor.select(e),Eo(n,{id:"tableSettings",header:{label:Xr}}))},el=n=>[{id:A.table,icon:D[A.table],label:"Table",items:[{id:A.tableSettings,label:Xr,icon:D[A.tableSettings],onClick:({event:t})=>Lc({...n,event:t})},{id:A.tableDelete,label:"Delete table",icon:D[A.tableDelete],onClick:()=>Vc(n)}]}],tl=({editor:n})=>{const e=ci(n);return e.length&&Pc(e)},ts=({component:n,editor:e,after:t})=>{if(!n.is(B))return;const i=n.closestType(ke),o=n.closestType(re),s=n.index()+(t?1:0);i==null||i.findType(re).forEach(l=>l.append({type:B},{at:s}));const r=o==null?void 0:o.components().at(s);r&&e.select(r)},nl=({component:n,opts:e})=>{if(!n.is(B))return;const t=n.closestType(ke),i=n.index();t==null||t.findType(re).forEach(o=>{var s;return(s=o.components().at(i))==null?void 0:s.remove(e)})},il=({component:n,editor:e})=>{if(!n.is(B))return;const t=n.closestType(ke),i=n.index(),o=(t==null?void 0:t.findType(re).map(s=>s.components().at(i)))||[];o.length&&e.em.set(Ao,o)},ns=n=>{const{component:e,editor:t,after:i}=n;if(!e.is(B)||!tl(n))return;const o=ci(t),s=e.closestType(ke),r=e.index()+(i?1:0);s==null||s.findType(re).forEach((l,a)=>{const c=o[a],d=(c==null?void 0:c.clone())||{type:B};l.append(d,{at:r})})},zc=n=>{const{component:e}=n;e.is(B)&&(il(n),nl({...n,opts:{temporary:!0}}))},Bc=n=>{const e=tl(n);return[{id:A.tableColumnItems,icon:D[A.tableColumn],label:"Column",items:[{id:A.tableColumnInsertBefore,label:"Insert column before",icon:D[A.tableColumnInsertBefore],onClick:()=>ts(n)},{id:A.tableColumnInsertAfter,label:"Insert column after",icon:D[A.tableColumnInsertAfter],onClick:()=>ts({...n,after:!0})},{id:A.tableColumnDelete,label:"Delete column",icon:D[A.tableColumnDelete],onClick:()=>nl(n)},{id:A.tableColumnCut,label:"Cut column",icon:D[A.tableColumnCut],onClick:()=>zc(n)},{id:A.tableColumnCopy,label:"Copy column",icon:D[A.tableColumnCopy],onClick:()=>il(n)},{id:A.tableColumnPasteBefore,label:"Paste column before",icon:D[A.tableColumnPasteBefore],disabled:!e,onClick:()=>ns(n)},{id:A.tableColumnPasteAfter,label:"Paste column after",icon:D[A.tableColumnPasteAfter],disabled:!e,onClick:()=>ns({...n,after:!0})}]}]},ol="Row settings",Hc=n=>n.every(e=>e.is(re)),qt=n=>{const{component:e}=n,t=e.is(B),i=e.is(re);if(!(!t&&!i))return i?e:e.closestType(re)},is=n=>{const{component:e,editor:t,after:i}=n,o=qt(n);if(!o)return;const s=o.index()+(i?1:0),r=o.components().length,l=Array.from(Array(r).keys()).map(()=>({type:B})),a=o.parent();if(a){const c=a.append({type:re,components:l},{at:s})[0];if(e.is(B)&&c){const d=e.index(),h=c.components().at(d);h&&t.select(h)}}},sl=n=>{var e;(e=qt(n))==null||e.remove(n.opts)},rl=n=>{const e=qt(n);e&&n.editor.em.set(Ao,[e])},ss=n=>{var l;const{editor:e,after:t}=n,i=qt(n);if(!i||!ll(n))return;const s=ci(e)[0],r=i.index()+(t?1:0);s&&((l=i.parent())==null||l.append(s.clone(),{at:r}))},Fc=n=>{qt(n)&&(rl(n),sl({...n,opts:{temporary:!0}}))},ll=({editor:n})=>{const e=ci(n);return e.length&&Hc(e)},$c=n=>{const e=qt(n);e&&(n.editor.select(e),Eo(n,{id:"tableRowSettings",header:{label:ol}}))},al=n=>{const e=ll(n);return[{id:A.tableRowItems,icon:D[A.tableRowProperties],label:"Row",items:[{id:A.tableRowInsertBefore,label:"Insert row before",icon:D[A.tableRowInsertBefore],onClick:()=>is(n)},{id:A.tableRowInsertAfter,label:"Insert row after",icon:D[A.tableRowInsertAfter],onClick:()=>is({...n,after:!0})},{id:A.tableRowDelete,label:"Delete row",icon:D[A.tableRowDelete],onClick:()=>sl(n)},{id:A.tableRowProperties,label:ol,icon:D[A.tableRowProperties],onClick:({event:i})=>$c({...n,event:i})},{id:A.tableRowCut,label:"Cut row",icon:D[A.tableRowCut],onClick:()=>Fc(n)},{id:A.tableRowCopy,label:"Copy row",icon:D[A.tableRowCopy],onClick:()=>rl(n)},{id:A.tableRowPasteBefore,label:"Paste row before",icon:D[A.tableRowPasteBefore],disabled:!e,onClick:()=>ss(n)},{id:A.tableRowPasteAfter,label:"Paste row after",icon:D[A.tableRowPasteAfter],disabled:!e,onClick:()=>ss({...n,after:!0})}]},...el(n)]},Oo=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),i=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:i}};function cl(n){const e=[];return n.components().forEach((t,i)=>{t.components().each((o,s)=>{const{rowspan:r,colspan:l}=Oo(o);if(e[i])for(;e[i][s];)s++;for(let a=i;a<i+r;a++){e[a]||(e[a]=[]);for(let c=s;c<s+l;c++)e[a][c]={real:a===i&&c===s,cell:o,rowspan:r,colspan:l}}})}),e}function Ot(n,e,t){var i;return(i=n[t])==null?void 0:i[e]}const Yi=n=>n.closestType(re);function Wc(n,{x:e,y:t,rows:i,cols:o}){var l;let s=Yi(n[t][e].cell),r;for(let a=1;a<=i;a++)if(s=(l=s==null?void 0:s.parent())==null?void 0:l.components().at(s.index()+1),s){for(r=e;r>=0;r--){const{cell:c}=n[t+a][r],d=Yi(c);if(d===s){for(let h=1;h<=o;h++){const u=c.index();d.append({type:B},{at:u+1})}break}}if(r===-1){const d=s.components().at(0).index();for(let h=1;h<=o;h++)s.append({type:B},{at:d})}}}function dl(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const o=n[e][t].cell;if(o.em.selected.hasComponent(o)){const{rowspan:s,colspan:r}=Oo(o);if(r>1||s>1){o.addAttributes({colspan:1,rowspan:1});for(let l=0;l<r-1;l++){const a=o.index();Yi(o).append({type:B},{at:a+1})}Wc(n,{x:t,y:e,rows:s-1,cols:r})}}}}function _c(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const di=(n,e={})=>{var r;const t=cl(n),{em:i}=n;let o,s;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((r=e.selected)!=null&&r.includes(c.cell)||i.selected.hasComponent(c.cell)){const d={x:a,y:l};o||(o=d),s=d}}return{grid:t,startPos:o,endPos:s}};function Kc(n,e={}){const t=di(n),{startPos:i,endPos:o}=t;let{grid:s}=t;const{em:r}=n;if(!i||!o)return;const l=i.x,a=i.y,c=o.x,d=o.y,h=Ot(s,l,a),u=Ot(s,c,d);if(h&&u){dl(s),s=cl(n);const f=[],p=Ot(s,l,a).cell;p.addAttributes({colspan:c-l+1,rowspan:d-a+1});for(let m=a;m<=d;m++)for(let g=l;g<=c;g++){const b=Ot(s,g,m);if(!b)continue;const{cell:x}=b;x!==p&&f.push(x)}f.forEach(m=>{e.mergeContent&&p.append(m.components().models),m.remove()}),r.setSelected(p),_c(n)}}const hl="Cell settings",qc="Merge cells",jc="Split cell",Jc=n=>n.closestType(re),Bt=n=>{var e;return(e=Jc(n))==null?void 0:e.parent()},Gc=n=>{const e=n.editor.getSelectedAll(),t=Bt(e[0]),i=e[0];if(!t||!(i!=null&&i.is(B))||e.length>1)return!1;const{rowspan:o,colspan:s}=Oo(i);return!(s<2&&o<2)},Uc=n=>{const t=n.editor.getSelectedAll()[0],i=Bt(t),{grid:o}=di(i);dl(o)},ul=n=>{const e=n.editor.getSelectedAll(),t=Bt(e[0]);if(!t||e.length<2||e.some(l=>!l.is(B)||Bt(l)!==t))return!1;const{grid:i,startPos:o,endPos:s}=di(t),{em:r}=t;if(!o||!s)return!1;for(let l=o.y;l<=s.y;l++)for(let a=o.x;a<=s.x;a++){const c=Ot(i,a,l);if(!c||!r.selected.hasComponent(c.cell))return!1}return!0},Zc=n=>{const{editor:e}=n;if(!ul(n))return;const t=e.getSelectedAll(),i=Bt(t[0]);Kc(i,{mergeContent:!0})},Yc=n=>{Eo(n,{id:"tableCellSettings",header:{label:hl}})},Xc=n=>[{id:A.tableCellItems,icon:D[A.tableCellProperties],label:"Cell",items:[{id:A.tableCellProperties,label:hl,icon:D[A.tableCellProperties],onClick:({event:t})=>Yc({...n,event:t})},{id:A.tableCellMerge,label:qc,icon:D[A.tableCellMerge],onClick:()=>Zc(n),disabled:!ul(n)},{id:A.tableCellSplit,label:jc,icon:D[A.tableCellSplit],onClick:()=>Uc(n),disabled:!Gc(n)}]},...Bc(n),...al(n)],Qc=n=>{const e=n[0]&&Bt(n[0]);if(!e)return;const{grid:t,startPos:i,endPos:o}=di(e,{selected:n});if(!i||!o)return;const s=[];for(let r=i.y;r<=o.y;r++)for(let l=i.x;l<=o.x;l++){const a=Ot(t,l,r);a&&s.push(a.cell)}s.length&&e.em.setSelected(s,{fromCell:!0})},ed="tableComponent",td=function(n,e={}){const t={block:{},...e},{Components:i}=n,o={copyable:!1,emptyState:!0,highlightable:!1,stylable:["color","font-family","font-size","font-weight","line-height","text-align","vertical-align","background-color","border-width","border-style","border-color"]};i.addType(ke,{block:t.block&&{label:"Table",media:D.table,category:"Extra",content:{type:ke,style:{width:"100%"}},select:!0,...t.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:D.table,stylable:["width","height","margin","font-family","font-size","font-weight","line-height","text-align","background","background-color","border-width","border-style","border-color"],traits:[{type:"number",min:0,name:"cellspacing",label:"Cell spacing"},{type:"number",min:0,name:"cellpadding",label:"Cell padding"},{id:"tableCaption",type:"checkbox",label:"Caption",setValue({component:r,value:l,emitUpdate:a}){const c=r.find("caption")[0];l?!c&&r.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):c==null||c.remove(),a(),n.refresh({tools:!0})},getValue(r){return!!r.component.find("caption")[0]}}],components:Rc(Zi,{rows:5}),contextMenu:({items:r,editor:l,component:a})=>[...el({editor:l,component:a,opts:t}),...r]}}}),i.addType(Zr,{model:{defaults:{icon:D.tableHead,...o}}}),i.addType(Yr,{model:{defaults:{icon:D.tableFoot,...o}}}),i.addType(Zi,{model:{defaults:{icon:D.tableRowProperties,...o}}}),i.addType(re,{model:{defaults:{icon:D.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:r,editor:l,component:a})=>[...al({editor:l,component:a,opts:t}),...r]}}}),i.addType(B,{model:{defaults:{icon:D.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background-color","text-align","vertical-align","border-width","border-style","border-color"],traits:[{id:"tableCellType",type:"select",options:[{value:"td",name:"Cell"},{value:"th",name:"Header Cell"}],label:"Cell type",name:"tagName",changeProp:!0},{id:"tableCellScope",type:"select",options:[{value:!1,name:"None"},{value:"row",name:"Row"},{value:"col",name:"Column"},{value:"rowgroup",name:"Row group"},{value:"colgroup",name:"Column group"}],label:"Scope",name:"scope"}],contextMenu:({items:r,editor:l,component:a})=>[...Xc({editor:l,component:a,opts:t}),...r]}}});const s=Ur((r,l)=>{var h;const a=n.getSelectedAll(),c=!!((h=l==null?void 0:l.event)!=null&&h.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(u=>u.is(B)?u:u.closestType(B)).filter(Boolean);d.length===a.length&&Qc(d)},0);n.on("component:select",s),Se({editor:n,plan:Z.startup,licenseKey:t.licenseKey,pluginName:ed,cleanup:()=>{n.off("component:select",s),n.Blocks.remove(ke),Ic.forEach(r=>i.removeType(r))}})},nd=ve(td),rs="page://",et="list-pages",vt="list-pages-item",tt="list-pages-link",id=n=>n.components().reduce((e,t)=>{var r;const i=t.findFirstType(tt),o=(r=i==null?void 0:i.attributes.attributes)==null?void 0:r.href,s=o!=null&&o.startsWith(rs)?o.replace(rs,""):"";if(s&&i){const l=e[s];l?l.push(i):e[s]=[i]}return e},{}),od="listPagesComponent",Bn="data-type-role",sd="page_root",rd=n=>e=>e.is(n),ld=n=>(e,t)=>t.is(n),Ci=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,Bn))===n},ad=function(n,e={}){const{Blocks:t,Components:i,Pages:o}=n,{licenseKey:s,block:r={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${Gi}${et}`,h=`${Gi}${tt}`,u='<svg viewBox="0 0 24 24"><path d="M11 15H17V17H11V15M9 7H7V9H9V7M11 13H17V11H11V13M11 9H17V7H11V9M9 11H7V13H9V11M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H5V19H19V5M9 15H7V17H9V15Z"/></svg>',f='<svg viewBox="0 0 24 24"><path d="M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" /></svg>';i.addType(et,{block:r&&{label:l,media:u,category:"Extra",select:!0,...e.block},isComponent:Ci(et),model:{defaults:{tagName:"ul",name:l,[sd]:"",classes:d,attributes:{[Bn]:et},droppable:rd(vt),styles:`
62
62
  .${d} {
63
63
  list-style: none;
64
64
  margin: 0;
65
65
  padding: 0;
66
66
  }
67
- `},init(){this.syncPageItems=Us(this.syncPageItems.bind(this),0),this.listenTo(this.em,o.events.all,this.syncPageItems),this.syncPageItems()},syncPageItems(){if(n.Components.getSymbolInfo(this).isInstance)return;const p=this.em.Pages.getAll(),m=this.components(),g=id(this);p.forEach((y,x)=>{const b=y.id,S=y.getName(),v=g[b];v?v==null||v.forEach(k=>{k.getInnerHTML()!==S&&k.components(S)}):m.add({type:St,components:[{type:tt,attributes:{href:`page://${b}`},components:{type:"textnode",content:S}}]},{at:x})})}}}),i.addType(St,{isComponent:Ci(St),model:{defaults:{name:a,tagName:"li",icon:f,attributes:{[Bn]:St},components:{type:tt},draggable:ld(et)}}}),i.addType(tt,{extend:"link",isComponent:Ci(tt),model:{defaults:{removable:!1,copyable:!1,delegate:{move:p=>p.closestType(St)},name:c,classes:h,attributes:{[Bn]:tt},components:{type:"textnode",content:"Item"},styles:`
67
+ `},init(){this.syncPageItems=Ur(this.syncPageItems.bind(this),0),this.listenTo(this.em,o.events.all,this.syncPageItems),this.syncPageItems()},syncPageItems(){if(n.Components.getSymbolInfo(this).isInstance)return;const p=this.em.Pages.getAll(),m=this.components(),g=id(this);p.forEach((b,x)=>{const y=b.id,v=b.getName(),S=g[y];S?S==null||S.forEach(k=>{k.getInnerHTML()!==v&&k.components(v)}):m.add({type:vt,components:[{type:tt,attributes:{href:`page://${y}`},components:{type:"textnode",content:v}}]},{at:x})})}}}),i.addType(vt,{isComponent:Ci(vt),model:{defaults:{name:a,tagName:"li",icon:f,attributes:{[Bn]:vt},components:{type:tt},draggable:ld(et)}}}),i.addType(tt,{extend:"link",isComponent:Ci(tt),model:{defaults:{removable:!1,copyable:!1,delegate:{move:p=>p.closestType(vt)},name:c,classes:h,attributes:{[Bn]:tt},components:{type:"textnode",content:"Item"},styles:`
68
68
  .${h} {
69
69
  text-decoration: none;
70
70
  }
71
- `}}}),Ae({editor:n,licenseKey:r,plan:ee.startup,pluginName:od,cleanup:()=>{t.remove(et),i.removeType(et)}})},cd=Me(ad),dd="fsLightboxComponent",Tn="data-fslightbox",Mn="data-type",hd="fslightbox-open",vt="fslightbox",xt={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',imageLightbox:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},ud=function(n,e={}){const{Blocks:t,Components:i}=n,o="Lightbox",r=`${Gi}${vt}`,s={toolbarIconOpen:xt.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=s,d=function(x){const b=this,S="data-fslightbox",v=window,k=()=>{var R;const A=v.refreshFsLightbox;A==null||A();const L=b.getAttribute(S);if((R=v.fsLightboxInstances)==null||R[L],!v._isEditor)return;Array.from(document.querySelectorAll(`[${S}]`)).forEach(P=>{const V=P.onclick;P.onclick=function(J){J.preventDefault();const de=P;!de.__skipLb&&(V==null||V(J)),de.__skipLb=!0}})};if(v.refreshFsLightbox)k();else{const A=document.createElement("script");A.src=x.cdnScript,A.onload=k,document.head.appendChild(A)}},h=x=>({id:`${vt}-open-lb`,label:a,command:()=>{const b=x.getView();b==null||b.toggleLightbox()}}),u="source-type",f={type:"radio",name:u,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:xt.image},{id:"video",label:"Video",icon:xt.video},{id:"el",label:"Custom Element",icon:xt.external}],labelToTitle:!0},p={id:"href-image",name:"href",type:"file",label:"Source Image"},m={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},g={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},y={image:[p],video:[m],el:[g]};i.addType(vt,{block:l&&{label:o,media:xt.imageLightbox,category:"Extra",select:!0,...s.block},isComponent:x=>{var b;return(b=x.hasAttribute)==null?void 0:b.call(x,Tn)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:o,icon:xt.imageLightbox,classes:r,draggable:(x,b)=>!b.is(vt),attributes:{[Tn]:"lightbox",[Mn]:"image",href:c},components:{type:"image",src:c},script:d,cdnScript:s.cdnScript,"script-props":["attributes","cdnScript"],[u]:"image",traits:[f,{name:Tn,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(x,b){var v;const S=(v=b.target)==null?void 0:v.getView();S==null||S.toggleLightbox()}}],styles:`
72
- .${r} {
71
+ `}}}),Se({editor:n,licenseKey:s,plan:Z.startup,pluginName:od,cleanup:()=>{t.remove(et),i.removeType(et)}})},cd=ve(ad),dd="fsLightboxComponent",Tn="data-fslightbox",Mn="data-type",hd="fslightbox-open",St="fslightbox",xt={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',imageLightbox:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},ud=function(n,e={}){const{Blocks:t,Components:i}=n,o="Lightbox",s=`${Gi}${St}`,r={toolbarIconOpen:xt.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=r,d=function(x){const y=this,v="data-fslightbox",S=window,k=()=>{var P;const T=S.refreshFsLightbox;T==null||T();const V=y.getAttribute(v);if((P=S.fsLightboxInstances)==null||P[V],!S._isEditor)return;Array.from(document.querySelectorAll(`[${v}]`)).forEach(R=>{const L=R.onclick;R.onclick=function(J){J.preventDefault();const de=R;!de.__skipLb&&(L==null||L(J)),de.__skipLb=!0}})};if(S.refreshFsLightbox)k();else{const T=document.createElement("script");T.src=x.cdnScript,T.onload=k,document.head.appendChild(T)}},h=x=>({id:`${St}-open-lb`,label:a,command:()=>{const y=x.getView();y==null||y.toggleLightbox()}}),u="source-type",f={type:"radio",name:u,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:xt.image},{id:"video",label:"Video",icon:xt.video},{id:"el",label:"Custom Element",icon:xt.external}],labelToTitle:!0},p={id:"href-image",name:"href",type:"file",label:"Source Image"},m={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},g={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},b={image:[p],video:[m],el:[g]};i.addType(St,{block:l&&{label:o,media:xt.imageLightbox,category:"Extra",select:!0,...r.block},isComponent:x=>{var y;return(y=x.hasAttribute)==null?void 0:y.call(x,Tn)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:o,icon:xt.imageLightbox,classes:s,draggable:(x,y)=>!y.is(St),attributes:{[Tn]:"lightbox",[Mn]:"image",href:c},components:{type:"image",src:c},script:d,cdnScript:r.cdnScript,"script-props":["attributes","cdnScript"],[u]:"image",traits:[f,{name:Tn,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(x,y){var S;const v=(S=y.target)==null?void 0:S.getView();v==null||v.toggleLightbox()}}],styles:`
72
+ .${s} {
73
73
  display: inline-block;
74
74
  padding: 10px;
75
75
  }
76
- `},init(){const x=[u].map(b=>`change:${b}`).join(" ");this.on(x,this.updateTraits),this.on(`change:${u}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(x,b,S){if(S.adjust)return;const k=this.get(u)==="video"?"video":"image";this.addAttributes({[Mn]:k,href:""})},adjustSourceType(){const x=this.get(u),b=this.getAttributes().href||"",S={adjust:!0};if(x==="video"){const v=b.includes("youtube.com")?"youtube":"video";this.addAttributes({[Mn]:v},S)}else x!=="el"&&b.startsWith("#")?this.set(u,"el",S):x==="image"&&this.addAttributes({[Mn]:"image"},S)},updateTraits(x={}){const{changed:b}=this,{init:S}=x;if(b[f.name]||S){this.removeTrait([p.name,m.name,g.name]);const v=this.get(u)||"image",k=this.getTraitIndex(u)+1;this.addTrait(y[v],{at:k})}},initToolbar(){if(!a)return;const{toolbar:x}=this,b=h(this);!x.find(v=>v.id===b.id)&&(x==null||x.unshift(b))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:x,el:b,model:S}=this,{Canvas:v}=x,k=S.getAttributes()[Tn],{defaultView:A,documentElement:L}=b.ownerDocument,M=(P=A.fsLightboxInstances)==null?void 0:P[k];if(L.classList.contains(hd))M.close();else{b.__skipLb=!1;let V;M.props.onOpen=()=>{V=v.getSpots(),setTimeout(()=>v.removeSpots())},M.props.onClose=()=>{V.forEach(J=>v.addSpot(J.attributes))},b.click()}}}}),Ae({editor:n,plan:ee.startup,licenseKey:s.licenseKey,pluginName:dd,cleanup:()=>{t.remove(vt),i.removeType(vt)}})},fd=Me(ud);var Mt=(n=>(n.image="image",n.video="video",n.external="external",n))(Mt||{});const nt="lightGallery",rr=`${nt}-item`,Hn="data-lightgallery",sr=`${Hn}-item`,qn="toggle",rt={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},ki={propKeys:[],props:{},traits:[]},Jt=(n,e={})=>{var o;const t={},i=[];for(const r in n){const{value:s,...l}=n[r];i.push({id:r,name:r,changeProp:!0,category:e.category,...l}),t[r]=s;const{subTraits:a={}}=l;for(const c in l.subTraits)(o=a[c])==null||o.forEach(d=>{const h=d.id||d.name;t[h]=d.value})}return{propKeys:Object.keys(t),props:t,traits:i}},Xi=(n,e)=>{const t=n.getTrait(e),i=t.get("category"),o=t.get("subTraits")||{},s=(Object.values(o).flat()||[]).map(c=>c.id||c.name);n.removeTrait(s);const l=o[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:i,...c})),{at:a})},Ti=(n,e)=>{e.forEach(t=>{const i=n.getTrait(t);if(!i||!i.get("subTraits"))return;const o=i.changeProp?`change:${t}`:`change:attributes:${t}`;n.on(o,()=>Xi(n,t)),Xi(n,t)})},pd=(n,e,t)=>{const o=n.getTrait(e).get("subTraits")||{},s=(Object.values(o).flat()||[]).map(a=>{const c=a.name||a.id;return a.changeProp?`change:${c}`:`change:attributes:${c}`}),l=Array.from(new Set(s));l.length&&n.on(l.join(" "),t)},md={[qn]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var t,i;return(i=(t=e.target)==null?void 0:t.getView())==null?void 0:i.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:n})=>!!n.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:n})=>!!n.getTrait("closable").getValue(),value:!0}},gd={thumbnail:{category:{id:"thumbnail-options",label:"Thumbnail Options"},type:"checkbox",label:"Thumbnails",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"enableThumbDrag",label:"Thumbnail drag",tip:"Enable thumbnail drag on desktop",changeProp:!0,value:!0},{type:"checkbox",name:"enableThumbSwipe",label:"Thumbnail swipe",tip:"Enable thumbnail swipe on mobile devices",changeProp:!0,value:!0},{type:"select",name:"alignThumbnails",tip:"Position of thumbnails when the width of all thumbnails combined is less than the gallery's width",label:"Align Thumbnails",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"select",name:"currentPagerPosition",label:"Select thumbnail position",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"number",name:"thumbMargin",label:"Thumb margin",tip:"Spacing between each thumbnails",changeProp:!0,min:0,value:"5"},{type:"number",name:"thumbWidth",label:"Thumb width",tip:"Width of each thumbnails",changeProp:!0,min:0,value:"100"}]}}},yd={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},bd={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},ze="sourceType",An="data-iframe",Qi={name:"href",type:"file",label:"Image Source"},jn={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},eo={name:"data-poster",label:"Video Poster",type:"file"},lr={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},fl={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},wd={[qn]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var o,r;const t=e.target,i=(o=t==null?void 0:t.closestType(nt))==null?void 0:o.getView();if(i&&t){const s=((r=i.getLightGallery())==null?void 0:r.items)||[],l=Array.from(s).indexOf(t.getEl());l>=0&&i.toggleGallery(l)}}},[ze]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[Qi],video:[jn,eo],external:[lr]},options:[{id:"image",label:Qi.label||"",icon:rt.image},{id:"video",label:jn.label||"",icon:rt.video},{id:"external",label:lr.label||"",icon:rt.external}]},subHtml:fl},Sd="lightGalleryComponent",ar="lgThumbnail",vd="lgVideo",cr="lgAutoplay",dr="lgZoom",Ct="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",xd=function(n,e={}){const{Blocks:t,Components:i}=n,o="LightGallery",r="LightGallery Item",s={toolbarIconOpen:rt.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[ar,vd,cr,dr],cdnScript:[`${Ct}/lightgallery.min.js`,`${Ct}/plugins/thumbnail/lg-thumbnail.min.js`,`${Ct}/plugins/video/lg-video.min.js`,`${Ct}/plugins/autoplay/lg-autoplay.min.js`,`${Ct}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${Ct}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=s,d=function(b){const S=this,v=window,{plugins:k,cdnScript:A,cdnStyle:L,inline:M,lgLicenseKey:R,...P}=b||{},V=de=>isNaN(de)?void 0:parseInt(de,10),J=()=>{var xn;const de={...P,licenseKey:R,speed:V(P.speed),startAnimationDuration:V(P.startAnimationDuration),thumbMargin:V(P.thumbMargin),thumbWidth:V(P.thumbWidth),slideShowInterval:V(P.slideShowInterval),scale:V(P.scale),enableZoomAfter:V(P.enableZoomAfter),plugins:(k||[]).map(Cn=>v[Cn])};M&&(de.container=S,de.closable=!1);const Si=(xn=v.lightGallery)==null?void 0:xn.call(v,S,de);M&&Si.openGallery()};if(v.lightGallery)J();else{const{head:de}=document,Si=Array.isArray(A)?[...A]:[A],xn=Array.isArray(L)?[...L]:[L],Cn=Qe=>{if(Qe.length){const Le=document.createElement("link");Le.href=Qe.shift(),Le.rel="stylesheet",de.appendChild(Le),Cn(Qe)}},Go=Qe=>{if(Qe.length){const Le=document.createElement("script");Le.src=Qe.shift(),Le.onerror=Le.onload=Go.bind(null,Qe),de.appendChild(Le)}else J()};Cn(xn),Go(Si)}},h=b=>{const S=b.getTrait(qn);if(!a||!S)return;const{toolbar:v}=b,k={id:qn,label:a,command:()=>setTimeout(()=>S.runCommand(),100)};!v.find(L=>L.id===k.id)&&(v==null||v.unshift(k))};let u=[];const f=s.plugins||[],p=Jt(md),m=f.includes(ar)?Jt(gd):ki,g=f.includes(cr)?Jt(yd):ki,y=f.includes(dr)?Jt(bd):ki;i.addType(nt,{block:l&&{label:o,media:rt.gallery,category:"Extra",select:!0,...s.block},isComponent:b=>zn(b,Hn),extendFn:["init","initToolbar"],model:{defaults:{name:o,icon:rt.gallery,draggable:(b,S)=>!S.is(nt),attributes:{[Hn]:!0},components:{type:rr},script:d,selector:"",exThumbImage:"",cdnScript:s.cdnScript,cdnStyle:s.cdnStyle,plugins:s.plugins,lgLicenseKey:s.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...p.propKeys,...m.propKeys,...g.propKeys,...y.propKeys],...p.props,...m.props,...g.props,...y.props,traits:[...p.traits,...m.traits,...g.traits,...y.traits]},init(){Ti(this,["thumbnail"]),Ti(this,["autoplay"]),Ti(this,["zoom"])},initToolbar(){h(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,i.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const b=this.getLightGallery();b==null||b.destroy()},disableLgInCanvas(){const b=this.getLightGallery();b.lgOpened=!0},isInlineGallery(){var S;const b=this.getLightGallery();return((S=b==null?void 0:b.settings)==null?void 0:S.container)===this.el},onLgInit(b){this.el.__lg=b.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:b}=this,{Canvas:S}=b,v=this.getLightGallery();u=S.getSpots(),setTimeout(()=>S.removeSpots()),v.__lgOpened=!0},onLgClose(){const b=this.getLightGallery();u.forEach(S=>this.em.Canvas.addSpot(S.attributes)),u=[],b.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(b){const S=this.getLightGallery();if(S.__lgOpened)return S.closeGallery(!0);S.lgOpened=!1,S.openGallery(b)}}});const x=Jt(wd);i.addType(rr,{isComponent:b=>zn(b,sr)||b.tagName==="A"&&zn(b.parentElement,Hn),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:r,icon:rt.galleryItem,attributes:{[sr]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...x.props,traits:[...x.traits]},init(){const b=[ze].map(S=>`change:${S}`).join(" ");this.initSourceType(),this.on(b,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),pd(this,ze,this.triggerGalleryUpdate)},initToolbar(){h(this)},initScriptUpdate(){const b=[fl.name].map(S=>`change:attributes:${S}`).join(" ");this.on(b,this.triggerGalleryUpdate)},triggerGalleryUpdate(...b){var S;(S=this.closestType(nt))==null||S.__scriptPropsChange(...b)},updateTraits(b={}){const{changed:S}=this,{init:v}=b;if(S[ze]||v){Xi(this,ze);const k=this.getTrait(ze).getValue();if(k===Mt.image){this.removeAttributes([jn.name,eo.name,An]);const A=this.getTrait(Qi.name);A.setValue(A.getValue()||c)}else k===Mt.video?this.removeAttributes([An]):k===Mt.external&&this.addAttributes({[An]:!0})}},initSourceType(){const b=this.getAttributes({noClass:!0,noStyle:!0});b[An]?this.set(ze,Mt.external):(b[jn.name]||b[eo.name])&&this.set(ze,Mt.video)}}}),Ae({editor:n,plan:ee.startup,licenseKey:s.licenseKey,pluginName:Sd,cleanup:()=>{t.remove(nt),i.removeType(nt)}})},Cd=Me(xd),be="swiper",an=`${be}-slide`,Dt=`${be}-wrapper`,It=`${be}-nav-prev`,Jn=`${be}-nav-next`,Pt=`${be}-pagination`,tn=`${be}-scrollbar`,Q={slider:`<svg viewBox="0 0 24 24">
76
+ `},init(){const x=[u].map(y=>`change:${y}`).join(" ");this.on(x,this.updateTraits),this.on(`change:${u}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(x,y,v){if(v.adjust)return;const k=this.get(u)==="video"?"video":"image";this.addAttributes({[Mn]:k,href:""})},adjustSourceType(){const x=this.get(u),y=this.getAttributes().href||"",v={adjust:!0};if(x==="video"){const S=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[Mn]:S},v)}else x!=="el"&&y.startsWith("#")?this.set(u,"el",v):x==="image"&&this.addAttributes({[Mn]:"image"},v)},updateTraits(x={}){const{changed:y}=this,{init:v}=x;if(y[f.name]||v){this.removeTrait([p.name,m.name,g.name]);const S=this.get(u)||"image",k=this.getTraitIndex(u)+1;this.addTrait(b[S],{at:k})}},initToolbar(){if(!a)return;const{toolbar:x}=this,y=h(this);!x.find(S=>S.id===y.id)&&(x==null||x.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var R;const{em:x,el:y,model:v}=this,{Canvas:S}=x,k=v.getAttributes()[Tn],{defaultView:T,documentElement:V}=y.ownerDocument,M=(R=T.fsLightboxInstances)==null?void 0:R[k];if(V.classList.contains(hd))M.close();else{y.__skipLb=!1;let L;M.props.onOpen=()=>{L=S.getSpots(),setTimeout(()=>S.removeSpots())},M.props.onClose=()=>{L.forEach(J=>S.addSpot(J.attributes))},y.click()}}}}),Se({editor:n,plan:Z.startup,licenseKey:r.licenseKey,pluginName:dd,cleanup:()=>{t.remove(St),i.removeType(St)}})},fd=ve(ud);var Mt=(n=>(n.image="image",n.video="video",n.external="external",n))(Mt||{});const nt="lightGallery",ls=`${nt}-item`,Hn="data-lightgallery",as=`${Hn}-item`,qn="toggle",st={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},ki={propKeys:[],props:{},traits:[]},Jt=(n,e={})=>{var o;const t={},i=[];for(const s in n){const{value:r,...l}=n[s];i.push({id:s,name:s,changeProp:!0,category:e.category,...l}),t[s]=r;const{subTraits:a={}}=l;for(const c in l.subTraits)(o=a[c])==null||o.forEach(d=>{const h=d.id||d.name;t[h]=d.value})}return{propKeys:Object.keys(t),props:t,traits:i}},Xi=(n,e)=>{const t=n.getTrait(e),i=t.get("category"),o=t.get("subTraits")||{},r=(Object.values(o).flat()||[]).map(c=>c.id||c.name);n.removeTrait(r);const l=o[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:i,...c})),{at:a})},Ti=(n,e)=>{e.forEach(t=>{const i=n.getTrait(t);if(!i||!i.get("subTraits"))return;const o=i.changeProp?`change:${t}`:`change:attributes:${t}`;n.on(o,()=>Xi(n,t)),Xi(n,t)})},pd=(n,e,t)=>{const o=n.getTrait(e).get("subTraits")||{},r=(Object.values(o).flat()||[]).map(a=>{const c=a.name||a.id;return a.changeProp?`change:${c}`:`change:attributes:${c}`}),l=Array.from(new Set(r));l.length&&n.on(l.join(" "),t)},md={[qn]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var t,i;return(i=(t=e.target)==null?void 0:t.getView())==null?void 0:i.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:n})=>!!n.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:n})=>!!n.getTrait("closable").getValue(),value:!0}},gd={thumbnail:{category:{id:"thumbnail-options",label:"Thumbnail Options"},type:"checkbox",label:"Thumbnails",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"enableThumbDrag",label:"Thumbnail drag",tip:"Enable thumbnail drag on desktop",changeProp:!0,value:!0},{type:"checkbox",name:"enableThumbSwipe",label:"Thumbnail swipe",tip:"Enable thumbnail swipe on mobile devices",changeProp:!0,value:!0},{type:"select",name:"alignThumbnails",tip:"Position of thumbnails when the width of all thumbnails combined is less than the gallery's width",label:"Align Thumbnails",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"select",name:"currentPagerPosition",label:"Select thumbnail position",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"number",name:"thumbMargin",label:"Thumb margin",tip:"Spacing between each thumbnails",changeProp:!0,min:0,value:"5"},{type:"number",name:"thumbWidth",label:"Thumb width",tip:"Width of each thumbnails",changeProp:!0,min:0,value:"100"}]}}},yd={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},bd={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},ze="sourceType",An="data-iframe",Qi={name:"href",type:"file",label:"Image Source"},jn={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},eo={name:"data-poster",label:"Video Poster",type:"file"},cs={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},fl={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},wd={[qn]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var o,s;const t=e.target,i=(o=t==null?void 0:t.closestType(nt))==null?void 0:o.getView();if(i&&t){const r=((s=i.getLightGallery())==null?void 0:s.items)||[],l=Array.from(r).indexOf(t.getEl());l>=0&&i.toggleGallery(l)}}},[ze]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[Qi],video:[jn,eo],external:[cs]},options:[{id:"image",label:Qi.label||"",icon:st.image},{id:"video",label:jn.label||"",icon:st.video},{id:"external",label:cs.label||"",icon:st.external}]},subHtml:fl},vd="lightGalleryComponent",ds="lgThumbnail",Sd="lgVideo",hs="lgAutoplay",us="lgZoom",Ct="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",xd=function(n,e={}){const{Blocks:t,Components:i}=n,o="LightGallery",s="LightGallery Item",r={toolbarIconOpen:st.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[ds,Sd,hs,us],cdnScript:[`${Ct}/lightgallery.min.js`,`${Ct}/plugins/thumbnail/lg-thumbnail.min.js`,`${Ct}/plugins/video/lg-video.min.js`,`${Ct}/plugins/autoplay/lg-autoplay.min.js`,`${Ct}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${Ct}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=r,d=function(y){const v=this,S=window,{plugins:k,cdnScript:T,cdnStyle:V,inline:M,lgLicenseKey:P,...R}=y||{},L=de=>isNaN(de)?void 0:parseInt(de,10),J=()=>{var xn;const de={...R,licenseKey:P,speed:L(R.speed),startAnimationDuration:L(R.startAnimationDuration),thumbMargin:L(R.thumbMargin),thumbWidth:L(R.thumbWidth),slideShowInterval:L(R.slideShowInterval),scale:L(R.scale),enableZoomAfter:L(R.enableZoomAfter),plugins:(k||[]).map(Cn=>S[Cn])};M&&(de.container=v,de.closable=!1);const vi=(xn=S.lightGallery)==null?void 0:xn.call(S,v,de);M&&vi.openGallery()};if(S.lightGallery)J();else{const{head:de}=document,vi=Array.isArray(T)?[...T]:[T],xn=Array.isArray(V)?[...V]:[V],Cn=Qe=>{if(Qe.length){const Le=document.createElement("link");Le.href=Qe.shift(),Le.rel="stylesheet",de.appendChild(Le),Cn(Qe)}},Uo=Qe=>{if(Qe.length){const Le=document.createElement("script");Le.src=Qe.shift(),Le.onerror=Le.onload=Uo.bind(null,Qe),de.appendChild(Le)}else J()};Cn(xn),Uo(vi)}},h=y=>{const v=y.getTrait(qn);if(!a||!v)return;const{toolbar:S}=y,k={id:qn,label:a,command:()=>setTimeout(()=>v.runCommand(),100)};!S.find(V=>V.id===k.id)&&(S==null||S.unshift(k))};let u=[];const f=r.plugins||[],p=Jt(md),m=f.includes(ds)?Jt(gd):ki,g=f.includes(hs)?Jt(yd):ki,b=f.includes(us)?Jt(bd):ki;i.addType(nt,{block:l&&{label:o,media:st.gallery,category:"Extra",select:!0,...r.block},isComponent:y=>zn(y,Hn),extendFn:["init","initToolbar"],model:{defaults:{name:o,icon:st.gallery,draggable:(y,v)=>!v.is(nt),attributes:{[Hn]:!0},components:{type:ls},script:d,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...p.propKeys,...m.propKeys,...g.propKeys,...b.propKeys],...p.props,...m.props,...g.props,...b.props,traits:[...p.traits,...m.traits,...g.traits,...b.traits]},init(){Ti(this,["thumbnail"]),Ti(this,["autoplay"]),Ti(this,["zoom"])},initToolbar(){h(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,i.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const y=this.getLightGallery();y==null||y.destroy()},disableLgInCanvas(){const y=this.getLightGallery();y.lgOpened=!0},isInlineGallery(){var v;const y=this.getLightGallery();return((v=y==null?void 0:y.settings)==null?void 0:v.container)===this.el},onLgInit(y){this.el.__lg=y.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:y}=this,{Canvas:v}=y,S=this.getLightGallery();u=v.getSpots(),setTimeout(()=>v.removeSpots()),S.__lgOpened=!0},onLgClose(){const y=this.getLightGallery();u.forEach(v=>this.em.Canvas.addSpot(v.attributes)),u=[],y.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(y){const v=this.getLightGallery();if(v.__lgOpened)return v.closeGallery(!0);v.lgOpened=!1,v.openGallery(y)}}});const x=Jt(wd);i.addType(ls,{isComponent:y=>zn(y,as)||y.tagName==="A"&&zn(y.parentElement,Hn),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:s,icon:st.galleryItem,attributes:{[as]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...x.props,traits:[...x.traits]},init(){const y=[ze].map(v=>`change:${v}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),pd(this,ze,this.triggerGalleryUpdate)},initToolbar(){h(this)},initScriptUpdate(){const y=[fl.name].map(v=>`change:attributes:${v}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var v;(v=this.closestType(nt))==null||v.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:v}=this,{init:S}=y;if(v[ze]||S){Xi(this,ze);const k=this.getTrait(ze).getValue();if(k===Mt.image){this.removeAttributes([jn.name,eo.name,An]);const T=this.getTrait(Qi.name);T.setValue(T.getValue()||c)}else k===Mt.video?this.removeAttributes([An]):k===Mt.external&&this.addAttributes({[An]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[An]?this.set(ze,Mt.external):(y[jn.name]||y[eo.name])&&this.set(ze,Mt.video)}}}),Se({editor:n,plan:Z.startup,licenseKey:r.licenseKey,pluginName:vd,cleanup:()=>{t.remove(nt),i.removeType(nt)}})},Cd=ve(xd),be="swiper",an=`${be}-slide`,Dt=`${be}-wrapper`,It=`${be}-nav-prev`,Jn=`${be}-nav-next`,Pt=`${be}-pagination`,tn=`${be}-scrollbar`,ee={slider:`<svg viewBox="0 0 24 24">
77
77
  <path d="M22 7.6c0-1-.5-1.6-1.3-1.6H3.4C2.5 6 2 6.7 2 7.6v9.8c0 1 .5 1.6 1.3 1.6h17.4c.8 0 1.3-.6 1.3-1.6V7.6zM21 18H3V7h18v11z" fill-rule="nonzero"/>
78
78
  <path d="M4 12.5L6 14v-3zM20 12.5L18 14v-3z"/>
79
79
  </svg>`,effect:`<svg viewBox="0 0 24 24">
@@ -96,34 +96,34 @@
96
96
  <path d="M2 12c0 5 4 9 9 9 2.4 0 4.7-1 6.4-2.6l-1.5-1.5A6.7 6.7 0 0 1 11 19a7 7 0 1 1 7-7h-3l4 4h.1l3.9-4h-3a9 9 0 0 0-18 0Z"/>
97
97
  </svg>`,prev:'<svg viewBox="0 0 24 24"><path d="M15.4 16.6 10.8 12l4.6-4.6L14 6l-6 6 6 6 1.4-1.4Z"/></svg>',next:'<svg viewBox="0 0 24 24"><path d="m8.6 16.6 4.6-4.6-4.6-4.6L10 6l6 6-6 6-1.4-1.4Z"/></svg>',add:`<svg viewBox="0 0 24 24">
98
98
  <path d="M12 20a8 8 0 1 1 0-16 8 8 0 0 1 0 16m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m1 5h-2v4H7v2h4v4h2v-4h4v-2h-4V7Z"/>
99
- </svg>`},hr={id:"swiper-responsive",label:"Responsive",icon:Q.responsive},ur={id:"swiper-extra",label:"Extra",icon:Q.extra},kd={actions:{type:"radio",label:!1,labelToTitle:!0,options:[{id:"r",label:"Reload slider",icon:Q.reload},{id:"p",label:"Previous slide",icon:Q.prev},{id:"n",label:"Next slide",icon:Q.next},{id:"a",label:"Add new slide",icon:Q.add}],setValue:({component:n,value:e})=>{var i;const t=(i=n.getView())==null?void 0:i.getSwiper();switch(e){case"r":n.reloadSlider();break;case"p":t==null||t.slidePrev();break;case"n":t==null||t.slideNext();break;case"a":n.addSlide();break}}},vertical:{type:"checkbox",label:"Vertical",value:!1},loop:{type:"checkbox",label:"Loop",value:!1},freeMode:{type:"checkbox",label:"Free mode",value:!1},autoHeight:{type:"checkbox",label:"Auto height",value:!1},navigation:{type:"checkbox",label:"Navigation",getValue:({component:n})=>!!n.findFirstType(It),setValue:({component:n,value:e})=>{var t,i;e?n.append([{type:It},{type:Jn}]):((t=n.findFirstType(It))==null||t.remove(),(i=n.findFirstType(Jn))==null||i.remove()),n.set({navigation:e})}},initialSlide:{type:"number",label:"Initial slide",min:0,value:"0"},speed:{type:"number",label:"Speed",tip:"Transition duration (in ms)",step:500,min:0,value:300},effect:{category:{id:"swiper-effect",label:"Effects",icon:Q.effect},type:"select",label:"Effect Type",value:"slide",options:[{id:"slide",label:"Slide"},{id:"fade",label:"Fade"},{id:"cube",label:"Cube"},{id:"coverflow",label:"Coverflow"},{id:"flip",label:"Flip"},{id:"cards",label:"Cards"}],subTraits:{slide:[{type:"number",name:"slidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"slidesPerGroup",label:"Slides per group",tip:"Numbers of slides for group sliding",changeProp:!0,min:1,value:1},{type:"number",name:"spaceBetween",label:"Space between",tip:"Distance between slides in px",changeProp:!0,min:0,value:0},{type:"number",name:"slidesOffsetBefore",label:"Slides offset before",tip:"Add additional slide offset in the beginning of the container (in px, before all slides)",changeProp:!0,min:0,value:0},{type:"number",name:"slidesOffsetAfter",label:"Slides offset after",tip:"Add additional slide offset in the end of the container (in px, after all slides)",changeProp:!0,min:0,value:0},{type:"checkbox",name:"centeredSlides",label:"Centered slides",tip:"If enabled, the active slide will be centered",changeProp:!0,value:!1}],fade:[{type:"checkbox",name:"crossFade",tip:"Enables slides cross fade",label:"Cross fade",changeProp:!0,value:!1}],cube:[{type:"checkbox",name:"cubeEffectShadow",label:"Shadow",changeProp:!0,value:!0},{type:"checkbox",name:"cubeEffectSlideShadows",label:"Slide shadows",changeProp:!0,value:!0},{type:"number",name:"cubeEffectShadowOffset",label:"Shadow offset",changeProp:!0,value:20},{type:"number",name:"cubeEffectShadowScale",label:"Shadow scale",changeProp:!0,value:.94}],coverflow:[{type:"number",name:"coverflowEffectDepth",tip:"Depth offset in px (slides translate in Z axis)",label:"Depth",changeProp:!0,min:0,value:100},{type:"number",name:"coverflowEffectModifier",tip:"Effect multiplier",label:"Modifier",changeProp:!0,step:.1,min:0,value:1},{type:"number",name:"coverflowEffectRotate",tip:"Slide rotate in degrees",label:"Rotate",changeProp:!0,min:0,value:50},{type:"number",name:"coverflowEffectScale",tip:"Slide scale effect",label:"Scale",changeProp:!0,min:0,step:.1,value:1},{type:"number",name:"coverflowEffectStretch",tip:"Stretch space between slides (in px)",label:"Stretch",changeProp:!0,min:0,value:0},{type:"checkbox",name:"coverflowEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadow",changeProp:!0,value:!0}],flip:[{type:"checkbox",name:"flipEffectLimitRotation",tip:"Limit edge slides rotation",label:"Limit rotation",changeProp:!0,value:!0},{type:"checkbox",name:"flipEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadows",changeProp:!0,value:!0}],cards:[{type:"number",name:"cardsEffectPerSlideOffset",tip:"Offset distance per slide (in px)",label:"Slide offset",changeProp:!0,min:0,value:8},{type:"number",name:"cardsEffectPerSlideRotate",tip:"Rotate angle per slide (in degrees)",label:"Slide rotate",changeProp:!0,min:0,value:2},{type:"checkbox",name:"cardsEffectRotate",tip:"Enables cards rotation",label:"Rotate",changeProp:!0,value:!0},{type:"checkbox",name:"cardsEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadows",changeProp:!0,value:!0}]}},autoplay:{category:{id:"swiper-autoplay",label:"Autoplay",icon:Q.autoplay},type:"checkbox",label:"Enable Autoplay",value:!1,subTraits:{true:[{type:"number",name:"autoplayDelay",label:"Delay",changeProp:!0,value:3e3},{type:"checkbox",name:"autoplayDisableOnInteraction",label:"Disable on interaction",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayWaitForTransition",label:"Wait for transition",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayPauseOnMouseEnter",label:"Pause on mouse enter",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayReverseDirection",label:"Reverse direction",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayStopOnLastSlide",label:"Stop on last slide",changeProp:!0,value:!1}]}},pagination:{category:{id:"swiper-pagination",label:"Pagination",icon:Q.pagination},type:"select",label:"Pagination Type",options:[{id:"none",label:"None"},{id:"bullets",label:"Bullets"},{id:"progressbar",label:"Progressbar"},{id:"fraction",label:"Fraction"}],getValue:({component:n})=>n.findFirstType(Pt)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(Pt);t==null||t.remove(),e!=="none"&&n.append({type:Pt}),n.set({pagination:e})},subTraits:{bullets:[{type:"checkbox",name:"dynamicBullets",label:"Dynamic bullets",changeProp:!0,value:!1},{type:"checkbox",name:"clickableBullets",label:"Clickable bullets",changeProp:!0,value:!0}],progressbar:[{type:"checkbox",name:"progressbarOpposite",label:"Progress opposite",changeProp:!0,value:!1}]}},scrollbar:{category:{id:"swiper-scrollbar",label:"Scrollbar",icon:Q.scrollbar},type:"checkbox",label:"Enable Scrollbar",getValue:({component:n})=>!!n.findFirstType(tn),setValue:({component:n,value:e})=>{const t=n.findFirstType(tn);t==null||t.remove(),e&&n.append({type:tn}),n.set({scrollbar:e})},subTraits:{false:[],true:[{type:"checkbox",name:"scrollbarDraggable",label:"Draggable",changeProp:!0,value:!1},{type:"checkbox",name:"scrollbarHide",label:"Hide",tip:"Hide scrollbar automatically after user interaction",changeProp:!0,value:!0}]}},parallax:{category:{id:"swiper-parallax",label:"Parallax",icon:Q.parallax},type:"checkbox",label:"Enable Parallax",value:!1},mobile:{category:hr,type:"checkbox",label:"Enable mobile breakpoint",value:!1,subTraits:{true:[{type:"number",name:"mobileBreakpoint",label:"Mobile breakpoint",tip:"Slide values below will be applied when the screen width is greater than this value",changeProp:!0,min:1,value:460},{type:"number",name:"mobileSlidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"mobileSlidesPerGroup",label:"Slides per group",changeProp:!0,min:1,value:1},{type:"number",name:"mobileSpaceBetween",label:"Space between",changeProp:!0,min:0,value:0}]}},tablet:{category:hr,type:"checkbox",label:"Enable tablet breakpoint",value:!1,subTraits:{true:[{type:"number",name:"tabletBreakpoint",label:"Tablet breakpoint",tip:"Slide values below will be applied when the screen width is greater than this value",changeProp:!0,min:1,value:991},{type:"number",name:"tabletSlidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"tabletSlidesPerGroup",label:"Slides per group",changeProp:!0,min:1,value:1},{type:"number",name:"tabletSpaceBetween",label:"Space between",changeProp:!0,min:0,value:0}]}},allowTouchMove:{category:ur,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:ur,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},fr="Slider",to="swiper",jt=`${to}-`,Td=(n,e)=>{const{Components:t,Blocks:i,Commands:o}=n,{block:r}=e,s=hc(kd),l="core:preview",a=o.events,c=function(u){const f=this,p=window,m=f.__onLoad,g=f.__activeSlide,y=f.__inPreview,{cdnScript:x,cdnStyle:b,slidesPerView:S}=u||{},v=A=>isNaN(A)?void 0:parseFloat(A),k=()=>{const A={loop:u.loop,speed:u.speed,initialSlide:u.initialSlide,direction:u.vertical?"vertical":"horizontal",effect:u.effect,freeMode:u.freeMode,parallax:u.parallax,autoHeight:u.autoHeight,allowTouchMove:u.allowTouchMove,grabCursor:u.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(S)?S:v(S),slidesPerGroup:v(u.slidesPerGroup),spaceBetween:v(u.spaceBetween),slidesOffsetBefore:v(u.slidesOffsetBefore),slidesOffsetAfter:v(u.slidesOffsetAfter),centeredSlides:u.centeredSlides,fadeEffect:{crossFade:u.crossFade},cubeEffect:{shadow:u.cubeEffectShadow,slideShadows:u.cubeEffectSlideShadows,shadowOffset:v(u.cubeEffectShadowOffset),shadowScale:v(u.cubeEffectShadowScale)},coverflowEffect:{depth:v(u.coverflowEffectDepth),modifier:v(u.coverflowEffectModifier),rotate:v(u.coverflowEffectRotate),scale:v(u.coverflowEffectScale),stretch:v(u.coverflowEffectStretch),slideShadows:u.coverflowEffectSlideShadows},flipEffect:{limitRotation:u.flipEffectLimitRotation,slideShadows:u.flipEffectSlideShadows},cardsEffect:{perSlideOffset:v(u.cardsEffectPerSlideOffset),perSlideRotate:v(u.cardsEffectPerSlideRotate),rotate:u.cardsEffectRotate,slideShadows:u.cardsEffectSlideShadows},navigation:{nextEl:f.querySelector(".swiper-button-next"),prevEl:f.querySelector(".swiper-button-prev")},pagination:{type:u.pagination||"bullets",dynamicBullets:u.dynamicBullets,clickable:u.clickableBullets,progressbarOpposite:u.progressbarOpposite,el:f.querySelector(".swiper-pagination")},scrollbar:{el:f.querySelector(".swiper-scrollbar"),draggable:u.scrollbarDraggable,hide:u.scrollbarHide},autoplay:u.autoplay&&{delay:u.autoplayDelay,disableOnInteraction:u.autoplayDisableOnInteraction,pauseOnMouseEnter:u.autoplayPauseOnMouseEnter,reverseDirection:u.autoplayReverseDirection,stopOnLastSlide:u.autoplayStopOnLastSlide,waitForTransition:u.autoplayWaitForTransition}};if(u.tablet){const{tabletBreakpoint:M,tabletSlidesPerView:R}=u,P=v(M);A.breakpoints[P]={slidesPerView:isNaN(R)?R:v(R),slidesPerGroup:v(u.tabletSlidesPerGroup),spaceBetween:v(u.tabletSpaceBetween)}}if(u.mobile){const{mobileBreakpoint:M,mobileSlidesPerView:R}=u,P=v(M);A.breakpoints[P]={slidesPerView:isNaN(R)?R:v(R),slidesPerGroup:v(u.mobileSlidesPerGroup),spaceBetween:v(u.mobileSpaceBetween)}}m&&!y&&(A.simulateTouch=!1),g&&(A.initialSlide=g);const L=new p.Swiper(f,A);m==null||m(L)};if(p.Swiper)k();else{const{head:A}=document,L=Array.isArray(x)?[...x]:[x],M=Array.isArray(b)?[...b]:[b],R=V=>{if(V.length){const J=document.createElement("link");J.href=V.shift(),J.rel="stylesheet",A.appendChild(J),R(V)}},P=V=>{if(V.length){const J=document.createElement("script");J.src=V.shift(),J.onerror=J.onload=P.bind(null,V),A.appendChild(J)}else k()};R(M),P(L)}},d=(u=0)=>({type:an,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${u}`}}}),h=t.getType("default").model;return t.addType(be,{block:r&&{label:fr,media:Q.slider,category:"Extra",select:!0,...e.block},isComponent:u=>mt(u,to),model:{defaults:()=>({name:fr,icon:Q.slider,classes:to,draggable:(u,f)=>!f.is(be),components:[{type:Dt,components:[d(1),d(2),d(3)]},{type:Pt}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...s.propKeys],...s.props,traits:[...s.traits]}),init(){const{em:u}=this;uc(this,s.traits),fc(this,s.propKeys),this.listenTo(u,`${a.runCommand}${l}`,this.onPreviewOn),this.listenTo(u,`${a.stopCommand}${l}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const u=this.findFirstType(Dt);u==null||u.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var f;const u=((f=this.findFirstType(Dt))==null?void 0:f.components().length)||0;return{type:an,components:{type:"text",components:{type:"textnode",content:`Slide ${u+1}`}}}},toJSON(...u){const f=h.prototype.toJSON.apply(this,u);return s.propsNoValues.forEach(p=>delete f[p]),delete f["script-props"],f}},view:{init(){this.listenTo(this.model,t.events.scriptUnmount,this.destroySwiper)},getSwiper(){return this.el.swiper},destroySwiper(){var u;(u=this.getSwiper())==null||u.destroy()},onRender(){const u=this.el;u.__onLoad=f=>f.on("slideChange",()=>this.__activeSlide=f.activeIndex),u.__activeSlide=this.__activeSlide,u.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(be),i.remove(be)}},Md="Nav Prev",Ad="Nav Next",On=`${jt}button-prev`,En=`${jt}button-next`,Od=n=>{const{Components:e}=n,t=i=>({type:"svg",selectable:!1,hoverable:!1,attributes:{viewBox:"0 0 27 44"},components:{type:"svg-in",tagName:"path",attributes:{d:i,fill:"currentColor"}}});return e.addType(It,{isComponent:i=>mt(i,On),model:{defaults:{name:Md,classes:On,copyable:!1,highlightable:!1,droppable:!1,draggable:!1,selectable:!1,hoverable:!1,layerable:!1,components:t("M0,22L22,0l2.1,2.1L4.2,22l19.9,19.9L22,44L0,22L0,22L0,22z"),styles:`
100
- .${On} {
99
+ </svg>`},fs={id:"swiper-responsive",label:"Responsive",icon:ee.responsive},ps={id:"swiper-extra",label:"Extra",icon:ee.extra},kd={actions:{type:"radio",label:!1,labelToTitle:!0,options:[{id:"r",label:"Reload slider",icon:ee.reload},{id:"p",label:"Previous slide",icon:ee.prev},{id:"n",label:"Next slide",icon:ee.next},{id:"a",label:"Add new slide",icon:ee.add}],setValue:({component:n,value:e})=>{var i;const t=(i=n.getView())==null?void 0:i.getSwiper();switch(e){case"r":n.reloadSlider();break;case"p":t==null||t.slidePrev();break;case"n":t==null||t.slideNext();break;case"a":n.addSlide();break}}},vertical:{type:"checkbox",label:"Vertical",value:!1},loop:{type:"checkbox",label:"Loop",value:!1},freeMode:{type:"checkbox",label:"Free mode",value:!1},autoHeight:{type:"checkbox",label:"Auto height",value:!1},navigation:{type:"checkbox",label:"Navigation",getValue:({component:n})=>!!n.findFirstType(It),setValue:({component:n,value:e})=>{var t,i;e?n.append([{type:It},{type:Jn}]):((t=n.findFirstType(It))==null||t.remove(),(i=n.findFirstType(Jn))==null||i.remove()),n.set({navigation:e})}},initialSlide:{type:"number",label:"Initial slide",min:0,value:"0"},speed:{type:"number",label:"Speed",tip:"Transition duration (in ms)",step:500,min:0,value:300},effect:{category:{id:"swiper-effect",label:"Effects",icon:ee.effect},type:"select",label:"Effect Type",value:"slide",options:[{id:"slide",label:"Slide"},{id:"fade",label:"Fade"},{id:"cube",label:"Cube"},{id:"coverflow",label:"Coverflow"},{id:"flip",label:"Flip"},{id:"cards",label:"Cards"}],subTraits:{slide:[{type:"number",name:"slidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"slidesPerGroup",label:"Slides per group",tip:"Numbers of slides for group sliding",changeProp:!0,min:1,value:1},{type:"number",name:"spaceBetween",label:"Space between",tip:"Distance between slides in px",changeProp:!0,min:0,value:0},{type:"number",name:"slidesOffsetBefore",label:"Slides offset before",tip:"Add additional slide offset in the beginning of the container (in px, before all slides)",changeProp:!0,min:0,value:0},{type:"number",name:"slidesOffsetAfter",label:"Slides offset after",tip:"Add additional slide offset in the end of the container (in px, after all slides)",changeProp:!0,min:0,value:0},{type:"checkbox",name:"centeredSlides",label:"Centered slides",tip:"If enabled, the active slide will be centered",changeProp:!0,value:!1}],fade:[{type:"checkbox",name:"crossFade",tip:"Enables slides cross fade",label:"Cross fade",changeProp:!0,value:!1}],cube:[{type:"checkbox",name:"cubeEffectShadow",label:"Shadow",changeProp:!0,value:!0},{type:"checkbox",name:"cubeEffectSlideShadows",label:"Slide shadows",changeProp:!0,value:!0},{type:"number",name:"cubeEffectShadowOffset",label:"Shadow offset",changeProp:!0,value:20},{type:"number",name:"cubeEffectShadowScale",label:"Shadow scale",changeProp:!0,value:.94}],coverflow:[{type:"number",name:"coverflowEffectDepth",tip:"Depth offset in px (slides translate in Z axis)",label:"Depth",changeProp:!0,min:0,value:100},{type:"number",name:"coverflowEffectModifier",tip:"Effect multiplier",label:"Modifier",changeProp:!0,step:.1,min:0,value:1},{type:"number",name:"coverflowEffectRotate",tip:"Slide rotate in degrees",label:"Rotate",changeProp:!0,min:0,value:50},{type:"number",name:"coverflowEffectScale",tip:"Slide scale effect",label:"Scale",changeProp:!0,min:0,step:.1,value:1},{type:"number",name:"coverflowEffectStretch",tip:"Stretch space between slides (in px)",label:"Stretch",changeProp:!0,min:0,value:0},{type:"checkbox",name:"coverflowEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadow",changeProp:!0,value:!0}],flip:[{type:"checkbox",name:"flipEffectLimitRotation",tip:"Limit edge slides rotation",label:"Limit rotation",changeProp:!0,value:!0},{type:"checkbox",name:"flipEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadows",changeProp:!0,value:!0}],cards:[{type:"number",name:"cardsEffectPerSlideOffset",tip:"Offset distance per slide (in px)",label:"Slide offset",changeProp:!0,min:0,value:8},{type:"number",name:"cardsEffectPerSlideRotate",tip:"Rotate angle per slide (in degrees)",label:"Slide rotate",changeProp:!0,min:0,value:2},{type:"checkbox",name:"cardsEffectRotate",tip:"Enables cards rotation",label:"Rotate",changeProp:!0,value:!0},{type:"checkbox",name:"cardsEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadows",changeProp:!0,value:!0}]}},autoplay:{category:{id:"swiper-autoplay",label:"Autoplay",icon:ee.autoplay},type:"checkbox",label:"Enable Autoplay",value:!1,subTraits:{true:[{type:"number",name:"autoplayDelay",label:"Delay",changeProp:!0,value:3e3},{type:"checkbox",name:"autoplayDisableOnInteraction",label:"Disable on interaction",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayWaitForTransition",label:"Wait for transition",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayPauseOnMouseEnter",label:"Pause on mouse enter",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayReverseDirection",label:"Reverse direction",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayStopOnLastSlide",label:"Stop on last slide",changeProp:!0,value:!1}]}},pagination:{category:{id:"swiper-pagination",label:"Pagination",icon:ee.pagination},type:"select",label:"Pagination Type",options:[{id:"none",label:"None"},{id:"bullets",label:"Bullets"},{id:"progressbar",label:"Progressbar"},{id:"fraction",label:"Fraction"}],getValue:({component:n})=>n.findFirstType(Pt)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(Pt);t==null||t.remove(),e!=="none"&&n.append({type:Pt}),n.set({pagination:e})},subTraits:{bullets:[{type:"checkbox",name:"dynamicBullets",label:"Dynamic bullets",changeProp:!0,value:!1},{type:"checkbox",name:"clickableBullets",label:"Clickable bullets",changeProp:!0,value:!0}],progressbar:[{type:"checkbox",name:"progressbarOpposite",label:"Progress opposite",changeProp:!0,value:!1}]}},scrollbar:{category:{id:"swiper-scrollbar",label:"Scrollbar",icon:ee.scrollbar},type:"checkbox",label:"Enable Scrollbar",getValue:({component:n})=>!!n.findFirstType(tn),setValue:({component:n,value:e})=>{const t=n.findFirstType(tn);t==null||t.remove(),e&&n.append({type:tn}),n.set({scrollbar:e})},subTraits:{false:[],true:[{type:"checkbox",name:"scrollbarDraggable",label:"Draggable",changeProp:!0,value:!1},{type:"checkbox",name:"scrollbarHide",label:"Hide",tip:"Hide scrollbar automatically after user interaction",changeProp:!0,value:!0}]}},parallax:{category:{id:"swiper-parallax",label:"Parallax",icon:ee.parallax},type:"checkbox",label:"Enable Parallax",value:!1},mobile:{category:fs,type:"checkbox",label:"Enable mobile breakpoint",value:!1,subTraits:{true:[{type:"number",name:"mobileBreakpoint",label:"Mobile breakpoint",tip:"Slide values below will be applied when the screen width is greater than this value",changeProp:!0,min:1,value:460},{type:"number",name:"mobileSlidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"mobileSlidesPerGroup",label:"Slides per group",changeProp:!0,min:1,value:1},{type:"number",name:"mobileSpaceBetween",label:"Space between",changeProp:!0,min:0,value:0}]}},tablet:{category:fs,type:"checkbox",label:"Enable tablet breakpoint",value:!1,subTraits:{true:[{type:"number",name:"tabletBreakpoint",label:"Tablet breakpoint",tip:"Slide values below will be applied when the screen width is greater than this value",changeProp:!0,min:1,value:991},{type:"number",name:"tabletSlidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"tabletSlidesPerGroup",label:"Slides per group",changeProp:!0,min:1,value:1},{type:"number",name:"tabletSpaceBetween",label:"Space between",changeProp:!0,min:0,value:0}]}},allowTouchMove:{category:ps,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:ps,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},ms="Slider",to="swiper",jt=`${to}-`,Td=(n,e)=>{const{Components:t,Blocks:i,Commands:o}=n,{block:s}=e,r=hc(kd),l="core:preview",a=o.events,c=function(u){const f=this,p=window,m=f.__onLoad,g=f.__activeSlide,b=f.__inPreview,{cdnScript:x,cdnStyle:y,slidesPerView:v}=u||{},S=T=>isNaN(T)?void 0:parseFloat(T),k=()=>{const T={loop:u.loop,speed:u.speed,initialSlide:u.initialSlide,direction:u.vertical?"vertical":"horizontal",effect:u.effect,freeMode:u.freeMode,parallax:u.parallax,autoHeight:u.autoHeight,allowTouchMove:u.allowTouchMove,grabCursor:u.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(v)?v:S(v),slidesPerGroup:S(u.slidesPerGroup),spaceBetween:S(u.spaceBetween),slidesOffsetBefore:S(u.slidesOffsetBefore),slidesOffsetAfter:S(u.slidesOffsetAfter),centeredSlides:u.centeredSlides,fadeEffect:{crossFade:u.crossFade},cubeEffect:{shadow:u.cubeEffectShadow,slideShadows:u.cubeEffectSlideShadows,shadowOffset:S(u.cubeEffectShadowOffset),shadowScale:S(u.cubeEffectShadowScale)},coverflowEffect:{depth:S(u.coverflowEffectDepth),modifier:S(u.coverflowEffectModifier),rotate:S(u.coverflowEffectRotate),scale:S(u.coverflowEffectScale),stretch:S(u.coverflowEffectStretch),slideShadows:u.coverflowEffectSlideShadows},flipEffect:{limitRotation:u.flipEffectLimitRotation,slideShadows:u.flipEffectSlideShadows},cardsEffect:{perSlideOffset:S(u.cardsEffectPerSlideOffset),perSlideRotate:S(u.cardsEffectPerSlideRotate),rotate:u.cardsEffectRotate,slideShadows:u.cardsEffectSlideShadows},navigation:{nextEl:f.querySelector(".swiper-button-next"),prevEl:f.querySelector(".swiper-button-prev")},pagination:{type:u.pagination||"bullets",dynamicBullets:u.dynamicBullets,clickable:u.clickableBullets,progressbarOpposite:u.progressbarOpposite,el:f.querySelector(".swiper-pagination")},scrollbar:{el:f.querySelector(".swiper-scrollbar"),draggable:u.scrollbarDraggable,hide:u.scrollbarHide},autoplay:u.autoplay&&{delay:u.autoplayDelay,disableOnInteraction:u.autoplayDisableOnInteraction,pauseOnMouseEnter:u.autoplayPauseOnMouseEnter,reverseDirection:u.autoplayReverseDirection,stopOnLastSlide:u.autoplayStopOnLastSlide,waitForTransition:u.autoplayWaitForTransition}};if(u.tablet){const{tabletBreakpoint:M,tabletSlidesPerView:P}=u,R=S(M);T.breakpoints[R]={slidesPerView:isNaN(P)?P:S(P),slidesPerGroup:S(u.tabletSlidesPerGroup),spaceBetween:S(u.tabletSpaceBetween)}}if(u.mobile){const{mobileBreakpoint:M,mobileSlidesPerView:P}=u,R=S(M);T.breakpoints[R]={slidesPerView:isNaN(P)?P:S(P),slidesPerGroup:S(u.mobileSlidesPerGroup),spaceBetween:S(u.mobileSpaceBetween)}}m&&!b&&(T.simulateTouch=!1),g&&(T.initialSlide=g);const V=new p.Swiper(f,T);m==null||m(V)};if(p.Swiper)k();else{const{head:T}=document,V=Array.isArray(x)?[...x]:[x],M=Array.isArray(y)?[...y]:[y],P=L=>{if(L.length){const J=document.createElement("link");J.href=L.shift(),J.rel="stylesheet",T.appendChild(J),P(L)}},R=L=>{if(L.length){const J=document.createElement("script");J.src=L.shift(),J.onerror=J.onload=R.bind(null,L),T.appendChild(J)}else k()};P(M),R(V)}},d=(u=0)=>({type:an,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${u}`}}}),h=t.getType("default").model;return t.addType(be,{block:s&&{label:ms,media:ee.slider,category:"Extra",select:!0,...e.block},isComponent:u=>mt(u,to),model:{defaults:()=>({name:ms,icon:ee.slider,classes:to,draggable:(u,f)=>!f.is(be),components:[{type:Dt,components:[d(1),d(2),d(3)]},{type:Pt}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...r.propKeys],...r.props,traits:[...r.traits]}),init(){const{em:u}=this;uc(this,r.traits),fc(this,r.propKeys),this.listenTo(u,`${a.runCommand}${l}`,this.onPreviewOn),this.listenTo(u,`${a.stopCommand}${l}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const u=this.findFirstType(Dt);u==null||u.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var f;const u=((f=this.findFirstType(Dt))==null?void 0:f.components().length)||0;return{type:an,components:{type:"text",components:{type:"textnode",content:`Slide ${u+1}`}}}},toJSON(...u){const f=h.prototype.toJSON.apply(this,u);return r.propsNoValues.forEach(p=>delete f[p]),delete f["script-props"],f}},view:{init(){this.listenTo(this.model,t.events.scriptUnmount,this.destroySwiper)},getSwiper(){return this.el.swiper},destroySwiper(){var u;(u=this.getSwiper())==null||u.destroy()},onRender(){const u=this.el;u.__onLoad=f=>f.on("slideChange",()=>this.__activeSlide=f.activeIndex),u.__activeSlide=this.__activeSlide,u.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(be),i.remove(be)}},Md="Nav Prev",Ad="Nav Next",En=`${jt}button-prev`,On=`${jt}button-next`,Ed=n=>{const{Components:e}=n,t=i=>({type:"svg",selectable:!1,hoverable:!1,attributes:{viewBox:"0 0 27 44"},components:{type:"svg-in",tagName:"path",attributes:{d:i,fill:"currentColor"}}});return e.addType(It,{isComponent:i=>mt(i,En),model:{defaults:{name:Md,classes:En,copyable:!1,highlightable:!1,droppable:!1,draggable:!1,selectable:!1,hoverable:!1,layerable:!1,components:t("M0,22L22,0l2.1,2.1L4.2,22l19.9,19.9L22,44L0,22L0,22L0,22z"),styles:`
100
+ .${En} {
101
101
  color: inherit;
102
102
  }
103
- .${On}:after {
103
+ .${En}:after {
104
104
  content: none;
105
105
  }
106
- `}}}),e.addType(Jn,{extend:It,isComponent:i=>mt(i,En),model:{defaults:{name:Ad,classes:En,components:t("M27,22L27,22L5,44l-2.1-2.1L22.8,22L2.9,2.1L5,0L27,22L27,22z"),styles:`
107
- .${En} {
106
+ `}}}),e.addType(Jn,{extend:It,isComponent:i=>mt(i,On),model:{defaults:{name:Ad,classes:On,components:t("M27,22L27,22L5,44l-2.1-2.1L22.8,22L2.9,2.1L5,0L27,22L27,22z"),styles:`
107
+ .${On} {
108
108
  color: inherit;
109
109
  }
110
- .${En}:after {
110
+ .${On}:after {
111
111
  content: none;
112
112
  }
113
- `}}}),()=>{e.removeType(It),e.removeType(Jn)}},Ed=n=>{const{Components:e}=n,t=`${jt}pagination`;return e.addType(Pt,{isComponent:i=>mt(i,t),model:{defaults:{name:"Pagination",classes:t,copyable:!1,highlightable:!1,droppable:!1,draggable:!1,selectable:!1,hoverable:!1,layerable:!1,styles:`
113
+ `}}}),()=>{e.removeType(It),e.removeType(Jn)}},Od=n=>{const{Components:e}=n,t=`${jt}pagination`;return e.addType(Pt,{isComponent:i=>mt(i,t),model:{defaults:{name:"Pagination",classes:t,copyable:!1,highlightable:!1,droppable:!1,draggable:!1,selectable:!1,hoverable:!1,layerable:!1,styles:`
114
114
  .${t}-bullet-active {
115
115
  background-color: currentColor;
116
116
  }
117
117
  .${t}-progressbar-fill {
118
118
  --swiper-pagination-color: currentColor;
119
119
  }
120
- `}}}),()=>{e.removeType(Pt)}},Nd="Scrollbar",pr=`${jt}scrollbar`,Dd=n=>{const{Components:e}=n;return e.addType(tn,{isComponent:t=>mt(t,pr),model:{defaults:{name:Nd,classes:pr,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{e.removeType(tn)}},Id="Slide",mr=`${jt}slide`,Pd=n=>{const{Components:e}=n;return e.addType(an,{isComponent:t=>mt(t,mr),model:{defaults:{name:Id,classes:mr,icon:Q.slider,draggable:(t,i)=>i.is(Dt)}}}),()=>{e.removeType(an)}},Rd="Wrapper",gr=`${jt}wrapper`,Vd=n=>{const{Components:e}=n,{events:t}=e;return e.addType(Dt,{isComponent:i=>mt(i,gr),model:{defaults:{name:Rd,icon:Q.slider,classes:gr,copyable:!1,removable:!1,draggable:!1,highlightable:!1,droppable:i=>i.is(an)},init(){const i=this.components();this.listenTo(i,"add remove",this.updateSlider)},updateSlider(i){const o=this.closestType(be);if(o){const r=o.getView();o.reloadSlider(),this.em.once(t.scriptMount,()=>{setTimeout(()=>{var s;return(s=r.getSwiper())==null?void 0:s.slideTo(i.index())},100)})}}}}),()=>{e.removeType(Dt)}},Ld="swiperComponent",zd=function(n,e={}){const t={block:{},cdnScript:"https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js",cdnStyle:"https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css",...e},i=[Td(n,t),Od(n),Vd(n),Pd(n),Ed(n),Dd(n)];Ae({editor:n,plan:ee.startup,licenseKey:t.licenseKey,pluginName:Ld,cleanup:()=>{i.forEach(o=>o())}})},Bd=Me(zd),Hd=n=>n.dispatchEvent(new CustomEvent("input"));function Fd(n,e){if(!e)return()=>{};const t=n.Components.events,i=d=>n.getSelectedAll().includes(d),o=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),r=d=>d.isChildOf("text"),s=d=>n.getEditing()===d,l=(d,h={})=>{d.trigger("focus",h.event)},a=(d,h)=>{i(d)&&o(d)&&!s(d)&&l(d,h)},c=(d,h)=>{if(i(d)&&!o(d)&&r(d)){const u=d.parents().find(f=>f.isInstanceOf("text"));u&&(l(u,h),setTimeout(()=>n.select(u),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Eo=new WeakMap,$d=(n,e)=>{Eo.set(n,e)},Wd=n=>{Eo.delete(n)},Mi=n=>Eo.get(n),Nn=n=>{const e=n.target,t=e.closest(".tox"),i=e.matches(".ephox-snooker-resizer-bar");(t||i)&&n.stopPropagation()},yr=n=>{n.stopPropagation(),n.preventDefault()},_d=(n,e)=>{const t=n.getDoc(),i=n.getWin();if(e!=null&&e.event){const{event:o}=e,{clientX:r,clientY:s}=o;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(r,s);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(r,s);l=t.createRange(),l==null||l.setStart(a.offsetNode,a.offset)}if(l){const a=i.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(l),n.selection.setRng(l)}}else n.execCommand("SelectAll")},Kd=n=>{var c,d;const{el:e,editor:t,componentView:i}=n,o=t.runCommand(Y.getStateTheme),r=i.model,s={target:e,inline:!0,skin:(o==null?void 0:o.theme)===_s.dark?"oxide-dark":"oxide",menubar:!1,image_advtab:!0,paste_data_images:!0,statusbar:!1,branding:!1,forced_root_block:"div",plugins:"advlist autolink lists link image media table",toolbar_mode:"sliding",toolbar:"bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"},l=((d=(c=n.pluginOpts)==null?void 0:c.loadConfig)==null?void 0:d.call(c,{config:s,editor:t,componentView:i,component:r}))||{};return{...s,...l}},br=(n,e=document)=>new Promise((t,i)=>{const o=Array.isArray(n)?[...n]:[n],{head:r}=e,s=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=s.bind(null,l),a.onerror=i,r.appendChild(a)}else t()};s(o)}),qd="rteTinyMce",jd=function(n,e={}){const t={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...e},{cdnScript:i}=t,o=n.Canvas.events,r=async(a,c)=>{const d=a.ownerDocument,h=d.defaultView,u=c==null?void 0:c.view;if(!h||!u){console.warn("Missing required data",{win:h,componentView:u});return}const f=Kd({el:a,editor:n,componentView:u,pluginOpts:t}),m=(await h.tinymce.init(f))[0];if(!m)return;const y=(await window.tinymce.init({...f,target:document.createElement("div")}))[0];return m.ui.show(),d.body.addEventListener("mousedown",Nn),document.body.addEventListener("mousedown",Nn),m.on("Change",()=>Hd(a)),m.on("blur",()=>m.ui.show()),m.on("OpenWindow",function(){var S;const x=(S=d.querySelector(".tox-dialog"))==null?void 0:S.closest(".tox");x&&(x==null?void 0:x.ownerDocument)!==document&&(document.body.appendChild(x),m.once("CloseWindow",()=>{x&&x.ownerDocument===document&&d.body.appendChild(x)}))}),a.addEventListener("dragstart",yr,{capture:!0}),n.runCommand(Y.setStateContextMenu,{enabled:!1}),_d(m,c),{rteEditor:m,rteEditorShallow:y}},s=(a,c)=>{a.ownerDocument.body.removeEventListener("mousedown",Nn),document.body.removeEventListener("mousedown",Nn),a.removeEventListener("dragstart",yr,{capture:!0}),n.runCommand(Y.setStateContextMenu,{enabled:!0}),c.rteEditor.destroy(),c.rteEditorShallow.destroy()};n.on(o.frameLoad,async({window:a})=>{br(i,a.document)}),n.onReady(()=>{br(i,document)}),n.setCustomRte({parseContent:!0,async enable(a,c,d){const h=Mi(a);if(h)return h.rteEditor;const u=await r(a,d);return u&&$d(a,u),u==null?void 0:u.rteEditor},disable(a){const c=Mi(a);c&&(Wd(a),s(a,c))},getContent(a){var d,h;const c=Mi(a);return c?(h=(d=c.rteEditor).getContent)==null?void 0:h.call(d):a.innerHTML}});const l=Fd(n,t.enableOnClick);Ae({editor:n,licenseKey:t.licenseKey,plan:ee.startup,pluginName:qd,cleanup:()=>{n.RichTextEditor.customRte=void 0,l()}})},Jd=Me(jd);function _(n){this.content=n}_.prototype={constructor:_,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 i=t&&t!=n?this.remove(t):this,o=i.find(n),r=i.content.slice();return o==-1?r.push(t||n,e):(r[o+1]=e,t&&(r[o]=t)),new _(r)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new _(t)},addToStart:function(n,e){return new _([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new _(t)},addBefore:function(n,e,t){var i=this.remove(e),o=i.content.slice(),r=i.find(n);return o.splice(r==-1?o.length:r,0,e,t),new _(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=_.from(n),n.size?new _(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=_.from(n),n.size?new _(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=_.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}};_.from=function(n){if(n instanceof _)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new _(e)};function pl(n,e,t){for(let i=0;;i++){if(i==n.childCount||i==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(i),r=e.child(i);if(o==r){t+=o.nodeSize;continue}if(!o.sameMarkup(r))return t;if(o.isText&&o.text!=r.text){for(let s=0;o.text[s]==r.text[s];s++)t++;return t}if(o.content.size||r.content.size){let s=pl(o.content,r.content,t+1);if(s!=null)return s}t+=o.nodeSize}}function ml(n,e,t,i){for(let o=n.childCount,r=e.childCount;;){if(o==0||r==0)return o==r?null:{a:t,b:i};let s=n.child(--o),l=e.child(--r),a=s.nodeSize;if(s==l){t-=a,i-=a;continue}if(!s.sameMarkup(l))return{a:t,b:i};if(s.isText&&s.text!=l.text){let c=0,d=Math.min(s.text.length,l.text.length);for(;c<d&&s.text[s.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,i--;return{a:t,b:i}}if(s.content.size||l.content.size){let c=ml(s.content,l.content,t-1,i-1);if(c)return c}t-=a,i-=a}}class w{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let i=0;i<e.length;i++)this.size+=e[i].nodeSize}nodesBetween(e,t,i,o=0,r){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&i(a,o+l,r||null,s)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),i,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,i,o){let r="",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)&&i&&(s?s=!1:r+=i),r+=c},0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,i=e.firstChild,o=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(i)&&(o[o.length-1]=t.withText(t.text+i.text),r=1);r<e.content.length;r++)o.push(e.content[r]);return new w(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let i=[],o=0;if(t>e)for(let r=0,s=0;s<t;r++){let l=this.content[r],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))),i.push(l),o+=l.nodeSize),s=a}return new w(i,o)}cutByIndex(e,t){return e==t?w.empty:e==0&&t==this.content.length?this:new w(this.content.slice(e,t))}replaceChild(e,t){let i=this.content[e];if(i==t)return this;let o=this.content.slice(),r=this.size+t.nodeSize-i.nodeSize;return o[e]=t,new w(o,r)}addToStart(e){return new w([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new w(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,i=0;t<this.content.length;t++){let o=this.content[t];e(o,i,t),i+=o.nodeSize}}findDiffStart(e,t=0){return pl(this,e,t)}findDiffEnd(e,t=this.size,i=e.size){return ml(this,e,t,i)}findIndex(e,t=-1){if(e==0)return Dn(0,e);if(e==this.size)return Dn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let i=0,o=0;;i++){let r=this.child(i),s=o+r.nodeSize;if(s>=e)return s==e||t>0?Dn(i+1,s):Dn(i,o);o=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 w.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new w(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return w.empty;let t,i=0;for(let o=0;o<e.length;o++){let r=e[o];i+=r.nodeSize,o&&r.isText&&e[o-1].sameMarkup(r)?(t||(t=e.slice(0,o)),t[t.length-1]=r.withText(t[t.length-1].text+r.text)):t&&t.push(r)}return new w(t||e,i)}static from(e){if(!e)return w.empty;if(e instanceof w)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new w([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}w.empty=new w([],0);const Ai={index:0,offset:0};function Dn(n,e){return Ai.index=n,Ai.offset=e,Ai}function Gn(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 i=0;i<n.length;i++)if(!Gn(n[i],e[i]))return!1}else{for(let i in n)if(!(i in e)||!Gn(n[i],e[i]))return!1;for(let i in e)if(!(i in n))return!1}return!0}class I{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,i=!1;for(let o=0;o<e.length;o++){let r=e[o];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,o));else{if(r.type.excludes(this.type))return e;!i&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),i=!0),t&&t.push(r)}}return t||(t=e.slice()),i||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&&Gn(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 i=e.marks[t.type];if(!i)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=i.create(t.attrs);return i.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].eq(t[i]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return I.none;if(e instanceof I)return[e];let t=e.slice();return t.sort((i,o)=>i.type.rank-o.type.rank),t}}I.none=[];class Un extends Error{}class C{constructor(e,t,i){this.content=e,this.openStart=t,this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let i=yl(this.content,e+this.openStart,t);return i&&new C(i,this.openStart,this.openEnd)}removeBetween(e,t){return new C(gl(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 C.empty;let i=t.openStart||0,o=t.openEnd||0;if(typeof i!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new C(w.fromJSON(e,t.content),i,o)}static maxOpen(e,t=!0){let i=0,o=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)i++;for(let r=e.lastChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.lastChild)o++;return new C(e,i,o)}}C.empty=new C(w.empty,0,0);function gl(n,e,t){let{index:i,offset:o}=n.findIndex(e),r=n.maybeChild(i),{index:s,offset:l}=n.findIndex(t);if(o==e||r.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(i!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(i,r.copy(gl(r.content,e-o-1,t-o-1)))}function yl(n,e,t,i){let{index:o,offset:r}=n.findIndex(e),s=n.maybeChild(o);if(r==e||s.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=yl(s.content,e-r-1,t);return l&&n.replaceChild(o,s.copy(l))}function Gd(n,e,t){if(t.openStart>n.depth)throw new Un("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Un("Inconsistent open depths");return bl(n,e,t,0)}function bl(n,e,t,i){let o=n.index(i),r=n.node(i);if(o==e.index(i)&&i<n.depth-t.openStart){let s=bl(n,e,t,i+1);return r.copy(r.content.replaceChild(o,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==i&&e.depth==i){let s=n.parent,l=s.content;return dt(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=Ud(t,n);return dt(r,Sl(n,s,l,e,i))}else return dt(r,Zn(n,e,i))}function wl(n,e){if(!e.type.compatibleContent(n.type))throw new Un("Cannot join "+e.type.name+" onto "+n.type.name)}function no(n,e,t){let i=n.node(t);return wl(i,e.node(t)),i}function ct(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 nn(n,e,t,i){let o=(e||n).node(t),r=0,s=e?e.index(t):o.childCount;n&&(r=n.index(t),n.depth>t?r++:n.textOffset&&(ct(n.nodeAfter,i),r++));for(let l=r;l<s;l++)ct(o.child(l),i);e&&e.depth==t&&e.textOffset&&ct(e.nodeBefore,i)}function dt(n,e){return n.type.checkContent(e),n.copy(e)}function Sl(n,e,t,i,o){let r=n.depth>o&&no(n,e,o+1),s=i.depth>o&&no(t,i,o+1),l=[];return nn(null,n,o,l),r&&s&&e.index(o)==t.index(o)?(wl(r,s),ct(dt(r,Sl(n,e,t,i,o+1)),l)):(r&&ct(dt(r,Zn(n,e,o+1)),l),nn(e,t,o,l),s&&ct(dt(s,Zn(t,i,o+1)),l)),nn(i,null,o,l),new w(l)}function Zn(n,e,t){let i=[];if(nn(null,n,t,i),n.depth>t){let o=no(n,e,t+1);ct(dt(o,Zn(n,e,t+1)),i)}return nn(e,null,t,i),new w(i)}function Ud(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let r=t-1;r>=0;r--)o=e.node(r).copy(w.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class cn{constructor(e,t,i){this.pos=e,this.path=t,this.parentOffset=i,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 i=this.pos-this.path[this.path.length-1],o=e.child(t);return i?e.child(t).cut(i):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 i=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let r=0;r<e;r++)o+=i.child(r).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return I.none;if(this.textOffset)return e.child(t).marks;let i=e.maybeChild(t-1),o=e.maybeChild(t);if(!i){let l=i;i=o,o=l}let r=i.marks;for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!o||!r[s].isInSet(o.marks))&&(r=r[s--].removeFromSet(r));return r}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let i=t.marks,o=e.parent.maybeChild(e.index());for(var r=0;r<i.length;r++)i[r].type.spec.inclusive===!1&&(!o||!i[r].isInSet(o.marks))&&(i=i[r--].removeFromSet(i));return i}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 i=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);i>=0;i--)if(e.pos<=this.end(i)&&(!t||t(this.node(i))))return new Yn(this,e,i);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 i=[],o=0,r=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(r),c=r-a;if(i.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;r=c-1,o+=a+1}return new cn(t,i,r)}static resolveCached(e,t){let i=wr.get(e);if(i)for(let r=0;r<i.elts.length;r++){let s=i.elts[r];if(s.pos==t)return s}else wr.set(e,i=new Zd);let o=i.elts[i.i]=cn.resolve(e,t);return i.i=(i.i+1)%Yd,o}}class Zd{constructor(){this.elts=[],this.i=0}}const Yd=12,wr=new WeakMap;class Yn{constructor(e,t,i){this.$from=e,this.$to=t,this.depth=i}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Xd=Object.create(null);let ht=class io{constructor(e,t,i,o=I.none){this.type=e,this.attrs=t,this.marks=o,this.content=i||w.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,i,o=0){this.content.nodesBetween(e,t,i,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,i,o){return this.content.textBetween(e,t,i,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,i){return this.type==e&&Gn(this.attrs,t||e.defaultAttrs||Xd)&&I.sameSet(this.marks,i||I.none)}copy(e=null){return e==this.content?this:new io(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new io(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,i=!1){if(e==t)return C.empty;let o=this.resolve(e),r=this.resolve(t),s=i?0:o.sharedDepth(t),l=o.start(s),c=o.node(s).content.cut(o.pos-l,r.pos-l);return new C(c,o.depth-s,r.depth-s)}replace(e,t,i){return Gd(this.resolve(e),this.resolve(t),i)}nodeAt(e){for(let t=this;;){let{index:i,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(i),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:i}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:i}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:i}=this.content.findIndex(e);if(i<e)return{node:this.content.child(t),index:t,offset:i};let o=this.content.child(t-1);return{node:o,index:t-1,offset:i-o.nodeSize}}resolve(e){return cn.resolveCached(this,e)}resolveNoCache(e){return cn.resolve(this,e)}rangeHasMark(e,t,i){let o=!1;return t>e&&this.nodesBetween(e,t,r=>(i.isInSet(r.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()+")"),vl(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,i=w.empty,o=0,r=i.childCount){let s=this.contentMatchAt(e).matchFragment(i,o,r),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<r;a++)if(!this.type.allowsMarks(i.child(a).marks))return!1;return!0}canReplaceWith(e,t,i,o){if(o&&!this.type.allowsMarks(o))return!1;let r=this.contentMatchAt(e).matchType(i),s=r&&r.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),this.type.checkAttrs(this.attrs);let e=I.none;for(let t=0;t<this.marks.length;t++){let i=this.marks[t];i.type.checkAttrs(i.attrs),e=i.addToSet(e)}if(!I.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 i;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=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,i)}let o=w.fromJSON(e,t.content),r=e.nodeType(t.type).create(t.attrs,o,i);return r.type.checkAttrs(r.attrs),r}};ht.prototype.text=void 0;class Xn extends ht{constructor(e,t,i,o){if(super(e,t,null,o),!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):vl(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 Xn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Xn(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 vl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class gt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let i=new Qd(e,t);if(i.next==null)return gt.empty;let o=xl(i);i.next&&i.err("Unexpected trailing text");let r=sh(rh(o));return lh(r,i),r}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,i=e.childCount){let o=this;for(let r=t;o&&r<i;r++)o=o.matchType(e.child(r).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 i=0;i<e.next.length;i++)if(this.next[t].type==e.next[i].type)return!0;return!1}fillBefore(e,t=!1,i=0){let o=[this];function r(s,l){let a=s.matchFragment(e,i);if(a&&(!t||a.validEnd))return w.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:d,next:h}=s.next[c];if(!(d.isText||d.hasRequiredAttrs())&&o.indexOf(h)==-1){o.push(h);let u=r(h,l.concat(d));if(u)return u}}return null}return r(this,[])}findWrapping(e){for(let i=0;i<this.wrapCache.length;i+=2)if(this.wrapCache[i]==e)return this.wrapCache[i+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),i=[{match:this,type:null,via:null}];for(;i.length;){let o=i.shift(),r=o.match;if(r.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<r.next.length;s++){let{type:l,next:a}=r.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(i.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(i){e.push(i);for(let o=0;o<i.next.length;o++)e.indexOf(i.next[o].next)==-1&&t(i.next[o].next)}return t(this),e.map((i,o)=>{let r=o+(i.validEnd?"*":" ")+" ";for(let s=0;s<i.next.length;s++)r+=(s?", ":"")+i.next[s].type.name+"->"+e.indexOf(i.next[s].next);return r}).join(`
121
- `)}}gt.empty=new gt(!0);class Qd{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 xl(n){let e=[];do e.push(eh(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function eh(n){let e=[];do e.push(th(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function th(n){let e=oh(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=nh(n,e);else break;return e}function Sr(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function nh(n,e){let t=Sr(n),i=t;return n.eat(",")&&(n.next!="}"?i=Sr(n):i=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:i,expr:e}}function ih(n,e){let t=n.nodeTypes,i=t[e];if(i)return[i];let o=[];for(let r in t){let s=t[r];s.isInGroup(e)&&o.push(s)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function oh(n){if(n.eat("(")){let e=xl(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=ih(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 rh(n){let e=[[]];return o(r(n,0),t()),e;function t(){return e.push([])-1}function i(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 r(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(r(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=r(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 i(l,a),o(r(s.expr,a),a),[i(a)]}else if(s.type=="plus"){let a=t();return o(r(s.expr,l),a),o(r(s.expr,a),a),[i(a)]}else{if(s.type=="opt")return[i(l)].concat(r(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let d=t();o(r(s.expr,a),d),a=d}if(s.max==-1)o(r(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let d=t();i(a,d),o(r(s.expr,a),d),a=d}return[i(a)]}else{if(s.type=="name")return[i(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Cl(n,e){return e-n}function vr(n,e){let t=[];return i(e),t.sort(Cl);function i(o){let r=n[o];if(r.length==1&&!r[0].term)return i(r[0].to);t.push(o);for(let s=0;s<r.length;s++){let{term:l,to:a}=r[s];!l&&t.indexOf(a)==-1&&i(a)}}}function sh(n){let e=Object.create(null);return t(vr(n,0));function t(i){let o=[];i.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]);vr(n,a).forEach(d=>{c||o.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let r=e[i.join(",")]=new gt(i.indexOf(n.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(Cl);r.next.push({type:o[s][0],next:e[l.join(",")]||t(l)})}return r}}function lh(n,e){for(let t=0,i=[n];t<i.length;t++){let o=i[t],r=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),r&&!(a.isText||a.hasRequiredAttrs())&&(r=!1),i.indexOf(c)==-1&&i.push(c)}r&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function kl(n){let e=Object.create(null);for(let t in n){let i=n[t];if(!i.hasDefault)return null;e[t]=i.default}return e}function Tl(n,e){let t=Object.create(null);for(let i in n){let o=e&&e[i];if(o===void 0){let r=n[i];if(r.hasDefault)o=r.default;else throw new RangeError("No value supplied for attribute "+i)}t[i]=o}return t}function Ml(n,e,t,i){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${o}`);for(let o in n){let r=n[o];r.validate&&r.validate(e[o])}}function Al(n,e){let t=Object.create(null);if(e)for(let i in e)t[i]=new ch(n,i,e[i]);return t}let xr=class Ol{constructor(e,t,i){this.name=e,this.schema=t,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=Al(e,i.attrs),this.defaultAttrs=kl(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==gt.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:Tl(this.attrs,e)}create(e=null,t,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ht(this,this.computeAttrs(e),w.from(t),I.setFrom(i))}createChecked(e=null,t,i){return t=w.from(t),this.checkContent(t),new ht(this,this.computeAttrs(e),t,I.setFrom(i))}createAndFill(e=null,t,i){if(e=this.computeAttrs(e),t=w.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let o=this.contentMatch.matchFragment(t),r=o&&o.fillBefore(w.empty,!0);return r?new ht(this,e,t.append(r),I.setFrom(i)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let i=0;i<e.childCount;i++)if(!this.allowsMarks(e.child(i).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){Ml(this.attrs,e,"node",this.name)}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 i=0;i<e.length;i++)this.allowsMarkType(e[i].type)?t&&t.push(e[i]):t||(t=e.slice(0,i));return t?t.length?t:I.none:e}static compile(e,t){let i=Object.create(null);e.forEach((r,s)=>i[r]=new Ol(r,t,s));let o=t.spec.topNode||"doc";if(!i[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let r in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};function ah(n,e,t){let i=t.split("|");return o=>{let r=o===null?"null":typeof o;if(i.indexOf(r)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${n}, got ${r}`)}}class ch{constructor(e,t,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate=typeof i.validate=="string"?ah(e,t,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class hi{constructor(e,t,i,o){this.name=e,this.rank=t,this.schema=i,this.spec=o,this.attrs=Al(e,o.attrs),this.excluded=null;let r=kl(this.attrs);this.instance=r?new I(this,r):null}create(e=null){return!e&&this.instance?this.instance:new I(this,Tl(this.attrs,e))}static compile(e,t){let i=Object.create(null),o=0;return e.forEach((r,s)=>i[r]=new hi(r,o++,t,s)),i}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]}checkAttrs(e){Ml(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class dh{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=_.from(e.nodes),t.marks=_.from(e.marks||{}),this.nodes=xr.compile(this.spec.nodes,this),this.marks=hi.compile(this.spec.marks,this);let i=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 r=this.nodes[o],s=r.spec.content||"",l=r.spec.marks;if(r.contentMatch=i[s]||(i[s]=gt.parse(s,this.nodes)),r.inlineContent=r.contentMatch.inlineContent,r.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!r.isInline||!r.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=r}r.markSet=l=="_"?null:l?Cr(this,l.split(" ")):l==""||!r.inlineContent?[]:null}for(let o in this.marks){let r=this.marks[o],s=r.spec.excludes;r.excluded=s==null?[r]:s==""?[]:Cr(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,i,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof xr){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,i,o)}text(e,t){let i=this.nodes.text;return new Xn(i,i.defaultAttrs,e,I.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return ht.fromJSON(this,e)}markFromJSON(e){return I.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Cr(n,e){let t=[];for(let i=0;i<e.length;i++){let o=e[i],r=n.marks[o],s=r;if(r)t.push(r);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[i]+"'")}return t}function hh(n){return n.tag!=null}function uh(n){return n.style!=null}class Ht{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let i=this.matchedStyles=[];t.forEach(o=>{if(hh(o))this.tags.push(o);else if(uh(o)){let r=/[^=]*/.exec(o.style)[0];i.indexOf(r)<0&&i.push(r),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let r=e.nodes[o.node];return r.contentMatch.matchType(r)})}parse(e,t={}){let i=new Tr(this,t,!1);return i.addAll(e,I.none,t.from,t.to),i.finish()}parseSlice(e,t={}){let i=new Tr(this,t,!0);return i.addAll(e,I.none,t.from,t.to),C.maxOpen(i.finish())}matchTag(e,t,i){for(let o=i?this.tags.indexOf(i)+1:0;o<this.tags.length;o++){let r=this.tags[o];if(mh(e,r.tag)&&(r.namespace===void 0||e.namespaceURI==r.namespace)&&(!r.context||t.matchesContext(r.context))){if(r.getAttrs){let s=r.getAttrs(e);if(s===!1)continue;r.attrs=s||void 0}return r}}}matchStyle(e,t,i,o){for(let r=o?this.styles.indexOf(o)+1:0;r<this.styles.length;r++){let s=this.styles[r],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!i.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 i(o){let r=o.priority==null?50:o.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<r)break}t.splice(s,0,o)}for(let o in e.marks){let r=e.marks[o].spec.parseDOM;r&&r.forEach(s=>{i(s=Mr(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let r=e.nodes[o].spec.parseDOM;r&&r.forEach(s=>{i(s=Mr(s)),s.node||s.ignore||s.mark||(s.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ht(e,Ht.schemaRules(e)))}}const El={address:!0,article:!0,aside:!0,blockquote:!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},fh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Nl={ol:!0,ul:!0},Qn=1,ei=2,on=4;function kr(n,e,t){return e!=null?(e?Qn:0)|(e==="full"?ei:0):n&&n.whitespace=="pre"?Qn|ei:t&~on}class In{constructor(e,t,i,o,r,s){this.type=e,this.attrs=t,this.marks=i,this.solid=o,this.options=s,this.content=[],this.activeMarks=I.none,this.match=r||(s&on?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(w.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let i=this.type.contentMatch,o;return(o=i.findWrapping(e.type))?(this.match=i,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Qn)){let i=this.content[this.content.length-1],o;if(i&&i.isText&&(o=/[ \t\r\n\u000c]+$/.exec(i.text))){let r=i;i.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-o[0].length))}}let t=w.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(w.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&&!El.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Tr{constructor(e,t,i){this.parser=e,this.options=t,this.isOpen=i,this.open=0;let o=t.topNode,r,s=kr(null,t.preserveWhitespace,0)|(i?on:0);o?r=new In(o.type,o.attrs,I.none,!0,t.topMatch||o.type.contentMatch,s):i?r=new In(null,null,I.none,!0,null,s):r=new In(e.schema.topNodeType,null,I.none,!0,null,s),this.nodes=[r],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 i=e.nodeValue,o=this.top;if(o.options&ei||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(i)){if(o.options&Qn)o.options&ei?i=i.replace(/\r\n?/g,`
122
- `):i=i.replace(/\r?\n|\r/g," ");else if(i=i.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let r=o.content[o.content.length-1],s=e.previousSibling;(!r||s&&s.nodeName=="BR"||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(i=i.slice(1))}i&&this.insertNode(this.parser.schema.text(i),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,i){let o=e.nodeName.toLowerCase(),r;Nl.hasOwnProperty(o)&&this.parser.normalizeLists&&ph(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(r=this.parser.matchTag(e,this,i));if(s?s.ignore:fh.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let l,a=this.top,c=this.needsBlock;if(El.hasOwnProperty(o))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),l=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);return}let d=s&&s.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),l&&this.sync(a),this.needsBlock=c}else{let l=this.readStyles(e,t);l&&this.addElementByRule(e,s,l,s.consuming===!1?r:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
123
- `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let i=e.style;if(i&&i.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let r=this.parser.matchedStyles[o],s=i.getPropertyValue(r);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(r,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,i,o){let r,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),i)||this.leafFallback(e,i);else{let a=this.enter(s,t.attrs||null,i,t.preserveWhitespace);a&&(r=!0,i=a)}else{let a=this.parser.schema.marks[t.mark];i=i.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,i,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,i));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,i),this.findAround(e,a,!1)}r&&this.sync(l)&&this.open--}addAll(e,t,i,o){let r=i||0;for(let s=i?e.childNodes[i]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(s,t);this.findAtPoint(e,r)}findPlace(e,t){let i,o;for(let r=this.open;r>=0;r--){let s=this.nodes[r],l=s.findWrapping(e);if(l&&(!i||i.length>l.length)&&(i=l,o=s,!l.length)||s.solid)break}if(!i)return null;this.sync(o);for(let r=0;r<i.length;r++)t=this.enterInner(i[r],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let i=this.findPlace(e,t);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let r=I.none;for(let s of i.concat(e.marks))(o.type?o.type.allowsMarkType(s.type):Ar(s.type,e.type))&&(r=s.addToSet(r));return o.content.push(e.mark(r)),!0}return!1}enter(e,t,i,o){let r=this.findPlace(e.create(t),i);return r&&(r=this.enterInner(e,t,i,!0,o)),r}enterInner(e,t,i,o=!1,r){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=kr(e,r,s.options);s.options&on&&s.content.length==0&&(l|=on);let a=I.none;return i=i.filter(c=>(s.type?s.type.allowsMarkType(c.type):Ar(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new In(e,t,a,o,null,l)),this.open++,i}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;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let i=this.nodes[t].content;for(let o=i.length-1;o>=0;o--)e+=i[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let i=0;i<this.find.length;i++)this.find[i].node==e&&this.find[i].offset==t&&(this.find[i].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,i){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)&(i?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("/"),i=this.options.context,o=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type),r=-(i?i.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>=r;a--)if(s(l-1,a))return!0;return!1}else{let d=a>0||a==0&&o?this.nodes[a].type:i&&a>=r?i.node(a-r).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 i=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let t in this.parser.schema.nodes){let i=this.parser.schema.nodes[t];if(i.isTextblock&&i.defaultAttrs)return i}}}function ph(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let i=e.nodeType==1?e.nodeName.toLowerCase():null;i&&Nl.hasOwnProperty(i)&&t?(t.appendChild(e),e=t):i=="li"?t=e:i&&(t=null)}}function mh(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Mr(n){let e={};for(let t in n)e[t]=n[t];return e}function Ar(n,e){let t=e.schema.nodes;for(let i in t){let o=t[i];if(!o.allowsMarkType(n))continue;let r=[],s=l=>{r.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||r.indexOf(d)<0&&s(d))return!0}};if(s(o.contentMatch))return!0}}class wt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},i){i||(i=Oi(t).createDocumentFragment());let o=i,r=[];return e.forEach(s=>{if(r.length||s.marks.length){let l=0,a=0;for(;l<r.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(r[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<r.length;)o=r.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],d=this.serializeMark(c,s.isInline,t);d&&(r.push([c,o]),o.appendChild(d.dom),o=d.contentDOM||d.dom)}}o.appendChild(this.serializeNodeInner(s,t))}),i}serializeNodeInner(e,t){let{dom:i,contentDOM:o}=Fn(Oi(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 i}serializeNode(e,t={}){let i=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let r=this.serializeMark(e.marks[o],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(i),i=r.dom)}return i}serializeMark(e,t,i={}){let o=this.marks[e.type.name];return o&&Fn(Oi(i),o(e,t),null,e.attrs)}static renderSpec(e,t,i=null,o){return Fn(e,t,i,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new wt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Or(e.nodes);return t.text||(t.text=i=>i.text),t}static marksFromSchema(e){return Or(e.marks)}}function Or(n){let e={};for(let t in n){let i=n[t].spec.toDOM;i&&(e[t]=i)}return e}function Oi(n){return n.document||window.document}const Er=new WeakMap;function gh(n){let e=Er.get(n);return e===void 0&&Er.set(n,e=yh(n)),e}function yh(n){let e=null;function t(i){if(i&&typeof i=="object")if(Array.isArray(i))if(typeof i[0]=="string")e||(e=[]),e.push(i);else for(let o=0;o<i.length;o++)t(i[o]);else for(let o in i)t(i[o])}return t(n),e}function Fn(n,e,t,i){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],r;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(i&&(r=gh(i))&&r.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 h in c)if(c[h]!=null){let u=h.indexOf(" ");u>0?a.setAttributeNS(h.slice(0,u),h.slice(u+1),c[h]):a.setAttribute(h,c[h])}}for(let h=d;h<e.length;h++){let u=e[h];if(u===0){if(h<e.length-1||h>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:p}=Fn(n,u,t,i);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Dl=65535,Il=Math.pow(2,16);function bh(n,e){return n+e*Il}function Nr(n){return n&Dl}function wh(n){return(n-(n&Dl))/Il}const Pl=1,Rl=2,$n=4,Vl=8;class oo{constructor(e,t,i){this.pos=e,this.delInfo=t,this.recover=i}get deleted(){return(this.delInfo&Vl)>0}get deletedBefore(){return(this.delInfo&(Pl|$n))>0}get deletedAfter(){return(this.delInfo&(Rl|$n))>0}get deletedAcross(){return(this.delInfo&$n)>0}}class le{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&le.empty)return le.empty}recover(e){let t=0,i=Nr(e);if(!this.inverted)for(let o=0;o<i;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[i*3]+t+wh(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,i){let o=0,r=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+r],d=this.ranges[l+s],h=a+c;if(e<=h){let u=c?e==a?-1:e==h?1:t:t,f=a+o+(u<0?0:d);if(i)return f;let p=e==(t<0?a:h)?null:bh(l/3,e-a),m=e==a?Rl:e==h?Pl:$n;return(t<0?e!=a:e!=h)&&(m|=Vl),new oo(f,m,p)}o+=d-c}return i?e+o:new oo(e+o,0,null)}touches(e,t){let i=0,o=Nr(t),r=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+r],d=a+c;if(e<=d&&l==o*3)return!0;i+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,i=this.inverted?1:2;for(let o=0,r=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?r:0),a=s+(this.inverted?0:r),c=this.ranges[o+t],d=this.ranges[o+i];e(l,l+c,a,a+d),r+=d-c}}invert(){return new le(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?le.empty:new le(e<0?[0,-e,0]:[0,0,e])}}le.empty=new le([]);class Rt{constructor(e=[],t,i=0,o=e.length){this.maps=e,this.mirror=t,this.from=i,this.to=o}slice(e=0,t=this.maps.length){return new Rt(this.maps,this.mirror,e,t)}copy(){return new Rt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,i=this.maps.length;t<e.maps.length;t++){let o=e.getMirror(t);this.appendMap(e.maps[t],o!=null&&o<t?i+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,i=this.maps.length+e.maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e.maps[t].invert(),o!=null&&o>t?i-o-1:void 0)}}invert(){let e=new Rt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let i=this.from;i<this.to;i++)e=this.maps[i].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,i){let o=0;for(let r=this.from;r<this.to;r++){let s=this.maps[r],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(r);if(a!=null&&a>r&&a<this.to){r=a,e=this.maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return i?e:new oo(e,o,null)}}const Ei=Object.create(null);class X{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 i=Ei[t.stepType];if(!i)throw new RangeError(`No step type ${t.stepType} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in Ei)throw new RangeError("Duplicate use of step JSON ID "+e);return Ei[e]=t,t.prototype.jsonID=e,t}}class F{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new F(e,null)}static fail(e){return new F(null,e)}static fromReplace(e,t,i,o){try{return F.ok(e.replace(t,i,o))}catch(r){if(r instanceof Un)return F.fail(r.message);throw r}}}function No(n,e,t){let i=[];for(let o=0;o<n.childCount;o++){let r=n.child(o);r.content.size&&(r=r.copy(No(r.content,e,r))),r.isInline&&(r=e(r,t,o)),i.push(r)}return w.fromArray(i)}class Ke extends X{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=e.resolve(this.from),o=i.node(i.sharedDepth(this.to)),r=new C(No(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 F.fromReplace(e,this.from,this.to,r)}invert(){return new ve(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new Ke(t.pos,i.pos,this.mark)}merge(e){return e instanceof Ke&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ke(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 Ke(t.from,t.to,e.markFromJSON(t.mark))}}X.jsonID("addMark",Ke);class ve extends X{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=new C(No(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return F.fromReplace(e,this.from,this.to,i)}invert(){return new Ke(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new ve(t.pos,i.pos,this.mark)}merge(e){return e instanceof ve&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ve(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 ve(t.from,t.to,e.markFromJSON(t.mark))}}X.jsonID("removeMark",ve);class qe extends X{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return F.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return F.fromReplace(e,this.pos,this.pos+1,new C(w.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let i=this.mark.addToSet(t.marks);if(i.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(i))return new qe(this.pos,t.marks[o]);return new qe(this.pos,this.mark)}}return new Ft(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new qe(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 qe(t.pos,e.markFromJSON(t.mark))}}X.jsonID("addNodeMark",qe);class Ft extends X{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return F.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return F.fromReplace(e,this.pos,this.pos+1,new C(w.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new qe(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ft(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 Ft(t.pos,e.markFromJSON(t.mark))}}X.jsonID("removeNodeMark",Ft);class U extends X{constructor(e,t,i,o=!1){super(),this.from=e,this.to=t,this.slice=i,this.structure=o}apply(e){return this.structure&&ro(e,this.from,this.to)?F.fail("Structure replace would overwrite content"):F.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 U(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deletedAcross&&i.deletedAcross?null:new U(t.pos,Math.max(t.pos,i.pos),this.slice)}merge(e){if(!(e instanceof U)||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?C.empty:new C(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new U(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?C.empty:new C(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new U(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 U(t.from,t.to,C.fromJSON(e,t.slice),!!t.structure)}}X.jsonID("replace",U);class j extends X{constructor(e,t,i,o,r,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=i,this.gapTo=o,this.slice=r,this.insert=s,this.structure=l}apply(e){if(this.structure&&(ro(e,this.from,this.gapFrom)||ro(e,this.gapTo,this.to)))return F.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return F.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,t.content);return i?F.fromReplace(e,this.from,this.to,i):F.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 j(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),i=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),r=this.to==this.gapTo?i.pos:e.map(this.gapTo,1);return t.deletedAcross&&i.deletedAcross||o<t.pos||r>i.pos?null:new j(t.pos,i.pos,o,r,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 j(t.from,t.to,t.gapFrom,t.gapTo,C.fromJSON(e,t.slice),t.insert,!!t.structure)}}X.jsonID("replaceAround",j);function ro(n,e,t){let i=n.resolve(e),o=t-e,r=i.depth;for(;o>0&&r>0&&i.indexAfter(r)==i.node(r).childCount;)r--,o--;if(o>0){let s=i.node(r).maybeChild(i.indexAfter(r));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function Sh(n,e,t,i){let o=[],r=[],s,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let h=a.marks;if(!i.isInSet(h)&&d.type.allowsMarkType(i.type)){let u=Math.max(c,e),f=Math.min(c+a.nodeSize,t),p=i.addToSet(h);for(let m=0;m<h.length;m++)h[m].isInSet(p)||(s&&s.to==u&&s.mark.eq(h[m])?s.to=f:o.push(s=new ve(u,f,h[m])));l&&l.to==u?l.to=f:r.push(l=new Ke(u,f,i))}}),o.forEach(a=>n.step(a)),r.forEach(a=>n.step(a))}function vh(n,e,t,i){let o=[],r=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;r++;let a=null;if(i instanceof hi){let c=s.marks,d;for(;d=i.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else i?i.isInSet(s.marks)&&(a=[i]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let d=0;d<a.length;d++){let h=a[d],u;for(let f=0;f<o.length;f++){let p=o[f];p.step==r-1&&h.eq(o[f].style)&&(u=p)}u?(u.to=c,u.step=r):o.push({style:h,from:Math.max(l,e),to:c,step:r})}}}),o.forEach(s=>n.step(new ve(s.from,s.to,s.style)))}function Do(n,e,t,i=t.contentMatch,o=!0){let r=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<r.childCount;a++){let c=r.child(a),d=l+c.nodeSize,h=i.matchType(c.type);if(!h)s.push(new U(l,d,C.empty));else{i=h;for(let u=0;u<c.marks.length;u++)t.allowsMarkType(c.marks[u].type)||n.step(new ve(l,d,c.marks[u]));if(o&&c.isText&&t.whitespace!="pre"){let u,f=/\r?\n|\r/g,p;for(;u=f.exec(c.text);)p||(p=new C(w.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new U(l+u.index,l+u.index+u[0].length,p))}}l=d}if(!i.validEnd){let a=i.fillBefore(w.empty,!0);n.replace(l,l,new C(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function xh(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function ui(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let i=n.depth;;--i){let o=n.$from.node(i),r=n.$from.index(i),s=n.$to.indexAfter(i);if(i<n.depth&&o.canReplace(r,s,t))return i;if(i==0||o.type.spec.isolating||!xh(o,r,s))break}return null}function Ch(n,e,t){let{$from:i,$to:o,depth:r}=e,s=i.before(r+1),l=o.after(r+1),a=s,c=l,d=w.empty,h=0;for(let p=r,m=!1;p>t;p--)m||i.index(p)>0?(m=!0,d=w.from(i.node(p).copy(d)),h++):a--;let u=w.empty,f=0;for(let p=r,m=!1;p>t;p--)m||o.after(p+1)<o.end(p)?(m=!0,u=w.from(o.node(p).copy(u)),f++):c++;n.step(new j(a,c,s,l,new C(d.append(u),h,f),d.size-h,!0))}function Ll(n,e,t=null,i=n){let o=kh(n,e),r=o&&Th(i,e);return r?o.map(Dr).concat({type:e,attrs:t}).concat(r.map(Dr)):null}function Dr(n){return{type:n,attrs:null}}function kh(n,e){let{parent:t,startIndex:i,endIndex:o}=n,r=t.contentMatchAt(i).findWrapping(e);if(!r)return null;let s=r.length?r[0]:e;return t.canReplaceWith(i,o,s)?r:null}function Th(n,e){let{parent:t,startIndex:i,endIndex:o}=n,r=t.child(i),s=e.contentMatch.findWrapping(r.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=i;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function Mh(n,e,t){let i=w.empty;for(let s=t.length-1;s>=0;s--){if(i.size){let l=t[s].type.contentMatch.matchFragment(i);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=w.from(t[s].type.create(t[s].attrs,i))}let o=e.start,r=e.end;n.step(new j(o,r,o,r,new C(i,0,0),t.length,!0))}function Ah(n,e,t,i,o){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let r=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(i,a)&&Oh(n.doc,n.mapping.slice(r).map(l),i)){let c=null;if(i.schema.linebreakReplacement){let f=i.whitespace=="pre",p=!!i.contentMatch.matchType(i.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&Bl(n,s,l,r),Do(n,n.mapping.slice(r).map(l,1),i,void 0,c===null);let d=n.mapping.slice(r),h=d.map(l,1),u=d.map(l+s.nodeSize,1);return n.step(new j(h,u,h+1,u-1,new C(w.from(i.create(a,null,s.marks)),0,0),1,!0)),c===!0&&zl(n,s,l,r),!1}})}function zl(n,e,t,i){e.forEach((o,r)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=n.mapping.slice(i).map(t+1+r+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Bl(n,e,t,i){e.forEach((o,r)=>{if(o.type==o.type.schema.linebreakReplacement){let s=n.mapping.slice(i).map(t+1+r);n.replaceWith(s,s+1,e.type.schema.text(`
124
- `))}})}function Oh(n,e,t){let i=n.resolve(e),o=i.index();return i.parent.canReplaceWith(o,o+1,t)}function Eh(n,e,t,i,o){let r=n.doc.nodeAt(e);if(!r)throw new RangeError("No node at given position");t||(t=r.type);let s=t.create(i,null,o||r.marks);if(r.isLeaf)return n.replaceWith(e,e+r.nodeSize,s);if(!t.validContent(r.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new j(e,e+r.nodeSize,e+1,e+r.nodeSize-1,new C(w.from(s),0,0),1,!0))}function Vt(n,e,t=1,i){let o=n.resolve(e),r=o.depth-t,s=i&&i[i.length-1]||o.parent;if(r<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>r;c--,d--){let h=o.node(c),u=o.index(c);if(h.type.spec.isolating)return!1;let f=h.content.cutByIndex(u,h.childCount),p=i&&i[d+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let m=i&&i[d]||h;if(!h.canReplace(u+1,h.childCount)||!m.type.validContent(f))return!1}let l=o.indexAfter(r),a=i&&i[0];return o.node(r).canReplaceWith(l,l,a?a.type:o.node(r+1).type)}function Nh(n,e,t=1,i){let o=n.doc.resolve(e),r=w.empty,s=w.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){r=w.from(o.node(l).copy(r));let d=i&&i[c];s=w.from(d?d.type.create(d.attrs,s):o.node(l).copy(s))}n.step(new U(e,e,new C(r.append(s),t,t),!0))}function fi(n,e){let t=n.resolve(e),i=t.index();return Ih(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(i,i+1)}function Dh(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:i}=n.type.schema;for(let o=0;o<e.childCount;o++){let r=e.child(o),s=r.type==i?n.type.schema.nodes.text:r.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(r.marks))return!1}return t.validEnd}function Ih(n,e){return!!(n&&e&&!n.isLeaf&&Dh(n,e))}function Ph(n,e,t){let i=null,{linebreakReplacement:o}=n.doc.type.schema,r=n.doc.resolve(e-t),s=r.node().type;if(o&&s.inlineContent){let d=s.whitespace=="pre",h=!!s.contentMatch.matchType(o);d&&!h?i=!1:!d&&h&&(i=!0)}let l=n.steps.length;if(i===!1){let d=n.doc.resolve(e+t);Bl(n,d.node(),d.before(),l)}s.inlineContent&&Do(n,e+t-1,s,r.node().contentMatchAt(r.index()),i==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new U(c,a.map(e+t,-1),C.empty,!0)),i===!0){let d=n.doc.resolve(c);zl(n,d.node(),d.before(),n.steps.length)}return n}function Rh(n,e,t){let i=n.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),t))return e;if(i.parentOffset==0)for(let o=i.depth-1;o>=0;o--){let r=i.index(o);if(i.node(o).canReplaceWith(r,r,t))return i.before(o+1);if(r>0)return null}if(i.parentOffset==i.parent.content.size)for(let o=i.depth-1;o>=0;o--){let r=i.indexAfter(o);if(i.node(o).canReplaceWith(r,r,t))return i.after(o+1);if(r<i.node(o).childCount)return null}return null}function Vh(n,e,t){let i=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let r=0;r<t.openStart;r++)o=o.firstChild.content;for(let r=1;r<=(t.openStart==0&&t.size?2:1);r++)for(let s=i.depth;s>=0;s--){let l=s==i.depth?0:i.pos<=(i.start(s+1)+i.end(s+1))/2?-1:1,a=i.index(s)+(l>0?1:0),c=i.node(s),d=!1;if(r==1)d=c.canReplace(a,a,o);else{let h=c.contentMatchAt(a).findWrapping(o.firstChild.type);d=h&&c.canReplaceWith(a,a,h[0])}if(d)return l==0?i.pos:l<0?i.before(s+1):i.after(s+1)}return null}function Io(n,e,t=e,i=C.empty){if(e==t&&!i.size)return null;let o=n.resolve(e),r=n.resolve(t);return Hl(o,r,i)?new U(e,t,i):new Lh(o,r,i).fit()}function Hl(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Lh{constructor(e,t,i){this.$from=e,this.$to=t,this.unplaced=i,this.frontier=[],this.placed=w.empty;for(let o=0;o<=e.depth;o++){let r=e.node(o);this.frontier.push({type:r.type,match:r.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=w.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,i=this.$from,o=this.close(e<0?this.$to:i.doc.resolve(e));if(!o)return null;let r=this.placed,s=i.depth,l=o.depth;for(;s&&l&&r.childCount==1;)r=r.firstChild.content,s--,l--;let a=new C(r,s,l);return e>-1?new j(i.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||i.pos!=this.$to.pos?new U(i.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,i=0,o=this.unplaced.openEnd;i<e;i++){let r=t.firstChild;if(t.childCount>1&&(o=0),r.type.spec.isolating&&o<=i){e=i;break}t=r.content}for(let t=1;t<=2;t++)for(let i=t==1?e:this.unplaced.openStart;i>=0;i--){let o,r=null;i?(r=Ni(this.unplaced.content,i-1).firstChild,o=r.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,h=null;if(t==1&&(s?c.matchType(s.type)||(h=c.fillBefore(w.from(s),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:i,frontierDepth:l,parent:r,inject:h};if(t==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:i,frontierDepth:l,parent:r,wrap:d};if(r&&c.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:i}=this.unplaced,o=Ni(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new C(e,t+1,Math.max(i,o.size+t>=e.size-i?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:i}=this.unplaced,o=Ni(e,t);if(o.childCount<=1&&t>0){let r=e.size-t<=t+o.size;this.unplaced=new C(Xt(e,t-1,1),t-1,r?t-1:i)}else this.unplaced=new C(Xt(e,t,1),t,i)}placeNodes({sliceDepth:e,frontierDepth:t,parent:i,inject:o,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let m=0;m<r.length;m++)this.openFrontierNode(r[m]);let s=this.unplaced,l=i?i.content:s.content,a=s.openStart-e,c=0,d=[],{match:h,type:u}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)d.push(o.child(m));h=h.matchFragment(o)}let f=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),g=h.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(h=g,d.push(Fl(m.mark(u.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=Qt(this.placed,t,w.from(d)),this.frontier[t].match=h,p&&f<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<f;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?C.empty:new C(Xt(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new C(Xt(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||!Di(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:i}=this.$to,o=this.$to.after(i);for(;i>1&&o==this.$to.end(--i);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:i,type:o}=this.frontier[t],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=Di(e,t,o,i,r);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Di(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:s,move:r?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=Qt(this.placed,t.depth,t.fit)),e=t.move;for(let i=t.depth+1;i<=e.depth;i++){let o=e.node(i),r=o.type.contentMatch.fillBefore(o.content,!0,e.index(i));this.openFrontierNode(o.type,o.attrs,r)}return e}openFrontierNode(e,t=null,i){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Qt(this.placed,this.depth,w.from(e.create(t,i))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(w.empty,!0);t.childCount&&(this.placed=Qt(this.placed,this.frontier.length,t))}}function Xt(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Xt(n.firstChild.content,e-1,t)))}function Qt(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Qt(n.lastChild.content,e-1,t)))}function Ni(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Fl(n,e,t){if(e<=0)return n;let i=n.content;return e>1&&(i=i.replaceChild(0,Fl(i.firstChild,e-1,i.childCount==1?t-1:0))),e>0&&(i=n.type.contentMatch.fillBefore(i).append(i),t<=0&&(i=i.append(n.type.contentMatch.matchFragment(i).fillBefore(w.empty,!0)))),n.copy(i)}function Di(n,e,t,i,o){let r=n.node(e),s=o?n.indexAfter(e):n.index(e);if(s==r.childCount&&!t.compatibleContent(r.type))return null;let l=i.fillBefore(r.content,!0,s);return l&&!zh(t,r.content,s)?l:null}function zh(n,e,t){for(let i=t;i<e.childCount;i++)if(!n.allowsMarks(e.child(i).marks))return!0;return!1}function Bh(n){return n.spec.defining||n.spec.definingForContent}function Hh(n,e,t,i){if(!i.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),r=n.doc.resolve(t);if(Hl(o,r,i))return n.step(new U(e,t,i));let s=Wl(o,n.doc.resolve(t));s[s.length-1]==0&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let u=o.depth,f=o.pos-1;u>0;u--,f--){let p=o.node(u).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(u)>-1?l=u:o.before(u)==f&&s.splice(1,0,-u)}let a=s.indexOf(l),c=[],d=i.openStart;for(let u=i.content,f=0;;f++){let p=u.firstChild;if(c.push(p),f==i.openStart)break;u=p.content}for(let u=d-1;u>=0;u--){let f=c[u],p=Bh(f.type);if(p&&!f.sameMarkup(o.node(Math.abs(l)-1)))d=u;else if(p||!f.type.isTextblock)break}for(let u=i.openStart;u>=0;u--){let f=(u+d+1)%(i.openStart+1),p=c[f];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 x=o.node(g-1),b=o.index(g-1);if(x.canReplaceWith(b,b,p.type,p.marks))return n.replace(o.before(g),y?r.after(g):t,new C($l(i.content,0,i.openStart,f),f,i.openEnd))}}let h=n.steps.length;for(let u=s.length-1;u>=0&&(n.replace(e,t,i),!(n.steps.length>h));u--){let f=s[u];f<0||(e=o.before(f),t=r.after(f))}}function $l(n,e,t,i,o){if(e<t){let r=n.firstChild;n=n.replaceChild(0,r.copy($l(r.content,e+1,t,i,r)))}if(e>i){let r=o.contentMatchAt(0),s=r.fillBefore(n).append(n);n=s.append(r.matchFragment(s).fillBefore(w.empty,!0))}return n}function Fh(n,e,t,i){if(!i.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=Rh(n.doc,e,i.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new C(w.from(i),0,0))}function $h(n,e,t){let i=n.doc.resolve(e),o=n.doc.resolve(t),r=Wl(i,o);for(let s=0;s<r.length;s++){let l=r[s],a=s==r.length-1;if(a&&l==0||i.node(l).type.contentMatch.validEnd)return n.delete(i.start(l),o.end(l));if(l>0&&(a||i.node(l-1).canReplace(i.index(l-1),o.indexAfter(l-1))))return n.delete(i.before(l),o.after(l))}for(let s=1;s<=i.depth&&s<=o.depth;s++)if(e-i.start(s)==i.depth-s&&t>i.end(s)&&o.end(s)-t!=o.depth-s&&i.start(s-1)==o.start(s-1)&&i.node(s-1).canReplace(i.index(s-1),o.index(s-1)))return n.delete(i.before(s),t);n.delete(e,t)}function Wl(n,e){let t=[],i=Math.min(n.depth,e.depth);for(let o=i;o>=0;o--){let r=n.start(o);if(r<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;(r==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==r-1)&&t.push(o)}return t}class Lt extends X{constructor(e,t,i){super(),this.pos=e,this.attr=t,this.value=i}apply(e){let t=e.nodeAt(this.pos);if(!t)return F.fail("No node at attribute step's position");let i=Object.create(null);for(let r in t.attrs)i[r]=t.attrs[r];i[this.attr]=this.value;let o=t.type.create(i,null,t.marks);return F.fromReplace(e,this.pos,this.pos+1,new C(w.from(o),0,t.isLeaf?0:1))}getMap(){return le.empty}invert(e){return new Lt(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 Lt(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 Lt(t.pos,t.attr,t.value)}}X.jsonID("attr",Lt);class dn extends X{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 i=e.type.create(t,e.content,e.marks);return F.ok(i)}getMap(){return le.empty}invert(e){return new dn(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 dn(t.attr,t.value)}}X.jsonID("docAttr",dn);let $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";class _l{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Rt}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}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,i=C.empty){let o=Io(this.doc,e,t,i);return o&&this.step(o),this}replaceWith(e,t,i){return this.replace(e,t,new C(w.from(i),0,0))}delete(e,t){return this.replace(e,t,C.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,i){return Hh(this,e,t,i),this}replaceRangeWith(e,t,i){return Fh(this,e,t,i),this}deleteRange(e,t){return $h(this,e,t),this}lift(e,t){return Ch(this,e,t),this}join(e,t=1){return Ph(this,e,t),this}wrap(e,t){return Mh(this,e,t),this}setBlockType(e,t=e,i,o=null){return Ah(this,e,t,i,o),this}setNodeMarkup(e,t,i=null,o){return Eh(this,e,t,i,o),this}setNodeAttribute(e,t,i){return this.step(new Lt(e,t,i)),this}setDocAttribute(e,t){return this.step(new dn(e,t)),this}addNodeMark(e,t){return this.step(new qe(e,t)),this}removeNodeMark(e,t){if(!(t instanceof I)){let i=this.doc.nodeAt(e);if(!i)throw new RangeError("No node at position "+e);if(t=t.isInSet(i.marks),!t)return this}return this.step(new Ft(e,t)),this}split(e,t=1,i){return Nh(this,e,t,i),this}addMark(e,t,i){return Sh(this,e,t,i),this}removeMark(e,t,i){return vh(this,e,t,i),this}clearIncompatible(e,t,i){return Do(this,e,t,i),this}}const Ii=Object.create(null);class E{constructor(e,t,i){this.$anchor=e,this.$head=t,this.ranges=i||[new Kl(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=C.empty){let i=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=i,i=i.lastChild;let r=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(r);e.replaceRange(d.map(a.pos),d.map(c.pos),l?C.empty:t),l==0&&Rr(e,r,(i?i.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let i=e.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){let{$from:s,$to:l}=o[r],a=e.mapping.slice(i),c=a.map(s.pos),d=a.map(l.pos);r?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),Rr(e,i,t.isInline?-1:1))}}static findFrom(e,t,i=!1){let o=e.parent.inlineContent?new N(e):At(e.node(0),e.parent,e.pos,e.index(),t,i);if(o)return o;for(let r=e.depth-1;r>=0;r--){let s=t<0?At(e.node(0),e.node(r),e.before(r+1),e.index(r),t,i):At(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,i);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ce(e.node(0))}static atStart(e){return At(e,e,0,0,1)||new ce(e)}static atEnd(e){return At(e,e,e.content.size,e.childCount,-1)||new ce(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=Ii[t.type];if(!i)throw new RangeError(`No selection type ${t.type} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in Ii)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ii[e]=t,t.prototype.jsonID=e,t}getBookmark(){return N.between(this.$anchor,this.$head).getBookmark()}}E.prototype.visible=!0;class Kl{constructor(e,t){this.$from=e,this.$to=t}}let Ir=!1;function Pr(n){!Ir&&!n.parent.inlineContent&&(Ir=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class N extends E{constructor(e,t=e){Pr(e),Pr(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let i=e.resolve(t.map(this.head));if(!i.parent.inlineContent)return E.near(i);let o=e.resolve(t.map(this.anchor));return new N(o.parent.inlineContent?o:i,i)}replace(e,t=C.empty){if(super.replace(e,t),t==C.empty){let i=this.$from.marksAcross(this.$to);i&&e.ensureMarks(i)}}eq(e){return e instanceof N&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new pi(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,i=t){let o=e.resolve(t);return new this(o,i==t?o:e.resolve(i))}static between(e,t,i){let o=e.pos-t.pos;if((!i||o)&&(i=o>=0?1:-1),!t.parent.inlineContent){let r=E.findFrom(t,i,!0)||E.findFrom(t,-i,!0);if(r)t=r.$head;else return E.near(t,i)}return e.parent.inlineContent||(o==0?e=t:(e=(E.findFrom(e,-i,!0)||E.findFrom(e,i,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new N(e,t)}}E.jsonID("text",N);class pi{constructor(e,t){this.anchor=e,this.head=t}map(e){return new pi(e.map(this.anchor),e.map(this.head))}resolve(e){return N.between(e.resolve(this.anchor),e.resolve(this.head))}}class O extends E{constructor(e){let t=e.nodeAfter,i=e.node(0).resolve(e.pos+t.nodeSize);super(e,i),this.node=t}map(e,t){let{deleted:i,pos:o}=t.mapResult(this.anchor),r=e.resolve(o);return i?E.near(r):new O(r)}content(){return new C(w.from(this.node),0,0)}eq(e){return e instanceof O&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Po(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new O(e.resolve(t.anchor))}static create(e,t){return new O(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}O.prototype.visible=!1;E.jsonID("node",O);class Po{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:i}=e.mapResult(this.anchor);return t?new pi(i,i):new Po(i)}resolve(e){let t=e.resolve(this.anchor),i=t.nodeAfter;return i&&O.isSelectable(i)?new O(t):E.near(t)}}class ce extends E{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=C.empty){if(t==C.empty){e.delete(0,e.doc.content.size);let i=E.atStart(e.doc);i.eq(e.selection)||e.setSelection(i)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ce(e)}map(e){return new ce(e)}eq(e){return e instanceof ce}getBookmark(){return Wh}}E.jsonID("all",ce);const Wh={map(){return this},resolve(n){return new ce(n)}};function At(n,e,t,i,o,r=!1){if(e.inlineContent)return N.create(n,t);for(let s=i-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let l=e.child(s);if(l.isAtom){if(!r&&O.isSelectable(l))return O.create(n,t-(o<0?l.nodeSize:0))}else{let a=At(n,l,t+o,o<0?l.childCount:0,o,r);if(a)return a}t+=l.nodeSize*o}return null}function Rr(n,e,t){let i=n.steps.length-1;if(i<e)return;let o=n.steps[i];if(!(o instanceof U||o instanceof j))return;let r=n.mapping.maps[i],s;r.forEach((l,a,c,d)=>{s==null&&(s=d)}),n.setSelection(E.near(n.doc.resolve(s),t))}const Vr=1,Pn=2,Lr=4;class _h extends _l{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|Vr)&~Pn,this.storedMarks=null,this}get selectionSet(){return(this.updated&Vr)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Pn,this}ensureMarks(e){return I.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&Pn)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Pn,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let i=this.selection;return t&&(e=e.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||I.none))),i.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,i){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(i==null&&(i=t),i=i??t,!e)return this.deleteRange(t,i);let r=this.storedMarks;if(!r){let s=this.doc.resolve(t);r=i==t?s.marks():s.marksAcross(this.doc.resolve(i))}return this.replaceRangeWith(t,i,o.text(e,r)),this.selection.empty||this.setSelection(E.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|=Lr,this}get scrolledIntoView(){return(this.updated&Lr)>0}}function zr(n,e){return!e||!n?n:n.bind(e)}class en{constructor(e,t,i){this.name=e,this.init=zr(t.init,i),this.apply=zr(t.apply,i)}}const Kh=[new en("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new en("selection",{init(n,e){return n.selection||E.atStart(e.doc)},apply(n){return n.selection}}),new en("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,i){return i.selection.$cursor?n.storedMarks:null}}),new en("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Pi{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Kh.slice(),t&&t.forEach(i=>{if(this.pluginsByKey[i.key])throw new RangeError("Adding different instances of a keyed plugin ("+i.key+")");this.plugins.push(i),this.pluginsByKey[i.key]=i,i.spec.state&&this.fields.push(new en(i.key,i.spec.state,i))})}}class Nt{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 i=0;i<this.config.plugins.length;i++)if(i!=t){let o=this.config.plugins[i];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],i=this.applyInner(e),o=null;for(;;){let r=!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,i);if(d&&i.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!o){o=[];for(let h=0;h<this.config.plugins.length;h++)o.push(h<s?{state:i,n:t.length}:{state:this,n:0})}t.push(d),i=i.applyInner(d),r=!0}o&&(o[s]={state:i,n:t.length})}}if(!r)return{state:i,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Nt(this.config),i=this.config.fields;for(let o=0;o<i.length;o++){let r=i[o];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new _h(this)}static create(e){let t=new Pi(e.doc?e.doc.type.schema:e.schema,e.plugins),i=new Nt(t);for(let o=0;o<t.fields.length;o++)i[t.fields[o].name]=t.fields[o].init(e,i);return i}reconfigure(e){let t=new Pi(this.schema,e.plugins),i=t.fields,o=new Nt(t);for(let r=0;r<i.length;r++){let s=i[r].name;o[s]=this.hasOwnProperty(s)?this[s]:i[r].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(i=>i.toJSON())),e&&typeof e=="object")for(let i in e){if(i=="doc"||i=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[i],r=o.spec.state;r&&r.toJSON&&(t[i]=r.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,i){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Pi(e.schema,e.plugins),r=new Nt(o);return o.fields.forEach(s=>{if(s.name=="doc")r.doc=ht.fromJSON(e.schema,t.doc);else if(s.name=="selection")r.selection=E.fromJSON(r.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(i)for(let l in i){let a=i[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){r[s.name]=c.fromJSON.call(a,e,t[l],r);return}}r[s.name]=s.init(e,r)}}),r}}function ql(n,e,t){for(let i in n){let o=n[i];o instanceof Function?o=o.bind(e):i=="handleDOMEvents"&&(o=ql(o,e,{})),t[i]=o}return t}class gn{constructor(e){this.spec=e,this.props={},e.props&&ql(e.props,this,this.props),this.key=e.key?e.key.key:jl("plugin")}getState(e){return e[this.key]}}const Ri=Object.create(null);function jl(n){return n in Ri?n+"$"+ ++Ri[n]:(Ri[n]=0,n+"$")}class yn{constructor(e="key"){this.key=jl(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Jl=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function qh(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const jh=(n,e,t)=>{let i=qh(n,t);if(!i)return!1;let o=Gl(i);if(!o){let s=i.blockRange(),l=s&&ui(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let r=o.nodeBefore;if(ea(n,o,e,-1))return!0;if(i.parent.content.size==0&&(Wt(r,"end")||O.isSelectable(r)))for(let s=i.depth;;s--){let l=Io(n.doc,i.before(s),i.after(s),C.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Wt(r,"end")?E.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):O.create(a.doc,o.pos-r.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||i.node(s-1).childCount>1)break}return r.isAtom&&o.depth==i.depth-1?(e&&e(n.tr.delete(o.pos-r.nodeSize,o.pos).scrollIntoView()),!0):!1};function Wt(n,e,t=!1){for(let i=n;i;i=e=="start"?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(t&&i.childCount!=1)return!1}return!1}const Jh=(n,e,t)=>{let{$head:i,empty:o}=n.selection,r=i;if(!o)return!1;if(i.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):i.parentOffset>0)return!1;r=Gl(i)}let s=r&&r.nodeBefore;return!s||!O.isSelectable(s)?!1:(e&&e(n.tr.setSelection(O.create(n.doc,r.pos-s.nodeSize)).scrollIntoView()),!0)};function Gl(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 Gh(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Uh=(n,e,t)=>{let i=Gh(n,t);if(!i)return!1;let o=Ul(i);if(!o)return!1;let r=o.nodeAfter;if(ea(n,o,e,1))return!0;if(i.parent.content.size==0&&(Wt(r,"start")||O.isSelectable(r))){let s=Io(n.doc,i.before(),i.after(),C.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=n.tr.step(s);l.setSelection(Wt(r,"start")?E.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):O.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return r.isAtom&&o.depth==i.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+r.nodeSize).scrollIntoView()),!0):!1},Zh=(n,e,t)=>{let{$head:i,empty:o}=n.selection,r=i;if(!o)return!1;if(i.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):i.parentOffset<i.parent.content.size)return!1;r=Ul(i)}let s=r&&r.nodeAfter;return!s||!O.isSelectable(s)?!1:(e&&e(n.tr.setSelection(O.create(n.doc,r.pos)).scrollIntoView()),!0)};function Ul(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}const Yh=(n,e)=>{let{$head:t,$anchor:i}=n.selection;return!t.parent.type.spec.code||!t.sameParent(i)?!1:(e&&e(n.tr.insertText(`
125
- `).scrollIntoView()),!0)};function Ro(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Zl=(n,e)=>{let{$head:t,$anchor:i}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(i))return!1;let o=t.node(-1),r=t.indexAfter(-1),s=Ro(o.contentMatchAt(r));if(!s||!o.canReplaceWith(r,r,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(E.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Xh=(n,e)=>{let t=n.selection,{$from:i,$to:o}=t;if(t instanceof ce||i.parent.inlineContent||o.parent.inlineContent)return!1;let r=Ro(o.parent.contentMatchAt(o.indexAfter()));if(!r||!r.isTextblock)return!1;if(e){let s=(!i.parentOffset&&o.index()<o.parent.childCount?i:o).pos,l=n.tr.insert(s,r.createAndFill());l.setSelection(N.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},Yl=(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 r=t.before();if(Vt(n.doc,r))return e&&e(n.tr.split(r).scrollIntoView()),!0}let i=t.blockRange(),o=i&&ui(i);return o==null?!1:(e&&e(n.tr.lift(i,o).scrollIntoView()),!0)};function Xl(n){return(e,t)=>{let{$from:i,$to:o}=e.selection;if(e.selection instanceof O&&e.selection.node.isBlock)return!i.parentOffset||!Vt(e.doc,i.pos)?!1:(t&&t(e.tr.split(i.pos).scrollIntoView()),!0);if(!i.depth)return!1;let r=[],s,l,a=!1,c=!1;for(let f=i.depth;;f--)if(i.node(f).isBlock){a=i.end(f)==i.pos+(i.depth-f),c=i.start(f)==i.pos-(i.depth-f),l=Ro(i.node(f-1).contentMatchAt(i.indexAfter(f-1)));let m=n&&n(o.parent,a,i);r.unshift(m||(a&&l?{type:l}:null)),s=f;break}else{if(f==1)return!1;r.unshift(null)}let d=e.tr;(e.selection instanceof N||e.selection instanceof ce)&&d.deleteSelection();let h=d.mapping.map(i.pos),u=Vt(d.doc,h,r.length,r);if(u||(r[0]=l?{type:l}:null,u=Vt(d.doc,h,r.length,r)),d.split(h,r.length,r),!a&&c&&i.node(s).type!=l){let f=d.mapping.map(i.before(s)),p=d.doc.resolve(f);l&&i.node(s-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(i.before(s)),l)}return t&&t(d.scrollIntoView()),!0}}const Qh=Xl(),Ql=(n,e)=>(e&&e(n.tr.setSelection(new ce(n.doc))),!0);function eu(n,e,t){let i=e.nodeBefore,o=e.nodeAfter,r=e.index();return!i||!o||!i.type.compatibleContent(o.type)?!1:!i.content.size&&e.parent.canReplace(r-1,r)?(t&&t(n.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(r,r+1)||!(o.isTextblock||fi(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function ea(n,e,t,i){let o=e.nodeBefore,r=e.nodeAfter,s,l,a=o.type.spec.isolating||r.type.spec.isolating;if(!a&&eu(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(r.type))&&l.matchType(s[0]||r.type).validEnd){if(t){let f=e.pos+r.nodeSize,p=w.empty;for(let y=s.length-1;y>=0;y--)p=w.from(s[y].create(null,p));p=w.from(o.copy(p));let m=n.tr.step(new j(e.pos-1,f,e.pos,f,new C(p,1,0),s.length,!0)),g=m.doc.resolve(f+2*s.length);g.nodeAfter&&g.nodeAfter.type==o.type&&fi(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=r.type.spec.isolating||i>0&&a?null:E.findFrom(e,1),h=d&&d.$from.blockRange(d.$to),u=h&&ui(h);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(h,u).scrollIntoView()),!0;if(c&&Wt(r,"start",!0)&&Wt(o,"end")){let f=o,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let m=r,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(t){let y=w.empty;for(let b=p.length-1;b>=0;b--)y=w.from(p[b].copy(y));let x=n.tr.step(new j(e.pos-p.length,e.pos+r.nodeSize,e.pos+g,e.pos+r.nodeSize-g,new C(y,p.length,0),0,!0));t(x.scrollIntoView())}return!0}}return!1}function ta(n){return function(e,t){let i=e.selection,o=n<0?i.$from:i.$to,r=o.depth;for(;o.node(r).isInline;){if(!r)return!1;r--}return o.node(r).isTextblock?(t&&t(e.tr.setSelection(N.create(e.doc,n<0?o.start(r):o.end(r)))),!0):!1}}const tu=ta(-1),nu=ta(1);function iu(n,e=null){return function(t,i){let o=!1;for(let r=0;r<t.selection.ranges.length&&!o;r++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[r];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),h=d.index();o=d.parent.canReplaceWith(h,h+1,n)}})}if(!o)return!1;if(i){let r=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[s];r.setBlockType(l,a,n,e)}i(r.scrollIntoView())}return!0}}function ou(n,e,t,i){for(let o=0;o<e.length;o++){let{$from:r,$to:s}=e[o],l=r.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(r.pos,s.pos,(a,c)=>{if(l||!i)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function it(n,e=null,t){let i=t!==!1;return function(o,r){let{empty:s,$cursor:l,ranges:a}=o.selection;if(s&&!l||!ou(o.doc,a,n,i))return!1;if(r)if(l)n.isInSet(o.storedMarks||l.marks())?r(o.tr.removeStoredMark(n)):r(o.tr.addStoredMark(n.create(e)));else{let c,d=o.tr;c=!a.some(h=>o.doc.rangeHasMark(h.$from.pos,h.$to.pos,n));for(let h=0;h<a.length;h++){let{$from:u,$to:f}=a[h];if(!c)d.removeMark(u.pos,f.pos,n);else{let p=u.pos,m=f.pos,g=u.nodeAfter,y=f.nodeBefore,x=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,b=y&&y.isText?/\s*$/.exec(y.text)[0].length:0;p+x<m&&(p+=x,m-=b),d.addMark(p,m,n.create(e))}}r(d.scrollIntoView())}return!0}}function hn(...n){return function(e,t,i){for(let o=0;o<n.length;o++)if(n[o](e,t,i))return!0;return!1}}let Vi=hn(Jl,jh,Jh),Br=hn(Jl,Uh,Zh);const Pe={Enter:hn(Yh,Xh,Yl,Qh),"Mod-Enter":Zl,Backspace:Vi,"Mod-Backspace":Vi,"Shift-Backspace":Vi,Delete:Br,"Mod-Delete":Br,"Mod-a":Ql},na={"Ctrl-h":Pe.Backspace,"Alt-Backspace":Pe["Mod-Backspace"],"Ctrl-d":Pe.Delete,"Ctrl-Alt-Backspace":Pe["Mod-Delete"],"Alt-Delete":Pe["Mod-Delete"],"Alt-d":Pe["Mod-Delete"],"Ctrl-a":tu,"Ctrl-e":nu};for(let n in Pe)na[n]=Pe[n];const ru=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,su=ru?na:Pe;var ti=200,$=function(){};$.prototype.append=function(e){return e.length?(e=$.from(e),!this.length&&e||e.length<ti&&this.leafAppend(e)||this.length<ti&&e.leafPrepend(this)||this.appendInner(e)):this};$.prototype.prepend=function(e){return e.length?$.from(e).append(this):this};$.prototype.appendInner=function(e){return new lu(this,e)};$.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?$.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};$.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};$.prototype.forEach=function(e,t,i){t===void 0&&(t=0),i===void 0&&(i=this.length),t<=i?this.forEachInner(e,t,i,0):this.forEachInvertedInner(e,t,i,0)};$.prototype.map=function(e,t,i){t===void 0&&(t=0),i===void 0&&(i=this.length);var o=[];return this.forEach(function(r,s){return o.push(e(r,s))},t,i),o};$.from=function(e){return e instanceof $?e:e&&e.length?new ia(e):$.empty};var ia=function(n){function e(i){n.call(this),this.values=i}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,r){return o==0&&r==this.length?this:new e(this.values.slice(o,r))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,r,s,l){for(var a=r;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,r,s,l){for(var a=r-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=ti)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=ti)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}($);$.empty=new ia([]);var lu=function(n){function e(t,i){n.call(this),this.left=t,this.right=i,this.length=t.length+i.length,this.depth=Math.max(t.depth,i.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(i){return i<this.left.length?this.left.get(i):this.right.get(i-this.left.length)},e.prototype.forEachInner=function(i,o,r,s){var l=this.left.length;if(o<l&&this.left.forEachInner(i,o,Math.min(r,l),s)===!1||r>l&&this.right.forEachInner(i,Math.max(o-l,0),Math.min(this.length,r)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,r,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(i,o-l,Math.max(r,l)-l,s+l)===!1||r<l&&this.left.forEachInvertedInner(i,Math.min(o,l),r,s)===!1)return!1},e.prototype.sliceInner=function(i,o){if(i==0&&o==this.length)return this;var r=this.left.length;return o<=r?this.left.slice(i,o):i>=r?this.right.slice(i-r,o-r):this.left.slice(i,r).append(this.right.slice(0,o-r))},e.prototype.leafAppend=function(i){var o=this.right.leafAppend(i);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(i){var o=this.left.leafPrepend(i);if(o)return new e(o,this.right)},e.prototype.appendInner=function(i){return this.left.depth>=Math.max(this.right.depth,i.depth)+1?new e(this.left,new e(this.right,i)):new e(this,i)},e}($);const au=500;class ye{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let i=this.items.length;for(;;i--)if(this.items.get(i-1).selection){--i;break}let o,r;t&&(o=this.remapping(i,this.items.length),r=o.maps.length);let s=e.tr,l,a,c=[],d=[];return this.items.forEach((h,u)=>{if(!h.step){o||(o=this.remapping(i,u+1),r=o.maps.length),r--,d.push(h);return}if(o){d.push(new Se(h.map));let f=h.step.map(o.slice(r)),p;f&&s.maybeStep(f).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new Se(p,void 0,void 0,c.length+d.length))),r--,p&&o.appendMap(p,r)}else s.maybeStep(h.step);if(h.selection)return l=o?h.selection.map(o.slice(r)):h.selection,a=new ye(this.items.slice(0,i).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,i,o){let r=[],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 h=e.steps[d].invert(e.docs[d]),u=new Se(e.mapping.maps[d],h,t),f;(f=a&&a.merge(u))&&(u=f,d?r.pop():l=l.slice(0,l.length-1)),r.push(u),t&&(s++,t=void 0),o||(a=u)}let c=s-i.depth;return c>du&&(l=cu(l,c),s-=c),new ye(l.append(r),s)}remapping(e,t){let i=new Rt;return this.items.forEach((o,r)=>{let s=o.mirrorOffset!=null&&r-o.mirrorOffset>=e?i.maps.length-o.mirrorOffset:void 0;i.appendMap(o.map,s)},e,t),i}addMaps(e){return this.eventCount==0?this:new ye(this.items.append(e.map(t=>new Se(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let i=[],o=Math.max(0,this.items.length-t),r=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(u=>{u.selection&&l--},o);let a=t;this.items.forEach(u=>{let f=r.getMirror(--a);if(f==null)return;s=Math.min(s,f);let p=r.maps[f];if(u.step){let m=e.steps[f].invert(e.docs[f]),g=u.selection&&u.selection.map(r.slice(a+1,f));g&&l++,i.push(new Se(p,m,g))}else i.push(new Se(p))},o);let c=[];for(let u=t;u<s;u++)c.push(new Se(r.maps[u]));let d=this.items.slice(0,o).append(c).append(i),h=new ye(d,l);return h.emptyItemCount()>au&&(h=h.compress(this.items.length-i.length)),h}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),i=t.maps.length,o=[],r=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&r++;else if(s.step){let a=s.step.map(t.slice(i)),c=a&&a.getMap();if(i--,c&&t.appendMap(c,i),a){let d=s.selection&&s.selection.map(t.slice(i));d&&r++;let h=new Se(c.invert(),a,d),u,f=o.length-1;(u=o.length&&o[f].merge(h))?o[f]=u:o.push(h)}}else s.map&&i--},this.items.length,0),new ye($.from(o.reverse()),r)}}ye.empty=new ye($.empty,0);function cu(n,e){let t;return n.forEach((i,o)=>{if(i.selection&&e--==0)return t=o,!1}),n.slice(t)}class Se{constructor(e,t,i,o){this.map=e,this.step=t,this.selection=i,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Se(t.getMap().invert(),t,this.selection)}}}class He{constructor(e,t,i,o,r){this.done=e,this.undone=t,this.prevRanges=i,this.prevTime=o,this.prevComposition=r}}const du=20;function hu(n,e,t,i){let o=t.getMeta(ut),r;if(o)return o.historyState;t.getMeta(pu)&&(n=new He(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(ut))return s.getMeta(ut).redo?new He(n.done.addTransform(t,void 0,i,Wn(e)),n.undone,Hr(t.mapping.maps),n.prevTime,n.prevComposition):new He(n.done,n.undone.addTransform(t,void 0,i,Wn(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)-i.newGroupDelay||!uu(t,n.prevRanges)),c=s?Li(n.prevRanges,t.mapping):Hr(t.mapping.maps);return new He(n.done.addTransform(t,a?e.selection.getBookmark():void 0,i,Wn(e)),ye.empty,c,t.time,l??n.prevComposition)}else return(r=t.getMeta("rebased"))?new He(n.done.rebased(t,r),n.undone.rebased(t,r),Li(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new He(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Li(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function uu(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((i,o)=>{for(let r=0;r<e.length;r+=2)i<=e[r+1]&&o>=e[r]&&(t=!0)}),t}function Hr(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((i,o,r,s)=>e.push(r,s));return e}function Li(n,e){if(!n)return null;let t=[];for(let i=0;i<n.length;i+=2){let o=e.map(n[i],1),r=e.map(n[i+1],-1);o<=r&&t.push(o,r)}return t}function fu(n,e,t){let i=Wn(e),o=ut.get(e).spec.config,r=(t?n.undone:n.done).popEvent(e,i);if(!r)return null;let s=r.selection.resolve(r.transform.doc),l=(t?n.done:n.undone).addTransform(r.transform,e.selection.getBookmark(),o,i),a=new He(t?l:r.remaining,t?r.remaining:l,null,0,-1);return r.transform.setSelection(s).setMeta(ut,{redo:t,historyState:a})}let zi=!1,Fr=null;function Wn(n){let e=n.plugins;if(Fr!=e){zi=!1,Fr=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){zi=!0;break}}return zi}const ut=new yn("history"),pu=new yn("closeHistory");function mu(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new gn({key:ut,state:{init(){return new He(ye.empty,ye.empty,null,0,-1)},apply(e,t,i){return hu(t,i,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let i=t.inputType,o=i=="historyUndo"?ra:i=="historyRedo"?so:null;return o?(t.preventDefault(),o(e.state,e.dispatch)):!1}}}})}function oa(n,e){return(t,i)=>{let o=ut.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(i){let r=fu(o,t,n);r&&i(e?r.scrollIntoView():r)}return!0}}const ra=oa(!1,!0),so=oa(!0,!0);var Ze={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:"'"},ni={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},gu=typeof navigator<"u"&&/Mac/.test(navigator.platform),yu=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var K=0;K<10;K++)Ze[48+K]=Ze[96+K]=String(K);for(var K=1;K<=24;K++)Ze[K+111]="F"+K;for(var K=65;K<=90;K++)Ze[K]=String.fromCharCode(K+32),ni[K]=String.fromCharCode(K);for(var Bi in Ze)ni.hasOwnProperty(Bi)||(ni[Bi]=Ze[Bi]);function bu(n){var e=gu&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||yu&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?ni:Ze)[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}const wu=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Su(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let i,o,r,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))i=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))r=!0;else if(/^mod$/i.test(a))wu?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return i&&(t="Alt-"+t),o&&(t="Ctrl-"+t),s&&(t="Meta-"+t),r&&(t="Shift-"+t),t}function vu(n){let e=Object.create(null);for(let t in n)e[Su(t)]=n[t];return e}function Hi(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 Fi(n){return new gn({props:{handleKeyDown:sa(n)}})}function sa(n){let e=vu(n);return function(t,i){let o=bu(i),r,s=e[Hi(o,i)];if(s&&s(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(i.shiftKey){let l=e[Hi(o,i,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((i.shiftKey||i.altKey||i.metaKey||o.charCodeAt(0)>127)&&(r=Ze[i.keyCode])&&r!=o){let l=e[Hi(r,i)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function $r(n,e=null){return function(t,i){let{$from:o,$to:r}=t.selection,s=o.blockRange(r),l=!1,a=s;if(!s)return!1;if(s.depth>=2&&o.node(s.depth-1).type.compatibleContent(n)&&s.startIndex==0){if(o.index(s.depth-1)==0)return!1;let d=t.doc.resolve(s.start-2);a=new Yn(d,d,s.depth),s.endIndex<s.parent.childCount&&(s=new Yn(o,t.doc.resolve(r.end(s.depth)),s.depth)),l=!0}let c=Ll(a,n,e,s);return c?(i&&i(xu(t.tr,s,c,l,n).scrollIntoView()),!0):!1}}function xu(n,e,t,i,o){let r=w.empty;for(let d=t.length-1;d>=0;d--)r=w.from(t[d].type.create(t[d].attrs,r));n.step(new j(e.start-(i?2:0),e.end,e.start,e.end,new C(r,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-(i?2:0),c=e.parent;for(let d=e.startIndex,h=e.endIndex,u=!0;d<h;d++,u=!1)!u&&Vt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function Cu(n,e){return function(t,i){let{$from:o,$to:r,node:s}=t.selection;if(s&&s.isBlock||o.depth<2||!o.sameParent(r))return!1;let l=o.node(-1);if(l.type!=n)return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||o.node(-3).type!=n||o.index(-2)!=o.node(-2).childCount-1)return!1;if(i){let h=w.empty,u=o.index(-1)?1:o.index(-2)?2:3;for(let y=o.depth-u;y>=o.depth-3;y--)h=w.from(o.node(y).copy(h));let f=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;h=h.append(w.from(n.createAndFill()));let p=o.before(o.depth-(u-1)),m=t.tr.replace(p,o.after(-f),new C(h,4-u,0)),g=-1;m.doc.nodesBetween(p,m.doc.content.size,(y,x)=>{if(g>-1)return!1;y.isTextblock&&y.content.size==0&&(g=x+1)}),g>-1&&m.setSelection(E.near(m.doc.resolve(g))),i(m.scrollIntoView())}return!0}let a=r.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,r.pos),d=a?[null,{type:a}]:void 0;return Vt(c.doc,o.pos,2,d)?(i&&i(c.split(o.pos,2,d).scrollIntoView()),!0):!1}}function lo(n){return function(e,t){let{$from:i,$to:o}=e.selection,r=i.blockRange(o,s=>s.childCount>0&&s.firstChild.type==n);return r?t?i.node(r.depth-1).type==n?ku(e,t,n,r):Tu(e,t,r):!0:!1}}function ku(n,e,t,i){let o=n.tr,r=i.end,s=i.$to.end(i.depth);r<s&&(o.step(new j(r-1,s,r,s,new C(w.from(t.create(null,i.parent.copy())),1,0),1,!0)),i=new Yn(o.doc.resolve(i.$from.pos),o.doc.resolve(s),i.depth));const l=ui(i);if(l==null)return!1;o.lift(i,l);let a=o.mapping.map(r,-1)-1;return fi(o.doc,a)&&o.join(a),e(o.scrollIntoView()),!0}function Tu(n,e,t){let i=n.tr,o=t.parent;for(let f=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)f-=o.child(p).nodeSize,i.delete(f-1,f+1);let r=i.doc.resolve(t.start),s=r.nodeAfter;if(i.mapping.map(t.end)!=t.start+r.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=r.node(-1),d=r.index(-1);if(!c.canReplace(d+(l?0:1),d+1,s.content.append(a?w.empty:w.from(o))))return!1;let h=r.pos,u=h+s.nodeSize;return i.step(new j(h-(l?1:0),u+(a?1:0),h+1,u-1,new C((l?w.empty:w.from(o.copy(w.empty))).append(a?w.empty:w.from(o.copy(w.empty))),l?0:1,a?0:1),l?0:1)),e(i.scrollIntoView()),!0}function Mu(n){return function(e,t){let{$from:i,$to:o}=e.selection,r=i.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!r)return!1;let s=r.startIndex;if(s==0)return!1;let l=r.parent,a=l.child(s-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=w.from(c?n.create():null),h=new C(w.from(n.create(null,w.from(l.type.create(null,d)))),c?3:1,0),u=r.start,f=r.end;t(e.tr.step(new j(u-(c?3:1),f,u,f,h,1,!0)).scrollIntoView())}return!0}}const q=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},un=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let ao=null;const Ie=function(n,e,t){let i=ao||(ao=document.createRange());return i.setEnd(n,t??n.nodeValue.length),i.setStart(n,e||0),i},Au=function(){ao=null},yt=function(n,e,t,i){return t&&(Wr(n,e,t,i,-1)||Wr(n,e,t,i,1))},Ou=/^(img|br|input|textarea|hr)$/i;function Wr(n,e,t,i,o){for(;;){if(n==t&&e==i)return!0;if(e==(o<0?0:fe(n))){let r=n.parentNode;if(!r||r.nodeType!=1||bn(n)||Ou.test(n.nodeName)||n.contentEditable=="false")return!1;e=q(n)+(o<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?fe(n):0}else return!1}}function fe(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Eu(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=fe(n)}else if(n.parentNode&&!bn(n))e=q(n),n=n.parentNode;else return null}}function Nu(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!bn(n))e=q(n)+1,n=n.parentNode;else return null}}function Du(n,e,t){for(let i=e==0,o=e==fe(n);i||o;){if(n==t)return!0;let r=q(n);if(n=n.parentNode,!n)return!1;i=i&&r==0,o=o&&r==fe(n)}}function bn(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)}const mi=function(n){return n.focusNode&&yt(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 Iu(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Pu(n,e,t){if(n.caretPositionFromPoint)try{let i=n.caretPositionFromPoint(e,t);if(i)return{node:i.offsetNode,offset:Math.min(fe(i.offsetNode),i.offset)}}catch{}if(n.caretRangeFromPoint){let i=n.caretRangeFromPoint(e,t);if(i)return{node:i.startContainer,offset:Math.min(fe(i.startContainer),i.startOffset)}}}const Ce=typeof navigator<"u"?navigator:null,_r=typeof document<"u"?document:null,Ye=Ce&&Ce.userAgent||"",co=/Edge\/(\d+)/.exec(Ye),la=/MSIE \d/.exec(Ye),ho=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ye),re=!!(la||ho||co),Je=la?document.documentMode:ho?+ho[1]:co?+co[1]:0,we=!re&&/gecko\/(\d+)/i.test(Ye);we&&+(/Firefox\/(\d+)/.exec(Ye)||[0,0])[1];const uo=!re&&/Chrome\/(\d+)/.exec(Ye),Z=!!uo,aa=uo?+uo[1]:0,te=!re&&!!Ce&&/Apple Computer/.test(Ce.vendor),_t=te&&(/Mobile\/\w+/.test(Ye)||!!Ce&&Ce.maxTouchPoints>2),ue=_t||(Ce?/Mac/.test(Ce.platform):!1),Ru=Ce?/Win/.test(Ce.platform):!1,ge=/Android \d/.test(Ye),wn=!!_r&&"webkitFontSmoothing"in _r.documentElement.style,Vu=wn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Lu(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 Oe(n,e){return typeof n=="number"?n:n[e]}function zu(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,i=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*i}}function Kr(n,e,t){let i=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,r=n.dom.ownerDocument;for(let s=t||n.dom;s;s=un(s)){if(s.nodeType!=1)continue;let l=s,a=l==r.body,c=a?Lu(r):zu(l),d=0,h=0;if(e.top<c.top+Oe(i,"top")?h=-(c.top-e.top+Oe(o,"top")):e.bottom>c.bottom-Oe(i,"bottom")&&(h=e.bottom-e.top>c.bottom-c.top?e.top+Oe(o,"top")-c.top:e.bottom-c.bottom+Oe(o,"bottom")),e.left<c.left+Oe(i,"left")?d=-(c.left-e.left+Oe(o,"left")):e.right>c.right-Oe(i,"right")&&(d=e.right-c.right+Oe(o,"right")),d||h)if(a)r.defaultView.scrollBy(d,h);else{let u=l.scrollLeft,f=l.scrollTop;h&&(l.scrollTop+=h),d&&(l.scrollLeft+=d);let p=l.scrollLeft-u,m=l.scrollTop-f;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function Bu(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),i,o;for(let r=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(r,s);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){i=l,o=a.top;break}}return{refDOM:i,refTop:o,stack:ca(n.dom)}}function ca(n){let e=[],t=n.ownerDocument;for(let i=n;i&&(e.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),n!=t);i=un(i));return e}function Hu({refDOM:n,refTop:e,stack:t}){let i=n?n.getBoundingClientRect().top:0;da(t,i==0?0:i-e)}function da(n,e){for(let t=0;t<n.length;t++){let{dom:i,top:o,left:r}=n[t];i.scrollTop!=o+e&&(i.scrollTop=o+e),i.scrollLeft!=r&&(i.scrollLeft=r)}}let kt=null;function Fu(n){if(n.setActive)return n.setActive();if(kt)return n.focus(kt);let e=ca(n);n.focus(kt==null?{get preventScroll(){return kt={preventScroll:!0},!0}}:void 0),kt||(kt=!1,da(e,0))}function ha(n,e){let t,i=2e8,o,r=0,s=e.top,l=e.top,a,c;for(let d=n.firstChild,h=0;d;d=d.nextSibling,h++){let u;if(d.nodeType==1)u=d.getClientRects();else if(d.nodeType==3)u=Ie(d).getClientRects();else continue;for(let f=0;f<u.length;f++){let p=u[f];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<i){t=d,i=m,o=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&m&&(r=h+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=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)&&(r=h+1)}}return!t&&a&&(t=a,o=c,i=0),t&&t.nodeType==3?$u(t,o):!t||i&&t.nodeType==1?{node:n,offset:r}:ha(t,o)}function $u(n,e){let t=n.nodeValue.length,i=document.createRange();for(let o=0;o<t;o++){i.setEnd(n,o+1),i.setStart(n,o);let r=Be(i,1);if(r.top!=r.bottom&&Vo(e,r))return{node:n,offset:o+(e.left>=(r.left+r.right)/2?1:0)}}return{node:n,offset:0}}function Vo(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Wu(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function _u(n,e,t){let{node:i,offset:o}=ha(e,t),r=-1;if(i.nodeType==1&&!i.firstChild){let s=i.getBoundingClientRect();r=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(i,o,r)}function Ku(n,e,t,i){let o=-1;for(let r=e,s=!1;r!=n.dom;){let l=n.docView.nearestDesc(r,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!s&&a.left>i.left||a.top>i.top?o=l.posBefore:(!s&&a.right<i.left||a.bottom<i.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<0&&!l.node.isText)return(l.node.isBlock?i.top<(a.top+a.bottom)/2:i.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}r=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function ua(n,e,t){let i=n.childNodes.length;if(i&&t.top<t.bottom)for(let o=Math.max(0,Math.min(i-1,Math.floor(i*(e.top-t.top)/(t.bottom-t.top))-2)),r=o;;){let s=n.childNodes[r];if(s.nodeType==1){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Vo(e,c))return ua(s,e,c)}}if((r=(r+1)%i)==o)break}return n}function qu(n,e){let t=n.dom.ownerDocument,i,o=0,r=Pu(t,e.left,e.top);r&&({node:i,offset:o}=r);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=n.dom.getBoundingClientRect();if(!Vo(e,c)||(s=ua(n.dom,e,c),!s))return null}if(te)for(let c=s;i&&c;c=un(c))c.draggable&&(i=void 0);if(s=Wu(s,e),i){if(we&&i.nodeType==1&&(o=Math.min(o,i.childNodes.length),o<i.childNodes.length)){let d=i.childNodes[o],h;d.nodeName=="IMG"&&(h=d.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&o++}let c;wn&&o&&i.nodeType==1&&(c=i.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,i==n.dom&&o==i.childNodes.length-1&&i.lastChild.nodeType==1&&e.top>i.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||i.nodeType!=1||i.childNodes[o-1].nodeName!="BR")&&(l=Ku(n,i,o,e))}l==null&&(l=_u(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function qr(n){return n.top<n.bottom||n.left<n.right}function Be(n,e){let t=n.getClientRects();if(t.length){let i=t[e<0?0:t.length-1];if(qr(i))return i}return Array.prototype.find.call(t,qr)||n.getBoundingClientRect()}const ju=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function fa(n,e,t){let{node:i,offset:o,atom:r}=n.docView.domFromPos(e,t<0?-1:1),s=wn||we;if(i.nodeType==3)if(s&&(ju.test(i.nodeValue)||(t<0?!o:o==i.nodeValue.length))){let a=Be(Ie(i,o,o),t);if(we&&o&&/\s/.test(i.nodeValue[o-1])&&o<i.nodeValue.length){let c=Be(Ie(i,o-1,o-1),-1);if(c.top==a.top){let d=Be(Ie(i,o,o+1),-1);if(d.top!=a.top)return Gt(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==i.nodeValue.length?(a--,d=1):t<0?a--:c++,Gt(Be(Ie(i,a,c),d),d<0)}if(!n.state.doc.resolve(e-(r||0)).parent.inlineContent){if(r==null&&o&&(t<0||o==fe(i))){let a=i.childNodes[o-1];if(a.nodeType==1)return $i(a.getBoundingClientRect(),!1)}if(r==null&&o<fe(i)){let a=i.childNodes[o];if(a.nodeType==1)return $i(a.getBoundingClientRect(),!0)}return $i(i.getBoundingClientRect(),t>=0)}if(r==null&&o&&(t<0||o==fe(i))){let a=i.childNodes[o-1],c=a.nodeType==3?Ie(a,fe(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Gt(Be(c,1),!1)}if(r==null&&o<fe(i)){let a=i.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ie(a,0,s?0:1):a.nodeType==1?a:null:null;if(c)return Gt(Be(c,-1),!0)}return Gt(Be(i.nodeType==3?Ie(i):i,-t),t>=0)}function Gt(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 $i(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 pa(n,e,t){let i=n.state,o=n.root.activeElement;i!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{i!=e&&n.updateState(i),o!=n.dom&&o&&o.focus()}}function Ju(n,e,t){let i=e.selection,o=t=="up"?i.$from:i.$to;return pa(n,e,()=>{let{node:r}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(r,!0);if(!l)break;if(l.node.isBlock){r=l.contentDOM||l.dom;break}r=l.dom.parentNode}let s=fa(n,o.pos,1);for(let l=r.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ie(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})}const Gu=/[\u0590-\u08ac]/;function Uu(n,e,t){let{$head:i}=e.selection;if(!i.parent.isTextblock)return!1;let o=i.parentOffset,r=!o,s=o==i.parent.content.size,l=n.domSelection();return l?!Gu.test(i.parent.textContent)||!l.modify?t=="left"||t=="backward"?r:s:pa(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:h}=n.domSelectionRange(),u=l.caretBidiLevel;l.modify("move",t,"character");let f=i.depth?n.docView.domAfterPos(i.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(d,h),a&&(a!=d||c!=h)&&l.extend&&l.extend(a,c)}catch{}return u!=null&&(l.caretBidiLevel=u),g}):i.pos==i.start()||i.pos==i.end()}let jr=null,Jr=null,Gr=!1;function Zu(n,e,t){return jr==e&&Jr==t?Gr:(jr=e,Jr=t,Gr=t=="up"||t=="down"?Ju(n,e,t):Uu(n,e,t))}const pe=0,Ur=1,st=2,ke=3;class Sn{constructor(e,t,i,o){this.parent=e,this.children=t,this.dom=i,this.contentDOM=o,this.dirty=pe,i.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,i){return!1}matchesHack(e){return!1}parseRule(){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,i=this.posAtStart;;t++){let o=this.children[t];if(o==e)return i;i+=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,i){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(i<0){let r,s;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&!((s=r.pmViewDesc)&&s.parent==this);)r=r.previousSibling;return r?this.posBeforeChild(s)+s.size:this.posAtStart}else{let r,s;if(e==this.contentDOM)r=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.nextSibling}for(;r&&!((s=r.pmViewDesc)&&s.parent==this);)r=r.nextSibling;return r?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>q(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let r=e;;r=r.parentNode){if(r==this.dom){o=!1;break}if(r.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let r=e;;r=r.parentNode){if(r==this.dom){o=!0;break}if(r.nextSibling)break}}return o??i>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let i=!0,o=e;o;o=o.parentNode){let r=this.getDesc(o),s;if(r&&(!t||r.node))if(i&&(s=r.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))i=!1;else return r}}getDesc(e){let t=e.pmViewDesc;for(let i=t;i;i=i.parent)if(i==this)return t}posFromDOM(e,t,i){for(let o=e;o;o=o.parentNode){let r=this.getDesc(o);if(r)return r.localPosFromDOM(e,t,i)}return-1}descAt(e){for(let t=0,i=0;t<this.children.length;t++){let o=this.children[t],r=i+o.size;if(i==e&&r!=i){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<r)return o.descAt(e-i-o.border);i=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let i=0,o=0;for(let r=0;i<this.children.length;i++){let s=this.children[i],l=r+s.size;if(l>e||s instanceof ga){o=e-r;break}r=l}if(o)return this.children[i].domFromPos(o-this.children[i].border,t);for(let r;i&&!(r=this.children[i-1]).size&&r instanceof ma&&r.side>=0;i--);if(t<=0){let r,s=!0;for(;r=i?this.children[i-1]:null,!(!r||r.dom.parentNode==this.contentDOM);i--,s=!1);return r&&t&&s&&!r.border&&!r.domAtom?r.domFromPos(r.size,t):{node:this.contentDOM,offset:r?q(r.dom)+1:0}}else{let r,s=!0;for(;r=i<this.children.length?this.children[i]:null,!(!r||r.dom.parentNode==this.contentDOM);i++,s=!1);return r&&s&&!r.border&&!r.domAtom?r.domFromPos(0,t):{node:this.contentDOM,offset:r?q(r.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,i=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,r=-1;for(let s=i,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 h=l;h>0;h--){let u=this.children[h-1];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(1)){o=q(u.dom)+1;break}e-=u.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 h=this.children[d];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){r=q(h.dom);break}t+=h.size}r==-1&&(r=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:r}}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:i}=this.domFromPos(e,0);if(t.nodeType!=1||i==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[i]}setSelection(e,t,i,o=!1){let r=Math.min(e,t),s=Math.max(e,t);for(let f=0,p=0;f<this.children.length;f++){let m=this.children[f],g=p+m.size;if(r>p&&s<g)return m.setSelection(e-p-m.border,t-p-m.border,i,o);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=i.root.getSelection(),d=i.domSelectionRange(),h=!1;if((we||te)&&e==t){let{node:f,offset:p}=l;if(f.nodeType==3){if(h=!!(p&&f.nodeValue[p-1]==`
126
- `),h&&p==f.nodeValue.length)for(let m=f,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:q(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=f.childNodes[p-1];h=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(we&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let f=d.focusNode.childNodes[d.focusOffset];f&&f.contentEditable=="false"&&(o=!0)}if(!(o||h&&te)&&yt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&yt(a.node,a.offset,d.focusNode,d.focusOffset))return;let u=!1;if((c.extend||e==t)&&!h){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),u=!0}catch{}}if(!u){if(e>t){let p=l;l=a,a=p}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let i=0,o=0;o<this.children.length;o++){let r=this.children[o],s=i+r.size;if(i==s?e<=s&&t>=i:e<s&&t>i){let l=i+r.border,a=s-r.border;if(e>=l&&t<=a){this.dirty=e==i||t==s?st:Ur,e==l&&t==a&&(r.contentLost||r.dom.parentNode!=this.contentDOM)?r.dirty=ke:r.markDirty(e-l,t-l);return}else r.dirty=r.dom==r.contentDOM&&r.dom.parentNode==this.contentDOM&&!r.children.length?st:ke}i=s}this.dirty=st}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let i=e==1?st:Ur;t.dirty<i&&(t.dirty=i)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class ma extends Sn{constructor(e,t,i,o){let r,s=t.type.toDOM;if(typeof s=="function"&&(s=s(i,()=>{if(!r)return o;if(r.parent)return r.parent.posBeforeChild(r)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==pe&&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 side(){return this.widget.type.side}}class Yu extends Sn{constructor(e,t,i,o){super(e,[],t,null),this.textDOM=i,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}}class bt extends Sn{constructor(e,t,i,o,r){super(e,[],i,o),this.mark=t,this.spec=r}static create(e,t,i,o){let r=o.nodeViews[t.type.name],s=r&&r(t,o,i);return(!s||!s.dom)&&(s=wt.renderSpec(document,t.type.spec.toDOM(t,i),null,t.attrs)),new bt(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&ke||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ke&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=pe){let i=this.parent;for(;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=pe}}slice(e,t,i){let o=bt.create(this.parent,this.mark,!0,i),r=this.children,s=this.size;t<s&&(r=po(r,t,s,i)),e>0&&(r=po(r,0,e,i));for(let l=0;l<r.length;l++)r[l].parent=o;return o.children=r,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Ge extends Sn{constructor(e,t,i,o,r,s,l,a,c){super(e,[],r,s),this.node=t,this.outerDeco=i,this.innerDeco=o,this.nodeDOM=l}static create(e,t,i,o,r,s){let l=r.nodeViews[t.type.name],a,c=l&&l(t,r,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},i,o),d=c&&c.dom,h=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:h}=wt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!h&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let u=d;return d=wa(d,i,t),c?a=new Xu(e,t,i,o,d,h||null,u,c,r,s+1):t.isText?new gi(e,t,i,o,d,u,r):new Ge(e,t,i,o,d,h||null,u,r,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let i=this.children[t];if(this.dom.contains(i.dom.parentNode)){e.contentElement=i.dom.parentNode;break}}e.contentElement||(e.getContent=()=>w.empty)}return e}matchesNode(e,t,i){return this.dirty==pe&&e.eq(this.node)&&ii(t,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let i=this.node.inlineContent,o=t,r=e.composing?this.localCompositionInfo(e,t):null,s=r&&r.pos>-1?r:null,l=r&&r.pos<0,a=new ef(this,s&&s.node,e);of(this.node,this.innerDeco,(c,d,h)=>{c.spec.marks?a.syncToMarks(c.spec.marks,i,e):c.type.side>=0&&!h&&a.syncToMarks(d==this.node.childCount?I.none:this.node.child(d).marks,i,e),a.placeWidget(c,e,o)},(c,d,h,u)=>{a.syncToMarks(c.marks,i,e);let f;a.findNodeMatch(c,d,h,u)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(f=a.findIndexWithChild(r.node))>-1&&a.updateNodeAt(c,d,h,f,e)||a.updateNextNode(c,d,h,e,u,o)||a.addNode(c,d,h,e,o),o+=c.nodeSize}),a.syncToMarks([],i,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==st)&&(s&&this.protectLocalComposition(e,s),ya(this.contentDOM,this.children,e),_t&&rf(this.dom))}localCompositionInfo(e,t){let{from:i,to:o}=e.state.selection;if(!(e.state.selection instanceof N)||i<t||o>t+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let s=r.nodeValue,l=sf(this.node.content,s,i-t,o-t);return l<0?null:{node:r,pos:l,text:s}}else return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:i,text:o}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let s=new Yu(this,r,t,o);e.input.compositionNodes.push(s),this.children=po(this.children,i,i+o.length,e,s)}update(e,t,i,o){return this.dirty==ke||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,i,o),!0)}updateInner(e,t,i,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=i,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=pe}updateOuterDeco(e){if(ii(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,i=this.dom;this.dom=ba(this.dom,this.nodeDOM,fo(this.outerDeco,this.node,t),fo(e,this.node,t)),this.dom!=i&&(i.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Zr(n,e,t,i,o){wa(i,e,n);let r=new Ge(void 0,n,e,t,i,i,i,o,0);return r.contentDOM&&r.updateChildren(o,0),r}class gi extends Ge{constructor(e,t,i,o,r,s,l){super(e,t,i,o,r,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,i,o){return this.dirty==ke||this.dirty!=pe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=pe||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=pe,!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,i){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,i)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,i){let o=this.node.cut(e,t),r=document.createTextNode(o.text);return new gi(this.parent,o,this.outerDeco,this.innerDeco,r,r,i)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ke)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ga extends Sn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==pe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Xu extends Ge{constructor(e,t,i,o,r,s,l,a,c,d){super(e,t,i,o,r,s,l,c,d),this.spec=a}update(e,t,i,o){if(this.dirty==ke)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,i);return r&&this.updateInner(e,t,i,o),r}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,i,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,i,o){this.spec.setSelection?this.spec.setSelection(e,t,i.root):super.setSelection(e,t,i,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 ya(n,e,t){let i=n.firstChild,o=!1;for(let r=0;r<e.length;r++){let s=e[r],l=s.dom;if(l.parentNode==n){for(;l!=i;)i=Yr(i),o=!0;i=i.nextSibling}else o=!0,n.insertBefore(l,i);if(s instanceof bt){let a=i?i.previousSibling:n.lastChild;ya(s.contentDOM,s.children,t),i=a?a.nextSibling:n.firstChild}}for(;i;)i=Yr(i),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const rn=function(n){n&&(this.nodeName=n)};rn.prototype=Object.create(null);const lt=[new rn];function fo(n,e,t){if(n.length==0)return lt;let i=t?lt[0]:new rn,o=[i];for(let r=0;r<n.length;r++){let s=n[r].type.attrs;if(s){s.nodeName&&o.push(i=new rn(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&o.length==1&&o.push(i=new rn(e.isInline?"span":"div")),l=="class"?i.class=(i.class?i.class+" ":"")+a:l=="style"?i.style=(i.style?i.style+";":"")+a:l!="nodeName"&&(i[l]=a))}}}return o}function ba(n,e,t,i){if(t==lt&&i==lt)return e;let o=e;for(let r=0;r<i.length;r++){let s=i[r],l=t[r];if(r){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=lt[0]),o=a}Qu(o,l||lt[0],s)}return o}function Qu(n,e,t){for(let i in e)i!="class"&&i!="style"&&i!="nodeName"&&!(i in t)&&n.removeAttribute(i);for(let i in t)i!="class"&&i!="style"&&i!="nodeName"&&t[i]!=e[i]&&n.setAttribute(i,t[i]);if(e.class!=t.class){let i=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let r=0;r<i.length;r++)o.indexOf(i[r])==-1&&n.classList.remove(i[r]);for(let r=0;r<o.length;r++)i.indexOf(o[r])==-1&&n.classList.add(o[r]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=i.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function wa(n,e,t){return ba(n,n,lt,fo(e,t,n.nodeType!=1))}function ii(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 Yr(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class ef{constructor(e,t,i){this.lock=t,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=tf(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let i=e;i<t;i++)this.top.children[i].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,i){let o=0,r=this.stack.length>>1,s=Math.min(r,e.length);for(;o<s&&(o==r-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<r;)this.destroyRest(),this.top.dirty=pe,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[r])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=bt.create(this.top,e[r],t,i);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,i,o){let r=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,i))r=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,i)&&!this.preMatch.matched.has(c)){r=l;break}}return r<0?!1:(this.destroyBetween(this.index,r),this.index++,!0)}updateNodeAt(e,t,i,o,r){let s=this.top.children[o];return s.dirty==ke&&s.dom==s.contentDOM&&(s.dirty=st),s.update(e,t,i,r)?(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 i=e.pmViewDesc;if(i){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==i)return o}return-1}e=t}}updateNextNode(e,t,i,o,r,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Ge){let c=this.preMatch.matched.get(a);if(c!=null&&c!=r)return!1;let d=a.dom,h,u=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=ke&&ii(t,a.outerDeco));if(!u&&a.update(e,t,i,o))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(h=this.recreateWrapper(a,e,t,i,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=st,h.updateChildren(o,s+1),h.dirty=pe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,i,o,r,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ii(i,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=Ge.create(this.top,t,i,o,r,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,i,o,r){let s=Ge.create(this.top,e,t,i,o,r);s.contentDOM&&s.updateChildren(o,r+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,i){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 r=new ma(this.top,e,t,i);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof bt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof gi)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((te||Z)&&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 i=document.createElement(e);e=="IMG"&&(i.className="ProseMirror-separator",i.alt=""),e=="BR"&&(i.className="ProseMirror-trailingBreak");let o=new ga(this.top,[],i,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||e.nodeType==1&&e.contains(this.lock.parentNode))}}function tf(n,e){let t=e,i=t.children.length,o=n.childCount,r=new Map,s=[];e:for(;o>0;){let l;for(;;)if(i){let c=t.children[i-1];if(c instanceof bt)t=c,i=c.children.length;else{l=c,i--;break}}else{if(t==e)break e;i=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,r.set(l,o),s.push(l)}}return{index:o,matched:r,matches:s.reverse()}}function nf(n,e){return n.type.side-e.type.side}function of(n,e,t,i){let o=e.locals(n),r=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);i(d,o,e.forChild(r,d),c),r+=d.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,h;for(;s<o.length&&o[s].to==r;){let g=o[s++];g.widget&&(d?(h||(h=[d])).push(g):d=g)}if(d)if(h){h.sort(nf);for(let g=0;g<h.length;g++)t(h[g],c,!!a)}else t(d,c,!!a);let u,f;if(a)f=-1,u=a,a=null;else if(c<n.childCount)f=c,u=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=r&&l.splice(g--,1);for(;s<o.length&&o[s].from<=r&&o[s].to>r;)l.push(o[s++]);let p=r+u.nodeSize;if(u.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=u.cut(g-r),u=u.cut(0,g-r),p=g,f=-1)}else for(;s<o.length&&o[s].to<p;)s++;let m=u.isInline&&!u.isLeaf?l.filter(g=>!g.inline):l.slice();i(u,m,e.forChild(r,u),f),r=p}}function rf(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 sf(n,e,t,i){for(let o=0,r=0;o<n.childCount&&r<=i;){let s=n.child(o++),l=r;if(r+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<n.childCount;){let c=n.child(o++);if(r+=c.nodeSize,!c.isText)break;a+=c.text}if(r>=t){if(r>=i&&a.slice(i-e.length-l,i-l)==e)return i-e.length;let c=l<i?a.lastIndexOf(e,i-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==i&&a.length>=i+e.length-l&&a.slice(i-l,i-l+e.length)==e)return i}}return-1}function po(n,e,t,i,o){let r=[];for(let s=0,l=0;s<n.length;s++){let a=n[s],c=l,d=l+=a.size;c>=t||d<=e?r.push(a):(c<e&&r.push(a.slice(0,e-c,i)),o&&(r.push(o),o=void 0),d>t&&r.push(a.slice(t-c,a.size,i)))}return r}function Lo(n,e=null){let t=n.domSelectionRange(),i=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),r=o&&o.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=i.resolve(s),a,c;if(mi(t)){for(a=s;o&&!o.node;)o=o.parent;let h=o.node;if(o&&h.isAtom&&O.isSelectable(h)&&o.parent&&!(h.isInline&&Du(t.focusNode,t.focusOffset,o.dom))){let u=o.posBefore;c=new O(s==u?l:i.resolve(u))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let h=s,u=s;for(let f=0;f<t.rangeCount;f++){let p=t.getRangeAt(f);h=Math.min(h,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),u=Math.max(u,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(h<0)return null;[a,s]=u==n.state.selection.anchor?[u,h]:[h,u],l=i.resolve(s)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=i.resolve(a);if(!c){let h=e=="pointer"||n.state.selection.head<l.pos&&!r?1:-1;c=zo(n,d,l,h)}return c}function Sa(n){return n.editable?n.hasFocus():xa(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Re(n,e=!1){let t=n.state.selection;if(va(n,t),!!Sa(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Z){let i=n.domSelectionRange(),o=n.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&yt(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)af(n);else{let{anchor:i,head:o}=t,r,s;Xr&&!(t instanceof N)&&(t.$from.parent.inlineContent||(r=Qr(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(s=Qr(n,t.to))),n.docView.setSelection(i,o,n,e),Xr&&(r&&es(r),s&&es(s)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&lf(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Xr=te||Z&&aa<63;function Qr(n,e){let{node:t,offset:i}=n.docView.domFromPos(e,0),o=i<t.childNodes.length?t.childNodes[i]:null,r=i?t.childNodes[i-1]:null;if(te&&o&&o.contentEditable=="false")return Wi(o);if((!o||o.contentEditable=="false")&&(!r||r.contentEditable=="false")){if(o)return Wi(o);if(r)return Wi(r)}}function Wi(n){return n.contentEditable="true",te&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function es(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function lf(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),i=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=i||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Sa(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function af(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let i=n.cursorWrapper.dom,o=i.nodeName=="IMG";o?t.setStart(i.parentNode,q(i)+1):t.setStart(i,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&re&&Je<=11&&(i.disabled=!0,i.disabled=!1)}function va(n,e){if(e instanceof O){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ts(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ts(n)}function ts(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function zo(n,e,t,i){return n.someProp("createSelectionBetween",o=>o(n,e,t))||N.between(e,t,i)}function ns(n){return n.editable&&!n.hasFocus()?!1:xa(n)}function xa(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function cf(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return yt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function mo(n,e){let{$anchor:t,$head:i}=n.selection,o=e>0?t.max(i):t.min(i),r=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return r&&E.findFrom(r,e)}function Fe(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function is(n,e,t){let i=n.state.selection;if(i instanceof N)if(t.indexOf("s")>-1){let{$head:o}=i,r=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let s=n.state.doc.resolve(o.pos+r.nodeSize*(e<0?-1:1));return Fe(n,new N(i.$anchor,s))}else if(i.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=mo(n.state,e);return o&&o instanceof O?Fe(n,o):!1}else if(!(ue&&t.indexOf("m")>-1)){let o=i.$head,r=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!r||r.isText)return!1;let l=e<0?o.pos-r.nodeSize:o.pos;return r.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?O.isSelectable(r)?Fe(n,new O(e<0?n.state.doc.resolve(o.pos-r.nodeSize):o)):wn?Fe(n,new N(n.state.doc.resolve(e<0?l:l+r.nodeSize))):!1:!1}}else return!1;else{if(i instanceof O&&i.node.isInline)return Fe(n,new N(e>0?i.$to:i.$from));{let o=mo(n.state,e);return o?Fe(n,o):!1}}}function oi(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function sn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Tt(n,e){return e<0?df(n):hf(n)}function df(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let o,r,s=!1;for(we&&t.nodeType==1&&i<oi(t)&&sn(t.childNodes[i],-1)&&(s=!0);;)if(i>0){if(t.nodeType!=1)break;{let l=t.childNodes[i-1];if(sn(l,-1))o=t,r=--i;else if(l.nodeType==3)t=l,i=t.nodeValue.length;else break}}else{if(Ca(t))break;{let l=t.previousSibling;for(;l&&sn(l,-1);)o=t.parentNode,r=q(l),l=l.previousSibling;if(l)t=l,i=oi(t);else{if(t=t.parentNode,t==n.dom)break;i=0}}}s?go(n,t,i):o&&go(n,o,r)}function hf(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let o=oi(t),r,s;for(;;)if(i<o){if(t.nodeType!=1)break;let l=t.childNodes[i];if(sn(l,1))r=t,s=++i;else break}else{if(Ca(t))break;{let l=t.nextSibling;for(;l&&sn(l,1);)r=l.parentNode,s=q(l)+1,l=l.nextSibling;if(l)t=l,i=0,o=oi(t);else{if(t=t.parentNode,t==n.dom)break;i=o=0}}}r&&go(n,r,s)}function Ca(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function uf(n,e){for(;n&&e==n.childNodes.length&&!bn(n);)e=q(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function ff(n,e){for(;n&&!e&&!bn(n);)e=q(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function go(n,e,t){if(e.nodeType!=3){let r,s;(s=uf(e,t))?(e=s,t=0):(r=ff(e,t))&&(e=r,t=r.nodeValue.length)}let i=n.domSelection();if(!i)return;if(mi(i)){let r=document.createRange();r.setEnd(e,t),r.setStart(e,t),i.removeAllRanges(),i.addRange(r)}else i.extend&&i.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&Re(n)},50)}function rs(n,e){let t=n.state.doc.resolve(e);if(!(Z||Ru)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let r=n.coordsAtPos(e-1),s=(r.top+r.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(r.left-o.left)>1)return r.left<o.left?"ltr":"rtl"}if(e<t.end()){let r=n.coordsAtPos(e+1),s=(r.top+r.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(r.left-o.left)>1)return r.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function ss(n,e,t){let i=n.state.selection;if(i instanceof N&&!i.empty||t.indexOf("s")>-1||ue&&t.indexOf("m")>-1)return!1;let{$from:o,$to:r}=i;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=mo(n.state,e);if(s&&s instanceof O)return Fe(n,s)}if(!o.parent.inlineContent){let s=e<0?o:r,l=i instanceof ce?E.near(s,e):E.findFrom(s,e);return l?Fe(n,l):!1}return!1}function ls(n,e){if(!(n.state.selection instanceof N))return!0;let{$head:t,$anchor:i,empty:o}=n.state.selection;if(!t.sameParent(i))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let r=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(r&&!r.isText){let s=n.state.tr;return e<0?s.delete(t.pos-r.nodeSize,t.pos):s.delete(t.pos,t.pos+r.nodeSize),n.dispatch(s),!0}return!1}function as(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function pf(n){if(!te||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let i=e.firstChild;as(n,i,"true"),setTimeout(()=>as(n,i,"false"),20)}return!1}function mf(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function gf(n,e){let t=e.keyCode,i=mf(e);if(t==8||ue&&t==72&&i=="c")return ls(n,-1)||Tt(n,-1);if(t==46&&!e.shiftKey||ue&&t==68&&i=="c")return ls(n,1)||Tt(n,1);if(t==13||t==27)return!0;if(t==37||ue&&t==66&&i=="c"){let o=t==37?rs(n,n.state.selection.from)=="ltr"?-1:1:-1;return is(n,o,i)||Tt(n,o)}else if(t==39||ue&&t==70&&i=="c"){let o=t==39?rs(n,n.state.selection.from)=="ltr"?1:-1:1;return is(n,o,i)||Tt(n,o)}else{if(t==38||ue&&t==80&&i=="c")return ss(n,-1,i)||Tt(n,-1);if(t==40||ue&&t==78&&i=="c")return pf(n)||ss(n,1,i)||Tt(n,1);if(i==(ue?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function ka(n,e){n.someProp("transformCopied",f=>{e=f(e,n)});let t=[],{content:i,openStart:o,openEnd:r}=e;for(;o>1&&r>1&&i.childCount==1&&i.firstChild.childCount==1;){o--,r--;let f=i.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),i=f.content}let s=n.someProp("clipboardSerializer")||wt.fromSchema(n.state.schema),l=Na(),a=l.createElement("div");a.appendChild(s.serializeFragment(i,{document:l}));let c=a.firstChild,d,h=0;for(;c&&c.nodeType==1&&(d=Ea[c.nodeName.toLowerCase()]);){for(let f=d.length-1;f>=0;f--){let p=l.createElement(d[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),h++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${r}${h?` -${h}`:""} ${JSON.stringify(t)}`);let u=n.someProp("clipboardTextSerializer",f=>f(e,n))||e.content.textBetween(0,e.content.size,`
120
+ `}}}),()=>{e.removeType(Pt)}},Nd="Scrollbar",gs=`${jt}scrollbar`,Dd=n=>{const{Components:e}=n;return e.addType(tn,{isComponent:t=>mt(t,gs),model:{defaults:{name:Nd,classes:gs,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{e.removeType(tn)}},Id="Slide",ys=`${jt}slide`,Pd=n=>{const{Components:e}=n;return e.addType(an,{isComponent:t=>mt(t,ys),model:{defaults:{name:Id,classes:ys,icon:ee.slider,draggable:(t,i)=>i.is(Dt)}}}),()=>{e.removeType(an)}},Rd="Wrapper",bs=`${jt}wrapper`,Vd=n=>{const{Components:e}=n,{events:t}=e;return e.addType(Dt,{isComponent:i=>mt(i,bs),model:{defaults:{name:Rd,icon:ee.slider,classes:bs,copyable:!1,removable:!1,draggable:!1,highlightable:!1,droppable:i=>i.is(an)},init(){const i=this.components();this.listenTo(i,"add remove",this.updateSlider)},updateSlider(i){const o=this.closestType(be);if(o){const s=o.getView();o.reloadSlider(),this.em.once(t.scriptMount,()=>{setTimeout(()=>{var r;return(r=s.getSwiper())==null?void 0:r.slideTo(i.index())},100)})}}}}),()=>{e.removeType(Dt)}},Ld="swiperComponent",zd=function(n,e={}){const t={block:{},cdnScript:"https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js",cdnStyle:"https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css",...e},i=[Td(n,t),Ed(n),Vd(n),Pd(n),Od(n),Dd(n)];Se({editor:n,plan:Z.startup,licenseKey:t.licenseKey,pluginName:Ld,cleanup:()=>{i.forEach(o=>o())}})},Bd=ve(zd),Hd=n=>n.dispatchEvent(new CustomEvent("input"));function Fd(n,e){if(!e)return()=>{};const t=n.Components.events,i=d=>n.getSelectedAll().includes(d),o=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),s=d=>d.isChildOf("text"),r=d=>n.getEditing()===d,l=(d,h={})=>{d.trigger("focus",h.event)},a=(d,h)=>{i(d)&&o(d)&&!r(d)&&l(d,h)},c=(d,h)=>{if(i(d)&&!o(d)&&s(d)){const u=d.parents().find(f=>f.isInstanceOf("text"));u&&(l(u,h),setTimeout(()=>n.select(u),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const No=new WeakMap,$d=(n,e)=>{No.set(n,e)},Wd=n=>{No.delete(n)},Mi=n=>No.get(n),Nn=n=>{const e=n.target,t=e.closest(".tox"),i=e.matches(".ephox-snooker-resizer-bar");(t||i)&&n.stopPropagation()},ws=n=>{n.stopPropagation(),n.preventDefault()},_d=(n,e)=>{const t=n.getDoc(),i=n.getWin();if(e!=null&&e.event){const{event:o}=e,{clientX:s,clientY:r}=o;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(s,r);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(s,r);l=t.createRange(),l==null||l.setStart(a.offsetNode,a.offset)}if(l){const a=i.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(l),n.selection.setRng(l)}}else n.execCommand("SelectAll")},Kd=n=>{var c,d;const{el:e,editor:t,componentView:i}=n,o=t.runCommand(X.getStateTheme),s=i.model,r={target:e,inline:!0,skin:(o==null?void 0:o.theme)===_r.dark?"oxide-dark":"oxide",menubar:!1,image_advtab:!0,paste_data_images:!0,statusbar:!1,branding:!1,forced_root_block:"div",plugins:"advlist autolink lists link image media table",toolbar_mode:"sliding",toolbar:"bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"},l=((d=(c=n.pluginOpts)==null?void 0:c.loadConfig)==null?void 0:d.call(c,{config:r,editor:t,componentView:i,component:s}))||{};return{...r,...l}},vs=(n,e=document)=>new Promise((t,i)=>{const o=Array.isArray(n)?[...n]:[n],{head:s}=e,r=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=r.bind(null,l),a.onerror=i,s.appendChild(a)}else t()};r(o)}),qd="rteTinyMce",jd=function(n,e={}){const t={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...e},{cdnScript:i}=t,o=n.Canvas.events,s=async(a,c)=>{const d=a.ownerDocument,h=d.defaultView,u=c==null?void 0:c.view;if(!h||!u){console.warn("Missing required data",{win:h,componentView:u});return}const f=Kd({el:a,editor:n,componentView:u,pluginOpts:t}),m=(await h.tinymce.init(f))[0];if(!m)return;const b=(await window.tinymce.init({...f,target:document.createElement("div")}))[0];return m.ui.show(),d.body.addEventListener("mousedown",Nn),document.body.addEventListener("mousedown",Nn),m.on("Change",()=>Hd(a)),m.on("blur",()=>m.ui.show()),m.on("OpenWindow",function(){var v;const x=(v=d.querySelector(".tox-dialog"))==null?void 0:v.closest(".tox");x&&(x==null?void 0:x.ownerDocument)!==document&&(document.body.appendChild(x),m.once("CloseWindow",()=>{x&&x.ownerDocument===document&&d.body.appendChild(x)}))}),a.addEventListener("dragstart",ws,{capture:!0}),n.runCommand(X.setStateContextMenu,{enabled:!1}),_d(m,c),{rteEditor:m,rteEditorShallow:b}},r=(a,c)=>{a.ownerDocument.body.removeEventListener("mousedown",Nn),document.body.removeEventListener("mousedown",Nn),a.removeEventListener("dragstart",ws,{capture:!0}),n.runCommand(X.setStateContextMenu,{enabled:!0}),c.rteEditor.destroy(),c.rteEditorShallow.destroy()};n.on(o.frameLoad,async({window:a})=>{vs(i,a.document)}),n.onReady(()=>{vs(i,document)}),n.setCustomRte({parseContent:!0,async enable(a,c,d){const h=Mi(a);if(h)return h.rteEditor;const u=await s(a,d);return u&&$d(a,u),u==null?void 0:u.rteEditor},disable(a){const c=Mi(a);c&&(Wd(a),r(a,c))},getContent(a){var d,h;const c=Mi(a);return c?(h=(d=c.rteEditor).getContent)==null?void 0:h.call(d):a.innerHTML}});const l=Fd(n,t.enableOnClick);Se({editor:n,licenseKey:t.licenseKey,plan:Z.startup,pluginName:qd,cleanup:()=>{n.RichTextEditor.customRte=void 0,l()}})},Jd=ve(jd);function _(n){this.content=n}_.prototype={constructor:_,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 i=t&&t!=n?this.remove(t):this,o=i.find(n),s=i.content.slice();return o==-1?s.push(t||n,e):(s[o+1]=e,t&&(s[o]=t)),new _(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 _(t)},addToStart:function(n,e){return new _([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new _(t)},addBefore:function(n,e,t){var i=this.remove(e),o=i.content.slice(),s=i.find(n);return o.splice(s==-1?o.length:s,0,e,t),new _(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=_.from(n),n.size?new _(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=_.from(n),n.size?new _(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=_.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}};_.from=function(n){if(n instanceof _)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new _(e)};function pl(n,e,t){for(let i=0;;i++){if(i==n.childCount||i==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(i),s=e.child(i);if(o==s){t+=o.nodeSize;continue}if(!o.sameMarkup(s))return t;if(o.isText&&o.text!=s.text){for(let r=0;o.text[r]==s.text[r];r++)t++;return t}if(o.content.size||s.content.size){let r=pl(o.content,s.content,t+1);if(r!=null)return r}t+=o.nodeSize}}function ml(n,e,t,i){for(let o=n.childCount,s=e.childCount;;){if(o==0||s==0)return o==s?null:{a:t,b:i};let r=n.child(--o),l=e.child(--s),a=r.nodeSize;if(r==l){t-=a,i-=a;continue}if(!r.sameMarkup(l))return{a:t,b:i};if(r.isText&&r.text!=l.text){let c=0,d=Math.min(r.text.length,l.text.length);for(;c<d&&r.text[r.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,i--;return{a:t,b:i}}if(r.content.size||l.content.size){let c=ml(r.content,l.content,t-1,i-1);if(c)return c}t-=a,i-=a}}class w{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let i=0;i<e.length;i++)this.size+=e[i].nodeSize}nodesBetween(e,t,i,o=0,s){for(let r=0,l=0;l<t;r++){let a=this.content[r],c=l+a.nodeSize;if(c>e&&i(a,o+l,s||null,r)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),i,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,i,o){let s="",r=!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)&&i&&(r?r=!1:s+=i),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,i=e.firstChild,o=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(i)&&(o[o.length-1]=t.withText(t.text+i.text),s=1);s<e.content.length;s++)o.push(e.content[s]);return new w(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let i=[],o=0;if(t>e)for(let s=0,r=0;r<t;s++){let l=this.content[s],a=r+l.nodeSize;a>e&&((r<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-r),Math.min(l.text.length,t-r)):l=l.cut(Math.max(0,e-r-1),Math.min(l.content.size,t-r-1))),i.push(l),o+=l.nodeSize),r=a}return new w(i,o)}cutByIndex(e,t){return e==t?w.empty:e==0&&t==this.content.length?this:new w(this.content.slice(e,t))}replaceChild(e,t){let i=this.content[e];if(i==t)return this;let o=this.content.slice(),s=this.size+t.nodeSize-i.nodeSize;return o[e]=t,new w(o,s)}addToStart(e){return new w([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new w(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,i=0;t<this.content.length;t++){let o=this.content[t];e(o,i,t),i+=o.nodeSize}}findDiffStart(e,t=0){return pl(this,e,t)}findDiffEnd(e,t=this.size,i=e.size){return ml(this,e,t,i)}findIndex(e,t=-1){if(e==0)return Dn(0,e);if(e==this.size)return Dn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let i=0,o=0;;i++){let s=this.child(i),r=o+s.nodeSize;if(r>=e)return r==e||t>0?Dn(i+1,r):Dn(i,o);o=r}}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 w.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new w(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return w.empty;let t,i=0;for(let o=0;o<e.length;o++){let s=e[o];i+=s.nodeSize,o&&s.isText&&e[o-1].sameMarkup(s)?(t||(t=e.slice(0,o)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new w(t||e,i)}static from(e){if(!e)return w.empty;if(e instanceof w)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new w([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}w.empty=new w([],0);const Ai={index:0,offset:0};function Dn(n,e){return Ai.index=n,Ai.offset=e,Ai}function Gn(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 i=0;i<n.length;i++)if(!Gn(n[i],e[i]))return!1}else{for(let i in n)if(!(i in e)||!Gn(n[i],e[i]))return!1;for(let i in e)if(!(i in n))return!1}return!0}class I{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,i=!1;for(let o=0;o<e.length;o++){let s=e[o];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,o));else{if(s.type.excludes(this.type))return e;!i&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),i=!0),t&&t.push(s)}}return t||(t=e.slice()),i||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&&Gn(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 i=e.marks[t.type];if(!i)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=i.create(t.attrs);return i.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].eq(t[i]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return I.none;if(e instanceof I)return[e];let t=e.slice();return t.sort((i,o)=>i.type.rank-o.type.rank),t}}I.none=[];class Un extends Error{}class C{constructor(e,t,i){this.content=e,this.openStart=t,this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let i=yl(this.content,e+this.openStart,t);return i&&new C(i,this.openStart,this.openEnd)}removeBetween(e,t){return new C(gl(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 C.empty;let i=t.openStart||0,o=t.openEnd||0;if(typeof i!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new C(w.fromJSON(e,t.content),i,o)}static maxOpen(e,t=!0){let i=0,o=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)i++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)o++;return new C(e,i,o)}}C.empty=new C(w.empty,0,0);function gl(n,e,t){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i),{index:r,offset:l}=n.findIndex(t);if(o==e||s.isText){if(l!=t&&!n.child(r).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(i!=r)throw new RangeError("Removing non-flat range");return n.replaceChild(i,s.copy(gl(s.content,e-o-1,t-o-1)))}function yl(n,e,t,i){let{index:o,offset:s}=n.findIndex(e),r=n.maybeChild(o);if(s==e||r.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=yl(r.content,e-s-1,t);return l&&n.replaceChild(o,r.copy(l))}function Gd(n,e,t){if(t.openStart>n.depth)throw new Un("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Un("Inconsistent open depths");return bl(n,e,t,0)}function bl(n,e,t,i){let o=n.index(i),s=n.node(i);if(o==e.index(i)&&i<n.depth-t.openStart){let r=bl(n,e,t,i+1);return s.copy(s.content.replaceChild(o,r))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==i&&e.depth==i){let r=n.parent,l=r.content;return dt(r,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:r,end:l}=Ud(t,n);return dt(s,vl(n,r,l,e,i))}else return dt(s,Zn(n,e,i))}function wl(n,e){if(!e.type.compatibleContent(n.type))throw new Un("Cannot join "+e.type.name+" onto "+n.type.name)}function no(n,e,t){let i=n.node(t);return wl(i,e.node(t)),i}function ct(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 nn(n,e,t,i){let o=(e||n).node(t),s=0,r=e?e.index(t):o.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(ct(n.nodeAfter,i),s++));for(let l=s;l<r;l++)ct(o.child(l),i);e&&e.depth==t&&e.textOffset&&ct(e.nodeBefore,i)}function dt(n,e){return n.type.checkContent(e),n.copy(e)}function vl(n,e,t,i,o){let s=n.depth>o&&no(n,e,o+1),r=i.depth>o&&no(t,i,o+1),l=[];return nn(null,n,o,l),s&&r&&e.index(o)==t.index(o)?(wl(s,r),ct(dt(s,vl(n,e,t,i,o+1)),l)):(s&&ct(dt(s,Zn(n,e,o+1)),l),nn(e,t,o,l),r&&ct(dt(r,Zn(t,i,o+1)),l)),nn(i,null,o,l),new w(l)}function Zn(n,e,t){let i=[];if(nn(null,n,t,i),n.depth>t){let o=no(n,e,t+1);ct(dt(o,Zn(n,e,t+1)),i)}return nn(e,null,t,i),new w(i)}function Ud(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)o=e.node(s).copy(w.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class cn{constructor(e,t,i){this.pos=e,this.path=t,this.parentOffset=i,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 i=this.pos-this.path[this.path.length-1],o=e.child(t);return i?e.child(t).cut(i):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 i=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)o+=i.child(s).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return I.none;if(this.textOffset)return e.child(t).marks;let i=e.maybeChild(t-1),o=e.maybeChild(t);if(!i){let l=i;i=o,o=l}let s=i.marks;for(var r=0;r<s.length;r++)s[r].type.spec.inclusive===!1&&(!o||!s[r].isInSet(o.marks))&&(s=s[r--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let i=t.marks,o=e.parent.maybeChild(e.index());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}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 i=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);i>=0;i--)if(e.pos<=this.end(i)&&(!t||t(this.node(i))))return new Yn(this,e,i);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 i=[],o=0,s=t;for(let r=e;;){let{index:l,offset:a}=r.content.findIndex(s),c=s-a;if(i.push(r,l,o+a),!c||(r=r.child(l),r.isText))break;s=c-1,o+=a+1}return new cn(t,i,s)}static resolveCached(e,t){let i=Ss.get(e);if(i)for(let s=0;s<i.elts.length;s++){let r=i.elts[s];if(r.pos==t)return r}else Ss.set(e,i=new Zd);let o=i.elts[i.i]=cn.resolve(e,t);return i.i=(i.i+1)%Yd,o}}class Zd{constructor(){this.elts=[],this.i=0}}const Yd=12,Ss=new WeakMap;class Yn{constructor(e,t,i){this.$from=e,this.$to=t,this.depth=i}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Xd=Object.create(null);let ht=class io{constructor(e,t,i,o=I.none){this.type=e,this.attrs=t,this.marks=o,this.content=i||w.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,i,o=0){this.content.nodesBetween(e,t,i,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,i,o){return this.content.textBetween(e,t,i,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,i){return this.type==e&&Gn(this.attrs,t||e.defaultAttrs||Xd)&&I.sameSet(this.marks,i||I.none)}copy(e=null){return e==this.content?this:new io(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new io(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,i=!1){if(e==t)return C.empty;let o=this.resolve(e),s=this.resolve(t),r=i?0:o.sharedDepth(t),l=o.start(r),c=o.node(r).content.cut(o.pos-l,s.pos-l);return new C(c,o.depth-r,s.depth-r)}replace(e,t,i){return Gd(this.resolve(e),this.resolve(t),i)}nodeAt(e){for(let t=this;;){let{index:i,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(i),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:i}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:i}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:i}=this.content.findIndex(e);if(i<e)return{node:this.content.child(t),index:t,offset:i};let o=this.content.child(t-1);return{node:o,index:t-1,offset:i-o.nodeSize}}resolve(e){return cn.resolveCached(this,e)}resolveNoCache(e){return cn.resolve(this,e)}rangeHasMark(e,t,i){let o=!1;return t>e&&this.nodesBetween(e,t,s=>(i.isInSet(s.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,i=w.empty,o=0,s=i.childCount){let r=this.contentMatchAt(e).matchFragment(i,o,s),l=r&&r.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<s;a++)if(!this.type.allowsMarks(i.child(a).marks))return!1;return!0}canReplaceWith(e,t,i,o){if(o&&!this.type.allowsMarks(o))return!1;let s=this.contentMatchAt(e).matchType(i),r=s&&s.matchFragment(this.content,t);return r?r.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),this.type.checkAttrs(this.attrs);let e=I.none;for(let t=0;t<this.marks.length;t++){let i=this.marks[t];i.type.checkAttrs(i.attrs),e=i.addToSet(e)}if(!I.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 i;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=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,i)}let o=w.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,o,i);return s.type.checkAttrs(s.attrs),s}};ht.prototype.text=void 0;class Xn extends ht{constructor(e,t,i,o){if(super(e,t,null,o),!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}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 Xn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Xn(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}class gt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let i=new Qd(e,t);if(i.next==null)return gt.empty;let o=xl(i);i.next&&i.err("Unexpected trailing text");let s=rh(sh(o));return lh(s,i),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,i=e.childCount){let o=this;for(let s=t;o&&s<i;s++)o=o.matchType(e.child(s).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 i=0;i<e.next.length;i++)if(this.next[t].type==e.next[i].type)return!0;return!1}fillBefore(e,t=!1,i=0){let o=[this];function s(r,l){let a=r.matchFragment(e,i);if(a&&(!t||a.validEnd))return w.from(l.map(c=>c.createAndFill()));for(let c=0;c<r.next.length;c++){let{type:d,next:h}=r.next[c];if(!(d.isText||d.hasRequiredAttrs())&&o.indexOf(h)==-1){o.push(h);let u=s(h,l.concat(d));if(u)return u}}return null}return s(this,[])}findWrapping(e){for(let i=0;i<this.wrapCache.length;i+=2)if(this.wrapCache[i]==e)return this.wrapCache[i+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),i=[{match:this,type:null,via:null}];for(;i.length;){let o=i.shift(),s=o.match;if(s.matchType(e)){let r=[];for(let l=o;l.type;l=l.via)r.push(l.type);return r.reverse()}for(let r=0;r<s.next.length;r++){let{type:l,next:a}=s.next[r];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(i.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(i){e.push(i);for(let o=0;o<i.next.length;o++)e.indexOf(i.next[o].next)==-1&&t(i.next[o].next)}return t(this),e.map((i,o)=>{let s=o+(i.validEnd?"*":" ")+" ";for(let r=0;r<i.next.length;r++)s+=(r?", ":"")+i.next[r].type.name+"->"+e.indexOf(i.next[r].next);return s}).join(`
121
+ `)}}gt.empty=new gt(!0);class Qd{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 xl(n){let e=[];do e.push(eh(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function eh(n){let e=[];do e.push(th(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function th(n){let e=oh(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=nh(n,e);else break;return e}function xs(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function nh(n,e){let t=xs(n),i=t;return n.eat(",")&&(n.next!="}"?i=xs(n):i=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:i,expr:e}}function ih(n,e){let t=n.nodeTypes,i=t[e];if(i)return[i];let o=[];for(let s in t){let r=t[s];r.isInGroup(e)&&o.push(r)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function oh(n){if(n.eat("(")){let e=xl(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=ih(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 sh(n){let e=[[]];return o(s(n,0),t()),e;function t(){return e.push([])-1}function i(r,l,a){let c={term:a,to:l};return e[r].push(c),c}function o(r,l){r.forEach(a=>a.to=l)}function s(r,l){if(r.type=="choice")return r.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(r.type=="seq")for(let a=0;;a++){let c=s(r.exprs[a],l);if(a==r.exprs.length-1)return c;o(c,l=t())}else if(r.type=="star"){let a=t();return i(l,a),o(s(r.expr,a),a),[i(a)]}else if(r.type=="plus"){let a=t();return o(s(r.expr,l),a),o(s(r.expr,a),a),[i(a)]}else{if(r.type=="opt")return[i(l)].concat(s(r.expr,l));if(r.type=="range"){let a=l;for(let c=0;c<r.min;c++){let d=t();o(s(r.expr,a),d),a=d}if(r.max==-1)o(s(r.expr,a),a);else for(let c=r.min;c<r.max;c++){let d=t();i(a,d),o(s(r.expr,a),d),a=d}return[i(a)]}else{if(r.type=="name")return[i(l,void 0,r.value)];throw new Error("Unknown expr type")}}}}function Cl(n,e){return e-n}function Cs(n,e){let t=[];return i(e),t.sort(Cl);function i(o){let s=n[o];if(s.length==1&&!s[0].term)return i(s[0].to);t.push(o);for(let r=0;r<s.length;r++){let{term:l,to:a}=s[r];!l&&t.indexOf(a)==-1&&i(a)}}}function rh(n){let e=Object.create(null);return t(Cs(n,0));function t(i){let o=[];i.forEach(r=>{n[r].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]);Cs(n,a).forEach(d=>{c||o.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let s=e[i.join(",")]=new gt(i.indexOf(n.length-1)>-1);for(let r=0;r<o.length;r++){let l=o[r][1].sort(Cl);s.next.push({type:o[r][0],next:e[l.join(",")]||t(l)})}return s}}function lh(n,e){for(let t=0,i=[n];t<i.length;t++){let o=i[t],s=!o.validEnd,r=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];r.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),i.indexOf(c)==-1&&i.push(c)}s&&e.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function kl(n){let e=Object.create(null);for(let t in n){let i=n[t];if(!i.hasDefault)return null;e[t]=i.default}return e}function Tl(n,e){let t=Object.create(null);for(let i in n){let o=e&&e[i];if(o===void 0){let s=n[i];if(s.hasDefault)o=s.default;else throw new RangeError("No value supplied for attribute "+i)}t[i]=o}return t}function Ml(n,e,t,i){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${o}`);for(let o in n){let s=n[o];s.validate&&s.validate(e[o])}}function Al(n,e){let t=Object.create(null);if(e)for(let i in e)t[i]=new ch(n,i,e[i]);return t}let ks=class El{constructor(e,t,i){this.name=e,this.schema=t,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=Al(e,i.attrs),this.defaultAttrs=kl(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==gt.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:Tl(this.attrs,e)}create(e=null,t,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ht(this,this.computeAttrs(e),w.from(t),I.setFrom(i))}createChecked(e=null,t,i){return t=w.from(t),this.checkContent(t),new ht(this,this.computeAttrs(e),t,I.setFrom(i))}createAndFill(e=null,t,i){if(e=this.computeAttrs(e),t=w.from(t),t.size){let r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}let o=this.contentMatch.matchFragment(t),s=o&&o.fillBefore(w.empty,!0);return s?new ht(this,e,t.append(s),I.setFrom(i)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let i=0;i<e.childCount;i++)if(!this.allowsMarks(e.child(i).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){Ml(this.attrs,e,"node",this.name)}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 i=0;i<e.length;i++)this.allowsMarkType(e[i].type)?t&&t.push(e[i]):t||(t=e.slice(0,i));return t?t.length?t:I.none:e}static compile(e,t){let i=Object.create(null);e.forEach((s,r)=>i[s]=new El(s,t,r));let o=t.spec.topNode||"doc";if(!i[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let s in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};function ah(n,e,t){let i=t.split("|");return o=>{let s=o===null?"null":typeof o;if(i.indexOf(s)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${n}, got ${s}`)}}class ch{constructor(e,t,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate=typeof i.validate=="string"?ah(e,t,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class hi{constructor(e,t,i,o){this.name=e,this.rank=t,this.schema=i,this.spec=o,this.attrs=Al(e,o.attrs),this.excluded=null;let s=kl(this.attrs);this.instance=s?new I(this,s):null}create(e=null){return!e&&this.instance?this.instance:new I(this,Tl(this.attrs,e))}static compile(e,t){let i=Object.create(null),o=0;return e.forEach((s,r)=>i[s]=new hi(s,o++,t,r)),i}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]}checkAttrs(e){Ml(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class dh{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=_.from(e.nodes),t.marks=_.from(e.marks||{}),this.nodes=ks.compile(this.spec.nodes,this),this.marks=hi.compile(this.spec.marks,this);let i=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 s=this.nodes[o],r=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=i[r]||(i[r]=gt.parse(r,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?Ts(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let o in this.marks){let s=this.marks[o],r=s.spec.excludes;s.excluded=r==null?[s]:r==""?[]:Ts(this,r.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,i,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ks){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,i,o)}text(e,t){let i=this.nodes.text;return new Xn(i,i.defaultAttrs,e,I.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return ht.fromJSON(this,e)}markFromJSON(e){return I.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Ts(n,e){let t=[];for(let i=0;i<e.length;i++){let o=e[i],s=n.marks[o],r=s;if(s)t.push(s);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(r=a)}if(!r)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return t}function hh(n){return n.tag!=null}function uh(n){return n.style!=null}class Ht{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let i=this.matchedStyles=[];t.forEach(o=>{if(hh(o))this.tags.push(o);else if(uh(o)){let s=/[^=]*/.exec(o.style)[0];i.indexOf(s)<0&&i.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=e.nodes[o.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let i=new As(this,t,!1);return i.addAll(e,I.none,t.from,t.to),i.finish()}parseSlice(e,t={}){let i=new As(this,t,!0);return i.addAll(e,I.none,t.from,t.to),C.maxOpen(i.finish())}matchTag(e,t,i){for(let o=i?this.tags.indexOf(i)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(mh(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let r=s.getAttrs(e);if(r===!1)continue;s.attrs=r||void 0}return s}}}matchStyle(e,t,i,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let r=this.styles[s],l=r.style;if(!(l.indexOf(e)!=0||r.context&&!i.matchesContext(r.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(r.getAttrs){let a=r.getAttrs(t);if(a===!1)continue;r.attrs=a||void 0}return r}}}static schemaRules(e){let t=[];function i(o){let s=o.priority==null?50:o.priority,r=0;for(;r<t.length;r++){let l=t[r];if((l.priority==null?50:l.priority)<s)break}t.splice(r,0,o)}for(let o in e.marks){let s=e.marks[o].spec.parseDOM;s&&s.forEach(r=>{i(r=Es(r)),r.mark||r.ignore||r.clearMark||(r.mark=o)})}for(let o in e.nodes){let s=e.nodes[o].spec.parseDOM;s&&s.forEach(r=>{i(r=Es(r)),r.node||r.ignore||r.mark||(r.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ht(e,Ht.schemaRules(e)))}}const Ol={address:!0,article:!0,aside:!0,blockquote:!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},fh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Nl={ol:!0,ul:!0},Qn=1,ei=2,on=4;function Ms(n,e,t){return e!=null?(e?Qn:0)|(e==="full"?ei:0):n&&n.whitespace=="pre"?Qn|ei:t&~on}class In{constructor(e,t,i,o,s,r){this.type=e,this.attrs=t,this.marks=i,this.solid=o,this.options=r,this.content=[],this.activeMarks=I.none,this.match=s||(r&on?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(w.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let i=this.type.contentMatch,o;return(o=i.findWrapping(e.type))?(this.match=i,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Qn)){let i=this.content[this.content.length-1],o;if(i&&i.isText&&(o=/[ \t\r\n\u000c]+$/.exec(i.text))){let s=i;i.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-o[0].length))}}let t=w.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(w.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&&!Ol.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class As{constructor(e,t,i){this.parser=e,this.options=t,this.isOpen=i,this.open=0;let o=t.topNode,s,r=Ms(null,t.preserveWhitespace,0)|(i?on:0);o?s=new In(o.type,o.attrs,I.none,!0,t.topMatch||o.type.contentMatch,r):i?s=new In(null,null,I.none,!0,null,r):s=new In(e.schema.topNodeType,null,I.none,!0,null,r),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 i=e.nodeValue,o=this.top;if(o.options&ei||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(i)){if(o.options&Qn)o.options&ei?i=i.replace(/\r\n?/g,`
122
+ `):i=i.replace(/\r?\n|\r/g," ");else if(i=i.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let s=o.content[o.content.length-1],r=e.previousSibling;(!s||r&&r.nodeName=="BR"||s.isText&&/[ \t\r\n\u000c]$/.test(s.text))&&(i=i.slice(1))}i&&this.insertNode(this.parser.schema.text(i),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,i){let o=e.nodeName.toLowerCase(),s;Nl.hasOwnProperty(o)&&this.parser.normalizeLists&&ph(e);let r=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(s=this.parser.matchTag(e,this,i));if(r?r.ignore:fh.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!r||r.skip||r.closeParent){r&&r.closeParent?this.open=Math.max(0,this.open-1):r&&r.skip.nodeType&&(e=r.skip);let l,a=this.top,c=this.needsBlock;if(Ol.hasOwnProperty(o))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),l=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);return}let d=r&&r.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),l&&this.sync(a),this.needsBlock=c}else{let l=this.readStyles(e,t);l&&this.addElementByRule(e,r,l,r.consuming===!1?s:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
123
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let i=e.style;if(i&&i.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],r=i.getPropertyValue(s);if(r)for(let l=void 0;;){let a=this.parser.matchStyle(s,r,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,i,o){let s,r;if(t.node)if(r=this.parser.schema.nodes[t.node],r.isLeaf)this.insertNode(r.create(t.attrs),i)||this.leafFallback(e,i);else{let a=this.enter(r,t.attrs||null,i,t.preserveWhitespace);a&&(s=!0,i=a)}else{let a=this.parser.schema.marks[t.mark];i=i.concat(a.create(t.attrs))}let l=this.top;if(r&&r.isLeaf)this.findInside(e);else if(o)this.addElement(e,i,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,i));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,i),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,i,o){let s=i||0;for(let r=i?e.childNodes[i]:e.firstChild,l=o==null?null:e.childNodes[o];r!=l;r=r.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(r,t);this.findAtPoint(e,s)}findPlace(e,t){let i,o;for(let s=this.open;s>=0;s--){let r=this.nodes[s],l=r.findWrapping(e);if(l&&(!i||i.length>l.length)&&(i=l,o=r,!l.length)||r.solid)break}if(!i)return null;this.sync(o);for(let s=0;s<i.length;s++)t=this.enterInner(i[s],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let i=this.findPlace(e,t);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=I.none;for(let r of i.concat(e.marks))(o.type?o.type.allowsMarkType(r.type):Os(r.type,e.type))&&(s=r.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,t,i,o){let s=this.findPlace(e.create(t),i);return s&&(s=this.enterInner(e,t,i,!0,o)),s}enterInner(e,t,i,o=!1,s){this.closeExtra();let r=this.top;r.match=r.match&&r.match.matchType(e);let l=Ms(e,s,r.options);r.options&on&&r.content.length==0&&(l|=on);let a=I.none;return i=i.filter(c=>(r.type?r.type.allowsMarkType(c.type):Os(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new In(e,t,a,o,null,l)),this.open++,i}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;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let i=this.nodes[t].content;for(let o=i.length-1;o>=0;o--)e+=i[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let i=0;i<this.find.length;i++)this.find[i].node==e&&this.find[i].offset==t&&(this.find[i].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,i){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)&(i?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("/"),i=this.options.context,o=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type),s=-(i?i.depth+1:0)+(o?0:1),r=(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(r(l-1,a))return!0;return!1}else{let d=a>0||a==0&&o?this.nodes[a].type:i&&a>=s?i.node(a-s).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return r(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let t in this.parser.schema.nodes){let i=this.parser.schema.nodes[t];if(i.isTextblock&&i.defaultAttrs)return i}}}function ph(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let i=e.nodeType==1?e.nodeName.toLowerCase():null;i&&Nl.hasOwnProperty(i)&&t?(t.appendChild(e),e=t):i=="li"?t=e:i&&(t=null)}}function mh(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Es(n){let e={};for(let t in n)e[t]=n[t];return e}function Os(n,e){let t=e.schema.nodes;for(let i in t){let o=t[i];if(!o.allowsMarkType(n))continue;let s=[],r=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||s.indexOf(d)<0&&r(d))return!0}};if(r(o.contentMatch))return!0}}class wt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},i){i||(i=Ei(t).createDocumentFragment());let o=i,s=[];return e.forEach(r=>{if(s.length||r.marks.length){let l=0,a=0;for(;l<s.length&&a<r.marks.length;){let c=r.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;)o=s.pop()[1];for(;a<r.marks.length;){let c=r.marks[a++],d=this.serializeMark(c,r.isInline,t);d&&(s.push([c,o]),o.appendChild(d.dom),o=d.contentDOM||d.dom)}}o.appendChild(this.serializeNodeInner(r,t))}),i}serializeNodeInner(e,t){let{dom:i,contentDOM:o}=Fn(Ei(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 i}serializeNode(e,t={}){let i=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let s=this.serializeMark(e.marks[o],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(i),i=s.dom)}return i}serializeMark(e,t,i={}){let o=this.marks[e.type.name];return o&&Fn(Ei(i),o(e,t),null,e.attrs)}static renderSpec(e,t,i=null,o){return Fn(e,t,i,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new wt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Ns(e.nodes);return t.text||(t.text=i=>i.text),t}static marksFromSchema(e){return Ns(e.marks)}}function Ns(n){let e={};for(let t in n){let i=n[t].spec.toDOM;i&&(e[t]=i)}return e}function Ei(n){return n.document||window.document}const Ds=new WeakMap;function gh(n){let e=Ds.get(n);return e===void 0&&Ds.set(n,e=yh(n)),e}function yh(n){let e=null;function t(i){if(i&&typeof i=="object")if(Array.isArray(i))if(typeof i[0]=="string")e||(e=[]),e.push(i);else for(let o=0;o<i.length;o++)t(i[o]);else for(let o in i)t(i[o])}return t(n),e}function Fn(n,e,t,i){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(i&&(s=gh(i))&&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 r=o.indexOf(" ");r>0&&(t=o.slice(0,r),o=o.slice(r+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 h in c)if(c[h]!=null){let u=h.indexOf(" ");u>0?a.setAttributeNS(h.slice(0,u),h.slice(u+1),c[h]):a.setAttribute(h,c[h])}}for(let h=d;h<e.length;h++){let u=e[h];if(u===0){if(h<e.length-1||h>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:p}=Fn(n,u,t,i);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Dl=65535,Il=Math.pow(2,16);function bh(n,e){return n+e*Il}function Is(n){return n&Dl}function wh(n){return(n-(n&Dl))/Il}const Pl=1,Rl=2,$n=4,Vl=8;class oo{constructor(e,t,i){this.pos=e,this.delInfo=t,this.recover=i}get deleted(){return(this.delInfo&Vl)>0}get deletedBefore(){return(this.delInfo&(Pl|$n))>0}get deletedAfter(){return(this.delInfo&(Rl|$n))>0}get deletedAcross(){return(this.delInfo&$n)>0}}class le{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&le.empty)return le.empty}recover(e){let t=0,i=Is(e);if(!this.inverted)for(let o=0;o<i;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[i*3]+t+wh(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,i){let o=0,s=this.inverted?2:1,r=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+s],d=this.ranges[l+r],h=a+c;if(e<=h){let u=c?e==a?-1:e==h?1:t:t,f=a+o+(u<0?0:d);if(i)return f;let p=e==(t<0?a:h)?null:bh(l/3,e-a),m=e==a?Rl:e==h?Pl:$n;return(t<0?e!=a:e!=h)&&(m|=Vl),new oo(f,m,p)}o+=d-c}return i?e+o:new oo(e+o,0,null)}touches(e,t){let i=0,o=Is(t),s=this.inverted?2:1,r=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],d=a+c;if(e<=d&&l==o*3)return!0;i+=this.ranges[l+r]-c}return!1}forEach(e){let t=this.inverted?2:1,i=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let r=this.ranges[o],l=r-(this.inverted?s:0),a=r+(this.inverted?0:s),c=this.ranges[o+t],d=this.ranges[o+i];e(l,l+c,a,a+d),s+=d-c}}invert(){return new le(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?le.empty:new le(e<0?[0,-e,0]:[0,0,e])}}le.empty=new le([]);class Rt{constructor(e=[],t,i=0,o=e.length){this.maps=e,this.mirror=t,this.from=i,this.to=o}slice(e=0,t=this.maps.length){return new Rt(this.maps,this.mirror,e,t)}copy(){return new Rt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,i=this.maps.length;t<e.maps.length;t++){let o=e.getMirror(t);this.appendMap(e.maps[t],o!=null&&o<t?i+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,i=this.maps.length+e.maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e.maps[t].invert(),o!=null&&o>t?i-o-1:void 0)}}invert(){let e=new Rt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let i=this.from;i<this.to;i++)e=this.maps[i].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,i){let o=0;for(let s=this.from;s<this.to;s++){let r=this.maps[s],l=r.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}}o|=l.delInfo,e=l.pos}return i?e:new oo(e,o,null)}}const Oi=Object.create(null);class Q{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 i=Oi[t.stepType];if(!i)throw new RangeError(`No step type ${t.stepType} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in Oi)throw new RangeError("Duplicate use of step JSON ID "+e);return Oi[e]=t,t.prototype.jsonID=e,t}}class F{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new F(e,null)}static fail(e){return new F(null,e)}static fromReplace(e,t,i,o){try{return F.ok(e.replace(t,i,o))}catch(s){if(s instanceof Un)return F.fail(s.message);throw s}}}function Do(n,e,t){let i=[];for(let o=0;o<n.childCount;o++){let s=n.child(o);s.content.size&&(s=s.copy(Do(s.content,e,s))),s.isInline&&(s=e(s,t,o)),i.push(s)}return w.fromArray(i)}class Ke extends Q{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=e.resolve(this.from),o=i.node(i.sharedDepth(this.to)),s=new C(Do(t.content,(r,l)=>!r.isAtom||!l.type.allowsMarkType(this.mark.type)?r:r.mark(this.mark.addToSet(r.marks)),o),t.openStart,t.openEnd);return F.fromReplace(e,this.from,this.to,s)}invert(){return new Ce(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new Ke(t.pos,i.pos,this.mark)}merge(e){return e instanceof Ke&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ke(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 Ke(t.from,t.to,e.markFromJSON(t.mark))}}Q.jsonID("addMark",Ke);class Ce extends Q{constructor(e,t,i){super(),this.from=e,this.to=t,this.mark=i}apply(e){let t=e.slice(this.from,this.to),i=new C(Do(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return F.fromReplace(e,this.from,this.to,i)}invert(){return new Ke(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deleted&&i.deleted||t.pos>=i.pos?null:new Ce(t.pos,i.pos,this.mark)}merge(e){return e instanceof Ce&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ce(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 Ce(t.from,t.to,e.markFromJSON(t.mark))}}Q.jsonID("removeMark",Ce);class qe extends Q{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return F.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return F.fromReplace(e,this.pos,this.pos+1,new C(w.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let i=this.mark.addToSet(t.marks);if(i.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(i))return new qe(this.pos,t.marks[o]);return new qe(this.pos,this.mark)}}return new Ft(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new qe(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 qe(t.pos,e.markFromJSON(t.mark))}}Q.jsonID("addNodeMark",qe);class Ft extends Q{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return F.fail("No node at mark step's position");let i=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return F.fromReplace(e,this.pos,this.pos+1,new C(w.from(i),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new qe(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ft(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 Ft(t.pos,e.markFromJSON(t.mark))}}Q.jsonID("removeNodeMark",Ft);class U extends Q{constructor(e,t,i,o=!1){super(),this.from=e,this.to=t,this.slice=i,this.structure=o}apply(e){return this.structure&&so(e,this.from,this.to)?F.fail("Structure replace would overwrite content"):F.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 U(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return t.deletedAcross&&i.deletedAcross?null:new U(t.pos,Math.max(t.pos,i.pos),this.slice)}merge(e){if(!(e instanceof U)||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?C.empty:new C(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new U(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?C.empty:new C(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new U(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 U(t.from,t.to,C.fromJSON(e,t.slice),!!t.structure)}}Q.jsonID("replace",U);class j extends Q{constructor(e,t,i,o,s,r,l=!1){super(),this.from=e,this.to=t,this.gapFrom=i,this.gapTo=o,this.slice=s,this.insert=r,this.structure=l}apply(e){if(this.structure&&(so(e,this.from,this.gapFrom)||so(e,this.gapTo,this.to)))return F.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return F.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,t.content);return i?F.fromReplace(e,this.from,this.to,i):F.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 j(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),i=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?i.pos:e.map(this.gapTo,1);return t.deletedAcross&&i.deletedAcross||o<t.pos||s>i.pos?null:new j(t.pos,i.pos,o,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 j(t.from,t.to,t.gapFrom,t.gapTo,C.fromJSON(e,t.slice),t.insert,!!t.structure)}}Q.jsonID("replaceAround",j);function so(n,e,t){let i=n.resolve(e),o=t-e,s=i.depth;for(;o>0&&s>0&&i.indexAfter(s)==i.node(s).childCount;)s--,o--;if(o>0){let r=i.node(s).maybeChild(i.indexAfter(s));for(;o>0;){if(!r||r.isLeaf)return!0;r=r.firstChild,o--}}return!1}function vh(n,e,t,i){let o=[],s=[],r,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let h=a.marks;if(!i.isInSet(h)&&d.type.allowsMarkType(i.type)){let u=Math.max(c,e),f=Math.min(c+a.nodeSize,t),p=i.addToSet(h);for(let m=0;m<h.length;m++)h[m].isInSet(p)||(r&&r.to==u&&r.mark.eq(h[m])?r.to=f:o.push(r=new Ce(u,f,h[m])));l&&l.to==u?l.to=f:s.push(l=new Ke(u,f,i))}}),o.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function Sh(n,e,t,i){let o=[],s=0;n.doc.nodesBetween(e,t,(r,l)=>{if(!r.isInline)return;s++;let a=null;if(i instanceof hi){let c=r.marks,d;for(;d=i.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else i?i.isInSet(r.marks)&&(a=[i]):a=r.marks;if(a&&a.length){let c=Math.min(l+r.nodeSize,t);for(let d=0;d<a.length;d++){let h=a[d],u;for(let f=0;f<o.length;f++){let p=o[f];p.step==s-1&&h.eq(o[f].style)&&(u=p)}u?(u.to=c,u.step=s):o.push({style:h,from:Math.max(l,e),to:c,step:s})}}}),o.forEach(r=>n.step(new Ce(r.from,r.to,r.style)))}function Io(n,e,t,i=t.contentMatch,o=!0){let s=n.doc.nodeAt(e),r=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),d=l+c.nodeSize,h=i.matchType(c.type);if(!h)r.push(new U(l,d,C.empty));else{i=h;for(let u=0;u<c.marks.length;u++)t.allowsMarkType(c.marks[u].type)||n.step(new Ce(l,d,c.marks[u]));if(o&&c.isText&&t.whitespace!="pre"){let u,f=/\r?\n|\r/g,p;for(;u=f.exec(c.text);)p||(p=new C(w.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),r.push(new U(l+u.index,l+u.index+u[0].length,p))}}l=d}if(!i.validEnd){let a=i.fillBefore(w.empty,!0);n.replace(l,l,new C(a,0,0))}for(let a=r.length-1;a>=0;a--)n.step(r[a])}function xh(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function ui(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let i=n.depth;;--i){let o=n.$from.node(i),s=n.$from.index(i),r=n.$to.indexAfter(i);if(i<n.depth&&o.canReplace(s,r,t))return i;if(i==0||o.type.spec.isolating||!xh(o,s,r))break}return null}function Ch(n,e,t){let{$from:i,$to:o,depth:s}=e,r=i.before(s+1),l=o.after(s+1),a=r,c=l,d=w.empty,h=0;for(let p=s,m=!1;p>t;p--)m||i.index(p)>0?(m=!0,d=w.from(i.node(p).copy(d)),h++):a--;let u=w.empty,f=0;for(let p=s,m=!1;p>t;p--)m||o.after(p+1)<o.end(p)?(m=!0,u=w.from(o.node(p).copy(u)),f++):c++;n.step(new j(a,c,r,l,new C(d.append(u),h,f),d.size-h,!0))}function Ll(n,e,t=null,i=n){let o=kh(n,e),s=o&&Th(i,e);return s?o.map(Ps).concat({type:e,attrs:t}).concat(s.map(Ps)):null}function Ps(n){return{type:n,attrs:null}}function kh(n,e){let{parent:t,startIndex:i,endIndex:o}=n,s=t.contentMatchAt(i).findWrapping(e);if(!s)return null;let r=s.length?s[0]:e;return t.canReplaceWith(i,o,r)?s:null}function Th(n,e){let{parent:t,startIndex:i,endIndex:o}=n,s=t.child(i),r=e.contentMatch.findWrapping(s.type);if(!r)return null;let a=(r.length?r[r.length-1]:e).contentMatch;for(let c=i;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:r}function Mh(n,e,t){let i=w.empty;for(let r=t.length-1;r>=0;r--){if(i.size){let l=t[r].type.contentMatch.matchFragment(i);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=w.from(t[r].type.create(t[r].attrs,i))}let o=e.start,s=e.end;n.step(new j(o,s,o,s,new C(i,0,0),t.length,!0))}function Ah(n,e,t,i,o){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(r,l)=>{let a=typeof o=="function"?o(r):o;if(r.isTextblock&&!r.hasMarkup(i,a)&&Eh(n.doc,n.mapping.slice(s).map(l),i)){let c=null;if(i.schema.linebreakReplacement){let f=i.whitespace=="pre",p=!!i.contentMatch.matchType(i.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&Bl(n,r,l,s),Io(n,n.mapping.slice(s).map(l,1),i,void 0,c===null);let d=n.mapping.slice(s),h=d.map(l,1),u=d.map(l+r.nodeSize,1);return n.step(new j(h,u,h+1,u-1,new C(w.from(i.create(a,null,r.marks)),0,0),1,!0)),c===!0&&zl(n,r,l,s),!1}})}function zl(n,e,t,i){e.forEach((o,s)=>{if(o.isText){let r,l=/\r?\n|\r/g;for(;r=l.exec(o.text);){let a=n.mapping.slice(i).map(t+1+s+r.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Bl(n,e,t,i){e.forEach((o,s)=>{if(o.type==o.type.schema.linebreakReplacement){let r=n.mapping.slice(i).map(t+1+s);n.replaceWith(r,r+1,e.type.schema.text(`
124
+ `))}})}function Eh(n,e,t){let i=n.resolve(e),o=i.index();return i.parent.canReplaceWith(o,o+1,t)}function Oh(n,e,t,i,o){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let r=t.create(i,null,o||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,r);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new j(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new C(w.from(r),0,0),1,!0))}function Vt(n,e,t=1,i){let o=n.resolve(e),s=o.depth-t,r=i&&i[i.length-1]||o.parent;if(s<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!r.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,d=t-2;c>s;c--,d--){let h=o.node(c),u=o.index(c);if(h.type.spec.isolating)return!1;let f=h.content.cutByIndex(u,h.childCount),p=i&&i[d+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let m=i&&i[d]||h;if(!h.canReplace(u+1,h.childCount)||!m.type.validContent(f))return!1}let l=o.indexAfter(s),a=i&&i[0];return o.node(s).canReplaceWith(l,l,a?a.type:o.node(s+1).type)}function Nh(n,e,t=1,i){let o=n.doc.resolve(e),s=w.empty,r=w.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){s=w.from(o.node(l).copy(s));let d=i&&i[c];r=w.from(d?d.type.create(d.attrs,r):o.node(l).copy(r))}n.step(new U(e,e,new C(s.append(r),t,t),!0))}function fi(n,e){let t=n.resolve(e),i=t.index();return Ih(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(i,i+1)}function Dh(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:i}=n.type.schema;for(let o=0;o<e.childCount;o++){let s=e.child(o),r=s.type==i?n.type.schema.nodes.text:s.type;if(t=t.matchType(r),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function Ih(n,e){return!!(n&&e&&!n.isLeaf&&Dh(n,e))}function Ph(n,e,t){let i=null,{linebreakReplacement:o}=n.doc.type.schema,s=n.doc.resolve(e-t),r=s.node().type;if(o&&r.inlineContent){let d=r.whitespace=="pre",h=!!r.contentMatch.matchType(o);d&&!h?i=!1:!d&&h&&(i=!0)}let l=n.steps.length;if(i===!1){let d=n.doc.resolve(e+t);Bl(n,d.node(),d.before(),l)}r.inlineContent&&Io(n,e+t-1,r,s.node().contentMatchAt(s.index()),i==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new U(c,a.map(e+t,-1),C.empty,!0)),i===!0){let d=n.doc.resolve(c);zl(n,d.node(),d.before(),n.steps.length)}return n}function Rh(n,e,t){let i=n.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),t))return e;if(i.parentOffset==0)for(let o=i.depth-1;o>=0;o--){let s=i.index(o);if(i.node(o).canReplaceWith(s,s,t))return i.before(o+1);if(s>0)return null}if(i.parentOffset==i.parent.content.size)for(let o=i.depth-1;o>=0;o--){let s=i.indexAfter(o);if(i.node(o).canReplaceWith(s,s,t))return i.after(o+1);if(s<i.node(o).childCount)return null}return null}function Vh(n,e,t){let i=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let s=0;s<t.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let r=i.depth;r>=0;r--){let l=r==i.depth?0:i.pos<=(i.start(r+1)+i.end(r+1))/2?-1:1,a=i.index(r)+(l>0?1:0),c=i.node(r),d=!1;if(s==1)d=c.canReplace(a,a,o);else{let h=c.contentMatchAt(a).findWrapping(o.firstChild.type);d=h&&c.canReplaceWith(a,a,h[0])}if(d)return l==0?i.pos:l<0?i.before(r+1):i.after(r+1)}return null}function Po(n,e,t=e,i=C.empty){if(e==t&&!i.size)return null;let o=n.resolve(e),s=n.resolve(t);return Hl(o,s,i)?new U(e,t,i):new Lh(o,s,i).fit()}function Hl(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Lh{constructor(e,t,i){this.$from=e,this.$to=t,this.unplaced=i,this.frontier=[],this.placed=w.empty;for(let o=0;o<=e.depth;o++){let s=e.node(o);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=w.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,i=this.$from,o=this.close(e<0?this.$to:i.doc.resolve(e));if(!o)return null;let s=this.placed,r=i.depth,l=o.depth;for(;r&&l&&s.childCount==1;)s=s.firstChild.content,r--,l--;let a=new C(s,r,l);return e>-1?new j(i.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||i.pos!=this.$to.pos?new U(i.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,i=0,o=this.unplaced.openEnd;i<e;i++){let s=t.firstChild;if(t.childCount>1&&(o=0),s.type.spec.isolating&&o<=i){e=i;break}t=s.content}for(let t=1;t<=2;t++)for(let i=t==1?e:this.unplaced.openStart;i>=0;i--){let o,s=null;i?(s=Ni(this.unplaced.content,i-1).firstChild,o=s.content):o=this.unplaced.content;let r=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,h=null;if(t==1&&(r?c.matchType(r.type)||(h=c.fillBefore(w.from(r),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:i,frontierDepth:l,parent:s,inject:h};if(t==2&&r&&(d=c.findWrapping(r.type)))return{sliceDepth:i,frontierDepth:l,parent:s,wrap:d};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:i}=this.unplaced,o=Ni(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new C(e,t+1,Math.max(i,o.size+t>=e.size-i?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:i}=this.unplaced,o=Ni(e,t);if(o.childCount<=1&&t>0){let s=e.size-t<=t+o.size;this.unplaced=new C(Xt(e,t-1,1),t-1,s?t-1:i)}else this.unplaced=new C(Xt(e,t,1),t,i)}placeNodes({sliceDepth:e,frontierDepth:t,parent:i,inject:o,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let r=this.unplaced,l=i?i.content:r.content,a=r.openStart-e,c=0,d=[],{match:h,type:u}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)d.push(o.child(m));h=h.matchFragment(o)}let f=l.size+e-(r.content.size-r.openEnd);for(;c<l.childCount;){let m=l.child(c),g=h.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(h=g,d.push(Fl(m.mark(u.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=Qt(this.placed,t,w.from(d)),this.frontier[t].match=h,p&&f<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<f;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=p?e==0?C.empty:new C(Xt(r.content,e-1,1),e-1,f<0?r.openEnd:e-1):new C(Xt(r.content,e,c),r.openStart,r.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Di(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:i}=this.$to,o=this.$to.after(i);for(;i>1&&o==this.$to.end(--i);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:i,type:o}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),r=Di(e,t,o,i,s);if(r){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Di(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:r,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=Qt(this.placed,t.depth,t.fit)),e=t.move;for(let i=t.depth+1;i<=e.depth;i++){let o=e.node(i),s=o.type.contentMatch.fillBefore(o.content,!0,e.index(i));this.openFrontierNode(o.type,o.attrs,s)}return e}openFrontierNode(e,t=null,i){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Qt(this.placed,this.depth,w.from(e.create(t,i))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(w.empty,!0);t.childCount&&(this.placed=Qt(this.placed,this.frontier.length,t))}}function Xt(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Xt(n.firstChild.content,e-1,t)))}function Qt(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Qt(n.lastChild.content,e-1,t)))}function Ni(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Fl(n,e,t){if(e<=0)return n;let i=n.content;return e>1&&(i=i.replaceChild(0,Fl(i.firstChild,e-1,i.childCount==1?t-1:0))),e>0&&(i=n.type.contentMatch.fillBefore(i).append(i),t<=0&&(i=i.append(n.type.contentMatch.matchFragment(i).fillBefore(w.empty,!0)))),n.copy(i)}function Di(n,e,t,i,o){let s=n.node(e),r=o?n.indexAfter(e):n.index(e);if(r==s.childCount&&!t.compatibleContent(s.type))return null;let l=i.fillBefore(s.content,!0,r);return l&&!zh(t,s.content,r)?l:null}function zh(n,e,t){for(let i=t;i<e.childCount;i++)if(!n.allowsMarks(e.child(i).marks))return!0;return!1}function Bh(n){return n.spec.defining||n.spec.definingForContent}function Hh(n,e,t,i){if(!i.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),s=n.doc.resolve(t);if(Hl(o,s,i))return n.step(new U(e,t,i));let r=Wl(o,n.doc.resolve(t));r[r.length-1]==0&&r.pop();let l=-(o.depth+1);r.unshift(l);for(let u=o.depth,f=o.pos-1;u>0;u--,f--){let p=o.node(u).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;r.indexOf(u)>-1?l=u:o.before(u)==f&&r.splice(1,0,-u)}let a=r.indexOf(l),c=[],d=i.openStart;for(let u=i.content,f=0;;f++){let p=u.firstChild;if(c.push(p),f==i.openStart)break;u=p.content}for(let u=d-1;u>=0;u--){let f=c[u],p=Bh(f.type);if(p&&!f.sameMarkup(o.node(Math.abs(l)-1)))d=u;else if(p||!f.type.isTextblock)break}for(let u=i.openStart;u>=0;u--){let f=(u+d+1)%(i.openStart+1),p=c[f];if(p)for(let m=0;m<r.length;m++){let g=r[(m+a)%r.length],b=!0;g<0&&(b=!1,g=-g);let x=o.node(g-1),y=o.index(g-1);if(x.canReplaceWith(y,y,p.type,p.marks))return n.replace(o.before(g),b?s.after(g):t,new C($l(i.content,0,i.openStart,f),f,i.openEnd))}}let h=n.steps.length;for(let u=r.length-1;u>=0&&(n.replace(e,t,i),!(n.steps.length>h));u--){let f=r[u];f<0||(e=o.before(f),t=s.after(f))}}function $l(n,e,t,i,o){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy($l(s.content,e+1,t,i,s)))}if(e>i){let s=o.contentMatchAt(0),r=s.fillBefore(n).append(n);n=r.append(s.matchFragment(r).fillBefore(w.empty,!0))}return n}function Fh(n,e,t,i){if(!i.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=Rh(n.doc,e,i.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new C(w.from(i),0,0))}function $h(n,e,t){let i=n.doc.resolve(e),o=n.doc.resolve(t),s=Wl(i,o);for(let r=0;r<s.length;r++){let l=s[r],a=r==s.length-1;if(a&&l==0||i.node(l).type.contentMatch.validEnd)return n.delete(i.start(l),o.end(l));if(l>0&&(a||i.node(l-1).canReplace(i.index(l-1),o.indexAfter(l-1))))return n.delete(i.before(l),o.after(l))}for(let r=1;r<=i.depth&&r<=o.depth;r++)if(e-i.start(r)==i.depth-r&&t>i.end(r)&&o.end(r)-t!=o.depth-r&&i.start(r-1)==o.start(r-1)&&i.node(r-1).canReplace(i.index(r-1),o.index(r-1)))return n.delete(i.before(r),t);n.delete(e,t)}function Wl(n,e){let t=[],i=Math.min(n.depth,e.depth);for(let o=i;o>=0;o--){let s=n.start(o);if(s<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;(s==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==s-1)&&t.push(o)}return t}class Lt extends Q{constructor(e,t,i){super(),this.pos=e,this.attr=t,this.value=i}apply(e){let t=e.nodeAt(this.pos);if(!t)return F.fail("No node at attribute step's position");let i=Object.create(null);for(let s in t.attrs)i[s]=t.attrs[s];i[this.attr]=this.value;let o=t.type.create(i,null,t.marks);return F.fromReplace(e,this.pos,this.pos+1,new C(w.from(o),0,t.isLeaf?0:1))}getMap(){return le.empty}invert(e){return new Lt(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 Lt(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 Lt(t.pos,t.attr,t.value)}}Q.jsonID("attr",Lt);class dn extends Q{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 i=e.type.create(t,e.content,e.marks);return F.ok(i)}getMap(){return le.empty}invert(e){return new dn(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 dn(t.attr,t.value)}}Q.jsonID("docAttr",dn);let $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";class _l{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Rt}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}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,i=C.empty){let o=Po(this.doc,e,t,i);return o&&this.step(o),this}replaceWith(e,t,i){return this.replace(e,t,new C(w.from(i),0,0))}delete(e,t){return this.replace(e,t,C.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,i){return Hh(this,e,t,i),this}replaceRangeWith(e,t,i){return Fh(this,e,t,i),this}deleteRange(e,t){return $h(this,e,t),this}lift(e,t){return Ch(this,e,t),this}join(e,t=1){return Ph(this,e,t),this}wrap(e,t){return Mh(this,e,t),this}setBlockType(e,t=e,i,o=null){return Ah(this,e,t,i,o),this}setNodeMarkup(e,t,i=null,o){return Oh(this,e,t,i,o),this}setNodeAttribute(e,t,i){return this.step(new Lt(e,t,i)),this}setDocAttribute(e,t){return this.step(new dn(e,t)),this}addNodeMark(e,t){return this.step(new qe(e,t)),this}removeNodeMark(e,t){if(!(t instanceof I)){let i=this.doc.nodeAt(e);if(!i)throw new RangeError("No node at position "+e);if(t=t.isInSet(i.marks),!t)return this}return this.step(new Ft(e,t)),this}split(e,t=1,i){return Nh(this,e,t,i),this}addMark(e,t,i){return vh(this,e,t,i),this}removeMark(e,t,i){return Sh(this,e,t,i),this}clearIncompatible(e,t,i){return Io(this,e,t,i),this}}const Ii=Object.create(null);class O{constructor(e,t,i){this.$anchor=e,this.$head=t,this.ranges=i||[new Kl(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=C.empty){let i=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=i,i=i.lastChild;let s=e.steps.length,r=this.ranges;for(let l=0;l<r.length;l++){let{$from:a,$to:c}=r[l],d=e.mapping.slice(s);e.replaceRange(d.map(a.pos),d.map(c.pos),l?C.empty:t),l==0&&Ls(e,s,(i?i.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let i=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:r,$to:l}=o[s],a=e.mapping.slice(i),c=a.map(r.pos),d=a.map(l.pos);s?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),Ls(e,i,t.isInline?-1:1))}}static findFrom(e,t,i=!1){let o=e.parent.inlineContent?new N(e):At(e.node(0),e.parent,e.pos,e.index(),t,i);if(o)return o;for(let s=e.depth-1;s>=0;s--){let r=t<0?At(e.node(0),e.node(s),e.before(s+1),e.index(s),t,i):At(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,i);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ce(e.node(0))}static atStart(e){return At(e,e,0,0,1)||new ce(e)}static atEnd(e){return At(e,e,e.content.size,e.childCount,-1)||new ce(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=Ii[t.type];if(!i)throw new RangeError(`No selection type ${t.type} defined`);return i.fromJSON(e,t)}static jsonID(e,t){if(e in Ii)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ii[e]=t,t.prototype.jsonID=e,t}getBookmark(){return N.between(this.$anchor,this.$head).getBookmark()}}O.prototype.visible=!0;class Kl{constructor(e,t){this.$from=e,this.$to=t}}let Rs=!1;function Vs(n){!Rs&&!n.parent.inlineContent&&(Rs=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class N extends O{constructor(e,t=e){Vs(e),Vs(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let i=e.resolve(t.map(this.head));if(!i.parent.inlineContent)return O.near(i);let o=e.resolve(t.map(this.anchor));return new N(o.parent.inlineContent?o:i,i)}replace(e,t=C.empty){if(super.replace(e,t),t==C.empty){let i=this.$from.marksAcross(this.$to);i&&e.ensureMarks(i)}}eq(e){return e instanceof N&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new pi(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,i=t){let o=e.resolve(t);return new this(o,i==t?o:e.resolve(i))}static between(e,t,i){let o=e.pos-t.pos;if((!i||o)&&(i=o>=0?1:-1),!t.parent.inlineContent){let s=O.findFrom(t,i,!0)||O.findFrom(t,-i,!0);if(s)t=s.$head;else return O.near(t,i)}return e.parent.inlineContent||(o==0?e=t:(e=(O.findFrom(e,-i,!0)||O.findFrom(e,i,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new N(e,t)}}O.jsonID("text",N);class pi{constructor(e,t){this.anchor=e,this.head=t}map(e){return new pi(e.map(this.anchor),e.map(this.head))}resolve(e){return N.between(e.resolve(this.anchor),e.resolve(this.head))}}class E extends O{constructor(e){let t=e.nodeAfter,i=e.node(0).resolve(e.pos+t.nodeSize);super(e,i),this.node=t}map(e,t){let{deleted:i,pos:o}=t.mapResult(this.anchor),s=e.resolve(o);return i?O.near(s):new E(s)}content(){return new C(w.from(this.node),0,0)}eq(e){return e instanceof E&&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 E(e.resolve(t.anchor))}static create(e,t){return new E(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}E.prototype.visible=!1;O.jsonID("node",E);class Ro{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:i}=e.mapResult(this.anchor);return t?new pi(i,i):new Ro(i)}resolve(e){let t=e.resolve(this.anchor),i=t.nodeAfter;return i&&E.isSelectable(i)?new E(t):O.near(t)}}class ce extends O{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=C.empty){if(t==C.empty){e.delete(0,e.doc.content.size);let i=O.atStart(e.doc);i.eq(e.selection)||e.setSelection(i)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ce(e)}map(e){return new ce(e)}eq(e){return e instanceof ce}getBookmark(){return Wh}}O.jsonID("all",ce);const Wh={map(){return this},resolve(n){return new ce(n)}};function At(n,e,t,i,o,s=!1){if(e.inlineContent)return N.create(n,t);for(let r=i-(o>0?0:1);o>0?r<e.childCount:r>=0;r+=o){let l=e.child(r);if(l.isAtom){if(!s&&E.isSelectable(l))return E.create(n,t-(o<0?l.nodeSize:0))}else{let a=At(n,l,t+o,o<0?l.childCount:0,o,s);if(a)return a}t+=l.nodeSize*o}return null}function Ls(n,e,t){let i=n.steps.length-1;if(i<e)return;let o=n.steps[i];if(!(o instanceof U||o instanceof j))return;let s=n.mapping.maps[i],r;s.forEach((l,a,c,d)=>{r==null&&(r=d)}),n.setSelection(O.near(n.doc.resolve(r),t))}const zs=1,Pn=2,Bs=4;class _h extends _l{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|zs)&~Pn,this.storedMarks=null,this}get selectionSet(){return(this.updated&zs)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Pn,this}ensureMarks(e){return I.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&Pn)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Pn,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let i=this.selection;return t&&(e=e.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||I.none))),i.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,i){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(i==null&&(i=t),i=i??t,!e)return this.deleteRange(t,i);let s=this.storedMarks;if(!s){let r=this.doc.resolve(t);s=i==t?r.marks():r.marksAcross(this.doc.resolve(i))}return this.replaceRangeWith(t,i,o.text(e,s)),this.selection.empty||this.setSelection(O.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|=Bs,this}get scrolledIntoView(){return(this.updated&Bs)>0}}function Hs(n,e){return!e||!n?n:n.bind(e)}class en{constructor(e,t,i){this.name=e,this.init=Hs(t.init,i),this.apply=Hs(t.apply,i)}}const Kh=[new en("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new en("selection",{init(n,e){return n.selection||O.atStart(e.doc)},apply(n){return n.selection}}),new en("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,i){return i.selection.$cursor?n.storedMarks:null}}),new en("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Pi{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Kh.slice(),t&&t.forEach(i=>{if(this.pluginsByKey[i.key])throw new RangeError("Adding different instances of a keyed plugin ("+i.key+")");this.plugins.push(i),this.pluginsByKey[i.key]=i,i.spec.state&&this.fields.push(new en(i.key,i.spec.state,i))})}}class Nt{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 i=0;i<this.config.plugins.length;i++)if(i!=t){let o=this.config.plugins[i];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],i=this.applyInner(e),o=null;for(;;){let s=!1;for(let r=0;r<this.config.plugins.length;r++){let l=this.config.plugins[r];if(l.spec.appendTransaction){let a=o?o[r].n:0,c=o?o[r].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,i);if(d&&i.filterTransaction(d,r)){if(d.setMeta("appendedTransaction",e),!o){o=[];for(let h=0;h<this.config.plugins.length;h++)o.push(h<r?{state:i,n:t.length}:{state:this,n:0})}t.push(d),i=i.applyInner(d),s=!0}o&&(o[r]={state:i,n:t.length})}}if(!s)return{state:i,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Nt(this.config),i=this.config.fields;for(let o=0;o<i.length;o++){let s=i[o];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new _h(this)}static create(e){let t=new Pi(e.doc?e.doc.type.schema:e.schema,e.plugins),i=new Nt(t);for(let o=0;o<t.fields.length;o++)i[t.fields[o].name]=t.fields[o].init(e,i);return i}reconfigure(e){let t=new Pi(this.schema,e.plugins),i=t.fields,o=new Nt(t);for(let s=0;s<i.length;s++){let r=i[s].name;o[r]=this.hasOwnProperty(r)?this[r]:i[s].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(i=>i.toJSON())),e&&typeof e=="object")for(let i in e){if(i=="doc"||i=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[i],s=o.spec.state;s&&s.toJSON&&(t[i]=s.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,i){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Pi(e.schema,e.plugins),s=new Nt(o);return o.fields.forEach(r=>{if(r.name=="doc")s.doc=ht.fromJSON(e.schema,t.doc);else if(r.name=="selection")s.selection=O.fromJSON(s.doc,t.selection);else if(r.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(i)for(let l in i){let a=i[l],c=a.spec.state;if(a.key==r.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[r.name]=c.fromJSON.call(a,e,t[l],s);return}}s[r.name]=r.init(e,s)}}),s}}function ql(n,e,t){for(let i in n){let o=n[i];o instanceof Function?o=o.bind(e):i=="handleDOMEvents"&&(o=ql(o,e,{})),t[i]=o}return t}class gn{constructor(e){this.spec=e,this.props={},e.props&&ql(e.props,this,this.props),this.key=e.key?e.key.key:jl("plugin")}getState(e){return e[this.key]}}const Ri=Object.create(null);function jl(n){return n in Ri?n+"$"+ ++Ri[n]:(Ri[n]=0,n+"$")}class yn{constructor(e="key"){this.key=jl(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Jl=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function qh(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const jh=(n,e,t)=>{let i=qh(n,t);if(!i)return!1;let o=Gl(i);if(!o){let r=i.blockRange(),l=r&&ui(r);return l==null?!1:(e&&e(n.tr.lift(r,l).scrollIntoView()),!0)}let s=o.nodeBefore;if(ea(n,o,e,-1))return!0;if(i.parent.content.size==0&&(Wt(s,"end")||E.isSelectable(s)))for(let r=i.depth;;r--){let l=Po(n.doc,i.before(r),i.after(r),C.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Wt(s,"end")?O.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):E.create(a.doc,o.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(r==1||i.node(r-1).childCount>1)break}return s.isAtom&&o.depth==i.depth-1?(e&&e(n.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0):!1};function Wt(n,e,t=!1){for(let i=n;i;i=e=="start"?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(t&&i.childCount!=1)return!1}return!1}const Jh=(n,e,t)=>{let{$head:i,empty:o}=n.selection,s=i;if(!o)return!1;if(i.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):i.parentOffset>0)return!1;s=Gl(i)}let r=s&&s.nodeBefore;return!r||!E.isSelectable(r)?!1:(e&&e(n.tr.setSelection(E.create(n.doc,s.pos-r.nodeSize)).scrollIntoView()),!0)};function Gl(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 Gh(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Uh=(n,e,t)=>{let i=Gh(n,t);if(!i)return!1;let o=Ul(i);if(!o)return!1;let s=o.nodeAfter;if(ea(n,o,e,1))return!0;if(i.parent.content.size==0&&(Wt(s,"start")||E.isSelectable(s))){let r=Po(n.doc,i.before(),i.after(),C.empty);if(r&&r.slice.size<r.to-r.from){if(e){let l=n.tr.step(r);l.setSelection(Wt(s,"start")?O.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):E.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&o.depth==i.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+s.nodeSize).scrollIntoView()),!0):!1},Zh=(n,e,t)=>{let{$head:i,empty:o}=n.selection,s=i;if(!o)return!1;if(i.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):i.parentOffset<i.parent.content.size)return!1;s=Ul(i)}let r=s&&s.nodeAfter;return!r||!E.isSelectable(r)?!1:(e&&e(n.tr.setSelection(E.create(n.doc,s.pos)).scrollIntoView()),!0)};function Ul(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}const Yh=(n,e)=>{let{$head:t,$anchor:i}=n.selection;return!t.parent.type.spec.code||!t.sameParent(i)?!1:(e&&e(n.tr.insertText(`
125
+ `).scrollIntoView()),!0)};function Vo(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Zl=(n,e)=>{let{$head:t,$anchor:i}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(i))return!1;let o=t.node(-1),s=t.indexAfter(-1),r=Vo(o.contentMatchAt(s));if(!r||!o.canReplaceWith(s,s,r))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,r.createAndFill());a.setSelection(O.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Xh=(n,e)=>{let t=n.selection,{$from:i,$to:o}=t;if(t instanceof ce||i.parent.inlineContent||o.parent.inlineContent)return!1;let s=Vo(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let r=(!i.parentOffset&&o.index()<o.parent.childCount?i:o).pos,l=n.tr.insert(r,s.createAndFill());l.setSelection(N.create(l.doc,r+1)),e(l.scrollIntoView())}return!0},Yl=(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(Vt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let i=t.blockRange(),o=i&&ui(i);return o==null?!1:(e&&e(n.tr.lift(i,o).scrollIntoView()),!0)};function Xl(n){return(e,t)=>{let{$from:i,$to:o}=e.selection;if(e.selection instanceof E&&e.selection.node.isBlock)return!i.parentOffset||!Vt(e.doc,i.pos)?!1:(t&&t(e.tr.split(i.pos).scrollIntoView()),!0);if(!i.depth)return!1;let s=[],r,l,a=!1,c=!1;for(let f=i.depth;;f--)if(i.node(f).isBlock){a=i.end(f)==i.pos+(i.depth-f),c=i.start(f)==i.pos-(i.depth-f),l=Vo(i.node(f-1).contentMatchAt(i.indexAfter(f-1)));let m=n&&n(o.parent,a,i);s.unshift(m||(a&&l?{type:l}:null)),r=f;break}else{if(f==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof N||e.selection instanceof ce)&&d.deleteSelection();let h=d.mapping.map(i.pos),u=Vt(d.doc,h,s.length,s);if(u||(s[0]=l?{type:l}:null,u=Vt(d.doc,h,s.length,s)),d.split(h,s.length,s),!a&&c&&i.node(r).type!=l){let f=d.mapping.map(i.before(r)),p=d.doc.resolve(f);l&&i.node(r-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(i.before(r)),l)}return t&&t(d.scrollIntoView()),!0}}const Qh=Xl(),Ql=(n,e)=>(e&&e(n.tr.setSelection(new ce(n.doc))),!0);function eu(n,e,t){let i=e.nodeBefore,o=e.nodeAfter,s=e.index();return!i||!o||!i.type.compatibleContent(o.type)?!1:!i.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(o.isTextblock||fi(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function ea(n,e,t,i){let o=e.nodeBefore,s=e.nodeAfter,r,l,a=o.type.spec.isolating||s.type.spec.isolating;if(!a&&eu(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(r=(l=o.contentMatchAt(o.childCount)).findWrapping(s.type))&&l.matchType(r[0]||s.type).validEnd){if(t){let f=e.pos+s.nodeSize,p=w.empty;for(let b=r.length-1;b>=0;b--)p=w.from(r[b].create(null,p));p=w.from(o.copy(p));let m=n.tr.step(new j(e.pos-1,f,e.pos,f,new C(p,1,0),r.length,!0)),g=m.doc.resolve(f+2*r.length);g.nodeAfter&&g.nodeAfter.type==o.type&&fi(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=s.type.spec.isolating||i>0&&a?null:O.findFrom(e,1),h=d&&d.$from.blockRange(d.$to),u=h&&ui(h);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(h,u).scrollIntoView()),!0;if(c&&Wt(s,"start",!0)&&Wt(o,"end")){let f=o,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(t){let b=w.empty;for(let y=p.length-1;y>=0;y--)b=w.from(p[y].copy(b));let x=n.tr.step(new j(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new C(b,p.length,0),0,!0));t(x.scrollIntoView())}return!0}}return!1}function ta(n){return function(e,t){let i=e.selection,o=n<0?i.$from:i.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return o.node(s).isTextblock?(t&&t(e.tr.setSelection(N.create(e.doc,n<0?o.start(s):o.end(s)))),!0):!1}}const tu=ta(-1),nu=ta(1);function iu(n,e=null){return function(t,i){let o=!1;for(let s=0;s<t.selection.ranges.length&&!o;s++){let{$from:{pos:r},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(r,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),h=d.index();o=d.parent.canReplaceWith(h,h+1,n)}})}if(!o)return!1;if(i){let s=t.tr;for(let r=0;r<t.selection.ranges.length;r++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[r];s.setBlockType(l,a,n,e)}i(s.scrollIntoView())}return!0}}function ou(n,e,t,i){for(let o=0;o<e.length;o++){let{$from:s,$to:r}=e[o],l=s.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(s.pos,r.pos,(a,c)=>{if(l||!i)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function it(n,e=null,t){let i=t!==!1;return function(o,s){let{empty:r,$cursor:l,ranges:a}=o.selection;if(r&&!l||!ou(o.doc,a,n,i))return!1;if(s)if(l)n.isInSet(o.storedMarks||l.marks())?s(o.tr.removeStoredMark(n)):s(o.tr.addStoredMark(n.create(e)));else{let c,d=o.tr;c=!a.some(h=>o.doc.rangeHasMark(h.$from.pos,h.$to.pos,n));for(let h=0;h<a.length;h++){let{$from:u,$to:f}=a[h];if(!c)d.removeMark(u.pos,f.pos,n);else{let p=u.pos,m=f.pos,g=u.nodeAfter,b=f.nodeBefore,x=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,y=b&&b.isText?/\s*$/.exec(b.text)[0].length:0;p+x<m&&(p+=x,m-=y),d.addMark(p,m,n.create(e))}}s(d.scrollIntoView())}return!0}}function hn(...n){return function(e,t,i){for(let o=0;o<n.length;o++)if(n[o](e,t,i))return!0;return!1}}let Vi=hn(Jl,jh,Jh),Fs=hn(Jl,Uh,Zh);const Pe={Enter:hn(Yh,Xh,Yl,Qh),"Mod-Enter":Zl,Backspace:Vi,"Mod-Backspace":Vi,"Shift-Backspace":Vi,Delete:Fs,"Mod-Delete":Fs,"Mod-a":Ql},na={"Ctrl-h":Pe.Backspace,"Alt-Backspace":Pe["Mod-Backspace"],"Ctrl-d":Pe.Delete,"Ctrl-Alt-Backspace":Pe["Mod-Delete"],"Alt-Delete":Pe["Mod-Delete"],"Alt-d":Pe["Mod-Delete"],"Ctrl-a":tu,"Ctrl-e":nu};for(let n in Pe)na[n]=Pe[n];const su=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,ru=su?na:Pe;var ti=200,$=function(){};$.prototype.append=function(e){return e.length?(e=$.from(e),!this.length&&e||e.length<ti&&this.leafAppend(e)||this.length<ti&&e.leafPrepend(this)||this.appendInner(e)):this};$.prototype.prepend=function(e){return e.length?$.from(e).append(this):this};$.prototype.appendInner=function(e){return new lu(this,e)};$.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?$.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};$.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};$.prototype.forEach=function(e,t,i){t===void 0&&(t=0),i===void 0&&(i=this.length),t<=i?this.forEachInner(e,t,i,0):this.forEachInvertedInner(e,t,i,0)};$.prototype.map=function(e,t,i){t===void 0&&(t=0),i===void 0&&(i=this.length);var o=[];return this.forEach(function(s,r){return o.push(e(s,r))},t,i),o};$.from=function(e){return e instanceof $?e:e&&e.length?new ia(e):$.empty};var ia=function(n){function e(i){n.call(this),this.values=i}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,s){return o==0&&s==this.length?this:new e(this.values.slice(o,s))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,s,r,l){for(var a=s;a<r;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,r,l){for(var a=s-1;a>=r;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=ti)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=ti)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}($);$.empty=new ia([]);var lu=function(n){function e(t,i){n.call(this),this.left=t,this.right=i,this.length=t.length+i.length,this.depth=Math.max(t.depth,i.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(i){return i<this.left.length?this.left.get(i):this.right.get(i-this.left.length)},e.prototype.forEachInner=function(i,o,s,r){var l=this.left.length;if(o<l&&this.left.forEachInner(i,o,Math.min(s,l),r)===!1||s>l&&this.right.forEachInner(i,Math.max(o-l,0),Math.min(this.length,s)-l,r+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,r){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(i,o-l,Math.max(s,l)-l,r+l)===!1||s<l&&this.left.forEachInvertedInner(i,Math.min(o,l),s,r)===!1)return!1},e.prototype.sliceInner=function(i,o){if(i==0&&o==this.length)return this;var s=this.left.length;return o<=s?this.left.slice(i,o):i>=s?this.right.slice(i-s,o-s):this.left.slice(i,s).append(this.right.slice(0,o-s))},e.prototype.leafAppend=function(i){var o=this.right.leafAppend(i);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(i){var o=this.left.leafPrepend(i);if(o)return new e(o,this.right)},e.prototype.appendInner=function(i){return this.left.depth>=Math.max(this.right.depth,i.depth)+1?new e(this.left,new e(this.right,i)):new e(this,i)},e}($);const au=500;class ye{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let i=this.items.length;for(;;i--)if(this.items.get(i-1).selection){--i;break}let o,s;t&&(o=this.remapping(i,this.items.length),s=o.maps.length);let r=e.tr,l,a,c=[],d=[];return this.items.forEach((h,u)=>{if(!h.step){o||(o=this.remapping(i,u+1),s=o.maps.length),s--,d.push(h);return}if(o){d.push(new xe(h.map));let f=h.step.map(o.slice(s)),p;f&&r.maybeStep(f).doc&&(p=r.mapping.maps[r.mapping.maps.length-1],c.push(new xe(p,void 0,void 0,c.length+d.length))),s--,p&&o.appendMap(p,s)}else r.maybeStep(h.step);if(h.selection)return l=o?h.selection.map(o.slice(s)):h.selection,a=new ye(this.items.slice(0,i).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:r,selection:l}}addTransform(e,t,i,o){let s=[],r=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 h=e.steps[d].invert(e.docs[d]),u=new xe(e.mapping.maps[d],h,t),f;(f=a&&a.merge(u))&&(u=f,d?s.pop():l=l.slice(0,l.length-1)),s.push(u),t&&(r++,t=void 0),o||(a=u)}let c=r-i.depth;return c>du&&(l=cu(l,c),r-=c),new ye(l.append(s),r)}remapping(e,t){let i=new Rt;return this.items.forEach((o,s)=>{let r=o.mirrorOffset!=null&&s-o.mirrorOffset>=e?i.maps.length-o.mirrorOffset:void 0;i.appendMap(o.map,r)},e,t),i}addMaps(e){return this.eventCount==0?this:new ye(this.items.append(e.map(t=>new xe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let i=[],o=Math.max(0,this.items.length-t),s=e.mapping,r=e.steps.length,l=this.eventCount;this.items.forEach(u=>{u.selection&&l--},o);let a=t;this.items.forEach(u=>{let f=s.getMirror(--a);if(f==null)return;r=Math.min(r,f);let p=s.maps[f];if(u.step){let m=e.steps[f].invert(e.docs[f]),g=u.selection&&u.selection.map(s.slice(a+1,f));g&&l++,i.push(new xe(p,m,g))}else i.push(new xe(p))},o);let c=[];for(let u=t;u<r;u++)c.push(new xe(s.maps[u]));let d=this.items.slice(0,o).append(c).append(i),h=new ye(d,l);return h.emptyItemCount()>au&&(h=h.compress(this.items.length-i.length)),h}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),i=t.maps.length,o=[],s=0;return this.items.forEach((r,l)=>{if(l>=e)o.push(r),r.selection&&s++;else if(r.step){let a=r.step.map(t.slice(i)),c=a&&a.getMap();if(i--,c&&t.appendMap(c,i),a){let d=r.selection&&r.selection.map(t.slice(i));d&&s++;let h=new xe(c.invert(),a,d),u,f=o.length-1;(u=o.length&&o[f].merge(h))?o[f]=u:o.push(h)}}else r.map&&i--},this.items.length,0),new ye($.from(o.reverse()),s)}}ye.empty=new ye($.empty,0);function cu(n,e){let t;return n.forEach((i,o)=>{if(i.selection&&e--==0)return t=o,!1}),n.slice(t)}class xe{constructor(e,t,i,o){this.map=e,this.step=t,this.selection=i,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new xe(t.getMap().invert(),t,this.selection)}}}class He{constructor(e,t,i,o,s){this.done=e,this.undone=t,this.prevRanges=i,this.prevTime=o,this.prevComposition=s}}const du=20;function hu(n,e,t,i){let o=t.getMeta(ut),s;if(o)return o.historyState;t.getMeta(pu)&&(n=new He(n.done,n.undone,null,0,-1));let r=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(r&&r.getMeta(ut))return r.getMeta(ut).redo?new He(n.done.addTransform(t,void 0,i,Wn(e)),n.undone,$s(t.mapping.maps),n.prevTime,n.prevComposition):new He(n.done,n.undone.addTransform(t,void 0,i,Wn(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(r&&r.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!r&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-i.newGroupDelay||!uu(t,n.prevRanges)),c=r?Li(n.prevRanges,t.mapping):$s(t.mapping.maps);return new He(n.done.addTransform(t,a?e.selection.getBookmark():void 0,i,Wn(e)),ye.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new He(n.done.rebased(t,s),n.undone.rebased(t,s),Li(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new He(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Li(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function uu(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((i,o)=>{for(let s=0;s<e.length;s+=2)i<=e[s+1]&&o>=e[s]&&(t=!0)}),t}function $s(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((i,o,s,r)=>e.push(s,r));return e}function Li(n,e){if(!n)return null;let t=[];for(let i=0;i<n.length;i+=2){let o=e.map(n[i],1),s=e.map(n[i+1],-1);o<=s&&t.push(o,s)}return t}function fu(n,e,t){let i=Wn(e),o=ut.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,i);if(!s)return null;let r=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),o,i),a=new He(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(r).setMeta(ut,{redo:t,historyState:a})}let zi=!1,Ws=null;function Wn(n){let e=n.plugins;if(Ws!=e){zi=!1,Ws=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){zi=!0;break}}return zi}const ut=new yn("history"),pu=new yn("closeHistory");function mu(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new gn({key:ut,state:{init(){return new He(ye.empty,ye.empty,null,0,-1)},apply(e,t,i){return hu(t,i,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let i=t.inputType,o=i=="historyUndo"?sa:i=="historyRedo"?ro:null;return o?(t.preventDefault(),o(e.state,e.dispatch)):!1}}}})}function oa(n,e){return(t,i)=>{let o=ut.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(i){let s=fu(o,t,n);s&&i(e?s.scrollIntoView():s)}return!0}}const sa=oa(!1,!0),ro=oa(!0,!0);var Ze={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:"'"},ni={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},gu=typeof navigator<"u"&&/Mac/.test(navigator.platform),yu=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var K=0;K<10;K++)Ze[48+K]=Ze[96+K]=String(K);for(var K=1;K<=24;K++)Ze[K+111]="F"+K;for(var K=65;K<=90;K++)Ze[K]=String.fromCharCode(K+32),ni[K]=String.fromCharCode(K);for(var Bi in Ze)ni.hasOwnProperty(Bi)||(ni[Bi]=Ze[Bi]);function bu(n){var e=gu&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||yu&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?ni:Ze)[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}const wu=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function vu(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let i,o,s,r;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))r=!0;else if(/^a(lt)?$/i.test(a))i=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))wu?r=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return i&&(t="Alt-"+t),o&&(t="Ctrl-"+t),r&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Su(n){let e=Object.create(null);for(let t in n)e[vu(t)]=n[t];return e}function Hi(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 Fi(n){return new gn({props:{handleKeyDown:ra(n)}})}function ra(n){let e=Su(n);return function(t,i){let o=bu(i),s,r=e[Hi(o,i)];if(r&&r(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(i.shiftKey){let l=e[Hi(o,i,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((i.shiftKey||i.altKey||i.metaKey||o.charCodeAt(0)>127)&&(s=Ze[i.keyCode])&&s!=o){let l=e[Hi(s,i)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function _s(n,e=null){return function(t,i){let{$from:o,$to:s}=t.selection,r=o.blockRange(s),l=!1,a=r;if(!r)return!1;if(r.depth>=2&&o.node(r.depth-1).type.compatibleContent(n)&&r.startIndex==0){if(o.index(r.depth-1)==0)return!1;let d=t.doc.resolve(r.start-2);a=new Yn(d,d,r.depth),r.endIndex<r.parent.childCount&&(r=new Yn(o,t.doc.resolve(s.end(r.depth)),r.depth)),l=!0}let c=Ll(a,n,e,r);return c?(i&&i(xu(t.tr,r,c,l,n).scrollIntoView()),!0):!1}}function xu(n,e,t,i,o){let s=w.empty;for(let d=t.length-1;d>=0;d--)s=w.from(t[d].type.create(t[d].attrs,s));n.step(new j(e.start-(i?2:0),e.end,e.start,e.end,new C(s,0,0),t.length,!0));let r=0;for(let d=0;d<t.length;d++)t[d].type==o&&(r=d+1);let l=t.length-r,a=e.start+t.length-(i?2:0),c=e.parent;for(let d=e.startIndex,h=e.endIndex,u=!0;d<h;d++,u=!1)!u&&Vt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function Cu(n,e){return function(t,i){let{$from:o,$to:s,node:r}=t.selection;if(r&&r.isBlock||o.depth<2||!o.sameParent(s))return!1;let l=o.node(-1);if(l.type!=n)return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||o.node(-3).type!=n||o.index(-2)!=o.node(-2).childCount-1)return!1;if(i){let h=w.empty,u=o.index(-1)?1:o.index(-2)?2:3;for(let b=o.depth-u;b>=o.depth-3;b--)h=w.from(o.node(b).copy(h));let f=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;h=h.append(w.from(n.createAndFill()));let p=o.before(o.depth-(u-1)),m=t.tr.replace(p,o.after(-f),new C(h,4-u,0)),g=-1;m.doc.nodesBetween(p,m.doc.content.size,(b,x)=>{if(g>-1)return!1;b.isTextblock&&b.content.size==0&&(g=x+1)}),g>-1&&m.setSelection(O.near(m.doc.resolve(g))),i(m.scrollIntoView())}return!0}let a=s.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,s.pos),d=a?[null,{type:a}]:void 0;return Vt(c.doc,o.pos,2,d)?(i&&i(c.split(o.pos,2,d).scrollIntoView()),!0):!1}}function lo(n){return function(e,t){let{$from:i,$to:o}=e.selection,s=i.blockRange(o,r=>r.childCount>0&&r.firstChild.type==n);return s?t?i.node(s.depth-1).type==n?ku(e,t,n,s):Tu(e,t,s):!0:!1}}function ku(n,e,t,i){let o=n.tr,s=i.end,r=i.$to.end(i.depth);s<r&&(o.step(new j(s-1,r,s,r,new C(w.from(t.create(null,i.parent.copy())),1,0),1,!0)),i=new Yn(o.doc.resolve(i.$from.pos),o.doc.resolve(r),i.depth));const l=ui(i);if(l==null)return!1;o.lift(i,l);let a=o.mapping.map(s,-1)-1;return fi(o.doc,a)&&o.join(a),e(o.scrollIntoView()),!0}function Tu(n,e,t){let i=n.tr,o=t.parent;for(let f=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)f-=o.child(p).nodeSize,i.delete(f-1,f+1);let s=i.doc.resolve(t.start),r=s.nodeAfter;if(i.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=s.node(-1),d=s.index(-1);if(!c.canReplace(d+(l?0:1),d+1,r.content.append(a?w.empty:w.from(o))))return!1;let h=s.pos,u=h+r.nodeSize;return i.step(new j(h-(l?1:0),u+(a?1:0),h+1,u-1,new C((l?w.empty:w.from(o.copy(w.empty))).append(a?w.empty:w.from(o.copy(w.empty))),l?0:1,a?0:1),l?0:1)),e(i.scrollIntoView()),!0}function Mu(n){return function(e,t){let{$from:i,$to:o}=e.selection,s=i.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let r=s.startIndex;if(r==0)return!1;let l=s.parent,a=l.child(r-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=w.from(c?n.create():null),h=new C(w.from(n.create(null,w.from(l.type.create(null,d)))),c?3:1,0),u=s.start,f=s.end;t(e.tr.step(new j(u-(c?3:1),f,u,f,h,1,!0)).scrollIntoView())}return!0}}const q=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},un=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let ao=null;const Ie=function(n,e,t){let i=ao||(ao=document.createRange());return i.setEnd(n,t??n.nodeValue.length),i.setStart(n,e||0),i},Au=function(){ao=null},yt=function(n,e,t,i){return t&&(Ks(n,e,t,i,-1)||Ks(n,e,t,i,1))},Eu=/^(img|br|input|textarea|hr)$/i;function Ks(n,e,t,i,o){for(;;){if(n==t&&e==i)return!0;if(e==(o<0?0:fe(n))){let s=n.parentNode;if(!s||s.nodeType!=1||bn(n)||Eu.test(n.nodeName)||n.contentEditable=="false")return!1;e=q(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?fe(n):0}else return!1}}function fe(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Ou(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=fe(n)}else if(n.parentNode&&!bn(n))e=q(n),n=n.parentNode;else return null}}function Nu(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!bn(n))e=q(n)+1,n=n.parentNode;else return null}}function Du(n,e,t){for(let i=e==0,o=e==fe(n);i||o;){if(n==t)return!0;let s=q(n);if(n=n.parentNode,!n)return!1;i=i&&s==0,o=o&&s==fe(n)}}function bn(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)}const mi=function(n){return n.focusNode&&yt(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 Iu(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Pu(n,e,t){if(n.caretPositionFromPoint)try{let i=n.caretPositionFromPoint(e,t);if(i)return{node:i.offsetNode,offset:Math.min(fe(i.offsetNode),i.offset)}}catch{}if(n.caretRangeFromPoint){let i=n.caretRangeFromPoint(e,t);if(i)return{node:i.startContainer,offset:Math.min(fe(i.startContainer),i.startOffset)}}}const Te=typeof navigator<"u"?navigator:null,qs=typeof document<"u"?document:null,Ye=Te&&Te.userAgent||"",co=/Edge\/(\d+)/.exec(Ye),la=/MSIE \d/.exec(Ye),ho=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ye),se=!!(la||ho||co),Je=la?document.documentMode:ho?+ho[1]:co?+co[1]:0,we=!se&&/gecko\/(\d+)/i.test(Ye);we&&+(/Firefox\/(\d+)/.exec(Ye)||[0,0])[1];const uo=!se&&/Chrome\/(\d+)/.exec(Ye),Y=!!uo,aa=uo?+uo[1]:0,te=!se&&!!Te&&/Apple Computer/.test(Te.vendor),_t=te&&(/Mobile\/\w+/.test(Ye)||!!Te&&Te.maxTouchPoints>2),ue=_t||(Te?/Mac/.test(Te.platform):!1),Ru=Te?/Win/.test(Te.platform):!1,ge=/Android \d/.test(Ye),wn=!!qs&&"webkitFontSmoothing"in qs.documentElement.style,Vu=wn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Lu(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 Ee(n,e){return typeof n=="number"?n:n[e]}function zu(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,i=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*i}}function js(n,e,t){let i=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let r=t||n.dom;r;r=un(r)){if(r.nodeType!=1)continue;let l=r,a=l==s.body,c=a?Lu(s):zu(l),d=0,h=0;if(e.top<c.top+Ee(i,"top")?h=-(c.top-e.top+Ee(o,"top")):e.bottom>c.bottom-Ee(i,"bottom")&&(h=e.bottom-e.top>c.bottom-c.top?e.top+Ee(o,"top")-c.top:e.bottom-c.bottom+Ee(o,"bottom")),e.left<c.left+Ee(i,"left")?d=-(c.left-e.left+Ee(o,"left")):e.right>c.right-Ee(i,"right")&&(d=e.right-c.right+Ee(o,"right")),d||h)if(a)s.defaultView.scrollBy(d,h);else{let u=l.scrollLeft,f=l.scrollTop;h&&(l.scrollTop+=h),d&&(l.scrollLeft+=d);let p=l.scrollLeft-u,m=l.scrollTop-f;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(r).position))break}}function Bu(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),i,o;for(let s=(e.left+e.right)/2,r=t+1;r<Math.min(innerHeight,e.bottom);r+=5){let l=n.root.elementFromPoint(s,r);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){i=l,o=a.top;break}}return{refDOM:i,refTop:o,stack:ca(n.dom)}}function ca(n){let e=[],t=n.ownerDocument;for(let i=n;i&&(e.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),n!=t);i=un(i));return e}function Hu({refDOM:n,refTop:e,stack:t}){let i=n?n.getBoundingClientRect().top:0;da(t,i==0?0:i-e)}function da(n,e){for(let t=0;t<n.length;t++){let{dom:i,top:o,left:s}=n[t];i.scrollTop!=o+e&&(i.scrollTop=o+e),i.scrollLeft!=s&&(i.scrollLeft=s)}}let kt=null;function Fu(n){if(n.setActive)return n.setActive();if(kt)return n.focus(kt);let e=ca(n);n.focus(kt==null?{get preventScroll(){return kt={preventScroll:!0},!0}}:void 0),kt||(kt=!1,da(e,0))}function ha(n,e){let t,i=2e8,o,s=0,r=e.top,l=e.top,a,c;for(let d=n.firstChild,h=0;d;d=d.nextSibling,h++){let u;if(d.nodeType==1)u=d.getClientRects();else if(d.nodeType==3)u=Ie(d).getClientRects();else continue;for(let f=0;f<u.length;f++){let p=u[f];if(p.top<=r&&p.bottom>=l){r=Math.max(p.bottom,r),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<i){t=d,i=m,o=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&m&&(s=h+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=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)&&(s=h+1)}}return!t&&a&&(t=a,o=c,i=0),t&&t.nodeType==3?$u(t,o):!t||i&&t.nodeType==1?{node:n,offset:s}:ha(t,o)}function $u(n,e){let t=n.nodeValue.length,i=document.createRange();for(let o=0;o<t;o++){i.setEnd(n,o+1),i.setStart(n,o);let s=Be(i,1);if(s.top!=s.bottom&&Lo(e,s))return{node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function Lo(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Wu(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function _u(n,e,t){let{node:i,offset:o}=ha(e,t),s=-1;if(i.nodeType==1&&!i.firstChild){let r=i.getBoundingClientRect();s=r.left!=r.right&&t.left>(r.left+r.right)/2?1:-1}return n.docView.posFromDOM(i,o,s)}function Ku(n,e,t,i){let o=-1;for(let s=e,r=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!r&&a.left>i.left||a.top>i.top?o=l.posBefore:(!r&&a.right<i.left||a.bottom<i.top)&&(o=l.posAfter),r=!0),!l.contentDOM&&o<0&&!l.node.isText)return(l.node.isBlock?i.top<(a.top+a.bottom)/2:i.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}s=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function ua(n,e,t){let i=n.childNodes.length;if(i&&t.top<t.bottom)for(let o=Math.max(0,Math.min(i-1,Math.floor(i*(e.top-t.top)/(t.bottom-t.top))-2)),s=o;;){let r=n.childNodes[s];if(r.nodeType==1){let l=r.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Lo(e,c))return ua(r,e,c)}}if((s=(s+1)%i)==o)break}return n}function qu(n,e){let t=n.dom.ownerDocument,i,o=0,s=Pu(t,e.left,e.top);s&&({node:i,offset:o}=s);let r=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!r||!n.dom.contains(r.nodeType!=1?r.parentNode:r)){let c=n.dom.getBoundingClientRect();if(!Lo(e,c)||(r=ua(n.dom,e,c),!r))return null}if(te)for(let c=r;i&&c;c=un(c))c.draggable&&(i=void 0);if(r=Wu(r,e),i){if(we&&i.nodeType==1&&(o=Math.min(o,i.childNodes.length),o<i.childNodes.length)){let d=i.childNodes[o],h;d.nodeName=="IMG"&&(h=d.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&o++}let c;wn&&o&&i.nodeType==1&&(c=i.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,i==n.dom&&o==i.childNodes.length-1&&i.lastChild.nodeType==1&&e.top>i.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||i.nodeType!=1||i.childNodes[o-1].nodeName!="BR")&&(l=Ku(n,i,o,e))}l==null&&(l=_u(n,r,e));let a=n.docView.nearestDesc(r,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Js(n){return n.top<n.bottom||n.left<n.right}function Be(n,e){let t=n.getClientRects();if(t.length){let i=t[e<0?0:t.length-1];if(Js(i))return i}return Array.prototype.find.call(t,Js)||n.getBoundingClientRect()}const ju=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function fa(n,e,t){let{node:i,offset:o,atom:s}=n.docView.domFromPos(e,t<0?-1:1),r=wn||we;if(i.nodeType==3)if(r&&(ju.test(i.nodeValue)||(t<0?!o:o==i.nodeValue.length))){let a=Be(Ie(i,o,o),t);if(we&&o&&/\s/.test(i.nodeValue[o-1])&&o<i.nodeValue.length){let c=Be(Ie(i,o-1,o-1),-1);if(c.top==a.top){let d=Be(Ie(i,o,o+1),-1);if(d.top!=a.top)return Gt(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==i.nodeValue.length?(a--,d=1):t<0?a--:c++,Gt(Be(Ie(i,a,c),d),d<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&o&&(t<0||o==fe(i))){let a=i.childNodes[o-1];if(a.nodeType==1)return $i(a.getBoundingClientRect(),!1)}if(s==null&&o<fe(i)){let a=i.childNodes[o];if(a.nodeType==1)return $i(a.getBoundingClientRect(),!0)}return $i(i.getBoundingClientRect(),t>=0)}if(s==null&&o&&(t<0||o==fe(i))){let a=i.childNodes[o-1],c=a.nodeType==3?Ie(a,fe(a)-(r?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Gt(Be(c,1),!1)}if(s==null&&o<fe(i)){let a=i.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ie(a,0,r?0:1):a.nodeType==1?a:null:null;if(c)return Gt(Be(c,-1),!0)}return Gt(Be(i.nodeType==3?Ie(i):i,-t),t>=0)}function Gt(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 $i(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 pa(n,e,t){let i=n.state,o=n.root.activeElement;i!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{i!=e&&n.updateState(i),o!=n.dom&&o&&o.focus()}}function Ju(n,e,t){let i=e.selection,o=t=="up"?i.$from:i.$to;return pa(n,e,()=>{let{node:s}=n.docView.domFromPos(o.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 r=fa(n,o.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ie(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"?r.top-d.top>(d.bottom-r.top)*2:d.bottom-r.bottom>(r.bottom-d.top)*2))return!1}}return!0})}const Gu=/[\u0590-\u08ac]/;function Uu(n,e,t){let{$head:i}=e.selection;if(!i.parent.isTextblock)return!1;let o=i.parentOffset,s=!o,r=o==i.parent.content.size,l=n.domSelection();return l?!Gu.test(i.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:r:pa(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:h}=n.domSelectionRange(),u=l.caretBidiLevel;l.modify("move",t,"character");let f=i.depth?n.docView.domAfterPos(i.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(d,h),a&&(a!=d||c!=h)&&l.extend&&l.extend(a,c)}catch{}return u!=null&&(l.caretBidiLevel=u),g}):i.pos==i.start()||i.pos==i.end()}let Gs=null,Us=null,Zs=!1;function Zu(n,e,t){return Gs==e&&Us==t?Zs:(Gs=e,Us=t,Zs=t=="up"||t=="down"?Ju(n,e,t):Uu(n,e,t))}const pe=0,Ys=1,rt=2,Me=3;class vn{constructor(e,t,i,o){this.parent=e,this.children=t,this.dom=i,this.contentDOM=o,this.dirty=pe,i.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,i){return!1}matchesHack(e){return!1}parseRule(){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,i=this.posAtStart;;t++){let o=this.children[t];if(o==e)return i;i+=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,i){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(i<0){let s,r;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((r=s.pmViewDesc)&&r.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(r)+r.size:this.posAtStart}else{let s,r;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((r=s.pmViewDesc)&&r.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(r):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>q(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??i>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let i=!0,o=e;o;o=o.parentNode){let s=this.getDesc(o),r;if(s&&(!t||s.node))if(i&&(r=s.nodeDOM)&&!(r.nodeType==1?r.contains(e.nodeType==1?e:e.parentNode):r==e))i=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let i=t;i;i=i.parent)if(i==this)return t}posFromDOM(e,t,i){for(let o=e;o;o=o.parentNode){let s=this.getDesc(o);if(s)return s.localPosFromDOM(e,t,i)}return-1}descAt(e){for(let t=0,i=0;t<this.children.length;t++){let o=this.children[t],s=i+o.size;if(i==e&&s!=i){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<s)return o.descAt(e-i-o.border);i=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let i=0,o=0;for(let s=0;i<this.children.length;i++){let r=this.children[i],l=s+r.size;if(l>e||r instanceof ga){o=e-s;break}s=l}if(o)return this.children[i].domFromPos(o-this.children[i].border,t);for(let s;i&&!(s=this.children[i-1]).size&&s instanceof ma&&s.side>=0;i--);if(t<=0){let s,r=!0;for(;s=i?this.children[i-1]:null,!(!s||s.dom.parentNode==this.contentDOM);i--,r=!1);return s&&t&&r&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?q(s.dom)+1:0}}else{let s,r=!0;for(;s=i<this.children.length?this.children[i]:null,!(!s||s.dom.parentNode==this.contentDOM);i++,r=!1);return s&&r&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?q(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,i=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let r=i,l=0;;l++){let a=this.children[l],c=r+a.size;if(o==-1&&e<=c){let d=r+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=r;for(let h=l;h>0;h--){let u=this.children[h-1];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(1)){o=q(u.dom)+1;break}e-=u.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 h=this.children[d];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){s=q(h.dom);break}t+=h.size}s==-1&&(s=this.contentDOM.childNodes.length);break}r=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,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:i}=this.domFromPos(e,0);if(t.nodeType!=1||i==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[i]}setSelection(e,t,i,o=!1){let s=Math.min(e,t),r=Math.max(e,t);for(let f=0,p=0;f<this.children.length;f++){let m=this.children[f],g=p+m.size;if(s>p&&r<g)return m.setSelection(e-p-m.border,t-p-m.border,i,o);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=i.root.getSelection(),d=i.domSelectionRange(),h=!1;if((we||te)&&e==t){let{node:f,offset:p}=l;if(f.nodeType==3){if(h=!!(p&&f.nodeValue[p-1]==`
126
+ `),h&&p==f.nodeValue.length)for(let m=f,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:q(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=f.childNodes[p-1];h=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(we&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let f=d.focusNode.childNodes[d.focusOffset];f&&f.contentEditable=="false"&&(o=!0)}if(!(o||h&&te)&&yt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&yt(a.node,a.offset,d.focusNode,d.focusOffset))return;let u=!1;if((c.extend||e==t)&&!h){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),u=!0}catch{}}if(!u){if(e>t){let p=l;l=a,a=p}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let i=0,o=0;o<this.children.length;o++){let s=this.children[o],r=i+s.size;if(i==r?e<=r&&t>=i:e<r&&t>i){let l=i+s.border,a=r-s.border;if(e>=l&&t<=a){this.dirty=e==i||t==r?rt:Ys,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Me:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?rt:Me}i=r}this.dirty=rt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let i=e==1?rt:Ys;t.dirty<i&&(t.dirty=i)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class ma extends vn{constructor(e,t,i,o){let s,r=t.type.toDOM;if(typeof r=="function"&&(r=r(i,()=>{if(!s)return o;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(r.nodeType!=1){let l=document.createElement("span");l.appendChild(r),r=l}r.contentEditable="false",r.classList.add("ProseMirror-widget")}super(e,[],r,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==pe&&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 side(){return this.widget.type.side}}class Yu extends vn{constructor(e,t,i,o){super(e,[],t,null),this.textDOM=i,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}}class bt extends vn{constructor(e,t,i,o,s){super(e,[],i,o),this.mark=t,this.spec=s}static create(e,t,i,o){let s=o.nodeViews[t.type.name],r=s&&s(t,o,i);return(!r||!r.dom)&&(r=wt.renderSpec(document,t.type.spec.toDOM(t,i),null,t.attrs)),new bt(e,t,r.dom,r.contentDOM||r.dom,r)}parseRule(){return this.dirty&Me||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Me&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=pe){let i=this.parent;for(;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=pe}}slice(e,t,i){let o=bt.create(this.parent,this.mark,!0,i),s=this.children,r=this.size;t<r&&(s=po(s,t,r,i)),e>0&&(s=po(s,0,e,i));for(let l=0;l<s.length;l++)s[l].parent=o;return o.children=s,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Ge extends vn{constructor(e,t,i,o,s,r,l,a,c){super(e,[],s,r),this.node=t,this.outerDeco=i,this.innerDeco=o,this.nodeDOM=l}static create(e,t,i,o,s,r){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return r;if(a.parent)return a.parent.posBeforeChild(a)},i,o),d=c&&c.dom,h=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:h}=wt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!h&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let u=d;return d=wa(d,i,t),c?a=new Xu(e,t,i,o,d,h||null,u,c,s,r+1):t.isText?new gi(e,t,i,o,d,u,s):new Ge(e,t,i,o,d,h||null,u,s,r+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let i=this.children[t];if(this.dom.contains(i.dom.parentNode)){e.contentElement=i.dom.parentNode;break}}e.contentElement||(e.getContent=()=>w.empty)}return e}matchesNode(e,t,i){return this.dirty==pe&&e.eq(this.node)&&ii(t,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let i=this.node.inlineContent,o=t,s=e.composing?this.localCompositionInfo(e,t):null,r=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new ef(this,r&&r.node,e);of(this.node,this.innerDeco,(c,d,h)=>{c.spec.marks?a.syncToMarks(c.spec.marks,i,e):c.type.side>=0&&!h&&a.syncToMarks(d==this.node.childCount?I.none:this.node.child(d).marks,i,e),a.placeWidget(c,e,o)},(c,d,h,u)=>{a.syncToMarks(c.marks,i,e);let f;a.findNodeMatch(c,d,h,u)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(f=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,d,h,f,e)||a.updateNextNode(c,d,h,e,u,o)||a.addNode(c,d,h,e,o),o+=c.nodeSize}),a.syncToMarks([],i,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==rt)&&(r&&this.protectLocalComposition(e,r),ya(this.contentDOM,this.children,e),_t&&sf(this.dom))}localCompositionInfo(e,t){let{from:i,to:o}=e.state.selection;if(!(e.state.selection instanceof N)||i<t||o>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 r=s.nodeValue,l=rf(this.node.content,r,i-t,o-t);return l<0?null:{node:s,pos:l,text:r}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:i,text:o}){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 r=new Yu(this,s,t,o);e.input.compositionNodes.push(r),this.children=po(this.children,i,i+o.length,e,r)}update(e,t,i,o){return this.dirty==Me||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,i,o),!0)}updateInner(e,t,i,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=i,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=pe}updateOuterDeco(e){if(ii(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,i=this.dom;this.dom=ba(this.dom,this.nodeDOM,fo(this.outerDeco,this.node,t),fo(e,this.node,t)),this.dom!=i&&(i.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Xs(n,e,t,i,o){wa(i,e,n);let s=new Ge(void 0,n,e,t,i,i,i,o,0);return s.contentDOM&&s.updateChildren(o,0),s}class gi extends Ge{constructor(e,t,i,o,s,r,l){super(e,t,i,o,s,null,r,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,i,o){return this.dirty==Me||this.dirty!=pe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=pe||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=pe,!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,i){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,i)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,i){let o=this.node.cut(e,t),s=document.createTextNode(o.text);return new gi(this.parent,o,this.outerDeco,this.innerDeco,s,s,i)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Me)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ga extends vn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==pe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Xu extends Ge{constructor(e,t,i,o,s,r,l,a,c,d){super(e,t,i,o,s,r,l,c,d),this.spec=a}update(e,t,i,o){if(this.dirty==Me)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,i);return s&&this.updateInner(e,t,i,o),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,i,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,i,o){this.spec.setSelection?this.spec.setSelection(e,t,i.root):super.setSelection(e,t,i,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 ya(n,e,t){let i=n.firstChild,o=!1;for(let s=0;s<e.length;s++){let r=e[s],l=r.dom;if(l.parentNode==n){for(;l!=i;)i=Qs(i),o=!0;i=i.nextSibling}else o=!0,n.insertBefore(l,i);if(r instanceof bt){let a=i?i.previousSibling:n.lastChild;ya(r.contentDOM,r.children,t),i=a?a.nextSibling:n.firstChild}}for(;i;)i=Qs(i),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const sn=function(n){n&&(this.nodeName=n)};sn.prototype=Object.create(null);const lt=[new sn];function fo(n,e,t){if(n.length==0)return lt;let i=t?lt[0]:new sn,o=[i];for(let s=0;s<n.length;s++){let r=n[s].type.attrs;if(r){r.nodeName&&o.push(i=new sn(r.nodeName));for(let l in r){let a=r[l];a!=null&&(t&&o.length==1&&o.push(i=new sn(e.isInline?"span":"div")),l=="class"?i.class=(i.class?i.class+" ":"")+a:l=="style"?i.style=(i.style?i.style+";":"")+a:l!="nodeName"&&(i[l]=a))}}}return o}function ba(n,e,t,i){if(t==lt&&i==lt)return e;let o=e;for(let s=0;s<i.length;s++){let r=i[s],l=t[s];if(s){let a;l&&l.nodeName==r.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==r.nodeName||(a=document.createElement(r.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=lt[0]),o=a}Qu(o,l||lt[0],r)}return o}function Qu(n,e,t){for(let i in e)i!="class"&&i!="style"&&i!="nodeName"&&!(i in t)&&n.removeAttribute(i);for(let i in t)i!="class"&&i!="style"&&i!="nodeName"&&t[i]!=e[i]&&n.setAttribute(i,t[i]);if(e.class!=t.class){let i=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<i.length;s++)o.indexOf(i[s])==-1&&n.classList.remove(i[s]);for(let s=0;s<o.length;s++)i.indexOf(o[s])==-1&&n.classList.add(o[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=i.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function wa(n,e,t){return ba(n,n,lt,fo(e,t,n.nodeType!=1))}function ii(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 Qs(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class ef{constructor(e,t,i){this.lock=t,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=tf(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let i=e;i<t;i++)this.top.children[i].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,i){let o=0,s=this.stack.length>>1,r=Math.min(s,e.length);for(;o<r&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=pe,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=bt.create(this.top,e[s],t,i);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,i,o){let s=-1,r;if(o>=this.preMatch.index&&(r=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,i))s=this.top.children.indexOf(r,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,i)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,i,o,s){let r=this.top.children[o];return r.dirty==Me&&r.dom==r.contentDOM&&(r.dirty=rt),r.update(e,t,i,s)?(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 i=e.pmViewDesc;if(i){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==i)return o}return-1}e=t}}updateNextNode(e,t,i,o,s,r){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Ge){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let d=a.dom,h,u=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Me&&ii(t,a.outerDeco));if(!u&&a.update(e,t,i,o))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(h=this.recreateWrapper(a,e,t,i,o,r)))return this.destroyBetween(this.index,l),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=rt,h.updateChildren(o,r+1),h.dirty=pe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,i,o,s,r){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ii(i,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=Ge.create(this.top,t,i,o,s,r);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,i,o,s){let r=Ge.create(this.top,e,t,i,o,s);r.contentDOM&&r.updateChildren(o,s+1),this.top.children.splice(this.index++,0,r),this.changed=!0}placeWidget(e,t,i){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 s=new ma(this.top,e,t,i);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 bt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof gi)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((te||Y)&&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 i=document.createElement(e);e=="IMG"&&(i.className="ProseMirror-separator",i.alt=""),e=="BR"&&(i.className="ProseMirror-trailingBreak");let o=new ga(this.top,[],i,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||e.nodeType==1&&e.contains(this.lock.parentNode))}}function tf(n,e){let t=e,i=t.children.length,o=n.childCount,s=new Map,r=[];e:for(;o>0;){let l;for(;;)if(i){let c=t.children[i-1];if(c instanceof bt)t=c,i=c.children.length;else{l=c,i--;break}}else{if(t==e)break e;i=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,s.set(l,o),r.push(l)}}return{index:o,matched:s,matches:r.reverse()}}function nf(n,e){return n.type.side-e.type.side}function of(n,e,t,i){let o=e.locals(n),s=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);i(d,o,e.forChild(s,d),c),s+=d.nodeSize}return}let r=0,l=[],a=null;for(let c=0;;){let d,h;for(;r<o.length&&o[r].to==s;){let g=o[r++];g.widget&&(d?(h||(h=[d])).push(g):d=g)}if(d)if(h){h.sort(nf);for(let g=0;g<h.length;g++)t(h[g],c,!!a)}else t(d,c,!!a);let u,f;if(a)f=-1,u=a,a=null;else if(c<n.childCount)f=c,u=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;r<o.length&&o[r].from<=s&&o[r].to>s;)l.push(o[r++]);let p=s+u.nodeSize;if(u.isText){let g=p;r<o.length&&o[r].from<g&&(g=o[r].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<p&&(a=u.cut(g-s),u=u.cut(0,g-s),p=g,f=-1)}else for(;r<o.length&&o[r].to<p;)r++;let m=u.isInline&&!u.isLeaf?l.filter(g=>!g.inline):l.slice();i(u,m,e.forChild(s,u),f),s=p}}function sf(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 rf(n,e,t,i){for(let o=0,s=0;o<n.childCount&&s<=i;){let r=n.child(o++),l=s;if(s+=r.nodeSize,!r.isText)continue;let a=r.text;for(;o<n.childCount;){let c=n.child(o++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=i&&a.slice(i-e.length-l,i-l)==e)return i-e.length;let c=l<i?a.lastIndexOf(e,i-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==i&&a.length>=i+e.length-l&&a.slice(i-l,i-l+e.length)==e)return i}}return-1}function po(n,e,t,i,o){let s=[];for(let r=0,l=0;r<n.length;r++){let a=n[r],c=l,d=l+=a.size;c>=t||d<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,i)),o&&(s.push(o),o=void 0),d>t&&s.push(a.slice(t-c,a.size,i)))}return s}function zo(n,e=null){let t=n.domSelectionRange(),i=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,r=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(r<0)return null;let l=i.resolve(r),a,c;if(mi(t)){for(a=r;o&&!o.node;)o=o.parent;let h=o.node;if(o&&h.isAtom&&E.isSelectable(h)&&o.parent&&!(h.isInline&&Du(t.focusNode,t.focusOffset,o.dom))){let u=o.posBefore;c=new E(r==u?l:i.resolve(u))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let h=r,u=r;for(let f=0;f<t.rangeCount;f++){let p=t.getRangeAt(f);h=Math.min(h,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),u=Math.max(u,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(h<0)return null;[a,r]=u==n.state.selection.anchor?[u,h]:[h,u],l=i.resolve(r)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=i.resolve(a);if(!c){let h=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=Bo(n,d,l,h)}return c}function va(n){return n.editable?n.hasFocus():xa(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Re(n,e=!1){let t=n.state.selection;if(Sa(n,t),!!va(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Y){let i=n.domSelectionRange(),o=n.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&yt(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)af(n);else{let{anchor:i,head:o}=t,s,r;er&&!(t instanceof N)&&(t.$from.parent.inlineContent||(s=tr(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(r=tr(n,t.to))),n.docView.setSelection(i,o,n,e),er&&(s&&nr(s),r&&nr(r)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&lf(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const er=te||Y&&aa<63;function tr(n,e){let{node:t,offset:i}=n.docView.domFromPos(e,0),o=i<t.childNodes.length?t.childNodes[i]:null,s=i?t.childNodes[i-1]:null;if(te&&o&&o.contentEditable=="false")return Wi(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return Wi(o);if(s)return Wi(s)}}function Wi(n){return n.contentEditable="true",te&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function nr(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function lf(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),i=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=i||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!va(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function af(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let i=n.cursorWrapper.dom,o=i.nodeName=="IMG";o?t.setStart(i.parentNode,q(i)+1):t.setStart(i,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&se&&Je<=11&&(i.disabled=!0,i.disabled=!1)}function Sa(n,e){if(e instanceof E){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ir(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ir(n)}function ir(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Bo(n,e,t,i){return n.someProp("createSelectionBetween",o=>o(n,e,t))||N.between(e,t,i)}function or(n){return n.editable&&!n.hasFocus()?!1:xa(n)}function xa(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function cf(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return yt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function mo(n,e){let{$anchor:t,$head:i}=n.selection,o=e>0?t.max(i):t.min(i),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&O.findFrom(s,e)}function Fe(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function sr(n,e,t){let i=n.state.selection;if(i instanceof N)if(t.indexOf("s")>-1){let{$head:o}=i,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let r=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return Fe(n,new N(i.$anchor,r))}else if(i.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=mo(n.state,e);return o&&o instanceof E?Fe(n,o):!1}else if(!(ue&&t.indexOf("m")>-1)){let o=i.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,r;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(r=n.docView.descAt(l))&&!r.contentDOM?E.isSelectable(s)?Fe(n,new E(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):wn?Fe(n,new N(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(i instanceof E&&i.node.isInline)return Fe(n,new N(e>0?i.$to:i.$from));{let o=mo(n.state,e);return o?Fe(n,o):!1}}}function oi(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function rn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Tt(n,e){return e<0?df(n):hf(n)}function df(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let o,s,r=!1;for(we&&t.nodeType==1&&i<oi(t)&&rn(t.childNodes[i],-1)&&(r=!0);;)if(i>0){if(t.nodeType!=1)break;{let l=t.childNodes[i-1];if(rn(l,-1))o=t,s=--i;else if(l.nodeType==3)t=l,i=t.nodeValue.length;else break}}else{if(Ca(t))break;{let l=t.previousSibling;for(;l&&rn(l,-1);)o=t.parentNode,s=q(l),l=l.previousSibling;if(l)t=l,i=oi(t);else{if(t=t.parentNode,t==n.dom)break;i=0}}}r?go(n,t,i):o&&go(n,o,s)}function hf(n){let e=n.domSelectionRange(),t=e.focusNode,i=e.focusOffset;if(!t)return;let o=oi(t),s,r;for(;;)if(i<o){if(t.nodeType!=1)break;let l=t.childNodes[i];if(rn(l,1))s=t,r=++i;else break}else{if(Ca(t))break;{let l=t.nextSibling;for(;l&&rn(l,1);)s=l.parentNode,r=q(l)+1,l=l.nextSibling;if(l)t=l,i=0,o=oi(t);else{if(t=t.parentNode,t==n.dom)break;i=o=0}}}s&&go(n,s,r)}function Ca(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function uf(n,e){for(;n&&e==n.childNodes.length&&!bn(n);)e=q(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function ff(n,e){for(;n&&!e&&!bn(n);)e=q(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function go(n,e,t){if(e.nodeType!=3){let s,r;(r=uf(e,t))?(e=r,t=0):(s=ff(e,t))&&(e=s,t=s.nodeValue.length)}let i=n.domSelection();if(!i)return;if(mi(i)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),i.removeAllRanges(),i.addRange(s)}else i.extend&&i.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&Re(n)},50)}function rr(n,e){let t=n.state.doc.resolve(e);if(!(Y||Ru)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),r=(s.top+s.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),r=(s.top+s.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function lr(n,e,t){let i=n.state.selection;if(i instanceof N&&!i.empty||t.indexOf("s")>-1||ue&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=i;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let r=mo(n.state,e);if(r&&r instanceof E)return Fe(n,r)}if(!o.parent.inlineContent){let r=e<0?o:s,l=i instanceof ce?O.near(r,e):O.findFrom(r,e);return l?Fe(n,l):!1}return!1}function ar(n,e){if(!(n.state.selection instanceof N))return!0;let{$head:t,$anchor:i,empty:o}=n.state.selection;if(!t.sameParent(i))return!0;if(!o)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 r=n.state.tr;return e<0?r.delete(t.pos-s.nodeSize,t.pos):r.delete(t.pos,t.pos+s.nodeSize),n.dispatch(r),!0}return!1}function cr(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function pf(n){if(!te||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let i=e.firstChild;cr(n,i,"true"),setTimeout(()=>cr(n,i,"false"),20)}return!1}function mf(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function gf(n,e){let t=e.keyCode,i=mf(e);if(t==8||ue&&t==72&&i=="c")return ar(n,-1)||Tt(n,-1);if(t==46&&!e.shiftKey||ue&&t==68&&i=="c")return ar(n,1)||Tt(n,1);if(t==13||t==27)return!0;if(t==37||ue&&t==66&&i=="c"){let o=t==37?rr(n,n.state.selection.from)=="ltr"?-1:1:-1;return sr(n,o,i)||Tt(n,o)}else if(t==39||ue&&t==70&&i=="c"){let o=t==39?rr(n,n.state.selection.from)=="ltr"?1:-1:1;return sr(n,o,i)||Tt(n,o)}else{if(t==38||ue&&t==80&&i=="c")return lr(n,-1,i)||Tt(n,-1);if(t==40||ue&&t==78&&i=="c")return pf(n)||lr(n,1,i)||Tt(n,1);if(i==(ue?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function ka(n,e){n.someProp("transformCopied",f=>{e=f(e,n)});let t=[],{content:i,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&i.childCount==1&&i.firstChild.childCount==1;){o--,s--;let f=i.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),i=f.content}let r=n.someProp("clipboardSerializer")||wt.fromSchema(n.state.schema),l=Na(),a=l.createElement("div");a.appendChild(r.serializeFragment(i,{document:l}));let c=a.firstChild,d,h=0;for(;c&&c.nodeType==1&&(d=Oa[c.nodeName.toLowerCase()]);){for(let f=d.length-1;f>=0;f--){let p=l.createElement(d[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),h++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${h?` -${h}`:""} ${JSON.stringify(t)}`);let u=n.someProp("clipboardTextSerializer",f=>f(e,n))||e.content.textBetween(0,e.content.size,`
127
127
 
128
- `);return{dom:a,text:u,slice:e}}function Ta(n,e,t,i,o){let r=o.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=e&&(i||r||!t);if(a){if(n.someProp("transformPastedText",u=>{e=u(e,r||i,n)}),r)return e?new C(w.from(n.state.schema.text(e.replace(/\r\n?/g,`
129
- `))),0,0):C.empty;let h=n.someProp("clipboardTextParser",u=>u(e,o,i,n));if(h)l=h;else{let u=o.marks(),{schema:f}=n.state,p=wt.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(f.text(m,u)))})}}else n.someProp("transformPastedHTML",h=>{t=h(t,n)}),s=Sf(t),wn&&vf(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 h=+d[3];h>0;h--){let u=s.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;s=u}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Ht.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!yf.test(u.parentNode.nodeName)?{ignore:!0}:null}})),d)l=xf(cs(l,+d[1],+d[2]),d[4]);else if(l=C.maxOpen(bf(l.content,o),!0),l.openStart||l.openEnd){let h=0,u=0;for(let f=l.content.firstChild;h<l.openStart&&!f.type.spec.isolating;h++,f=f.firstChild);for(let f=l.content.lastChild;u<l.openEnd&&!f.type.spec.isolating;u++,f=f.lastChild);l=cs(l,h,u)}return n.someProp("transformPasted",h=>{l=h(l,n)}),l}const yf=/^(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 bf(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)),r,s=[];if(n.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&r.length&&Aa(a,r,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Oa(s[s.length-1],r.length));let d=Ma(l,a);s.push(d),o=o.matchType(d.type),r=a}}),s)return w.from(s)}return n}function Ma(n,e,t=0){for(let i=e.length-1;i>=t;i--)n=e[i].create(null,w.from(n));return n}function Aa(n,e,t,i,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let r=Aa(n,e,t,i.lastChild,o+1);if(r)return i.copy(i.content.replaceChild(i.childCount-1,r));if(i.contentMatchAt(i.childCount).matchType(o==n.length-1?t.type:n[o+1]))return i.copy(i.content.append(w.from(Ma(t,n,o+1))))}}function Oa(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Oa(n.lastChild,e-1)),i=n.contentMatchAt(n.childCount).fillBefore(w.empty,!0);return n.copy(t.append(i))}function yo(n,e,t,i,o,r){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(r=0),o<i-1&&(l=yo(l,e,t,i,o+1,r)),o>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,r<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(w.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function cs(n,e,t){return e<n.openStart&&(n=new C(yo(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new C(yo(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Ea={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ds=null;function Na(){return ds||(ds=document.implementation.createHTMLDocument("title"))}let _i=null;function wf(n){let e=window.trustedTypes;return e?(_i||(_i=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),_i.createHTML(n)):n}function Sf(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Na().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(n),o;if((o=i&&Ea[i[1].toLowerCase()])&&(n=o.map(r=>"<"+r+">").join("")+n+o.map(r=>"</"+r+">").reverse().join("")),t.innerHTML=wf(n),o)for(let r=0;r<o.length;r++)t=t.querySelector(o[r])||t;return t}function vf(n){let e=n.querySelectorAll(Z?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let i=e[t];i.childNodes.length==1&&i.textContent==" "&&i.parentNode&&i.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),i)}}function xf(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch{return n}let{content:o,openStart:r,openEnd:s}=n;for(let l=i.length-2;l>=0;l-=2){let a=t.nodes[i[l]];if(!a||a.hasRequiredAttrs())break;o=w.from(a.create(i[l+1],o)),r++,s++}return new C(o,r,s)}const ne={},ie={},Cf={touchstart:!0,touchmove:!0};class kf{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Tf(n){for(let e in ne){let t=ne[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=i=>{Af(n,i)&&!Bo(n,i)&&(n.editable||!(i.type in ie))&&t(n,i)},Cf[e]?{passive:!0}:void 0)}te&&n.dom.addEventListener("input",()=>null),bo(n)}function je(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Mf(n){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 bo(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=i=>Bo(n,i))})}function Bo(n,e){return n.someProp("handleDOMEvents",t=>{let i=t[e.type];return i?i(n,e)||e.defaultPrevented:!1})}function Af(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){!Bo(n,e)&&ne[e.type]&&(n.editable||!(e.type in ie))&&ne[e.type](n,e)}ie.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Ia(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ge&&Z&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),_t&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let i=Date.now();n.input.lastIOSEnter=i,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==i&&(n.someProp("handleKeyDown",o=>o(n,ot(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",i=>i(n,t))||gf(n,t)?t.preventDefault():je(n,"key")};ie.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};ie.keypress=(n,e)=>{let t=e;if(Ia(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ue&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let i=n.state.selection;if(!(i instanceof N)||!i.$from.sameParent(i.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",r=>r(n,i.$from.pos,i.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function yi(n){return{left:n.clientX,top:n.clientY}}function Ef(n,e){let t=e.x-n.clientX,i=e.y-n.clientY;return t*t+i*i<100}function Ho(n,e,t,i,o){if(i==-1)return!1;let r=n.state.doc.resolve(i);for(let s=r.depth+1;s>0;s--)if(n.someProp(e,l=>s>r.depth?l(n,t,r.nodeAfter,r.before(s),o,!0):l(n,t,r.node(s),r.before(s),o,!1)))return!0;return!1}function zt(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let i=n.state.tr.setSelection(e);i.setMeta("pointer",!0),n.dispatch(i)}function Nf(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),i=t.nodeAfter;return i&&i.isAtom&&O.isSelectable(i)?(zt(n,new O(t)),!0):!1}function Df(n,e){if(e==-1)return!1;let t=n.state.selection,i,o;t instanceof O&&(i=t.node);let r=n.state.doc.resolve(e);for(let s=r.depth+1;s>0;s--){let l=s>r.depth?r.nodeAfter:r.node(s);if(O.isSelectable(l)){i&&t.$from.depth>0&&s>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?o=r.before(t.$from.depth):o=r.before(s);break}}return o!=null?(zt(n,O.create(n.state.doc,o)),!0):!1}function If(n,e,t,i,o){return Ho(n,"handleClickOn",e,t,i)||n.someProp("handleClick",r=>r(n,e,i))||(o?Df(n,t):Nf(n,t))}function Pf(n,e,t,i){return Ho(n,"handleDoubleClickOn",e,t,i)||n.someProp("handleDoubleClick",o=>o(n,e,i))}function Rf(n,e,t,i){return Ho(n,"handleTripleClickOn",e,t,i)||n.someProp("handleTripleClick",o=>o(n,e,i))||Vf(n,t,i)}function Vf(n,e,t){if(t.button!=0)return!1;let i=n.state.doc;if(e==-1)return i.inlineContent?(zt(n,N.create(i,0,i.content.size)),!0):!1;let o=i.resolve(e);for(let r=o.depth+1;r>0;r--){let s=r>o.depth?o.nodeAfter:o.node(r),l=o.before(r);if(s.inlineContent)zt(n,N.create(i,l+1,l+1+s.content.size));else if(O.isSelectable(s))zt(n,O.create(i,l));else continue;return!0}}function Fo(n){return ri(n)}const Da=ue?"metaKey":"ctrlKey";ne.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let i=Fo(n),o=Date.now(),r="singleClick";o-n.input.lastClick.time<500&&Ef(t,n.input.lastClick)&&!t[Da]&&(n.input.lastClick.type=="singleClick"?r="doubleClick":n.input.lastClick.type=="doubleClick"&&(r="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:r};let s=n.posAtCoords(yi(t));s&&(r=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Lf(n,s,t,!!i)):(r=="doubleClick"?Pf:Rf)(n,s.pos,s.inside,t)?t.preventDefault():je(n,"pointer"))};class Lf{constructor(e,t,i,o){this.view=e,this.pos=t,this.event=i,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!i[Da],this.allowDefault=i.shiftKey;let r,s;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),s=t.inside;else{let d=e.state.doc.resolve(t.pos);r=d.parent,s=d.depth?d.before():0}const l=o?null:i.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(i.button==0&&r.type.spec.draggable&&r.type.spec.selectable!==!1||c instanceof O&&c.from<=s&&c.to>s)&&(this.mightDrag={node:r,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&we&&!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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),je(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),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(()=>Re(this.view)),this.view.input.mouseDown=null}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(yi(e))),this.updateAllowDefault(e),this.allowDefault||!t?je(this.view,"pointer"):If(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||te&&this.mightDrag&&!this.mightDrag.node.isAtom||Z&&!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)?(zt(this.view,E.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):je(this.view,"pointer")}move(e){this.updateAllowDefault(e),je(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ne.touchstart=n=>{n.input.lastTouch=Date.now(),Fo(n),je(n,"pointer")};ne.touchmove=n=>{n.input.lastTouch=Date.now(),je(n,"pointer")};ne.contextmenu=n=>Fo(n);function Ia(n,e){return n.composing?!0:te&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const zf=ge?5e3:-1;ie.compositionstart=ie.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof N&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(i=>i.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),ri(n,!0),n.markCursor=null;else if(ri(n,!e.selection.empty),we&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let i=n.domSelectionRange();for(let o=i.focusNode,r=i.focusOffset;o&&o.nodeType==1&&r!=0;){let s=r<0?o.lastChild:o.childNodes[r-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,r=-1}}n.input.composing=!0}Pa(n,zf)};ie.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Pa(n,20))};function Pa(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>ri(n),e))}function Ra(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Hf());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Bf(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Eu(e.focusNode,e.focusOffset),i=Nu(e.focusNode,e.focusOffset);if(t&&i&&t!=i){let o=i.pmViewDesc,r=n.domObserver.lastChangedTextNode;if(t==r||i==r)return r;if(!o||!o.isText(i.nodeValue))return i;if(n.input.compositionNode==i){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return i}}return t||i}function Hf(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function ri(n,e=!1){if(!(ge&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ra(n),e||n.docView&&n.docView.dirty){let t=Lo(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Ff(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 i=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),i.removeAllRanges(),i.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const fn=re&&Je<15||_t&&Vu<604;ne.copy=ie.cut=(n,e)=>{let t=e,i=n.state.selection,o=t.type=="cut";if(i.empty)return;let r=fn?null:t.clipboardData,s=i.content(),{dom:l,text:a}=ka(n,s);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",a)):Ff(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function $f(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,i=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),i.parentNode&&i.parentNode.removeChild(i),t?pn(n,i.value,null,o,e):pn(n,i.textContent,i.innerHTML,o,e)},50)}function pn(n,e,t,i,o){let r=Ta(n,e,t,i,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,r||C.empty)))return!0;if(!r)return!1;let s=$f(r),l=s?n.state.tr.replaceSelectionWith(s,i):n.state.tr.replaceSelection(r);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Va(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," "):""}ie.paste=(n,e)=>{let t=e;if(n.composing&&!ge)return;let i=fn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;i&&pn(n,Va(i),i.getData("text/html"),o,t)?t.preventDefault():Wf(n,t)};class La{constructor(e,t,i){this.slice=e,this.move=t,this.node=i}}const za=ue?"altKey":"ctrlKey";ne.dragstart=(n,e)=>{let t=e,i=n.input.mouseDown;if(i&&i.done(),!t.dataTransfer)return;let o=n.state.selection,r=o.empty?null:n.posAtCoords(yi(t)),s;if(!(r&&r.pos>=o.from&&r.pos<=(o instanceof O?o.to-1:o.to))){if(i&&i.mightDrag)s=O.create(n.state.doc,i.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let h=n.docView.nearestDesc(t.target,!0);h&&h.node.type.spec.draggable&&h!=n.docView&&(s=O.create(n.state.doc,h.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:d}=ka(n,l);(!t.dataTransfer.files.length||!Z||aa>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(fn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",fn||t.dataTransfer.setData("text/plain",c),n.dragging=new La(d,!t[za],s)};ne.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};ie.dragover=ie.dragenter=(n,e)=>e.preventDefault();ie.drop=(n,e)=>{let t=e,i=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(yi(t));if(!o)return;let r=n.state.doc.resolve(o.pos),s=i&&i.slice;s?n.someProp("transformPasted",p=>{s=p(s,n)}):s=Ta(n,Va(t.dataTransfer),fn?null:t.dataTransfer.getData("text/html"),!1,r);let l=!!(i&&!t[za]);if(n.someProp("handleDrop",p=>p(n,t,s||C.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?Vh(n.state.doc,r.pos,s):r.pos;a==null&&(a=r.pos);let c=n.state.tr;if(l){let{node:p}=i;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),h=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,u=c.doc;if(h?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(u))return;let f=c.doc.resolve(d);if(h&&O.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new O(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,x)=>p=x),c.setSelection(zo(n,f,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};ne.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())&&Re(n)},20))};ne.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)};ne.beforeinput=(n,e)=>{if(Z&&ge&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:i}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=i||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",r=>r(n,ot(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 ie)ne[n]=ie[n];function mn(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}class si{constructor(e,t){this.toDOM=e,this.spec=t||ft,this.side=this.spec.side||0}map(e,t,i,o){let{pos:r,deleted:s}=e.mapResult(t.from+o,this.side<0?-1:1);return s?null:new oe(r-i,r-i,this)}valid(){return!0}eq(e){return this==e||e instanceof si&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&mn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ue{constructor(e,t){this.attrs=e,this.spec=t||ft}map(e,t,i,o){let r=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-i,s=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-i;return r>=s?null:new oe(r,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ue&&mn(this.attrs,e.attrs)&&mn(this.spec,e.spec)}static is(e){return e.type instanceof Ue}destroy(){}}class $o{constructor(e,t){this.attrs=e,this.spec=t||ft}map(e,t,i,o){let r=e.mapResult(t.from+o,1);if(r.deleted)return null;let s=e.mapResult(t.to+o,-1);return s.deleted||s.pos<=r.pos?null:new oe(r.pos-i,s.pos-i,this)}valid(e,t){let{index:i,offset:o}=e.content.findIndex(t.from),r;return o==t.from&&!(r=e.child(i)).isText&&o+r.nodeSize==t.to}eq(e){return this==e||e instanceof $o&&mn(this.attrs,e.attrs)&&mn(this.spec,e.spec)}destroy(){}}class oe{constructor(e,t,i){this.from=e,this.to=t,this.type=i}copy(e,t){return new oe(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,i){return this.type.map(e,this,t,i)}static widget(e,t,i){return new oe(e,e,new si(t,i))}static inline(e,t,i,o){return new oe(e,t,new Ue(i,o))}static node(e,t,i,o){return new oe(e,t,new $o(i,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ue}get widget(){return this.type instanceof si}}const Ot=[],ft={};class z{constructor(e,t){this.local=e.length?e:Ot,this.children=t.length?t:Ot}static create(e,t){return t.length?li(t,e,0,ft):G}find(e,t,i){let o=[];return this.findInner(e??0,t??1e9,o,0,i),o}findInner(e,t,i,o,r){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!r||r(l.spec))&&i.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,i,o+l,r)}}map(e,t,i){return this==G||e.maps.length==0?this:this.mapInner(e,t,0,0,i||ft)}mapInner(e,t,i,o,r){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,i,o);a&&a.type.valid(t,a)?(s||(s=[])).push(a):r.onRemove&&r.onRemove(this.local[l].spec)}return this.children.length?_f(this.children,s||[],e,t,i,o,r):s?new z(s.sort(pt),Ot):G}add(e,t){return t.length?this==G?z.create(e,t):this.addInner(e,t,0):this}addInner(e,t,i){let o,r=0;e.forEach((l,a)=>{let c=a+i,d;if(d=Ha(t,l,c)){for(o||(o=this.children.slice());r<o.length&&o[r]<a;)r+=3;o[r]==a?o[r+2]=o[r+2].addInner(l,d,c+1):o.splice(r,0,a,a+l.nodeSize,li(d,l,c+1,ft)),r+=3}});let s=Ba(r?Fa(t):t,-i);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new z(s.length?this.local.concat(s).sort(pt):this.local,o||this.children)}remove(e){return e.length==0||this==G?this:this.removeInner(e,0)}removeInner(e,t){let i=this.children,o=this.local;for(let r=0;r<i.length;r+=3){let s,l=i[r]+t,a=i[r+1]+t;for(let d=0,h;d<e.length;d++)(h=e[d])&&h.from>l&&h.to<a&&(e[d]=null,(s||(s=[])).push(h));if(!s)continue;i==this.children&&(i=this.children.slice());let c=i[r+2].removeInner(s,l+1);c!=G?i[r+2]=c:(i.splice(r,3),r-=3)}if(o.length){for(let r=0,s;r<e.length;r++)if(s=e[r])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 i==this.children&&o==this.local?this:o.length||i.length?new z(o,i):G}forChild(e,t){if(this==G)return this;if(t.isLeaf)return z.empty;let i,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(i=this.children[l+2]);break}let r=e+1,s=r+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>r&&a.type instanceof Ue){let c=Math.max(r,a.from)-r,d=Math.min(s,a.to)-r;c<d&&(o||(o=[])).push(a.copy(c,d))}}if(o){let l=new z(o.sort(pt),Ot);return i?new We([l,i]):l}return i||G}eq(e){if(this==e)return!0;if(!(e instanceof z)||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 Wo(this.localsInner(e))}localsInner(e){if(this==G)return Ot;if(e.inlineContent||!this.local.some(Ue.is))return this.local;let t=[];for(let i=0;i<this.local.length;i++)this.local[i].type instanceof Ue||t.push(this.local[i]);return t}forEachSet(e){e(this)}}z.empty=new z([],[]);z.removeOverlap=Wo;const G=z.empty;class We{constructor(e){this.members=e}map(e,t){const i=this.members.map(o=>o.map(e,t,ft));return We.from(i)}forChild(e,t){if(t.isLeaf)return z.empty;let i=[];for(let o=0;o<this.members.length;o++){let r=this.members[o].forChild(e,t);r!=G&&(r instanceof We?i=i.concat(r.members):i.push(r))}return We.from(i)}eq(e){if(!(e instanceof We)||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,i=!0;for(let o=0;o<this.members.length;o++){let r=this.members[o].localsInner(e);if(r.length)if(!t)t=r;else{i&&(t=t.slice(),i=!1);for(let s=0;s<r.length;s++)t.push(r[s])}}return t?Wo(i?t:t.sort(pt)):Ot}static from(e){switch(e.length){case 0:return G;case 1:return e[0];default:return new We(e.every(t=>t instanceof z)?e:e.reduce((t,i)=>t.concat(i instanceof z?i:i.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function _f(n,e,t,i,o,r,s){let l=n.slice();for(let c=0,d=r;c<t.maps.length;c++){let h=0;t.maps[c].forEach((u,f,p,m)=>{let g=m-p-(f-u);for(let y=0;y<l.length;y+=3){let x=l[y+1];if(x<0||u>x+d-h)continue;let b=l[y]+d-h;f>=b?l[y+1]=u<=b?-2:-1:u>=d&&g&&(l[y]+=g,l[y+1]+=g)}h+=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]+r),h=d-o;if(h<0||h>=i.content.size){a=!0;continue}let u=t.map(n[c+1]+r,-1),f=u-o,{index:p,offset:m}=i.content.findIndex(h),g=i.maybeChild(p);if(g&&m==h&&m+g.nodeSize==f){let y=l[c+2].mapInner(t,g,d+1,n[c]+r+1,s);y!=G?(l[c]=h,l[c+1]=f,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Kf(l,n,e,t,o,r,s),d=li(c,i,0,s);e=d.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,u=0;h<d.children.length;h+=3){let f=d.children[h];for(;u<l.length&&l[u]<f;)u+=3;l.splice(u,0,d.children[h],d.children[h+1],d.children[h+2])}}return new z(e.sort(pt),l)}function Ba(n,e){if(!e||!n.length)return n;let t=[];for(let i=0;i<n.length;i++){let o=n[i];t.push(new oe(o.from+e,o.to+e,o.type))}return t}function Kf(n,e,t,i,o,r,s){function l(a,c){for(let d=0;d<a.local.length;d++){let h=a.local[d].map(i,o,c);h?t.push(h):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]+r+1);return t}function Ha(n,e,t){if(e.isLeaf)return null;let i=t+e.nodeSize,o=null;for(let r=0,s;r<n.length;r++)(s=n[r])&&s.from>t&&s.to<i&&((o||(o=[])).push(s),n[r]=null);return o}function Fa(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function li(n,e,t,i){let o=[],r=!1;e.forEach((l,a)=>{let c=Ha(n,l,a+t);if(c){r=!0;let d=li(c,l,t+a+1,i);d!=G&&o.push(a,a+l.nodeSize,d)}});let s=Ba(r?Fa(n):n,-t).sort(pt);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(i.onRemove&&i.onRemove(s[l].spec),s.splice(l--,1));return s.length||o.length?new z(s,o):G}function pt(n,e){return n.from-e.from||n.to-e.to}function Wo(n){let e=n;for(let t=0;t<e.length-1;t++){let i=e[t];if(i.from!=i.to)for(let o=t+1;o<e.length;o++){let r=e[o];if(r.from==i.from){r.to!=i.to&&(e==n&&(e=n.slice()),e[o]=r.copy(r.from,i.to),hs(e,o+1,r.copy(i.to,r.to)));continue}else{r.from<i.to&&(e==n&&(e=n.slice()),e[t]=i.copy(i.from,r.from),hs(e,o,i.copy(r.from,i.to)));break}}}return e}function hs(n,e,t){for(;e<n.length&&pt(t,n[e])>0;)e++;n.splice(e,0,t)}function Ki(n){let e=[];return n.someProp("decorations",t=>{let i=t(n.state);i&&i!=G&&e.push(i)}),n.cursorWrapper&&e.push(z.create(n.state.doc,[n.cursorWrapper.deco])),We.from(e)}const qf={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},jf=re&&Je<=11;class Jf{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Gf{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Jf,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(i=>{for(let o=0;o<i.length;o++)this.queue.push(i[o]);re&&Je<=11&&i.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),jf&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.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,qf)),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(ns(this.view)){if(this.suppressingSelectionUpdates)return Re(this.view);if(re&&Je<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&yt(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,i;for(let r=e.focusNode;r;r=un(r))t.add(r);for(let r=e.anchorNode;r;r=un(r))if(t.has(r)){i=r;break}let o=i&&this.view.docView.nearestDesc(i);if(o&&o.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i}))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 i=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&ns(e)&&!this.ignoreSelectionChange(i),r=-1,s=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let h=this.registerMutation(t[d],a);h&&(r=r<0?h.from:Math.min(h.from,r),s=s<0?h.to:Math.max(h.to,s),h.typeOver&&(l=!0))}if(we&&a.length){let d=a.filter(h=>h.nodeName=="BR");if(d.length==2){let[h,u]=d;h.parentNode&&h.parentNode.parentNode==u.parentNode?u.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let u of d){let f=u.parentNode;f&&f.nodeName=="LI"&&(!h||Yf(e,h)!=f)&&u.remove()}}}let c=null;r<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&mi(i)&&(c=Lo(e))&&c.eq(E.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Re(e),this.currentSelection.set(i),e.scrollToSelection()):(r>-1||o)&&(r>-1&&(e.docView.markDirty(r,s),Uf(e)),this.handleDOMChange(r,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(i)||Re(e),this.currentSelection.set(i))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let i=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(i==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!i||i.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let h=e.addedNodes[d];t.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(e.target))return{from:i.posBefore,to:i.posAfter};let o=e.previousSibling,r=e.nextSibling;if(re&&Je<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:h,nextSibling:u}=e.addedNodes[d];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(o=h),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(r=u)}let s=o&&o.parentNode==e.target?q(o)+1:0,l=i.localPosFromDOM(e.target,s,-1),a=r&&r.parentNode==e.target?q(r):e.target.childNodes.length,c=i.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}:(this.lastChangedTextNode=e.target,{from:i.posAtStart,to:i.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let us=new WeakMap,fs=!1;function Uf(n){if(!us.has(n)&&(us.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=we,fs)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."),fs=!0}}function ps(n,e){let t=e.startContainer,i=e.startOffset,o=e.endContainer,r=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return yt(s.node,s.offset,o,r)&&([t,i,o,r]=[o,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:o,focusOffset:r}}function Zf(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return ps(n,o)}let t;function i(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",i,!0),t?ps(n,t):null}function Yf(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let i=n.docView.nearestDesc(t,!0);if(i&&i.node.isBlock)return t}return null}function Xf(n,e,t){let{node:i,fromOffset:o,toOffset:r,from:s,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],mi(a)||c.push({node:a.focusNode,offset:a.focusOffset})),Z&&n.input.lastKeyCode===8)for(let g=r;g>o;g--){let y=i.childNodes[g-1],x=y.pmViewDesc;if(y.nodeName=="BR"&&!x){r=g;break}if(!x||x.size)break}let h=n.state.doc,u=n.someProp("domParser")||Ht.fromSchema(n.state.schema),f=h.resolve(s),p=null,m=u.parse(i,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:o,to:r,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Qf,context:f});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+s,head:y+s}}return{doc:m,sel:p,from:s,to:l}}function Qf(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(te&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||te&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const ep=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function tp(n,e,t,i,o){let r=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let M=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,R=Lo(n,M);if(R&&!n.state.selection.eq(R)){if(Z&&ge&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",V=>V(n,ot(13,"Enter"))))return;let P=n.state.tr.setSelection(R);M=="pointer"?P.setMeta("pointer",!0):M=="key"&&P.scrollIntoView(),r&&P.setMeta("composition",r),n.dispatch(P)}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=Xf(n,e,t),d=n.state.doc,h=d.slice(c.from,c.to),u,f;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,f="end"):(u=n.state.selection.from,f="start"),n.input.lastKeyCode=null;let p=op(h.content,c.doc.content,c.from,u,f);if(p&&n.input.domChangeCount++,(_t&&n.input.lastIOSEnter>Date.now()-225||ge)&&o.some(M=>M.nodeType==1&&!ep.test(M.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",M=>M(n,ot(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(i&&a instanceof N&&!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 M=ms(n,n.state.doc,c.sel);if(M&&!M.eq(n.state.selection)){let R=n.state.tr.setSelection(M);r&&R.setMeta("composition",r),n.dispatch(R)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof N&&(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)),re&&Je<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=d.resolve(p.start),x=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA,b;if((_t&&n.input.lastIOSEnter>Date.now()-225&&(!x||o.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!x&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(b=E.findFrom(c.doc.resolve(m.pos+1),1,!0))&&b.head==g.pos)&&n.someProp("handleKeyDown",M=>M(n,ot(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&ip(d,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",M=>M(n,ot(8,"Backspace")))){ge&&Z&&n.domObserver.suppressSelectionUpdates();return}Z&&ge&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),ge&&!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(M){return M(n,ot(13,"Enter"))})},20));let S=p.start,v=p.endA,k,A,L;if(x){if(m.pos==g.pos)re&&Je<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Re(n),20)),k=n.state.tr.delete(S,v),A=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(L=np(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))k=n.state.tr,L.type=="add"?k.addMark(S,v,L.mark):k.removeMark(S,v,L.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let M=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",R=>R(n,S,v,M)))return;k=n.state.tr.insertText(M,S,v)}}if(k||(k=n.state.tr.replace(S,v,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let M=ms(n,k.doc,c.sel);M&&!(Z&&ge&&n.composing&&M.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(M.head==S||M.head==k.mapping.map(v)-1)||re&&M.empty&&M.head==S)&&k.setSelection(M)}A&&k.ensureMarks(A),r&&k.setMeta("composition",r),n.dispatch(k.scrollIntoView())}function ms(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:zo(n,e.resolve(t.anchor),e.resolve(t.head))}function np(n,e){let t=n.firstChild.marks,i=e.firstChild.marks,o=t,r=i,s,l,a;for(let d=0;d<i.length;d++)o=i[d].removeFromSet(o);for(let d=0;d<t.length;d++)r=t[d].removeFromSet(r);if(o.length==1&&r.length==0)l=o[0],s="add",a=d=>d.mark(l.addToSet(d.marks));else if(o.length==0&&r.length==1)l=r[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(w.from(c).eq(n))return{mark:l,type:s}}function ip(n,e,t,i,o){if(t-e<=o.pos-i.pos||qi(i,!0,!1)<o.pos)return!1;let r=n.resolve(e);if(!i.parent.isTextblock){let l=r.nodeAfter;return l!=null&&t==e+l.nodeSize}if(r.parentOffset<r.parent.content.size||!r.parent.isTextblock)return!1;let s=n.resolve(qi(r,!0,!0));return!s.parent.isTextblock||s.pos>t||qi(s,!0,!1)<t?!1:i.parent.content.cut(i.parentOffset).eq(s.parent.content)}function qi(n,e,t){let i=n.depth,o=e?n.end():n.pos;for(;i>0&&(e||n.indexAfter(i)==n.node(i).childCount);)i--,o++,e=!1;if(t){let r=n.node(i).maybeChild(n.indexAfter(i));for(;r&&!r.isLeaf;)r=r.firstChild,o++}return o}function op(n,e,t,i,o){let r=n.findDiffStart(e,t);if(r==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,r-Math.min(s,l));i-=s+a-r}if(s<r&&n.size<e.size){let a=i<=r&&i>=s?r-i:0;r-=a,r&&r<e.size&&gs(e.textBetween(r-1,r+1))&&(r+=a?1:-1),l=r+(l-s),s=r}else if(l<r){let a=i<=r&&i>=l?r-i:0;r-=a,r&&r<n.size&&gs(n.textBetween(r-1,r+1))&&(r+=a?1:-1),s=r+(s-l),l=r}return{start:r,endA:s,endB:l}}function gs(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class rp{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 kf,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(vs),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=ws(this),bs(this),this.nodeViews=Ss(this),this.docView=Zr(this.state.doc,ys(this),Ki(this),this.dom,this),this.domObserver=new Gf(this,(i,o,r,s)=>tp(this,i,o,r,s)),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&&bo(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(vs),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let i in this._props)t[i]=this._props[i];t.state=this.state;for(let i in e)t[i]=e[i];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var i;let o=this.state,r=!1,s=!1;e.storedMarks&&this.composing&&(Ra(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 f=Ss(this);lp(f,this.nodeViews)&&(this.nodeViews=f,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&bo(this),this.editable=ws(this),bs(this);let a=Ki(this),c=ys(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",h=r||!this.docView.matchesNode(e.doc,c,a);(h||!e.selection.eq(o.selection))&&(s=!0);let u=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Bu(this);if(s){this.domObserver.stop();let f=h&&(re||Z)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&sp(o.selection,e.selection);if(h){let p=Z?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Bf(this)),(r||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Zr(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&cf(this))?Re(this,f):(va(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((i=this.dragging)===null||i===void 0)&&i.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():u&&Hu(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof O){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Kr(this,t.getBoundingClientRect(),e)}else Kr(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 i=this.directPlugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let i=this.state.plugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let i=this.pluginViews[t];i.update&&i.update(this,e)}}updateDraggedNode(e,t){let i=e.node,o=-1;if(this.state.doc.nodeAt(i.from)==i.node)o=i.from;else{let r=i.from+(this.state.doc.content.size-t.doc.content.size);(r>0&&this.state.doc.nodeAt(r))==i.node&&(o=r)}this.dragging=new La(e.slice,e.move,o<0?void 0:O.create(this.state.doc,o))}someProp(e,t){let i=this._props&&this._props[e],o;if(i!=null&&(o=t?t(i):i))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 r=this.state.plugins;if(r)for(let s=0;s<r.length;s++){let l=r[s].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(re){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&&Fu(this.dom),Re(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 qu(this,e)}coordsAtPos(e,t=1){return fa(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,i=-1){let o=this.docView.posFromDOM(e,t,i);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Zu(this,t||this.state,e)}pasteHTML(e,t){return pn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return pn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Mf(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ki(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Au())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Of(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?te&&this.root.nodeType===11&&Iu(this.dom.ownerDocument)==this.dom&&Zf(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function ys(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 i in t)i=="class"?e.class+=" "+t[i]:i=="style"?e.style=(e.style?e.style+";":"")+t[i]:!e[i]&&i!="contenteditable"&&i!="nodeName"&&(e[i]=String(t[i]))}),e.translate||(e.translate="no"),[oe.node(0,n.state.doc.content.size,e)]}function bs(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:oe.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function ws(n){return!n.someProp("editable",e=>e(n.state)===!1)}function sp(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 Ss(n){let e=Object.create(null);function t(i){for(let o in i)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=i[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function lp(n,e){let t=0,i=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)i++;return t!=i}function vs(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 wo,So;if(typeof WeakMap<"u"){let n=new WeakMap;wo=e=>n.get(e),So=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;wo=i=>{for(let o=0;o<n.length;o+=2)if(n[o]==i)return n[o+1]},So=(i,o)=>(t==10&&(t=0),n[t++]=i,n[t++]=o)}var H=class{constructor(n,e,t,i){this.width=n,this.height=e,this.map=t,this.problems=i}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const i=e%this.width,o=e/this.width|0;let r=i+1,s=o+1;for(let l=1;r<this.width&&this.map[e+l]==t;l++)r++;for(let l=1;s<this.height&&this.map[e+this.width*l]==t;l++)s++;return{left:i,top:o,right:r,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){const{left:i,right:o,top:r,bottom:s}=this.findCell(n);return e=="horiz"?(t<0?i==0:o==this.width)?null:this.map[r*this.width+(t<0?i-1:o)]:(t<0?r==0:s==this.height)?null:this.map[i+this.width*(t<0?r-1:s)]}rectBetween(n,e){const{left:t,right:i,top:o,bottom:r}=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(i,l),bottom:Math.max(r,c)}}cellsInRect(n){const e=[],t={};for(let i=n.top;i<n.bottom;i++)for(let o=n.left;o<n.right;o++){const r=i*this.width+o,s=this.map[r];t[s]||(t[s]=!0,!(o==n.left&&o&&this.map[r-1]==s||i==n.top&&i&&this.map[r-this.width]==s)&&e.push(s))}return e}positionAt(n,e,t){for(let i=0,o=0;;i++){const r=o+t.child(i).nodeSize;if(i==n){let s=e+n*this.width;const l=(n+1)*this.width;for(;s<l&&this.map[s]<o;)s++;return s==l?r-1:this.map[s]}o=r}}static get(n){return wo(n)||So(n,ap(n))}};function ap(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=cp(n),t=n.childCount,i=[];let o=0,r=null;const s=[];for(let c=0,d=e*t;c<d;c++)i[c]=0;for(let c=0,d=0;c<t;c++){const h=n.child(c);d++;for(let p=0;;p++){for(;o<i.length&&i[o]!=0;)o++;if(p==h.childCount)break;const m=h.child(p),{colspan:g,rowspan:y,colwidth:x}=m.attrs;for(let b=0;b<y;b++){if(b+c>=t){(r||(r=[])).push({type:"overlong_rowspan",pos:d,n:y-b});break}const S=o+b*e;for(let v=0;v<g;v++){i[S+v]==0?i[S+v]=d:(r||(r=[])).push({type:"collision",row:c,pos:d,n:g-v});const k=x&&x[v];if(k){const A=(S+v)%e*2,L=s[A];L==null||L!=k&&s[A+1]==1?(s[A]=k,s[A+1]=1):L==k&&s[A+1]++}}}o+=g,d+=m.nodeSize}const u=(c+1)*e;let f=0;for(;o<u;)i[o++]==0&&f++;f&&(r||(r=[])).push({type:"missing",row:c,n:f}),d++}const l=new H(e,t,i,r);let a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<t&&(a=!0);return a&&dp(l,s,n),l}function cp(n){let e=-1,t=!1;for(let i=0;i<n.childCount;i++){const o=n.child(i);let r=0;if(t)for(let s=0;s<i;s++){const l=n.child(s);for(let a=0;a<l.childCount;a++){const c=l.child(a);s+c.attrs.rowspan>i&&(r+=c.attrs.colspan)}}for(let s=0;s<o.childCount;s++){const l=o.child(s);r+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=r:e!=r&&(e=Math.max(e,r))}return e}function dp(n,e,t){n.problems||(n.problems=[]);const i={};for(let o=0;o<n.map.length;o++){const r=n.map[o];if(i[r])continue;i[r]=!0;const s=t.nodeAt(r);if(!s)throw new RangeError(`No cell with offset ${r} found`);let l=null;const a=s.attrs;for(let c=0;c<a.colspan;c++){const d=(o+c)%n.width,h=e[d*2];h!=null&&(!a.colwidth||a.colwidth[c]!=h)&&((l||(l=hp(a)))[c]=h)}l&&n.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:l})}}function hp(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function xs(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),i=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(s=>Number(s)):null,o=Number(n.getAttribute("colspan")||1),r={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:i&&i.length==o?i:null};for(const s in e){const l=e[s].getFromDOM,a=l&&l(n);a!=null&&(r[s]=a)}return r}function Cs(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const i in e){const o=e[i].setDOMAttr;o&&o(n.attrs[i],t)}return t}function up(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const i in e)t[i]={default:e[i].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:i=>xs(i,e)}],toDOM(i){return["td",Cs(i,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:i=>xs(i,e)}],toDOM(i){return["th",Cs(i,e),0]}}}}function Te(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const i=n.nodes[t],o=i.spec.tableRole;o&&(e[o]=i)}}return e}var _e=new yn("selectingCells");function vn(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 bi(n){const 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 _o(n){const 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;const t=vn(e.$head)||fp(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function fp(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function vo(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function pp(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Ko(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function $a(n,e,t){const i=n.node(-1),o=H.get(i),r=n.start(-1),s=o.nextCell(n.pos-r,e,t);return s==null?null:n.node(0).resolve(r+s)}function Kt(n,e,t=1){const i={...n,colspan:n.colspan-t};return i.colwidth&&(i.colwidth=i.colwidth.slice(),i.colwidth.splice(e,t),i.colwidth.some(o=>o>0)||(i.colwidth=null)),i}var W=class De extends E{constructor(e,t=e){const i=e.node(-1),o=H.get(i),r=e.start(-1),s=o.rectBetween(e.pos-r,t.pos-r),l=e.node(0),a=o.cellsInRect(s).filter(d=>d!=t.pos-r);a.unshift(t.pos-r);const c=a.map(d=>{const h=i.nodeAt(d);if(!h)throw RangeError(`No cell with offset ${d} found`);const u=r+d+1;return new Kl(l.resolve(u),l.resolve(u+h.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const i=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(vo(i)&&vo(o)&&Ko(i,o)){const r=this.$anchorCell.node(-1)!=i.node(-1);return r&&this.isRowSelection()?De.rowSelection(i,o):r&&this.isColSelection()?De.colSelection(i,o):new De(i,o)}return N.between(i,o)}content(){const e=this.$anchorCell.node(-1),t=H.get(e),i=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i),r={},s=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let d=a*t.width+o.left,h=o.left;h<o.right;h++,d++){const u=t.map[d];if(r[u])continue;r[u]=!0;const f=t.findCell(u);let p=e.nodeAt(u);if(!p)throw RangeError(`No cell with offset ${u} found`);const m=o.left-f.left,g=f.right-o.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=Kt(y,0,m)),g>0&&(y=Kt(y,y.colspan-g,g)),f.left<o.left){if(p=p.type.createAndFill(y),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(f.top<o.top||f.bottom>o.bottom){const y={...p.attrs,rowspan:Math.min(f.bottom,o.bottom)-Math.max(f.top,o.top)};f.top<o.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}s.push(e.child(a).copy(w.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:s;return new C(w.from(l),1,1)}replace(e,t=C.empty){const i=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){const{$from:l,$to:a}=o[s],c=e.mapping.slice(i);e.replace(c.map(l.pos),c.map(a.pos),s?C.empty:t)}const r=E.findFrom(e.doc.resolve(e.mapping.slice(i).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,t){this.replace(e,new C(w.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),i=H.get(t),o=this.$anchorCell.start(-1),r=i.cellsInRect(i.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<r.length;s++)e(t.nodeAt(r[s]),o+r[s])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const i=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(i,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const i=e.node(-1),o=H.get(i),r=e.start(-1),s=o.findCell(e.pos-r),l=o.findCell(t.pos-r),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(r+o.map[s.left])),l.bottom<o.height&&(t=a.resolve(r+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(r+o.map[l.left])),s.bottom<o.height&&(e=a.resolve(r+o.map[o.width*(o.height-1)+s.right-1]))),new De(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=H.get(e),i=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-i),r=t.colCount(this.$headCell.pos-i);if(Math.min(o,r)>0)return!1;const s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==t.width}eq(e){return e instanceof De&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const i=e.node(-1),o=H.get(i),r=e.start(-1),s=o.findCell(e.pos-r),l=o.findCell(t.pos-r),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(r+o.map[s.top*o.width])),l.right<o.width&&(t=a.resolve(r+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(r+o.map[l.top*o.width])),s.right<o.width&&(e=a.resolve(r+o.map[o.width*(s.top+1)-1]))),new De(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new De(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,i=t){return new De(e.resolve(t),e.resolve(i))}getBookmark(){return new mp(this.$anchorCell.pos,this.$headCell.pos)}};W.prototype.visible=!1;E.jsonID("cell",W);var mp=class Wa{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Wa(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),i=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&i.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&i.index()<i.parent.childCount&&Ko(t,i)?new W(t,i):E.near(i,1)}};function gp(n){if(!(n.selection instanceof W))return null;const e=[];return n.selection.forEachCell((t,i)=>{e.push(oe.node(i,i+t.nodeSize,{class:"selectedCell"}))}),z.create(n.doc,e)}function yp({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,i=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let r=e.depth;r>=0&&!(e.before(r+1)>e.start(r));r--,i--);return t==i&&/row|table/.test(n.node(o).type.spec.tableRole)}function bp({$from:n,$to:e}){let t,i;for(let o=n.depth;o>0;o--){const r=n.node(o);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){t=r;break}}for(let o=e.depth;o>0;o--){const r=e.node(o);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){i=r;break}}return t!==i&&e.parentOffset===0}function wp(n,e,t){const i=(e||n).selection,o=(e||n).doc;let r,s;if(i instanceof O&&(s=i.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")r=W.create(o,i.from);else if(s=="row"){const l=o.resolve(i.from+1);r=W.rowSelection(l,l)}else if(!t){const l=H.get(i.node),a=i.from+1,c=a+l.map[l.width*l.height-1];r=W.create(o,a+1,c)}}else i instanceof N&&yp(i)?r=N.create(o,i.from):i instanceof N&&bp(i)&&(r=N.create(o,i.$from.start(),i.$from.end()));return r&&(e||(e=n.tr)).setSelection(r),e}var Sp=new yn("fix-tables");function _a(n,e,t,i){const o=n.childCount,r=e.childCount;e:for(let s=0,l=0;s<r;s++){const 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}i(a,t),l<o&&n.child(l).sameMarkup(a)?_a(n.child(l),a,t+1,i):a.nodesBetween(0,a.content.size,i,t+1),t+=a.nodeSize}}function vp(n,e){let t;const i=(o,r)=>{o.type.spec.tableRole=="table"&&(t=xp(n,o,r,t))};return e?e.doc!=n.doc&&_a(e.doc,n.doc,0,i):n.doc.descendants(i),t}function xp(n,e,t,i){const o=H.get(e);if(!o.problems)return i;i||(i=n.tr);const r=[];for(let a=0;a<o.height;a++)r.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const h=d.attrs;for(let u=0;u<h.rowspan;u++)r[c.row+u]+=c.n;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,Kt(h,h.colspan-c.n,c.n))}else if(c.type=="missing")r[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}}let s,l;for(let a=0;a<r.length;a++)r[a]&&(s==null&&(s=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const d=e.child(a),h=c+d.nodeSize,u=r[a];if(u>0){let f="cell";d.firstChild&&(f=d.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<u;g++){const y=Te(n.schema)[f].createAndFill();y&&p.push(y)}const m=(a==0||s==a-1)&&l==a?c+1:h-1;i.insert(i.mapping.map(m),p)}c=h}return i.setMeta(Sp,{fixTables:!0})}function Ka(n){const e=n.selection,t=_o(n),i=t.node(-1),o=t.start(-1),r=H.get(i);return{...e instanceof W?r.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):r.findCell(t.pos-o),tableStart:o,map:r,table:i}}function Cp(n){return function(e,t){if(!bi(e))return!1;if(t){const i=Te(e.schema),o=Ka(e),r=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==i.header_cell&&r.setNodeMarkup(o.tableStart+s[a],i.cell,l[a].attrs);if(r.steps.length==0)for(let a=0;a<s.length;a++)r.setNodeMarkup(o.tableStart+s[a],i.header_cell,l[a].attrs);t(r)}return!0}}function ks(n,e,t){const i=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<i.length;o++){const r=e.table.nodeAt(i[o]);if(r&&r.type!==t.header_cell)return!1}return!0}function qo(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Cp(n):function(t,i){if(!bi(t))return!1;if(i){const o=Te(t.schema),r=Ka(t),s=t.tr,l=ks("row",r,o),a=ks("column",r,o),d=(n==="column"?l:n==="row"?a:!1)?1:0,h=n=="column"?{left:0,top:d,right:1,bottom:r.map.height}:n=="row"?{left:d,top:0,right:r.map.width,bottom:1}:r,u=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;r.map.cellsInRect(h).forEach(f=>{const p=f+r.tableStart,m=s.doc.nodeAt(p);m&&s.setNodeMarkup(p,u,m.attrs)}),i(s)}return!0}}qo("row",{useDeprecatedLogic:!0});qo("column",{useDeprecatedLogic:!0});qo("cell",{useDeprecatedLogic:!0});function kp(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let i=n.index(-1)-1,o=n.before();i>=0;i--){const r=n.node(-1).child(i),s=r.lastChild;if(s)return o-1-s.nodeSize;o-=r.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let i=n.indexAfter(-1),o=n.after();i<t.childCount;i++){const r=t.child(i);if(r.childCount)return o+1;o+=r.nodeSize}}return null}function Ts(n){return function(e,t){if(!bi(e))return!1;const i=kp(_o(e),n);if(i==null)return!1;if(t){const o=e.doc.resolve(i);t(e.tr.setSelection(N.between(o,pp(o))).scrollIntoView())}return!0}}function Rn(n,e){const t=n.selection;if(!(t instanceof W))return!1;if(e){const i=n.tr,o=Te(n.schema).cell.createAndFill().content;t.forEachCell((r,s)=>{r.content.eq(o)||i.replace(i.mapping.map(s+1),i.mapping.map(s+r.nodeSize-1),new C(o,0,0))}),i.docChanged&&e(i)}return!0}function Tp(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:i}=n;for(;e.childCount==1&&(t>0&&i>0||e.child(0).type.spec.tableRole=="table");)t--,i--,e=e.child(0).content;const o=e.child(0),r=o.type.spec.tableRole,s=o.type.schema,l=[];if(r=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),h=a<e.childCount-1?0:Math.max(0,i-1);(d||h)&&(c=xo(Te(s).row,new C(c,d,h)).content),l.push(c)}else if(r=="cell"||r=="header_cell")l.push(t||i?xo(Te(s).row,new C(e,t,i)).content:e);else return null;return Mp(s,l)}function Mp(n,e){const t=[];for(let o=0;o<e.length;o++){const r=e[o];for(let s=r.childCount-1;s>=0;s--){const{rowspan:l,colspan:a}=r.child(s).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let i=0;for(let o=0;o<t.length;o++)i=Math.max(i,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(w.empty),t[o]<i){const r=Te(n).cell.createAndFill(),s=[];for(let l=t[o];l<i;l++)s.push(r);e[o]=e[o].append(w.from(s))}return{height:e.length,width:i,rows:e}}function xo(n,e){const t=n.createAndFill();return new _l(t).replace(0,t.content.size,e).doc}function Ap({width:n,height:e,rows:t},i,o){if(n!=i){const r=[],s=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=r[l]||0,h=0;d<i;h++){let u=a.child(h%a.childCount);d+u.attrs.colspan>i&&(u=u.type.createChecked(Kt(u.attrs,u.attrs.colspan,d+u.attrs.colspan-i),u.content)),c.push(u),d+=u.attrs.colspan;for(let f=1;f<u.attrs.rowspan;f++)r[l+f]=(r[l+f]||0)+u.attrs.colspan}s.push(w.from(c))}t=s,n=i}if(e!=o){const r=[];for(let s=0,l=0;s<o;s++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let h=c.child(d);s+h.attrs.rowspan>o&&(h=h.type.create({...h.attrs,rowspan:Math.max(1,o-h.attrs.rowspan)},h.content)),a.push(h)}r.push(w.from(a))}t=r,e=o}return{width:n,height:e,rows:t}}function Op(n,e,t,i,o,r,s){const l=n.doc.type.schema,a=Te(l);let c,d;if(o>e.width)for(let h=0,u=0;h<e.height;h++){const f=t.child(h);u+=f.nodeSize;const p=[];let m;f.lastChild==null||f.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(u-1+i),p)}if(r>e.height){const h=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){const g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;h.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const u=a.row.create(null,w.from(h)),f=[];for(let p=e.height;p<r;p++)f.push(u);n.insert(n.mapping.slice(s).map(i+t.nodeSize-2),f)}return!!(c||d)}function Ms(n,e,t,i,o,r,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=o;c<r;c++){const d=s*e.width+c,h=e.map[d];if(e.map[d-e.width]==h){a=!0;const u=t.nodeAt(h),{top:f,left:p}=e.findCell(h);n.setNodeMarkup(n.mapping.slice(l).map(h+i),null,{...u.attrs,rowspan:s-f}),n.insert(n.mapping.slice(l).map(e.positionAt(s,p,t)),u.type.createAndFill({...u.attrs,rowspan:f+u.attrs.rowspan-s})),c+=u.attrs.colspan-1}}return a}function As(n,e,t,i,o,r,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=o;c<r;c++){const d=c*e.width+s,h=e.map[d];if(e.map[d-1]==h){a=!0;const u=t.nodeAt(h),f=e.colCount(h),p=n.mapping.slice(l).map(h+i);n.setNodeMarkup(p,null,Kt(u.attrs,s-f,u.attrs.colspan-(s-f))),n.insert(p+u.nodeSize,u.type.createAndFill(Kt(u.attrs,0,s-f))),c+=u.attrs.rowspan-1}}return a}function Os(n,e,t,i,o){let r=t?n.doc.nodeAt(t-1):n.doc;if(!r)throw new Error("No table found");let s=H.get(r);const{top:l,left:a}=i,c=a+o.width,d=l+o.height,h=n.tr;let u=0;function f(){if(r=t?h.doc.nodeAt(t-1):h.doc,!r)throw new Error("No table found");s=H.get(r),u=h.mapping.maps.length}Op(h,s,r,t,c,d,u)&&f(),Ms(h,s,r,t,a,c,l,u)&&f(),Ms(h,s,r,t,a,c,d,u)&&f(),As(h,s,r,t,l,d,a,u)&&f(),As(h,s,r,t,l,d,c,u)&&f();for(let p=l;p<d;p++){const m=s.positionAt(p,a,r),g=s.positionAt(p,c,r);h.replace(h.mapping.slice(u).map(m+t),h.mapping.slice(u).map(g+t),new C(o.rows[p-l],0,0))}f(),h.setSelection(new W(h.doc.resolve(t+s.positionAt(l,a,r)),h.doc.resolve(t+s.positionAt(d-1,c-1,r)))),e(h)}var Ep=sa({ArrowLeft:Vn("horiz",-1),ArrowRight:Vn("horiz",1),ArrowUp:Vn("vert",-1),ArrowDown:Vn("vert",1),"Shift-ArrowLeft":Ln("horiz",-1),"Shift-ArrowRight":Ln("horiz",1),"Shift-ArrowUp":Ln("vert",-1),"Shift-ArrowDown":Ln("vert",1),Backspace:Rn,"Mod-Backspace":Rn,Delete:Rn,"Mod-Delete":Rn});function _n(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Vn(n,e){return(t,i,o)=>{if(!o)return!1;const r=t.selection;if(r instanceof W)return _n(t,i,E.near(r.$headCell,e));if(n!="horiz"&&!r.empty)return!1;const s=qa(o,n,e);if(s==null)return!1;if(n=="horiz")return _n(t,i,E.near(t.doc.resolve(r.head+e),e));{const l=t.doc.resolve(s),a=$a(l,n,e);let c;return a?c=E.near(a,1):e<0?c=E.near(t.doc.resolve(l.before(-1)),-1):c=E.near(t.doc.resolve(l.after(-1)),1),_n(t,i,c)}}}function Ln(n,e){return(t,i,o)=>{if(!o)return!1;const r=t.selection;let s;if(r instanceof W)s=r;else{const a=qa(o,n,e);if(a==null)return!1;s=new W(t.doc.resolve(a))}const l=$a(s.$headCell,n,e);return l?_n(t,i,new W(s.$anchorCell,l)):!1}}function Np(n,e){const t=n.state.doc,i=vn(t.resolve(e));return i?(n.dispatch(n.state.tr.setSelection(new W(i))),!0):!1}function Dp(n,e,t){if(!bi(n.state))return!1;let i=Tp(t);const o=n.state.selection;if(o instanceof W){i||(i={width:1,height:1,rows:[w.from(xo(Te(n.state.schema).cell,t))]});const r=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=H.get(r).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return i=Ap(i,l.right-l.left,l.bottom-l.top),Os(n.state,n.dispatch,s,l,i),!0}else if(i){const r=_o(n.state),s=r.start(-1);return Os(n.state,n.dispatch,s,H.get(r.node(-1)).findCell(r.pos-s),i),!0}else return!1}function Ip(n,e){var t;if(e.ctrlKey||e.metaKey)return;const i=Es(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof W)r(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&i&&(o=vn(n.state.selection.$anchor))!=null&&((t=ji(n,e))==null?void 0:t.pos)!=o.pos)r(o,e),e.preventDefault();else if(!i)return;function r(a,c){let d=ji(n,c);const h=_e.getState(n.state)==null;if(!d||!Ko(a,d))if(h)d=a;else return;const u=new W(a,d);if(h||!n.state.selection.eq(u)){const f=n.state.tr.setSelection(u);h&&f.setMeta(_e,a.pos),n.dispatch(f)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",l),_e.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(_e,-1))}function l(a){const c=a,d=_e.getState(n.state);let h;if(d!=null)h=n.state.doc.resolve(d);else if(Es(n,c.target)!=i&&(h=ji(n,e),!h))return s();h&&r(h,c)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",l)}function qa(n,e,t){if(!(n.state.selection instanceof N))return null;const{$head:i}=n.state.selection;for(let o=i.depth-1;o>=0;o--){const r=i.node(o);if((t<0?i.index(o):i.indexAfter(o))!=(t<0?0:r.childCount))return null;if(r.type.spec.tableRole=="cell"||r.type.spec.tableRole=="header_cell"){const l=i.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Es(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function ji(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?vn(n.state.doc.resolve(t.pos)):null}var Pp=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")),Co(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,Co(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Co(n,e,t,i,o,r){var s;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let h=0,u=0;h<d.childCount;h++){const{colspan:f,colwidth:p}=d.child(h).attrs;for(let m=0;m<f;m++,u++){const g=o==u?r:p&&p[m],y=g?g+"px":"";if(l+=g||i,g||(a=!1),c)c.style.width!=y&&(c.style.width=y),c=c.nextSibling;else{const x=document.createElement("col");x.style.width=y,e.appendChild(x)}}}for(;c;){const h=c.nextSibling;(s=c.parentNode)==null||s.removeChild(c),c=h}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var ae=new yn("tableColumnResizing");function Rp({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:i=Pp,lastColumnResizable:o=!0}={}){const r=new gn({key:ae,state:{init(s,l){var a,c;const d=(c=(a=r.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,h=Te(l.schema).table.name;return i&&d&&(d[h]=(u,f)=>new i(u,t,f)),new Vp(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{const l=ae.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{Lp(s,l,n,o)},mouseleave:s=>{zp(s)},mousedown:(s,l)=>{Bp(s,l,e,t)}},decorations:s=>{const l=ae.getState(s);if(l&&l.activeHandle>-1)return _p(s,l.activeHandle)},nodeViews:{}}});return r}var Vp=class Kn{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,i=e.getMeta(ae);if(i&&i.setHandle!=null)return new Kn(i.setHandle,!1);if(i&&i.setDragging!==void 0)return new Kn(t.activeHandle,i.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return vo(e.doc.resolve(o))||(o=-1),new Kn(o,t.dragging)}return t}};function Lp(n,e,t,i){const o=ae.getState(n.state);if(o&&!o.dragging){const r=Fp(e.target);let s=-1;if(r){const{left:l,right:a}=r.getBoundingClientRect();e.clientX-l<=t?s=Ns(n,e,"left",t):a-e.clientX<=t&&(s=Ns(n,e,"right",t))}if(s!=o.activeHandle){if(!i&&s!==-1){const l=n.state.doc.resolve(s),a=l.node(-1),c=H.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}ja(n,s)}}}function zp(n){const e=ae.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&ja(n,-1)}function Bp(n,e,t,i){var o;const r=(o=n.dom.ownerDocument.defaultView)!=null?o:window,s=ae.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const l=n.state.doc.nodeAt(s.activeHandle),a=Hp(n,s.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ae,{setDragging:{startX:e.clientX,startWidth:a}}));function c(h){r.removeEventListener("mouseup",c),r.removeEventListener("mousemove",d);const u=ae.getState(n.state);u!=null&&u.dragging&&($p(n,u.activeHandle,Ds(u.dragging,h,t)),n.dispatch(n.state.tr.setMeta(ae,{setDragging:null})))}function d(h){if(!h.which)return c(h);const u=ae.getState(n.state);if(u&&u.dragging){const f=Ds(u.dragging,h,t);Is(n,u.activeHandle,f,i)}}return Is(n,s.activeHandle,a,i),r.addEventListener("mouseup",c),r.addEventListener("mousemove",d),e.preventDefault(),!0}function Hp(n,e,{colspan:t,colwidth:i}){const o=i&&i[i.length-1];if(o)return o;const r=n.domAtPos(e);let l=r.node.childNodes[r.offset].offsetWidth,a=t;if(i)for(let c=0;c<t;c++)i[c]&&(l-=i[c],a--);return l/a}function Fp(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Ns(n,e,t,i){const o=t=="right"?-i:i,r=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!r)return-1;const{pos:s}=r,l=vn(n.state.doc.resolve(s));if(!l)return-1;if(t=="right")return l.pos;const a=H.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 Ds(n,e,t){const i=e.clientX-n.startX;return Math.max(t,n.startWidth+i)}function ja(n,e){n.dispatch(n.state.tr.setMeta(ae,{setHandle:e}))}function $p(n,e,t){const i=n.state.doc.resolve(e),o=i.node(-1),r=H.get(o),s=i.start(-1),l=r.colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<r.height;c++){const d=c*r.width+l;if(c&&r.map[d]==r.map[d-r.width])continue;const h=r.map[d],u=o.nodeAt(h).attrs,f=u.colspan==1?0:l-r.colCount(h);if(u.colwidth&&u.colwidth[f]==t)continue;const p=u.colwidth?u.colwidth.slice():Wp(u.colspan);p[f]=t,a.setNodeMarkup(s+h,null,{...u,colwidth:p})}a.docChanged&&n.dispatch(a)}function Is(n,e,t,i){const o=n.state.doc.resolve(e),r=o.node(-1),s=o.start(-1),l=H.get(r).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let a=n.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Co(r,a.firstChild,a,i,l,t)}function Wp(n){return Array(n).fill(0)}function _p(n,e){var t;const i=[],o=n.doc.resolve(e),r=o.node(-1);if(!r)return z.empty;const s=H.get(r),l=o.start(-1),a=s.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let c=0;c<s.height;c++){const d=a+c*s.width;if((a==s.width-1||s.map[d]!=s.map[d+1])&&(c==0||s.map[d]!=s.map[d-s.width])){const h=s.map[d],u=l+h+r.nodeAt(h).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(t=ae.getState(n))!=null&&t.dragging&&i.push(oe.node(l+h,l+h+r.nodeAt(h).nodeSize,{class:"column-resize-dragging"})),i.push(oe.widget(u,f))}}return z.create(n.doc,i)}function Kp({allowTableNodeSelection:n=!1}={}){return new gn({key:_e,state:{init(){return null},apply(e,t){const i=e.getMeta(_e);if(i!=null)return i==-1?null:i;if(t==null||!e.docChanged)return t;const{deleted:o,pos:r}=e.mapping.mapResult(t);return o?null:r}},props:{decorations:gp,handleDOMEvents:{mousedown:Ip},createSelectionBetween(e){return _e.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Np,handleKeyDown:Ep,handlePaste:Dp},appendTransaction(e,t,i){return wp(i,vp(i,t),n)}})}const ln=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},Ps="data-gs-mrk-fs",Rs="data-gs-ib",ai="data-gs-ifrg",Ve="attrs",Ja={[Ve]:{default:"{}"}},Ee={[Ve]:{default:{}}},Ga=n=>({[Ve]:JSON.stringify(ln(n))}),Ne=n=>({attrs:ln(n)}),Ut=n=>e=>[n,e.attrs.attrs,0],$e=n=>n.attrs[Ve]?JSON.parse(n.attrs[Ve]):{},qp={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${ai}]`,getAttrs:Ne}],toDOM:()=>["span",{[ai]:""},0]},div:{group:"block",content:"inline*",attrs:Ee,parseDOM:[{tag:"div",getAttrs:Ne}],toDOM:Ut("div")},paragraph:{group:"block",content:"inline*",attrs:Ee,parseDOM:[{tag:"p",getAttrs:Ne}],toDOM:Ut("p")},orderedList:{group:"block",content:"listItem+",attrs:Ee,parseDOM:[{tag:"ol",getAttrs:Ne}],toDOM:Ut("ol")},bulletList:{group:"block",content:"listItem+",attrs:Ee,parseDOM:[{tag:"ul",getAttrs:Ne}],toDOM:Ut("ul")},listItem:{content:"block*",group:"block",attrs:Ee,parseDOM:[{tag:"li",getAttrs:Ne}],toDOM:Ut("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:Ee,parseDOM:[{tag:"pre",getAttrs:Ne}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:Ee,parseDOM:[{tag:"img[src]",getAttrs:Ne}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${Rs}]`}],toDOM(){return["br",{[Rs]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:Ee,parseDOM:[{tag:"br",getAttrs:Ne}],toDOM:n=>["br",{...n.attrs.attrs}]},heading:{group:"block",content:"inline*",attrs:{level:{default:1},attrs:{default:{}}},defining:!0,parseDOM:Array.from({length:6},(n,e)=>({tag:`h${e+1}`,getAttrs:t=>({level:e+1,attrs:ln(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...up({tableGroup:"block",cellContent:"block+",cellAttributes:{[Ve]:{default:Ee[Ve].default,getFromDOM:ln,setDOMAttr:(n,e)=>{n&&Object.assign(e,n)}},background:{default:null,getFromDOM(n){return n.style.backgroundColor||null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`background-color: ${n};`)}}}}),nonTextNode:{group:"block",content:"block*",attrs:{tagName:{default:"span"},attrs:{default:{}}},parseDOM:[{tag:"*:not(tbody)",getAttrs:n=>({tagName:n.tagName.toLowerCase(),attrs:ln(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},Zt=(n,e)=>({attrs:Ja,parseDOM:n.map(t=>({tag:t,getAttrs:Ga})),toDOM:e}),jp={strong:Zt(["strong","b"],n=>["b",$e(n)]),link:Zt(["a"],n=>["a",$e(n),0]),em:Zt(["em","i"],n=>["em",$e(n)]),underline:Zt(["u"],n=>["u",$e(n),0]),strikethrough:Zt(["s"],n=>["s",$e(n),0]),font_size:{attrs:{...Ja,size:{default:null}},parseDOM:[{tag:`span[${Ps}]`,getAttrs:n=>({...Ga(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...$e(n),[Ps]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},Vs=new dh({nodes:qp,marks:jp}),wi=new WeakMap,jo=new WeakMap,Jp=(n,e)=>{wi.set(n,e),jo.set(e,n)},Gp=(n,e)=>{wi.delete(n),jo.delete(e)},Ji=n=>wi.get(n),Up=n=>jo.get(n),Ls=n=>{var t;const e=Up(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},Zp=n=>n.dispatchEvent(new CustomEvent("input"));function Yp(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(ai)){if(t.getAttribute("style")){t.removeAttribute(ai);return}const i=t.parentElement;if(i){for(;t.firstChild;)i.insertBefore(t.firstChild,t);i.removeChild(t)}}else Array.from(t.children).forEach(i=>e(i))};e(n)}function Xp(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,i=d=>n.getSelectedAll().includes(d),o=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),r=d=>d.isChildOf("text"),s=d=>n.getEditing()===d,l=(d,h={})=>{d.trigger("focus",h.event)},a=(d,h)=>{i(d)&&o(d)&&!s(d)&&l(d,h)},c=(d,h)=>{if(i(d)&&!o(d)&&r(d)){const u=d.parents().find(f=>f.isInstanceOf("text"));u&&(l(u,h),setTimeout(()=>n.select(u),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Qp=(n,e)=>{const t=em(n);return t&&cm(t)?tm(n,e):t?Xl(()=>({type:n.schema.nodes.div}))(n,e):!1};function em(n){const e=n.selection.$from;if(e.node(e.depth).type===n.schema.nodes.inlineFragment){const t=e.depth-1;return e.node(t)}return e.node(e.depth)}function tm(n,e){const{selection:t,schema:i,tr:o}=n;o.split(t.from,1);const r=t.from+1,s=o.doc.nodeAt(r),l={...s.attrs.attrs,id:void 0},a=s.textContent.length>0,c=s.textContent.length||0,d=s.textContent||" ",h=i.text(d),u=i.nodes.div.create(l,a?h:[],[]);return o.replaceRangeWith(r,r+c+2,u),o.setSelection(N.create(o.doc,r+1)),e==null||e(o.scrollIntoView()),!0}function nm(n,e,t){const{state:i,dispatch:o}=n,{selection:r,tr:s}=i,l=(a,c,d)=>{const h={};return a.split(";").forEach(u=>{const[f,p]=u.split(":").map(m=>m.trim());f&&(h[f]=p)}),h[c]=d,Object.entries(h).map(([u,f])=>`${u}: ${f}`).join("; ")};if(!r.empty||t)s.doc.nodesBetween(r.from,r.to,(a,c)=>{var d,h;if(a.type===i.schema.nodes.image){const u=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);s.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}else if(a.type.isBlock){const u=l(((h=a.attrs.attrs)==null?void 0:h.style)||"","text-align",e);Ua(a)?s.setBlockType(r.from,void 0,i.schema.nodes.div,{attrs:{style:u}}):s.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}});else{const a=i.doc.resolve(r.from),c=a.start(a.depth),d=i.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const h=l(d.attrs.style||"","text-align",e);s.setNodeMarkup(c,void 0,{...d.attrs,style:h})}}s.docChanged&&o(s.scrollIntoView())}const Yt=(n,e)=>{const{from:t,to:i}=n.selection;let o=!1;return n.doc.nodesBetween(t,i,r=>{if(o)return!1;r.marks.some(s=>s.type===e)&&(o=!0)}),o};function im(n,e,t="_blank"){const{state:i,dispatch:o}=n,{schema:r,selection:s,tr:l}=i,a=r.marks.link;try{const c=a.create({[Ve]:JSON.stringify({href:e,target:t})});l.addMark(s.from,s.to,c),o(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function om(n,e){const{state:t,dispatch:i}=n,{selection:o,tr:r}=t;if(o.empty)return;const s=t.schema.marks.font_size;if(!s){console.error("Font size mark is not defined in the schema.");return}r.addMark(o.from,o.to,s.create({size:e})),i(r.scrollIntoView())}const at=(n,e)=>{const{doc:t,selection:i}=n.state,o=t.resolve(i.from);for(let r=o.depth;r>0;r--){const s=o.node(r);if(e(s))return{pos:r>0?o.before(r):0,start:o.start(r),depth:r,node:s}}},rm=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,i])=>(t=t.replace(/-./g,o=>o.toUpperCase()[1]).trim(),e[t]=`${i}`.trim(),e),{});function sm(...n){return(e,t)=>{const i=s=>{e=e.apply(s),t==null||t(s)},o=n.pop();return n.reduce((s,l)=>s||l(e,i),!1)&&o!==void 0&&o(e,t)}}const lm=(n,e)=>{const{state:t,dispatch:i}=n;if(e!=null&&e.event){const{event:o}=e,r=n.posAtCoords({left:o.clientX,top:o.clientY});r!=null&&r.pos&&i(t.tr.setSelection(N.create(t.doc,r.pos)))}else Ql(t,i);setTimeout(()=>setTimeout(()=>n.focus()))},ko=n=>n.isBlock,Ua=n=>n.type.name==="inlineFragment",am=n=>ko(n)&&!Ua(n),Za=n=>n.type.name==="bulletList",Ya=n=>n.type.name==="orderedList",cm=n=>n.type.name==="heading",dm=n=>Za(n)||Ya(n),zs=(n,e)=>{var r,s;const t=(r=at(n,l=>l.type===e))==null?void 0:r.node,i=n.state.schema.nodes.listItem;let o;return t?o=lo(i):(s=at(n,dm))!=null&&s.node?o=sm(lo(i),$r(e)):o=$r(e),o(n.state,n.dispatch)},Xa=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(i=>i.type.name===e)},hm=n=>{var s;const{view:e,prop:t,editor:i,propCSS:o}=n,r=(s=at(e,am))==null?void 0:s.node;if(r){const l=r.attrs.attrs||{},a=rm(l.style);if(t in a)return a[t]||"";if(l.id){const c=i.Components.getById(l.id);return((c==null?void 0:c.getStyle())||{})[o]||""}}return""},um=n=>{const{view:e,prop:t,markName:i,editor:o,propCSS:r}=n,s=Xa(e,i);if(s){const l=s.attrs;if(l[t])return l[t];if(l[Ve]){const a=$e(s).id;if(a){const c=o.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[r]||""}}}return""},Qa=(n,e)=>{const{dispatch:t}=n,{nodes:i,marks:o}=n.state.schema;return{text:{selected:()=>{const{selection:r,doc:s}=n.state;return s.textBetween(r.from,r.to," ")},replace:(r,s={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(r));s.select&&(c=c.setSelection(N.create(c.doc,a,a+r.length))),t==null||t(c)}},bold:{toggle:()=>it(o.strong)(n.state,t),isActive:()=>Yt(n.state,o.strong)},italic:{toggle:()=>it(o.em)(n.state,t),isActive:()=>Yt(n.state,o.em)},underline:{toggle:()=>it(o.underline)(n.state,t),isActive:()=>Yt(n.state,o.underline)},strikethrough:{toggle:()=>it(o.strikethrough)(n.state,t),isActive:()=>Yt(n.state,o.strikethrough)},link:{get:()=>{const r=Ls(n);if(r!=null&&r.is("link"))return r.getAttributes();{const s=Xa(n,"link");return s?$e(s):{}}},toggle:()=>it(o.link)(n.state,t),isActive:()=>Yt(n.state,o.link),create:r=>{const s=Ls(n);s!=null&&s.is("link")?(s.addAttributes({href:r.url,target:r.target}),n.focus()):im(n,r.url,r.target)}},alignText:{get:()=>hm({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:r=>nm(n,r.value,!0)},fontSize:{get:()=>um({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:r=>om(n,r.value)},image:{open(){const r="assetLayout",{state:s,dispatch:l}=n,{selection:a,doc:c}=s,d=c.textBetween(a.from,a.to," "),h={id:r,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:u=>{const f={alt:d,src:u.asset.getSrc()};l(s.tr.replaceSelectionWith(i.image.createAndFill({attrs:f})))}}};e.runCommand(Y.layoutToggle,h)}},heading:{get:()=>{var s;const r=(s=at(n,ko))==null?void 0:s.node;return`${(r==null?void 0:r.attrs.level)||""}`},set:({value:r})=>{var a;const{state:s}=n,l=(a=at(n,ko))==null?void 0:a.node;iu(s.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:r?parseInt(r,10):0})(s,t)}},listBullet:{isActive:()=>{var r;return!!((r=at(n,Za))!=null&&r.node)},toggle:()=>zs(n,i.bulletList)},listOrdered:{isActive:()=>{var r;return!!((r=at(n,Ya))!=null&&r.node)},toggle:()=>zs(n,i.orderedList)}}},me="rte:selectionchange",he={bold:'<svg viewBox="0 0 24 24"><path d="M13.5,15.5H10V12.5H13.5A1.5,1.5 0 0,1 15,14A1.5,1.5 0 0,1 13.5,15.5M10,6.5H13A1.5,1.5 0 0,1 14.5,8A1.5,1.5 0 0,1 13,9.5H10M15.6,10.79C16.57,10.11 17.25,9 17.25,8C17.25,5.74 15.5,4 13.25,4H7V18H14.04C16.14,18 17.75,16.3 17.75,14.21C17.75,12.69 16.89,11.39 15.6,10.79Z" /></svg>',italic:'<svg viewBox="0 0 24 24"><path d="M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z" /></svg>',underline:'<svg viewBox="0 0 24 24"><path d="M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z" /></svg>',strikethrough:'<svg viewBox="0 0 24 24"><path d="M7.2 9.8c-1.2-2.3.5-5 2.9-5.5 3.1-1 7.6.4 7.5 4.2h-3l-.1-.8c-.2-.6-.6-.9-1.2-1.1-.8-.3-2.1-.2-2.8.3C9 8.2 10.4 9.5 12 10H7.4l-.2-.2M21 13v-2H3v2h9.6l.6.2c.6.3 1.1.5 1.3 1.1.1.4.2.9 0 1.3-.2.5-.6.7-1.1.9-1.8.5-4-.2-3.9-2.4h-3c-.1 2.6 2.1 4.4 4.5 4.7 3.8.8 8.3-1.6 6.3-5.9l3.7.1Z"/></svg>',link:'<svg viewBox="0 0 24 24"><path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" /></svg>',image:'<svg viewBox="0 0 24 24"><path d="M19,19H5V5H19M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M13.96,12.29L11.21,15.83L9.25,13.47L6.5,17H17.5L13.96,12.29Z"></path></svg>',listBullet:'<svg viewBox="0 0 24 24"><path d="M7 5h14v2H7V5m0 8v-2h14v2H7M4 4.5A1.5 1.5 0 0 1 5.5 6 1.5 1.5 0 0 1 4 7.5 1.5 1.5 0 0 1 2.5 6 1.5 1.5 0 0 1 4 4.5m0 6A1.5 1.5 0 0 1 5.5 12 1.5 1.5 0 0 1 4 13.5 1.5 1.5 0 0 1 2.5 12 1.5 1.5 0 0 1 4 10.5M7 19v-2h14v2H7m-3-2.5A1.5 1.5 0 0 1 5.5 18 1.5 1.5 0 0 1 4 19.5 1.5 1.5 0 0 1 2.5 18 1.5 1.5 0 0 1 4 16.5Z"/></svg>',listOrdered:'<svg viewBox="0 0 24 24"><path d="M7 13v-2h14v2H7m0 6v-2h14v2H7M7 7V5h14v2H7M3 8V5H2V4h2v4H3m-1 9v-1h3v4H2v-1h2v-.5H3v-1h1V17H2m2.3-7a.8.8 0 0 1 .7.8c0 .1 0 .3-.2.5L3 13h2v1H2v-1l2-2H2v-1h2.3Z"/></svg>',alignTextLeft:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H15V9H3V7M3,11H21V13H3V11M3,15H15V17H3V15M3,19H21V21H3V19Z" /></svg>',alignTextCenter:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M7,7H17V9H7V7M3,11H21V13H3V11M7,15H17V17H7V15M3,19H21V21H3V19Z" /></svg>',alignTextRight:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M9,7H21V9H9V7M3,11H21V13H3V11M9,15H21V17H9V15M3,19H21V21H3V19Z" /></svg>',alignTextJustify:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H21V9H3V7M3,11H21V13H3V11M3,15H21V17H3V15M3,19H21V21H3V19Z" /></svg>'},fm=(n,e)=>{var a;const{editor:t,el:i}=n,o=wi.get(i),r=Qa(o,t),s={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:he.bold,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.bold.isActive()})}},onClick:({setState:c})=>{r.bold.toggle(),c({active:r.bold.isActive()})}},italic:{id:"italic",icon:he.italic,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.italic.isActive()})}},onClick:({setState:c})=>{r.italic.toggle(),c({active:r.italic.isActive()})}},underline:{id:"underline",icon:he.underline,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.underline.isActive()})}},onClick:({setState:c})=>{r.underline.toggle(),c({active:r.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:he.strikethrough,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.strikethrough.isActive()})}},onClick:({setState:c})=>{r.strikethrough.toggle(),c({active:r.strikethrough.isActive()})}},image:{id:"image",icon:he.image,size:"s",type:"button",onClick:()=>r.image.open()},link:{id:"link",icon:he.link,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.link.isActive(),disabled:o.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:h,y:u,width:f,height:p}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(Y.layoutRemove,{id:m}),y=r.link.get(),x={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:h,y:u,w:f,h:p},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:b=>{b.preventDefault();const S=new FormData(b.currentTarget);r.link.create({url:S.get("url"),target:S.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(y==null?void 0:y.href)||"",onChange:({value:b,setState:S})=>S({value:b})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(y==null?void 0:y.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:b,setState:S})=>S({value:b})},{type:"row",style:{gap:10,justifyContent:"end"},children:[r.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{r.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(Y.layoutToggle,x)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:he.alignTextLeft},{id:"center",icon:he.alignTextCenter},{id:"right",icon:he.alignTextRight},{id:"justify",icon:he.alignTextJustify}],editorEvents:{[me]:({setState:c})=>{c({value:r.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:he.listBullet,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.listBullet.isActive()})}},onClick:({setState:c})=>{r.listBullet.toggle(),c({active:r.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:he.listOrdered,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:r.listOrdered.isActive()})}},onClick:({setState:c})=>{r.listOrdered.toggle(),c({active:r.listOrdered.isActive()})}},heading:{id:"heading",type:"selectField",size:"s",value:"",emptyState:"Heading",options:[{id:"",label:"Normal"},{id:"1",label:"Heading 1"},{id:"2",label:"Heading 2"},{id:"3",label:"Heading 3"},{id:"4",label:"Heading 4"},{id:"5",label:"Heading 5"},{id:"6",label:"Heading 6"}],editorEvents:{[me]:({setState:c})=>{c({value:r.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.heading.set({value:c}),o.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"Font size",options:[{id:"8pt",label:"8pt"},{id:"10pt",label:"10pt"},{id:"12pt",label:"12pt"},{id:"14pt",label:"14pt"},{id:"18pt",label:"18pt"},{id:"24pt",label:"24pt"},{id:"36pt",label:"36pt"}],editorEvents:{[me]:({setState:c})=>{c({value:r.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.fontSize.set({value:c}),o.focus()}}},l=[s.bold,s.italic,s.underline,s.strikethrough,s.image,s.link,s.listBullet,s.listOrdered,s.alignText,s.heading,s.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:r,layouts:s,proseMirror:{view:o},items:l}))||l};class pm{constructor(e,t,i){this.editor=i,this.node=e,this.dom=document.createElement("img"),this.view=t,Object.keys(e.attrs.attrs).forEach(o=>{this.dom.setAttribute(o,e.attrs.attrs[o])}),this.dom.addEventListener("dblclick",o=>this.handleDoubleClick(o))}handleDoubleClick(e){const{editor:t,view:i}=this;Qa(i,t).image.open(),e.preventDefault()}update(e){return e.type!==this.node.type?!1:(this.node=e,Object.keys(e.attrs.attrs).forEach(t=>{this.dom.setAttribute(t,e.attrs.attrs[t])}),!0)}selectNode(){this.dom.style.outline="2px solid #ffca6f"}deselectNode(){this.dom.style.outline=""}}class Xe{constructor(e,t,i={}){this.match=e,this.match=e,this.handler=typeof t=="string"?mm(t):t,this.undoable=i.undoable!==!1,this.inCode=i.inCode||!1}}function mm(n){return function(e,t,i,o){let r=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);r+=t[0].slice(s+t[1].length),i+=s;let l=i-o;l>0&&(r=t[0].slice(s-l,s)+r,i=o)}return e.tr.insertText(r,i,o)}}const gm=500;function ym({rules:n}){let e=new gn({state:{init(){return null},apply(t,i){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:i)}},props:{handleTextInput(t,i,o,r){return Bs(t,i,o,r,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:i}=t.state.selection;i&&Bs(t,i.pos,i.pos,"",n,e)})}}},isInputRules:!0});return e}function Bs(n,e,t,i,o,r){if(n.composing)return!1;let s=n.state,l=s.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-gm),l.parentOffset,null,"")+i;for(let c=0;c<o.length;c++){let d=o[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let h=d.match.exec(a),u=h&&d.handler(s,h,e-(h[0].length-i.length),t);if(u)return d.undoable&&u.setMeta(r,{transform:u,from:e,to:t,text:i}),n.dispatch(u),!0}return!1}const bm=new Xe(/--$/,"—"),wm=new Xe(/\.\.\.$/,"…"),Sm=new Xe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),vm=new Xe(/"$/,"”"),xm=new Xe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),Cm=new Xe(/'$/,"’"),km=[Sm,vm,xm,Cm];function Jo(n,e,t=null,i){return new Xe(n,(o,r,s,l)=>{let a=t instanceof Function?t(r):t,c=o.tr.delete(s,l),d=c.doc.resolve(s),h=d.blockRange(),u=h&&Ll(h,e,a);if(!u)return null;c.wrap(h,u);let f=c.doc.resolve(s-1).nodeBefore;return f&&f.type==e&&fi(c.doc,s-1)&&(!i||i(r,f))&&c.join(s-1),c})}function ec(n,e,t=null){return new Xe(n,(i,o,r,s)=>{let l=i.doc.resolve(r),a=t instanceof Function?t(o):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?i.tr.delete(r,s).setBlockType(r,r,e,a):null})}function Tm(n){return Jo(/^\s*>\s$/,n)}function Mm(n){return Jo(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function Am(n){return Jo(/^\s*([-+*])\s$/,n)}function Om(n){return ec(/^```$/,n)}function Em(n,e){return ec(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function Nm(n){const e=km.concat(wm,bm);let t;return(t=n.nodes.blockquote)&&e.push(Tm(t)),(t=n.nodes.orderedList)&&e.push(Mm(t)),(t=n.nodes.bulletList)&&e.push(Am(t)),(t=n.nodes.codeBlock)&&e.push(Om(t)),(t=n.nodes.heading)&&e.push(Em(t,6)),ym({rules:e})}const Dm="rteProseMirror",Im=function(n,e={}){const t={plugins:s=>s.plugins,...e},i=(s,l)=>{var p,m;const a=((p=t.schema)==null?void 0:p.call(t,{editor:n,schema:Vs}))||Vs,{nodes:c,marks:d}=a,h=Ht.fromSchema(a).parse(s),u=Nt.create({doc:h,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,plugins:[Rp(),Kp(),Nm(a),mu(),Fi({Tab:Ts(1),"Shift-Tab":Ts(-1)}),Fi({Enter:hn(Yl,Cu(c.listItem),Qp),"Shift-Enter":hn(Zl,(g,y)=>(y&&y(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":ra,"Mod-y":so,"Mod-Shift-z":so,"Mod-b":it(d.strong),"Mod-i":it(d.em),"Shift-Tab":lo(c.listItem),Tab:Mu(c.listItem)}),Fi(su)]})}),f=new rp({mount:s},{state:u,dispatchTransaction(g){var v;const{state:y}=f,x=y.apply(g),b=!y.doc.eq(x.doc);f.updateState(x);const S=!y.selection.eq(x.selection);b&&(Zp(((v=l==null?void 0:l.view)==null?void 0:v.el)||s),f.focus()),(S||b)&&n.trigger(me)}});return s.__rteView=f,f.setProps({nodeViews:{image(g){return new pm(g,f,n)}}}),f},o=s=>fm(s,t);n.setCustomRte({toolbar:o,parseContent:!0,async enable(s,l,a){const c=Ji(s);if(c)return c;const d=i(s,a);return Jp(s,d),lm(d,a),d},disable(s){const l=Ji(s);if(l)return Gp(s,l),l.destroy(),{forceSync:!0}},getContent(s){const l=Ji(s);if(l){const{schema:a,doc:c}=l.state,d=document.createElement("div"),h=wt.fromSchema(a).serializeFragment(c.content);return h.childNodes.forEach(u=>{u.nodeType===Node.ELEMENT_NODE&&u.innerHTML===""&&(u.innerHTML="<br/>")}),d.appendChild(h),Yp(d),s.classList.remove("ProseMirror-focused"),d.innerHTML}return s.innerHTML}});const r=Xp(n,t);Ae({editor:n,licenseKey:t.licenseKey,plan:ee.free,pluginName:Dm,cleanup:()=>{n.RichTextEditor.customRte=void 0,r()}})},Pm=Me(Im),Rm=n=>{const e={};for(const t of Object.keys(n)){let i=n[t];i&&(Array.isArray(i)?i=i.map(o=>o.toString()).join(","):i=i.toString(),e[t]=i)}return new URLSearchParams(e)},Vm=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:i="high"}=n,o=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=Rm(l);return`${c}?${d}`},r=l=>{var a,c,d;return((a=l[i])==null?void 0:a.url)||((c=l.high)==null?void 0:c.url)||((d=l.medium)==null?void 0:d.url)||l.default.url},s=l=>{const a=r(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:["youtube-video"],label:"YouTube Videos",search:{reloadOnInput:!0,debounceMs:1e3},async onLoad({searchValue:l,pageCustomData:a}){var m;const c={maxResults:25,q:l,pageToken:a==null?void 0:a.token,type:["video"],key:e},d=t==null?void 0:t({searchValue:l}),h={...c,...d};h.part?h.part.includes("snippet")||h.part.push("snippet"):h.part=["snippet"];const f=await(await fetch(o(h))).json();return(m=f.items)!=null&&m.length?{items:f.items.map(s),nextPageCustomData:{token:f.nextPageToken},isLastPage:!f.nextPageToken}:{items:[],isLastPage:!0}},itemLayout:({assetProps:l,onSelect:a})=>({type:"column",onClick:()=>a(l),htmlAttrs:{title:l.name},style:{border:"1px solid gray",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"custom",render:()=>{var c;return`<img src="${(c=l.customData)==null?void 0:c.thumbnailUrl}" alt="${l.name}" style="width: 100%; height: 100px; object-fit: cover">`}},{type:"text",content:l.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingLeft:8,paddingRight:8}}]})}},Lm="youtubeAssetProvider",zm=function(n,e){const{skipVideoComponent:t}=e,i=Vm(e);n.runCommand(Y.assetProviderAdd,{provider:i});const o="search-on-youtube",r="video";if(!t){const s=n.Components.getType(r).model.prototype;n.Components.addType(r,{model:{getYoutubeTraits(){const[l,...a]=s.getYoutubeTraits.apply(this);return[l,{id:o,type:"button",label:n.I18n.t("youtube.searchBtn"),command:()=>{n.AssetManager.open({select:c=>{n.Assets.close(),this.set({videoId:c.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})}},...a]}}})}Ae({editor:n,licenseKey:e.licenseKey,plan:ee.startup,pluginName:Lm,cleanup:()=>{if(n.runCommand(Y.assetProviderRemove,{id:i.id}),!t){const s=n.Components.getType(r).model.prototype;n.Components.addType(r,{model:{getYoutubeTraits(){return s.getYoutubeTraits.apply(this).filter(l=>l.id!==o)}}})}}})},Bm=Me(zm);exports.dialogComponent=gc;exports.fsLightboxComponent=fd;exports.iconifyComponent=Dc;exports.lightGalleryComponent=Cd;exports.listPagesComponent=cd;exports.rteProseMirror=Pm;exports.rteTinyMce=Jd;exports.swiperComponent=Bd;exports.tableComponent=nd;exports.youtubeAssetProvider=Bm;
128
+ `);return{dom:a,text:u,slice:e}}function Ta(n,e,t,i,o){let s=o.parent.type.spec.code,r,l;if(!t&&!e)return null;let a=e&&(i||s||!t);if(a){if(n.someProp("transformPastedText",u=>{e=u(e,s||i,n)}),s)return e?new C(w.from(n.state.schema.text(e.replace(/\r\n?/g,`
129
+ `))),0,0):C.empty;let h=n.someProp("clipboardTextParser",u=>u(e,o,i,n));if(h)l=h;else{let u=o.marks(),{schema:f}=n.state,p=wt.fromSchema(f);r=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=r.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(f.text(m,u)))})}}else n.someProp("transformPastedHTML",h=>{t=h(t,n)}),r=vf(t),wn&&Sf(r);let c=r&&r.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let h=+d[3];h>0;h--){let u=r.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;r=u}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Ht.fromSchema(n.state.schema)).parseSlice(r,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!yf.test(u.parentNode.nodeName)?{ignore:!0}:null}})),d)l=xf(dr(l,+d[1],+d[2]),d[4]);else if(l=C.maxOpen(bf(l.content,o),!0),l.openStart||l.openEnd){let h=0,u=0;for(let f=l.content.firstChild;h<l.openStart&&!f.type.spec.isolating;h++,f=f.firstChild);for(let f=l.content.lastChild;u<l.openEnd&&!f.type.spec.isolating;u++,f=f.lastChild);l=dr(l,h,u)}return n.someProp("transformPasted",h=>{l=h(l,n)}),l}const yf=/^(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 bf(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)),s,r=[];if(n.forEach(l=>{if(!r)return;let a=o.findWrapping(l.type),c;if(!a)return r=null;if(c=r.length&&s.length&&Aa(a,s,l,r[r.length-1],0))r[r.length-1]=c;else{r.length&&(r[r.length-1]=Ea(r[r.length-1],s.length));let d=Ma(l,a);r.push(d),o=o.matchType(d.type),s=a}}),r)return w.from(r)}return n}function Ma(n,e,t=0){for(let i=e.length-1;i>=t;i--)n=e[i].create(null,w.from(n));return n}function Aa(n,e,t,i,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=Aa(n,e,t,i.lastChild,o+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));if(i.contentMatchAt(i.childCount).matchType(o==n.length-1?t.type:n[o+1]))return i.copy(i.content.append(w.from(Ma(t,n,o+1))))}}function Ea(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Ea(n.lastChild,e-1)),i=n.contentMatchAt(n.childCount).fillBefore(w.empty,!0);return n.copy(t.append(i))}function yo(n,e,t,i,o,s){let r=e<0?n.firstChild:n.lastChild,l=r.content;return n.childCount>1&&(s=0),o<i-1&&(l=yo(l,e,t,i,o+1,s)),o>=t&&(l=e<0?r.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(r.contentMatchAt(r.childCount).fillBefore(w.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,r.copy(l))}function dr(n,e,t){return e<n.openStart&&(n=new C(yo(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new C(yo(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Oa={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let hr=null;function Na(){return hr||(hr=document.implementation.createHTMLDocument("title"))}let _i=null;function wf(n){let e=window.trustedTypes;return e?(_i||(_i=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),_i.createHTML(n)):n}function vf(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Na().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(n),o;if((o=i&&Oa[i[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=wf(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function Sf(n){let e=n.querySelectorAll(Y?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let i=e[t];i.childNodes.length==1&&i.textContent==" "&&i.parentNode&&i.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),i)}}function xf(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:r}=n;for(let l=i.length-2;l>=0;l-=2){let a=t.nodes[i[l]];if(!a||a.hasRequiredAttrs())break;o=w.from(a.create(i[l+1],o)),s++,r++}return new C(o,s,r)}const ne={},ie={},Cf={touchstart:!0,touchmove:!0};class kf{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Tf(n){for(let e in ne){let t=ne[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=i=>{Af(n,i)&&!Ho(n,i)&&(n.editable||!(i.type in ie))&&t(n,i)},Cf[e]?{passive:!0}:void 0)}te&&n.dom.addEventListener("input",()=>null),bo(n)}function je(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Mf(n){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 bo(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=i=>Ho(n,i))})}function Ho(n,e){return n.someProp("handleDOMEvents",t=>{let i=t[e.type];return i?i(n,e)||e.defaultPrevented:!1})}function Af(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 Ef(n,e){!Ho(n,e)&&ne[e.type]&&(n.editable||!(e.type in ie))&&ne[e.type](n,e)}ie.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Ia(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ge&&Y&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),_t&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let i=Date.now();n.input.lastIOSEnter=i,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==i&&(n.someProp("handleKeyDown",o=>o(n,ot(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",i=>i(n,t))||gf(n,t)?t.preventDefault():je(n,"key")};ie.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};ie.keypress=(n,e)=>{let t=e;if(Ia(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ue&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let i=n.state.selection;if(!(i instanceof N)||!i.$from.sameParent(i.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,i.$from.pos,i.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function yi(n){return{left:n.clientX,top:n.clientY}}function Of(n,e){let t=e.x-n.clientX,i=e.y-n.clientY;return t*t+i*i<100}function Fo(n,e,t,i,o){if(i==-1)return!1;let s=n.state.doc.resolve(i);for(let r=s.depth+1;r>0;r--)if(n.someProp(e,l=>r>s.depth?l(n,t,s.nodeAfter,s.before(r),o,!0):l(n,t,s.node(r),s.before(r),o,!1)))return!0;return!1}function zt(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let i=n.state.tr.setSelection(e);i.setMeta("pointer",!0),n.dispatch(i)}function Nf(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),i=t.nodeAfter;return i&&i.isAtom&&E.isSelectable(i)?(zt(n,new E(t)),!0):!1}function Df(n,e){if(e==-1)return!1;let t=n.state.selection,i,o;t instanceof E&&(i=t.node);let s=n.state.doc.resolve(e);for(let r=s.depth+1;r>0;r--){let l=r>s.depth?s.nodeAfter:s.node(r);if(E.isSelectable(l)){i&&t.$from.depth>0&&r>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(r);break}}return o!=null?(zt(n,E.create(n.state.doc,o)),!0):!1}function If(n,e,t,i,o){return Fo(n,"handleClickOn",e,t,i)||n.someProp("handleClick",s=>s(n,e,i))||(o?Df(n,t):Nf(n,t))}function Pf(n,e,t,i){return Fo(n,"handleDoubleClickOn",e,t,i)||n.someProp("handleDoubleClick",o=>o(n,e,i))}function Rf(n,e,t,i){return Fo(n,"handleTripleClickOn",e,t,i)||n.someProp("handleTripleClick",o=>o(n,e,i))||Vf(n,t,i)}function Vf(n,e,t){if(t.button!=0)return!1;let i=n.state.doc;if(e==-1)return i.inlineContent?(zt(n,N.create(i,0,i.content.size)),!0):!1;let o=i.resolve(e);for(let s=o.depth+1;s>0;s--){let r=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(r.inlineContent)zt(n,N.create(i,l+1,l+1+r.content.size));else if(E.isSelectable(r))zt(n,E.create(i,l));else continue;return!0}}function $o(n){return si(n)}const Da=ue?"metaKey":"ctrlKey";ne.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let i=$o(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&Of(t,n.input.lastClick)&&!t[Da]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s};let r=n.posAtCoords(yi(t));r&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Lf(n,r,t,!!i)):(s=="doubleClick"?Pf:Rf)(n,r.pos,r.inside,t)?t.preventDefault():je(n,"pointer"))};class Lf{constructor(e,t,i,o){this.view=e,this.pos=t,this.event=i,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!i[Da],this.allowDefault=i.shiftKey;let s,r;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),r=t.inside;else{let d=e.state.doc.resolve(t.pos);s=d.parent,r=d.depth?d.before():0}const l=o?null:i.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(i.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof E&&c.from<=r&&c.to>r)&&(this.mightDrag={node:s,pos:r,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&we&&!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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),je(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),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(()=>Re(this.view)),this.view.input.mouseDown=null}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(yi(e))),this.updateAllowDefault(e),this.allowDefault||!t?je(this.view,"pointer"):If(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||te&&this.mightDrag&&!this.mightDrag.node.isAtom||Y&&!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)?(zt(this.view,O.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):je(this.view,"pointer")}move(e){this.updateAllowDefault(e),je(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ne.touchstart=n=>{n.input.lastTouch=Date.now(),$o(n),je(n,"pointer")};ne.touchmove=n=>{n.input.lastTouch=Date.now(),je(n,"pointer")};ne.contextmenu=n=>$o(n);function Ia(n,e){return n.composing?!0:te&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const zf=ge?5e3:-1;ie.compositionstart=ie.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof N&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(i=>i.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),si(n,!0),n.markCursor=null;else if(si(n,!e.selection.empty),we&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let i=n.domSelectionRange();for(let o=i.focusNode,s=i.focusOffset;o&&o.nodeType==1&&s!=0;){let r=s<0?o.lastChild:o.childNodes[s-1];if(!r)break;if(r.nodeType==3){let l=n.domSelection();l&&l.collapse(r,r.nodeValue.length);break}else o=r,s=-1}}n.input.composing=!0}Pa(n,zf)};ie.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Pa(n,20))};function Pa(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>si(n),e))}function Ra(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Hf());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Bf(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Ou(e.focusNode,e.focusOffset),i=Nu(e.focusNode,e.focusOffset);if(t&&i&&t!=i){let o=i.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||i==s)return s;if(!o||!o.isText(i.nodeValue))return i;if(n.input.compositionNode==i){let r=t.pmViewDesc;if(!(!r||!r.isText(t.nodeValue)))return i}}return t||i}function Hf(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function si(n,e=!1){if(!(ge&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ra(n),e||n.docView&&n.docView.dirty){let t=zo(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Ff(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 i=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),i.removeAllRanges(),i.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const fn=se&&Je<15||_t&&Vu<604;ne.copy=ie.cut=(n,e)=>{let t=e,i=n.state.selection,o=t.type=="cut";if(i.empty)return;let s=fn?null:t.clipboardData,r=i.content(),{dom:l,text:a}=ka(n,r);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Ff(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function $f(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,i=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),i.parentNode&&i.parentNode.removeChild(i),t?pn(n,i.value,null,o,e):pn(n,i.textContent,i.innerHTML,o,e)},50)}function pn(n,e,t,i,o){let s=Ta(n,e,t,i,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||C.empty)))return!0;if(!s)return!1;let r=$f(s),l=r?n.state.tr.replaceSelectionWith(r,i):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Va(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," "):""}ie.paste=(n,e)=>{let t=e;if(n.composing&&!ge)return;let i=fn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;i&&pn(n,Va(i),i.getData("text/html"),o,t)?t.preventDefault():Wf(n,t)};class La{constructor(e,t,i){this.slice=e,this.move=t,this.node=i}}const za=ue?"altKey":"ctrlKey";ne.dragstart=(n,e)=>{let t=e,i=n.input.mouseDown;if(i&&i.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(yi(t)),r;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof E?o.to-1:o.to))){if(i&&i.mightDrag)r=E.create(n.state.doc,i.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let h=n.docView.nearestDesc(t.target,!0);h&&h.node.type.spec.draggable&&h!=n.docView&&(r=E.create(n.state.doc,h.posBefore))}}let l=(r||n.state.selection).content(),{dom:a,text:c,slice:d}=ka(n,l);(!t.dataTransfer.files.length||!Y||aa>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(fn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",fn||t.dataTransfer.setData("text/plain",c),n.dragging=new La(d,!t[za],r)};ne.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};ie.dragover=ie.dragenter=(n,e)=>e.preventDefault();ie.drop=(n,e)=>{let t=e,i=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(yi(t));if(!o)return;let s=n.state.doc.resolve(o.pos),r=i&&i.slice;r?n.someProp("transformPasted",p=>{r=p(r,n)}):r=Ta(n,Va(t.dataTransfer),fn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(i&&!t[za]);if(n.someProp("handleDrop",p=>p(n,t,r||C.empty,l))){t.preventDefault();return}if(!r)return;t.preventDefault();let a=r?Vh(n.state.doc,s.pos,r):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:p}=i;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),h=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,u=c.doc;if(h?c.replaceRangeWith(d,d,r.content.firstChild):c.replaceRange(d,d,r),c.doc.eq(u))return;let f=c.doc.resolve(d);if(h&&E.isSelectable(r.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(r.content.firstChild))c.setSelection(new E(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,x)=>p=x),c.setSelection(Bo(n,f,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};ne.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())&&Re(n)},20))};ne.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)};ne.beforeinput=(n,e)=>{if(Y&&ge&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:i}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=i||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,ot(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 ie)ne[n]=ie[n];function mn(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}class ri{constructor(e,t){this.toDOM=e,this.spec=t||ft,this.side=this.spec.side||0}map(e,t,i,o){let{pos:s,deleted:r}=e.mapResult(t.from+o,this.side<0?-1:1);return r?null:new oe(s-i,s-i,this)}valid(){return!0}eq(e){return this==e||e instanceof ri&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&mn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ue{constructor(e,t){this.attrs=e,this.spec=t||ft}map(e,t,i,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-i,r=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-i;return s>=r?null:new oe(s,r,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ue&&mn(this.attrs,e.attrs)&&mn(this.spec,e.spec)}static is(e){return e.type instanceof Ue}destroy(){}}class Wo{constructor(e,t){this.attrs=e,this.spec=t||ft}map(e,t,i,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let r=e.mapResult(t.to+o,-1);return r.deleted||r.pos<=s.pos?null:new oe(s.pos-i,r.pos-i,this)}valid(e,t){let{index:i,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(i)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof Wo&&mn(this.attrs,e.attrs)&&mn(this.spec,e.spec)}destroy(){}}class oe{constructor(e,t,i){this.from=e,this.to=t,this.type=i}copy(e,t){return new oe(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,i){return this.type.map(e,this,t,i)}static widget(e,t,i){return new oe(e,e,new ri(t,i))}static inline(e,t,i,o){return new oe(e,t,new Ue(i,o))}static node(e,t,i,o){return new oe(e,t,new Wo(i,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ue}get widget(){return this.type instanceof ri}}const Et=[],ft={};class z{constructor(e,t){this.local=e.length?e:Et,this.children=t.length?t:Et}static create(e,t){return t.length?li(t,e,0,ft):G}find(e,t,i){let o=[];return this.findInner(e??0,t??1e9,o,0,i),o}findInner(e,t,i,o,s){for(let r=0;r<this.local.length;r++){let l=this.local[r];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&i.push(l.copy(l.from+o,l.to+o))}for(let r=0;r<this.children.length;r+=3)if(this.children[r]<t&&this.children[r+1]>e){let l=this.children[r]+1;this.children[r+2].findInner(e-l,t-l,i,o+l,s)}}map(e,t,i){return this==G||e.maps.length==0?this:this.mapInner(e,t,0,0,i||ft)}mapInner(e,t,i,o,s){let r;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,i,o);a&&a.type.valid(t,a)?(r||(r=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?_f(this.children,r||[],e,t,i,o,s):r?new z(r.sort(pt),Et):G}add(e,t){return t.length?this==G?z.create(e,t):this.addInner(e,t,0):this}addInner(e,t,i){let o,s=0;e.forEach((l,a)=>{let c=a+i,d;if(d=Ha(t,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,d,c+1):o.splice(s,0,a,a+l.nodeSize,li(d,l,c+1,ft)),s+=3}});let r=Ba(s?Fa(t):t,-i);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||r.splice(l--,1);return new z(r.length?this.local.concat(r).sort(pt):this.local,o||this.children)}remove(e){return e.length==0||this==G?this:this.removeInner(e,0)}removeInner(e,t){let i=this.children,o=this.local;for(let s=0;s<i.length;s+=3){let r,l=i[s]+t,a=i[s+1]+t;for(let d=0,h;d<e.length;d++)(h=e[d])&&h.from>l&&h.to<a&&(e[d]=null,(r||(r=[])).push(h));if(!r)continue;i==this.children&&(i=this.children.slice());let c=i[s+2].removeInner(r,l+1);c!=G?i[s+2]=c:(i.splice(s,3),s-=3)}if(o.length){for(let s=0,r;s<e.length;s++)if(r=e[s])for(let l=0;l<o.length;l++)o[l].eq(r,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return i==this.children&&o==this.local?this:o.length||i.length?new z(o,i):G}forChild(e,t){if(this==G)return this;if(t.isLeaf)return z.empty;let i,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(i=this.children[l+2]);break}let s=e+1,r=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<r&&a.to>s&&a.type instanceof Ue){let c=Math.max(s,a.from)-s,d=Math.min(r,a.to)-s;c<d&&(o||(o=[])).push(a.copy(c,d))}}if(o){let l=new z(o.sort(pt),Et);return i?new We([l,i]):l}return i||G}eq(e){if(this==e)return!0;if(!(e instanceof z)||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 _o(this.localsInner(e))}localsInner(e){if(this==G)return Et;if(e.inlineContent||!this.local.some(Ue.is))return this.local;let t=[];for(let i=0;i<this.local.length;i++)this.local[i].type instanceof Ue||t.push(this.local[i]);return t}forEachSet(e){e(this)}}z.empty=new z([],[]);z.removeOverlap=_o;const G=z.empty;class We{constructor(e){this.members=e}map(e,t){const i=this.members.map(o=>o.map(e,t,ft));return We.from(i)}forChild(e,t){if(t.isLeaf)return z.empty;let i=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=G&&(s instanceof We?i=i.concat(s.members):i.push(s))}return We.from(i)}eq(e){if(!(e instanceof We)||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,i=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{i&&(t=t.slice(),i=!1);for(let r=0;r<s.length;r++)t.push(s[r])}}return t?_o(i?t:t.sort(pt)):Et}static from(e){switch(e.length){case 0:return G;case 1:return e[0];default:return new We(e.every(t=>t instanceof z)?e:e.reduce((t,i)=>t.concat(i instanceof z?i:i.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function _f(n,e,t,i,o,s,r){let l=n.slice();for(let c=0,d=s;c<t.maps.length;c++){let h=0;t.maps[c].forEach((u,f,p,m)=>{let g=m-p-(f-u);for(let b=0;b<l.length;b+=3){let x=l[b+1];if(x<0||u>x+d-h)continue;let y=l[b]+d-h;f>=y?l[b+1]=u<=y?-2:-1:u>=d&&g&&(l[b]+=g,l[b+1]+=g)}h+=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]+s),h=d-o;if(h<0||h>=i.content.size){a=!0;continue}let u=t.map(n[c+1]+s,-1),f=u-o,{index:p,offset:m}=i.content.findIndex(h),g=i.maybeChild(p);if(g&&m==h&&m+g.nodeSize==f){let b=l[c+2].mapInner(t,g,d+1,n[c]+s+1,r);b!=G?(l[c]=h,l[c+1]=f,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Kf(l,n,e,t,o,s,r),d=li(c,i,0,r);e=d.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,u=0;h<d.children.length;h+=3){let f=d.children[h];for(;u<l.length&&l[u]<f;)u+=3;l.splice(u,0,d.children[h],d.children[h+1],d.children[h+2])}}return new z(e.sort(pt),l)}function Ba(n,e){if(!e||!n.length)return n;let t=[];for(let i=0;i<n.length;i++){let o=n[i];t.push(new oe(o.from+e,o.to+e,o.type))}return t}function Kf(n,e,t,i,o,s,r){function l(a,c){for(let d=0;d<a.local.length;d++){let h=a.local[d].map(i,o,c);h?t.push(h):r.onRemove&&r.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]+s+1);return t}function Ha(n,e,t){if(e.isLeaf)return null;let i=t+e.nodeSize,o=null;for(let s=0,r;s<n.length;s++)(r=n[s])&&r.from>t&&r.to<i&&((o||(o=[])).push(r),n[s]=null);return o}function Fa(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function li(n,e,t,i){let o=[],s=!1;e.forEach((l,a)=>{let c=Ha(n,l,a+t);if(c){s=!0;let d=li(c,l,t+a+1,i);d!=G&&o.push(a,a+l.nodeSize,d)}});let r=Ba(s?Fa(n):n,-t).sort(pt);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||(i.onRemove&&i.onRemove(r[l].spec),r.splice(l--,1));return r.length||o.length?new z(r,o):G}function pt(n,e){return n.from-e.from||n.to-e.to}function _o(n){let e=n;for(let t=0;t<e.length-1;t++){let i=e[t];if(i.from!=i.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==i.from){s.to!=i.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,i.to),ur(e,o+1,s.copy(i.to,s.to)));continue}else{s.from<i.to&&(e==n&&(e=n.slice()),e[t]=i.copy(i.from,s.from),ur(e,o,i.copy(s.from,i.to)));break}}}return e}function ur(n,e,t){for(;e<n.length&&pt(t,n[e])>0;)e++;n.splice(e,0,t)}function Ki(n){let e=[];return n.someProp("decorations",t=>{let i=t(n.state);i&&i!=G&&e.push(i)}),n.cursorWrapper&&e.push(z.create(n.state.doc,[n.cursorWrapper.deco])),We.from(e)}const qf={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},jf=se&&Je<=11;class Jf{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Gf{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Jf,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(i=>{for(let o=0;o<i.length;o++)this.queue.push(i[o]);se&&Je<=11&&i.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),jf&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.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,qf)),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(or(this.view)){if(this.suppressingSelectionUpdates)return Re(this.view);if(se&&Je<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&yt(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,i;for(let s=e.focusNode;s;s=un(s))t.add(s);for(let s=e.anchorNode;s;s=un(s))if(t.has(s)){i=s;break}let o=i&&this.view.docView.nearestDesc(i);if(o&&o.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i}))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 i=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&or(e)&&!this.ignoreSelectionChange(i),s=-1,r=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let h=this.registerMutation(t[d],a);h&&(s=s<0?h.from:Math.min(h.from,s),r=r<0?h.to:Math.max(h.to,r),h.typeOver&&(l=!0))}if(we&&a.length){let d=a.filter(h=>h.nodeName=="BR");if(d.length==2){let[h,u]=d;h.parentNode&&h.parentNode.parentNode==u.parentNode?u.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let u of d){let f=u.parentNode;f&&f.nodeName=="LI"&&(!h||Yf(e,h)!=f)&&u.remove()}}}let c=null;s<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&mi(i)&&(c=zo(e))&&c.eq(O.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Re(e),this.currentSelection.set(i),e.scrollToSelection()):(s>-1||o)&&(s>-1&&(e.docView.markDirty(s,r),Uf(e)),this.handleDOMChange(s,r,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(i)||Re(e),this.currentSelection.set(i))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let i=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(i==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!i||i.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let h=e.addedNodes[d];t.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(e.target))return{from:i.posBefore,to:i.posAfter};let o=e.previousSibling,s=e.nextSibling;if(se&&Je<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:h,nextSibling:u}=e.addedNodes[d];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(o=h),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u)}let r=o&&o.parentNode==e.target?q(o)+1:0,l=i.localPosFromDOM(e.target,r,-1),a=s&&s.parentNode==e.target?q(s):e.target.childNodes.length,c=i.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}:(this.lastChangedTextNode=e.target,{from:i.posAtStart,to:i.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let fr=new WeakMap,pr=!1;function Uf(n){if(!fr.has(n)&&(fr.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=we,pr)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."),pr=!0}}function mr(n,e){let t=e.startContainer,i=e.startOffset,o=e.endContainer,s=e.endOffset,r=n.domAtPos(n.state.selection.anchor);return yt(r.node,r.offset,o,s)&&([t,i,o,s]=[o,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:o,focusOffset:s}}function Zf(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return mr(n,o)}let t;function i(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",i,!0),t?mr(n,t):null}function Yf(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let i=n.docView.nearestDesc(t,!0);if(i&&i.node.isBlock)return t}return null}function Xf(n,e,t){let{node:i,fromOffset:o,toOffset:s,from:r,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],mi(a)||c.push({node:a.focusNode,offset:a.focusOffset})),Y&&n.input.lastKeyCode===8)for(let g=s;g>o;g--){let b=i.childNodes[g-1],x=b.pmViewDesc;if(b.nodeName=="BR"&&!x){s=g;break}if(!x||x.size)break}let h=n.state.doc,u=n.someProp("domParser")||Ht.fromSchema(n.state.schema),f=h.resolve(r),p=null,m=u.parse(i,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:o,to:s,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Qf,context:f});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),p={anchor:g+r,head:b+r}}return{doc:m,sel:p,from:r,to:l}}function Qf(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(te&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||te&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const ep=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function tp(n,e,t,i,o){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let M=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,P=zo(n,M);if(P&&!n.state.selection.eq(P)){if(Y&&ge&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",L=>L(n,ot(13,"Enter"))))return;let R=n.state.tr.setSelection(P);M=="pointer"?R.setMeta("pointer",!0):M=="key"&&R.scrollIntoView(),s&&R.setMeta("composition",s),n.dispatch(R)}return}let r=n.state.doc.resolve(e),l=r.sharedDepth(t);e=r.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Xf(n,e,t),d=n.state.doc,h=d.slice(c.from,c.to),u,f;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,f="end"):(u=n.state.selection.from,f="start"),n.input.lastKeyCode=null;let p=op(h.content,c.doc.content,c.from,u,f);if(p&&n.input.domChangeCount++,(_t&&n.input.lastIOSEnter>Date.now()-225||ge)&&o.some(M=>M.nodeType==1&&!ep.test(M.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",M=>M(n,ot(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(i&&a instanceof N&&!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 M=gr(n,n.state.doc,c.sel);if(M&&!M.eq(n.state.selection)){let P=n.state.tr.setSelection(M);s&&P.setMeta("composition",s),n.dispatch(P)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof N&&(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)),se&&Je<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),b=d.resolve(p.start),x=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=p.endA,y;if((_t&&n.input.lastIOSEnter>Date.now()-225&&(!x||o.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!x&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(y=O.findFrom(c.doc.resolve(m.pos+1),1,!0))&&y.head==g.pos)&&n.someProp("handleKeyDown",M=>M(n,ot(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&ip(d,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",M=>M(n,ot(8,"Backspace")))){ge&&Y&&n.domObserver.suppressSelectionUpdates();return}Y&&ge&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),ge&&!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(M){return M(n,ot(13,"Enter"))})},20));let v=p.start,S=p.endA,k,T,V;if(x){if(m.pos==g.pos)se&&Je<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Re(n),20)),k=n.state.tr.delete(v,S),T=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(V=np(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start()))))k=n.state.tr,V.type=="add"?k.addMark(v,S,V.mark):k.removeMark(v,S,V.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let M=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",P=>P(n,v,S,M)))return;k=n.state.tr.insertText(M,v,S)}}if(k||(k=n.state.tr.replace(v,S,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let M=gr(n,k.doc,c.sel);M&&!(Y&&ge&&n.composing&&M.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(M.head==v||M.head==k.mapping.map(S)-1)||se&&M.empty&&M.head==v)&&k.setSelection(M)}T&&k.ensureMarks(T),s&&k.setMeta("composition",s),n.dispatch(k.scrollIntoView())}function gr(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Bo(n,e.resolve(t.anchor),e.resolve(t.head))}function np(n,e){let t=n.firstChild.marks,i=e.firstChild.marks,o=t,s=i,r,l,a;for(let d=0;d<i.length;d++)o=i[d].removeFromSet(o);for(let d=0;d<t.length;d++)s=t[d].removeFromSet(s);if(o.length==1&&s.length==0)l=o[0],r="add",a=d=>d.mark(l.addToSet(d.marks));else if(o.length==0&&s.length==1)l=s[0],r="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(w.from(c).eq(n))return{mark:l,type:r}}function ip(n,e,t,i,o){if(t-e<=o.pos-i.pos||qi(i,!0,!1)<o.pos)return!1;let s=n.resolve(e);if(!i.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let r=n.resolve(qi(s,!0,!0));return!r.parent.isTextblock||r.pos>t||qi(r,!0,!1)<t?!1:i.parent.content.cut(i.parentOffset).eq(r.parent.content)}function qi(n,e,t){let i=n.depth,o=e?n.end():n.pos;for(;i>0&&(e||n.indexAfter(i)==n.node(i).childCount);)i--,o++,e=!1;if(t){let s=n.node(i).maybeChild(n.indexAfter(i));for(;s&&!s.isLeaf;)s=s.firstChild,o++}return o}function op(n,e,t,i,o){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:r,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,s-Math.min(r,l));i-=r+a-s}if(r<s&&n.size<e.size){let a=i<=s&&i>=r?s-i:0;s-=a,s&&s<e.size&&yr(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-r),r=s}else if(l<s){let a=i<=s&&i>=l?s-i:0;s-=a,s&&s<n.size&&yr(n.textBetween(s-1,s+1))&&(s+=a?1:-1),r=s+(r-l),l=s}return{start:s,endA:r,endB:l}}function yr(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class sp{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 kf,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(xr),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=vr(this),wr(this),this.nodeViews=Sr(this),this.docView=Xs(this.state.doc,br(this),Ki(this),this.dom,this),this.domObserver=new Gf(this,(i,o,s,r)=>tp(this,i,o,s,r)),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&&bo(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(xr),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let i in this._props)t[i]=this._props[i];t.state=this.state;for(let i in e)t[i]=e[i];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var i;let o=this.state,s=!1,r=!1;e.storedMarks&&this.composing&&(Ra(this),r=!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 f=Sr(this);lp(f,this.nodeViews)&&(this.nodeViews=f,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&bo(this),this.editable=vr(this),wr(this);let a=Ki(this),c=br(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,c,a);(h||!e.selection.eq(o.selection))&&(r=!0);let u=d=="preserve"&&r&&this.dom.style.overflowAnchor==null&&Bu(this);if(r){this.domObserver.stop();let f=h&&(se||Y)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&rp(o.selection,e.selection);if(h){let p=Y?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Bf(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Xs(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&cf(this))?Re(this,f):(Sa(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((i=this.dragging)===null||i===void 0)&&i.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():u&&Hu(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof E){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&js(this,t.getBoundingClientRect(),e)}else js(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 i=this.directPlugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let i=this.state.plugins[t];i.spec.view&&this.pluginViews.push(i.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let i=this.pluginViews[t];i.update&&i.update(this,e)}}updateDraggedNode(e,t){let i=e.node,o=-1;if(this.state.doc.nodeAt(i.from)==i.node)o=i.from;else{let s=i.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==i.node&&(o=s)}this.dragging=new La(e.slice,e.move,o<0?void 0:E.create(this.state.doc,o))}someProp(e,t){let i=this._props&&this._props[e],o;if(i!=null&&(o=t?t(i):i))return o;for(let r=0;r<this.directPlugins.length;r++){let l=this.directPlugins[r].props[e];if(l!=null&&(o=t?t(l):l))return o}let s=this.state.plugins;if(s)for(let r=0;r<s.length;r++){let l=s[r].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(se){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&&Fu(this.dom),Re(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 qu(this,e)}coordsAtPos(e,t=1){return fa(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,i=-1){let o=this.docView.posFromDOM(e,t,i);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Zu(this,t||this.state,e)}pasteHTML(e,t){return pn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return pn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Mf(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ki(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Au())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ef(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?te&&this.root.nodeType===11&&Iu(this.dom.ownerDocument)==this.dom&&Zf(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function br(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 i in t)i=="class"?e.class+=" "+t[i]:i=="style"?e.style=(e.style?e.style+";":"")+t[i]:!e[i]&&i!="contenteditable"&&i!="nodeName"&&(e[i]=String(t[i]))}),e.translate||(e.translate="no"),[oe.node(0,n.state.doc.content.size,e)]}function wr(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:oe.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function vr(n){return!n.someProp("editable",e=>e(n.state)===!1)}function rp(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 Sr(n){let e=Object.create(null);function t(i){for(let o in i)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=i[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function lp(n,e){let t=0,i=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)i++;return t!=i}function xr(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 wo,vo;if(typeof WeakMap<"u"){let n=new WeakMap;wo=e=>n.get(e),vo=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;wo=i=>{for(let o=0;o<n.length;o+=2)if(n[o]==i)return n[o+1]},vo=(i,o)=>(t==10&&(t=0),n[t++]=i,n[t++]=o)}var H=class{constructor(n,e,t,i){this.width=n,this.height=e,this.map=t,this.problems=i}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const i=e%this.width,o=e/this.width|0;let s=i+1,r=o+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;r<this.height&&this.map[e+this.width*l]==t;l++)r++;return{left:i,top:o,right:s,bottom:r}}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){const{left:i,right:o,top:s,bottom:r}=this.findCell(n);return e=="horiz"?(t<0?i==0:o==this.width)?null:this.map[s*this.width+(t<0?i-1:o)]:(t<0?s==0:r==this.height)?null:this.map[i+this.width*(t<0?s-1:r)]}rectBetween(n,e){const{left:t,right:i,top:o,bottom:s}=this.findCell(n),{left:r,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,r),top:Math.min(o,a),right:Math.max(i,l),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let i=n.top;i<n.bottom;i++)for(let o=n.left;o<n.right;o++){const s=i*this.width+o,r=this.map[s];t[r]||(t[r]=!0,!(o==n.left&&o&&this.map[s-1]==r||i==n.top&&i&&this.map[s-this.width]==r)&&e.push(r))}return e}positionAt(n,e,t){for(let i=0,o=0;;i++){const s=o+t.child(i).nodeSize;if(i==n){let r=e+n*this.width;const l=(n+1)*this.width;for(;r<l&&this.map[r]<o;)r++;return r==l?s-1:this.map[r]}o=s}}static get(n){return wo(n)||vo(n,ap(n))}};function ap(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=cp(n),t=n.childCount,i=[];let o=0,s=null;const r=[];for(let c=0,d=e*t;c<d;c++)i[c]=0;for(let c=0,d=0;c<t;c++){const h=n.child(c);d++;for(let p=0;;p++){for(;o<i.length&&i[o]!=0;)o++;if(p==h.childCount)break;const m=h.child(p),{colspan:g,rowspan:b,colwidth:x}=m.attrs;for(let y=0;y<b;y++){if(y+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:d,n:b-y});break}const v=o+y*e;for(let S=0;S<g;S++){i[v+S]==0?i[v+S]=d:(s||(s=[])).push({type:"collision",row:c,pos:d,n:g-S});const k=x&&x[S];if(k){const T=(v+S)%e*2,V=r[T];V==null||V!=k&&r[T+1]==1?(r[T]=k,r[T+1]=1):V==k&&r[T+1]++}}}o+=g,d+=m.nodeSize}const u=(c+1)*e;let f=0;for(;o<u;)i[o++]==0&&f++;f&&(s||(s=[])).push({type:"missing",row:c,n:f}),d++}const l=new H(e,t,i,s);let a=!1;for(let c=0;!a&&c<r.length;c+=2)r[c]!=null&&r[c+1]<t&&(a=!0);return a&&dp(l,r,n),l}function cp(n){let e=-1,t=!1;for(let i=0;i<n.childCount;i++){const o=n.child(i);let s=0;if(t)for(let r=0;r<i;r++){const l=n.child(r);for(let a=0;a<l.childCount;a++){const c=l.child(a);r+c.attrs.rowspan>i&&(s+=c.attrs.colspan)}}for(let r=0;r<o.childCount;r++){const l=o.child(r);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function dp(n,e,t){n.problems||(n.problems=[]);const i={};for(let o=0;o<n.map.length;o++){const s=n.map[o];if(i[s])continue;i[s]=!0;const r=t.nodeAt(s);if(!r)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=r.attrs;for(let c=0;c<a.colspan;c++){const d=(o+c)%n.width,h=e[d*2];h!=null&&(!a.colwidth||a.colwidth[c]!=h)&&((l||(l=hp(a)))[c]=h)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function hp(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Cr(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),i=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(r=>Number(r)):null,o=Number(n.getAttribute("colspan")||1),s={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:i&&i.length==o?i:null};for(const r in e){const l=e[r].getFromDOM,a=l&&l(n);a!=null&&(s[r]=a)}return s}function kr(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const i in e){const o=e[i].setDOMAttr;o&&o(n.attrs[i],t)}return t}function up(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const i in e)t[i]={default:e[i].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:i=>Cr(i,e)}],toDOM(i){return["td",kr(i,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:i=>Cr(i,e)}],toDOM(i){return["th",kr(i,e),0]}}}}function Ae(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const i=n.nodes[t],o=i.spec.tableRole;o&&(e[o]=i)}}return e}var _e=new yn("selectingCells");function Sn(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 bi(n){const 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 Ko(n){const 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;const t=Sn(e.$head)||fp(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function fp(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function So(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function pp(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function qo(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function $a(n,e,t){const i=n.node(-1),o=H.get(i),s=n.start(-1),r=o.nextCell(n.pos-s,e,t);return r==null?null:n.node(0).resolve(s+r)}function Kt(n,e,t=1){const i={...n,colspan:n.colspan-t};return i.colwidth&&(i.colwidth=i.colwidth.slice(),i.colwidth.splice(e,t),i.colwidth.some(o=>o>0)||(i.colwidth=null)),i}var W=class De extends O{constructor(e,t=e){const i=e.node(-1),o=H.get(i),s=e.start(-1),r=o.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=o.cellsInRect(r).filter(d=>d!=t.pos-s);a.unshift(t.pos-s);const c=a.map(d=>{const h=i.nodeAt(d);if(!h)throw RangeError(`No cell with offset ${d} found`);const u=s+d+1;return new Kl(l.resolve(u),l.resolve(u+h.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const i=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(So(i)&&So(o)&&qo(i,o)){const s=this.$anchorCell.node(-1)!=i.node(-1);return s&&this.isRowSelection()?De.rowSelection(i,o):s&&this.isColSelection()?De.colSelection(i,o):new De(i,o)}return N.between(i,o)}content(){const e=this.$anchorCell.node(-1),t=H.get(e),i=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i),s={},r=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let d=a*t.width+o.left,h=o.left;h<o.right;h++,d++){const u=t.map[d];if(s[u])continue;s[u]=!0;const f=t.findCell(u);let p=e.nodeAt(u);if(!p)throw RangeError(`No cell with offset ${u} found`);const m=o.left-f.left,g=f.right-o.right;if(m>0||g>0){let b=p.attrs;if(m>0&&(b=Kt(b,0,m)),g>0&&(b=Kt(b,b.colspan-g,g)),f.left<o.left){if(p=p.type.createAndFill(b),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(f.top<o.top||f.bottom>o.bottom){const b={...p.attrs,rowspan:Math.min(f.bottom,o.bottom)-Math.max(f.top,o.top)};f.top<o.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}r.push(e.child(a).copy(w.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:r;return new C(w.from(l),1,1)}replace(e,t=C.empty){const i=e.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){const{$from:l,$to:a}=o[r],c=e.mapping.slice(i);e.replace(c.map(l.pos),c.map(a.pos),r?C.empty:t)}const s=O.findFrom(e.doc.resolve(e.mapping.slice(i).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new C(w.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),i=H.get(t),o=this.$anchorCell.start(-1),s=i.cellsInRect(i.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let r=0;r<s.length;r++)e(t.nodeAt(s[r]),o+s[r])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const i=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(i,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const i=e.node(-1),o=H.get(i),s=e.start(-1),r=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return r.top<=l.top?(r.top>0&&(e=a.resolve(s+o.map[r.left])),l.bottom<o.height&&(t=a.resolve(s+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(s+o.map[l.left])),r.bottom<o.height&&(e=a.resolve(s+o.map[o.width*(o.height-1)+r.right-1]))),new De(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=H.get(e),i=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-i),s=t.colCount(this.$headCell.pos-i);if(Math.min(o,s)>0)return!1;const r=o+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(r,l)==t.width}eq(e){return e instanceof De&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const i=e.node(-1),o=H.get(i),s=e.start(-1),r=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return r.left<=l.left?(r.left>0&&(e=a.resolve(s+o.map[r.top*o.width])),l.right<o.width&&(t=a.resolve(s+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(s+o.map[l.top*o.width])),r.right<o.width&&(e=a.resolve(s+o.map[o.width*(r.top+1)-1]))),new De(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new De(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,i=t){return new De(e.resolve(t),e.resolve(i))}getBookmark(){return new mp(this.$anchorCell.pos,this.$headCell.pos)}};W.prototype.visible=!1;O.jsonID("cell",W);var mp=class Wa{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Wa(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),i=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&i.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&i.index()<i.parent.childCount&&qo(t,i)?new W(t,i):O.near(i,1)}};function gp(n){if(!(n.selection instanceof W))return null;const e=[];return n.selection.forEachCell((t,i)=>{e.push(oe.node(i,i+t.nodeSize,{class:"selectedCell"}))}),z.create(n.doc,e)}function yp({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,i=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,i--);return t==i&&/row|table/.test(n.node(o).type.spec.tableRole)}function bp({$from:n,$to:e}){let t,i;for(let o=n.depth;o>0;o--){const s=n.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let o=e.depth;o>0;o--){const s=e.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){i=s;break}}return t!==i&&e.parentOffset===0}function wp(n,e,t){const i=(e||n).selection,o=(e||n).doc;let s,r;if(i instanceof E&&(r=i.node.type.spec.tableRole)){if(r=="cell"||r=="header_cell")s=W.create(o,i.from);else if(r=="row"){const l=o.resolve(i.from+1);s=W.rowSelection(l,l)}else if(!t){const l=H.get(i.node),a=i.from+1,c=a+l.map[l.width*l.height-1];s=W.create(o,a+1,c)}}else i instanceof N&&yp(i)?s=N.create(o,i.from):i instanceof N&&bp(i)&&(s=N.create(o,i.$from.start(),i.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var vp=new yn("fix-tables");function _a(n,e,t,i){const o=n.childCount,s=e.childCount;e:for(let r=0,l=0;r<s;r++){const a=e.child(r);for(let c=l,d=Math.min(o,r+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}i(a,t),l<o&&n.child(l).sameMarkup(a)?_a(n.child(l),a,t+1,i):a.nodesBetween(0,a.content.size,i,t+1),t+=a.nodeSize}}function Sp(n,e){let t;const i=(o,s)=>{o.type.spec.tableRole=="table"&&(t=xp(n,o,s,t))};return e?e.doc!=n.doc&&_a(e.doc,n.doc,0,i):n.doc.descendants(i),t}function xp(n,e,t,i){const o=H.get(e);if(!o.problems)return i;i||(i=n.tr);const s=[];for(let a=0;a<o.height;a++)s.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const h=d.attrs;for(let u=0;u<h.rowspan;u++)s[c.row+u]+=c.n;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,Kt(h,h.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;i.setNodeMarkup(i.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}}let r,l;for(let a=0;a<s.length;a++)s[a]&&(r==null&&(r=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const d=e.child(a),h=c+d.nodeSize,u=s[a];if(u>0){let f="cell";d.firstChild&&(f=d.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<u;g++){const b=Ae(n.schema)[f].createAndFill();b&&p.push(b)}const m=(a==0||r==a-1)&&l==a?c+1:h-1;i.insert(i.mapping.map(m),p)}c=h}return i.setMeta(vp,{fixTables:!0})}function Ka(n){const e=n.selection,t=Ko(n),i=t.node(-1),o=t.start(-1),s=H.get(i);return{...e instanceof W?s.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):s.findCell(t.pos-o),tableStart:o,map:s,table:i}}function Cp(n){return function(e,t){if(!bi(e))return!1;if(t){const i=Ae(e.schema),o=Ka(e),s=e.tr,r=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=r.map(a=>o.table.nodeAt(a));for(let a=0;a<r.length;a++)l[a].type==i.header_cell&&s.setNodeMarkup(o.tableStart+r[a],i.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<r.length;a++)s.setNodeMarkup(o.tableStart+r[a],i.header_cell,l[a].attrs);t(s)}return!0}}function Tr(n,e,t){const i=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<i.length;o++){const s=e.table.nodeAt(i[o]);if(s&&s.type!==t.header_cell)return!1}return!0}function jo(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Cp(n):function(t,i){if(!bi(t))return!1;if(i){const o=Ae(t.schema),s=Ka(t),r=t.tr,l=Tr("row",s,o),a=Tr("column",s,o),d=(n==="column"?l:n==="row"?a:!1)?1:0,h=n=="column"?{left:0,top:d,right:1,bottom:s.map.height}:n=="row"?{left:d,top:0,right:s.map.width,bottom:1}:s,u=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;s.map.cellsInRect(h).forEach(f=>{const p=f+s.tableStart,m=r.doc.nodeAt(p);m&&r.setNodeMarkup(p,u,m.attrs)}),i(r)}return!0}}jo("row",{useDeprecatedLogic:!0});jo("column",{useDeprecatedLogic:!0});jo("cell",{useDeprecatedLogic:!0});function kp(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let i=n.index(-1)-1,o=n.before();i>=0;i--){const s=n.node(-1).child(i),r=s.lastChild;if(r)return o-1-r.nodeSize;o-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let i=n.indexAfter(-1),o=n.after();i<t.childCount;i++){const s=t.child(i);if(s.childCount)return o+1;o+=s.nodeSize}}return null}function Mr(n){return function(e,t){if(!bi(e))return!1;const i=kp(Ko(e),n);if(i==null)return!1;if(t){const o=e.doc.resolve(i);t(e.tr.setSelection(N.between(o,pp(o))).scrollIntoView())}return!0}}function Rn(n,e){const t=n.selection;if(!(t instanceof W))return!1;if(e){const i=n.tr,o=Ae(n.schema).cell.createAndFill().content;t.forEachCell((s,r)=>{s.content.eq(o)||i.replace(i.mapping.map(r+1),i.mapping.map(r+s.nodeSize-1),new C(o,0,0))}),i.docChanged&&e(i)}return!0}function Tp(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:i}=n;for(;e.childCount==1&&(t>0&&i>0||e.child(0).type.spec.tableRole=="table");)t--,i--,e=e.child(0).content;const o=e.child(0),s=o.type.spec.tableRole,r=o.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),h=a<e.childCount-1?0:Math.max(0,i-1);(d||h)&&(c=xo(Ae(r).row,new C(c,d,h)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||i?xo(Ae(r).row,new C(e,t,i)).content:e);else return null;return Mp(r,l)}function Mp(n,e){const t=[];for(let o=0;o<e.length;o++){const s=e[o];for(let r=s.childCount-1;r>=0;r--){const{rowspan:l,colspan:a}=s.child(r).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let i=0;for(let o=0;o<t.length;o++)i=Math.max(i,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(w.empty),t[o]<i){const s=Ae(n).cell.createAndFill(),r=[];for(let l=t[o];l<i;l++)r.push(s);e[o]=e[o].append(w.from(r))}return{height:e.length,width:i,rows:e}}function xo(n,e){const t=n.createAndFill();return new _l(t).replace(0,t.content.size,e).doc}function Ap({width:n,height:e,rows:t},i,o){if(n!=i){const s=[],r=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=s[l]||0,h=0;d<i;h++){let u=a.child(h%a.childCount);d+u.attrs.colspan>i&&(u=u.type.createChecked(Kt(u.attrs,u.attrs.colspan,d+u.attrs.colspan-i),u.content)),c.push(u),d+=u.attrs.colspan;for(let f=1;f<u.attrs.rowspan;f++)s[l+f]=(s[l+f]||0)+u.attrs.colspan}r.push(w.from(c))}t=r,n=i}if(e!=o){const s=[];for(let r=0,l=0;r<o;r++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let h=c.child(d);r+h.attrs.rowspan>o&&(h=h.type.create({...h.attrs,rowspan:Math.max(1,o-h.attrs.rowspan)},h.content)),a.push(h)}s.push(w.from(a))}t=s,e=o}return{width:n,height:e,rows:t}}function Ep(n,e,t,i,o,s,r){const l=n.doc.type.schema,a=Ae(l);let c,d;if(o>e.width)for(let h=0,u=0;h<e.height;h++){const f=t.child(h);u+=f.nodeSize;const p=[];let m;f.lastChild==null||f.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(r).map(u-1+i),p)}if(s>e.height){const h=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){const g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;h.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const u=a.row.create(null,w.from(h)),f=[];for(let p=e.height;p<s;p++)f.push(u);n.insert(n.mapping.slice(r).map(i+t.nodeSize-2),f)}return!!(c||d)}function Ar(n,e,t,i,o,s,r,l){if(r==0||r==e.height)return!1;let a=!1;for(let c=o;c<s;c++){const d=r*e.width+c,h=e.map[d];if(e.map[d-e.width]==h){a=!0;const u=t.nodeAt(h),{top:f,left:p}=e.findCell(h);n.setNodeMarkup(n.mapping.slice(l).map(h+i),null,{...u.attrs,rowspan:r-f}),n.insert(n.mapping.slice(l).map(e.positionAt(r,p,t)),u.type.createAndFill({...u.attrs,rowspan:f+u.attrs.rowspan-r})),c+=u.attrs.colspan-1}}return a}function Er(n,e,t,i,o,s,r,l){if(r==0||r==e.width)return!1;let a=!1;for(let c=o;c<s;c++){const d=c*e.width+r,h=e.map[d];if(e.map[d-1]==h){a=!0;const u=t.nodeAt(h),f=e.colCount(h),p=n.mapping.slice(l).map(h+i);n.setNodeMarkup(p,null,Kt(u.attrs,r-f,u.attrs.colspan-(r-f))),n.insert(p+u.nodeSize,u.type.createAndFill(Kt(u.attrs,0,r-f))),c+=u.attrs.rowspan-1}}return a}function Or(n,e,t,i,o){let s=t?n.doc.nodeAt(t-1):n.doc;if(!s)throw new Error("No table found");let r=H.get(s);const{top:l,left:a}=i,c=a+o.width,d=l+o.height,h=n.tr;let u=0;function f(){if(s=t?h.doc.nodeAt(t-1):h.doc,!s)throw new Error("No table found");r=H.get(s),u=h.mapping.maps.length}Ep(h,r,s,t,c,d,u)&&f(),Ar(h,r,s,t,a,c,l,u)&&f(),Ar(h,r,s,t,a,c,d,u)&&f(),Er(h,r,s,t,l,d,a,u)&&f(),Er(h,r,s,t,l,d,c,u)&&f();for(let p=l;p<d;p++){const m=r.positionAt(p,a,s),g=r.positionAt(p,c,s);h.replace(h.mapping.slice(u).map(m+t),h.mapping.slice(u).map(g+t),new C(o.rows[p-l],0,0))}f(),h.setSelection(new W(h.doc.resolve(t+r.positionAt(l,a,s)),h.doc.resolve(t+r.positionAt(d-1,c-1,s)))),e(h)}var Op=ra({ArrowLeft:Vn("horiz",-1),ArrowRight:Vn("horiz",1),ArrowUp:Vn("vert",-1),ArrowDown:Vn("vert",1),"Shift-ArrowLeft":Ln("horiz",-1),"Shift-ArrowRight":Ln("horiz",1),"Shift-ArrowUp":Ln("vert",-1),"Shift-ArrowDown":Ln("vert",1),Backspace:Rn,"Mod-Backspace":Rn,Delete:Rn,"Mod-Delete":Rn});function _n(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Vn(n,e){return(t,i,o)=>{if(!o)return!1;const s=t.selection;if(s instanceof W)return _n(t,i,O.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const r=qa(o,n,e);if(r==null)return!1;if(n=="horiz")return _n(t,i,O.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(r),a=$a(l,n,e);let c;return a?c=O.near(a,1):e<0?c=O.near(t.doc.resolve(l.before(-1)),-1):c=O.near(t.doc.resolve(l.after(-1)),1),_n(t,i,c)}}}function Ln(n,e){return(t,i,o)=>{if(!o)return!1;const s=t.selection;let r;if(s instanceof W)r=s;else{const a=qa(o,n,e);if(a==null)return!1;r=new W(t.doc.resolve(a))}const l=$a(r.$headCell,n,e);return l?_n(t,i,new W(r.$anchorCell,l)):!1}}function Np(n,e){const t=n.state.doc,i=Sn(t.resolve(e));return i?(n.dispatch(n.state.tr.setSelection(new W(i))),!0):!1}function Dp(n,e,t){if(!bi(n.state))return!1;let i=Tp(t);const o=n.state.selection;if(o instanceof W){i||(i={width:1,height:1,rows:[w.from(xo(Ae(n.state.schema).cell,t))]});const s=o.$anchorCell.node(-1),r=o.$anchorCell.start(-1),l=H.get(s).rectBetween(o.$anchorCell.pos-r,o.$headCell.pos-r);return i=Ap(i,l.right-l.left,l.bottom-l.top),Or(n.state,n.dispatch,r,l,i),!0}else if(i){const s=Ko(n.state),r=s.start(-1);return Or(n.state,n.dispatch,r,H.get(s.node(-1)).findCell(s.pos-r),i),!0}else return!1}function Ip(n,e){var t;if(e.ctrlKey||e.metaKey)return;const i=Nr(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof W)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&i&&(o=Sn(n.state.selection.$anchor))!=null&&((t=ji(n,e))==null?void 0:t.pos)!=o.pos)s(o,e),e.preventDefault();else if(!i)return;function s(a,c){let d=ji(n,c);const h=_e.getState(n.state)==null;if(!d||!qo(a,d))if(h)d=a;else return;const u=new W(a,d);if(h||!n.state.selection.eq(u)){const f=n.state.tr.setSelection(u);h&&f.setMeta(_e,a.pos),n.dispatch(f)}}function r(){n.root.removeEventListener("mouseup",r),n.root.removeEventListener("dragstart",r),n.root.removeEventListener("mousemove",l),_e.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(_e,-1))}function l(a){const c=a,d=_e.getState(n.state);let h;if(d!=null)h=n.state.doc.resolve(d);else if(Nr(n,c.target)!=i&&(h=ji(n,e),!h))return r();h&&s(h,c)}n.root.addEventListener("mouseup",r),n.root.addEventListener("dragstart",r),n.root.addEventListener("mousemove",l)}function qa(n,e,t){if(!(n.state.selection instanceof N))return null;const{$head:i}=n.state.selection;for(let o=i.depth-1;o>=0;o--){const s=i.node(o);if((t<0?i.index(o):i.indexAfter(o))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=i.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Nr(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function ji(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Sn(n.state.doc.resolve(t.pos)):null}var Pp=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")),Co(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,Co(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Co(n,e,t,i,o,s){var r;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let h=0,u=0;h<d.childCount;h++){const{colspan:f,colwidth:p}=d.child(h).attrs;for(let m=0;m<f;m++,u++){const g=o==u?s:p&&p[m],b=g?g+"px":"";if(l+=g||i,g||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const x=document.createElement("col");x.style.width=b,e.appendChild(x)}}}for(;c;){const h=c.nextSibling;(r=c.parentNode)==null||r.removeChild(c),c=h}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var ae=new yn("tableColumnResizing");function Rp({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:i=Pp,lastColumnResizable:o=!0}={}){const s=new gn({key:ae,state:{init(r,l){var a,c;const d=(c=(a=s.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,h=Ae(l.schema).table.name;return i&&d&&(d[h]=(u,f)=>new i(u,t,f)),new Vp(-1,!1)},apply(r,l){return l.apply(r)}},props:{attributes:r=>{const l=ae.getState(r);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(r,l)=>{Lp(r,l,n,o)},mouseleave:r=>{zp(r)},mousedown:(r,l)=>{Bp(r,l,e,t)}},decorations:r=>{const l=ae.getState(r);if(l&&l.activeHandle>-1)return _p(r,l.activeHandle)},nodeViews:{}}});return s}var Vp=class Kn{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,i=e.getMeta(ae);if(i&&i.setHandle!=null)return new Kn(i.setHandle,!1);if(i&&i.setDragging!==void 0)return new Kn(t.activeHandle,i.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return So(e.doc.resolve(o))||(o=-1),new Kn(o,t.dragging)}return t}};function Lp(n,e,t,i){const o=ae.getState(n.state);if(o&&!o.dragging){const s=Fp(e.target);let r=-1;if(s){const{left:l,right:a}=s.getBoundingClientRect();e.clientX-l<=t?r=Dr(n,e,"left",t):a-e.clientX<=t&&(r=Dr(n,e,"right",t))}if(r!=o.activeHandle){if(!i&&r!==-1){const l=n.state.doc.resolve(r),a=l.node(-1),c=H.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}ja(n,r)}}}function zp(n){const e=ae.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&ja(n,-1)}function Bp(n,e,t,i){var o;const s=(o=n.dom.ownerDocument.defaultView)!=null?o:window,r=ae.getState(n.state);if(!r||r.activeHandle==-1||r.dragging)return!1;const l=n.state.doc.nodeAt(r.activeHandle),a=Hp(n,r.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ae,{setDragging:{startX:e.clientX,startWidth:a}}));function c(h){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",d);const u=ae.getState(n.state);u!=null&&u.dragging&&($p(n,u.activeHandle,Ir(u.dragging,h,t)),n.dispatch(n.state.tr.setMeta(ae,{setDragging:null})))}function d(h){if(!h.which)return c(h);const u=ae.getState(n.state);if(u&&u.dragging){const f=Ir(u.dragging,h,t);Pr(n,u.activeHandle,f,i)}}return Pr(n,r.activeHandle,a,i),s.addEventListener("mouseup",c),s.addEventListener("mousemove",d),e.preventDefault(),!0}function Hp(n,e,{colspan:t,colwidth:i}){const o=i&&i[i.length-1];if(o)return o;const s=n.domAtPos(e);let l=s.node.childNodes[s.offset].offsetWidth,a=t;if(i)for(let c=0;c<t;c++)i[c]&&(l-=i[c],a--);return l/a}function Fp(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Dr(n,e,t,i){const o=t=="right"?-i:i,s=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!s)return-1;const{pos:r}=s,l=Sn(n.state.doc.resolve(r));if(!l)return-1;if(t=="right")return l.pos;const a=H.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 Ir(n,e,t){const i=e.clientX-n.startX;return Math.max(t,n.startWidth+i)}function ja(n,e){n.dispatch(n.state.tr.setMeta(ae,{setHandle:e}))}function $p(n,e,t){const i=n.state.doc.resolve(e),o=i.node(-1),s=H.get(o),r=i.start(-1),l=s.colCount(i.pos-r)+i.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<s.height;c++){const d=c*s.width+l;if(c&&s.map[d]==s.map[d-s.width])continue;const h=s.map[d],u=o.nodeAt(h).attrs,f=u.colspan==1?0:l-s.colCount(h);if(u.colwidth&&u.colwidth[f]==t)continue;const p=u.colwidth?u.colwidth.slice():Wp(u.colspan);p[f]=t,a.setNodeMarkup(r+h,null,{...u,colwidth:p})}a.docChanged&&n.dispatch(a)}function Pr(n,e,t,i){const o=n.state.doc.resolve(e),s=o.node(-1),r=o.start(-1),l=H.get(s).colCount(o.pos-r)+o.nodeAfter.attrs.colspan-1;let a=n.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Co(s,a.firstChild,a,i,l,t)}function Wp(n){return Array(n).fill(0)}function _p(n,e){var t;const i=[],o=n.doc.resolve(e),s=o.node(-1);if(!s)return z.empty;const r=H.get(s),l=o.start(-1),a=r.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let c=0;c<r.height;c++){const d=a+c*r.width;if((a==r.width-1||r.map[d]!=r.map[d+1])&&(c==0||r.map[d]!=r.map[d-r.width])){const h=r.map[d],u=l+h+s.nodeAt(h).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(t=ae.getState(n))!=null&&t.dragging&&i.push(oe.node(l+h,l+h+s.nodeAt(h).nodeSize,{class:"column-resize-dragging"})),i.push(oe.widget(u,f))}}return z.create(n.doc,i)}function Kp({allowTableNodeSelection:n=!1}={}){return new gn({key:_e,state:{init(){return null},apply(e,t){const i=e.getMeta(_e);if(i!=null)return i==-1?null:i;if(t==null||!e.docChanged)return t;const{deleted:o,pos:s}=e.mapping.mapResult(t);return o?null:s}},props:{decorations:gp,handleDOMEvents:{mousedown:Ip},createSelectionBetween(e){return _e.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Np,handleKeyDown:Op,handlePaste:Dp},appendTransaction(e,t,i){return wp(i,Sp(i,t),n)}})}const ln=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},Rr="data-gs-mrk-fs",Vr="data-gs-ib",ai="data-gs-ifrg",Ve="attrs",Ja={[Ve]:{default:"{}"}},Oe={[Ve]:{default:{}}},Ga=n=>({[Ve]:JSON.stringify(ln(n))}),Ne=n=>({attrs:ln(n)}),Ut=n=>e=>[n,e.attrs.attrs,0],$e=n=>n.attrs[Ve]?JSON.parse(n.attrs[Ve]):{},qp={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${ai}]`,getAttrs:Ne}],toDOM:()=>["span",{[ai]:""},0]},div:{group:"block",content:"inline*",attrs:Oe,parseDOM:[{tag:"div",getAttrs:Ne}],toDOM:Ut("div")},paragraph:{group:"block",content:"inline*",attrs:Oe,parseDOM:[{tag:"p",getAttrs:Ne}],toDOM:Ut("p")},orderedList:{group:"block",content:"listItem+",attrs:Oe,parseDOM:[{tag:"ol",getAttrs:Ne}],toDOM:Ut("ol")},bulletList:{group:"block",content:"listItem+",attrs:Oe,parseDOM:[{tag:"ul",getAttrs:Ne}],toDOM:Ut("ul")},listItem:{content:"block*",group:"block",attrs:Oe,parseDOM:[{tag:"li",getAttrs:Ne}],toDOM:Ut("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:Oe,parseDOM:[{tag:"pre",getAttrs:Ne}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:Oe,parseDOM:[{tag:"img[src]",getAttrs:Ne}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${Vr}]`}],toDOM(){return["br",{[Vr]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:Oe,parseDOM:[{tag:"br",getAttrs:Ne}],toDOM:n=>["br",{...n.attrs.attrs}]},heading:{group:"block",content:"inline*",attrs:{level:{default:1},attrs:{default:{}}},defining:!0,parseDOM:Array.from({length:6},(n,e)=>({tag:`h${e+1}`,getAttrs:t=>({level:e+1,attrs:ln(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...up({tableGroup:"block",cellContent:"block+",cellAttributes:{[Ve]:{default:Oe[Ve].default,getFromDOM:ln,setDOMAttr:(n,e)=>{n&&Object.assign(e,n)}},background:{default:null,getFromDOM(n){return n.style.backgroundColor||null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`background-color: ${n};`)}}}}),nonTextNode:{group:"block",content:"block*",attrs:{tagName:{default:"span"},attrs:{default:{}}},parseDOM:[{tag:"*:not(tbody)",getAttrs:n=>({tagName:n.tagName.toLowerCase(),attrs:ln(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},Zt=(n,e)=>({attrs:Ja,parseDOM:n.map(t=>({tag:t,getAttrs:Ga})),toDOM:e}),jp={strong:Zt(["strong","b"],n=>["b",$e(n)]),link:Zt(["a"],n=>["a",$e(n),0]),em:Zt(["em","i"],n=>["em",$e(n)]),underline:Zt(["u"],n=>["u",$e(n),0]),strikethrough:Zt(["s"],n=>["s",$e(n),0]),font_size:{attrs:{...Ja,size:{default:null}},parseDOM:[{tag:`span[${Rr}]`,getAttrs:n=>({...Ga(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...$e(n),[Rr]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},Lr=new dh({nodes:qp,marks:jp}),wi=new WeakMap,Jo=new WeakMap,Jp=(n,e)=>{wi.set(n,e),Jo.set(e,n)},Gp=(n,e)=>{wi.delete(n),Jo.delete(e)},Ji=n=>wi.get(n),Up=n=>Jo.get(n),zr=n=>{var t;const e=Up(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},Zp=n=>n.dispatchEvent(new CustomEvent("input"));function Yp(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(ai)){if(t.getAttribute("style")){t.removeAttribute(ai);return}const i=t.parentElement;if(i){for(;t.firstChild;)i.insertBefore(t.firstChild,t);i.removeChild(t)}}else Array.from(t.children).forEach(i=>e(i))};e(n)}function Xp(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,i=d=>n.getSelectedAll().includes(d),o=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),s=d=>d.isChildOf("text"),r=d=>n.getEditing()===d,l=(d,h={})=>{d.trigger("focus",h.event)},a=(d,h)=>{i(d)&&o(d)&&!r(d)&&l(d,h)},c=(d,h)=>{if(i(d)&&!o(d)&&s(d)){const u=d.parents().find(f=>f.isInstanceOf("text"));u&&(l(u,h),setTimeout(()=>n.select(u),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Qp=(n,e)=>{const t=em(n);return t&&cm(t)?tm(n,e):t?Xl(()=>({type:n.schema.nodes.div}))(n,e):!1};function em(n){const e=n.selection.$from;if(e.node(e.depth).type===n.schema.nodes.inlineFragment){const t=e.depth-1;return e.node(t)}return e.node(e.depth)}function tm(n,e){const{selection:t,schema:i,tr:o}=n;o.split(t.from,1);const s=t.from+1,r=o.doc.nodeAt(s),l={...r.attrs.attrs,id:void 0},a=r.textContent.length>0,c=r.textContent.length||0,d=r.textContent||" ",h=i.text(d),u=i.nodes.div.create(l,a?h:[],[]);return o.replaceRangeWith(s,s+c+2,u),o.setSelection(N.create(o.doc,s+1)),e==null||e(o.scrollIntoView()),!0}function nm(n,e,t){const{state:i,dispatch:o}=n,{selection:s,tr:r}=i,l=(a,c,d)=>{const h={};return a.split(";").forEach(u=>{const[f,p]=u.split(":").map(m=>m.trim());f&&(h[f]=p)}),h[c]=d,Object.entries(h).map(([u,f])=>`${u}: ${f}`).join("; ")};if(!s.empty||t)r.doc.nodesBetween(s.from,s.to,(a,c)=>{var d,h;if(a.type===i.schema.nodes.image){const u=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}else if(a.type.isBlock){const u=l(((h=a.attrs.attrs)==null?void 0:h.style)||"","text-align",e);Ua(a)?r.setBlockType(s.from,void 0,i.schema.nodes.div,{attrs:{style:u}}):r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}});else{const a=i.doc.resolve(s.from),c=a.start(a.depth),d=i.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const h=l(d.attrs.style||"","text-align",e);r.setNodeMarkup(c,void 0,{...d.attrs,style:h})}}r.docChanged&&o(r.scrollIntoView())}const Yt=(n,e)=>{const{from:t,to:i}=n.selection;let o=!1;return n.doc.nodesBetween(t,i,s=>{if(o)return!1;s.marks.some(r=>r.type===e)&&(o=!0)}),o};function im(n,e,t="_blank"){const{state:i,dispatch:o}=n,{schema:s,selection:r,tr:l}=i,a=s.marks.link;try{const c=a.create({[Ve]:JSON.stringify({href:e,target:t})});l.addMark(r.from,r.to,c),o(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function om(n,e){const{state:t,dispatch:i}=n,{selection:o,tr:s}=t;if(o.empty)return;const r=t.schema.marks.font_size;if(!r){console.error("Font size mark is not defined in the schema.");return}s.addMark(o.from,o.to,r.create({size:e})),i(s.scrollIntoView())}const at=(n,e)=>{const{doc:t,selection:i}=n.state,o=t.resolve(i.from);for(let s=o.depth;s>0;s--){const r=o.node(s);if(e(r))return{pos:s>0?o.before(s):0,start:o.start(s),depth:s,node:r}}},sm=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,i])=>(t=t.replace(/-./g,o=>o.toUpperCase()[1]).trim(),e[t]=`${i}`.trim(),e),{});function rm(...n){return(e,t)=>{const i=r=>{e=e.apply(r),t==null||t(r)},o=n.pop();return n.reduce((r,l)=>r||l(e,i),!1)&&o!==void 0&&o(e,t)}}const lm=(n,e)=>{const{state:t,dispatch:i}=n;if(e!=null&&e.event){const{event:o}=e,s=n.posAtCoords({left:o.clientX,top:o.clientY});s!=null&&s.pos&&i(t.tr.setSelection(N.create(t.doc,s.pos)))}else Ql(t,i);setTimeout(()=>setTimeout(()=>n.focus()))},ko=n=>n.isBlock,Ua=n=>n.type.name==="inlineFragment",am=n=>ko(n)&&!Ua(n),Za=n=>n.type.name==="bulletList",Ya=n=>n.type.name==="orderedList",cm=n=>n.type.name==="heading",dm=n=>Za(n)||Ya(n),Br=(n,e)=>{var s,r;const t=(s=at(n,l=>l.type===e))==null?void 0:s.node,i=n.state.schema.nodes.listItem;let o;return t?o=lo(i):(r=at(n,dm))!=null&&r.node?o=rm(lo(i),_s(e)):o=_s(e),o(n.state,n.dispatch)},Xa=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(i=>i.type.name===e)},hm=n=>{var r;const{view:e,prop:t,editor:i,propCSS:o}=n,s=(r=at(e,am))==null?void 0:r.node;if(s){const l=s.attrs.attrs||{},a=sm(l.style);if(t in a)return a[t]||"";if(l.id){const c=i.Components.getById(l.id);return((c==null?void 0:c.getStyle())||{})[o]||""}}return""},um=n=>{const{view:e,prop:t,markName:i,editor:o,propCSS:s}=n,r=Xa(e,i);if(r){const l=r.attrs;if(l[t])return l[t];if(l[Ve]){const a=$e(r).id;if(a){const c=o.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[s]||""}}}return""},Qa=(n,e)=>{const{dispatch:t}=n,{nodes:i,marks:o}=n.state.schema;return{text:{selected:()=>{const{selection:s,doc:r}=n.state;return r.textBetween(s.from,s.to," ")},replace:(s,r={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(s));r.select&&(c=c.setSelection(N.create(c.doc,a,a+s.length))),t==null||t(c)}},bold:{toggle:()=>it(o.strong)(n.state,t),isActive:()=>Yt(n.state,o.strong)},italic:{toggle:()=>it(o.em)(n.state,t),isActive:()=>Yt(n.state,o.em)},underline:{toggle:()=>it(o.underline)(n.state,t),isActive:()=>Yt(n.state,o.underline)},strikethrough:{toggle:()=>it(o.strikethrough)(n.state,t),isActive:()=>Yt(n.state,o.strikethrough)},link:{get:()=>{const s=zr(n);if(s!=null&&s.is("link"))return s.getAttributes();{const r=Xa(n,"link");return r?$e(r):{}}},toggle:()=>it(o.link)(n.state,t),isActive:()=>Yt(n.state,o.link),create:s=>{const r=zr(n);r!=null&&r.is("link")?(r.addAttributes({href:s.url,target:s.target}),n.focus()):im(n,s.url,s.target)}},alignText:{get:()=>hm({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:s=>nm(n,s.value,!0)},fontSize:{get:()=>um({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:s=>om(n,s.value)},image:{open(){const s="assetLayout",{state:r,dispatch:l}=n,{selection:a,doc:c}=r,d=c.textBetween(a.from,a.to," "),h={id:s,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:u=>{const f={alt:d,src:u.asset.getSrc()};l(r.tr.replaceSelectionWith(i.image.createAndFill({attrs:f})))}}};e.runCommand(X.layoutToggle,h)}},heading:{get:()=>{var r;const s=(r=at(n,ko))==null?void 0:r.node;return`${(s==null?void 0:s.attrs.level)||""}`},set:({value:s})=>{var a;const{state:r}=n,l=(a=at(n,ko))==null?void 0:a.node;iu(r.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:s?parseInt(s,10):0})(r,t)}},listBullet:{isActive:()=>{var s;return!!((s=at(n,Za))!=null&&s.node)},toggle:()=>Br(n,i.bulletList)},listOrdered:{isActive:()=>{var s;return!!((s=at(n,Ya))!=null&&s.node)},toggle:()=>Br(n,i.orderedList)}}},me="rte:selectionchange",he={bold:'<svg viewBox="0 0 24 24"><path d="M13.5,15.5H10V12.5H13.5A1.5,1.5 0 0,1 15,14A1.5,1.5 0 0,1 13.5,15.5M10,6.5H13A1.5,1.5 0 0,1 14.5,8A1.5,1.5 0 0,1 13,9.5H10M15.6,10.79C16.57,10.11 17.25,9 17.25,8C17.25,5.74 15.5,4 13.25,4H7V18H14.04C16.14,18 17.75,16.3 17.75,14.21C17.75,12.69 16.89,11.39 15.6,10.79Z" /></svg>',italic:'<svg viewBox="0 0 24 24"><path d="M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z" /></svg>',underline:'<svg viewBox="0 0 24 24"><path d="M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z" /></svg>',strikethrough:'<svg viewBox="0 0 24 24"><path d="M7.2 9.8c-1.2-2.3.5-5 2.9-5.5 3.1-1 7.6.4 7.5 4.2h-3l-.1-.8c-.2-.6-.6-.9-1.2-1.1-.8-.3-2.1-.2-2.8.3C9 8.2 10.4 9.5 12 10H7.4l-.2-.2M21 13v-2H3v2h9.6l.6.2c.6.3 1.1.5 1.3 1.1.1.4.2.9 0 1.3-.2.5-.6.7-1.1.9-1.8.5-4-.2-3.9-2.4h-3c-.1 2.6 2.1 4.4 4.5 4.7 3.8.8 8.3-1.6 6.3-5.9l3.7.1Z"/></svg>',link:'<svg viewBox="0 0 24 24"><path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" /></svg>',image:'<svg viewBox="0 0 24 24"><path d="M19,19H5V5H19M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M13.96,12.29L11.21,15.83L9.25,13.47L6.5,17H17.5L13.96,12.29Z"></path></svg>',listBullet:'<svg viewBox="0 0 24 24"><path d="M7 5h14v2H7V5m0 8v-2h14v2H7M4 4.5A1.5 1.5 0 0 1 5.5 6 1.5 1.5 0 0 1 4 7.5 1.5 1.5 0 0 1 2.5 6 1.5 1.5 0 0 1 4 4.5m0 6A1.5 1.5 0 0 1 5.5 12 1.5 1.5 0 0 1 4 13.5 1.5 1.5 0 0 1 2.5 12 1.5 1.5 0 0 1 4 10.5M7 19v-2h14v2H7m-3-2.5A1.5 1.5 0 0 1 5.5 18 1.5 1.5 0 0 1 4 19.5 1.5 1.5 0 0 1 2.5 18 1.5 1.5 0 0 1 4 16.5Z"/></svg>',listOrdered:'<svg viewBox="0 0 24 24"><path d="M7 13v-2h14v2H7m0 6v-2h14v2H7M7 7V5h14v2H7M3 8V5H2V4h2v4H3m-1 9v-1h3v4H2v-1h2v-.5H3v-1h1V17H2m2.3-7a.8.8 0 0 1 .7.8c0 .1 0 .3-.2.5L3 13h2v1H2v-1l2-2H2v-1h2.3Z"/></svg>',alignTextLeft:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H15V9H3V7M3,11H21V13H3V11M3,15H15V17H3V15M3,19H21V21H3V19Z" /></svg>',alignTextCenter:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M7,7H17V9H7V7M3,11H21V13H3V11M7,15H17V17H7V15M3,19H21V21H3V19Z" /></svg>',alignTextRight:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M9,7H21V9H9V7M3,11H21V13H3V11M9,15H21V17H9V15M3,19H21V21H3V19Z" /></svg>',alignTextJustify:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H21V9H3V7M3,11H21V13H3V11M3,15H21V17H3V15M3,19H21V21H3V19Z" /></svg>'},fm=(n,e)=>{var a;const{editor:t,el:i}=n,o=wi.get(i),s=Qa(o,t),r={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:he.bold,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:s.bold.isActive()})}},onClick:({setState:c})=>{s.bold.toggle(),c({active:s.bold.isActive()})}},italic:{id:"italic",icon:he.italic,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:s.italic.isActive()})}},onClick:({setState:c})=>{s.italic.toggle(),c({active:s.italic.isActive()})}},underline:{id:"underline",icon:he.underline,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:s.underline.isActive()})}},onClick:({setState:c})=>{s.underline.toggle(),c({active:s.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:he.strikethrough,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:s.strikethrough.isActive()})}},onClick:({setState:c})=>{s.strikethrough.toggle(),c({active:s.strikethrough.isActive()})}},image:{id:"image",icon:he.image,size:"s",type:"button",onClick:()=>s.image.open()},link:{id:"link",icon:he.link,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:s.link.isActive(),disabled:o.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:h,y:u,width:f,height:p}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(X.layoutRemove,{id:m}),b=s.link.get(),x={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:h,y:u,w:f,h:p},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:y=>{y.preventDefault();const v=new FormData(y.currentTarget);s.link.create({url:v.get("url"),target:v.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(b==null?void 0:b.href)||"",onChange:({value:y,setState:v})=>v({value:y})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(b==null?void 0:b.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:y,setState:v})=>v({value:y})},{type:"row",style:{gap:10,justifyContent:"end"},children:[s.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{s.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(X.layoutToggle,x)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:he.alignTextLeft},{id:"center",icon:he.alignTextCenter},{id:"right",icon:he.alignTextRight},{id:"justify",icon:he.alignTextJustify}],editorEvents:{[me]:({setState:c})=>{c({value:s.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),s.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:he.listBullet,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:s.listBullet.isActive()})}},onClick:({setState:c})=>{s.listBullet.toggle(),c({active:s.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:he.listOrdered,size:"s",type:"button",editorEvents:{[me]:({setState:c})=>{c({active:s.listOrdered.isActive()})}},onClick:({setState:c})=>{s.listOrdered.toggle(),c({active:s.listOrdered.isActive()})}},heading:{id:"heading",type:"selectField",size:"s",value:"",emptyState:"Heading",options:[{id:"",label:"Normal"},{id:"1",label:"Heading 1"},{id:"2",label:"Heading 2"},{id:"3",label:"Heading 3"},{id:"4",label:"Heading 4"},{id:"5",label:"Heading 5"},{id:"6",label:"Heading 6"}],editorEvents:{[me]:({setState:c})=>{c({value:s.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),s.heading.set({value:c}),o.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"Font size",options:[{id:"8pt",label:"8pt"},{id:"10pt",label:"10pt"},{id:"12pt",label:"12pt"},{id:"14pt",label:"14pt"},{id:"18pt",label:"18pt"},{id:"24pt",label:"24pt"},{id:"36pt",label:"36pt"}],editorEvents:{[me]:({setState:c})=>{c({value:s.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),s.fontSize.set({value:c}),o.focus()}}},l=[r.bold,r.italic,r.underline,r.strikethrough,r.image,r.link,r.listBullet,r.listOrdered,r.alignText,r.heading,r.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:s,layouts:r,proseMirror:{view:o},items:l}))||l};class pm{constructor(e,t,i){this.editor=i,this.node=e,this.dom=document.createElement("img"),this.view=t,Object.keys(e.attrs.attrs).forEach(o=>{this.dom.setAttribute(o,e.attrs.attrs[o])}),this.dom.addEventListener("dblclick",o=>this.handleDoubleClick(o))}handleDoubleClick(e){const{editor:t,view:i}=this;Qa(i,t).image.open(),e.preventDefault()}update(e){return e.type!==this.node.type?!1:(this.node=e,Object.keys(e.attrs.attrs).forEach(t=>{this.dom.setAttribute(t,e.attrs.attrs[t])}),!0)}selectNode(){this.dom.style.outline="2px solid #ffca6f"}deselectNode(){this.dom.style.outline=""}}class Xe{constructor(e,t,i={}){this.match=e,this.match=e,this.handler=typeof t=="string"?mm(t):t,this.undoable=i.undoable!==!1,this.inCode=i.inCode||!1}}function mm(n){return function(e,t,i,o){let s=n;if(t[1]){let r=t[0].lastIndexOf(t[1]);s+=t[0].slice(r+t[1].length),i+=r;let l=i-o;l>0&&(s=t[0].slice(r-l,r)+s,i=o)}return e.tr.insertText(s,i,o)}}const gm=500;function ym({rules:n}){let e=new gn({state:{init(){return null},apply(t,i){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:i)}},props:{handleTextInput(t,i,o,s){return Hr(t,i,o,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:i}=t.state.selection;i&&Hr(t,i.pos,i.pos,"",n,e)})}}},isInputRules:!0});return e}function Hr(n,e,t,i,o,s){if(n.composing)return!1;let r=n.state,l=r.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-gm),l.parentOffset,null,"")+i;for(let c=0;c<o.length;c++){let d=o[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let h=d.match.exec(a),u=h&&d.handler(r,h,e-(h[0].length-i.length),t);if(u)return d.undoable&&u.setMeta(s,{transform:u,from:e,to:t,text:i}),n.dispatch(u),!0}return!1}const bm=new Xe(/--$/,"—"),wm=new Xe(/\.\.\.$/,"…"),vm=new Xe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),Sm=new Xe(/"$/,"”"),xm=new Xe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),Cm=new Xe(/'$/,"’"),km=[vm,Sm,xm,Cm];function Go(n,e,t=null,i){return new Xe(n,(o,s,r,l)=>{let a=t instanceof Function?t(s):t,c=o.tr.delete(r,l),d=c.doc.resolve(r),h=d.blockRange(),u=h&&Ll(h,e,a);if(!u)return null;c.wrap(h,u);let f=c.doc.resolve(r-1).nodeBefore;return f&&f.type==e&&fi(c.doc,r-1)&&(!i||i(s,f))&&c.join(r-1),c})}function ec(n,e,t=null){return new Xe(n,(i,o,s,r)=>{let l=i.doc.resolve(s),a=t instanceof Function?t(o):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?i.tr.delete(s,r).setBlockType(s,s,e,a):null})}function Tm(n){return Go(/^\s*>\s$/,n)}function Mm(n){return Go(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function Am(n){return Go(/^\s*([-+*])\s$/,n)}function Em(n){return ec(/^```$/,n)}function Om(n,e){return ec(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function Nm(n){const e=km.concat(wm,bm);let t;return(t=n.nodes.blockquote)&&e.push(Tm(t)),(t=n.nodes.orderedList)&&e.push(Mm(t)),(t=n.nodes.bulletList)&&e.push(Am(t)),(t=n.nodes.codeBlock)&&e.push(Em(t)),(t=n.nodes.heading)&&e.push(Om(t,6)),ym({rules:e})}const Dm="rteProseMirror",Im=function(n,e={}){const t={plugins:r=>r.plugins,...e},i=(r,l)=>{var p,m;const a=((p=t.schema)==null?void 0:p.call(t,{editor:n,schema:Lr}))||Lr,{nodes:c,marks:d}=a,h=Ht.fromSchema(a).parse(r),u=Nt.create({doc:h,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,plugins:[Rp(),Kp(),Nm(a),mu(),Fi({Tab:Mr(1),"Shift-Tab":Mr(-1)}),Fi({Enter:hn(Yl,Cu(c.listItem),Qp),"Shift-Enter":hn(Zl,(g,b)=>(b&&b(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":sa,"Mod-y":ro,"Mod-Shift-z":ro,"Mod-b":it(d.strong),"Mod-i":it(d.em),"Shift-Tab":lo(c.listItem),Tab:Mu(c.listItem)}),Fi(ru)]})}),f=new sp({mount:r},{state:u,dispatchTransaction(g){var S;const{state:b}=f,x=b.apply(g),y=!b.doc.eq(x.doc);f.updateState(x);const v=!b.selection.eq(x.selection);y&&(Zp(((S=l==null?void 0:l.view)==null?void 0:S.el)||r),f.focus()),(v||y)&&n.trigger(me)}});return r.__rteView=f,f.setProps({nodeViews:{image(g){return new pm(g,f,n)}}}),f},o=r=>fm(r,t);n.setCustomRte({toolbar:o,parseContent:!0,async enable(r,l,a){const c=Ji(r);if(c)return c;const d=i(r,a);return Jp(r,d),lm(d,a),d},disable(r){const l=Ji(r);if(l)return Gp(r,l),l.destroy(),{forceSync:!0}},getContent(r){const l=Ji(r);if(l){const{schema:a,doc:c}=l.state,d=document.createElement("div"),h=wt.fromSchema(a).serializeFragment(c.content);return h.childNodes.forEach(u=>{u.nodeType===Node.ELEMENT_NODE&&u.innerHTML===""&&(u.innerHTML="<br/>")}),d.appendChild(h),Yp(d),r.classList.remove("ProseMirror-focused"),d.innerHTML}return r.innerHTML}});const s=Xp(n,t);Se({editor:n,licenseKey:t.licenseKey,plan:Z.free,pluginName:Dm,cleanup:()=>{n.RichTextEditor.customRte=void 0,s()}})},Pm=ve(Im),Rm="canvasEmptyState",Vm=function(n,e={}){const t=new WeakMap,i=new WeakMap,o=new WeakMap,s=new Set,r=new WeakMap,l={emptyStates:[],...e},a=(y,v)=>{let S=!1;const{isValid:k}=v;return Array.isArray(k)?S=k.some(T=>y.is(T)):To(k)?S=k({component:y,editor:n}):S=y.is(k),S},c=y=>{const v=t.get(y);t.delete(y),v==null||v()},d=y=>{y.views.forEach(v=>c(v)),o.delete(y)},h=y=>{if(!(!y||s.has(y)))try{s.add(y);const v=y.components().length>0,S=o.get(y);if(v&&S)d(y);else if(!v&&!S){const k=r.has(y)?r.get(y):l.emptyStates.find(T=>a(y,T));if(r.set(y,k),!k)return;y.views.forEach(T=>{const V=k.render({editor:n,component:y,componentView:T,mount:M=>{i.set(T,M),o.set(y,!0);const P=T.getChildrenContainer();P==null||P.appendChild(M)},unmount:()=>c(T)});t.set(T,()=>{V==null||V();const M=i.get(T);M==null||M.remove()})})}}finally{s.delete(y)}},u=y=>{o.has(y)&&d(y)},f=({model:y})=>{h(y.getComponent())},p=n.Components.events,m=`${p.update}:components`,g="component:mount",b=n.Canvas.events.frameLoadBody,x=p.removed||p.remove;n.on(m,h),n.on(g,h),n.on(x,u),n.on(b,f),Se({editor:n,licenseKey:l.licenseKey,plan:Z.startup,pluginName:Rm,cleanup:()=>{n.off(m,h),n.off(g,h),n.off(x,u),n.off(b,f)}})},Lm=ve(Vm),zm=n=>{const e={};for(const t of Object.keys(n)){let i=n[t];i&&(Array.isArray(i)?i=i.map(o=>o.toString()).join(","):i=i.toString(),e[t]=i)}return new URLSearchParams(e)},Bm=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:i="high"}=n,o=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=zm(l);return`${c}?${d}`},s=l=>{var a,c,d;return((a=l[i])==null?void 0:a.url)||((c=l.high)==null?void 0:c.url)||((d=l.medium)==null?void 0:d.url)||l.default.url},r=l=>{const a=s(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:["youtube-video"],label:({editor:l})=>l.I18n.t("youtubeAssetProvider.providerLabel"),search:{reloadOnInput:!0,debounceMs:1e3},async onLoad({searchValue:l,pageCustomData:a}){var m;const c={maxResults:25,q:l,pageToken:a==null?void 0:a.token,type:["video"],key:e},d=t==null?void 0:t({searchValue:l}),h={...c,...d};h.part?h.part.includes("snippet")||h.part.push("snippet"):h.part=["snippet"];const f=await(await fetch(o(h))).json();return(m=f.items)!=null&&m.length?{items:f.items.map(r),nextPageCustomData:{token:f.nextPageToken},isLastPage:!f.nextPageToken}:{items:[],isLastPage:!0}},itemLayout:({assetProps:l,onSelect:a})=>({type:"column",onClick:()=>a(l),htmlAttrs:{title:l.name},style:{border:"1px solid gray",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"custom",render:()=>{var c;return`<img src="${(c=l.customData)==null?void 0:c.thumbnailUrl}" alt="${l.name}" style="width: 100%; height: 100px; object-fit: cover">`}},{type:"text",content:l.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingLeft:8,paddingRight:8}}]})}},Hm={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},Fm="youtubeAssetProvider",$m=function(n,e){var c;const{skipVideoComponent:t,i18n:i={}}=e,o=Bm(e);n.runCommand(X.assetProviderAdd,{provider:o});const s="search-on-youtube",r="video",l=(c=n.Components.getType(r))==null?void 0:c.model.prototype,a=d=>{n.Assets.open({modalTitle:n.I18n.t("youtubeAssetProvider.modalTitle"),providerId:o.id,providers:[],types:[],select:h=>{n.Assets.close(),d.set({videoId:h.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){const[d,...h]=l.getYoutubeTraits.apply(this);return[d,{id:s,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...h]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:d}=this,h=d.get("provider")||"";h!=null&&h.startsWith("yt")&&a(d)}}}),n.I18n.addMessages({en:Hm,...i}),Se({editor:n,licenseKey:e.licenseKey,plan:Z.startup,pluginName:Fm,cleanup:()=>{n.runCommand(X.assetProviderRemove,{id:o.id}),!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==s)}}})}})},Wm=ve($m);exports.canvasEmptyState=Lm;exports.dialogComponent=gc;exports.fsLightboxComponent=fd;exports.iconifyComponent=Dc;exports.lightGalleryComponent=Cd;exports.listPagesComponent=cd;exports.rteProseMirror=Pm;exports.rteTinyMce=Jd;exports.swiperComponent=Bd;exports.tableComponent=nd;exports.youtubeAssetProvider=Wm;