@grapesjs/studio-sdk-plugins 1.0.17 → 1.0.18

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.umd.js CHANGED
@@ -1,13 +1,13 @@
1
- (function($,Dt){typeof exports=="object"&&typeof module<"u"?Dt(exports):typeof define=="function"&&define.amd?define(["exports"],Dt):($=typeof globalThis<"u"?globalThis:$||self,Dt($.StudioSdkPlugins={}))})(this,function($){"use strict";const Dt="app.grapesjs.com",Li="app-stage.grapesjs.com",Vi=[Dt,Li,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],id="license:check:start",rd="license:check:end",ld=()=>typeof window<"u",ad=({isDev:n,isStage:e})=>`${n?"":`https://${e?Li:Dt}`}/api`,cd=()=>{const n=ld()&&window.location.hostname;return!!n&&(Vi.includes(n)||Vi.some(e=>n.endsWith(e)))},dd=n=>n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?"-":"")+e.toLowerCase()),ud=n=>typeof n<"u";function Un(n){return typeof n=="function"}async function hd({path:n,baseApiUrl:e,method:t="GET",headers:s={},params:o,body:i}){const l=`${e||ad({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...s}};i&&(a.body=JSON.stringify(i));const c=o?new URLSearchParams(o).toString():"",d=c?`?${c}`:"",u=await fetch(`${l}${d}`,a);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}var F=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(F||{}),Bi=(n=>(n.Info="info",n.Error="error",n.Success="success",n.Warning="warning",n))(Bi||{}),B=(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.layoutUpdate="studio:layoutUpdate",n.layoutGet="studio:layoutGet",n.layoutConfigGet="studio:layoutConfigGet",n.layoutConfigSet="studio:layoutConfigSet",n.getStateTheme="studio:getStateTheme",n.setStateTheme="studio:setStateTheme",n.assetProviderGet="studio:assetProviderGet",n.assetProviderAdd="studio:assetProviderAdd",n.assetProviderRemove="studio:assetProviderRemove",n.fontGet="studio:fontGet",n.fontAdd="studio:fontAdd",n.fontRemove="studio:fontRemove",n))(B||{}),Hi=(n=>(n.layoutToggleId="studio:layoutToggle:",n.toggleBlocksPanel="studio:toggleBlocksPanel",n.pageSettingsUpdate="studio:pageSettingsUpdate",n))(Hi||{}),$i=(n=>(n.dark="dark",n.light="light",n.auto="auto",n))($i||{}),Fi=(n=>(n.web="web",n.email="email",n))(Fi||{});const Wi={[F.free]:0,[F.startup]:10,[F.business]:20,[F.enterprise]:30};function fd(n){const e=n;return e.init=t=>s=>n(s,t),e}const Q=n=>fd(n);async function ee({editor:n,plan:e,pluginName:t,licenseKey:s,cleanup:o}){let i="",r=!1;const l=cd(),a=d=>{console.warn("Cleanup plugin:",t,"Reason:",d),o()},c=(d={})=>{var m;const{error:u,sdkLicense:h}=d,f=(m=d.plan)==null?void 0:m.category;if(!(h||d.license)||u)a(u||"Invalid license");else if(f){const g=Wi[e],b=Wi[f];g>b&&a({pluginRequiredPlan:e,licensePlan:f})}};n.on(id,d=>{i=d==null?void 0:d.baseApiUrl,r=!0}),n.on(rd,d=>{c(d)}),setTimeout(async()=>{if(!r){if(l)return;if(s){const d=await pd({licenseKey:s,pluginName:t,baseApiUrl:i});d&&c(d)}else a("The `licenseKey` option not provided")}},2e3)}async function pd(n){const{licenseKey:e,pluginName:t,baseApiUrl:s}=n;try{return(await hd({baseApiUrl:s,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))},ct=(n,e)=>{var t;return!!((t=n==null?void 0:n.classList)!=null&&t.contains(e))},dt=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,Ge))===n},Qs=(...n)=>e=>n.some(t=>e.is(t)),_i=(...n)=>(e,t)=>n.some(s=>t.is(s)),md=(n,e={})=>{var i;const t={},s=[],o=[];for(const r in n){const{value:l,...a}=n[r];s.push({id:r,name:r,changeProp:!0,category:e.category,...a}),t[r]=l,!ud(l)&&o.push(r);const{subTraits:c={}}=a;for(const d in a.subTraits)(i=c[d])==null||i.forEach(u=>{const h=u.id||u.name;t[h]=u.value})}return{propKeys:Object.keys(t),propsNoValues:o,props:t,traits:s}},gd=(n,e)=>{e.forEach(t=>{if(t.subTraits){const s=`${t.id||t.name}`,o=t.changeProp?`change:${s}`:`change:attributes:${s}`;n.on(o,()=>qi(n,s)),qi(n,s)}})},qi=(n,e)=>{const t=n.getTrait(e),s=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:s,...c})),{at:a})},yd=(n,e)=>{e.forEach(t=>{const s=dd(t);s!==t&&n.has(s)&&n.set({[t]:n.get(s),[s]:void 0})})},ze="gjs-plg-",Ge="data-type-role",Gi=(...n)=>n.map(e=>`[data-gjs-type="${e}"]`).join(","),bd="dialogComponent",vd=Q(function(n,e={}){const{Blocks:t,Components:s}=n,{licenseKey:o}=e,i="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",u="gjs-plg-dialog-description",h="gjs-plg-dialog-placeholder";t.add(i,{label:"Dialog",media:`
1
+ (function($,Dt){typeof exports=="object"&&typeof module<"u"?Dt(exports):typeof define=="function"&&define.amd?define(["exports"],Dt):($=typeof globalThis<"u"?globalThis:$||self,Dt($.StudioSdkPlugins={}))})(this,function($){"use strict";const Dt="app.grapesjs.com",Li="app-stage.grapesjs.com",Vi=[Dt,Li,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],id="license:check:start",rd="license:check:end",ld=()=>typeof window<"u",ad=({isDev:n,isStage:e})=>`${n?"":`https://${e?Li:Dt}`}/api`,cd=()=>{const n=ld()&&window.location.hostname;return!!n&&(Vi.includes(n)||Vi.some(e=>n.endsWith(e)))},dd=n=>n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?"-":"")+e.toLowerCase()),ud=n=>typeof n<"u";function Un(n){return typeof n=="function"}async function hd({path:n,baseApiUrl:e,method:t="GET",headers:o={},params:s,body:i}){const l=`${e||ad({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...o}};i&&(a.body=JSON.stringify(i));const c=s?new URLSearchParams(s).toString():"",d=c?`?${c}`:"",u=await fetch(`${l}${d}`,a);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}var F=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(F||{}),Bi=(n=>(n.Info="info",n.Error="error",n.Success="success",n.Warning="warning",n))(Bi||{}),B=(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.layoutUpdate="studio:layoutUpdate",n.layoutGet="studio:layoutGet",n.layoutConfigGet="studio:layoutConfigGet",n.layoutConfigSet="studio:layoutConfigSet",n.getStateTheme="studio:getStateTheme",n.setStateTheme="studio:setStateTheme",n.assetProviderGet="studio:assetProviderGet",n.assetProviderAdd="studio:assetProviderAdd",n.assetProviderRemove="studio:assetProviderRemove",n.fontGet="studio:fontGet",n.fontAdd="studio:fontAdd",n.fontRemove="studio:fontRemove",n))(B||{}),Hi=(n=>(n.layoutToggleId="studio:layoutToggle:",n.toggleBlocksPanel="studio:toggleBlocksPanel",n.pageSettingsUpdate="studio:pageSettingsUpdate",n))(Hi||{}),$i=(n=>(n.dark="dark",n.light="light",n.auto="auto",n))($i||{}),Fi=(n=>(n.web="web",n.email="email",n))(Fi||{});const _i={[F.free]:0,[F.startup]:10,[F.business]:20,[F.enterprise]:30};function fd(n){const e=n;return e.init=t=>o=>n(o,t),e}const Q=n=>fd(n);async function ee({editor:n,plan:e,pluginName:t,licenseKey:o,cleanup:s}){let i="",r=!1;const l=cd(),a=d=>{console.warn("Cleanup plugin:",t,"Reason:",d),s()},c=(d={})=>{var m;const{error:u,sdkLicense:h}=d,f=(m=d.plan)==null?void 0:m.category;if(!(h||d.license)||u)a(u||"Invalid license");else if(f){const g=_i[e],y=_i[f];g>y&&a({pluginRequiredPlan:e,licensePlan:f})}};n.on(id,d=>{i=d==null?void 0:d.baseApiUrl,r=!0}),n.on(rd,d=>{c(d)}),setTimeout(async()=>{if(!r){if(l)return;if(o){const d=await pd({licenseKey:o,pluginName:t,baseApiUrl:i});d&&c(d)}else a("The `licenseKey` option not provided")}},2e3)}async function pd(n){const{licenseKey:e,pluginName:t,baseApiUrl:o}=n;try{return(await hd({baseApiUrl:o,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}const Zn=(n,e)=>{var t;return!!((t=n==null?void 0:n.hasAttribute)!=null&&t.call(n,e))},ct=(n,e)=>{var t;return!!((t=n==null?void 0:n.classList)!=null&&t.contains(e))},dt=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,Ge))===n},Qo=(...n)=>e=>n.some(t=>e.is(t)),Wi=(...n)=>(e,t)=>n.some(o=>t.is(o)),md=(n,e={})=>{var i;const t={},o=[],s=[];for(const r in n){const{value:l,...a}=n[r];o.push({id:r,name:r,changeProp:!0,category:e.category,...a}),t[r]=l,!ud(l)&&s.push(r);const{subTraits:c={}}=a;for(const d in a.subTraits)(i=c[d])==null||i.forEach(u=>{const h=u.id||u.name;t[h]=u.value})}return{propKeys:Object.keys(t),propsNoValues:s,props:t,traits:o}},gd=(n,e)=>{e.forEach(t=>{if(t.subTraits){const o=`${t.id||t.name}`,s=t.changeProp?`change:${o}`:`change:attributes:${o}`;n.on(s,()=>qi(n,o)),qi(n,o)}})},qi=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},r=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(r);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},yd=(n,e,t)=>{const{doc:o=document}=t,s=t.target||o.head,i=s.querySelector(`style[${n}]`)||o.createElement("style");i.setAttribute(n,"true"),i.innerHTML=e,!s.contains(i)&&s.appendChild(i)},bd=(n,e)=>{e.forEach(t=>{const o=dd(t);o!==t&&n.has(o)&&n.set({[t]:n.get(o),[o]:void 0})})},ze="gjs-plg-",Ge="data-type-role",Gi=(...n)=>n.map(e=>`[data-gjs-type="${e}"]`).join(","),vd="dialogComponent",xd=Q(function(n,e={}){const{Blocks:t,Components:o}=n,{licenseKey:s}=e,i="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",u="gjs-plg-dialog-description",h="gjs-plg-dialog-placeholder";t.add(i,{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:i},activate:!0,...e.block}),s.addType(i,{model:{defaults:{tagName:"div",attributes:{class:i,"data-type-role":i},components:[{type:r},{type:h}],draggable:Gi("wrapper"),droppable:Gi(i),styles:`
5
+ `,category:"Extra",content:{type:i},activate:!0,...e.block}),o.addType(i,{model:{defaults:{tagName:"div",attributes:{class:i,"data-type-role":i},components:[{type:r},{type:h}],draggable:Gi("wrapper"),droppable:Gi(i),styles:`
6
6
  .${i} {
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(w){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),C=m.querySelector('[data-type-role="gjs-plg-dialog-close"]');function k(){v.style.display="none"}w?(m._onCloseWhenPressingX=k,C.addEventListener("click",m._onCloseWhenPressingX)):(C.removeEventListener("click",m._onCloseWhenPressingX),m._onCloseWhenPressingX=null)}function b(w){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function C(k){k.key==="Escape"&&(v.style.display="none")}w?(m._onCloseWhenPressingEsc=C,m.addEventListener("keydown",m._onCloseWhenPressingEsc)):(m.removeEventListener("keydown",m._onCloseWhenPressingEsc),m._onCloseWhenPressingEsc=null)}function S(w){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function C(){v.style.display="flex"}w?(m._onOpenWhenLeavingWindow=C,document.addEventListener("mouseleave",m._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",m._onOpenWhenLeavingWindow),m._onOpenWhenLeavingWindow=null)}function y(w){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function C(){const k=document.documentElement.scrollTop;w&&k>=Number(w)&&(v.style.display="flex")}w?(m._onOpenWhenScrollingToLevel=C,document.addEventListener("scroll",m._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",m._onOpenWhenScrollingToLevel),m._onOpenWhenScrollingToLevel=null)}g(p.closeWhenPressingX),b(p.closeWhenPressingEsc),S(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"}}}),s.addType(r,{model:{defaults:{tagName:"div",attributes:{class:r,"data-type-role":r},components:{type:l},droppable:!1,draggable:!1,styles:`
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(x){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),w=m.querySelector('[data-type-role="gjs-plg-dialog-close"]');function C(){v.style.display="none"}x?(m._onCloseWhenPressingX=C,w.addEventListener("click",m._onCloseWhenPressingX)):(w.removeEventListener("click",m._onCloseWhenPressingX),m._onCloseWhenPressingX=null)}function y(x){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function w(C){C.key==="Escape"&&(v.style.display="none")}x?(m._onCloseWhenPressingEsc=w,m.addEventListener("keydown",m._onCloseWhenPressingEsc)):(m.removeEventListener("keydown",m._onCloseWhenPressingEsc),m._onCloseWhenPressingEsc=null)}function S(x){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function w(){v.style.display="flex"}x?(m._onOpenWhenLeavingWindow=w,document.addEventListener("mouseleave",m._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",m._onOpenWhenLeavingWindow),m._onOpenWhenLeavingWindow=null)}function b(x){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function w(){const C=document.documentElement.scrollTop;x&&C>=Number(x)&&(v.style.display="flex")}x?(m._onOpenWhenScrollingToLevel=w,document.addEventListener("scroll",m._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",m._onOpenWhenScrollingToLevel),m._onOpenWhenScrollingToLevel=null)}g(p.closeWhenPressingX),y(p.closeWhenPressingEsc),S(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"}}}),o.addType(r,{model:{defaults:{tagName:"div",attributes:{class:r,"data-type-role":r},components:{type:l},droppable:!1,draggable:!1,styles:`
11
11
  .${r} {
12
12
  position: fixed;
13
13
  top: 0;
@@ -19,7 +19,7 @@
19
19
  justify-content: center;
20
20
  background-color: rgba(0, 0, 0, 0.5);
21
21
  }
22
- `}}}),s.addType(l,{model:{defaults:{tagName:"div",attributes:{class:l,"data-type-role":l},components:[{type:a},{type:c},{type:d}],droppable:!1,draggable:!1,styles:`
22
+ `}}}),o.addType(l,{model:{defaults:{tagName:"div",attributes:{class:l,"data-type-role":l},components:[{type:a},{type:c},{type:d}],droppable:!1,draggable:!1,styles:`
23
23
  .${l} {
24
24
  position: relative;
25
25
  background-color: #fff;
@@ -30,7 +30,7 @@
30
30
  height: 600px;
31
31
  box-sizing: border-box;
32
32
  }
33
- `}}}),s.addType(a,{model:{defaults:{tagName:"button",attributes:{class:a,"data-type-role":a},components:"&times;",droppable:!1,draggable:!1,styles:`
33
+ `}}}),o.addType(a,{model:{defaults:{tagName:"button",attributes:{class:a,"data-type-role":a},components:"&times;",droppable:!1,draggable:!1,styles:`
34
34
  .${a} {
35
35
  position: absolute;
36
36
  top: 10px;
@@ -42,38 +42,38 @@
42
42
  font-size: 20px;
43
43
  cursor: pointer;
44
44
  }
45
- `}}}),s.addType(c,{model:{defaults:{tagName:"h2",attributes:{class:c,"data-type-role":c},components:"Dialog Title",editable:!0,droppable:!1,draggable:!1,styles:`
45
+ `}}}),o.addType(c,{model:{defaults:{tagName:"h2",attributes:{class:c,"data-type-role":c},components:"Dialog Title",editable:!0,droppable:!1,draggable:!1,styles:`
46
46
  .${c} {
47
47
  margin: 0;
48
48
  padding: 0 40px 20px 0;
49
49
  }
50
- `}}}),s.addType(d,{model:{defaults:{tagName:"div",attributes:{class:d,"data-type-role":d},components:[{type:u}],styles:`
50
+ `}}}),o.addType(d,{model:{defaults:{tagName:"div",attributes:{class:d,"data-type-role":d},components:[{type:u}],styles:`
51
51
  .${d} {
52
52
  height: 90%;
53
53
  overflow: auto;
54
54
  }
55
- `}}}),s.addType(u,{model:{defaults:{tagName:"p",attributes:{class:u,"data-type-role":u},components:"This is a customizable dialog!",editable:!0,styles:`
55
+ `}}}),o.addType(u,{model:{defaults:{tagName:"p",attributes:{class:u,"data-type-role":u},components:"This is a customizable dialog!",editable:!0,styles:`
56
56
  .${u} {
57
57
  margin: 0;
58
58
  }
59
- `}}}),s.addType(h,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:h,"data-type-role":h},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=""})}}}),ee({editor:n,licenseKey:o,plan:F.startup,pluginName:bd,cleanup:()=>{t.remove(i),s.removeType(i)}})}),wd={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},eo=`<svg viewBox="0 0 24 24">
59
+ `}}}),o.addType(h,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:h,"data-type-role":h},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=""})}}}),ee({editor:n,licenseKey:s,plan:F.startup,pluginName:vd,cleanup:()=>{t.remove(i),o.removeType(i)}})}),wd={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},es=`<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>`,ji="layout-icon-picker",Sd="icons-layout-",Ki="icons-list-layout",Ji="gs-iconify-picker",to="__iconify_collection",Cd="https://api.iconify.design",no=new Map;let Yn;const xd=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function Ui({collectionId:n,editor:e}){try{if(no.has(n))return no.get(n);const t=await fetch(xd({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const s=await t.json();return no.set(n,s),s}catch(t){console.error("Error fetching collection",t),e.runCommand(B.toastAdd,Pd());return}}async function kd({collectionIds:n,editor:e}){try{if(Yn)return Yn;const t=n?`?prefixes=${n.join(",")}`:"",s=await fetch(`${Cd}/collections${t}`);if(!s.ok)throw new Error(`Failed to fetch collections: ${s.statusText}`);return Yn=await s.json(),Yn}catch(t){console.error("Error fetching collections",t),e.runCommand(B.toastAdd,Yi());return}}function Zi(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function Td({collectionIds:n,editor:e,component:t}){const s=await kd({collectionIds:n,editor:e});if(!s)return;const o=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},i=Object.entries(s).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),r=t.get("collectionId")??i[0].id;e.runCommand(B.layoutToggle,{id:ji,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[Ed({collectionsList:i,collectionId:r,editor:e,handleClick:o}),{id:Ki,type:"column",grow:!0}]}});const l=await Ui({collectionId:r,editor:e});l&&so({editor:e,collection:l,handleClick:o,collectionId:r})}function Md({editor:n,collection:e}){n.em.set(to,e)}function Ad(n){return n.em.get(to)}function so(n){const{editor:e}=n,t={id:Sd,layout:Od(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:Ki}};e.runCommand(B.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>e.runCommand(B.layoutAdd,t),10)}function Ed(n){const{collectionsList:e,collectionId:t,editor:s,handleClick:o}=n,i=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:`${Ji}__header`,children:[{type:"selectField",value:t,options:i,emptyState:"Select an icon collection",onChange:async({setState:r,value:l})=>{const a=await Ui({collectionId:l,editor:s});a&&(r({value:l}),Md({editor:s,collection:a}),so({editor:s,collection:a,handleClick:o,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${to}`]:({setState:r})=>r({value:""})},onInput:({setState:r,value:l,editor:a})=>{const c=Ad(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([u])=>u.includes(l)));r({value:l}),so({editor:a,collection:c,handleClick:o,collectionId:l,collectionFiltered:{...c,icons:d}})}}]}}function Od({collection:n,collectionFiltered:e,handleClick:t}){const{height:s=24,width:o=24,icons:i,prefix:r}=e||n,l=Object.entries(i).map(([a,{body:c}])=>({name:a,body:c}),{});return{type:"column",className:`${Ji}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>[{type:"custom",render:c=>{const{editor:d,addEl:u,removeEl:h}=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} ${s}`);const{cssWidth:p,cssHeight:m}=Nd(o,s);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 S=b.outerHTML;t({icon:S,collectionId:r,iconId:a.name}),d==null||d.runCommand(B.layoutRemove,{id:ji})};return f.addEventListener("click",g),u(f),()=>{f.removeEventListener("click",g),h(f)}}}]}}}function Nd(n,e){const t=n/e;let s=48,o=48;return t>1?o=48/t:t<1&&(s=48*t),{cssWidth:s,cssHeight:o}}function Yi(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:Bi.Error}}function Pd(){return{...Yi(),id:"toast-error-getCollection",content:"Error fetching collection"}}const Id="iconifyComponent",Rd=Q(function(n,e={}){var f;const{Components:t,Blocks:s}=n,{collections:o,extendIconComponent:i=!0,licenseKey:r,block:l={}}=e,a="icon",c="iconify",d="Iconify",u="data-type-iconify",h={events:()=>({dblclick:"onActive"}),onActive(){Td({collectionIds:o,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:eo,content:{type:c},category:"Extra",activate:!0,...l},isComponent:p=>Zn(p,u),model:{defaults:{name:d,icon:eo,droppable:!1,attributes:{[u]:!0},resizable:wd,components:eo,style:{width:"50px",height:"50px"},traits:[Zi()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(p=>p.set({layerable:!1,locked:!0}))}},view:h}),i){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,Zi(),...b]}},view:h})}ee({editor:n,licenseKey:r,plan:F.startup,pluginName:Id,cleanup:()=>{s.remove(c),t.removeType(c)}})});function oo(n,e,t){let s,o,i,r,l;const a=e===void 0?100:e;function c(){const u=Date.now()-r;u<a&&u>=0?s=setTimeout(c,a-u):(s=null,l=n.apply(i,o),i=o=null)}const d=function(){return i=this,o=arguments,r=Date.now(),s||(s=setTimeout(c,a)),l};return d.clear=function(){s&&(clearTimeout(s),s=null)},d.flush=function(){s&&(l=n.apply(i,o),i=o=null,clearTimeout(s),s=null)},d}var O=(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))(O||{});const L={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>'},Ee="table",Xi="thead",Qi="tfoot",io="tbody",ce="row",W="cell",ro="clipboardTable",Dd=[Ee,Xi,Qi,io,ce,W],Xn=n=>n.em.get(ro)||[],zd=n=>n.every(e=>e.is(W)),lo=(n,e)=>{const{editor:t,event:s,opts:o}=n,i=s.currentTarget||s.target,{x:r,y:l,width:a,height:c}=i.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};Un(o.openSettings)?o.openSettings({...n,layoutProps:d}):t.runCommand(B.layoutToggle,d)},Ld=(n,{rows:e=1,cells:t=5,text:s}={})=>({type:n,components:Array.from(Array(e).keys()).map(o=>({type:ce,components:Array.from(Array(t).keys()).map(i=>({type:W,components:s?{type:"text",content:Un(s)?s({y:o,x:i}):s}:void 0}))}))}),er="Table settings",tr=n=>{const{component:e}=n;return e.is(Ee)?e:e.closestType(Ee)},Vd=n=>{var e;(e=tr(n))==null||e.remove(n.opts)},Bd=n=>{const e=tr(n);e&&(n.editor.select(e),lo(n,{id:"tableSettings",header:{label:er}}))},nr=n=>[{id:O.table,icon:L[O.table],label:"Table",items:[{id:O.tableSettings,label:er,icon:L[O.tableSettings],onClick:({event:t})=>Bd({...n,event:t})},{id:O.tableDelete,label:"Delete table",icon:L[O.tableDelete],onClick:()=>Vd(n)}]}],sr=({editor:n})=>{const e=Xn(n);return e.length&&zd(e)},or=({component:n,editor:e,after:t})=>{if(!n.is(W))return;const s=n.closestType(Ee),o=n.closestType(ce),i=n.index()+(t?1:0);s==null||s.findType(ce).forEach(l=>l.append({type:W},{at:i}));const r=o==null?void 0:o.components().at(i);r&&e.select(r)},ir=({component:n,opts:e})=>{if(!n.is(W))return;const t=n.closestType(Ee),s=n.index();t==null||t.findType(ce).forEach(o=>{var i;return(i=o.components().at(s))==null?void 0:i.remove(e)})},rr=({component:n,editor:e})=>{if(!n.is(W))return;const t=n.closestType(Ee),s=n.index(),o=(t==null?void 0:t.findType(ce).map(i=>i.components().at(s)))||[];o.length&&e.em.set(ro,o)},lr=n=>{const{component:e,editor:t,after:s}=n;if(!e.is(W)||!sr(n))return;const o=Xn(t),i=e.closestType(Ee),r=e.index()+(s?1:0);i==null||i.findType(ce).forEach((l,a)=>{const c=o[a],d=(c==null?void 0:c.clone())||{type:W};l.append(d,{at:r})})},Hd=n=>{const{component:e}=n;e.is(W)&&(rr(n),ir({...n,opts:{temporary:!0}}))},$d=n=>{const e=sr(n);return[{id:O.tableColumnItems,icon:L[O.tableColumn],label:"Column",items:[{id:O.tableColumnInsertBefore,label:"Insert column before",icon:L[O.tableColumnInsertBefore],onClick:()=>or(n)},{id:O.tableColumnInsertAfter,label:"Insert column after",icon:L[O.tableColumnInsertAfter],onClick:()=>or({...n,after:!0})},{id:O.tableColumnDelete,label:"Delete column",icon:L[O.tableColumnDelete],onClick:()=>ir(n)},{id:O.tableColumnCut,label:"Cut column",icon:L[O.tableColumnCut],onClick:()=>Hd(n)},{id:O.tableColumnCopy,label:"Copy column",icon:L[O.tableColumnCopy],onClick:()=>rr(n)},{id:O.tableColumnPasteBefore,label:"Paste column before",icon:L[O.tableColumnPasteBefore],disabled:!e,onClick:()=>lr(n)},{id:O.tableColumnPasteAfter,label:"Paste column after",icon:L[O.tableColumnPasteAfter],disabled:!e,onClick:()=>lr({...n,after:!0})}]}]},ar="Row settings",Fd=n=>n.every(e=>e.is(ce)),zt=n=>{const{component:e}=n,t=e.is(W),s=e.is(ce);if(!(!t&&!s))return s?e:e.closestType(ce)},cr=n=>{const{component:e,editor:t,after:s}=n,o=zt(n);if(!o)return;const i=o.index()+(s?1:0),r=o.components().length,l=Array.from(Array(r).keys()).map(()=>({type:W})),a=o.parent();if(a){const c=a.append({type:ce,components:l},{at:i})[0];if(e.is(W)&&c){const d=e.index(),u=c.components().at(d);u&&t.select(u)}}},dr=n=>{var e;(e=zt(n))==null||e.remove(n.opts)},ur=n=>{const e=zt(n);e&&n.editor.em.set(ro,[e])},hr=n=>{var l;const{editor:e,after:t}=n,s=zt(n);if(!s||!fr(n))return;const i=Xn(e)[0],r=s.index()+(t?1:0);i&&((l=s.parent())==null||l.append(i.clone(),{at:r}))},Wd=n=>{zt(n)&&(ur(n),dr({...n,opts:{temporary:!0}}))},fr=({editor:n})=>{const e=Xn(n);return e.length&&Fd(e)},_d=n=>{const e=zt(n);e&&(n.editor.select(e),lo(n,{id:"tableRowSettings",header:{label:ar}}))},pr=n=>{const e=fr(n);return[{id:O.tableRowItems,icon:L[O.tableRowProperties],label:"Row",items:[{id:O.tableRowInsertBefore,label:"Insert row before",icon:L[O.tableRowInsertBefore],onClick:()=>cr(n)},{id:O.tableRowInsertAfter,label:"Insert row after",icon:L[O.tableRowInsertAfter],onClick:()=>cr({...n,after:!0})},{id:O.tableRowDelete,label:"Delete row",icon:L[O.tableRowDelete],onClick:()=>dr(n)},{id:O.tableRowProperties,label:ar,icon:L[O.tableRowProperties],onClick:({event:s})=>_d({...n,event:s})},{id:O.tableRowCut,label:"Cut row",icon:L[O.tableRowCut],onClick:()=>Wd(n)},{id:O.tableRowCopy,label:"Copy row",icon:L[O.tableRowCopy],onClick:()=>ur(n)},{id:O.tableRowPasteBefore,label:"Paste row before",icon:L[O.tableRowPasteBefore],disabled:!e,onClick:()=>hr(n)},{id:O.tableRowPasteAfter,label:"Paste row after",icon:L[O.tableRowPasteAfter],disabled:!e,onClick:()=>hr({...n,after:!0})}]},...nr(n)]},ao=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),s=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:s}};function mr(n){const e=[];return n.components().forEach((t,s)=>{t.components().each((o,i)=>{const{rowspan:r,colspan:l}=ao(o);if(e[s])for(;e[s][i];)i++;for(let a=s;a<s+r;a++){e[a]||(e[a]=[]);for(let c=i;c<i+l;c++)e[a][c]={real:a===s&&c===i,cell:o,rowspan:r,colspan:l}}})}),e}function Lt(n,e,t){var s;return(s=n[t])==null?void 0:s[e]}const co=n=>n.closestType(ce);function qd(n,{x:e,y:t,rows:s,cols:o}){var l;let i=co(n[t][e].cell),r;for(let a=1;a<=s;a++)if(i=(l=i==null?void 0:i.parent())==null?void 0:l.components().at(i.index()+1),i){for(r=e;r>=0;r--){const{cell:c}=n[t+a][r],d=co(c);if(d===i){for(let u=1;u<=o;u++){const h=c.index();d.append({type:W},{at:h+1})}break}}if(r===-1){const d=i.components().at(0).index();for(let u=1;u<=o;u++)i.append({type:W},{at:d})}}}function gr(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:i,colspan:r}=ao(o);if(r>1||i>1){o.addAttributes({colspan:1,rowspan:1});for(let l=0;l<r-1;l++){const a=o.index();co(o).append({type:W},{at:a+1})}qd(n,{x:t,y:e,rows:i-1,cols:r})}}}}function Gd(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const Qn=(n,e={})=>{var r;const t=mr(n),{em:s}=n;let o,i;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)||s.selected.hasComponent(c.cell)){const d={x:a,y:l};o||(o=d),i=d}}return{grid:t,startPos:o,endPos:i}};function jd(n,e={}){const t=Qn(n),{startPos:s,endPos:o}=t;let{grid:i}=t;const{em:r}=n;if(!s||!o)return;const l=s.x,a=s.y,c=o.x,d=o.y,u=Lt(i,l,a),h=Lt(i,c,d);if(u&&h){gr(i),i=mr(n);const f=[],p=Lt(i,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=Lt(i,g,m);if(!b)continue;const{cell:S}=b;S!==p&&f.push(S)}f.forEach(m=>{e.mergeContent&&p.append(m.components().models),m.remove()}),r.setSelected(p),Gd(n)}}const yr="Cell settings",Kd="Merge cells",Jd="Split cell",Ud=n=>n.closestType(ce),Vt=n=>{var e;return(e=Ud(n))==null?void 0:e.parent()},Zd=n=>{const e=n.editor.getSelectedAll(),t=Vt(e[0]),s=e[0];if(!t||!(s!=null&&s.is(W))||e.length>1)return!1;const{rowspan:o,colspan:i}=ao(s);return!(i<2&&o<2)},Yd=n=>{const t=n.editor.getSelectedAll()[0],s=Vt(t),{grid:o}=Qn(s);gr(o)},br=n=>{const e=n.editor.getSelectedAll(),t=Vt(e[0]);if(!t||e.length<2||e.some(l=>!l.is(W)||Vt(l)!==t))return!1;const{grid:s,startPos:o,endPos:i}=Qn(t),{em:r}=t;if(!o||!i)return!1;for(let l=o.y;l<=i.y;l++)for(let a=o.x;a<=i.x;a++){const c=Lt(s,a,l);if(!c||!r.selected.hasComponent(c.cell))return!1}return!0},Xd=n=>{const{editor:e}=n;if(!br(n))return;const t=e.getSelectedAll(),s=Vt(t[0]);jd(s,{mergeContent:!0})},Qd=n=>{lo(n,{id:"tableCellSettings",header:{label:yr}})},eu=n=>[{id:O.tableCellItems,icon:L[O.tableCellProperties],label:"Cell",items:[{id:O.tableCellProperties,label:yr,icon:L[O.tableCellProperties],onClick:({event:t})=>Qd({...n,event:t})},{id:O.tableCellMerge,label:Kd,icon:L[O.tableCellMerge],onClick:()=>Xd(n),disabled:!br(n)},{id:O.tableCellSplit,label:Jd,icon:L[O.tableCellSplit],onClick:()=>Yd(n),disabled:!Zd(n)}]},...$d(n),...pr(n)],tu=n=>{const e=n[0]&&Vt(n[0]);if(!e)return;const{grid:t,startPos:s,endPos:o}=Qn(e,{selected:n});if(!s||!o)return;const i=[];for(let r=s.y;r<=o.y;r++)for(let l=s.x;l<=o.x;l++){const a=Lt(t,l,r);a&&i.push(a.cell)}i.length&&e.em.setSelected(i,{fromCell:!0})},nu="tableComponent",su=Q(function(n,e={}){const t={block:{},...e},{Components:s}=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"]};s.addType(Ee,{block:t.block&&{label:"Table",media:L.table,category:"Extra",content:{type:Ee,style:{width:"100%"}},select:!0,...t.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:L.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:Ld(io,{rows:5}),contextMenu:({items:r,editor:l,component:a})=>[...nr({editor:l,component:a,opts:t}),...r]}}}),s.addType(Xi,{model:{defaults:{icon:L.tableHead,...o}}}),s.addType(Qi,{model:{defaults:{icon:L.tableFoot,...o}}}),s.addType(io,{model:{defaults:{icon:L.tableRowProperties,...o}}}),s.addType(ce,{model:{defaults:{icon:L.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:r,editor:l,component:a})=>[...pr({editor:l,component:a,opts:t}),...r]}}}),s.addType(W,{model:{defaults:{icon:L.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background","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})=>[...eu({editor:l,component:a,opts:t}),...r]}}});const i=oo((r,l)=>{var u;const a=n.getSelectedAll(),c=!!((u=l==null?void 0:l.event)!=null&&u.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(h=>h.is(W)?h:h.closestType(W)).filter(Boolean);d.length===a.length&&tu(d)},0);n.on("component:select",i),ee({editor:n,plan:F.startup,licenseKey:t.licenseKey,pluginName:nu,cleanup:()=>{n.off("component:select",i),n.Blocks.remove(Ee),Dd.forEach(r=>s.removeType(r))}})}),vr="page://",ut="list-pages",Bt="list-pages-item",ht="list-pages-link",ou=n=>n.components().reduce((e,t)=>{var r;const s=t.findFirstType(ht),o=(r=s==null?void 0:s.attributes.attributes)==null?void 0:r.href,i=o!=null&&o.startsWith(vr)?o.replace(vr,""):"";if(i&&s){const l=e[i];l?l.push(s):e[i]=[s]}return e},{}),iu="listPagesComponent",es="data-type-role",ru="page_root",lu=n=>e=>e.is(n),au=n=>(e,t)=>t.is(n),uo=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,es))===n},cu=Q(function(n,e={}){const{Blocks:t,Components:s,Pages:o}=n,{licenseKey:i,block:r={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${ze}${ut}`,u=`${ze}${ht}`,h='<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>';s.addType(ut,{block:r&&{label:l,media:h,category:"Extra",select:!0,...e.block},isComponent:uo(ut),model:{defaults:{tagName:"ul",name:l,[ru]:"",classes:d,attributes:{[es]:ut,role:"navigation"},droppable:lu(Bt),styles:`
61
+ </svg>`,ji="layout-icon-picker",Sd="icons-layout-",Ki="icons-list-layout",Ji="gs-iconify-picker",ts="__iconify_collection",Cd="https://api.iconify.design",ns=new Map;let Yn;const kd=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function Ui({collectionId:n,editor:e}){try{if(ns.has(n))return ns.get(n);const t=await fetch(kd({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const o=await t.json();return ns.set(n,o),o}catch(t){console.error("Error fetching collection",t),e.runCommand(B.toastAdd,Id());return}}async function Td({collectionIds:n,editor:e}){try{if(Yn)return Yn;const t=n?`?prefixes=${n.join(",")}`:"",o=await fetch(`${Cd}/collections${t}`);if(!o.ok)throw new Error(`Failed to fetch collections: ${o.statusText}`);return Yn=await o.json(),Yn}catch(t){console.error("Error fetching collections",t),e.runCommand(B.toastAdd,Yi());return}}function Zi(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function Md({collectionIds:n,editor:e,component:t}){const o=await Td({collectionIds:n,editor:e});if(!o)return;const s=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},i=Object.entries(o).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),r=t.get("collectionId")??i[0].id;e.runCommand(B.layoutToggle,{id:ji,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[Od({collectionsList:i,collectionId:r,editor:e,handleClick:s}),{id:Ki,type:"column",grow:!0}]}});const l=await Ui({collectionId:r,editor:e});l&&ss({editor:e,collection:l,handleClick:s,collectionId:r})}function Ad({editor:n,collection:e}){n.em.set(ts,e)}function Ed(n){return n.em.get(ts)}function ss(n){const{editor:e}=n,t={id:Sd,layout:Nd(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:Ki}};e.runCommand(B.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>e.runCommand(B.layoutAdd,t),10)}function Od(n){const{collectionsList:e,collectionId:t,editor:o,handleClick:s}=n,i=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:`${Ji}__header`,children:[{type:"selectField",value:t,options:i,emptyState:"Select an icon collection",onChange:async({setState:r,value:l})=>{const a=await Ui({collectionId:l,editor:o});a&&(r({value:l}),Ad({editor:o,collection:a}),ss({editor:o,collection:a,handleClick:s,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${ts}`]:({setState:r})=>r({value:""})},onInput:({setState:r,value:l,editor:a})=>{const c=Ed(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([u])=>u.includes(l)));r({value:l}),ss({editor:a,collection:c,handleClick:s,collectionId:l,collectionFiltered:{...c,icons:d}})}}]}}function Nd({collection:n,collectionFiltered:e,handleClick:t}){const{height:o=24,width:s=24,icons:i,prefix:r}=e||n,l=Object.entries(i).map(([a,{body:c}])=>({name:a,body:c}),{});return{type:"column",className:`${Ji}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>[{type:"custom",render:c=>{const{editor:d,addEl:u,removeEl:h}=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 ${s} ${o}`);const{cssWidth:p,cssHeight:m}=Pd(s,o);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 S=y.outerHTML;t({icon:S,collectionId:r,iconId:a.name}),d==null||d.runCommand(B.layoutRemove,{id:ji})};return f.addEventListener("click",g),u(f),()=>{f.removeEventListener("click",g),h(f)}}}]}}}function Pd(n,e){const t=n/e;let o=48,s=48;return t>1?s=48/t:t<1&&(o=48*t),{cssWidth:o,cssHeight:s}}function Yi(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:Bi.Error}}function Id(){return{...Yi(),id:"toast-error-getCollection",content:"Error fetching collection"}}const Rd="iconifyComponent",Dd=Q(function(n,e={}){var f;const{Components:t,Blocks:o}=n,{collections:s,extendIconComponent:i=!0,licenseKey:r,block:l={}}=e,a="icon",c="iconify",d="Iconify",u="data-type-iconify",h={events:()=>({dblclick:"onActive"}),onActive(){Md({collectionIds:s,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:es,content:{type:c},category:"Extra",activate:!0,...l},isComponent:p=>Zn(p,u),model:{defaults:{name:d,icon:es,droppable:!1,attributes:{[u]:!0},resizable:wd,components:es,style:{width:"50px",height:"50px"},traits:[Zi()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(p=>p.set({layerable:!1,locked:!0}))}},view:h}),i){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,Zi(),...y]}},view:h})}ee({editor:n,licenseKey:r,plan:F.startup,pluginName:Rd,cleanup:()=>{o.remove(c),t.removeType(c)}})});function is(n,e,t){let o,s,i,r,l;const a=e===void 0?100:e;function c(){const u=Date.now()-r;u<a&&u>=0?o=setTimeout(c,a-u):(o=null,l=n.apply(i,s),i=s=null)}const d=function(){return i=this,s=arguments,r=Date.now(),o||(o=setTimeout(c,a)),l};return d.clear=function(){o&&(clearTimeout(o),o=null)},d.flush=function(){o&&(l=n.apply(i,s),i=s=null,clearTimeout(o),o=null)},d}var O=(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))(O||{});const L={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>'},Ee="table",Xi="thead",Qi="tfoot",rs="tbody",ce="row",_="cell",ls="clipboardTable",zd=[Ee,Xi,Qi,rs,ce,_],Xn=n=>n.em.get(ls)||[],Ld=n=>n.every(e=>e.is(_)),as=(n,e)=>{const{editor:t,event:o,opts:s}=n,i=o.currentTarget||o.target,{x:r,y:l,width:a,height:c}=i.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};Un(s.openSettings)?s.openSettings({...n,layoutProps:d}):t.runCommand(B.layoutToggle,d)},Vd=(n,{rows:e=1,cells:t=5,text:o}={})=>({type:n,components:Array.from(Array(e).keys()).map(s=>({type:ce,components:Array.from(Array(t).keys()).map(i=>({type:_,components:o?{type:"text",content:Un(o)?o({y:s,x:i}):o}:void 0}))}))}),er="Table settings",tr=n=>{const{component:e}=n;return e.is(Ee)?e:e.closestType(Ee)},Bd=n=>{var e;(e=tr(n))==null||e.remove(n.opts)},Hd=n=>{const e=tr(n);e&&(n.editor.select(e),as(n,{id:"tableSettings",header:{label:er}}))},nr=n=>[{id:O.table,icon:L[O.table],label:"Table",items:[{id:O.tableSettings,label:er,icon:L[O.tableSettings],onClick:({event:t})=>Hd({...n,event:t})},{id:O.tableDelete,label:"Delete table",icon:L[O.tableDelete],onClick:()=>Bd(n)}]}],or=({editor:n})=>{const e=Xn(n);return e.length&&Ld(e)},sr=({component:n,editor:e,after:t})=>{if(!n.is(_))return;const o=n.closestType(Ee),s=n.closestType(ce),i=n.index()+(t?1:0);o==null||o.findType(ce).forEach(l=>l.append({type:_},{at:i}));const r=s==null?void 0:s.components().at(i);r&&e.select(r)},ir=({component:n,opts:e})=>{if(!n.is(_))return;const t=n.closestType(Ee),o=n.index();t==null||t.findType(ce).forEach(s=>{var i;return(i=s.components().at(o))==null?void 0:i.remove(e)})},rr=({component:n,editor:e})=>{if(!n.is(_))return;const t=n.closestType(Ee),o=n.index(),s=(t==null?void 0:t.findType(ce).map(i=>i.components().at(o)))||[];s.length&&e.em.set(ls,s)},lr=n=>{const{component:e,editor:t,after:o}=n;if(!e.is(_)||!or(n))return;const s=Xn(t),i=e.closestType(Ee),r=e.index()+(o?1:0);i==null||i.findType(ce).forEach((l,a)=>{const c=s[a],d=(c==null?void 0:c.clone())||{type:_};l.append(d,{at:r})})},$d=n=>{const{component:e}=n;e.is(_)&&(rr(n),ir({...n,opts:{temporary:!0}}))},Fd=n=>{const e=or(n);return[{id:O.tableColumnItems,icon:L[O.tableColumn],label:"Column",items:[{id:O.tableColumnInsertBefore,label:"Insert column before",icon:L[O.tableColumnInsertBefore],onClick:()=>sr(n)},{id:O.tableColumnInsertAfter,label:"Insert column after",icon:L[O.tableColumnInsertAfter],onClick:()=>sr({...n,after:!0})},{id:O.tableColumnDelete,label:"Delete column",icon:L[O.tableColumnDelete],onClick:()=>ir(n)},{id:O.tableColumnCut,label:"Cut column",icon:L[O.tableColumnCut],onClick:()=>$d(n)},{id:O.tableColumnCopy,label:"Copy column",icon:L[O.tableColumnCopy],onClick:()=>rr(n)},{id:O.tableColumnPasteBefore,label:"Paste column before",icon:L[O.tableColumnPasteBefore],disabled:!e,onClick:()=>lr(n)},{id:O.tableColumnPasteAfter,label:"Paste column after",icon:L[O.tableColumnPasteAfter],disabled:!e,onClick:()=>lr({...n,after:!0})}]}]},ar="Row settings",_d=n=>n.every(e=>e.is(ce)),zt=n=>{const{component:e}=n,t=e.is(_),o=e.is(ce);if(!(!t&&!o))return o?e:e.closestType(ce)},cr=n=>{const{component:e,editor:t,after:o}=n,s=zt(n);if(!s)return;const i=s.index()+(o?1:0),r=s.components().length,l=Array.from(Array(r).keys()).map(()=>({type:_})),a=s.parent();if(a){const c=a.append({type:ce,components:l},{at:i})[0];if(e.is(_)&&c){const d=e.index(),u=c.components().at(d);u&&t.select(u)}}},dr=n=>{var e;(e=zt(n))==null||e.remove(n.opts)},ur=n=>{const e=zt(n);e&&n.editor.em.set(ls,[e])},hr=n=>{var l;const{editor:e,after:t}=n,o=zt(n);if(!o||!fr(n))return;const i=Xn(e)[0],r=o.index()+(t?1:0);i&&((l=o.parent())==null||l.append(i.clone(),{at:r}))},Wd=n=>{zt(n)&&(ur(n),dr({...n,opts:{temporary:!0}}))},fr=({editor:n})=>{const e=Xn(n);return e.length&&_d(e)},qd=n=>{const e=zt(n);e&&(n.editor.select(e),as(n,{id:"tableRowSettings",header:{label:ar}}))},pr=n=>{const e=fr(n);return[{id:O.tableRowItems,icon:L[O.tableRowProperties],label:"Row",items:[{id:O.tableRowInsertBefore,label:"Insert row before",icon:L[O.tableRowInsertBefore],onClick:()=>cr(n)},{id:O.tableRowInsertAfter,label:"Insert row after",icon:L[O.tableRowInsertAfter],onClick:()=>cr({...n,after:!0})},{id:O.tableRowDelete,label:"Delete row",icon:L[O.tableRowDelete],onClick:()=>dr(n)},{id:O.tableRowProperties,label:ar,icon:L[O.tableRowProperties],onClick:({event:o})=>qd({...n,event:o})},{id:O.tableRowCut,label:"Cut row",icon:L[O.tableRowCut],onClick:()=>Wd(n)},{id:O.tableRowCopy,label:"Copy row",icon:L[O.tableRowCopy],onClick:()=>ur(n)},{id:O.tableRowPasteBefore,label:"Paste row before",icon:L[O.tableRowPasteBefore],disabled:!e,onClick:()=>hr(n)},{id:O.tableRowPasteAfter,label:"Paste row after",icon:L[O.tableRowPasteAfter],disabled:!e,onClick:()=>hr({...n,after:!0})}]},...nr(n)]},cs=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),o=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:o}};function mr(n){const e=[];return n.components().forEach((t,o)=>{t.components().each((s,i)=>{const{rowspan:r,colspan:l}=cs(s);if(e[o])for(;e[o][i];)i++;for(let a=o;a<o+r;a++){e[a]||(e[a]=[]);for(let c=i;c<i+l;c++)e[a][c]={real:a===o&&c===i,cell:s,rowspan:r,colspan:l}}})}),e}function Lt(n,e,t){var o;return(o=n[t])==null?void 0:o[e]}const ds=n=>n.closestType(ce);function Gd(n,{x:e,y:t,rows:o,cols:s}){var l;let i=ds(n[t][e].cell),r;for(let a=1;a<=o;a++)if(i=(l=i==null?void 0:i.parent())==null?void 0:l.components().at(i.index()+1),i){for(r=e;r>=0;r--){const{cell:c}=n[t+a][r],d=ds(c);if(d===i){for(let u=1;u<=s;u++){const h=c.index();d.append({type:_},{at:h+1})}break}}if(r===-1){const d=i.components().at(0).index();for(let u=1;u<=s;u++)i.append({type:_},{at:d})}}}function gr(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const s=n[e][t].cell;if(s.em.selected.hasComponent(s)){const{rowspan:i,colspan:r}=cs(s);if(r>1||i>1){s.addAttributes({colspan:1,rowspan:1});for(let l=0;l<r-1;l++){const a=s.index();ds(s).append({type:_},{at:a+1})}Gd(n,{x:t,y:e,rows:i-1,cols:r})}}}}function jd(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const Qn=(n,e={})=>{var r;const t=mr(n),{em:o}=n;let s,i;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)||o.selected.hasComponent(c.cell)){const d={x:a,y:l};s||(s=d),i=d}}return{grid:t,startPos:s,endPos:i}};function Kd(n,e={}){const t=Qn(n),{startPos:o,endPos:s}=t;let{grid:i}=t;const{em:r}=n;if(!o||!s)return;const l=o.x,a=o.y,c=s.x,d=s.y,u=Lt(i,l,a),h=Lt(i,c,d);if(u&&h){gr(i),i=mr(n);const f=[],p=Lt(i,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=Lt(i,g,m);if(!y)continue;const{cell:S}=y;S!==p&&f.push(S)}f.forEach(m=>{e.mergeContent&&p.append(m.components().models),m.remove()}),r.setSelected(p),jd(n)}}const yr="Cell settings",Jd="Merge cells",Ud="Split cell",Zd=n=>n.closestType(ce),Vt=n=>{var e;return(e=Zd(n))==null?void 0:e.parent()},Yd=n=>{const e=n.editor.getSelectedAll(),t=Vt(e[0]),o=e[0];if(!t||!(o!=null&&o.is(_))||e.length>1)return!1;const{rowspan:s,colspan:i}=cs(o);return!(i<2&&s<2)},Xd=n=>{const t=n.editor.getSelectedAll()[0],o=Vt(t),{grid:s}=Qn(o);gr(s)},br=n=>{const e=n.editor.getSelectedAll(),t=Vt(e[0]);if(!t||e.length<2||e.some(l=>!l.is(_)||Vt(l)!==t))return!1;const{grid:o,startPos:s,endPos:i}=Qn(t),{em:r}=t;if(!s||!i)return!1;for(let l=s.y;l<=i.y;l++)for(let a=s.x;a<=i.x;a++){const c=Lt(o,a,l);if(!c||!r.selected.hasComponent(c.cell))return!1}return!0},Qd=n=>{const{editor:e}=n;if(!br(n))return;const t=e.getSelectedAll(),o=Vt(t[0]);Kd(o,{mergeContent:!0})},eu=n=>{as(n,{id:"tableCellSettings",header:{label:yr}})},tu=n=>[{id:O.tableCellItems,icon:L[O.tableCellProperties],label:"Cell",items:[{id:O.tableCellProperties,label:yr,icon:L[O.tableCellProperties],onClick:({event:t})=>eu({...n,event:t})},{id:O.tableCellMerge,label:Jd,icon:L[O.tableCellMerge],onClick:()=>Qd(n),disabled:!br(n)},{id:O.tableCellSplit,label:Ud,icon:L[O.tableCellSplit],onClick:()=>Xd(n),disabled:!Yd(n)}]},...Fd(n),...pr(n)],nu=n=>{const e=n[0]&&Vt(n[0]);if(!e)return;const{grid:t,startPos:o,endPos:s}=Qn(e,{selected:n});if(!o||!s)return;const i=[];for(let r=o.y;r<=s.y;r++)for(let l=o.x;l<=s.x;l++){const a=Lt(t,l,r);a&&i.push(a.cell)}i.length&&e.em.setSelected(i,{fromCell:!0})},ou="tableComponent",su=Q(function(n,e={}){const t={block:{},...e},{Components:o}=n,s={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"]};o.addType(Ee,{block:t.block&&{label:"Table",media:L.table,category:"Extra",content:{type:Ee,style:{width:"100%"}},select:!0,...t.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:L.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:Vd(rs,{rows:5}),contextMenu:({items:r,editor:l,component:a})=>[...nr({editor:l,component:a,opts:t}),...r]}}}),o.addType(Xi,{model:{defaults:{icon:L.tableHead,...s}}}),o.addType(Qi,{model:{defaults:{icon:L.tableFoot,...s}}}),o.addType(rs,{model:{defaults:{icon:L.tableRowProperties,...s}}}),o.addType(ce,{model:{defaults:{icon:L.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:r,editor:l,component:a})=>[...pr({editor:l,component:a,opts:t}),...r]}}}),o.addType(_,{model:{defaults:{icon:L.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background","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})=>[...tu({editor:l,component:a,opts:t}),...r]}}});const i=is((r,l)=>{var u;const a=n.getSelectedAll(),c=!!((u=l==null?void 0:l.event)!=null&&u.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(h=>h.is(_)?h:h.closestType(_)).filter(Boolean);d.length===a.length&&nu(d)},0);n.on("component:select",i),ee({editor:n,plan:F.startup,licenseKey:t.licenseKey,pluginName:ou,cleanup:()=>{n.off("component:select",i),n.Blocks.remove(Ee),zd.forEach(r=>o.removeType(r))}})}),vr="page://",ut="list-pages",Bt="list-pages-item",ht="list-pages-link",iu=n=>n.components().reduce((e,t)=>{var r;const o=t.findFirstType(ht),s=(r=o==null?void 0:o.attributes.attributes)==null?void 0:r.href,i=s!=null&&s.startsWith(vr)?s.replace(vr,""):"";if(i&&o){const l=e[i];l?l.push(o):e[i]=[o]}return e},{}),ru="listPagesComponent",eo="data-type-role",lu="page_root",au=n=>e=>e.is(n),cu=n=>(e,t)=>t.is(n),us=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,eo))===n},du=Q(function(n,e={}){const{Blocks:t,Components:o,Pages:s}=n,{licenseKey:i,block:r={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${ze}${ut}`,u=`${ze}${ht}`,h='<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>';o.addType(ut,{block:r&&{label:l,media:h,category:"Extra",select:!0,...e.block},isComponent:us(ut),model:{defaults:{tagName:"ul",name:l,[lu]:"",classes:d,attributes:{[eo]:ut,role:"navigation"},droppable:au(Bt),styles:`
62
62
  .${d} {
63
63
  list-style: none;
64
64
  margin: 0;
65
65
  padding: 0;
66
66
  }
67
- `},init(){this.syncPageItems=oo(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=ou(this);p.forEach((b,S)=>{const y=b.id,w=b.getName(),v=g[y];v?v==null||v.forEach(C=>{C.getInnerHTML()!==w&&C.components(w)}):m.add({type:Bt,components:[{type:ht,attributes:{href:`page://${y}`},components:{type:"textnode",content:w}}]},{at:S})})}}}),s.addType(Bt,{isComponent:uo(Bt),model:{defaults:{name:a,tagName:"li",icon:f,attributes:{[es]:Bt},components:{type:ht},draggable:au(ut)}}}),s.addType(ht,{extend:"link",isComponent:uo(ht),model:{defaults:{removable:!1,copyable:!1,delegate:{move:p=>p.closestType(Bt)},name:c,classes:u,attributes:{[es]:ht},components:{type:"textnode",content:"Item"},styles:`
67
+ `},init(){this.syncPageItems=is(this.syncPageItems.bind(this),0),this.listenTo(this.em,s.events.all,this.syncPageItems),this.syncPageItems()},syncPageItems(){if(n.Components.getSymbolInfo(this).isInstance)return;const p=this.em.Pages.getAll(),m=this.components(),g=iu(this);p.forEach((y,S)=>{const b=y.id,x=y.getName(),v=g[b];v?v==null||v.forEach(w=>{w.getInnerHTML()!==x&&w.components(x)}):m.add({type:Bt,components:[{type:ht,attributes:{href:`page://${b}`},components:{type:"textnode",content:x}}]},{at:S})})}}}),o.addType(Bt,{isComponent:us(Bt),model:{defaults:{name:a,tagName:"li",icon:f,attributes:{[eo]:Bt},components:{type:ht},draggable:cu(ut)}}}),o.addType(ht,{extend:"link",isComponent:us(ht),model:{defaults:{removable:!1,copyable:!1,delegate:{move:p=>p.closestType(Bt)},name:c,classes:u,attributes:{[eo]:ht},components:{type:"textnode",content:"Item"},styles:`
68
68
  .${u} {
69
69
  text-decoration: none;
70
70
  }
71
- `}}}),ee({editor:n,licenseKey:i,plan:F.startup,pluginName:iu,cleanup:()=>{t.remove(ut),s.removeType(ut)}})}),du="fsLightboxComponent",ts="data-fslightbox",ns="data-type",uu="fslightbox-open",Ht="fslightbox",$t={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>'},hu=Q(function(n,e={}){const{Blocks:t,Components:s}=n,o="Lightbox",i=`${ze}${Ht}`,r={toolbarIconOpen:$t.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(S){const y=this,w="data-fslightbox",v=window,C=()=>{var A;const k=v.refreshFsLightbox;k==null||k();const E=y.getAttribute(w);if((A=v.fsLightboxInstances)==null||A[E],!v._isEditor)return;Array.from(document.querySelectorAll(`[${w}]`)).forEach(P=>{const D=P.onclick;P.onclick=function(z){z.preventDefault();const H=P;!H.__skipLb&&(D==null||D(z)),H.__skipLb=!0}})};if(v.refreshFsLightbox)C();else{const k=document.createElement("script");k.src=S.cdnScript,k.onload=C,document.head.appendChild(k)}},u=S=>({id:`${Ht}-open-lb`,label:a,command:()=>{const y=S.getView();y==null||y.toggleLightbox()}}),h="source-type",f={type:"radio",name:h,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:$t.image},{id:"video",label:"Video",icon:$t.video},{id:"el",label:"Custom Element",icon:$t.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]};s.addType(Ht,{block:l&&{label:o,media:$t.imageLightbox,category:"Extra",select:!0,...r.block},isComponent:S=>{var y;return(y=S.hasAttribute)==null?void 0:y.call(S,ts)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:o,icon:$t.imageLightbox,classes:i,draggable:(S,y)=>!y.is(Ht),attributes:{[ts]:"lightbox",[ns]:"image",href:c},components:{type:"image",src:c},script:d,cdnScript:r.cdnScript,"script-props":["attributes","cdnScript"],[h]:"image",traits:[f,{name:ts,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(S,y){var v;const w=(v=y.target)==null?void 0:v.getView();w==null||w.toggleLightbox()}}],styles:`
71
+ `}}}),ee({editor:n,licenseKey:i,plan:F.startup,pluginName:ru,cleanup:()=>{t.remove(ut),o.removeType(ut)}})}),uu="fsLightboxComponent",to="data-fslightbox",no="data-type",hu="fslightbox-open",Ht="fslightbox",$t={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>'},fu=Q(function(n,e={}){const{Blocks:t,Components:o}=n,s="Lightbox",i=`${ze}${Ht}`,r={toolbarIconOpen:$t.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(S){const b=this,x="data-fslightbox",v=window,w=()=>{var A;const C=v.refreshFsLightbox;C==null||C();const E=b.getAttribute(x);if((A=v.fsLightboxInstances)==null||A[E],!v._isEditor)return;Array.from(document.querySelectorAll(`[${x}]`)).forEach(P=>{const D=P.onclick;P.onclick=function(z){z.preventDefault();const H=P;!H.__skipLb&&(D==null||D(z)),H.__skipLb=!0}})};if(v.refreshFsLightbox)w();else{const C=document.createElement("script");C.src=S.cdnScript,C.onload=w,document.head.appendChild(C)}},u=S=>({id:`${Ht}-open-lb`,label:a,command:()=>{const b=S.getView();b==null||b.toggleLightbox()}}),h="source-type",f={type:"radio",name:h,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:$t.image},{id:"video",label:"Video",icon:$t.video},{id:"el",label:"Custom Element",icon:$t.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]};o.addType(Ht,{block:l&&{label:s,media:$t.imageLightbox,category:"Extra",select:!0,...r.block},isComponent:S=>{var b;return(b=S.hasAttribute)==null?void 0:b.call(S,to)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:s,icon:$t.imageLightbox,classes:i,draggable:(S,b)=>!b.is(Ht),attributes:{[to]:"lightbox",[no]:"image",href:c},components:{type:"image",src:c},script:d,cdnScript:r.cdnScript,"script-props":["attributes","cdnScript"],[h]:"image",traits:[f,{name:to,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(S,b){var v;const x=(v=b.target)==null?void 0:v.getView();x==null||x.toggleLightbox()}}],styles:`
72
72
  .${i} {
73
73
  display: inline-block;
74
74
  padding: 10px;
75
75
  }
76
- `},init(){const S=[h].map(y=>`change:${y}`).join(" ");this.on(S,this.updateTraits),this.on(`change:${h}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(S,y,w){if(w.adjust)return;const C=this.get(h)==="video"?"video":"image";this.addAttributes({[ns]:C,href:""})},adjustSourceType(){const S=this.get(h),y=this.getAttributes().href||"",w={adjust:!0};if(S==="video"){const v=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[ns]:v},w)}else S!=="el"&&y.startsWith("#")?this.set(h,"el",w):S==="image"&&this.addAttributes({[ns]:"image"},w)},updateTraits(S={}){const{changed:y}=this,{init:w}=S;if(y[f.name]||w){this.removeTrait([p.name,m.name,g.name]);const v=this.get(h)||"image",C=this.getTraitIndex(h)+1;this.addTrait(b[v],{at:C})}},initToolbar(){if(!a)return;const{toolbar:S}=this,y=u(this);!S.find(v=>v.id===y.id)&&(S==null||S.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:S,el:y,model:w}=this,{Canvas:v}=S,C=w.getAttributes()[ts],{defaultView:k,documentElement:E}=y.ownerDocument,T=(P=k.fsLightboxInstances)==null?void 0:P[C];if(E.classList.contains(uu))T.close();else{y.__skipLb=!1;let D;T.props.onOpen=()=>{D=v.getSpots(),setTimeout(()=>v.removeSpots())},T.props.onClose=()=>{D.forEach(z=>v.addSpot(z.attributes))},y.click()}}}}),ee({editor:n,plan:F.startup,licenseKey:r.licenseKey,pluginName:du,cleanup:()=>{t.remove(Ht),s.removeType(Ht)}})});var Ft=(n=>(n.image="image",n.video="video",n.external="external",n))(Ft||{});const ft="lightGallery",wr=`${ft}-item`,ss="data-lightgallery",Sr=`${ss}-item`,is="toggle",pt={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>'},ho={propKeys:[],props:{},traits:[]},un=(n,e={})=>{var o;const t={},s=[];for(const i in n){const{value:r,...l}=n[i];s.push({id:i,name:i,changeProp:!0,category:e.category,...l}),t[i]=r;const{subTraits:a={}}=l;for(const c in l.subTraits)(o=a[c])==null||o.forEach(d=>{const u=d.id||d.name;t[u]=d.value})}return{propKeys:Object.keys(t),props:t,traits:s}},fo=(n,e)=>{const t=n.getTrait(e),s=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:s,...c})),{at:a})},po=(n,e)=>{e.forEach(t=>{const s=n.getTrait(t);if(!s||!s.get("subTraits"))return;const o=s.changeProp?`change:${t}`:`change:attributes:${t}`;n.on(o,()=>fo(n,t)),fo(n,t)})},fu=(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)},pu={[is]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var t,s;return(s=(t=e.target)==null?void 0:t.getView())==null?void 0:s.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}},mu={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"}]}}},gu={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}]}}},yu={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}]}}},je="sourceType",rs="data-iframe",mo={name:"href",type:"file",label:"Image Source"},ls={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},go={name:"data-poster",label:"Video Poster",type:"file"},Cr={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},xr={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},bu={[is]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var o,i;const t=e.target,s=(o=t==null?void 0:t.closestType(ft))==null?void 0:o.getView();if(s&&t){const r=((i=s.getLightGallery())==null?void 0:i.items)||[],l=Array.from(r).indexOf(t.getEl());l>=0&&s.toggleGallery(l)}}},[je]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[mo],video:[ls,go],external:[Cr]},options:[{id:"image",label:mo.label||"",icon:pt.image},{id:"video",label:ls.label||"",icon:pt.video},{id:"external",label:Cr.label||"",icon:pt.external}]},subHtml:xr},vu="lightGalleryComponent",kr="lgThumbnail",wu="lgVideo",Tr="lgAutoplay",Mr="lgZoom",Wt="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Su=Q(function(n,e={}){const{Blocks:t,Components:s}=n,o="LightGallery",i="LightGallery Item",r={toolbarIconOpen:pt.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[kr,wu,Tr,Mr],cdnScript:[`${Wt}/lightgallery.min.js`,`${Wt}/plugins/thumbnail/lg-thumbnail.min.js`,`${Wt}/plugins/video/lg-video.min.js`,`${Wt}/plugins/autoplay/lg-autoplay.min.js`,`${Wt}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${Wt}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=r,d=function(y){const w=this,v=window,{plugins:C,cdnScript:k,cdnStyle:E,inline:T,lgLicenseKey:A,...P}=y||{},D=H=>isNaN(H)?void 0:parseInt(H,10),z=()=>{var Me;const H={...P,licenseKey:A,speed:D(P.speed),startAnimationDuration:D(P.startAnimationDuration),thumbMargin:D(P.thumbMargin),thumbWidth:D(P.thumbWidth),slideShowInterval:D(P.slideShowInterval),scale:D(P.scale),enableZoomAfter:D(P.enableZoomAfter),plugins:(C||[]).map(Rt=>v[Rt])};T&&(H.container=w,H.closable=!1);const Te=(Me=v.lightGallery)==null?void 0:Me.call(v,w,H);T&&Te.openGallery()};if(v.lightGallery)z();else{const{head:H}=document,Te=Array.isArray(k)?[...k]:[k],Me=Array.isArray(E)?[...E]:[E],Rt=X=>{if(X.length){const Ae=document.createElement("link");Ae.href=X.shift(),Ae.rel="stylesheet",H.appendChild(Ae),Rt(X)}},Jn=X=>{if(X.length){const Ae=document.createElement("script");Ae.src=X.shift(),Ae.onerror=Ae.onload=Jn.bind(null,X),H.appendChild(Ae)}else z()};Rt(Me),Jn(Te)}},u=y=>{const w=y.getTrait(is);if(!a||!w)return;const{toolbar:v}=y,C={id:is,label:a,command:()=>setTimeout(()=>w.runCommand(),100)};!v.find(E=>E.id===C.id)&&(v==null||v.unshift(C))};let h=[];const f=r.plugins||[],p=un(pu),m=f.includes(kr)?un(mu):ho,g=f.includes(Tr)?un(gu):ho,b=f.includes(Mr)?un(yu):ho;s.addType(ft,{block:l&&{label:o,media:pt.gallery,category:"Extra",select:!0,...r.block},isComponent:y=>Zn(y,ss),extendFn:["init","initToolbar"],model:{defaults:{name:o,icon:pt.gallery,draggable:(y,w)=>!w.is(ft),attributes:{[ss]:!0},components:{type:wr},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(){po(this,["thumbnail"]),po(this,["autoplay"]),po(this,["zoom"])},initToolbar(){u(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,s.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 w;const y=this.getLightGallery();return((w=y==null?void 0:y.settings)==null?void 0:w.container)===this.el},onLgInit(y){this.el.__lg=y.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:y}=this,{Canvas:w}=y,v=this.getLightGallery();h=w.getSpots(),setTimeout(()=>w.removeSpots()),v.__lgOpened=!0},onLgClose(){const y=this.getLightGallery();h.forEach(w=>this.em.Canvas.addSpot(w.attributes)),h=[],y.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(y){const w=this.getLightGallery();if(w.__lgOpened)return w.closeGallery(!0);w.lgOpened=!1,w.openGallery(y)}}});const S=un(bu);s.addType(wr,{isComponent:y=>Zn(y,Sr)||y.tagName==="A"&&Zn(y.parentElement,ss),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:i,icon:pt.galleryItem,attributes:{[Sr]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...S.props,traits:[...S.traits]},init(){const y=[je].map(w=>`change:${w}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),fu(this,je,this.triggerGalleryUpdate)},initToolbar(){u(this)},initScriptUpdate(){const y=[xr.name].map(w=>`change:attributes:${w}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var w;(w=this.closestType(ft))==null||w.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:w}=this,{init:v}=y;if(w[je]||v){fo(this,je);const C=this.getTrait(je).getValue();if(C===Ft.image){this.removeAttributes([ls.name,go.name,rs]);const k=this.getTrait(mo.name);k.setValue(k.getValue()||c)}else C===Ft.video?this.removeAttributes([rs]):C===Ft.external&&this.addAttributes({[rs]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[rs]?this.set(je,Ft.external):(y[ls.name]||y[go.name])&&this.set(je,Ft.video)}}}),ee({editor:n,plan:F.startup,licenseKey:r.licenseKey,pluginName:vu,cleanup:()=>{t.remove(ft),s.removeType(ft)}})}),we="swiper",hn=`${we}-slide`,_t=`${we}-wrapper`,qt=`${we}-nav-prev`,as=`${we}-nav-next`,Gt=`${we}-pagination`,fn=`${we}-scrollbar`,ie={slider:`<svg viewBox="0 0 24 24">
76
+ `},init(){const S=[h].map(b=>`change:${b}`).join(" ");this.on(S,this.updateTraits),this.on(`change:${h}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(S,b,x){if(x.adjust)return;const w=this.get(h)==="video"?"video":"image";this.addAttributes({[no]:w,href:""})},adjustSourceType(){const S=this.get(h),b=this.getAttributes().href||"",x={adjust:!0};if(S==="video"){const v=b.includes("youtube.com")?"youtube":"video";this.addAttributes({[no]:v},x)}else S!=="el"&&b.startsWith("#")?this.set(h,"el",x):S==="image"&&this.addAttributes({[no]:"image"},x)},updateTraits(S={}){const{changed:b}=this,{init:x}=S;if(b[f.name]||x){this.removeTrait([p.name,m.name,g.name]);const v=this.get(h)||"image",w=this.getTraitIndex(h)+1;this.addTrait(y[v],{at:w})}},initToolbar(){if(!a)return;const{toolbar:S}=this,b=u(this);!S.find(v=>v.id===b.id)&&(S==null||S.unshift(b))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:S,el:b,model:x}=this,{Canvas:v}=S,w=x.getAttributes()[to],{defaultView:C,documentElement:E}=b.ownerDocument,T=(P=C.fsLightboxInstances)==null?void 0:P[w];if(E.classList.contains(hu))T.close();else{b.__skipLb=!1;let D;T.props.onOpen=()=>{D=v.getSpots(),setTimeout(()=>v.removeSpots())},T.props.onClose=()=>{D.forEach(z=>v.addSpot(z.attributes))},b.click()}}}}),ee({editor:n,plan:F.startup,licenseKey:r.licenseKey,pluginName:uu,cleanup:()=>{t.remove(Ht),o.removeType(Ht)}})});var Ft=(n=>(n.image="image",n.video="video",n.external="external",n))(Ft||{});const ft="lightGallery",xr=`${ft}-item`,oo="data-lightgallery",wr=`${oo}-item`,so="toggle",pt={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>'},hs={propKeys:[],props:{},traits:[]},un=(n,e={})=>{var s;const t={},o=[];for(const i in n){const{value:r,...l}=n[i];o.push({id:i,name:i,changeProp:!0,category:e.category,...l}),t[i]=r;const{subTraits:a={}}=l;for(const c in l.subTraits)(s=a[c])==null||s.forEach(d=>{const u=d.id||d.name;t[u]=d.value})}return{propKeys:Object.keys(t),props:t,traits:o}},fs=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},r=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(r);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},ps=(n,e)=>{e.forEach(t=>{const o=n.getTrait(t);if(!o||!o.get("subTraits"))return;const s=o.changeProp?`change:${t}`:`change:attributes:${t}`;n.on(s,()=>fs(n,t)),fs(n,t)})},pu=(n,e,t)=>{const s=n.getTrait(e).get("subTraits")||{},r=(Object.values(s).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)},mu={[so]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var t,o;return(o=(t=e.target)==null?void 0:t.getView())==null?void 0:o.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}},gu={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"}]}}},yu={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}]}}},bu={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}]}}},je="sourceType",io="data-iframe",ms={name:"href",type:"file",label:"Image Source"},ro={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},gs={name:"data-poster",label:"Video Poster",type:"file"},Sr={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},Cr={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},vu={[so]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var s,i;const t=e.target,o=(s=t==null?void 0:t.closestType(ft))==null?void 0:s.getView();if(o&&t){const r=((i=o.getLightGallery())==null?void 0:i.items)||[],l=Array.from(r).indexOf(t.getEl());l>=0&&o.toggleGallery(l)}}},[je]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[ms],video:[ro,gs],external:[Sr]},options:[{id:"image",label:ms.label||"",icon:pt.image},{id:"video",label:ro.label||"",icon:pt.video},{id:"external",label:Sr.label||"",icon:pt.external}]},subHtml:Cr},xu="lightGalleryComponent",kr="lgThumbnail",wu="lgVideo",Tr="lgAutoplay",Mr="lgZoom",_t="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Su=Q(function(n,e={}){const{Blocks:t,Components:o}=n,s="LightGallery",i="LightGallery Item",r={toolbarIconOpen:pt.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[kr,wu,Tr,Mr],cdnScript:[`${_t}/lightgallery.min.js`,`${_t}/plugins/thumbnail/lg-thumbnail.min.js`,`${_t}/plugins/video/lg-video.min.js`,`${_t}/plugins/autoplay/lg-autoplay.min.js`,`${_t}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${_t}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=r,d=function(b){const x=this,v=window,{plugins:w,cdnScript:C,cdnStyle:E,inline:T,lgLicenseKey:A,...P}=b||{},D=H=>isNaN(H)?void 0:parseInt(H,10),z=()=>{var Me;const H={...P,licenseKey:A,speed:D(P.speed),startAnimationDuration:D(P.startAnimationDuration),thumbMargin:D(P.thumbMargin),thumbWidth:D(P.thumbWidth),slideShowInterval:D(P.slideShowInterval),scale:D(P.scale),enableZoomAfter:D(P.enableZoomAfter),plugins:(w||[]).map(Rt=>v[Rt])};T&&(H.container=x,H.closable=!1);const Te=(Me=v.lightGallery)==null?void 0:Me.call(v,x,H);T&&Te.openGallery()};if(v.lightGallery)z();else{const{head:H}=document,Te=Array.isArray(C)?[...C]:[C],Me=Array.isArray(E)?[...E]:[E],Rt=X=>{if(X.length){const Ae=document.createElement("link");Ae.href=X.shift(),Ae.rel="stylesheet",H.appendChild(Ae),Rt(X)}},Jn=X=>{if(X.length){const Ae=document.createElement("script");Ae.src=X.shift(),Ae.onerror=Ae.onload=Jn.bind(null,X),H.appendChild(Ae)}else z()};Rt(Me),Jn(Te)}},u=b=>{const x=b.getTrait(so);if(!a||!x)return;const{toolbar:v}=b,w={id:so,label:a,command:()=>setTimeout(()=>x.runCommand(),100)};!v.find(E=>E.id===w.id)&&(v==null||v.unshift(w))};let h=[];const f=r.plugins||[],p=un(mu),m=f.includes(kr)?un(gu):hs,g=f.includes(Tr)?un(yu):hs,y=f.includes(Mr)?un(bu):hs;o.addType(ft,{block:l&&{label:s,media:pt.gallery,category:"Extra",select:!0,...r.block},isComponent:b=>Zn(b,oo),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:pt.gallery,draggable:(b,x)=>!x.is(ft),attributes:{[oo]:!0},components:{type:xr},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,...y.propKeys],...p.props,...m.props,...g.props,...y.props,traits:[...p.traits,...m.traits,...g.traits,...y.traits]},init(){ps(this,["thumbnail"]),ps(this,["autoplay"]),ps(this,["zoom"])},initToolbar(){u(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,o.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 x;const b=this.getLightGallery();return((x=b==null?void 0:b.settings)==null?void 0:x.container)===this.el},onLgInit(b){this.el.__lg=b.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:b}=this,{Canvas:x}=b,v=this.getLightGallery();h=x.getSpots(),setTimeout(()=>x.removeSpots()),v.__lgOpened=!0},onLgClose(){const b=this.getLightGallery();h.forEach(x=>this.em.Canvas.addSpot(x.attributes)),h=[],b.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(b){const x=this.getLightGallery();if(x.__lgOpened)return x.closeGallery(!0);x.lgOpened=!1,x.openGallery(b)}}});const S=un(vu);o.addType(xr,{isComponent:b=>Zn(b,wr)||b.tagName==="A"&&Zn(b.parentElement,oo),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:i,icon:pt.galleryItem,attributes:{[wr]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...S.props,traits:[...S.traits]},init(){const b=[je].map(x=>`change:${x}`).join(" ");this.initSourceType(),this.on(b,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),pu(this,je,this.triggerGalleryUpdate)},initToolbar(){u(this)},initScriptUpdate(){const b=[Cr.name].map(x=>`change:attributes:${x}`).join(" ");this.on(b,this.triggerGalleryUpdate)},triggerGalleryUpdate(...b){var x;(x=this.closestType(ft))==null||x.__scriptPropsChange(...b)},updateTraits(b={}){const{changed:x}=this,{init:v}=b;if(x[je]||v){fs(this,je);const w=this.getTrait(je).getValue();if(w===Ft.image){this.removeAttributes([ro.name,gs.name,io]);const C=this.getTrait(ms.name);C.setValue(C.getValue()||c)}else w===Ft.video?this.removeAttributes([io]):w===Ft.external&&this.addAttributes({[io]:!0})}},initSourceType(){const b=this.getAttributes({noClass:!0,noStyle:!0});b[io]?this.set(je,Ft.external):(b[ro.name]||b[gs.name])&&this.set(je,Ft.video)}}}),ee({editor:n,plan:F.startup,licenseKey:r.licenseKey,pluginName:xu,cleanup:()=>{t.remove(ft),o.removeType(ft)}})}),xe="swiper",hn=`${xe}-slide`,Wt=`${xe}-wrapper`,qt=`${xe}-nav-prev`,lo=`${xe}-nav-next`,Gt=`${xe}-pagination`,fn=`${xe}-scrollbar`,ie={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,28 +96,28 @@
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>`},Ar={id:"swiper-responsive",label:"Responsive",icon:ie.responsive},Er={id:"swiper-extra",label:"Extra",icon:ie.extra},Cu={actions:{type:"radio",label:!1,labelToTitle:!0,options:[{id:"r",label:"Reload slider",icon:ie.reload},{id:"p",label:"Previous slide",icon:ie.prev},{id:"n",label:"Next slide",icon:ie.next},{id:"a",label:"Add new slide",icon:ie.add}],setValue:({component:n,value:e})=>{var s;const t=(s=n.getView())==null?void 0:s.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(qt),setValue:({component:n,value:e})=>{var t,s;e?n.append([{type:qt},{type:as}]):((t=n.findFirstType(qt))==null||t.remove(),(s=n.findFirstType(as))==null||s.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:ie.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:ie.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:ie.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(Gt)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(Gt);t==null||t.remove(),e!=="none"&&n.append({type:Gt}),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:ie.scrollbar},type:"checkbox",label:"Enable Scrollbar",getValue:({component:n})=>!!n.findFirstType(fn),setValue:({component:n,value:e})=>{const t=n.findFirstType(fn);t==null||t.remove(),e&&n.append({type:fn}),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:ie.parallax},type:"checkbox",label:"Enable Parallax",value:!1},mobile:{category:Ar,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:Ar,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:Er,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:Er,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},Or="Slider",yo="swiper",jt=`${yo}-`,xu=(n,e)=>{const{Components:t,Blocks:s,Commands:o}=n,{block:i}=e,r=md(Cu),l="core:preview",a=o.events,c=function(h){const f=this,p=window,m=f.__onLoad,g=f.__activeSlide,b=f.__inPreview,{cdnScript:S,cdnStyle:y,slidesPerView:w}=h||{},v=k=>isNaN(k)?void 0:parseFloat(k),C=()=>{const k={loop:h.loop,speed:h.speed,initialSlide:h.initialSlide,direction:h.vertical?"vertical":"horizontal",effect:h.effect,freeMode:h.freeMode,parallax:h.parallax,autoHeight:h.autoHeight,allowTouchMove:h.allowTouchMove,grabCursor:h.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(w)?w:v(w),slidesPerGroup:v(h.slidesPerGroup),spaceBetween:v(h.spaceBetween),slidesOffsetBefore:v(h.slidesOffsetBefore),slidesOffsetAfter:v(h.slidesOffsetAfter),centeredSlides:h.centeredSlides,fadeEffect:{crossFade:h.crossFade},cubeEffect:{shadow:h.cubeEffectShadow,slideShadows:h.cubeEffectSlideShadows,shadowOffset:v(h.cubeEffectShadowOffset),shadowScale:v(h.cubeEffectShadowScale)},coverflowEffect:{depth:v(h.coverflowEffectDepth),modifier:v(h.coverflowEffectModifier),rotate:v(h.coverflowEffectRotate),scale:v(h.coverflowEffectScale),stretch:v(h.coverflowEffectStretch),slideShadows:h.coverflowEffectSlideShadows},flipEffect:{limitRotation:h.flipEffectLimitRotation,slideShadows:h.flipEffectSlideShadows},cardsEffect:{perSlideOffset:v(h.cardsEffectPerSlideOffset),perSlideRotate:v(h.cardsEffectPerSlideRotate),rotate:h.cardsEffectRotate,slideShadows:h.cardsEffectSlideShadows},navigation:{nextEl:f.querySelector(".swiper-button-next"),prevEl:f.querySelector(".swiper-button-prev")},pagination:{type:h.pagination||"bullets",dynamicBullets:h.dynamicBullets,clickable:h.clickableBullets,progressbarOpposite:h.progressbarOpposite,el:f.querySelector(".swiper-pagination")},scrollbar:{el:f.querySelector(".swiper-scrollbar"),draggable:h.scrollbarDraggable,hide:h.scrollbarHide},autoplay:h.autoplay&&{delay:h.autoplayDelay,disableOnInteraction:h.autoplayDisableOnInteraction,pauseOnMouseEnter:h.autoplayPauseOnMouseEnter,reverseDirection:h.autoplayReverseDirection,stopOnLastSlide:h.autoplayStopOnLastSlide,waitForTransition:h.autoplayWaitForTransition}};if(h.tablet){const{tabletBreakpoint:T,tabletSlidesPerView:A}=h,P=v(T);k.breakpoints[P]={slidesPerView:isNaN(A)?A:v(A),slidesPerGroup:v(h.tabletSlidesPerGroup),spaceBetween:v(h.tabletSpaceBetween)}}if(h.mobile){const{mobileBreakpoint:T,mobileSlidesPerView:A}=h,P=v(T);k.breakpoints[P]={slidesPerView:isNaN(A)?A:v(A),slidesPerGroup:v(h.mobileSlidesPerGroup),spaceBetween:v(h.mobileSpaceBetween)}}m&&!b&&(k.simulateTouch=!1),g&&(k.initialSlide=g);const E=new p.Swiper(f,k);m==null||m(E)};if(p.Swiper)C();else{const{head:k}=document,E=Array.isArray(S)?[...S]:[S],T=Array.isArray(y)?[...y]:[y],A=D=>{if(D.length){const z=document.createElement("link");z.href=D.shift(),z.rel="stylesheet",k.appendChild(z),A(D)}},P=D=>{if(D.length){const z=document.createElement("script");z.src=D.shift(),z.onerror=z.onload=P.bind(null,D),k.appendChild(z)}else C()};A(T),P(E)}},d=(h=0)=>({type:hn,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${h}`}}}),u=t.getType("default").model;return t.addType(we,{block:i&&{label:Or,media:ie.slider,category:"Extra",select:!0,...e.block},isComponent:h=>ct(h,yo),model:{defaults:()=>({name:Or,icon:ie.slider,classes:yo,draggable:(h,f)=>!f.is(we),components:[{type:_t,components:[d(1),d(2),d(3)]},{type:Gt}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...r.propKeys],...r.props,traits:[...r.traits]}),init(){const{em:h}=this;gd(this,r.traits),yd(this,r.propKeys),this.listenTo(h,`${a.runCommand}${l}`,this.onPreviewOn),this.listenTo(h,`${a.stopCommand}${l}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const h=this.findFirstType(_t);h==null||h.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var f;const h=((f=this.findFirstType(_t))==null?void 0:f.components().length)||0;return{type:hn,components:{type:"text",components:{type:"textnode",content:`Slide ${h+1}`}}}},toJSON(...h){const f=u.prototype.toJSON.apply(this,h);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 h;(h=this.getSwiper())==null||h.destroy()},onRender(){const h=this.el;h.__onLoad=f=>f.on("slideChange",()=>this.__activeSlide=f.activeIndex),h.__activeSlide=this.__activeSlide,h.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(we),s.remove(we)}},ku="Nav Prev",Tu="Nav Next",cs=`${jt}button-prev`,ds=`${jt}button-next`,Mu=n=>{const{Components:e}=n,t=s=>({type:"svg",selectable:!1,hoverable:!1,attributes:{viewBox:"0 0 27 44"},components:{type:"svg-in",tagName:"path",attributes:{d:s,fill:"currentColor"}}});return e.addType(qt,{isComponent:s=>ct(s,cs),model:{defaults:{name:ku,classes:cs,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
- .${cs} {
99
+ </svg>`},Ar={id:"swiper-responsive",label:"Responsive",icon:ie.responsive},Er={id:"swiper-extra",label:"Extra",icon:ie.extra},Cu={actions:{type:"radio",label:!1,labelToTitle:!0,options:[{id:"r",label:"Reload slider",icon:ie.reload},{id:"p",label:"Previous slide",icon:ie.prev},{id:"n",label:"Next slide",icon:ie.next},{id:"a",label:"Add new slide",icon:ie.add}],setValue:({component:n,value:e})=>{var o;const t=(o=n.getView())==null?void 0:o.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(qt),setValue:({component:n,value:e})=>{var t,o;e?n.append([{type:qt},{type:lo}]):((t=n.findFirstType(qt))==null||t.remove(),(o=n.findFirstType(lo))==null||o.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:ie.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:ie.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:ie.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(Gt)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(Gt);t==null||t.remove(),e!=="none"&&n.append({type:Gt}),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:ie.scrollbar},type:"checkbox",label:"Enable Scrollbar",getValue:({component:n})=>!!n.findFirstType(fn),setValue:({component:n,value:e})=>{const t=n.findFirstType(fn);t==null||t.remove(),e&&n.append({type:fn}),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:ie.parallax},type:"checkbox",label:"Enable Parallax",value:!1},mobile:{category:Ar,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:Ar,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:Er,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:Er,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},Or="Slider",ys="swiper",jt=`${ys}-`,ku=(n,e)=>{const{Components:t,Blocks:o,Commands:s}=n,{block:i}=e,r=md(Cu),l="core:preview",a=s.events,c=function(h){const f=this,p=window,m=f.__onLoad,g=f.__activeSlide,y=f.__inPreview,{cdnScript:S,cdnStyle:b,slidesPerView:x}=h||{},v=C=>isNaN(C)?void 0:parseFloat(C),w=()=>{const C={loop:h.loop,speed:h.speed,initialSlide:h.initialSlide,direction:h.vertical?"vertical":"horizontal",effect:h.effect,freeMode:h.freeMode,parallax:h.parallax,autoHeight:h.autoHeight,allowTouchMove:h.allowTouchMove,grabCursor:h.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(x)?x:v(x),slidesPerGroup:v(h.slidesPerGroup),spaceBetween:v(h.spaceBetween),slidesOffsetBefore:v(h.slidesOffsetBefore),slidesOffsetAfter:v(h.slidesOffsetAfter),centeredSlides:h.centeredSlides,fadeEffect:{crossFade:h.crossFade},cubeEffect:{shadow:h.cubeEffectShadow,slideShadows:h.cubeEffectSlideShadows,shadowOffset:v(h.cubeEffectShadowOffset),shadowScale:v(h.cubeEffectShadowScale)},coverflowEffect:{depth:v(h.coverflowEffectDepth),modifier:v(h.coverflowEffectModifier),rotate:v(h.coverflowEffectRotate),scale:v(h.coverflowEffectScale),stretch:v(h.coverflowEffectStretch),slideShadows:h.coverflowEffectSlideShadows},flipEffect:{limitRotation:h.flipEffectLimitRotation,slideShadows:h.flipEffectSlideShadows},cardsEffect:{perSlideOffset:v(h.cardsEffectPerSlideOffset),perSlideRotate:v(h.cardsEffectPerSlideRotate),rotate:h.cardsEffectRotate,slideShadows:h.cardsEffectSlideShadows},navigation:{nextEl:f.querySelector(".swiper-button-next"),prevEl:f.querySelector(".swiper-button-prev")},pagination:{type:h.pagination||"bullets",dynamicBullets:h.dynamicBullets,clickable:h.clickableBullets,progressbarOpposite:h.progressbarOpposite,el:f.querySelector(".swiper-pagination")},scrollbar:{el:f.querySelector(".swiper-scrollbar"),draggable:h.scrollbarDraggable,hide:h.scrollbarHide},autoplay:h.autoplay&&{delay:h.autoplayDelay,disableOnInteraction:h.autoplayDisableOnInteraction,pauseOnMouseEnter:h.autoplayPauseOnMouseEnter,reverseDirection:h.autoplayReverseDirection,stopOnLastSlide:h.autoplayStopOnLastSlide,waitForTransition:h.autoplayWaitForTransition}};if(h.tablet){const{tabletBreakpoint:T,tabletSlidesPerView:A}=h,P=v(T);C.breakpoints[P]={slidesPerView:isNaN(A)?A:v(A),slidesPerGroup:v(h.tabletSlidesPerGroup),spaceBetween:v(h.tabletSpaceBetween)}}if(h.mobile){const{mobileBreakpoint:T,mobileSlidesPerView:A}=h,P=v(T);C.breakpoints[P]={slidesPerView:isNaN(A)?A:v(A),slidesPerGroup:v(h.mobileSlidesPerGroup),spaceBetween:v(h.mobileSpaceBetween)}}m&&!y&&(C.simulateTouch=!1),g&&(C.initialSlide=g);const E=new p.Swiper(f,C);m==null||m(E)};if(p.Swiper)w();else{const{head:C}=document,E=Array.isArray(S)?[...S]:[S],T=Array.isArray(b)?[...b]:[b],A=D=>{if(D.length){const z=document.createElement("link");z.href=D.shift(),z.rel="stylesheet",C.appendChild(z),A(D)}},P=D=>{if(D.length){const z=document.createElement("script");z.src=D.shift(),z.onerror=z.onload=P.bind(null,D),C.appendChild(z)}else w()};A(T),P(E)}},d=(h=0)=>({type:hn,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${h}`}}}),u=t.getType("default").model;return t.addType(xe,{block:i&&{label:Or,media:ie.slider,category:"Extra",select:!0,...e.block},isComponent:h=>ct(h,ys),model:{defaults:()=>({name:Or,icon:ie.slider,classes:ys,draggable:(h,f)=>!f.is(xe),components:[{type:Wt,components:[d(1),d(2),d(3)]},{type:Gt}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...r.propKeys],...r.props,traits:[...r.traits]}),init(){const{em:h}=this;gd(this,r.traits),bd(this,r.propKeys),this.listenTo(h,`${a.runCommand}${l}`,this.onPreviewOn),this.listenTo(h,`${a.stopCommand}${l}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const h=this.findFirstType(Wt);h==null||h.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var f;const h=((f=this.findFirstType(Wt))==null?void 0:f.components().length)||0;return{type:hn,components:{type:"text",components:{type:"textnode",content:`Slide ${h+1}`}}}},toJSON(...h){const f=u.prototype.toJSON.apply(this,h);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 h;(h=this.getSwiper())==null||h.destroy()},onRender(){const h=this.el;h.__onLoad=f=>f.on("slideChange",()=>this.__activeSlide=f.activeIndex),h.__activeSlide=this.__activeSlide,h.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(xe),o.remove(xe)}},Tu="Nav Prev",Mu="Nav Next",ao=`${jt}button-prev`,co=`${jt}button-next`,Au=n=>{const{Components:e}=n,t=o=>({type:"svg",selectable:!1,hoverable:!1,attributes:{viewBox:"0 0 27 44"},components:{type:"svg-in",tagName:"path",attributes:{d:o,fill:"currentColor"}}});return e.addType(qt,{isComponent:o=>ct(o,ao),model:{defaults:{name:Tu,classes:ao,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
+ .${ao} {
101
101
  color: inherit;
102
102
  }
103
- .${cs}:after {
103
+ .${ao}:after {
104
104
  content: none;
105
105
  }
106
- `}}}),e.addType(as,{extend:qt,isComponent:s=>ct(s,ds),model:{defaults:{name:Tu,classes:ds,components:t("M27,22L27,22L5,44l-2.1-2.1L22.8,22L2.9,2.1L5,0L27,22L27,22z"),styles:`
107
- .${ds} {
106
+ `}}}),e.addType(lo,{extend:qt,isComponent:o=>ct(o,co),model:{defaults:{name:Mu,classes:co,components:t("M27,22L27,22L5,44l-2.1-2.1L22.8,22L2.9,2.1L5,0L27,22L27,22z"),styles:`
107
+ .${co} {
108
108
  color: inherit;
109
109
  }
110
- .${ds}:after {
110
+ .${co}:after {
111
111
  content: none;
112
112
  }
113
- `}}}),()=>{e.removeType(qt),e.removeType(as)}},Au=n=>{const{Components:e}=n,t=`${jt}pagination`;return e.addType(Gt,{isComponent:s=>ct(s,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(qt),e.removeType(lo)}},Eu=n=>{const{Components:e}=n,t=`${jt}pagination`;return e.addType(Gt,{isComponent:o=>ct(o,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(Gt)}},Eu="Scrollbar",Nr=`${jt}scrollbar`,Ou=n=>{const{Components:e}=n;return e.addType(fn,{isComponent:t=>ct(t,Nr),model:{defaults:{name:Eu,classes:Nr,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{e.removeType(fn)}},Nu="Slide",Pr=`${jt}slide`,Pu=n=>{const{Components:e}=n;return e.addType(hn,{isComponent:t=>ct(t,Pr),model:{defaults:{name:Nu,classes:Pr,icon:ie.slider,draggable:(t,s)=>s.is(_t)}}}),()=>{e.removeType(hn)}},Iu="Wrapper",Ir=`${jt}wrapper`,Ru=n=>{const{Components:e}=n,{events:t}=e;return e.addType(_t,{isComponent:s=>ct(s,Ir),model:{defaults:{name:Iu,icon:ie.slider,classes:Ir,copyable:!1,removable:!1,draggable:!1,highlightable:!1,droppable:s=>s.is(hn)},init(){const s=this.components();this.listenTo(s,"add remove",this.updateSlider)},updateSlider(s){const o=this.closestType(we);if(o){const i=o.getView();o.reloadSlider(),this.em.once(t.scriptMount,()=>{setTimeout(()=>{var r;return(r=i.getSwiper())==null?void 0:r.slideTo(s.index())},100)})}}}}),()=>{e.removeType(_t)}},Du="swiperComponent",zu=Q(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},s=[xu(n,t),Mu(n),Ru(n),Pu(n),Au(n),Ou(n)];ee({editor:n,plan:F.startup,licenseKey:t.licenseKey,pluginName:Du,cleanup:()=>{s.forEach(o=>o())}})}),de="accordion",pn=`${de}-group`,Le=`${de}-header`,Ke=`${de}-content`,mt=`${de}-marker`,Rr=`${ze}${Le}`,bo=`${ze}${mt}`,Lu=`${ze}${Ke}`,Dr=`${bo}-open`,gt={accordion:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M5.616 20q-.691 0-1.153-.462T4 18.384V5.616q0-.691.463-1.153T5.616 4h12.769q.69 0 1.153.463T20 5.616v12.769q0 .69-.462 1.153T18.384 20zm0-1h12.769q.23 0 .423-.192t.192-.424V8.154H5v10.23q0 .232.192.424t.423.192"/></svg>',accordionGroup:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M8.116 16h10.769q.23 0 .423-.192t.192-.423V6h-12v9.385q0 .23.192.423t.423.192m0 1q-.69 0-1.153-.462T6.5 15.385V4.615q0-.69.463-1.153T8.116 3h10.769q.69 0 1.153.462t.462 1.153v10.77q0 .69-.462 1.152T18.884 17zm-3 3q-.69 0-1.153-.462T3.5 18.385V6.615h1v11.77q0 .23.192.423t.423.192h11.77v1zM7.5 4v12z"/></svg>',accordionHeader:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M5.616 20q-.691 0-1.153-.462T4 18.384V5.616q0-.691.463-1.153T5.616 4h12.769q.69 0 1.153.463T20 5.616v12.769q0 .69-.462 1.153T18.384 20zm0-1h12.769q.23 0 .423-.192t.192-.424V5.616q0-.231-.192-.424T18.384 5H5.616q-.231 0-.424.192T5 5.616v12.769q0 .23.192.423t.423.192M5 5v14zm2.616 4.192h6q.413 0 .706-.293q.294-.293.294-.707t-.294-.706q-.293-.294-.706-.294h-6q-.414 0-.707.294t-.293.706t.293.707t.707.293"/></svg>',accordionContent:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M4.616 19q-.691 0-1.153-.462T3 17.384V6.616q0-.691.463-1.153T4.615 5h14.77q.69 0 1.152.463T21 6.616v10.769q0 .69-.463 1.153T19.385 19zm0-1h14.769q.23 0 .423-.192t.192-.424V6.616q0-.231-.192-.424T19.385 6H4.615q-.23 0-.423.192T4 6.616v10.769q0 .23.192.423t.423.192M4 18V6zm2.23-2.116h11.54q.213 0 .356-.143t.143-.357t-.143-.356t-.357-.144H6.231q-.214 0-.357.144q-.143.143-.143.357q0 .213.143.356t.357.144m0-3.385h11.538q.214 0 .357-.143t.143-.357t-.143-.357t-.357-.143H6.231q-.214 0-.357.143T5.731 12t.143.357t.357.143m0-3.384H14q.214 0 .357-.144q.143-.143.143-.356q0-.214-.143-.357T14 8.116H6.23q-.213 0-.356.143t-.143.357t.143.356t.357.144"/></svg>',accordionMarker:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="m12 15.596l3.173-3.192H8.827zM5.616 20q-.672 0-1.144-.472T4 18.385V5.615q0-.67.472-1.143Q4.944 4 5.616 4h12.769q.67 0 1.143.472q.472.472.472 1.144v12.769q0 .67-.472 1.143q-.472.472-1.143.472zM5 9v9.385q0 .23.192.423t.423.192h12.77q.23 0 .423-.192t.192-.423V9z"/></svg>',caret:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m7.4 8.6 4.6 4.6 4.6-4.6L18 10l-6 6-6-6 1.4-1.4Z"/></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>'},zr=(n,e)=>{const{toolbarIconOpen:t=gt.eye}=e,s=n.is(de)?n:n.closestType(de);if(!t||!s)return;const{toolbar:o}=n,i={id:"accordion-toggle-open",label:t,command:()=>s.toggleOpen()};!o.find(l=>l.id===i.id)&&(o==null||o.unshift(i))},Vu=(n,e)=>{const{Components:t,Blocks:s}=n,{block:o={}}=e,i="Accordion",r=`${ze}${de}`,l=function(a={}){const c=this,d=()=>{const{clsMarkerOpen:u}=a,h=c.querySelector('[data-type-role="accordion-marker"]');!h||!u||(c.open?h.classList.add(u):h.classList.remove(u))};c.addEventListener("toggle",()=>{d(),c.dispatchEvent(new CustomEvent("details-toggle",{bubbles:!0}))}),d()};return t.addType(de,{block:o&&{label:i,media:gt.accordion,category:"Extra",select:!0,...o},isComponent:dt(de),extendFn:["initToolbar"],model:{defaults:{tagName:"details",name:i,classes:r,emptyState:!0,clsMarkerOpen:Dr,attributes:{[Ge]:de},droppable:Qs(Le,Ke),components:[{type:Le},{type:Ke}],"script-props":["clsMarkerOpen"],script:l,traits:[{type:"checkbox",name:"open",label:"Open"}],styles:`
120
+ `}}}),()=>{e.removeType(Gt)}},Ou="Scrollbar",Nr=`${jt}scrollbar`,Nu=n=>{const{Components:e}=n;return e.addType(fn,{isComponent:t=>ct(t,Nr),model:{defaults:{name:Ou,classes:Nr,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{e.removeType(fn)}},Pu="Slide",Pr=`${jt}slide`,Iu=n=>{const{Components:e}=n;return e.addType(hn,{isComponent:t=>ct(t,Pr),model:{defaults:{name:Pu,classes:Pr,icon:ie.slider,draggable:(t,o)=>o.is(Wt)}}}),()=>{e.removeType(hn)}},Ru="Wrapper",Ir=`${jt}wrapper`,Du=n=>{const{Components:e}=n,{events:t}=e;return e.addType(Wt,{isComponent:o=>ct(o,Ir),model:{defaults:{name:Ru,icon:ie.slider,classes:Ir,copyable:!1,removable:!1,draggable:!1,highlightable:!1,droppable:o=>o.is(hn)},init(){const o=this.components();this.listenTo(o,"add remove",this.updateSlider)},updateSlider(o){const s=this.closestType(xe);if(s){const i=s.getView();s.reloadSlider(),this.em.once(t.scriptMount,()=>{setTimeout(()=>{var r;return(r=i.getSwiper())==null?void 0:r.slideTo(o.index())},100)})}}}}),()=>{e.removeType(Wt)}},zu="swiperComponent",Lu=Q(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},o=[ku(n,t),Au(n),Du(n),Iu(n),Eu(n),Nu(n)];ee({editor:n,plan:F.startup,licenseKey:t.licenseKey,pluginName:zu,cleanup:()=>{o.forEach(s=>s())}})}),de="accordion",pn=`${de}-group`,Le=`${de}-header`,Ke=`${de}-content`,mt=`${de}-marker`,Rr=`${ze}${Le}`,bs=`${ze}${mt}`,Vu=`${ze}${Ke}`,Dr=`${bs}-open`,gt={accordion:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M5.616 20q-.691 0-1.153-.462T4 18.384V5.616q0-.691.463-1.153T5.616 4h12.769q.69 0 1.153.463T20 5.616v12.769q0 .69-.462 1.153T18.384 20zm0-1h12.769q.23 0 .423-.192t.192-.424V8.154H5v10.23q0 .232.192.424t.423.192"/></svg>',accordionGroup:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M8.116 16h10.769q.23 0 .423-.192t.192-.423V6h-12v9.385q0 .23.192.423t.423.192m0 1q-.69 0-1.153-.462T6.5 15.385V4.615q0-.69.463-1.153T8.116 3h10.769q.69 0 1.153.462t.462 1.153v10.77q0 .69-.462 1.152T18.884 17zm-3 3q-.69 0-1.153-.462T3.5 18.385V6.615h1v11.77q0 .23.192.423t.423.192h11.77v1zM7.5 4v12z"/></svg>',accordionHeader:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M5.616 20q-.691 0-1.153-.462T4 18.384V5.616q0-.691.463-1.153T5.616 4h12.769q.69 0 1.153.463T20 5.616v12.769q0 .69-.462 1.153T18.384 20zm0-1h12.769q.23 0 .423-.192t.192-.424V5.616q0-.231-.192-.424T18.384 5H5.616q-.231 0-.424.192T5 5.616v12.769q0 .23.192.423t.423.192M5 5v14zm2.616 4.192h6q.413 0 .706-.293q.294-.293.294-.707t-.294-.706q-.293-.294-.706-.294h-6q-.414 0-.707.294t-.293.706t.293.707t.707.293"/></svg>',accordionContent:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M4.616 19q-.691 0-1.153-.462T3 17.384V6.616q0-.691.463-1.153T4.615 5h14.77q.69 0 1.152.463T21 6.616v10.769q0 .69-.463 1.153T19.385 19zm0-1h14.769q.23 0 .423-.192t.192-.424V6.616q0-.231-.192-.424T19.385 6H4.615q-.23 0-.423.192T4 6.616v10.769q0 .23.192.423t.423.192M4 18V6zm2.23-2.116h11.54q.213 0 .356-.143t.143-.357t-.143-.356t-.357-.144H6.231q-.214 0-.357.144q-.143.143-.143.357q0 .213.143.356t.357.144m0-3.385h11.538q.214 0 .357-.143t.143-.357t-.143-.357t-.357-.143H6.231q-.214 0-.357.143T5.731 12t.143.357t.357.143m0-3.384H14q.214 0 .357-.144q.143-.143.143-.356q0-.214-.143-.357T14 8.116H6.23q-.213 0-.356.143t-.143.357t.143.356t.357.144"/></svg>',accordionMarker:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="m12 15.596l3.173-3.192H8.827zM5.616 20q-.672 0-1.144-.472T4 18.385V5.615q0-.67.472-1.143Q4.944 4 5.616 4h12.769q.67 0 1.143.472q.472.472.472 1.144v12.769q0 .67-.472 1.143q-.472.472-1.143.472zM5 9v9.385q0 .23.192.423t.423.192h12.77q.23 0 .423-.192t.192-.423V9z"/></svg>',caret:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m7.4 8.6 4.6 4.6 4.6-4.6L18 10l-6 6-6-6 1.4-1.4Z"/></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>'},zr=(n,e)=>{const{toolbarIconOpen:t=gt.eye}=e,o=n.is(de)?n:n.closestType(de);if(!t||!o)return;const{toolbar:s}=n,i={id:"accordion-toggle-open",label:t,command:()=>o.toggleOpen()};!s.find(l=>l.id===i.id)&&(s==null||s.unshift(i))},Bu=(n,e)=>{const{Components:t,Blocks:o}=n,{block:s={}}=e,i="Accordion",r=`${ze}${de}`,l=function(a={}){const c=this,d=()=>{const{clsMarkerOpen:u}=a,h=c.querySelector('[data-type-role="accordion-marker"]');!h||!u||(c.open?h.classList.add(u):h.classList.remove(u))};c.addEventListener("toggle",()=>{d(),c.dispatchEvent(new CustomEvent("details-toggle",{bubbles:!0}))}),d()};return t.addType(de,{block:s&&{label:i,media:gt.accordion,category:"Extra",select:!0,...s},isComponent:dt(de),extendFn:["initToolbar"],model:{defaults:{tagName:"details",name:i,classes:r,emptyState:!0,clsMarkerOpen:Dr,attributes:{[Ge]:de},droppable:Qo(Le,Ke),components:[{type:Le},{type:Ke}],"script-props":["clsMarkerOpen"],script:l,traits:[{type:"checkbox",name:"open",label:"Open"}],styles:`
121
121
  .${r}::details-content {
122
122
  opacity: 0;
123
123
  block-size: 0;
@@ -134,7 +134,7 @@
134
134
  transform: translateY(0);
135
135
  block-size: auto;
136
136
  }
137
- `},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){zr(this,e)}}}),()=>{s.remove(de),t.removeType(de)}},Bu=n=>{const{Components:e}=n;return e.addType(Ke,{isComponent:dt(Ke),model:{defaults:{name:"Accordion Content",removable:!1,copyable:!1,draggable:!1,emptyState:!0,classes:Lu,icon:gt.accordionContent,attributes:{[Ge]:Ke},components:"<div>Accordion content</div>"}}}),()=>{e.removeType(Ke)}},Hu=(n,e)=>{const{Components:t,Blocks:s}=n,{blockGroup:o={}}=e,i="Accordion Group",r=function(a={}){if(!a.single)return;const c=this;c.addEventListener("details-toggle",d=>{const u=d.target;if(!a.single||!u||!u.open)return;c.querySelectorAll('[data-type-role="accordion"]').forEach(f=>{u!==f&&f.open&&(f.open=!1)})})},l=(a={})=>({type:de,attributes:{open:a.open},components:[{type:Le,components:[`<div>${a.header}</div>`,{type:mt}]},{type:Ke,components:`<div>${a.content}</div>`}]});return t.addType(pn,{block:o&&{label:i,media:gt.accordionGroup,category:"Extra",select:!0,...o},isComponent:dt(pn),model:{defaults:{name:i,attributes:{[Ge]:pn},droppable:Qs(de),single:!0,emptyState:!0,components:Array(3).fill(0).map((a,c)=>l({open:c===0,header:`Accordion header ${c+1}`,content:`Accordion content ${c+1}`})),traits:[{type:"checkbox",name:"single",changeProp:!0,tip:"Only one accordion can be open at a time",label:"Single open"}],"script-props":["single"],script:r}}}),()=>{s.remove(pn),t.removeType(pn)}},$u=(n,e)=>{const{Components:t}=n;return t.addType(Le,{isComponent:dt(Le),extendFn:["initToolbar"],model:{defaults:{tagName:"summary",name:"Accordion Header",removable:!1,copyable:!1,draggable:!1,emptyState:!0,icon:gt.accordionHeader,classes:Rr,attributes:{[Ge]:Le},components:["<div>Accordion header</div>",{type:mt}],styles:`
137
+ `},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){zr(this,e)}}}),()=>{o.remove(de),t.removeType(de)}},Hu=n=>{const{Components:e}=n;return e.addType(Ke,{isComponent:dt(Ke),model:{defaults:{name:"Accordion Content",removable:!1,copyable:!1,draggable:!1,emptyState:!0,classes:Vu,icon:gt.accordionContent,attributes:{[Ge]:Ke},components:"<div>Accordion content</div>"}}}),()=>{e.removeType(Ke)}},$u=(n,e)=>{const{Components:t,Blocks:o}=n,{blockGroup:s={}}=e,i="Accordion Group",r=function(a={}){if(!a.single)return;const c=this;c.addEventListener("details-toggle",d=>{const u=d.target;if(!a.single||!u||!u.open)return;c.querySelectorAll('[data-type-role="accordion"]').forEach(f=>{u!==f&&f.open&&(f.open=!1)})})},l=(a={})=>({type:de,attributes:{open:a.open},components:[{type:Le,components:[`<div>${a.header}</div>`,{type:mt}]},{type:Ke,components:`<div>${a.content}</div>`}]});return t.addType(pn,{block:s&&{label:i,media:gt.accordionGroup,category:"Extra",select:!0,...s},isComponent:dt(pn),model:{defaults:{name:i,attributes:{[Ge]:pn},droppable:Qo(de),single:!0,emptyState:!0,components:Array(3).fill(0).map((a,c)=>l({open:c===0,header:`Accordion header ${c+1}`,content:`Accordion content ${c+1}`})),traits:[{type:"checkbox",name:"single",changeProp:!0,tip:"Only one accordion can be open at a time",label:"Single open"}],"script-props":["single"],script:r}}}),()=>{o.remove(pn),t.removeType(pn)}},Fu=(n,e)=>{const{Components:t}=n;return t.addType(Le,{isComponent:dt(Le),extendFn:["initToolbar"],model:{defaults:{tagName:"summary",name:"Accordion Header",removable:!1,copyable:!1,draggable:!1,emptyState:!0,icon:gt.accordionHeader,classes:Rr,attributes:{[Ge]:Le},components:["<div>Accordion header</div>",{type:mt}],styles:`
138
138
  summary {
139
139
  list-style: none;
140
140
  }
@@ -145,8 +145,8 @@
145
145
  justify-content: space-between;
146
146
  gap: 1rem;
147
147
  }
148
- `},initToolbar(){zr(this,e)}}}),()=>{t.removeType(Le)}},Fu=n=>{const{Components:e}=n;return e.addType(mt,{extend:"icon",isComponent:dt(mt),model:{defaults:{name:"Accordion Marker",icon:gt.accordionMarker,classes:bo,attributes:{[Ge]:mt},components:gt.caret,droppable:!1,draggable:_i(Le),styles:`
149
- .${bo} {
148
+ `},initToolbar(){zr(this,e)}}}),()=>{t.removeType(Le)}},_u=n=>{const{Components:e}=n;return e.addType(mt,{extend:"icon",isComponent:dt(mt),model:{defaults:{name:"Accordion Marker",icon:gt.accordionMarker,classes:bs,attributes:{[Ge]:mt},components:gt.caret,droppable:!1,draggable:Wi(Le),styles:`
149
+ .${bs} {
150
150
  min-width: 24px;
151
151
  width: 24px;
152
152
  height: 24px;
@@ -155,19 +155,19 @@
155
155
  .${Dr} {
156
156
  transform: rotateZ(180deg);
157
157
  }
158
- `}}}),()=>{e.removeType(mt)}},Wu="accordionComponent",_u=Q(function(n,e={}){const t=[Vu(n,e),Hu(n,e),$u(n,e),Fu(n),Bu(n)];ee({editor:n,licenseKey:e.licenseKey,plan:F.startup,pluginName:Wu,cleanup:()=>{t.forEach(s=>s())}})}),Gn=class Gn{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):ko(e.componentColumn,Gn.CSS_FLEX_BASIS)}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:o,partial:i}=e;s.addStyle({[Gn.CSS_FLEX_BASIS]:o},{partial:i})}}};Gn.CSS_FLEX_BASIS="flex-basis";let vo=Gn;const jn=class jn{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):ko(e.componentRow,jn.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:s,gapValue:o,partial:i}=e;s.addStyle({[jn.CSS_GAP]:o},{partial:i})}}};jn.CSS_GAP="gap";let wo=jn;const Zs=class Zs{constructor(e){this.config=e}getParentSize(e){var i;if((i=this.config)!=null&&i.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,o=t.getEl();return o?s?o.clientHeight:o.clientWidth:0}isLayoutVertical(e){var s;if((s=this.config)!=null&&s.isParentVertical)return this.config.isParentVertical(e);const t=ko(e.componentRow,Zs.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};Zs.CSS_FLEX_DIRECTION="flex-direction";let So=Zs;const Kn=class Kn{constructor(e){this.config=e}getSize(e){var s;if((s=this.config)!=null&&s.getSize)return this.config.getSize(e);const t=e.componentColumn;if(t.is(Kn.MJML_COLUMN_TYPE)){const i=t.getAttributes().width;if(i&&(i.includes("%")||!isNaN(parseFloat(i))))return parseFloat(i);const r=t.parent();return 100/(r?r.components().length:1)}return 0}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:o,partial:i}=e;s.is(Kn.MJML_COLUMN_TYPE)&&s.addAttributes({width:`${parseFloat(o)}%`},{partial:i})}}};Kn.MJML_COLUMN_TYPE="mj-column";let Co=Kn;const Ys=class Ys{constructor(e){this.config=e}isGapSupported(){return!1}getGap(e){var s;if((s=this.config)!=null&&s.getGap)return this.config.getGap(e);const{componentRow:t}=e;if(t.is(Ys.MJML_SECTION_TYPE)){const o=t.getAttributes();if(o&&o.padding)return parseInt(o.padding,10)||0}return 0}setGap(e){var t,s;(s=(t=this.config)==null?void 0:t.setGap)==null||s.call(t,e)}};Ys.MJML_SECTION_TYPE="mj-section";let xo=Ys;class qu{constructor(e){this.config=e}getParentSize(e){var r;if((r=this.config)!=null&&r.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,o=t.getEl();if(!o)return 0;let i=o;if(o.tagName!=="TABLE"){const l=o.querySelectorAll("table");l.length&&(i=l[0])}return s?i.clientHeight:i.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class Kt{constructor(){this.handlerCache=new Map}static getInstance(){return Kt.instance||(Kt.instance=new Kt),Kt.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(Jt(e)?this.handlerCache.set(t,{sizeHandler:new Co(e),gapHandler:new xo(e),parentSizeHandler:new qu(e)}):this.handlerCache.set(t,{sizeHandler:new vo(e),gapHandler:new wo(e),parentSizeHandler:new So(e)})),this.handlerCache.get(t)}}function yt(n){return Kt.getInstance().getHandlers(n)}const Lr=n=>{n.style.display="none"},Vr=n=>{n.style.display="block"},mn=n=>+parseFloat(`${n}`).toFixed(2),Jt=n=>n.projectType===Fi.email,us=(n,e)=>{const t=n.Canvas.getFramesEl();t&&(t.style.pointerEvents=e?"none":"")},Gu=n=>n?["top","bottom"]:["left","right"],ju=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},Ku=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},Ju=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},Uu=(n,e,t,s)=>{const i=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return i>=0&&i<s?i:-1},hs=n=>n==="top"||n==="bottom",Zu=(n,e)=>!!(ju(n)&&(e==="left"||e==="top")||Ku(n)&&(e==="right"||e==="bottom")),Yu=n=>{const e=n.parent();return e?e.components().models.length>1:!1},Br=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,ko=(n,e,t=!1)=>{const s=!t,o=n.getEl();if(!o)return s?0:"";const r=window.getComputedStyle(o)[e]||"";if(s){let l;return typeof r=="string"?(l=parseFloat(r.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(r)||0,l}return r},Hr=(n,e,t)=>{const s=To({componentRow:n,isVertical:e},t),o=n.components().models;return s*(o.length-1)},gn=(n,e)=>yt(e).parentSizeHandler.isLayoutVertical({componentRow:n}),yn=(n,e)=>yt(e).sizeHandler.getSize(n),To=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:s}=yt(e);if(!t.isGapSupported())return 0;const o=t.getGap(n),i=s.getParentSize(n);return o/100*i},Mo=(n,e)=>yt(e).parentSizeHandler.getParentSize(n),bn=(n,e)=>{yt(e).sizeHandler.setSize(n)},$r=(n,e)=>{const t=yn(n,e);bn({...n,sizeValue:`${t}%`,partial:!1},e)},Fr=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=yt(e);t.isGapSupported()&&t.setGap(n)},Xu=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const s=n.components().models,o={componentRow:n,isVertical:gn(n,e)};s.map(i=>$r({...o,componentColumn:i},e)),Fr({...o,gapValue:String(t),partial:!1},e)};function Qu(n,e){const{Blocks:t}=n,{typeColumn:s,typeRow:o,blocks:i}=e;if(i===!1||Jt(e))return;const r=u=>({type:o,components:u.map(h=>({type:s,style:{"flex-basis":`${h}%`}}))}),l=u=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
158
+ `}}}),()=>{e.removeType(mt)}},Wu="accordionComponent",qu=Q(function(n,e={}){const t=[Bu(n,e),$u(n,e),Fu(n,e),_u(n),Hu(n)];ee({editor:n,licenseKey:e.licenseKey,plan:F.startup,pluginName:Wu,cleanup:()=>{t.forEach(o=>o())}})}),Gn=class Gn{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):ks(e.componentColumn,Gn.CSS_FLEX_BASIS)}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:o,sizeValue:s,partial:i}=e;o.addStyle({[Gn.CSS_FLEX_BASIS]:s},{partial:i})}}};Gn.CSS_FLEX_BASIS="flex-basis";let vs=Gn;const jn=class jn{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):ks(e.componentRow,jn.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:o,gapValue:s,partial:i}=e;o.addStyle({[jn.CSS_GAP]:s},{partial:i})}}};jn.CSS_GAP="gap";let xs=jn;const Zo=class Zo{constructor(e){this.config=e}getParentSize(e){var i;if((i=this.config)!=null&&i.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:o}=e,s=t.getEl();return s?o?s.clientHeight:s.clientWidth:0}isLayoutVertical(e){var o;if((o=this.config)!=null&&o.isParentVertical)return this.config.isParentVertical(e);const t=ks(e.componentRow,Zo.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};Zo.CSS_FLEX_DIRECTION="flex-direction";let ws=Zo;const Kn=class Kn{constructor(e){this.config=e}getSize(e){var o;if((o=this.config)!=null&&o.getSize)return this.config.getSize(e);const t=e.componentColumn;if(t.is(Kn.MJML_COLUMN_TYPE)){const i=t.getAttributes().width;if(i&&(i.includes("%")||!isNaN(parseFloat(i))))return parseFloat(i);const r=t.parent();return 100/(r?r.components().length:1)}return 0}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:o,sizeValue:s,partial:i}=e;o.is(Kn.MJML_COLUMN_TYPE)&&o.addAttributes({width:`${parseFloat(s)}%`},{partial:i})}}};Kn.MJML_COLUMN_TYPE="mj-column";let Ss=Kn;const Yo=class Yo{constructor(e){this.config=e}isGapSupported(){return!1}getGap(e){var o;if((o=this.config)!=null&&o.getGap)return this.config.getGap(e);const{componentRow:t}=e;if(t.is(Yo.MJML_SECTION_TYPE)){const s=t.getAttributes();if(s&&s.padding)return parseInt(s.padding,10)||0}return 0}setGap(e){var t,o;(o=(t=this.config)==null?void 0:t.setGap)==null||o.call(t,e)}};Yo.MJML_SECTION_TYPE="mj-section";let Cs=Yo;class Gu{constructor(e){this.config=e}getParentSize(e){var r;if((r=this.config)!=null&&r.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:o}=e,s=t.getEl();if(!s)return 0;let i=s;if(s.tagName!=="TABLE"){const l=s.querySelectorAll("table");l.length&&(i=l[0])}return o?i.clientHeight:i.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class Kt{constructor(){this.handlerCache=new Map}static getInstance(){return Kt.instance||(Kt.instance=new Kt),Kt.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(Jt(e)?this.handlerCache.set(t,{sizeHandler:new Ss(e),gapHandler:new Cs(e),parentSizeHandler:new Gu(e)}):this.handlerCache.set(t,{sizeHandler:new vs(e),gapHandler:new xs(e),parentSizeHandler:new ws(e)})),this.handlerCache.get(t)}}function yt(n){return Kt.getInstance().getHandlers(n)}const Lr=n=>{n.style.display="none"},Vr=n=>{n.style.display="block"},mn=n=>+parseFloat(`${n}`).toFixed(2),Jt=n=>n.projectType===Fi.email,uo=(n,e)=>{const t=n.Canvas.getFramesEl();t&&(t.style.pointerEvents=e?"none":"")},ju=n=>n?["top","bottom"]:["left","right"],Ku=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},Ju=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},Uu=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},Zu=(n,e,t,o)=>{const i=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return i>=0&&i<o?i:-1},ho=n=>n==="top"||n==="bottom",Yu=(n,e)=>!!(Ku(n)&&(e==="left"||e==="top")||Ju(n)&&(e==="right"||e==="bottom")),Xu=n=>{const e=n.parent();return e?e.components().models.length>1:!1},Br=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,ks=(n,e,t=!1)=>{const o=!t,s=n.getEl();if(!s)return o?0:"";const r=window.getComputedStyle(s)[e]||"";if(o){let l;return typeof r=="string"?(l=parseFloat(r.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(r)||0,l}return r},Hr=(n,e,t)=>{const o=Ts({componentRow:n,isVertical:e},t),s=n.components().models;return o*(s.length-1)},gn=(n,e)=>yt(e).parentSizeHandler.isLayoutVertical({componentRow:n}),yn=(n,e)=>yt(e).sizeHandler.getSize(n),Ts=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:o}=yt(e);if(!t.isGapSupported())return 0;const s=t.getGap(n),i=o.getParentSize(n);return s/100*i},Ms=(n,e)=>yt(e).parentSizeHandler.getParentSize(n),bn=(n,e)=>{yt(e).sizeHandler.setSize(n)},$r=(n,e)=>{const t=yn(n,e);bn({...n,sizeValue:`${t}%`,partial:!1},e)},Fr=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=yt(e);t.isGapSupported()&&t.setGap(n)},Qu=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const o=n.components().models,s={componentRow:n,isVertical:gn(n,e)};o.map(i=>$r({...s,componentColumn:i},e)),Fr({...s,gapValue:String(t),partial:!1},e)};function eh(n,e){const{Blocks:t}=n,{typeColumn:o,typeRow:s,blocks:i}=e;if(i===!1||Jt(e))return;const r=u=>({type:s,components:u.map(h=>({type:o,style:{"flex-basis":`${h}%`}}))}),l=u=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
159
159
  ${u.map(h=>`<div style="flex-basis: ${h}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
160
- </div>`,a=(u,h)=>({id:`flex-row-${h.join("-")}`,label:u,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(h),content:r(h)}),c=[a("1 Column",[100]),a("2 Columns 50/50",[50,50]),a("2 Columns 25/75",[25,75]),a("2 Columns 75/25",[75,25]),a("3 Columns",[33.33,33.33,33.33]),a("3 Columns 50/25/25",[50,25,25]),a("3 Columns 25/50/25",[25,50,25]),a("3 Columns 25/25/50",[25,25,50]),a("4 Columns",[25,25,25,25]),a("5 Columns",[20,20,20,20,20])],d=Un(i)?i({blocks:c}):c;return d.forEach(u=>t.add(u.id,u)),()=>{d.forEach(u=>t.remove(u.id))}}const eh=(n,e)=>{const{Components:t}=n,{typeRow:s,typeColumn:o,extendTypeColumn:i}=e,r=`${ze}${o}`,a=!!o&&!!t.getType(o)&&!i;if(!(!o||a||Jt(e)))return t.addType(o,{isComponent:dt(o),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:r,icon:'<svg viewBox="0 0 24 24"><path d="M14.5 2.3A1.8 1.8 0 0 0 12.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8zm-8 0A1.8 1.8 0 0 0 4.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',draggable:_i(s),attributes:{[Ge]:o},styles:`
160
+ </div>`,a=(u,h)=>({id:`flex-row-${h.join("-")}`,label:u,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(h),content:r(h)}),c=[a("1 Column",[100]),a("2 Columns 50/50",[50,50]),a("2 Columns 25/75",[25,75]),a("2 Columns 75/25",[75,25]),a("3 Columns",[33.33,33.33,33.33]),a("3 Columns 50/25/25",[50,25,25]),a("3 Columns 25/50/25",[25,50,25]),a("3 Columns 25/25/50",[25,25,50]),a("4 Columns",[25,25,25,25]),a("5 Columns",[20,20,20,20,20])],d=Un(i)?i({blocks:c}):c;return d.forEach(u=>t.add(u.id,u)),()=>{d.forEach(u=>t.remove(u.id))}}const th=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:s,extendTypeColumn:i}=e,r=`${ze}${s}`,a=!!s&&!!t.getType(s)&&!i;if(!(!s||a||Jt(e)))return t.addType(s,{isComponent:dt(s),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:r,icon:'<svg viewBox="0 0 24 24"><path d="M14.5 2.3A1.8 1.8 0 0 0 12.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8zm-8 0A1.8 1.8 0 0 0 4.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',draggable:Wi(o),attributes:{[Ge]:s},styles:`
161
161
  .${r} {
162
162
  flex-grow: 1;
163
163
  }
164
- `}}}),()=>{t.removeType(o)}},th=(n,e)=>{const{Components:t}=n,{typeRow:s,typeColumn:o,extendTypeRow:i}=e,r=`${ze}${s}`,a=!!s&&!!t.getType(s)&&!i;if(!(!s||a||Jt(e)))return t.addType(s,{isComponent:dt(s),model:{defaults:{name:"Row",classes:r,icon:'<svg viewBox="0 0 24 24"><path d="M4 4.8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3A1.8 1.8 0 0 0 20 4.7zm0 8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',emptyState:{styleIn:"width: 100%"},attributes:{[Ge]:s},droppable:Qs(o),traits:[{type:"checkbox",name:"snap",label:"Enable Snap",default:e.snapEnabled,changeProp:!0},{type:"number",name:"snap-divisions",label:"Snap Divisions",min:1,max:12,step:1,default:e.snapDivisions,changeProp:!0}],resizable:{tl:0,tc:0,tr:0,cl:0,bl:0,br:0},styles:`
164
+ `}}}),()=>{t.removeType(s)}},nh=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:s,extendTypeRow:i}=e,r=`${ze}${o}`,a=!!o&&!!t.getType(o)&&!i;if(!(!o||a||Jt(e)))return t.addType(o,{isComponent:dt(o),model:{defaults:{name:"Row",classes:r,icon:'<svg viewBox="0 0 24 24"><path d="M4 4.8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3A1.8 1.8 0 0 0 20 4.7zm0 8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',emptyState:{styleIn:"width: 100%"},attributes:{[Ge]:o},droppable:Qo(s),traits:[{type:"checkbox",name:"snap",label:"Enable Snap",default:e.snapEnabled,changeProp:!0},{type:"number",name:"snap-divisions",label:"Snap Divisions",min:1,max:12,step:1,default:e.snapDivisions,changeProp:!0}],resizable:{tl:0,tc:0,tr:0,cl:0,bl:0,br:0},styles:`
165
165
  .${r} {
166
166
  display: flex;
167
167
  align-items: stretch;
168
168
  flex-wrap: nowrap;
169
169
  }
170
- `}}}),()=>{t.removeType(s)}};class nh{constructor(){this.resizableChildTypes=new Set,this.gapAdjustableParentTypes=new Set,this.typeRelationships=new Map}registerResizableChild(e){this.resizableChildTypes.add(e)}registerGapAdjustableParent(e){this.gapAdjustableParentTypes.add(e)}registerTypeRelationship(e,t){this.typeRelationships.has(e)||this.typeRelationships.set(e,new Set),this.typeRelationships.get(e).add(t),this.registerResizableChild(t),this.registerGapAdjustableParent(e)}isResizableChild(e){return this.resizableChildTypes.has(e.get("type"))}isGapAdjustableParent(e){return this.gapAdjustableParentTypes.has(e.get("type"))}isValidRelationship(e,t){const s=e.get("type"),o=t.get("type");return this.typeRelationships.has(s)?this.typeRelationships.get(s).has(o):!1}}class sh{constructor(e,t,s){this.editor=e,this.registry=t,this.opts=s,this.resizeState=new WeakMap}getState(e){return this.resizeState.has(e)||this.resizeState.set(e,{}),this.resizeState.get(e)}clearState(e){return this.resizeState.delete(e)}startResize(e,t,s){const{opts:o}=this,i=this.getState(e);i.direction=t,i.startX=s.clientX,i.startY=s.clientY,i.resizing=!0,i.lastSnappedPercent=void 0;const r=e.parent();if(!r||!this.registry.isValidRelationship(r,e))return;i.snapEnabled=r.get("snap")??o.snapEnabled,i.snapDivisions=r.get("snap-divisions")??o.snapDivisions??12;const l=r.components().models,a=l.findIndex(h=>h.cid===e.cid),c=gn(r,o),d=Uu(a,t,c,l.length);d!==-1&&(i.adjacentIdx=d);const u={componentColumn:e,componentRow:r,isVertical:c};if(i.startPercent=yn(u,o),typeof i.adjacentIdx<"u"){const h=l[i.adjacentIdx];i.neighborStartPercent=yn({...u,componentColumn:h},o)}}updateResizeByDelta(e,t,s){const o=this.getState(e),i=e.parent();!o.resizing||!i||(o.snapEnabled?this.updateSnapResize(e,t,s):this.updateContinuesResize(e,t,s))}finishResize(e){const t=e.parent(),s=t==null?void 0:t.components().models,o={componentRow:t,isVertical:!!t&&gn(t,this.opts)};s==null||s.forEach(i=>$r({...o,componentColumn:i},this.opts)),this.clearState(e)}updateContinuesResize(e,t,s){const o=this.getState(e),i=e.parent(),{opts:r}=this;if(!i)return;const l=r.minItemPercent??0,a=hs(t),c=Mo({componentRow:i,isVertical:a},r),d=Hr(i,a,this.opts),h=100-d/c*100,f=s/(c-d)*h,{startPercent:p=0,neighborStartPercent:m=0}=o,g={componentRow:i,isVertical:a,componentColumn:e,partial:!0},b=Br(t,s)?p+Math.abs(f):p-Math.abs(f);if(typeof o.adjacentIdx<"u"){const S=i.components().models[o.adjacentIdx],y=p+m,w=y-l,C=Math.min(w,Math.max(l,b)),k=y-C;bn({...g,sizeValue:`${mn(C)}%`},r),bn({...g,componentColumn:S,sizeValue:`${mn(k)}%`},r)}else{const S=Math.max(l,Math.min(h,b));bn({...g,sizeValue:`${mn(S)}%`},r)}}updateSnapResize(e,t,s){const o=this.getState(e),i=e.parent(),r=hs(t),l=Mo({componentRow:i,isVertical:r},this.opts),a=Hr(i,r,this.opts),c=l-a,d=s/c*100,u=Br(t,s),{startPercent:h=0,snapDivisions:f=12}=o,p=u?h+Math.abs(d):h-Math.abs(d),m=100/f,g=Math.floor(p/m)*m,b=Math.ceil(p/m)*m,S=Math.abs(b-p),y=Math.abs(p-g),w=m*.2,v=S<y?b:g;if(v>0&&v<100&&(S<w||y<w)&&o.lastSnappedPercent!==v){o.lastSnappedPercent=v;let E=Math.abs(v-h)/100*c;(u&&(t==="left"||t==="top")||!u&&(t==="right"||t==="bottom"))&&(E=-E),this.updateContinuesResize(e,t,E)}else S>=w&&y>=w&&(o.lastSnappedPercent=void 0)}}class oh{constructor(e,t,s){this.editor=e,this.registry=t,this.opts=s}updateGapByDelta(e,t,s,o){if(!this.registry.isGapAdjustableParent(e))return;const{opts:i}=this,r=Math.max(0,s+t),l=Mo({componentRow:e,isVertical:o},i),a=r/l*100,c=e.components().models,d=c.length-1,u={componentRow:e,isVertical:o},h=c.reduce((w,v)=>w+yn({...u,componentColumn:v},i),0),p=100-a*d,m=i.minItemPercent||5;if(p<m*c.length)return;const b=100-d*a,S=h-b,y={componentRow:e,isVertical:o,partial:!0};c.map(w=>{const v=yn({...u,componentColumn:w},i),C=v-v/h*S;bn({...y,componentColumn:w,sizeValue:`${mn(C)}%`},i)}),Fr({...y,gapValue:`${mn(a)}%`},i)}finishGapAdjust(e){Xu(e,this.opts)}}class ih{constructor(e,t,s){this.editor=e,this.registry=t,this.opts=s,this.resizeHandler=new sh(e,t,s),this.gapHandler=new oh(e,t,s)}startResize(e,t,s){this.resizeHandler.startResize(e,t,s)}updateResizeByDelta(e,t,s){this.resizeHandler.updateResizeByDelta(e,t,s)}finishResize(e){this.resizeHandler.finishResize(e)}updateGapByDelta(e,t,s,o){this.gapHandler.updateGapByDelta(e,t,s,o)}finishGapAdjust(e){this.gapHandler.finishGapAdjust(e)}canResize(e){const t=e.parent();return t?this.registry.isValidRelationship(t,e):!1}canAdjustGap(e){return this.registry.isGapAdjustableParent(e)}}const fs="gs-flex-spots",Wr=`${fs}__handle-size`,rh=`${fs}__handle-gap`;function lh(n,e){const{Canvas:t}=n,s="flex-resize-spot";let o,i,r,l,a=null,c=null;const d=new nh,u=new ih(n,d,e),h=()=>{var C;o=document.createElement("div"),o.className=fs,o.style.display="none",i=document.createElement("div"),i.className=`${fs}__handles`,i.style.position="absolute",i.style.pointerEvents="none",i.style.zIndex="21",r={left:document.createElement("div"),right:document.createElement("div"),top:document.createElement("div"),bottom:document.createElement("div")},Object.entries(r).forEach(([k,E])=>{const T=k,A=hs(T);E.className=`${Wr} ${Wr}-${T} gjs-resizer-h gjs-cv-unscale`,E.style.cssText=`
170
+ `}}}),()=>{t.removeType(o)}};class oh{constructor(){this.resizableChildTypes=new Set,this.gapAdjustableParentTypes=new Set,this.typeRelationships=new Map}registerResizableChild(e){this.resizableChildTypes.add(e)}registerGapAdjustableParent(e){this.gapAdjustableParentTypes.add(e)}registerTypeRelationship(e,t){this.typeRelationships.has(e)||this.typeRelationships.set(e,new Set),this.typeRelationships.get(e).add(t),this.registerResizableChild(t),this.registerGapAdjustableParent(e)}isResizableChild(e){return this.resizableChildTypes.has(e.get("type"))}isGapAdjustableParent(e){return this.gapAdjustableParentTypes.has(e.get("type"))}isValidRelationship(e,t){const o=e.get("type"),s=t.get("type");return this.typeRelationships.has(o)?this.typeRelationships.get(o).has(s):!1}}class sh{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o,this.resizeState=new WeakMap}getState(e){return this.resizeState.has(e)||this.resizeState.set(e,{}),this.resizeState.get(e)}clearState(e){return this.resizeState.delete(e)}startResize(e,t,o){const{opts:s}=this,i=this.getState(e);i.direction=t,i.startX=o.clientX,i.startY=o.clientY,i.resizing=!0,i.lastSnappedPercent=void 0;const r=e.parent();if(!r||!this.registry.isValidRelationship(r,e))return;i.snapEnabled=r.get("snap")??s.snapEnabled,i.snapDivisions=r.get("snap-divisions")??s.snapDivisions??12;const l=r.components().models,a=l.findIndex(h=>h.cid===e.cid),c=gn(r,s),d=Zu(a,t,c,l.length);d!==-1&&(i.adjacentIdx=d);const u={componentColumn:e,componentRow:r,isVertical:c};if(i.startPercent=yn(u,s),typeof i.adjacentIdx<"u"){const h=l[i.adjacentIdx];i.neighborStartPercent=yn({...u,componentColumn:h},s)}}updateResizeByDelta(e,t,o){const s=this.getState(e),i=e.parent();!s.resizing||!i||(s.snapEnabled?this.updateSnapResize(e,t,o):this.updateContinuesResize(e,t,o))}finishResize(e){const t=e.parent(),o=t==null?void 0:t.components().models,s={componentRow:t,isVertical:!!t&&gn(t,this.opts)};o==null||o.forEach(i=>$r({...s,componentColumn:i},this.opts)),this.clearState(e)}updateContinuesResize(e,t,o){const s=this.getState(e),i=e.parent(),{opts:r}=this;if(!i)return;const l=r.minItemPercent??0,a=ho(t),c=Ms({componentRow:i,isVertical:a},r),d=Hr(i,a,this.opts),h=100-d/c*100,f=o/(c-d)*h,{startPercent:p=0,neighborStartPercent:m=0}=s,g={componentRow:i,isVertical:a,componentColumn:e,partial:!0},y=Br(t,o)?p+Math.abs(f):p-Math.abs(f);if(typeof s.adjacentIdx<"u"){const S=i.components().models[s.adjacentIdx],b=p+m,x=b-l,w=Math.min(x,Math.max(l,y)),C=b-w;bn({...g,sizeValue:`${mn(w)}%`},r),bn({...g,componentColumn:S,sizeValue:`${mn(C)}%`},r)}else{const S=Math.max(l,Math.min(h,y));bn({...g,sizeValue:`${mn(S)}%`},r)}}updateSnapResize(e,t,o){const s=this.getState(e),i=e.parent(),r=ho(t),l=Ms({componentRow:i,isVertical:r},this.opts),a=Hr(i,r,this.opts),c=l-a,d=o/c*100,u=Br(t,o),{startPercent:h=0,snapDivisions:f=12}=s,p=u?h+Math.abs(d):h-Math.abs(d),m=100/f,g=Math.floor(p/m)*m,y=Math.ceil(p/m)*m,S=Math.abs(y-p),b=Math.abs(p-g),x=m*.2,v=S<b?y:g;if(v>0&&v<100&&(S<x||b<x)&&s.lastSnappedPercent!==v){s.lastSnappedPercent=v;let E=Math.abs(v-h)/100*c;(u&&(t==="left"||t==="top")||!u&&(t==="right"||t==="bottom"))&&(E=-E),this.updateContinuesResize(e,t,E)}else S>=x&&b>=x&&(s.lastSnappedPercent=void 0)}}class ih{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o}updateGapByDelta(e,t,o,s){if(!this.registry.isGapAdjustableParent(e))return;const{opts:i}=this,r=Math.max(0,o+t),l=Ms({componentRow:e,isVertical:s},i),a=r/l*100,c=e.components().models,d=c.length-1,u={componentRow:e,isVertical:s},h=c.reduce((x,v)=>x+yn({...u,componentColumn:v},i),0),p=100-a*d,m=i.minItemPercent||5;if(p<m*c.length)return;const y=100-d*a,S=h-y,b={componentRow:e,isVertical:s,partial:!0};c.map(x=>{const v=yn({...u,componentColumn:x},i),w=v-v/h*S;bn({...b,componentColumn:x,sizeValue:`${mn(w)}%`},i)}),Fr({...b,gapValue:`${mn(a)}%`},i)}finishGapAdjust(e){Qu(e,this.opts)}}class rh{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o,this.resizeHandler=new sh(e,t,o),this.gapHandler=new ih(e,t,o)}startResize(e,t,o){this.resizeHandler.startResize(e,t,o)}updateResizeByDelta(e,t,o){this.resizeHandler.updateResizeByDelta(e,t,o)}finishResize(e){this.resizeHandler.finishResize(e)}updateGapByDelta(e,t,o,s){this.gapHandler.updateGapByDelta(e,t,o,s)}finishGapAdjust(e){this.gapHandler.finishGapAdjust(e)}canResize(e){const t=e.parent();return t?this.registry.isValidRelationship(t,e):!1}canAdjustGap(e){return this.registry.isGapAdjustableParent(e)}}const fo="gs-flex-spots",_r=`${fo}__handle-size`,lh=`${fo}__handle-gap`;function ah(n,e){const{Canvas:t}=n,o="flex-resize-spot";let s,i,r,l,a=null,c=null;const d=new oh,u=new rh(n,d,e),h=()=>{var w;s=document.createElement("div"),s.className=fo,s.style.display="none",i=document.createElement("div"),i.className=`${fo}__handles`,i.style.position="absolute",i.style.pointerEvents="none",i.style.zIndex="21",r={left:document.createElement("div"),right:document.createElement("div"),top:document.createElement("div"),bottom:document.createElement("div")},Object.entries(r).forEach(([C,E])=>{const T=C,A=ho(T);E.className=`${_r} ${_r}-${T} gjs-resizer-h gjs-cv-unscale`,E.style.cssText=`
171
171
  pointer-events: all;
172
172
  position: absolute;
173
173
  z-index: 1;
@@ -177,9 +177,9 @@
177
177
  ${T==="right"?"right: 0px;":""}
178
178
  ${T==="top"?"top: 0px;":""}
179
179
  ${T==="bottom"?"bottom: 0px;":""}
180
- `,E.addEventListener("pointerdown",f(T)),i.appendChild(E)}),!e.disableGapHandler&&!Jt(e)&&(l=document.createElement("div"),l.className=rh,l.style.cssText=`
180
+ `,E.addEventListener("pointerdown",f(T)),i.appendChild(E)}),!e.disableGapHandler&&!Jt(e)&&(l=document.createElement("div"),l.className=lh,l.style.cssText=`
181
181
  position: absolute;
182
- background-color: #3b97e3;
182
+ background-color: var(--gs-theme-cl-cmp-bg1, #3b97e3);
183
183
  border-width: 2px;
184
184
  border-radius: 9999px;
185
185
  border-color: #fff;
@@ -187,21 +187,124 @@
187
187
  pointer-events: all;
188
188
  max-width: 3rem;
189
189
  max-height: 3rem;
190
- `,l.addEventListener("pointerdown",p()),i.appendChild(l)),o.append(i),(C=t.getSpotsEl())==null||C.appendChild(o)},f=C=>k=>{if(!a)return;us(n,!0),k.stopPropagation(),k.preventDefault(),u.startResize(a,C,k);const E=k.clientX,T=k.clientY;k.target.setPointerCapture(k.pointerId);const A=D=>{const z=n.Canvas.getZoomMultiplier(),H=(D.clientX-E)*z,Te=(D.clientY-T)*z,Me=hs(C)?Te:H;u.updateResizeByDelta(a,C,Me)},P=()=>{us(n,!1),u.finishResize(a),k.target.releasePointerCapture(k.pointerId),document.removeEventListener("pointermove",A),document.removeEventListener("pointerup",P)};document.addEventListener("pointermove",A),document.addEventListener("pointerup",P)},p=()=>C=>{if(!c)return;const k=c;us(n,!0),C.stopPropagation(),C.preventDefault();const E=gn(k,e),T=To({componentRow:k,isVertical:E},e),A=C.clientX,P=C.clientY;C.target.setPointerCapture(C.pointerId);const D=H=>{const Te=n.Canvas.getZoomMultiplier(),Me=E?(H.clientY-P)*Te:(H.clientX-A)*Te;u.updateGapByDelta(k,Me,T,E)},z=()=>{us(n,!1),u.finishGapAdjust(k),C.target.releasePointerCapture(C.pointerId),document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",z)};document.addEventListener("pointermove",D),document.addEventListener("pointerup",z)},m=C=>{const k=C.component;if(!k||!o||(a=k,c=k.parent(),!c))return;const E=c;Vr(o);const T=C.getStyle();i&&Object.assign(i.style,T);const A=gn(E,e),P=Gu(A);if(Object.values(r).forEach(Lr),P.forEach(z=>{if(Zu(k,z))return;const H=r[z];Vr(H)}),yt(e).gapHandler.isGapSupported()&&l&&Yu(k)){const z=To({componentRow:E,isVertical:A},e);g(z,A,Ju(k))}},g=(C,k,E=!1)=>{const T=e.gapHandleSize,A=l.style;if(k){A.height=`${T}px`;const P=l.offsetHeight;E?(A.top=`-${(C+P)/2}px`,A.bottom=""):(A.bottom=`-${(C+P)/2}px`,A.top=""),A.width="50%",A.left="50%",A.transform="translateX(-50%)",A.cursor="row-resize"}else{A.width=`${T}px`;const P=l.offsetWidth;E?(A.left=`-${(C+P)/2}px`,A.right=""):(A.right=`-${(C+P)/2}px`,A.left=""),A.height="50%",A.top="50%",A.transform="translateY(-50%)",A.cursor="col-resize"}},b=()=>{o&&(Lr(o),a=null,c=null)},S=()=>{t.removeSpots({type:s});const C=n.getSelected(),k=C==null?void 0:C.parent();C&&k&&d.isValidRelationship(k,C)?t.addSpot({type:s,component:C}):b()},y=()=>{const C=t.getSpots().filter(k=>k.type===s)[0];C&&m(C)},w=(C,k)=>{d.registerTypeRelationship(C,k)};n.onReady(()=>{h(),Jt(e)?w("mj-section","mj-column"):w(e.typeRow,e.typeColumn)});const v="component:toggled";return n.on(t.events.spot,y),n.on(v,S),()=>{n.off(t.events.spot,y),n.off(v,S)}}const ah="flexComponent",ch=Q(function(n,e={}){const t={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...e},s=[th(n,t),eh(n,t)],o=lh(n,t),i=Qu(n,t);ee({editor:n,licenseKey:t.licenseKey,plan:F.startup,pluginName:ah,cleanup:()=>{s.forEach(r=>r==null?void 0:r()),o(),i==null||i()}})}),dh=n=>n.dispatchEvent(new CustomEvent("input"));function uh(n,e){if(!e)return()=>{};const t=n.Components.events,s=d=>n.getSelectedAll().includes(d),o=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),i=d=>d.isChildOf("text"),r=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{s(d)&&o(d)&&!r(d)&&l(d,u)},c=(d,u)=>{if(s(d)&&!o(d)&&i(d)){const h=d.parents().find(f=>f.isInstanceOf("text"));h&&(l(h,u),setTimeout(()=>n.select(h),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Ao=new WeakMap,hh=(n,e)=>{Ao.set(n,e)},fh=n=>{Ao.delete(n)},Eo=n=>Ao.get(n),ps=n=>{const e=n.target,t=e.closest(".tox"),s=e.matches(".ephox-snooker-resizer-bar");(t||s)&&n.stopPropagation()},_r=n=>{n.stopPropagation(),n.preventDefault()},ph=(n,e)=>{const t=n.getDoc(),s=n.getWin();if(e!=null&&e.event){const{event:o}=e,{clientX:i,clientY:r}=o;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(i,r);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(i,r);l=t.createRange(),l==null||l.setStart(a.offsetNode,a.offset)}if(l){const a=s.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(l),n.selection.setRng(l)}}else n.execCommand("SelectAll")},mh=n=>{var c,d;const{el:e,editor:t,componentView:s}=n,o=t.runCommand(B.getStateTheme),i=s.model,r={target:e,inline:!0,skin:(o==null?void 0:o.theme)===$i.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:s,component:i}))||{};return{...r,...l}},qr=(n,e=document)=>new Promise((t,s)=>{const o=Array.isArray(n)?[...n]:[n],{head:i}=e,r=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=r.bind(null,l),a.onerror=s,i.appendChild(a)}else t()};r(o)}),gh="rteTinyMce",yh=Q(function(n,e={}){const t={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...e},{cdnScript:s}=t,o=n.Canvas.events,i=async(a,c)=>{const d=a.ownerDocument,u=d.defaultView,h=c==null?void 0:c.view;if(!u||!h){console.warn("Missing required data",{win:u,componentView:h});return}const f=mh({el:a,editor:n,componentView:h,pluginOpts:t}),m=(await u.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",ps),document.body.addEventListener("mousedown",ps),m.on("Change",()=>dh(a)),m.on("blur",()=>m.ui.show()),m.on("OpenWindow",function(){var w;const S=(w=d.querySelector(".tox-dialog"))==null?void 0:w.closest(".tox");S&&(S==null?void 0:S.ownerDocument)!==document&&(document.body.appendChild(S),m.once("CloseWindow",()=>{S&&S.ownerDocument===document&&d.body.appendChild(S)}))}),a.addEventListener("dragstart",_r,{capture:!0}),n.runCommand(B.setStateContextMenu,{enabled:!1}),ph(m,c),{rteEditor:m,rteEditorShallow:b}},r=(a,c)=>{a.ownerDocument.body.removeEventListener("mousedown",ps),document.body.removeEventListener("mousedown",ps),a.removeEventListener("dragstart",_r,{capture:!0}),n.runCommand(B.setStateContextMenu,{enabled:!0}),c.rteEditor.destroy(),c.rteEditorShallow.destroy()};n.on(o.frameLoad,async({window:a})=>{qr(s,a.document)}),n.onReady(()=>{qr(s,document)}),n.setCustomRte({parseContent:!0,async enable(a,c,d){const u=Eo(a);if(u)return u.rteEditor;const h=await i(a,d);return h&&hh(a,h),h==null?void 0:h.rteEditor},disable(a){const c=Eo(a);c&&(fh(a),r(a,c))},getContent(a){var d,u;const c=Eo(a);return c?(u=(d=c.rteEditor).getContent)==null?void 0:u.call(d):a.innerHTML}});const l=uh(n,t.enableOnClick);ee({editor:n,licenseKey:t.licenseKey,plan:F.startup,pluginName:gh,cleanup:()=>{n.RichTextEditor.customRte=void 0,l()}})});function J(n){this.content=n}J.prototype={constructor:J,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 s=t&&t!=n?this.remove(t):this,o=s.find(n),i=s.content.slice();return o==-1?i.push(t||n,e):(i[o+1]=e,t&&(i[o]=t)),new J(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new J(t)},addToStart:function(n,e){return new J([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new J(t)},addBefore:function(n,e,t){var s=this.remove(e),o=s.content.slice(),i=s.find(n);return o.splice(i==-1?o.length:i,0,e,t),new J(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=J.from(n),n.size?new J(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=J.from(n),n.size?new J(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=J.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}},J.from=function(n){if(n instanceof J)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new J(e)};function Gr(n,e,t){for(let s=0;;s++){if(s==n.childCount||s==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(s),i=e.child(s);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){for(let r=0;o.text[r]==i.text[r];r++)t++;return t}if(o.content.size||i.content.size){let r=Gr(o.content,i.content,t+1);if(r!=null)return r}t+=o.nodeSize}}function jr(n,e,t,s){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:s};let r=n.child(--o),l=e.child(--i),a=r.nodeSize;if(r==l){t-=a,s-=a;continue}if(!r.sameMarkup(l))return{a:t,b:s};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--,s--;return{a:t,b:s}}if(r.content.size||l.content.size){let c=jr(r.content,l.content,t-1,s-1);if(c)return c}t-=a,s-=a}}class x{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let s=0;s<e.length;s++)this.size+=e[s].nodeSize}nodesBetween(e,t,s,o=0,i){for(let r=0,l=0;l<t;r++){let a=this.content[r],c=l+a.nodeSize;if(c>e&&s(a,o+l,i||null,r)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),s,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,s,o){let i="",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)&&s&&(r?r=!1:i+=s),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,s=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(s)&&(o[o.length-1]=t.withText(t.text+s.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new x(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let s=[],o=0;if(t>e)for(let i=0,r=0;r<t;i++){let l=this.content[i],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))),s.push(l),o+=l.nodeSize),r=a}return new x(s,o)}cutByIndex(e,t){return e==t?x.empty:e==0&&t==this.content.length?this:new x(this.content.slice(e,t))}replaceChild(e,t){let s=this.content[e];if(s==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-s.nodeSize;return o[e]=t,new x(o,i)}addToStart(e){return new x([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new x(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,s=0;t<this.content.length;t++){let o=this.content[t];e(o,s,t),s+=o.nodeSize}}findDiffStart(e,t=0){return Gr(this,e,t)}findDiffEnd(e,t=this.size,s=e.size){return jr(this,e,t,s)}findIndex(e,t=-1){if(e==0)return ms(0,e);if(e==this.size)return ms(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let s=0,o=0;;s++){let i=this.child(s),r=o+i.nodeSize;if(r>=e)return r==e||t>0?ms(s+1,r):ms(s,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 x.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new x(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return x.empty;let t,s=0;for(let o=0;o<e.length;o++){let i=e[o];s+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(t||(t=e.slice(0,o)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new x(t||e,s)}static from(e){if(!e)return x.empty;if(e instanceof x)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new x([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}x.empty=new x([],0);const Oo={index:0,offset:0};function ms(n,e){return Oo.index=n,Oo.offset=e,Oo}function gs(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 s=0;s<n.length;s++)if(!gs(n[s],e[s]))return!1}else{for(let s in n)if(!(s in e)||!gs(n[s],e[s]))return!1;for(let s in e)if(!(s in n))return!1}return!0}class V{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,s=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!s&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),s=!0),t&&t.push(i)}}return t||(t=e.slice()),s||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&&gs(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 s=e.marks[t.type];if(!s)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=s.create(t.attrs);return s.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let s=0;s<e.length;s++)if(!e[s].eq(t[s]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return V.none;if(e instanceof V)return[e];let t=e.slice();return t.sort((s,o)=>s.type.rank-o.type.rank),t}}V.none=[];class ys extends Error{}class M{constructor(e,t,s){this.content=e,this.openStart=t,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let s=Jr(this.content,e+this.openStart,t);return s&&new M(s,this.openStart,this.openEnd)}removeBetween(e,t){return new M(Kr(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 M.empty;let s=t.openStart||0,o=t.openEnd||0;if(typeof s!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new M(x.fromJSON(e,t.content),s,o)}static maxOpen(e,t=!0){let s=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)s++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new M(e,s,o)}}M.empty=new M(x.empty,0,0);function Kr(n,e,t){let{index:s,offset:o}=n.findIndex(e),i=n.maybeChild(s),{index:r,offset:l}=n.findIndex(t);if(o==e||i.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(s!=r)throw new RangeError("Removing non-flat range");return n.replaceChild(s,i.copy(Kr(i.content,e-o-1,t-o-1)))}function Jr(n,e,t,s){let{index:o,offset:i}=n.findIndex(e),r=n.maybeChild(o);if(i==e||r.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Jr(r.content,e-i-1,t);return l&&n.replaceChild(o,r.copy(l))}function bh(n,e,t){if(t.openStart>n.depth)throw new ys("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new ys("Inconsistent open depths");return Ur(n,e,t,0)}function Ur(n,e,t,s){let o=n.index(s),i=n.node(s);if(o==e.index(s)&&s<n.depth-t.openStart){let r=Ur(n,e,t,s+1);return i.copy(i.content.replaceChild(o,r))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==s&&e.depth==s){let r=n.parent,l=r.content;return vt(r,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:r,end:l}=vh(t,n);return vt(i,Yr(n,r,l,e,s))}else return vt(i,bs(n,e,s))}function Zr(n,e){if(!e.type.compatibleContent(n.type))throw new ys("Cannot join "+e.type.name+" onto "+n.type.name)}function No(n,e,t){let s=n.node(t);return Zr(s,e.node(t)),s}function bt(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 vn(n,e,t,s){let o=(e||n).node(t),i=0,r=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(bt(n.nodeAfter,s),i++));for(let l=i;l<r;l++)bt(o.child(l),s);e&&e.depth==t&&e.textOffset&&bt(e.nodeBefore,s)}function vt(n,e){return n.type.checkContent(e),n.copy(e)}function Yr(n,e,t,s,o){let i=n.depth>o&&No(n,e,o+1),r=s.depth>o&&No(t,s,o+1),l=[];return vn(null,n,o,l),i&&r&&e.index(o)==t.index(o)?(Zr(i,r),bt(vt(i,Yr(n,e,t,s,o+1)),l)):(i&&bt(vt(i,bs(n,e,o+1)),l),vn(e,t,o,l),r&&bt(vt(r,bs(t,s,o+1)),l)),vn(s,null,o,l),new x(l)}function bs(n,e,t){let s=[];if(vn(null,n,t,s),n.depth>t){let o=No(n,e,t+1);bt(vt(o,bs(n,e,t+1)),s)}return vn(e,null,t,s),new x(s)}function vh(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)o=e.node(i).copy(x.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class wn{constructor(e,t,s){this.pos=e,this.path=t,this.parentOffset=s,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 s=this.pos-this.path[this.path.length-1],o=e.child(t);return s?e.child(t).cut(s):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 s=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)o+=s.child(i).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return V.none;if(this.textOffset)return e.child(t).marks;let s=e.maybeChild(t-1),o=e.maybeChild(t);if(!s){let l=s;s=o,o=l}let i=s.marks;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}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let s=t.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!o||!s[i].isInSet(o.marks))&&(s=s[i--].removeFromSet(s));return s}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 s=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);s>=0;s--)if(e.pos<=this.end(s)&&(!t||t(this.node(s))))return new vs(this,e,s);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 s=[],o=0,i=t;for(let r=e;;){let{index:l,offset:a}=r.content.findIndex(i),c=i-a;if(s.push(r,l,o+a),!c||(r=r.child(l),r.isText))break;i=c-1,o+=a+1}return new wn(t,s,i)}static resolveCached(e,t){let s=Xr.get(e);if(s)for(let i=0;i<s.elts.length;i++){let r=s.elts[i];if(r.pos==t)return r}else Xr.set(e,s=new wh);let o=s.elts[s.i]=wn.resolve(e,t);return s.i=(s.i+1)%Sh,o}}class wh{constructor(){this.elts=[],this.i=0}}const Sh=12,Xr=new WeakMap;class vs{constructor(e,t,s){this.$from=e,this.$to=t,this.depth=s}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 Ch=Object.create(null);let wt=class zi{constructor(e,t,s,o=V.none){this.type=e,this.attrs=t,this.marks=o,this.content=s||x.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,s,o=0){this.content.nodesBetween(e,t,s,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,s,o){return this.content.textBetween(e,t,s,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,s){return this.type==e&&gs(this.attrs,t||e.defaultAttrs||Ch)&&V.sameSet(this.marks,s||V.none)}copy(e=null){return e==this.content?this:new zi(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new zi(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,s=!1){if(e==t)return M.empty;let o=this.resolve(e),i=this.resolve(t),r=s?0:o.sharedDepth(t),l=o.start(r),c=o.node(r).content.cut(o.pos-l,i.pos-l);return new M(c,o.depth-r,i.depth-r)}replace(e,t,s){return bh(this.resolve(e),this.resolve(t),s)}nodeAt(e){for(let t=this;;){let{index:s,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(s),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:s}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:s}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:s}=this.content.findIndex(e);if(s<e)return{node:this.content.child(t),index:t,offset:s};let o=this.content.child(t-1);return{node:o,index:t-1,offset:s-o.nodeSize}}resolve(e){return wn.resolveCached(this,e)}resolveNoCache(e){return wn.resolve(this,e)}rangeHasMark(e,t,s){let o=!1;return t>e&&this.nodesBetween(e,t,i=>(s.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Qr(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,s=x.empty,o=0,i=s.childCount){let r=this.contentMatchAt(e).matchFragment(s,o,i),l=r&&r.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(s.child(a).marks))return!1;return!0}canReplaceWith(e,t,s,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(s),r=i&&i.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=V.none;for(let t=0;t<this.marks.length;t++){let s=this.marks[t];s.type.checkAttrs(s.attrs),e=s.addToSet(e)}if(!V.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 s;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=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,s)}let o=x.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,o,s);return i.type.checkAttrs(i.attrs),i}};wt.prototype.text=void 0;class ws extends wt{constructor(e,t,s,o){if(super(e,t,null,o),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Qr(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 ws(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ws(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 Qr(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class St{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let s=new xh(e,t);if(s.next==null)return St.empty;let o=el(s);s.next&&s.err("Unexpected trailing text");let i=Nh(Oh(o));return Ph(i,s),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,s=e.childCount){let o=this;for(let i=t;o&&i<s;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let s=0;s<e.next.length;s++)if(this.next[t].type==e.next[s].type)return!0;return!1}fillBefore(e,t=!1,s=0){let o=[this];function i(r,l){let a=r.matchFragment(e,s);if(a&&(!t||a.validEnd))return x.from(l.map(c=>c.createAndFill()));for(let c=0;c<r.next.length;c++){let{type:d,next:u}=r.next[c];if(!(d.isText||d.hasRequiredAttrs())&&o.indexOf(u)==-1){o.push(u);let h=i(u,l.concat(d));if(h)return h}}return null}return i(this,[])}findWrapping(e){for(let s=0;s<this.wrapCache.length;s+=2)if(this.wrapCache[s]==e)return this.wrapCache[s+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),s=[{match:this,type:null,via:null}];for(;s.length;){let o=s.shift(),i=o.match;if(i.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<i.next.length;r++){let{type:l,next:a}=i.next[r];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(s.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(s){e.push(s);for(let o=0;o<s.next.length;o++)e.indexOf(s.next[o].next)==-1&&t(s.next[o].next)}return t(this),e.map((s,o)=>{let i=o+(s.validEnd?"*":" ")+" ";for(let r=0;r<s.next.length;r++)i+=(r?", ":"")+s.next[r].type.name+"->"+e.indexOf(s.next[r].next);return i}).join(`
191
- `)}}St.empty=new St(!0);class xh{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 el(n){let e=[];do e.push(kh(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function kh(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=Eh(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=Mh(n,e);else break;return e}function tl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Mh(n,e){let t=tl(n),s=t;return n.eat(",")&&(n.next!="}"?s=tl(n):s=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:s,expr:e}}function Ah(n,e){let t=n.nodeTypes,s=t[e];if(s)return[s];let o=[];for(let i in t){let r=t[i];r.isInGroup(e)&&o.push(r)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Eh(n){if(n.eat("(")){let e=el(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=Ah(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 Oh(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function s(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 i(r,l){if(r.type=="choice")return r.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(r.type=="seq")for(let a=0;;a++){let c=i(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 s(l,a),o(i(r.expr,a),a),[s(a)]}else if(r.type=="plus"){let a=t();return o(i(r.expr,l),a),o(i(r.expr,a),a),[s(a)]}else{if(r.type=="opt")return[s(l)].concat(i(r.expr,l));if(r.type=="range"){let a=l;for(let c=0;c<r.min;c++){let d=t();o(i(r.expr,a),d),a=d}if(r.max==-1)o(i(r.expr,a),a);else for(let c=r.min;c<r.max;c++){let d=t();s(a,d),o(i(r.expr,a),d),a=d}return[s(a)]}else{if(r.type=="name")return[s(l,void 0,r.value)];throw new Error("Unknown expr type")}}}}function nl(n,e){return e-n}function sl(n,e){let t=[];return s(e),t.sort(nl);function s(o){let i=n[o];if(i.length==1&&!i[0].term)return s(i[0].to);t.push(o);for(let r=0;r<i.length;r++){let{term:l,to:a}=i[r];!l&&t.indexOf(a)==-1&&s(a)}}}function Nh(n){let e=Object.create(null);return t(sl(n,0));function t(s){let o=[];s.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]);sl(n,a).forEach(d=>{c||o.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[s.join(",")]=new St(s.indexOf(n.length-1)>-1);for(let r=0;r<o.length;r++){let l=o[r][1].sort(nl);i.next.push({type:o[r][0],next:e[l.join(",")]||t(l)})}return i}}function Ph(n,e){for(let t=0,s=[n];t<s.length;t++){let o=s[t],i=!o.validEnd,r=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];r.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),s.indexOf(c)==-1&&s.push(c)}i&&e.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function ol(n){let e=Object.create(null);for(let t in n){let s=n[t];if(!s.hasDefault)return null;e[t]=s.default}return e}function il(n,e){let t=Object.create(null);for(let s in n){let o=e&&e[s];if(o===void 0){let i=n[s];if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+s)}t[s]=o}return t}function rl(n,e,t,s){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 i=n[o];i.validate&&i.validate(e[o])}}function ll(n,e){let t=Object.create(null);if(e)for(let s in e)t[s]=new Rh(n,s,e[s]);return t}let al=class sd{constructor(e,t,s){this.name=e,this.schema=t,this.spec=s,this.markSet=null,this.groups=s.group?s.group.split(" "):[],this.attrs=ll(e,s.attrs),this.defaultAttrs=ol(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(s.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==St.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:il(this.attrs,e)}create(e=null,t,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new wt(this,this.computeAttrs(e),x.from(t),V.setFrom(s))}createChecked(e=null,t,s){return t=x.from(t),this.checkContent(t),new wt(this,this.computeAttrs(e),t,V.setFrom(s))}createAndFill(e=null,t,s){if(e=this.computeAttrs(e),t=x.from(t),t.size){let r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(x.empty,!0);return i?new wt(this,e,t.append(i),V.setFrom(s)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let s=0;s<e.childCount;s++)if(!this.allowsMarks(e.child(s).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){rl(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 s=0;s<e.length;s++)this.allowsMarkType(e[s].type)?t&&t.push(e[s]):t||(t=e.slice(0,s));return t?t.length?t:V.none:e}static compile(e,t){let s=Object.create(null);e.forEach((i,r)=>s[i]=new sd(i,t,r));let o=t.spec.topNode||"doc";if(!s[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let i in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function Ih(n,e,t){let s=t.split("|");return o=>{let i=o===null?"null":typeof o;if(s.indexOf(i)<0)throw new RangeError(`Expected value of type ${s} for attribute ${e} on type ${n}, got ${i}`)}}class Rh{constructor(e,t,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?Ih(e,t,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class Ss{constructor(e,t,s,o){this.name=e,this.rank=t,this.schema=s,this.spec=o,this.attrs=ll(e,o.attrs),this.excluded=null;let i=ol(this.attrs);this.instance=i?new V(this,i):null}create(e=null){return!e&&this.instance?this.instance:new V(this,il(this.attrs,e))}static compile(e,t){let s=Object.create(null),o=0;return e.forEach((i,r)=>s[i]=new Ss(i,o++,t,r)),s}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){rl(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=J.from(e.nodes),t.marks=J.from(e.marks||{}),this.nodes=al.compile(this.spec.nodes,this),this.marks=Ss.compile(this.spec.marks,this);let s=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],r=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=s[r]||(s[r]=St.parse(r,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?cl(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],r=i.spec.excludes;i.excluded=r==null?[i]:r==""?[]:cl(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,s,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof al){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,s,o)}text(e,t){let s=this.nodes.text;return new ws(s,s.defaultAttrs,e,V.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return wt.fromJSON(this,e)}markFromJSON(e){return V.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function cl(n,e){let t=[];for(let s=0;s<e.length;s++){let o=e[s],i=n.marks[o],r=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(r=a)}if(!r)throw new SyntaxError("Unknown mark type: '"+e[s]+"'")}return t}function zh(n){return n.tag!=null}function Lh(n){return n.style!=null}class Ut{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let s=this.matchedStyles=[];t.forEach(o=>{if(zh(o))this.tags.push(o);else if(Lh(o)){let i=/[^=]*/.exec(o.style)[0];s.indexOf(i)<0&&s.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let s=new fl(this,t,!1);return s.addAll(e,V.none,t.from,t.to),s.finish()}parseSlice(e,t={}){let s=new fl(this,t,!0);return s.addAll(e,V.none,t.from,t.to),M.maxOpen(s.finish())}matchTag(e,t,s){for(let o=s?this.tags.indexOf(s)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(Hh(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let r=i.getAttrs(e);if(r===!1)continue;i.attrs=r||void 0}return i}}}matchStyle(e,t,s,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let r=this.styles[i],l=r.style;if(!(l.indexOf(e)!=0||r.context&&!s.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 s(o){let i=o.priority==null?50:o.priority,r=0;for(;r<t.length;r++){let l=t[r];if((l.priority==null?50:l.priority)<i)break}t.splice(r,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(r=>{s(r=pl(r)),r.mark||r.ignore||r.clearMark||(r.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(r=>{s(r=pl(r)),r.node||r.ignore||r.mark||(r.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ut(e,Ut.schemaRules(e)))}}const dl={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},Vh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ul={ol:!0,ul:!0},Cs=1,xs=2,Sn=4;function hl(n,e,t){return e!=null?(e?Cs:0)|(e==="full"?xs:0):n&&n.whitespace=="pre"?Cs|xs:t&~Sn}class ks{constructor(e,t,s,o,i,r){this.type=e,this.attrs=t,this.marks=s,this.solid=o,this.options=r,this.content=[],this.activeMarks=V.none,this.match=i||(r&Sn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(x.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let s=this.type.contentMatch,o;return(o=s.findWrapping(e.type))?(this.match=s,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Cs)){let s=this.content[this.content.length-1],o;if(s&&s.isText&&(o=/[ \t\r\n\u000c]+$/.exec(s.text))){let i=s;s.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let t=x.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(x.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&&!dl.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class fl{constructor(e,t,s){this.parser=e,this.options=t,this.isOpen=s,this.open=0;let o=t.topNode,i,r=hl(null,t.preserveWhitespace,0)|(s?Sn:0);o?i=new ks(o.type,o.attrs,V.none,!0,t.topMatch||o.type.contentMatch,r):s?i=new ks(null,null,V.none,!0,null,r):i=new ks(e.schema.topNodeType,null,V.none,!0,null,r),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let s=e.nodeValue,o=this.top;if(o.options&xs||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(s)){if(o.options&Cs)o.options&xs?s=s.replace(/\r\n?/g,`
192
- `):s=s.replace(/\r?\n|\r/g," ");else if(s=s.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(s)&&this.open==this.nodes.length-1){let i=o.content[o.content.length-1],r=e.previousSibling;(!i||r&&r.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(s=s.slice(1))}s&&this.insertNode(this.parser.schema.text(s),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,s){let o=e.nodeName.toLowerCase(),i;ul.hasOwnProperty(o)&&this.parser.normalizeLists&&Bh(e);let r=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,s));if(r?r.ignore:Vh.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(dl.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?i:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
193
- `),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 s=e.style;if(s&&s.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],r=s.getPropertyValue(i);if(r)for(let l=void 0;;){let a=this.parser.matchStyle(i,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,s,o){let i,r;if(t.node)if(r=this.parser.schema.nodes[t.node],r.isLeaf)this.insertNode(r.create(t.attrs),s)||this.leafFallback(e,s);else{let a=this.enter(r,t.attrs||null,s,t.preserveWhitespace);a&&(i=!0,s=a)}else{let a=this.parser.schema.marks[t.mark];s=s.concat(a.create(t.attrs))}let l=this.top;if(r&&r.isLeaf)this.findInside(e);else if(o)this.addElement(e,s,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,s));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,s),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,s,o){let i=s||0;for(let r=s?e.childNodes[s]:e.firstChild,l=o==null?null:e.childNodes[o];r!=l;r=r.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(r,t);this.findAtPoint(e,i)}findPlace(e,t){let s,o;for(let i=this.open;i>=0;i--){let r=this.nodes[i],l=r.findWrapping(e);if(l&&(!s||s.length>l.length)&&(s=l,o=r,!l.length)||r.solid)break}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)t=this.enterInner(s[i],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 s=this.findPlace(e,t);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=V.none;for(let r of s.concat(e.marks))(o.type?o.type.allowsMarkType(r.type):ml(r.type,e.type))&&(i=r.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,t,s,o){let i=this.findPlace(e.create(t),s);return i&&(i=this.enterInner(e,t,s,!0,o)),i}enterInner(e,t,s,o=!1,i){this.closeExtra();let r=this.top;r.match=r.match&&r.match.matchType(e);let l=hl(e,i,r.options);r.options&Sn&&r.content.length==0&&(l|=Sn);let a=V.none;return s=s.filter(c=>(r.type?r.type.allowsMarkType(c.type):ml(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new ks(e,t,a,o,null,l)),this.open++,s}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 s=this.nodes[t].content;for(let o=s.length-1;o>=0;o--)e+=s[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let s=0;s<this.find.length;s++)this.find[s].node==e&&this.find[s].offset==t&&(this.find[s].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,s){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)&(s?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("/"),s=this.options.context,o=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),i=-(s?s.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>=i;a--)if(r(l-1,a))return!0;return!1}else{let d=a>0||a==0&&o?this.nodes[a].type:s&&a>=i?s.node(a-i).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 s=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let t in this.parser.schema.nodes){let s=this.parser.schema.nodes[t];if(s.isTextblock&&s.defaultAttrs)return s}}}function Bh(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let s=e.nodeType==1?e.nodeName.toLowerCase():null;s&&ul.hasOwnProperty(s)&&t?(t.appendChild(e),e=t):s=="li"?t=e:s&&(t=null)}}function Hh(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function pl(n){let e={};for(let t in n)e[t]=n[t];return e}function ml(n,e){let t=e.schema.nodes;for(let s in t){let o=t[s];if(!o.allowsMarkType(n))continue;let i=[],r=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&r(d))return!0}};if(r(o.contentMatch))return!0}}class Ct{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},s){s||(s=Po(t).createDocumentFragment());let o=s,i=[];return e.forEach(r=>{if(i.length||r.marks.length){let l=0,a=0;for(;l<i.length&&a<r.marks.length;){let c=r.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)o=i.pop()[1];for(;a<r.marks.length;){let c=r.marks[a++],d=this.serializeMark(c,r.isInline,t);d&&(i.push([c,o]),o.appendChild(d.dom),o=d.contentDOM||d.dom)}}o.appendChild(this.serializeNodeInner(r,t))}),s}serializeNodeInner(e,t){let{dom:s,contentDOM:o}=Ts(Po(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 s}serializeNode(e,t={}){let s=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(s),s=i.dom)}return s}serializeMark(e,t,s={}){let o=this.marks[e.type.name];return o&&Ts(Po(s),o(e,t),null,e.attrs)}static renderSpec(e,t,s=null,o){return Ts(e,t,s,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ct(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=gl(e.nodes);return t.text||(t.text=s=>s.text),t}static marksFromSchema(e){return gl(e.marks)}}function gl(n){let e={};for(let t in n){let s=n[t].spec.toDOM;s&&(e[t]=s)}return e}function Po(n){return n.document||window.document}const yl=new WeakMap;function $h(n){let e=yl.get(n);return e===void 0&&yl.set(n,e=Fh(n)),e}function Fh(n){let e=null;function t(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")e||(e=[]),e.push(s);else for(let o=0;o<s.length;o++)t(s[o]);else for(let o in s)t(s[o])}return t(n),e}function Ts(n,e,t,s){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],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(s&&(i=$h(s))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let 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 u in c)if(c[u]!=null){let h=u.indexOf(" ");h>0?a.setAttributeNS(u.slice(0,h),u.slice(h+1),c[u]):a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let h=e[u];if(h===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:p}=Ts(n,h,t,s);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const bl=65535,vl=Math.pow(2,16);function Wh(n,e){return n+e*vl}function wl(n){return n&bl}function _h(n){return(n-(n&bl))/vl}const Sl=1,Cl=2,Ms=4,xl=8;class Io{constructor(e,t,s){this.pos=e,this.delInfo=t,this.recover=s}get deleted(){return(this.delInfo&xl)>0}get deletedBefore(){return(this.delInfo&(Sl|Ms))>0}get deletedAfter(){return(this.delInfo&(Cl|Ms))>0}get deletedAcross(){return(this.delInfo&Ms)>0}}class fe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&fe.empty)return fe.empty}recover(e){let t=0,s=wl(e);if(!this.inverted)for(let o=0;o<s;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[s*3]+t+_h(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,s){let o=0,i=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+i],d=this.ranges[l+r],u=a+c;if(e<=u){let h=c?e==a?-1:e==u?1:t:t,f=a+o+(h<0?0:d);if(s)return f;let p=e==(t<0?a:u)?null:Wh(l/3,e-a),m=e==a?Cl:e==u?Sl:Ms;return(t<0?e!=a:e!=u)&&(m|=xl),new Io(f,m,p)}o+=d-c}return s?e+o:new Io(e+o,0,null)}touches(e,t){let s=0,o=wl(t),i=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?s:0);if(a>e)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==o*3)return!0;s+=this.ranges[l+r]-c}return!1}forEach(e){let t=this.inverted?2:1,s=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let r=this.ranges[o],l=r-(this.inverted?i:0),a=r+(this.inverted?0:i),c=this.ranges[o+t],d=this.ranges[o+s];e(l,l+c,a,a+d),i+=d-c}}invert(){return new fe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?fe.empty:new fe(e<0?[0,-e,0]:[0,0,e])}}fe.empty=new fe([]);class Zt{constructor(e=[],t,s=0,o=e.length){this.maps=e,this.mirror=t,this.from=s,this.to=o}slice(e=0,t=this.maps.length){return new Zt(this.maps,this.mirror,e,t)}copy(){return new Zt(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,s=this.maps.length;t<e.maps.length;t++){let o=e.getMirror(t);this.appendMap(e.maps[t],o!=null&&o<t?s+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,s=this.maps.length+e.maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e.maps[t].invert(),o!=null&&o>t?s-o-1:void 0)}}invert(){let e=new Zt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let s=this.from;s<this.to;s++)e=this.maps[s].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,s){let o=0;for(let i=this.from;i<this.to;i++){let r=this.maps[i],l=r.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this.maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return s?e:new Io(e,o,null)}}const Ro=Object.create(null);class te{getMap(){return fe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let s=Ro[t.stepType];if(!s)throw new RangeError(`No step type ${t.stepType} defined`);return s.fromJSON(e,t)}static jsonID(e,t){if(e in Ro)throw new RangeError("Duplicate use of step JSON ID "+e);return Ro[e]=t,t.prototype.jsonID=e,t}}class q{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new q(e,null)}static fail(e){return new q(null,e)}static fromReplace(e,t,s,o){try{return q.ok(e.replace(t,s,o))}catch(i){if(i instanceof ys)return q.fail(i.message);throw i}}}function Do(n,e,t){let s=[];for(let o=0;o<n.childCount;o++){let i=n.child(o);i.content.size&&(i=i.copy(Do(i.content,e,i))),i.isInline&&(i=e(i,t,o)),s.push(i)}return x.fromArray(s)}class Je extends te{constructor(e,t,s){super(),this.from=e,this.to=t,this.mark=s}apply(e){let t=e.slice(this.from,this.to),s=e.resolve(this.from),o=s.node(s.sharedDepth(this.to)),i=new M(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 q.fromReplace(e,this.from,this.to,i)}invert(){return new Oe(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deleted&&s.deleted||t.pos>=s.pos?null:new Je(t.pos,s.pos,this.mark)}merge(e){return e instanceof Je&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Je(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 Je(t.from,t.to,e.markFromJSON(t.mark))}}te.jsonID("addMark",Je);class Oe extends te{constructor(e,t,s){super(),this.from=e,this.to=t,this.mark=s}apply(e){let t=e.slice(this.from,this.to),s=new M(Do(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return q.fromReplace(e,this.from,this.to,s)}invert(){return new Je(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deleted&&s.deleted||t.pos>=s.pos?null:new Oe(t.pos,s.pos,this.mark)}merge(e){return e instanceof Oe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Oe(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 Oe(t.from,t.to,e.markFromJSON(t.mark))}}te.jsonID("removeMark",Oe);class Ue extends te{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let s=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new M(x.from(s),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let s=this.mark.addToSet(t.marks);if(s.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(s))return new Ue(this.pos,t.marks[o]);return new Ue(this.pos,this.mark)}}return new Yt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ue(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 Ue(t.pos,e.markFromJSON(t.mark))}}te.jsonID("addNodeMark",Ue);class Yt extends te{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let s=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new M(x.from(s),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ue(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Yt(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 Yt(t.pos,e.markFromJSON(t.mark))}}te.jsonID("removeNodeMark",Yt);class ne extends te{constructor(e,t,s,o=!1){super(),this.from=e,this.to=t,this.slice=s,this.structure=o}apply(e){return this.structure&&zo(e,this.from,this.to)?q.fail("Structure replace would overwrite content"):q.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new fe([this.from,this.to-this.from,this.slice.size])}invert(e){return new ne(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deletedAcross&&s.deletedAcross?null:new ne(t.pos,Math.max(t.pos,s.pos),this.slice)}merge(e){if(!(e instanceof ne)||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?M.empty:new M(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ne(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?M.empty:new M(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ne(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 ne(t.from,t.to,M.fromJSON(e,t.slice),!!t.structure)}}te.jsonID("replace",ne);class U extends te{constructor(e,t,s,o,i,r,l=!1){super(),this.from=e,this.to=t,this.gapFrom=s,this.gapTo=o,this.slice=i,this.insert=r,this.structure=l}apply(e){if(this.structure&&(zo(e,this.from,this.gapFrom)||zo(e,this.gapTo,this.to)))return q.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return q.fail("Gap is not a flat range");let s=this.slice.insertAt(this.insert,t.content);return s?q.fromReplace(e,this.from,this.to,s):q.fail("Content does not fit in gap")}getMap(){return new fe([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 U(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),s=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?s.pos:e.map(this.gapTo,1);return t.deletedAcross&&s.deletedAcross||o<t.pos||i>s.pos?null:new U(t.pos,s.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new U(t.from,t.to,t.gapFrom,t.gapTo,M.fromJSON(e,t.slice),t.insert,!!t.structure)}}te.jsonID("replaceAround",U);function zo(n,e,t){let s=n.resolve(e),o=t-e,i=s.depth;for(;o>0&&i>0&&s.indexAfter(i)==s.node(i).childCount;)i--,o--;if(o>0){let r=s.node(i).maybeChild(s.indexAfter(i));for(;o>0;){if(!r||r.isLeaf)return!0;r=r.firstChild,o--}}return!1}function qh(n,e,t,s){let o=[],i=[],r,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!s.isInSet(u)&&d.type.allowsMarkType(s.type)){let h=Math.max(c,e),f=Math.min(c+a.nodeSize,t),p=s.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(p)||(r&&r.to==h&&r.mark.eq(u[m])?r.to=f:o.push(r=new Oe(h,f,u[m])));l&&l.to==h?l.to=f:i.push(l=new Je(h,f,s))}}),o.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function Gh(n,e,t,s){let o=[],i=0;n.doc.nodesBetween(e,t,(r,l)=>{if(!r.isInline)return;i++;let a=null;if(s instanceof Ss){let c=r.marks,d;for(;d=s.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else s?s.isInSet(r.marks)&&(a=[s]):a=r.marks;if(a&&a.length){let c=Math.min(l+r.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],h;for(let f=0;f<o.length;f++){let p=o[f];p.step==i-1&&u.eq(o[f].style)&&(h=p)}h?(h.to=c,h.step=i):o.push({style:u,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(r=>n.step(new Oe(r.from,r.to,r.style)))}function Lo(n,e,t,s=t.contentMatch,o=!0){let i=n.doc.nodeAt(e),r=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,u=s.matchType(c.type);if(!u)r.push(new ne(l,d,M.empty));else{s=u;for(let h=0;h<c.marks.length;h++)t.allowsMarkType(c.marks[h].type)||n.step(new Oe(l,d,c.marks[h]));if(o&&c.isText&&t.whitespace!="pre"){let h,f=/\r?\n|\r/g,p;for(;h=f.exec(c.text);)p||(p=new M(x.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),r.push(new ne(l+h.index,l+h.index+h[0].length,p))}}l=d}if(!s.validEnd){let a=s.fillBefore(x.empty,!0);n.replace(l,l,new M(a,0,0))}for(let a=r.length-1;a>=0;a--)n.step(r[a])}function jh(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function As(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let s=n.depth;;--s){let o=n.$from.node(s),i=n.$from.index(s),r=n.$to.indexAfter(s);if(s<n.depth&&o.canReplace(i,r,t))return s;if(s==0||o.type.spec.isolating||!jh(o,i,r))break}return null}function Kh(n,e,t){let{$from:s,$to:o,depth:i}=e,r=s.before(i+1),l=o.after(i+1),a=r,c=l,d=x.empty,u=0;for(let p=i,m=!1;p>t;p--)m||s.index(p)>0?(m=!0,d=x.from(s.node(p).copy(d)),u++):a--;let h=x.empty,f=0;for(let p=i,m=!1;p>t;p--)m||o.after(p+1)<o.end(p)?(m=!0,h=x.from(o.node(p).copy(h)),f++):c++;n.step(new U(a,c,r,l,new M(d.append(h),u,f),d.size-u,!0))}function kl(n,e,t=null,s=n){let o=Jh(n,e),i=o&&Uh(s,e);return i?o.map(Tl).concat({type:e,attrs:t}).concat(i.map(Tl)):null}function Tl(n){return{type:n,attrs:null}}function Jh(n,e){let{parent:t,startIndex:s,endIndex:o}=n,i=t.contentMatchAt(s).findWrapping(e);if(!i)return null;let r=i.length?i[0]:e;return t.canReplaceWith(s,o,r)?i:null}function Uh(n,e){let{parent:t,startIndex:s,endIndex:o}=n,i=t.child(s),r=e.contentMatch.findWrapping(i.type);if(!r)return null;let a=(r.length?r[r.length-1]:e).contentMatch;for(let c=s;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:r}function Zh(n,e,t){let s=x.empty;for(let r=t.length-1;r>=0;r--){if(s.size){let l=t[r].type.contentMatch.matchFragment(s);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=x.from(t[r].type.create(t[r].attrs,s))}let o=e.start,i=e.end;n.step(new U(o,i,o,i,new M(s,0,0),t.length,!0))}function Yh(n,e,t,s,o){if(!s.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(r,l)=>{let a=typeof o=="function"?o(r):o;if(r.isTextblock&&!r.hasMarkup(s,a)&&Xh(n.doc,n.mapping.slice(i).map(l),s)){let c=null;if(s.schema.linebreakReplacement){let f=s.whitespace=="pre",p=!!s.contentMatch.matchType(s.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&Al(n,r,l,i),Lo(n,n.mapping.slice(i).map(l,1),s,void 0,c===null);let d=n.mapping.slice(i),u=d.map(l,1),h=d.map(l+r.nodeSize,1);return n.step(new U(u,h,u+1,h-1,new M(x.from(s.create(a,null,r.marks)),0,0),1,!0)),c===!0&&Ml(n,r,l,i),!1}})}function Ml(n,e,t,s){e.forEach((o,i)=>{if(o.isText){let r,l=/\r?\n|\r/g;for(;r=l.exec(o.text);){let a=n.mapping.slice(s).map(t+1+i+r.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Al(n,e,t,s){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let r=n.mapping.slice(s).map(t+1+i);n.replaceWith(r,r+1,e.type.schema.text(`
194
- `))}})}function Xh(n,e,t){let s=n.resolve(e),o=s.index();return s.parent.canReplaceWith(o,o+1,t)}function Qh(n,e,t,s,o){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let r=t.create(s,null,o||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,r);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new U(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new M(x.from(r),0,0),1,!0))}function Xt(n,e,t=1,s){let o=n.resolve(e),i=o.depth-t,r=s&&s[s.length-1]||o.parent;if(i<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>i;c--,d--){let u=o.node(c),h=o.index(c);if(u.type.spec.isolating)return!1;let f=u.content.cutByIndex(h,u.childCount),p=s&&s[d+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let m=s&&s[d]||u;if(!u.canReplace(h+1,u.childCount)||!m.type.validContent(f))return!1}let l=o.indexAfter(i),a=s&&s[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function ef(n,e,t=1,s){let o=n.doc.resolve(e),i=x.empty,r=x.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){i=x.from(o.node(l).copy(i));let d=s&&s[c];r=x.from(d?d.type.create(d.attrs,r):o.node(l).copy(r))}n.step(new ne(e,e,new M(i.append(r),t,t),!0))}function Es(n,e){let t=n.resolve(e),s=t.index();return nf(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(s,s+1)}function tf(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:s}=n.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),r=i.type==s?n.type.schema.nodes.text:i.type;if(t=t.matchType(r),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function nf(n,e){return!!(n&&e&&!n.isLeaf&&tf(n,e))}function sf(n,e,t){let s=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(e-t),r=i.node().type;if(o&&r.inlineContent){let d=r.whitespace=="pre",u=!!r.contentMatch.matchType(o);d&&!u?s=!1:!d&&u&&(s=!0)}let l=n.steps.length;if(s===!1){let d=n.doc.resolve(e+t);Al(n,d.node(),d.before(),l)}r.inlineContent&&Lo(n,e+t-1,r,i.node().contentMatchAt(i.index()),s==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new ne(c,a.map(e+t,-1),M.empty,!0)),s===!0){let d=n.doc.resolve(c);Ml(n,d.node(),d.before(),n.steps.length)}return n}function of(n,e,t){let s=n.resolve(e);if(s.parent.canReplaceWith(s.index(),s.index(),t))return e;if(s.parentOffset==0)for(let o=s.depth-1;o>=0;o--){let i=s.index(o);if(s.node(o).canReplaceWith(i,i,t))return s.before(o+1);if(i>0)return null}if(s.parentOffset==s.parent.content.size)for(let o=s.depth-1;o>=0;o--){let i=s.indexAfter(o);if(s.node(o).canReplaceWith(i,i,t))return s.after(o+1);if(i<s.node(o).childCount)return null}return null}function rf(n,e,t){let s=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let i=0;i<t.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let r=s.depth;r>=0;r--){let l=r==s.depth?0:s.pos<=(s.start(r+1)+s.end(r+1))/2?-1:1,a=s.index(r)+(l>0?1:0),c=s.node(r),d=!1;if(i==1)d=c.canReplace(a,a,o);else{let u=c.contentMatchAt(a).findWrapping(o.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?s.pos:l<0?s.before(r+1):s.after(r+1)}return null}function Vo(n,e,t=e,s=M.empty){if(e==t&&!s.size)return null;let o=n.resolve(e),i=n.resolve(t);return El(o,i,s)?new ne(e,t,s):new lf(o,i,s).fit()}function El(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class lf{constructor(e,t,s){this.$from=e,this.$to=t,this.unplaced=s,this.frontier=[],this.placed=x.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=x.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,s=this.$from,o=this.close(e<0?this.$to:s.doc.resolve(e));if(!o)return null;let i=this.placed,r=s.depth,l=o.depth;for(;r&&l&&i.childCount==1;)i=i.firstChild.content,r--,l--;let a=new M(i,r,l);return e>-1?new U(s.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||s.pos!=this.$to.pos?new ne(s.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,s=0,o=this.unplaced.openEnd;s<e;s++){let i=t.firstChild;if(t.childCount>1&&(o=0),i.type.spec.isolating&&o<=s){e=s;break}t=i.content}for(let t=1;t<=2;t++)for(let s=t==1?e:this.unplaced.openStart;s>=0;s--){let o,i=null;s?(i=Bo(this.unplaced.content,s-1).firstChild,o=i.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,u=null;if(t==1&&(r?c.matchType(r.type)||(u=c.fillBefore(x.from(r),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:s,frontierDepth:l,parent:i,inject:u};if(t==2&&r&&(d=c.findWrapping(r.type)))return{sliceDepth:s,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:s}=this.unplaced,o=Bo(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new M(e,t+1,Math.max(s,o.size+t>=e.size-s?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:s}=this.unplaced,o=Bo(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new M(Cn(e,t-1,1),t-1,i?t-1:s)}else this.unplaced=new M(Cn(e,t,1),t,s)}placeNodes({sliceDepth:e,frontierDepth:t,parent:s,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let r=this.unplaced,l=s?s.content:r.content,a=r.openStart-e,c=0,d=[],{match:u,type:h}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)d.push(o.child(m));u=u.matchFragment(o)}let f=l.size+e-(r.content.size-r.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,d.push(Ol(m.mark(h.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=xn(this.placed,t,x.from(d)),this.frontier[t].match=u,p&&f<0&&s&&s.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?M.empty:new M(Cn(r.content,e-1,1),e-1,f<0?r.openEnd:e-1):new M(Cn(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||!Ho(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:s}=this.$to,o=this.$to.after(s);for(;s>1&&o==this.$to.end(--s);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:s,type:o}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),r=Ho(e,t,o,s,i);if(r){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Ho(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:r,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=xn(this.placed,t.depth,t.fit)),e=t.move;for(let s=t.depth+1;s<=e.depth;s++){let o=e.node(s),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(s));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,s){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=xn(this.placed,this.depth,x.from(e.create(t,s))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(x.empty,!0);t.childCount&&(this.placed=xn(this.placed,this.frontier.length,t))}}function Cn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Cn(n.firstChild.content,e-1,t)))}function xn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(xn(n.lastChild.content,e-1,t)))}function Bo(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Ol(n,e,t){if(e<=0)return n;let s=n.content;return e>1&&(s=s.replaceChild(0,Ol(s.firstChild,e-1,s.childCount==1?t-1:0))),e>0&&(s=n.type.contentMatch.fillBefore(s).append(s),t<=0&&(s=s.append(n.type.contentMatch.matchFragment(s).fillBefore(x.empty,!0)))),n.copy(s)}function Ho(n,e,t,s,o){let i=n.node(e),r=o?n.indexAfter(e):n.index(e);if(r==i.childCount&&!t.compatibleContent(i.type))return null;let l=s.fillBefore(i.content,!0,r);return l&&!af(t,i.content,r)?l:null}function af(n,e,t){for(let s=t;s<e.childCount;s++)if(!n.allowsMarks(e.child(s).marks))return!0;return!1}function cf(n){return n.spec.defining||n.spec.definingForContent}function df(n,e,t,s){if(!s.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),i=n.doc.resolve(t);if(El(o,i,s))return n.step(new ne(e,t,s));let r=Pl(o,n.doc.resolve(t));r[r.length-1]==0&&r.pop();let l=-(o.depth+1);r.unshift(l);for(let h=o.depth,f=o.pos-1;h>0;h--,f--){let p=o.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;r.indexOf(h)>-1?l=h:o.before(h)==f&&r.splice(1,0,-h)}let a=r.indexOf(l),c=[],d=s.openStart;for(let h=s.content,f=0;;f++){let p=h.firstChild;if(c.push(p),f==s.openStart)break;h=p.content}for(let h=d-1;h>=0;h--){let f=c[h],p=cf(f.type);if(p&&!f.sameMarkup(o.node(Math.abs(l)-1)))d=h;else if(p||!f.type.isTextblock)break}for(let h=s.openStart;h>=0;h--){let f=(h+d+1)%(s.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 S=o.node(g-1),y=o.index(g-1);if(S.canReplaceWith(y,y,p.type,p.marks))return n.replace(o.before(g),b?i.after(g):t,new M(Nl(s.content,0,s.openStart,f),f,s.openEnd))}}let u=n.steps.length;for(let h=r.length-1;h>=0&&(n.replace(e,t,s),!(n.steps.length>u));h--){let f=r[h];f<0||(e=o.before(f),t=i.after(f))}}function Nl(n,e,t,s,o){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(Nl(i.content,e+1,t,s,i)))}if(e>s){let i=o.contentMatchAt(0),r=i.fillBefore(n).append(n);n=r.append(i.matchFragment(r).fillBefore(x.empty,!0))}return n}function uf(n,e,t,s){if(!s.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=of(n.doc,e,s.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new M(x.from(s),0,0))}function hf(n,e,t){let s=n.doc.resolve(e),o=n.doc.resolve(t),i=Pl(s,o);for(let r=0;r<i.length;r++){let l=i[r],a=r==i.length-1;if(a&&l==0||s.node(l).type.contentMatch.validEnd)return n.delete(s.start(l),o.end(l));if(l>0&&(a||s.node(l-1).canReplace(s.index(l-1),o.indexAfter(l-1))))return n.delete(s.before(l),o.after(l))}for(let r=1;r<=s.depth&&r<=o.depth;r++)if(e-s.start(r)==s.depth-r&&t>s.end(r)&&o.end(r)-t!=o.depth-r&&s.start(r-1)==o.start(r-1)&&s.node(r-1).canReplace(s.index(r-1),o.index(r-1)))return n.delete(s.before(r),t);n.delete(e,t)}function Pl(n,e){let t=[],s=Math.min(n.depth,e.depth);for(let o=s;o>=0;o--){let i=n.start(o);if(i<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&t.push(o)}return t}class Qt extends te{constructor(e,t,s){super(),this.pos=e,this.attr=t,this.value=s}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at attribute step's position");let s=Object.create(null);for(let i in t.attrs)s[i]=t.attrs[i];s[this.attr]=this.value;let o=t.type.create(s,null,t.marks);return q.fromReplace(e,this.pos,this.pos+1,new M(x.from(o),0,t.isLeaf?0:1))}getMap(){return fe.empty}invert(e){return new Qt(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 Qt(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 Qt(t.pos,t.attr,t.value)}}te.jsonID("attr",Qt);class kn extends te{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 s=e.type.create(t,e.content,e.marks);return q.ok(s)}getMap(){return fe.empty}invert(e){return new kn(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 kn(t.attr,t.value)}}te.jsonID("docAttr",kn);let en=class extends Error{};en=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},en.prototype=Object.create(Error.prototype),en.prototype.constructor=en,en.prototype.name="TransformError";class Il{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Zt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new en(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,s=M.empty){let o=Vo(this.doc,e,t,s);return o&&this.step(o),this}replaceWith(e,t,s){return this.replace(e,t,new M(x.from(s),0,0))}delete(e,t){return this.replace(e,t,M.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,s){return df(this,e,t,s),this}replaceRangeWith(e,t,s){return uf(this,e,t,s),this}deleteRange(e,t){return hf(this,e,t),this}lift(e,t){return Kh(this,e,t),this}join(e,t=1){return sf(this,e,t),this}wrap(e,t){return Zh(this,e,t),this}setBlockType(e,t=e,s,o=null){return Yh(this,e,t,s,o),this}setNodeMarkup(e,t,s=null,o){return Qh(this,e,t,s,o),this}setNodeAttribute(e,t,s){return this.step(new Qt(e,t,s)),this}setDocAttribute(e,t){return this.step(new kn(e,t)),this}addNodeMark(e,t){return this.step(new Ue(e,t)),this}removeNodeMark(e,t){if(!(t instanceof V)){let s=this.doc.nodeAt(e);if(!s)throw new RangeError("No node at position "+e);if(t=t.isInSet(s.marks),!t)return this}return this.step(new Yt(e,t)),this}split(e,t=1,s){return ef(this,e,t,s),this}addMark(e,t,s){return qh(this,e,t,s),this}removeMark(e,t,s){return Gh(this,e,t,s),this}clearIncompatible(e,t,s){return Lo(this,e,t,s),this}}const $o=Object.create(null);class I{constructor(e,t,s){this.$anchor=e,this.$head=t,this.ranges=s||[new Rl(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=M.empty){let s=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=s,s=s.lastChild;let i=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(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?M.empty:t),l==0&&Ll(e,i,(s?s.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let s=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:r,$to:l}=o[i],a=e.mapping.slice(s),c=a.map(r.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),Ll(e,s,t.isInline?-1:1))}}static findFrom(e,t,s=!1){let o=e.parent.inlineContent?new R(e):tn(e.node(0),e.parent,e.pos,e.index(),t,s);if(o)return o;for(let i=e.depth-1;i>=0;i--){let r=t<0?tn(e.node(0),e.node(i),e.before(i+1),e.index(i),t,s):tn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,s);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new pe(e.node(0))}static atStart(e){return tn(e,e,0,0,1)||new pe(e)}static atEnd(e){return tn(e,e,e.content.size,e.childCount,-1)||new pe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=$o[t.type];if(!s)throw new RangeError(`No selection type ${t.type} defined`);return s.fromJSON(e,t)}static jsonID(e,t){if(e in $o)throw new RangeError("Duplicate use of selection JSON ID "+e);return $o[e]=t,t.prototype.jsonID=e,t}getBookmark(){return R.between(this.$anchor,this.$head).getBookmark()}}I.prototype.visible=!0;class Rl{constructor(e,t){this.$from=e,this.$to=t}}let Dl=!1;function zl(n){!Dl&&!n.parent.inlineContent&&(Dl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class R extends I{constructor(e,t=e){zl(e),zl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let s=e.resolve(t.map(this.head));if(!s.parent.inlineContent)return I.near(s);let o=e.resolve(t.map(this.anchor));return new R(o.parent.inlineContent?o:s,s)}replace(e,t=M.empty){if(super.replace(e,t),t==M.empty){let s=this.$from.marksAcross(this.$to);s&&e.ensureMarks(s)}}eq(e){return e instanceof R&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Os(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new R(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,s=t){let o=e.resolve(t);return new this(o,s==t?o:e.resolve(s))}static between(e,t,s){let o=e.pos-t.pos;if((!s||o)&&(s=o>=0?1:-1),!t.parent.inlineContent){let i=I.findFrom(t,s,!0)||I.findFrom(t,-s,!0);if(i)t=i.$head;else return I.near(t,s)}return e.parent.inlineContent||(o==0?e=t:(e=(I.findFrom(e,-s,!0)||I.findFrom(e,s,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new R(e,t)}}I.jsonID("text",R);class Os{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Os(e.map(this.anchor),e.map(this.head))}resolve(e){return R.between(e.resolve(this.anchor),e.resolve(this.head))}}class N extends I{constructor(e){let t=e.nodeAfter,s=e.node(0).resolve(e.pos+t.nodeSize);super(e,s),this.node=t}map(e,t){let{deleted:s,pos:o}=t.mapResult(this.anchor),i=e.resolve(o);return s?I.near(i):new N(i)}content(){return new M(x.from(this.node),0,0)}eq(e){return e instanceof N&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Fo(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new N(e.resolve(t.anchor))}static create(e,t){return new N(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}N.prototype.visible=!1,I.jsonID("node",N);class Fo{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:s}=e.mapResult(this.anchor);return t?new Os(s,s):new Fo(s)}resolve(e){let t=e.resolve(this.anchor),s=t.nodeAfter;return s&&N.isSelectable(s)?new N(t):I.near(t)}}class pe extends I{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=M.empty){if(t==M.empty){e.delete(0,e.doc.content.size);let s=I.atStart(e.doc);s.eq(e.selection)||e.setSelection(s)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new pe(e)}map(e){return new pe(e)}eq(e){return e instanceof pe}getBookmark(){return ff}}I.jsonID("all",pe);const ff={map(){return this},resolve(n){return new pe(n)}};function tn(n,e,t,s,o,i=!1){if(e.inlineContent)return R.create(n,t);for(let r=s-(o>0?0:1);o>0?r<e.childCount:r>=0;r+=o){let l=e.child(r);if(l.isAtom){if(!i&&N.isSelectable(l))return N.create(n,t-(o<0?l.nodeSize:0))}else{let a=tn(n,l,t+o,o<0?l.childCount:0,o,i);if(a)return a}t+=l.nodeSize*o}return null}function Ll(n,e,t){let s=n.steps.length-1;if(s<e)return;let o=n.steps[s];if(!(o instanceof ne||o instanceof U))return;let i=n.mapping.maps[s],r;i.forEach((l,a,c,d)=>{r==null&&(r=d)}),n.setSelection(I.near(n.doc.resolve(r),t))}const Vl=1,Ns=2,Bl=4;class pf extends Il{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|Vl)&~Ns,this.storedMarks=null,this}get selectionSet(){return(this.updated&Vl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ns,this}ensureMarks(e){return V.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&Ns)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Ns,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let s=this.selection;return t&&(e=e.mark(this.storedMarks||(s.empty?s.$from.marks():s.$from.marksAcross(s.$to)||V.none))),s.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,s){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(s==null&&(s=t),s=s??t,!e)return this.deleteRange(t,s);let i=this.storedMarks;if(!i){let r=this.doc.resolve(t);i=s==t?r.marks():r.marksAcross(this.doc.resolve(s))}return this.replaceRangeWith(t,s,o.text(e,i)),this.selection.empty||this.setSelection(I.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Bl,this}get scrolledIntoView(){return(this.updated&Bl)>0}}function Hl(n,e){return!e||!n?n:n.bind(e)}class Tn{constructor(e,t,s){this.name=e,this.init=Hl(t.init,s),this.apply=Hl(t.apply,s)}}const mf=[new Tn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Tn("selection",{init(n,e){return n.selection||I.atStart(e.doc)},apply(n){return n.selection}}),new Tn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,s){return s.selection.$cursor?n.storedMarks:null}}),new Tn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Wo{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=mf.slice(),t&&t.forEach(s=>{if(this.pluginsByKey[s.key])throw new RangeError("Adding different instances of a keyed plugin ("+s.key+")");this.plugins.push(s),this.pluginsByKey[s.key]=s,s.spec.state&&this.fields.push(new Tn(s.key,s.spec.state,s))})}}class nn{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 s=0;s<this.config.plugins.length;s++)if(s!=t){let o=this.config.plugins[s];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],s=this.applyInner(e),o=null;for(;;){let i=!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,s);if(d&&s.filterTransaction(d,r)){if(d.setMeta("appendedTransaction",e),!o){o=[];for(let u=0;u<this.config.plugins.length;u++)o.push(u<r?{state:s,n:t.length}:{state:this,n:0})}t.push(d),s=s.applyInner(d),i=!0}o&&(o[r]={state:s,n:t.length})}}if(!i)return{state:s,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new nn(this.config),s=this.config.fields;for(let o=0;o<s.length;o++){let i=s[o];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new pf(this)}static create(e){let t=new Wo(e.doc?e.doc.type.schema:e.schema,e.plugins),s=new nn(t);for(let o=0;o<t.fields.length;o++)s[t.fields[o].name]=t.fields[o].init(e,s);return s}reconfigure(e){let t=new Wo(this.schema,e.plugins),s=t.fields,o=new nn(t);for(let i=0;i<s.length;i++){let r=s[i].name;o[r]=this.hasOwnProperty(r)?this[r]:s[i].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(s=>s.toJSON())),e&&typeof e=="object")for(let s in e){if(s=="doc"||s=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[s],i=o.spec.state;i&&i.toJSON&&(t[s]=i.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,s){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Wo(e.schema,e.plugins),i=new nn(o);return o.fields.forEach(r=>{if(r.name=="doc")i.doc=wt.fromJSON(e.schema,t.doc);else if(r.name=="selection")i.selection=I.fromJSON(i.doc,t.selection);else if(r.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(s)for(let l in s){let a=s[l],c=a.spec.state;if(a.key==r.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[r.name]=c.fromJSON.call(a,e,t[l],i);return}}i[r.name]=r.init(e,i)}}),i}}function $l(n,e,t){for(let s in n){let o=n[s];o instanceof Function?o=o.bind(e):s=="handleDOMEvents"&&(o=$l(o,e,{})),t[s]=o}return t}class Mn{constructor(e){this.spec=e,this.props={},e.props&&$l(e.props,this,this.props),this.key=e.key?e.key.key:Fl("plugin")}getState(e){return e[this.key]}}const _o=Object.create(null);function Fl(n){return n in _o?n+"$"+ ++_o[n]:(_o[n]=0,n+"$")}class An{constructor(e="key"){this.key=Fl(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Wl=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function gf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const yf=(n,e,t)=>{let s=gf(n,t);if(!s)return!1;let o=_l(s);if(!o){let r=s.blockRange(),l=r&&As(r);return l==null?!1:(e&&e(n.tr.lift(r,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Ul(n,o,e,-1))return!0;if(s.parent.content.size==0&&(sn(i,"end")||N.isSelectable(i)))for(let r=s.depth;;r--){let l=Vo(n.doc,s.before(r),s.after(r),M.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(sn(i,"end")?I.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):N.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(r==1||s.node(r-1).childCount>1)break}return i.isAtom&&o.depth==s.depth-1?(e&&e(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1};function sn(n,e,t=!1){for(let s=n;s;s=e=="start"?s.firstChild:s.lastChild){if(s.isTextblock)return!0;if(t&&s.childCount!=1)return!1}return!1}const bf=(n,e,t)=>{let{$head:s,empty:o}=n.selection,i=s;if(!o)return!1;if(s.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):s.parentOffset>0)return!1;i=_l(s)}let r=i&&i.nodeBefore;return!r||!N.isSelectable(r)?!1:(e&&e(n.tr.setSelection(N.create(n.doc,i.pos-r.nodeSize)).scrollIntoView()),!0)};function _l(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 vf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const wf=(n,e,t)=>{let s=vf(n,t);if(!s)return!1;let o=ql(s);if(!o)return!1;let i=o.nodeAfter;if(Ul(n,o,e,1))return!0;if(s.parent.content.size==0&&(sn(i,"start")||N.isSelectable(i))){let r=Vo(n.doc,s.before(),s.after(),M.empty);if(r&&r.slice.size<r.to-r.from){if(e){let l=n.tr.step(r);l.setSelection(sn(i,"start")?I.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):N.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==s.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},Sf=(n,e,t)=>{let{$head:s,empty:o}=n.selection,i=s;if(!o)return!1;if(s.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):s.parentOffset<s.parent.content.size)return!1;i=ql(s)}let r=i&&i.nodeAfter;return!r||!N.isSelectable(r)?!1:(e&&e(n.tr.setSelection(N.create(n.doc,i.pos)).scrollIntoView()),!0)};function ql(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 Cf=(n,e)=>{let{$head:t,$anchor:s}=n.selection;return!t.parent.type.spec.code||!t.sameParent(s)?!1:(e&&e(n.tr.insertText(`
195
- `).scrollIntoView()),!0)};function qo(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 Gl=(n,e)=>{let{$head:t,$anchor:s}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(s))return!1;let o=t.node(-1),i=t.indexAfter(-1),r=qo(o.contentMatchAt(i));if(!r||!o.canReplaceWith(i,i,r))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,r.createAndFill());a.setSelection(I.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},xf=(n,e)=>{let t=n.selection,{$from:s,$to:o}=t;if(t instanceof pe||s.parent.inlineContent||o.parent.inlineContent)return!1;let i=qo(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let r=(!s.parentOffset&&o.index()<o.parent.childCount?s:o).pos,l=n.tr.insert(r,i.createAndFill());l.setSelection(R.create(l.doc,r+1)),e(l.scrollIntoView())}return!0},jl=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(Xt(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let s=t.blockRange(),o=s&&As(s);return o==null?!1:(e&&e(n.tr.lift(s,o).scrollIntoView()),!0)};function Kl(n){return(e,t)=>{let{$from:s,$to:o}=e.selection;if(e.selection instanceof N&&e.selection.node.isBlock)return!s.parentOffset||!Xt(e.doc,s.pos)?!1:(t&&t(e.tr.split(s.pos).scrollIntoView()),!0);if(!s.depth)return!1;let i=[],r,l,a=!1,c=!1;for(let f=s.depth;;f--)if(s.node(f).isBlock){a=s.end(f)==s.pos+(s.depth-f),c=s.start(f)==s.pos-(s.depth-f),l=qo(s.node(f-1).contentMatchAt(s.indexAfter(f-1)));let m=n&&n(o.parent,a,s);i.unshift(m||(a&&l?{type:l}:null)),r=f;break}else{if(f==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof R||e.selection instanceof pe)&&d.deleteSelection();let u=d.mapping.map(s.pos),h=Xt(d.doc,u,i.length,i);if(h||(i[0]=l?{type:l}:null,h=Xt(d.doc,u,i.length,i)),d.split(u,i.length,i),!a&&c&&s.node(r).type!=l){let f=d.mapping.map(s.before(r)),p=d.doc.resolve(f);l&&s.node(r-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(s.before(r)),l)}return t&&t(d.scrollIntoView()),!0}}const kf=Kl(),Jl=(n,e)=>(e&&e(n.tr.setSelection(new pe(n.doc))),!0);function Tf(n,e,t){let s=e.nodeBefore,o=e.nodeAfter,i=e.index();return!s||!o||!s.type.compatibleContent(o.type)?!1:!s.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-s.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||Es(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Ul(n,e,t,s){let o=e.nodeBefore,i=e.nodeAfter,r,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Tf(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(i.type))&&l.matchType(r[0]||i.type).validEnd){if(t){let f=e.pos+i.nodeSize,p=x.empty;for(let b=r.length-1;b>=0;b--)p=x.from(r[b].create(null,p));p=x.from(o.copy(p));let m=n.tr.step(new U(e.pos-1,f,e.pos,f,new M(p,1,0),r.length,!0)),g=m.doc.resolve(f+2*r.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Es(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||s>0&&a?null:I.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),h=u&&As(u);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&sn(i,"start",!0)&&sn(o,"end")){let f=o,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(t){let b=x.empty;for(let y=p.length-1;y>=0;y--)b=x.from(p[y].copy(b));let S=n.tr.step(new U(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new M(b,p.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function Zl(n){return function(e,t){let s=e.selection,o=n<0?s.$from:s.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(t&&t(e.tr.setSelection(R.create(e.doc,n<0?o.start(i):o.end(i)))),!0):!1}}const Mf=Zl(-1),Af=Zl(1);function Ef(n,e=null){return function(t,s){let o=!1;for(let i=0;i<t.selection.ranges.length&&!o;i++){let{$from:{pos:r},$to:{pos:l}}=t.selection.ranges[i];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),u=d.index();o=d.parent.canReplaceWith(u,u+1,n)}})}if(!o)return!1;if(s){let i=t.tr;for(let r=0;r<t.selection.ranges.length;r++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[r];i.setBlockType(l,a,n,e)}s(i.scrollIntoView())}return!0}}function Of(n,e,t,s){for(let o=0;o<e.length;o++){let{$from:i,$to:r}=e[o],l=i.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(i.pos,r.pos,(a,c)=>{if(l||!s)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function xt(n,e=null,t){let s=t!==!1;return function(o,i){let{empty:r,$cursor:l,ranges:a}=o.selection;if(r&&!l||!Of(o.doc,a,n,s))return!1;if(i)if(l)n.isInSet(o.storedMarks||l.marks())?i(o.tr.removeStoredMark(n)):i(o.tr.addStoredMark(n.create(e)));else{let c,d=o.tr;c=!a.some(u=>o.doc.rangeHasMark(u.$from.pos,u.$to.pos,n));for(let u=0;u<a.length;u++){let{$from:h,$to:f}=a[u];if(!c)d.removeMark(h.pos,f.pos,n);else{let p=h.pos,m=f.pos,g=h.nodeAfter,b=f.nodeBefore,S=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,y=b&&b.isText?/\s*$/.exec(b.text)[0].length:0;p+S<m&&(p+=S,m-=y),d.addMark(p,m,n.create(e))}}i(d.scrollIntoView())}return!0}}function En(...n){return function(e,t,s){for(let o=0;o<n.length;o++)if(n[o](e,t,s))return!0;return!1}}let Go=En(Wl,yf,bf),Yl=En(Wl,wf,Sf);const Ve={Enter:En(Cf,xf,jl,kf),"Mod-Enter":Gl,Backspace:Go,"Mod-Backspace":Go,"Shift-Backspace":Go,Delete:Yl,"Mod-Delete":Yl,"Mod-a":Jl},Xl={"Ctrl-h":Ve.Backspace,"Alt-Backspace":Ve["Mod-Backspace"],"Ctrl-d":Ve.Delete,"Ctrl-Alt-Backspace":Ve["Mod-Delete"],"Alt-Delete":Ve["Mod-Delete"],"Alt-d":Ve["Mod-Delete"],"Ctrl-a":Mf,"Ctrl-e":Af};for(let n in Ve)Xl[n]=Ve[n];const Nf=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?Xl:Ve;var Ps=200,j=function(){};j.prototype.append=function(e){return e.length?(e=j.from(e),!this.length&&e||e.length<Ps&&this.leafAppend(e)||this.length<Ps&&e.leafPrepend(this)||this.appendInner(e)):this},j.prototype.prepend=function(e){return e.length?j.from(e).append(this):this},j.prototype.appendInner=function(e){return new Pf(this,e)},j.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?j.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},j.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},j.prototype.forEach=function(e,t,s){t===void 0&&(t=0),s===void 0&&(s=this.length),t<=s?this.forEachInner(e,t,s,0):this.forEachInvertedInner(e,t,s,0)},j.prototype.map=function(e,t,s){t===void 0&&(t=0),s===void 0&&(s=this.length);var o=[];return this.forEach(function(i,r){return o.push(e(i,r))},t,s),o},j.from=function(e){return e instanceof j?e:e&&e.length?new Ql(e):j.empty};var Ql=function(n){function e(s){n.call(this),this.values=s}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,r,l){for(var a=i;a<r;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,r,l){for(var a=i-1;a>=r;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Ps)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Ps)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}(j);j.empty=new Ql([]);var Pf=function(n){function e(t,s){n.call(this),this.left=t,this.right=s,this.length=t.length+s.length,this.depth=Math.max(t.depth,s.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(s){return s<this.left.length?this.left.get(s):this.right.get(s-this.left.length)},e.prototype.forEachInner=function(s,o,i,r){var l=this.left.length;if(o<l&&this.left.forEachInner(s,o,Math.min(i,l),r)===!1||i>l&&this.right.forEachInner(s,Math.max(o-l,0),Math.min(this.length,i)-l,r+l)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,r){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(s,o-l,Math.max(i,l)-l,r+l)===!1||i<l&&this.left.forEachInvertedInner(s,Math.min(o,l),i,r)===!1)return!1},e.prototype.sliceInner=function(s,o){if(s==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(s,o):s>=i?this.right.slice(s-i,o-i):this.left.slice(s,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(s){var o=this.right.leafAppend(s);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(s){var o=this.left.leafPrepend(s);if(o)return new e(o,this.right)},e.prototype.appendInner=function(s){return this.left.depth>=Math.max(this.right.depth,s.depth)+1?new e(this.left,new e(this.right,s)):new e(this,s)},e}(j);const If=500;class Se{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let s=this.items.length;for(;;s--)if(this.items.get(s-1).selection){--s;break}let o,i;t&&(o=this.remapping(s,this.items.length),i=o.maps.length);let r=e.tr,l,a,c=[],d=[];return this.items.forEach((u,h)=>{if(!u.step){o||(o=this.remapping(s,h+1),i=o.maps.length),i--,d.push(u);return}if(o){d.push(new Ne(u.map));let f=u.step.map(o.slice(i)),p;f&&r.maybeStep(f).doc&&(p=r.mapping.maps[r.mapping.maps.length-1],c.push(new Ne(p,void 0,void 0,c.length+d.length))),i--,p&&o.appendMap(p,i)}else r.maybeStep(u.step);if(u.selection)return l=o?u.selection.map(o.slice(i)):u.selection,a=new Se(this.items.slice(0,s).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:r,selection:l}}addTransform(e,t,s,o){let i=[],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 u=e.steps[d].invert(e.docs[d]),h=new Ne(e.mapping.maps[d],u,t),f;(f=a&&a.merge(h))&&(h=f,d?i.pop():l=l.slice(0,l.length-1)),i.push(h),t&&(r++,t=void 0),o||(a=h)}let c=r-s.depth;return c>Df&&(l=Rf(l,c),r-=c),new Se(l.append(i),r)}remapping(e,t){let s=new Zt;return this.items.forEach((o,i)=>{let r=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?s.maps.length-o.mirrorOffset:void 0;s.appendMap(o.map,r)},e,t),s}addMaps(e){return this.eventCount==0?this:new Se(this.items.append(e.map(t=>new Ne(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let s=[],o=Math.max(0,this.items.length-t),i=e.mapping,r=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},o);let a=t;this.items.forEach(h=>{let f=i.getMirror(--a);if(f==null)return;r=Math.min(r,f);let p=i.maps[f];if(h.step){let m=e.steps[f].invert(e.docs[f]),g=h.selection&&h.selection.map(i.slice(a+1,f));g&&l++,s.push(new Ne(p,m,g))}else s.push(new Ne(p))},o);let c=[];for(let h=t;h<r;h++)c.push(new Ne(i.maps[h]));let d=this.items.slice(0,o).append(c).append(s),u=new Se(d,l);return u.emptyItemCount()>If&&(u=u.compress(this.items.length-s.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),s=t.maps.length,o=[],i=0;return this.items.forEach((r,l)=>{if(l>=e)o.push(r),r.selection&&i++;else if(r.step){let a=r.step.map(t.slice(s)),c=a&&a.getMap();if(s--,c&&t.appendMap(c,s),a){let d=r.selection&&r.selection.map(t.slice(s));d&&i++;let u=new Ne(c.invert(),a,d),h,f=o.length-1;(h=o.length&&o[f].merge(u))?o[f]=h:o.push(u)}}else r.map&&s--},this.items.length,0),new Se(j.from(o.reverse()),i)}}Se.empty=new Se(j.empty,0);function Rf(n,e){let t;return n.forEach((s,o)=>{if(s.selection&&e--==0)return t=o,!1}),n.slice(t)}class Ne{constructor(e,t,s,o){this.map=e,this.step=t,this.selection=s,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Ne(t.getMap().invert(),t,this.selection)}}}class Ze{constructor(e,t,s,o,i){this.done=e,this.undone=t,this.prevRanges=s,this.prevTime=o,this.prevComposition=i}}const Df=20;function zf(n,e,t,s){let o=t.getMeta(kt),i;if(o)return o.historyState;t.getMeta(Bf)&&(n=new Ze(n.done,n.undone,null,0,-1));let r=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(r&&r.getMeta(kt))return r.getMeta(kt).redo?new Ze(n.done.addTransform(t,void 0,s,Is(e)),n.undone,ea(t.mapping.maps),n.prevTime,n.prevComposition):new Ze(n.done,n.undone.addTransform(t,void 0,s,Is(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)-s.newGroupDelay||!Lf(t,n.prevRanges)),c=r?jo(n.prevRanges,t.mapping):ea(t.mapping.maps);return new Ze(n.done.addTransform(t,a?e.selection.getBookmark():void 0,s,Is(e)),Se.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new Ze(n.done.rebased(t,i),n.undone.rebased(t,i),jo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Ze(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),jo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Lf(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((s,o)=>{for(let i=0;i<e.length;i+=2)s<=e[i+1]&&o>=e[i]&&(t=!0)}),t}function ea(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((s,o,i,r)=>e.push(i,r));return e}function jo(n,e){if(!n)return null;let t=[];for(let s=0;s<n.length;s+=2){let o=e.map(n[s],1),i=e.map(n[s+1],-1);o<=i&&t.push(o,i)}return t}function Vf(n,e,t){let s=Is(e),o=kt.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,s);if(!i)return null;let r=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),o,s),a=new Ze(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(r).setMeta(kt,{redo:t,historyState:a})}let Ko=!1,ta=null;function Is(n){let e=n.plugins;if(ta!=e){Ko=!1,ta=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ko=!0;break}}return Ko}const kt=new An("history"),Bf=new An("closeHistory");function Hf(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Mn({key:kt,state:{init(){return new Ze(Se.empty,Se.empty,null,0,-1)},apply(e,t,s){return zf(t,s,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let s=t.inputType,o=s=="historyUndo"?sa:s=="historyRedo"?Jo:null;return o?(t.preventDefault(),o(e.state,e.dispatch)):!1}}}})}function na(n,e){return(t,s)=>{let o=kt.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(s){let i=Vf(o,t,n);i&&s(e?i.scrollIntoView():i)}return!0}}const sa=na(!1,!0),Jo=na(!0,!0);for(var Ye={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:"'"},Rs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},$f=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ff=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Z=0;Z<10;Z++)Ye[48+Z]=Ye[96+Z]=String(Z);for(var Z=1;Z<=24;Z++)Ye[Z+111]="F"+Z;for(var Z=65;Z<=90;Z++)Ye[Z]=String.fromCharCode(Z+32),Rs[Z]=String.fromCharCode(Z);for(var Uo in Ye)Rs.hasOwnProperty(Uo)||(Rs[Uo]=Ye[Uo]);function Wf(n){var e=$f&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Ff&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Rs:Ye)[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 _f=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function qf(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let s,o,i,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))s=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))_f?r=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return s&&(t="Alt-"+t),o&&(t="Ctrl-"+t),r&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function Gf(n){let e=Object.create(null);for(let t in n)e[qf(t)]=n[t];return e}function Zo(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 Yo(n){return new Mn({props:{handleKeyDown:oa(n)}})}function oa(n){let e=Gf(n);return function(t,s){let o=Wf(s),i,r=e[Zo(o,s)];if(r&&r(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(s.shiftKey){let l=e[Zo(o,s,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((s.shiftKey||s.altKey||s.metaKey||o.charCodeAt(0)>127)&&(i=Ye[s.keyCode])&&i!=o){let l=e[Zo(i,s)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function ia(n,e=null){return function(t,s){let{$from:o,$to:i}=t.selection,r=o.blockRange(i),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 vs(d,d,r.depth),r.endIndex<r.parent.childCount&&(r=new vs(o,t.doc.resolve(i.end(r.depth)),r.depth)),l=!0}let c=kl(a,n,e,r);return c?(s&&s(jf(t.tr,r,c,l,n).scrollIntoView()),!0):!1}}function jf(n,e,t,s,o){let i=x.empty;for(let d=t.length-1;d>=0;d--)i=x.from(t[d].type.create(t[d].attrs,i));n.step(new U(e.start-(s?2:0),e.end,e.start,e.end,new M(i,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-(s?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,h=!0;d<u;d++,h=!1)!h&&Xt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function Kf(n,e){return function(t,s){let{$from:o,$to:i,node:r}=t.selection;if(r&&r.isBlock||o.depth<2||!o.sameParent(i))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(s){let u=x.empty,h=o.index(-1)?1:o.index(-2)?2:3;for(let b=o.depth-h;b>=o.depth-3;b--)u=x.from(o.node(b).copy(u));let f=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;u=u.append(x.from(n.createAndFill()));let p=o.before(o.depth-(h-1)),m=t.tr.replace(p,o.after(-f),new M(u,4-h,0)),g=-1;m.doc.nodesBetween(p,m.doc.content.size,(b,S)=>{if(g>-1)return!1;b.isTextblock&&b.content.size==0&&(g=S+1)}),g>-1&&m.setSelection(I.near(m.doc.resolve(g))),s(m.scrollIntoView())}return!0}let a=i.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,i.pos),d=a?[null,{type:a}]:void 0;return Xt(c.doc,o.pos,2,d)?(s&&s(c.split(o.pos,2,d).scrollIntoView()),!0):!1}}function Xo(n){return function(e,t){let{$from:s,$to:o}=e.selection,i=s.blockRange(o,r=>r.childCount>0&&r.firstChild.type==n);return i?t?s.node(i.depth-1).type==n?Jf(e,t,n,i):Uf(e,t,i):!0:!1}}function Jf(n,e,t,s){let o=n.tr,i=s.end,r=s.$to.end(s.depth);i<r&&(o.step(new U(i-1,r,i,r,new M(x.from(t.create(null,s.parent.copy())),1,0),1,!0)),s=new vs(o.doc.resolve(s.$from.pos),o.doc.resolve(r),s.depth));const l=As(s);if(l==null)return!1;o.lift(s,l);let a=o.mapping.map(i,-1)-1;return Es(o.doc,a)&&o.join(a),e(o.scrollIntoView()),!0}function Uf(n,e,t){let s=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,s.delete(f-1,f+1);let i=s.doc.resolve(t.start),r=i.nodeAfter;if(s.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,r.content.append(a?x.empty:x.from(o))))return!1;let u=i.pos,h=u+r.nodeSize;return s.step(new U(u-(l?1:0),h+(a?1:0),u+1,h-1,new M((l?x.empty:x.from(o.copy(x.empty))).append(a?x.empty:x.from(o.copy(x.empty))),l?0:1,a?0:1),l?0:1)),e(s.scrollIntoView()),!0}function Zf(n){return function(e,t){let{$from:s,$to:o}=e.selection,i=s.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let r=i.startIndex;if(r==0)return!1;let l=i.parent,a=l.child(r-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=x.from(c?n.create():null),u=new M(x.from(n.create(null,x.from(l.type.create(null,d)))),c?3:1,0),h=i.start,f=i.end;t(e.tr.step(new U(h-(c?3:1),f,h,f,u,1,!0)).scrollIntoView())}return!0}}const Y=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},On=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Qo=null;const Be=function(n,e,t){let s=Qo||(Qo=document.createRange());return s.setEnd(n,t??n.nodeValue.length),s.setStart(n,e||0),s},Yf=function(){Qo=null},Tt=function(n,e,t,s){return t&&(ra(n,e,t,s,-1)||ra(n,e,t,s,1))},Xf=/^(img|br|input|textarea|hr)$/i;function ra(n,e,t,s,o){for(;;){if(n==t&&e==s)return!0;if(e==(o<0?0:ge(n))){let i=n.parentNode;if(!i||i.nodeType!=1||Nn(n)||Xf.test(n.nodeName)||n.contentEditable=="false")return!1;e=Y(n)+(o<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?ge(n):0}else return!1}}function ge(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Qf(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=ge(n)}else if(n.parentNode&&!Nn(n))e=Y(n),n=n.parentNode;else return null}}function ep(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&&!Nn(n))e=Y(n)+1,n=n.parentNode;else return null}}function tp(n,e,t){for(let s=e==0,o=e==ge(n);s||o;){if(n==t)return!0;let i=Y(n);if(n=n.parentNode,!n)return!1;s=s&&i==0,o=o&&i==ge(n)}}function Nn(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 Ds=function(n){return n.focusNode&&Tt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Mt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function np(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function sp(n,e,t){if(n.caretPositionFromPoint)try{let s=n.caretPositionFromPoint(e,t);if(s)return{node:s.offsetNode,offset:Math.min(ge(s.offsetNode),s.offset)}}catch{}if(n.caretRangeFromPoint){let s=n.caretRangeFromPoint(e,t);if(s)return{node:s.startContainer,offset:Math.min(ge(s.startContainer),s.startOffset)}}}const Pe=typeof navigator<"u"?navigator:null,la=typeof document<"u"?document:null,Xe=Pe&&Pe.userAgent||"",ei=/Edge\/(\d+)/.exec(Xe),aa=/MSIE \d/.exec(Xe),ti=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Xe),ue=!!(aa||ti||ei),Qe=aa?document.documentMode:ti?+ti[1]:ei?+ei[1]:0,Ce=!ue&&/gecko\/(\d+)/i.test(Xe);Ce&&+(/Firefox\/(\d+)/.exec(Xe)||[0,0])[1];const ni=!ue&&/Chrome\/(\d+)/.exec(Xe),se=!!ni,ca=ni?+ni[1]:0,re=!ue&&!!Pe&&/Apple Computer/.test(Pe.vendor),on=re&&(/Mobile\/\w+/.test(Xe)||!!Pe&&Pe.maxTouchPoints>2),ye=on||(Pe?/Mac/.test(Pe.platform):!1),op=Pe?/Win/.test(Pe.platform):!1,xe=/Android \d/.test(Xe),Pn=!!la&&"webkitFontSmoothing"in la.documentElement.style,ip=Pn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function rp(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 He(n,e){return typeof n=="number"?n:n[e]}function lp(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,s=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*s}}function da(n,e,t){let s=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let r=t||n.dom;r;r=On(r)){if(r.nodeType!=1)continue;let l=r,a=l==i.body,c=a?rp(i):lp(l),d=0,u=0;if(e.top<c.top+He(s,"top")?u=-(c.top-e.top+He(o,"top")):e.bottom>c.bottom-He(s,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+He(o,"top")-c.top:e.bottom-c.bottom+He(o,"bottom")),e.left<c.left+He(s,"left")?d=-(c.left-e.left+He(o,"left")):e.right>c.right-He(s,"right")&&(d=e.right-c.right+He(o,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,f=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let p=l.scrollLeft-h,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 ap(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),s,o;for(let i=(e.left+e.right)/2,r=t+1;r<Math.min(innerHeight,e.bottom);r+=5){let l=n.root.elementFromPoint(i,r);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){s=l,o=a.top;break}}return{refDOM:s,refTop:o,stack:ua(n.dom)}}function ua(n){let e=[],t=n.ownerDocument;for(let s=n;s&&(e.push({dom:s,top:s.scrollTop,left:s.scrollLeft}),n!=t);s=On(s));return e}function cp({refDOM:n,refTop:e,stack:t}){let s=n?n.getBoundingClientRect().top:0;ha(t,s==0?0:s-e)}function ha(n,e){for(let t=0;t<n.length;t++){let{dom:s,top:o,left:i}=n[t];s.scrollTop!=o+e&&(s.scrollTop=o+e),s.scrollLeft!=i&&(s.scrollLeft=i)}}let rn=null;function dp(n){if(n.setActive)return n.setActive();if(rn)return n.focus(rn);let e=ua(n);n.focus(rn==null?{get preventScroll(){return rn={preventScroll:!0},!0}}:void 0),rn||(rn=!1,ha(e,0))}function fa(n,e){let t,s=2e8,o,i=0,r=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let h;if(d.nodeType==1)h=d.getClientRects();else if(d.nodeType==3)h=Be(d).getClientRects();else continue;for(let f=0;f<h.length;f++){let p=h[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<s){t=d,s=m,o=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&m&&(i=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!t&&a&&(t=a,o=c,s=0),t&&t.nodeType==3?up(t,o):!t||s&&t.nodeType==1?{node:n,offset:i}:fa(t,o)}function up(n,e){let t=n.nodeValue.length,s=document.createRange();for(let o=0;o<t;o++){s.setEnd(n,o+1),s.setStart(n,o);let i=et(s,1);if(i.top!=i.bottom&&si(e,i))return{node:n,offset:o+(e.left>=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function si(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function hp(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function fp(n,e,t){let{node:s,offset:o}=fa(e,t),i=-1;if(s.nodeType==1&&!s.firstChild){let r=s.getBoundingClientRect();i=r.left!=r.right&&t.left>(r.left+r.right)/2?1:-1}return n.docView.posFromDOM(s,o,i)}function pp(n,e,t,s){let o=-1;for(let i=e,r=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!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>s.left||a.top>s.top?o=l.posBefore:(!r&&a.right<s.left||a.bottom<s.top)&&(o=l.posAfter),r=!0),!l.contentDOM&&o<0&&!l.node.isText)return(l.node.isBlock?s.top<(a.top+a.bottom)/2:s.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}i=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function pa(n,e,t){let s=n.childNodes.length;if(s&&t.top<t.bottom)for(let o=Math.max(0,Math.min(s-1,Math.floor(s*(e.top-t.top)/(t.bottom-t.top))-2)),i=o;;){let r=n.childNodes[i];if(r.nodeType==1){let l=r.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(si(e,c))return pa(r,e,c)}}if((i=(i+1)%s)==o)break}return n}function mp(n,e){let t=n.dom.ownerDocument,s,o=0,i=sp(t,e.left,e.top);i&&({node:s,offset:o}=i);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(!si(e,c)||(r=pa(n.dom,e,c),!r))return null}if(re)for(let c=r;s&&c;c=On(c))c.draggable&&(s=void 0);if(r=hp(r,e),s){if(Ce&&s.nodeType==1&&(o=Math.min(o,s.childNodes.length),o<s.childNodes.length)){let d=s.childNodes[o],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&o++}let c;Pn&&o&&s.nodeType==1&&(c=s.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,s==n.dom&&o==s.childNodes.length-1&&s.lastChild.nodeType==1&&e.top>s.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||s.nodeType!=1||s.childNodes[o-1].nodeName!="BR")&&(l=pp(n,s,o,e))}l==null&&(l=fp(n,r,e));let a=n.docView.nearestDesc(r,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function ma(n){return n.top<n.bottom||n.left<n.right}function et(n,e){let t=n.getClientRects();if(t.length){let s=t[e<0?0:t.length-1];if(ma(s))return s}return Array.prototype.find.call(t,ma)||n.getBoundingClientRect()}const gp=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ga(n,e,t){let{node:s,offset:o,atom:i}=n.docView.domFromPos(e,t<0?-1:1),r=Pn||Ce;if(s.nodeType==3)if(r&&(gp.test(s.nodeValue)||(t<0?!o:o==s.nodeValue.length))){let a=et(Be(s,o,o),t);if(Ce&&o&&/\s/.test(s.nodeValue[o-1])&&o<s.nodeValue.length){let c=et(Be(s,o-1,o-1),-1);if(c.top==a.top){let d=et(Be(s,o,o+1),-1);if(d.top!=a.top)return In(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==s.nodeValue.length?(a--,d=1):t<0?a--:c++,In(et(Be(s,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(t<0||o==ge(s))){let a=s.childNodes[o-1];if(a.nodeType==1)return oi(a.getBoundingClientRect(),!1)}if(i==null&&o<ge(s)){let a=s.childNodes[o];if(a.nodeType==1)return oi(a.getBoundingClientRect(),!0)}return oi(s.getBoundingClientRect(),t>=0)}if(i==null&&o&&(t<0||o==ge(s))){let a=s.childNodes[o-1],c=a.nodeType==3?Be(a,ge(a)-(r?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return In(et(c,1),!1)}if(i==null&&o<ge(s)){let a=s.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Be(a,0,r?0:1):a.nodeType==1?a:null:null;if(c)return In(et(c,-1),!0)}return In(et(s.nodeType==3?Be(s):s,-t),t>=0)}function In(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 oi(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 ya(n,e,t){let s=n.state,o=n.root.activeElement;s!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{s!=e&&n.updateState(s),o!=n.dom&&o&&o.focus()}}function yp(n,e,t){let s=e.selection,o=t=="up"?s.$from:s.$to;return ya(n,e,()=>{let{node:i}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let r=ga(n,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Be(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 bp=/[\u0590-\u08ac]/;function vp(n,e,t){let{$head:s}=e.selection;if(!s.parent.isTextblock)return!1;let o=s.parentOffset,i=!o,r=o==s.parent.content.size,l=n.domSelection();return l?!bp.test(s.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:r:ya(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",t,"character");let f=s.depth?n.docView.domAfterPos(s.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,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return h!=null&&(l.caretBidiLevel=h),g}):s.pos==s.start()||s.pos==s.end()}let ba=null,va=null,wa=!1;function wp(n,e,t){return ba==e&&va==t?wa:(ba=e,va=t,wa=t=="up"||t=="down"?yp(n,e,t):vp(n,e,t))}const be=0,Sa=1,At=2,Ie=3;class Rn{constructor(e,t,s,o){this.parent=e,this.children=t,this.dom=s,this.contentDOM=o,this.dirty=be,s.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,s){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,s=this.posAtStart;;t++){let o=this.children[t];if(o==e)return s;s+=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,s){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(s<0){let i,r;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((r=i.pmViewDesc)&&r.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(r)+r.size:this.posAtStart}else{let i,r;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((r=i.pmViewDesc)&&r.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(r):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>Y(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 i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??s>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let s=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),r;if(i&&(!t||i.node))if(s&&(r=i.nodeDOM)&&!(r.nodeType==1?r.contains(e.nodeType==1?e:e.parentNode):r==e))s=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let s=t;s;s=s.parent)if(s==this)return t}posFromDOM(e,t,s){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,s)}return-1}descAt(e){for(let t=0,s=0;t<this.children.length;t++){let o=this.children[t],i=s+o.size;if(s==e&&i!=s){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<i)return o.descAt(e-s-o.border);s=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let s=0,o=0;for(let i=0;s<this.children.length;s++){let r=this.children[s],l=i+r.size;if(l>e||r instanceof ka){o=e-i;break}i=l}if(o)return this.children[s].domFromPos(o-this.children[s].border,t);for(let i;s&&!(i=this.children[s-1]).size&&i instanceof Ca&&i.side>=0;s--);if(t<=0){let i,r=!0;for(;i=s?this.children[s-1]:null,!(!i||i.dom.parentNode==this.contentDOM);s--,r=!1);return i&&t&&r&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?Y(i.dom)+1:0}}else{let i,r=!0;for(;i=s<this.children.length?this.children[s]:null,!(!i||i.dom.parentNode==this.contentDOM);s++,r=!1);return i&&r&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?Y(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,s=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let r=s,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 u=l;u>0;u--){let h=this.children[u-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){o=Y(h.dom)+1;break}e-=h.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=Y(u.dom);break}t+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}r=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:s}=this.domFromPos(e,0);if(t.nodeType!=1||s==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[s]}setSelection(e,t,s,o=!1){let i=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(i>p&&r<g)return m.setSelection(e-p-m.border,t-p-m.border,s,o);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=s.root.getSelection(),d=s.domSelectionRange(),u=!1;if((Ce||re)&&e==t){let{node:f,offset:p}=l;if(f.nodeType==3){if(u=!!(p&&f.nodeValue[p-1]==`
196
- `),u&&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:Y(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=f.childNodes[p-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Ce&&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||u&&re)&&Tt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Tt(a.node,a.offset,d.focusNode,d.focusOffset))return;let h=!1;if((c.extend||e==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),h=!0}catch{}}if(!h){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 s=0,o=0;o<this.children.length;o++){let i=this.children[o],r=s+i.size;if(s==r?e<=r&&t>=s:e<r&&t>s){let l=s+i.border,a=r-i.border;if(e>=l&&t<=a){this.dirty=e==s||t==r?At:Sa,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ie:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?At:Ie}s=r}this.dirty=At}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let s=e==1?At:Sa;t.dirty<s&&(t.dirty=s)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Ca extends Rn{constructor(e,t,s,o){let i,r=t.type.toDOM;if(typeof r=="function"&&(r=r(s,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!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,i=this}matchesWidget(e){return this.dirty==be&&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 Sp extends Rn{constructor(e,t,s,o){super(e,[],t,null),this.textDOM=s,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 Et extends Rn{constructor(e,t,s,o,i){super(e,[],s,o),this.mark=t,this.spec=i}static create(e,t,s,o){let i=o.nodeViews[t.type.name],r=i&&i(t,o,s);return(!r||!r.dom)&&(r=Ct.renderSpec(document,t.type.spec.toDOM(t,s),null,t.attrs)),new Et(e,t,r.dom,r.contentDOM||r.dom,r)}parseRule(){return this.dirty&Ie||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ie&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=be){let s=this.parent;for(;!s.node;)s=s.parent;s.dirty<this.dirty&&(s.dirty=this.dirty),this.dirty=be}}slice(e,t,s){let o=Et.create(this.parent,this.mark,!0,s),i=this.children,r=this.size;t<r&&(i=ri(i,t,r,s)),e>0&&(i=ri(i,0,e,s));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class tt extends Rn{constructor(e,t,s,o,i,r,l,a,c){super(e,[],i,r),this.node=t,this.outerDeco=s,this.innerDeco=o,this.nodeDOM=l}static create(e,t,s,o,i,r){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return r;if(a.parent)return a.parent.posBeforeChild(a)},s,o),d=c&&c.dom,u=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:u}=Ct.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let h=d;return d=Aa(d,s,t),c?a=new Cp(e,t,s,o,d,u||null,h,c,i,r+1):t.isText?new zs(e,t,s,o,d,h,i):new tt(e,t,s,o,d,u||null,h,i,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 s=this.children[t];if(this.dom.contains(s.dom.parentNode)){e.contentElement=s.dom.parentNode;break}}e.contentElement||(e.getContent=()=>x.empty)}return e}matchesNode(e,t,s){return this.dirty==be&&e.eq(this.node)&&Ls(t,this.outerDeco)&&s.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let s=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,r=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new kp(this,r&&r.node,e);Ap(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,s,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?V.none:this.node.child(d).marks,s,e),a.placeWidget(c,e,o)},(c,d,u,h)=>{a.syncToMarks(c.marks,s,e);let f;a.findNodeMatch(c,d,u,h)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(f=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,u,f,e)||a.updateNextNode(c,d,u,e,h,o)||a.addNode(c,d,u,e,o),o+=c.nodeSize}),a.syncToMarks([],s,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==At)&&(r&&this.protectLocalComposition(e,r),Ta(this.contentDOM,this.children,e),on&&Ep(this.dom))}localCompositionInfo(e,t){let{from:s,to:o}=e.state.selection;if(!(e.state.selection instanceof R)||s<t||o>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let r=i.nodeValue,l=Op(this.node.content,r,s-t,o-t);return l<0?null:{node:i,pos:l,text:r}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:s,text:o}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let r=new Sp(this,i,t,o);e.input.compositionNodes.push(r),this.children=ri(this.children,s,s+o.length,e,r)}update(e,t,s,o){return this.dirty==Ie||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,s,o),!0)}updateInner(e,t,s,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=s,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=be}updateOuterDeco(e){if(Ls(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,s=this.dom;this.dom=Ma(this.dom,this.nodeDOM,ii(this.outerDeco,this.node,t),ii(e,this.node,t)),this.dom!=s&&(s.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 xa(n,e,t,s,o){Aa(s,e,n);let i=new tt(void 0,n,e,t,s,s,s,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class zs extends tt{constructor(e,t,s,o,i,r,l){super(e,t,s,o,i,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,s,o){return this.dirty==Ie||this.dirty!=be&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=be||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=be,!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,s){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,s)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,s){let o=this.node.cut(e,t),i=document.createTextNode(o.text);return new zs(this.parent,o,this.outerDeco,this.innerDeco,i,i,s)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ie)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ka extends Rn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==be&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Cp extends tt{constructor(e,t,s,o,i,r,l,a,c,d){super(e,t,s,o,i,r,l,c,d),this.spec=a}update(e,t,s,o){if(this.dirty==Ie)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,s);return i&&this.updateInner(e,t,s,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,s,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,s,o){this.spec.setSelection?this.spec.setSelection(e,t,s.root):super.setSelection(e,t,s,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 Ta(n,e,t){let s=n.firstChild,o=!1;for(let i=0;i<e.length;i++){let r=e[i],l=r.dom;if(l.parentNode==n){for(;l!=s;)s=Ea(s),o=!0;s=s.nextSibling}else o=!0,n.insertBefore(l,s);if(r instanceof Et){let a=s?s.previousSibling:n.lastChild;Ta(r.contentDOM,r.children,t),s=a?a.nextSibling:n.firstChild}}for(;s;)s=Ea(s),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const Dn=function(n){n&&(this.nodeName=n)};Dn.prototype=Object.create(null);const Ot=[new Dn];function ii(n,e,t){if(n.length==0)return Ot;let s=t?Ot[0]:new Dn,o=[s];for(let i=0;i<n.length;i++){let r=n[i].type.attrs;if(r){r.nodeName&&o.push(s=new Dn(r.nodeName));for(let l in r){let a=r[l];a!=null&&(t&&o.length==1&&o.push(s=new Dn(e.isInline?"span":"div")),l=="class"?s.class=(s.class?s.class+" ":"")+a:l=="style"?s.style=(s.style?s.style+";":"")+a:l!="nodeName"&&(s[l]=a))}}}return o}function Ma(n,e,t,s){if(t==Ot&&s==Ot)return e;let o=e;for(let i=0;i<s.length;i++){let r=s[i],l=t[i];if(i){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=Ot[0]),o=a}xp(o,l||Ot[0],r)}return o}function xp(n,e,t){for(let s in e)s!="class"&&s!="style"&&s!="nodeName"&&!(s in t)&&n.removeAttribute(s);for(let s in t)s!="class"&&s!="style"&&s!="nodeName"&&t[s]!=e[s]&&n.setAttribute(s,t[s]);if(e.class!=t.class){let s=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<s.length;i++)o.indexOf(s[i])==-1&&n.classList.remove(s[i]);for(let i=0;i<o.length;i++)s.indexOf(o[i])==-1&&n.classList.add(o[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let s=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=s.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Aa(n,e,t){return Ma(n,n,Ot,ii(e,t,n.nodeType!=1))}function Ls(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 Ea(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class kp{constructor(e,t,s){this.lock=t,this.view=s,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Tp(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let s=e;s<t;s++)this.top.children[s].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,s){let o=0,i=this.stack.length>>1,r=Math.min(i,e.length);for(;o<r&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=be,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<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[i])&&!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=Et.create(this.top,e[i],t,s);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,s,o){let i=-1,r;if(o>=this.preMatch.index&&(r=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,s))i=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,s)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,s,o,i){let r=this.top.children[o];return r.dirty==Ie&&r.dom==r.contentDOM&&(r.dirty=At),r.update(e,t,s,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let s=e.pmViewDesc;if(s){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==s)return o}return-1}e=t}}updateNextNode(e,t,s,o,i,r){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof tt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,u,h=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Ie&&Ls(t,a.outerDeco));if(!h&&a.update(e,t,s,o))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(u=this.recreateWrapper(a,e,t,s,o,r)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=At,u.updateChildren(o,r+1),u.dirty=be),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,s,o,i,r){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ls(s,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=tt.create(this.top,t,s,o,i,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,s,o,i){let r=tt.create(this.top,e,t,s,o,i);r.contentDOM&&r.updateChildren(o,i+1),this.top.children.splice(this.index++,0,r),this.changed=!0}placeWidget(e,t,s){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new Ca(this.top,e,t,s);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Et;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof zs)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((re||se)&&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 s=document.createElement(e);e=="IMG"&&(s.className="ProseMirror-separator",s.alt=""),e=="BR"&&(s.className="ProseMirror-trailingBreak");let o=new ka(this.top,[],s,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 Tp(n,e){let t=e,s=t.children.length,o=n.childCount,i=new Map,r=[];e:for(;o>0;){let l;for(;;)if(s){let c=t.children[s-1];if(c instanceof Et)t=c,s=c.children.length;else{l=c,s--;break}}else{if(t==e)break e;s=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,i.set(l,o),r.push(l)}}return{index:o,matched:i,matches:r.reverse()}}function Mp(n,e){return n.type.side-e.type.side}function Ap(n,e,t,s){let o=e.locals(n),i=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);s(d,o,e.forChild(i,d),c),i+=d.nodeSize}return}let r=0,l=[],a=null;for(let c=0;;){let d,u;for(;r<o.length&&o[r].to==i;){let g=o[r++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(Mp);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let h,f;if(a)f=-1,h=a,a=null;else if(c<n.childCount)f=c,h=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;r<o.length&&o[r].from<=i&&o[r].to>i;)l.push(o[r++]);let p=i+h.nodeSize;if(h.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=h.cut(g-i),h=h.cut(0,g-i),p=g,f=-1)}else for(;r<o.length&&o[r].to<p;)r++;let m=h.isInline&&!h.isLeaf?l.filter(g=>!g.inline):l.slice();s(h,m,e.forChild(i,h),f),i=p}}function Ep(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 Op(n,e,t,s){for(let o=0,i=0;o<n.childCount&&i<=s;){let r=n.child(o++),l=i;if(i+=r.nodeSize,!r.isText)continue;let a=r.text;for(;o<n.childCount;){let c=n.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=s&&a.slice(s-e.length-l,s-l)==e)return s-e.length;let c=l<s?a.lastIndexOf(e,s-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==s&&a.length>=s+e.length-l&&a.slice(s-l,s-l+e.length)==e)return s}}return-1}function ri(n,e,t,s,o){let i=[];for(let r=0,l=0;r<n.length;r++){let a=n[r],c=l,d=l+=a.size;c>=t||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,s)),o&&(i.push(o),o=void 0),d>t&&i.push(a.slice(t-c,a.size,s)))}return i}function li(n,e=null){let t=n.domSelectionRange(),s=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),i=o&&o.size==0,r=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(r<0)return null;let l=s.resolve(r),a,c;if(Ds(t)){for(a=r;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&N.isSelectable(u)&&o.parent&&!(u.isInline&&tp(t.focusNode,t.focusOffset,o.dom))){let h=o.posBefore;c=new N(r==h?l:s.resolve(h))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=r,h=r;for(let f=0;f<t.rangeCount;f++){let p=t.getRangeAt(f);u=Math.min(u,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),h=Math.max(h,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,r]=h==n.state.selection.anchor?[h,u]:[u,h],l=s.resolve(r)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=s.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=ci(n,d,l,u)}return c}function Oa(n){return n.editable?n.hasFocus():La(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function $e(n,e=!1){let t=n.state.selection;if(Ra(n,t),!!Oa(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&se){let s=n.domSelectionRange(),o=n.domObserver.currentSelection;if(s.anchorNode&&o.anchorNode&&Tt(s.anchorNode,s.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Pp(n);else{let{anchor:s,head:o}=t,i,r;Na&&!(t instanceof R)&&(t.$from.parent.inlineContent||(i=Pa(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(r=Pa(n,t.to))),n.docView.setSelection(s,o,n,e),Na&&(i&&Ia(i),r&&Ia(r)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Np(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Na=re||se&&ca<63;function Pa(n,e){let{node:t,offset:s}=n.docView.domFromPos(e,0),o=s<t.childNodes.length?t.childNodes[s]:null,i=s?t.childNodes[s-1]:null;if(re&&o&&o.contentEditable=="false")return ai(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return ai(o);if(i)return ai(i)}}function ai(n){return n.contentEditable="true",re&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ia(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Np(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),s=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=s||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Oa(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Pp(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let s=n.cursorWrapper.dom,o=s.nodeName=="IMG";o?t.setStart(s.parentNode,Y(s)+1):t.setStart(s,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&ue&&Qe<=11&&(s.disabled=!0,s.disabled=!1)}function Ra(n,e){if(e instanceof N){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Da(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Da(n)}function Da(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function ci(n,e,t,s){return n.someProp("createSelectionBetween",o=>o(n,e,t))||R.between(e,t,s)}function za(n){return n.editable&&!n.hasFocus()?!1:La(n)}function La(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 Ip(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Tt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function di(n,e){let{$anchor:t,$head:s}=n.selection,o=e>0?t.max(s):t.min(s),i=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return i&&I.findFrom(i,e)}function nt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Va(n,e,t){let s=n.state.selection;if(s instanceof R)if(t.indexOf("s")>-1){let{$head:o}=s,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let r=n.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return nt(n,new R(s.$anchor,r))}else if(s.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=di(n.state,e);return o&&o instanceof N?nt(n,o):!1}else if(!(ye&&t.indexOf("m")>-1)){let o=s.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,r;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(r=n.docView.descAt(l))&&!r.contentDOM?N.isSelectable(i)?nt(n,new N(e<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):Pn?nt(n,new R(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(s instanceof N&&s.node.isInline)return nt(n,new R(e>0?s.$to:s.$from));{let o=di(n.state,e);return o?nt(n,o):!1}}}function Vs(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function zn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function ln(n,e){return e<0?Rp(n):Dp(n)}function Rp(n){let e=n.domSelectionRange(),t=e.focusNode,s=e.focusOffset;if(!t)return;let o,i,r=!1;for(Ce&&t.nodeType==1&&s<Vs(t)&&zn(t.childNodes[s],-1)&&(r=!0);;)if(s>0){if(t.nodeType!=1)break;{let l=t.childNodes[s-1];if(zn(l,-1))o=t,i=--s;else if(l.nodeType==3)t=l,s=t.nodeValue.length;else break}}else{if(Ba(t))break;{let l=t.previousSibling;for(;l&&zn(l,-1);)o=t.parentNode,i=Y(l),l=l.previousSibling;if(l)t=l,s=Vs(t);else{if(t=t.parentNode,t==n.dom)break;s=0}}}r?ui(n,t,s):o&&ui(n,o,i)}function Dp(n){let e=n.domSelectionRange(),t=e.focusNode,s=e.focusOffset;if(!t)return;let o=Vs(t),i,r;for(;;)if(s<o){if(t.nodeType!=1)break;let l=t.childNodes[s];if(zn(l,1))i=t,r=++s;else break}else{if(Ba(t))break;{let l=t.nextSibling;for(;l&&zn(l,1);)i=l.parentNode,r=Y(l)+1,l=l.nextSibling;if(l)t=l,s=0,o=Vs(t);else{if(t=t.parentNode,t==n.dom)break;s=o=0}}}i&&ui(n,i,r)}function Ba(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function zp(n,e){for(;n&&e==n.childNodes.length&&!Nn(n);)e=Y(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 Lp(n,e){for(;n&&!e&&!Nn(n);)e=Y(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 ui(n,e,t){if(e.nodeType!=3){let i,r;(r=zp(e,t))?(e=r,t=0):(i=Lp(e,t))&&(e=i,t=i.nodeValue.length)}let s=n.domSelection();if(!s)return;if(Ds(s)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),s.removeAllRanges(),s.addRange(i)}else s.extend&&s.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&$e(n)},50)}function Ha(n,e){let t=n.state.doc.resolve(e);if(!(se||op)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),r=(i.top+i.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),r=(i.top+i.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function $a(n,e,t){let s=n.state.selection;if(s instanceof R&&!s.empty||t.indexOf("s")>-1||ye&&t.indexOf("m")>-1)return!1;let{$from:o,$to:i}=s;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let r=di(n.state,e);if(r&&r instanceof N)return nt(n,r)}if(!o.parent.inlineContent){let r=e<0?o:i,l=s instanceof pe?I.near(r,e):I.findFrom(r,e);return l?nt(n,l):!1}return!1}function Fa(n,e){if(!(n.state.selection instanceof R))return!0;let{$head:t,$anchor:s,empty:o}=n.state.selection;if(!t.sameParent(s))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let r=n.state.tr;return e<0?r.delete(t.pos-i.nodeSize,t.pos):r.delete(t.pos,t.pos+i.nodeSize),n.dispatch(r),!0}return!1}function Wa(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Vp(n){if(!re||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 s=e.firstChild;Wa(n,s,"true"),setTimeout(()=>Wa(n,s,"false"),20)}return!1}function Bp(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Hp(n,e){let t=e.keyCode,s=Bp(e);if(t==8||ye&&t==72&&s=="c")return Fa(n,-1)||ln(n,-1);if(t==46&&!e.shiftKey||ye&&t==68&&s=="c")return Fa(n,1)||ln(n,1);if(t==13||t==27)return!0;if(t==37||ye&&t==66&&s=="c"){let o=t==37?Ha(n,n.state.selection.from)=="ltr"?-1:1:-1;return Va(n,o,s)||ln(n,o)}else if(t==39||ye&&t==70&&s=="c"){let o=t==39?Ha(n,n.state.selection.from)=="ltr"?1:-1:1;return Va(n,o,s)||ln(n,o)}else{if(t==38||ye&&t==80&&s=="c")return $a(n,-1,s)||ln(n,-1);if(t==40||ye&&t==78&&s=="c")return Vp(n)||$a(n,1,s)||ln(n,1);if(s==(ye?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function _a(n,e){n.someProp("transformCopied",f=>{e=f(e,n)});let t=[],{content:s,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&s.childCount==1&&s.firstChild.childCount==1;){o--,i--;let f=s.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),s=f.content}let r=n.someProp("clipboardSerializer")||Ct.fromSchema(n.state.schema),l=Ya(),a=l.createElement("div");a.appendChild(r.serializeFragment(s,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Ua[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),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${u?` -${u}`:""} ${JSON.stringify(t)}`);let h=n.someProp("clipboardTextSerializer",f=>f(e,n))||e.content.textBetween(0,e.content.size,`
197
-
198
- `);return{dom:a,text:h,slice:e}}function qa(n,e,t,s,o){let i=o.parent.type.spec.code,r,l;if(!t&&!e)return null;let a=e&&(s||i||!t);if(a){if(n.someProp("transformPastedText",h=>{e=h(e,i||s,n)}),i)return e?new M(x.from(n.state.schema.text(e.replace(/\r\n?/g,`
199
- `))),0,0):M.empty;let u=n.someProp("clipboardTextParser",h=>h(e,o,s,n));if(u)l=u;else{let h=o.marks(),{schema:f}=n.state,p=Ct.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,h)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),r=_p(t),Pn&&qp(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 u=+d[3];u>0;u--){let h=r.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;r=h}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Ut.fromSchema(n.state.schema)).parseSlice(r,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!$p.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Gp(Ja(l,+d[1],+d[2]),d[4]);else if(l=M.maxOpen(Fp(l.content,o),!0),l.openStart||l.openEnd){let u=0,h=0;for(let f=l.content.firstChild;u<l.openStart&&!f.type.spec.isolating;u++,f=f.firstChild);for(let f=l.content.lastChild;h<l.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);l=Ja(l,u,h)}return n.someProp("transformPasted",u=>{l=u(l,n)}),l}const $p=/^(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 Fp(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),i,r=[];if(n.forEach(l=>{if(!r)return;let a=o.findWrapping(l.type),c;if(!a)return r=null;if(c=r.length&&i.length&&ja(a,i,l,r[r.length-1],0))r[r.length-1]=c;else{r.length&&(r[r.length-1]=Ka(r[r.length-1],i.length));let d=Ga(l,a);r.push(d),o=o.matchType(d.type),i=a}}),r)return x.from(r)}return n}function Ga(n,e,t=0){for(let s=e.length-1;s>=t;s--)n=e[s].create(null,x.from(n));return n}function ja(n,e,t,s,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let i=ja(n,e,t,s.lastChild,o+1);if(i)return s.copy(s.content.replaceChild(s.childCount-1,i));if(s.contentMatchAt(s.childCount).matchType(o==n.length-1?t.type:n[o+1]))return s.copy(s.content.append(x.from(Ga(t,n,o+1))))}}function Ka(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Ka(n.lastChild,e-1)),s=n.contentMatchAt(n.childCount).fillBefore(x.empty,!0);return n.copy(t.append(s))}function hi(n,e,t,s,o,i){let r=e<0?n.firstChild:n.lastChild,l=r.content;return n.childCount>1&&(i=0),o<s-1&&(l=hi(l,e,t,s,o+1,i)),o>=t&&(l=e<0?r.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(r.contentMatchAt(r.childCount).fillBefore(x.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,r.copy(l))}function Ja(n,e,t){return e<n.openStart&&(n=new M(hi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new M(hi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Ua={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 Za=null;function Ya(){return Za||(Za=document.implementation.createHTMLDocument("title"))}let fi=null;function Wp(n){let e=window.trustedTypes;return e?(fi||(fi=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),fi.createHTML(n)):n}function _p(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Ya().createElement("div"),s=/<([a-z][^>\s]+)/i.exec(n),o;if((o=s&&Ua[s[1].toLowerCase()])&&(n=o.map(i=>"<"+i+">").join("")+n+o.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=Wp(n),o)for(let i=0;i<o.length;i++)t=t.querySelector(o[i])||t;return t}function qp(n){let e=n.querySelectorAll(se?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let s=e[t];s.childNodes.length==1&&s.textContent==" "&&s.parentNode&&s.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),s)}}function Gp(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,s;try{s=JSON.parse(e)}catch{return n}let{content:o,openStart:i,openEnd:r}=n;for(let l=s.length-2;l>=0;l-=2){let a=t.nodes[s[l]];if(!a||a.hasRequiredAttrs())break;o=x.from(a.create(s[l+1],o)),i++,r++}return new M(o,i,r)}const le={},ae={},jp={touchstart:!0,touchmove:!0};class Kp{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 Jp(n){for(let e in le){let t=le[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=s=>{Zp(n,s)&&!mi(n,s)&&(n.editable||!(s.type in ae))&&t(n,s)},jp[e]?{passive:!0}:void 0)}re&&n.dom.addEventListener("input",()=>null),pi(n)}function st(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Up(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 pi(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=s=>mi(n,s))})}function mi(n,e){return n.someProp("handleDOMEvents",t=>{let s=t[e.type];return s?s(n,e)||e.defaultPrevented:!1})}function Zp(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 Yp(n,e){!mi(n,e)&&le[e.type]&&(n.editable||!(e.type in ae))&&le[e.type](n,e)}ae.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Qa(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(xe&&se&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),on&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let s=Date.now();n.input.lastIOSEnter=s,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==s&&(n.someProp("handleKeyDown",o=>o(n,Mt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",s=>s(n,t))||Hp(n,t)?t.preventDefault():st(n,"key")},ae.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},ae.keypress=(n,e)=>{let t=e;if(Qa(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ye&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let s=n.state.selection;if(!(s instanceof R)||!s.$from.sameParent(s.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",i=>i(n,s.$from.pos,s.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Bs(n){return{left:n.clientX,top:n.clientY}}function Xp(n,e){let t=e.x-n.clientX,s=e.y-n.clientY;return t*t+s*s<100}function gi(n,e,t,s,o){if(s==-1)return!1;let i=n.state.doc.resolve(s);for(let r=i.depth+1;r>0;r--)if(n.someProp(e,l=>r>i.depth?l(n,t,i.nodeAfter,i.before(r),o,!0):l(n,t,i.node(r),i.before(r),o,!1)))return!0;return!1}function an(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let s=n.state.tr.setSelection(e);s.setMeta("pointer",!0),n.dispatch(s)}function Qp(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),s=t.nodeAfter;return s&&s.isAtom&&N.isSelectable(s)?(an(n,new N(t)),!0):!1}function em(n,e){if(e==-1)return!1;let t=n.state.selection,s,o;t instanceof N&&(s=t.node);let i=n.state.doc.resolve(e);for(let r=i.depth+1;r>0;r--){let l=r>i.depth?i.nodeAfter:i.node(r);if(N.isSelectable(l)){s&&t.$from.depth>0&&r>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?o=i.before(t.$from.depth):o=i.before(r);break}}return o!=null?(an(n,N.create(n.state.doc,o)),!0):!1}function tm(n,e,t,s,o){return gi(n,"handleClickOn",e,t,s)||n.someProp("handleClick",i=>i(n,e,s))||(o?em(n,t):Qp(n,t))}function nm(n,e,t,s){return gi(n,"handleDoubleClickOn",e,t,s)||n.someProp("handleDoubleClick",o=>o(n,e,s))}function sm(n,e,t,s){return gi(n,"handleTripleClickOn",e,t,s)||n.someProp("handleTripleClick",o=>o(n,e,s))||om(n,t,s)}function om(n,e,t){if(t.button!=0)return!1;let s=n.state.doc;if(e==-1)return s.inlineContent?(an(n,R.create(s,0,s.content.size)),!0):!1;let o=s.resolve(e);for(let i=o.depth+1;i>0;i--){let r=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(r.inlineContent)an(n,R.create(s,l+1,l+1+r.content.size));else if(N.isSelectable(r))an(n,N.create(s,l));else continue;return!0}}function yi(n){return Hs(n)}const Xa=ye?"metaKey":"ctrlKey";le.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let s=yi(n),o=Date.now(),i="singleClick";o-n.input.lastClick.time<500&&Xp(t,n.input.lastClick)&&!t[Xa]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:i};let r=n.posAtCoords(Bs(t));r&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new im(n,r,t,!!s)):(i=="doubleClick"?nm:sm)(n,r.pos,r.inside,t)?t.preventDefault():st(n,"pointer"))};class im{constructor(e,t,s,o){this.view=e,this.pos=t,this.event=s,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!s[Xa],this.allowDefault=s.shiftKey;let i,r;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),r=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,r=d.depth?d.before():0}const l=o?null:s.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(s.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof N&&c.from<=r&&c.to>r)&&(this.mightDrag={node:i,pos:r,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ce&&!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)),st(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(()=>$e(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(Bs(e))),this.updateAllowDefault(e),this.allowDefault||!t?st(this.view,"pointer"):tm(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||re&&this.mightDrag&&!this.mightDrag.node.isAtom||se&&!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)?(an(this.view,I.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):st(this.view,"pointer")}move(e){this.updateAllowDefault(e),st(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)}}le.touchstart=n=>{n.input.lastTouch=Date.now(),yi(n),st(n,"pointer")},le.touchmove=n=>{n.input.lastTouch=Date.now(),st(n,"pointer")},le.contextmenu=n=>yi(n);function Qa(n,e){return n.composing?!0:re&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const rm=xe?5e3:-1;ae.compositionstart=ae.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof R&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(s=>s.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Hs(n,!0),n.markCursor=null;else if(Hs(n,!e.selection.empty),Ce&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let s=n.domSelectionRange();for(let o=s.focusNode,i=s.focusOffset;o&&o.nodeType==1&&i!=0;){let r=i<0?o.lastChild:o.childNodes[i-1];if(!r)break;if(r.nodeType==3){let l=n.domSelection();l&&l.collapse(r,r.nodeValue.length);break}else o=r,i=-1}}n.input.composing=!0}ec(n,rm)},ae.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++,ec(n,20))};function ec(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Hs(n),e))}function tc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=am());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function lm(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Qf(e.focusNode,e.focusOffset),s=ep(e.focusNode,e.focusOffset);if(t&&s&&t!=s){let o=s.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||s==i)return i;if(!o||!o.isText(s.nodeValue))return s;if(n.input.compositionNode==s){let r=t.pmViewDesc;if(!(!r||!r.isText(t.nodeValue)))return s}}return t||s}function am(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Hs(n,e=!1){if(!(xe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),tc(n),e||n.docView&&n.docView.dirty){let t=li(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 cm(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 s=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),s.removeAllRanges(),s.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Ln=ue&&Qe<15||on&&ip<604;le.copy=ae.cut=(n,e)=>{let t=e,s=n.state.selection,o=t.type=="cut";if(s.empty)return;let i=Ln?null:t.clipboardData,r=s.content(),{dom:l,text:a}=_a(n,r);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):cm(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function dm(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function um(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,s=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(s.contentEditable="true"),s.style.cssText="position: fixed; left: -10000px; top: 10px",s.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),s.parentNode&&s.parentNode.removeChild(s),t?Vn(n,s.value,null,o,e):Vn(n,s.textContent,s.innerHTML,o,e)},50)}function Vn(n,e,t,s,o){let i=qa(n,e,t,s,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,i||M.empty)))return!0;if(!i)return!1;let r=dm(i),l=r?n.state.tr.replaceSelectionWith(r,s):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function nc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ae.paste=(n,e)=>{let t=e;if(n.composing&&!xe)return;let s=Ln?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;s&&Vn(n,nc(s),s.getData("text/html"),o,t)?t.preventDefault():um(n,t)};class sc{constructor(e,t,s){this.slice=e,this.move=t,this.node=s}}const oc=ye?"altKey":"ctrlKey";le.dragstart=(n,e)=>{let t=e,s=n.input.mouseDown;if(s&&s.done(),!t.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords(Bs(t)),r;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof N?o.to-1:o.to))){if(s&&s.mightDrag)r=N.create(n.state.doc,s.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(r=N.create(n.state.doc,u.posBefore))}}let l=(r||n.state.selection).content(),{dom:a,text:c,slice:d}=_a(n,l);(!t.dataTransfer.files.length||!se||ca>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Ln?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Ln||t.dataTransfer.setData("text/plain",c),n.dragging=new sc(d,!t[oc],r)},le.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},ae.dragover=ae.dragenter=(n,e)=>e.preventDefault(),ae.drop=(n,e)=>{let t=e,s=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Bs(t));if(!o)return;let i=n.state.doc.resolve(o.pos),r=s&&s.slice;r?n.someProp("transformPasted",p=>{r=p(r,n)}):r=qa(n,nc(t.dataTransfer),Ln?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(s&&!t[oc]);if(n.someProp("handleDrop",p=>p(n,t,r||M.empty,l))){t.preventDefault();return}if(!r)return;t.preventDefault();let a=r?rf(n.state.doc,i.pos,r):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:p}=s;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,r.content.firstChild):c.replaceRange(d,d,r),c.doc.eq(h))return;let f=c.doc.resolve(d);if(u&&N.isSelectable(r.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(r.content.firstChild))c.setSelection(new N(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,S)=>p=S),c.setSelection(ci(n,f,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},le.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&$e(n)},20))},le.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},le.beforeinput=(n,e)=>{if(se&&xe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:s}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=s||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,Mt(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in ae)le[n]=ae[n];function Bn(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 $s{constructor(e,t){this.toDOM=e,this.spec=t||Nt,this.side=this.spec.side||0}map(e,t,s,o){let{pos:i,deleted:r}=e.mapResult(t.from+o,this.side<0?-1:1);return r?null:new he(i-s,i-s,this)}valid(){return!0}eq(e){return this==e||e instanceof $s&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Bn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ot{constructor(e,t){this.attrs=e,this.spec=t||Nt}map(e,t,s,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-s,r=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-s;return i>=r?null:new he(i,r,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof ot&&Bn(this.attrs,e.attrs)&&Bn(this.spec,e.spec)}static is(e){return e.type instanceof ot}destroy(){}}class bi{constructor(e,t){this.attrs=e,this.spec=t||Nt}map(e,t,s,o){let i=e.mapResult(t.from+o,1);if(i.deleted)return null;let r=e.mapResult(t.to+o,-1);return r.deleted||r.pos<=i.pos?null:new he(i.pos-s,r.pos-s,this)}valid(e,t){let{index:s,offset:o}=e.content.findIndex(t.from),i;return o==t.from&&!(i=e.child(s)).isText&&o+i.nodeSize==t.to}eq(e){return this==e||e instanceof bi&&Bn(this.attrs,e.attrs)&&Bn(this.spec,e.spec)}destroy(){}}class he{constructor(e,t,s){this.from=e,this.to=t,this.type=s}copy(e,t){return new he(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,s){return this.type.map(e,this,t,s)}static widget(e,t,s){return new he(e,e,new $s(t,s))}static inline(e,t,s,o){return new he(e,t,new ot(s,o))}static node(e,t,s,o){return new he(e,t,new bi(s,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof ot}get widget(){return this.type instanceof $s}}const cn=[],Nt={};class _{constructor(e,t){this.local=e.length?e:cn,this.children=t.length?t:cn}static create(e,t){return t.length?Fs(t,e,0,Nt):oe}find(e,t,s){let o=[];return this.findInner(e??0,t??1e9,o,0,s),o}findInner(e,t,s,o,i){for(let r=0;r<this.local.length;r++){let l=this.local[r];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&s.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,s,o+l,i)}}map(e,t,s){return this==oe||e.maps.length==0?this:this.mapInner(e,t,0,0,s||Nt)}mapInner(e,t,s,o,i){let r;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,s,o);a&&a.type.valid(t,a)?(r||(r=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?hm(this.children,r||[],e,t,s,o,i):r?new _(r.sort(Pt),cn):oe}add(e,t){return t.length?this==oe?_.create(e,t):this.addInner(e,t,0):this}addInner(e,t,s){let o,i=0;e.forEach((l,a)=>{let c=a+s,d;if(d=rc(t,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,d,c+1):o.splice(i,0,a,a+l.nodeSize,Fs(d,l,c+1,Nt)),i+=3}});let r=ic(i?lc(t):t,-s);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||r.splice(l--,1);return new _(r.length?this.local.concat(r).sort(Pt):this.local,o||this.children)}remove(e){return e.length==0||this==oe?this:this.removeInner(e,0)}removeInner(e,t){let s=this.children,o=this.local;for(let i=0;i<s.length;i+=3){let r,l=s[i]+t,a=s[i+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(r||(r=[])).push(u));if(!r)continue;s==this.children&&(s=this.children.slice());let c=s[i+2].removeInner(r,l+1);c!=oe?s[i+2]=c:(s.splice(i,3),i-=3)}if(o.length){for(let i=0,r;i<e.length;i++)if(r=e[i])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 s==this.children&&o==this.local?this:o.length||s.length?new _(o,s):oe}forChild(e,t){if(this==oe)return this;if(t.isLeaf)return _.empty;let s,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(s=this.children[l+2]);break}let i=e+1,r=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<r&&a.to>i&&a.type instanceof ot){let c=Math.max(i,a.from)-i,d=Math.min(r,a.to)-i;c<d&&(o||(o=[])).push(a.copy(c,d))}}if(o){let l=new _(o.sort(Pt),cn);return s?new it([l,s]):l}return s||oe}eq(e){if(this==e)return!0;if(!(e instanceof _)||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 vi(this.localsInner(e))}localsInner(e){if(this==oe)return cn;if(e.inlineContent||!this.local.some(ot.is))return this.local;let t=[];for(let s=0;s<this.local.length;s++)this.local[s].type instanceof ot||t.push(this.local[s]);return t}forEachSet(e){e(this)}}_.empty=new _([],[]),_.removeOverlap=vi;const oe=_.empty;class it{constructor(e){this.members=e}map(e,t){const s=this.members.map(o=>o.map(e,t,Nt));return it.from(s)}forChild(e,t){if(t.isLeaf)return _.empty;let s=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,t);i!=oe&&(i instanceof it?s=s.concat(i.members):s.push(i))}return it.from(s)}eq(e){if(!(e instanceof it)||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,s=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!t)t=i;else{s&&(t=t.slice(),s=!1);for(let r=0;r<i.length;r++)t.push(i[r])}}return t?vi(s?t:t.sort(Pt)):cn}static from(e){switch(e.length){case 0:return oe;case 1:return e[0];default:return new it(e.every(t=>t instanceof _)?e:e.reduce((t,s)=>t.concat(s instanceof _?s:s.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function hm(n,e,t,s,o,i,r){let l=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let u=0;t.maps[c].forEach((h,f,p,m)=>{let g=m-p-(f-h);for(let b=0;b<l.length;b+=3){let S=l[b+1];if(S<0||h>S+d-u)continue;let y=l[b]+d-u;f>=y?l[b+1]=h<=y?-2:-1:h>=d&&g&&(l[b]+=g,l[b+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+i),u=d-o;if(u<0||u>=s.content.size){a=!0;continue}let h=t.map(n[c+1]+i,-1),f=h-o,{index:p,offset:m}=s.content.findIndex(u),g=s.maybeChild(p);if(g&&m==u&&m+g.nodeSize==f){let b=l[c+2].mapInner(t,g,d+1,n[c]+i+1,r);b!=oe?(l[c]=u,l[c+1]=f,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=fm(l,n,e,t,o,i,r),d=Fs(c,s,0,r);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,h=0;u<d.children.length;u+=3){let f=d.children[u];for(;h<l.length&&l[h]<f;)h+=3;l.splice(h,0,d.children[u],d.children[u+1],d.children[u+2])}}return new _(e.sort(Pt),l)}function ic(n,e){if(!e||!n.length)return n;let t=[];for(let s=0;s<n.length;s++){let o=n[s];t.push(new he(o.from+e,o.to+e,o.type))}return t}function fm(n,e,t,s,o,i,r){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(s,o,c);u?t.push(u):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]+i+1);return t}function rc(n,e,t){if(e.isLeaf)return null;let s=t+e.nodeSize,o=null;for(let i=0,r;i<n.length;i++)(r=n[i])&&r.from>t&&r.to<s&&((o||(o=[])).push(r),n[i]=null);return o}function lc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Fs(n,e,t,s){let o=[],i=!1;e.forEach((l,a)=>{let c=rc(n,l,a+t);if(c){i=!0;let d=Fs(c,l,t+a+1,s);d!=oe&&o.push(a,a+l.nodeSize,d)}});let r=ic(i?lc(n):n,-t).sort(Pt);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||(s.onRemove&&s.onRemove(r[l].spec),r.splice(l--,1));return r.length||o.length?new _(r,o):oe}function Pt(n,e){return n.from-e.from||n.to-e.to}function vi(n){let e=n;for(let t=0;t<e.length-1;t++){let s=e[t];if(s.from!=s.to)for(let o=t+1;o<e.length;o++){let i=e[o];if(i.from==s.from){i.to!=s.to&&(e==n&&(e=n.slice()),e[o]=i.copy(i.from,s.to),ac(e,o+1,i.copy(s.to,i.to)));continue}else{i.from<s.to&&(e==n&&(e=n.slice()),e[t]=s.copy(s.from,i.from),ac(e,o,s.copy(i.from,s.to)));break}}}return e}function ac(n,e,t){for(;e<n.length&&Pt(t,n[e])>0;)e++;n.splice(e,0,t)}function wi(n){let e=[];return n.someProp("decorations",t=>{let s=t(n.state);s&&s!=oe&&e.push(s)}),n.cursorWrapper&&e.push(_.create(n.state.doc,[n.cursorWrapper.deco])),it.from(e)}const pm={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},mm=ue&&Qe<=11;class gm{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 ym{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new gm,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(s=>{for(let o=0;o<s.length;o++)this.queue.push(s[o]);ue&&Qe<=11&&s.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),mm&&(this.onCharData=s=>{this.queue.push({target:s.target,type:"characterData",oldValue:s.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,pm)),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(za(this.view)){if(this.suppressingSelectionUpdates)return $e(this.view);if(ue&&Qe<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Tt(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,s;for(let i=e.focusNode;i;i=On(i))t.add(i);for(let i=e.anchorNode;i;i=On(i))if(t.has(i)){s=i;break}let o=s&&this.view.docView.nearestDesc(s);if(o&&o.ignoreMutation({type:"selection",target:s.nodeType==3?s.parentNode:s}))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 s=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(s)&&za(e)&&!this.ignoreSelectionChange(s),i=-1,r=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(i=i<0?u.from:Math.min(u.from,i),r=r<0?u.to:Math.max(u.to,r),u.typeOver&&(l=!0))}if(Ce&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,h]=d;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let h of d){let f=h.parentNode;f&&f.nodeName=="LI"&&(!u||wm(e,u)!=f)&&h.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ds(s)&&(c=li(e))&&c.eq(I.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,$e(e),this.currentSelection.set(s),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,r),bm(e)),this.handleDOMChange(i,r,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(s)||$e(e),this.currentSelection.set(s))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let s=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(s==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!s||s.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(s.contentDOM&&s.contentDOM!=s.dom&&!s.contentDOM.contains(e.target))return{from:s.posBefore,to:s.posAfter};let o=e.previousSibling,i=e.nextSibling;if(ue&&Qe<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:h}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(o=u),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h)}let r=o&&o.parentNode==e.target?Y(o)+1:0,l=s.localPosFromDOM(e.target,r,-1),a=i&&i.parentNode==e.target?Y(i):e.target.childNodes.length,c=s.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:s.posAtStart-s.border,to:s.posAtEnd+s.border}:(this.lastChangedTextNode=e.target,{from:s.posAtStart,to:s.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let cc=new WeakMap,dc=!1;function bm(n){if(!cc.has(n)&&(cc.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ce,dc)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."),dc=!0}}function uc(n,e){let t=e.startContainer,s=e.startOffset,o=e.endContainer,i=e.endOffset,r=n.domAtPos(n.state.selection.anchor);return Tt(r.node,r.offset,o,i)&&([t,s,o,i]=[o,i,t,s]),{anchorNode:t,anchorOffset:s,focusNode:o,focusOffset:i}}function vm(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return uc(n,o)}let t;function s(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",s,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",s,!0),t?uc(n,t):null}function wm(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let s=n.docView.nearestDesc(t,!0);if(s&&s.node.isBlock)return t}return null}function Sm(n,e,t){let{node:s,fromOffset:o,toOffset:i,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}],Ds(a)||c.push({node:a.focusNode,offset:a.focusOffset})),se&&n.input.lastKeyCode===8)for(let g=i;g>o;g--){let b=s.childNodes[g-1],S=b.pmViewDesc;if(b.nodeName=="BR"&&!S){i=g;break}if(!S||S.size)break}let u=n.state.doc,h=n.someProp("domParser")||Ut.fromSchema(n.state.schema),f=u.resolve(r),p=null,m=h.parse(s,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:o,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Cm,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 Cm(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(re&&/^(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||re&&/^(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 xm=/^(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 km(n,e,t,s,o){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,A=li(n,T);if(A&&!n.state.selection.eq(A)){if(se&&xe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",D=>D(n,Mt(13,"Enter"))))return;let P=n.state.tr.setSelection(A);T=="pointer"?P.setMeta("pointer",!0):T=="key"&&P.scrollIntoView(),i&&P.setMeta("composition",i),n.dispatch(P)}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=Sm(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),h,f;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(h=n.state.selection.to,f="end"):(h=n.state.selection.from,f="start"),n.input.lastKeyCode=null;let p=Am(u.content,c.doc.content,c.from,h,f);if(p&&n.input.domChangeCount++,(on&&n.input.lastIOSEnter>Date.now()-225||xe)&&o.some(T=>T.nodeType==1&&!xm.test(T.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",T=>T(n,Mt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(s&&a instanceof R&&!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 T=hc(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let A=n.state.tr.setSelection(T);i&&A.setMeta("composition",i),n.dispatch(A)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof R&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ue&&Qe<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(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),S=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=p.endA,y;if((on&&n.input.lastIOSEnter>Date.now()-225&&(!S||o.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!S&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(y=I.findFrom(c.doc.resolve(m.pos+1),1,!0))&&y.head==g.pos)&&n.someProp("handleKeyDown",T=>T(n,Mt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Mm(d,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",T=>T(n,Mt(8,"Backspace")))){xe&&se&&n.domObserver.suppressSelectionUpdates();return}se&&xe&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),xe&&!S&&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(T){return T(n,Mt(13,"Enter"))})},20));let w=p.start,v=p.endA,C,k,E;if(S){if(m.pos==g.pos)ue&&Qe<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>$e(n),20)),C=n.state.tr.delete(w,v),k=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(E=Tm(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start()))))C=n.state.tr,E.type=="add"?C.addMark(w,v,E.mark):C.removeMark(w,v,E.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",A=>A(n,w,v,T)))return;C=n.state.tr.insertText(T,w,v)}}if(C||(C=n.state.tr.replace(w,v,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let T=hc(n,C.doc,c.sel);T&&!(se&&xe&&n.composing&&T.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(T.head==w||T.head==C.mapping.map(v)-1)||ue&&T.empty&&T.head==w)&&C.setSelection(T)}k&&C.ensureMarks(k),i&&C.setMeta("composition",i),n.dispatch(C.scrollIntoView())}function hc(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:ci(n,e.resolve(t.anchor),e.resolve(t.head))}function Tm(n,e){let t=n.firstChild.marks,s=e.firstChild.marks,o=t,i=s,r,l,a;for(let d=0;d<s.length;d++)o=s[d].removeFromSet(o);for(let d=0;d<t.length;d++)i=t[d].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],r="add",a=d=>d.mark(l.addToSet(d.marks));else if(o.length==0&&i.length==1)l=i[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(x.from(c).eq(n))return{mark:l,type:r}}function Mm(n,e,t,s,o){if(t-e<=o.pos-s.pos||Si(s,!0,!1)<o.pos)return!1;let i=n.resolve(e);if(!s.parent.isTextblock){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let r=n.resolve(Si(i,!0,!0));return!r.parent.isTextblock||r.pos>t||Si(r,!0,!1)<t?!1:s.parent.content.cut(s.parentOffset).eq(r.parent.content)}function Si(n,e,t){let s=n.depth,o=e?n.end():n.pos;for(;s>0&&(e||n.indexAfter(s)==n.node(s).childCount);)s--,o++,e=!1;if(t){let i=n.node(s).maybeChild(n.indexAfter(s));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function Am(n,e,t,s,o){let i=n.findDiffStart(e,t);if(i==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,i-Math.min(r,l));s-=r+a-i}if(r<i&&n.size<e.size){let a=s<=i&&s>=r?i-s:0;i-=a,i&&i<e.size&&fc(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-r),r=i}else if(l<i){let a=s<=i&&s>=l?i-s:0;i-=a,i&&i<n.size&&fc(n.textBetween(i-1,i+1))&&(i+=a?1:-1),r=i+(r-l),l=i}return{start:i,endA:r,endB:l}}function fc(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 Em{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 Kp,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(bc),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=gc(this),mc(this),this.nodeViews=yc(this),this.docView=xa(this.state.doc,pc(this),wi(this),this.dom,this),this.domObserver=new ym(this,(s,o,i,r)=>km(this,s,o,i,r)),this.domObserver.start(),Jp(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&pi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(bc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let s in this._props)t[s]=this._props[s];t.state=this.state;for(let s in e)t[s]=e[s];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var s;let o=this.state,i=!1,r=!1;e.storedMarks&&this.composing&&(tc(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=yc(this);Nm(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&pi(this),this.editable=gc(this),mc(this);let a=wi(this),c=pc(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(o.selection))&&(r=!0);let h=d=="preserve"&&r&&this.dom.style.overflowAnchor==null&&ap(this);if(r){this.domObserver.stop();let f=u&&(ue||se)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Om(o.selection,e.selection);if(u){let p=se?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=lm(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=xa(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ip(this))?$e(this,f):(Ra(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((s=this.dragging)===null||s===void 0)&&s.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():h&&cp(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof N){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&da(this,t.getBoundingClientRect(),e)}else da(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 s=this.directPlugins[t];s.spec.view&&this.pluginViews.push(s.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let s=this.state.plugins[t];s.spec.view&&this.pluginViews.push(s.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let s=this.pluginViews[t];s.update&&s.update(this,e)}}updateDraggedNode(e,t){let s=e.node,o=-1;if(this.state.doc.nodeAt(s.from)==s.node)o=s.from;else{let i=s.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==s.node&&(o=i)}this.dragging=new sc(e.slice,e.move,o<0?void 0:N.create(this.state.doc,o))}someProp(e,t){let s=this._props&&this._props[e],o;if(s!=null&&(o=t?t(s):s))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 i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let l=i[r].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(ue){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&dp(this.dom),$e(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 mp(this,e)}coordsAtPos(e,t=1){return ga(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,s=-1){let o=this.docView.posFromDOM(e,t,s);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return wp(this,t||this.state,e)}pasteHTML(e,t){return Vn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Vn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Up(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],wi(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Yf())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Yp(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?re&&this.root.nodeType===11&&np(this.dom.ownerDocument)==this.dom&&vm(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function pc(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 s in t)s=="class"?e.class+=" "+t[s]:s=="style"?e.style=(e.style?e.style+";":"")+t[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(t[s]))}),e.translate||(e.translate="no"),[he.node(0,n.state.doc.content.size,e)]}function mc(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:he.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function gc(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Om(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 yc(n){let e=Object.create(null);function t(s){for(let o in s)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=s[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Nm(n,e){let t=0,s=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)s++;return t!=s}function bc(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 Ci,xi;if(typeof WeakMap<"u"){let n=new WeakMap;Ci=e=>n.get(e),xi=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Ci=s=>{for(let o=0;o<n.length;o+=2)if(n[o]==s)return n[o+1]},xi=(s,o)=>(t==10&&(t=0),n[t++]=s,n[t++]=o)}var G=class{constructor(n,e,t,s){this.width=n,this.height=e,this.map=t,this.problems=s}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const s=e%this.width,o=e/this.width|0;let i=s+1,r=o+1;for(let l=1;i<this.width&&this.map[e+l]==t;l++)i++;for(let l=1;r<this.height&&this.map[e+this.width*l]==t;l++)r++;return{left:s,top:o,right:i,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:s,right:o,top:i,bottom:r}=this.findCell(n);return e=="horiz"?(t<0?s==0:o==this.width)?null:this.map[i*this.width+(t<0?s-1:o)]:(t<0?i==0:r==this.height)?null:this.map[s+this.width*(t<0?i-1:r)]}rectBetween(n,e){const{left:t,right:s,top:o,bottom:i}=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(s,l),bottom:Math.max(i,c)}}cellsInRect(n){const e=[],t={};for(let s=n.top;s<n.bottom;s++)for(let o=n.left;o<n.right;o++){const i=s*this.width+o,r=this.map[i];t[r]||(t[r]=!0,!(o==n.left&&o&&this.map[i-1]==r||s==n.top&&s&&this.map[i-this.width]==r)&&e.push(r))}return e}positionAt(n,e,t){for(let s=0,o=0;;s++){const i=o+t.child(s).nodeSize;if(s==n){let r=e+n*this.width;const l=(n+1)*this.width;for(;r<l&&this.map[r]<o;)r++;return r==l?i-1:this.map[r]}o=i}}static get(n){return Ci(n)||xi(n,Pm(n))}};function Pm(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=Im(n),t=n.childCount,s=[];let o=0,i=null;const r=[];for(let c=0,d=e*t;c<d;c++)s[c]=0;for(let c=0,d=0;c<t;c++){const u=n.child(c);d++;for(let p=0;;p++){for(;o<s.length&&s[o]!=0;)o++;if(p==u.childCount)break;const m=u.child(p),{colspan:g,rowspan:b,colwidth:S}=m.attrs;for(let y=0;y<b;y++){if(y+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:b-y});break}const w=o+y*e;for(let v=0;v<g;v++){s[w+v]==0?s[w+v]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:g-v});const C=S&&S[v];if(C){const k=(w+v)%e*2,E=r[k];E==null||E!=C&&r[k+1]==1?(r[k]=C,r[k+1]=1):E==C&&r[k+1]++}}}o+=g,d+=m.nodeSize}const h=(c+1)*e;let f=0;for(;o<h;)s[o++]==0&&f++;f&&(i||(i=[])).push({type:"missing",row:c,n:f}),d++}const l=new G(e,t,s,i);let a=!1;for(let c=0;!a&&c<r.length;c+=2)r[c]!=null&&r[c+1]<t&&(a=!0);return a&&Rm(l,r,n),l}function Im(n){let e=-1,t=!1;for(let s=0;s<n.childCount;s++){const o=n.child(s);let i=0;if(t)for(let r=0;r<s;r++){const l=n.child(r);for(let a=0;a<l.childCount;a++){const c=l.child(a);r+c.attrs.rowspan>s&&(i+=c.attrs.colspan)}}for(let r=0;r<o.childCount;r++){const l=o.child(r);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function Rm(n,e,t){n.problems||(n.problems=[]);const s={};for(let o=0;o<n.map.length;o++){const i=n.map[o];if(s[i])continue;s[i]=!0;const r=t.nodeAt(i);if(!r)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=r.attrs;for(let c=0;c<a.colspan;c++){const d=(o+c)%n.width,u=e[d*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=Dm(a)))[c]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function Dm(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function vc(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),s=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(r=>Number(r)):null,o=Number(n.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:s&&s.length==o?s:null};for(const r in e){const l=e[r].getFromDOM,a=l&&l(n);a!=null&&(i[r]=a)}return i}function wc(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 s in e){const o=e[s].setDOMAttr;o&&o(n.attrs[s],t)}return t}function zm(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const s in e)t[s]={default:e[s].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:s=>vc(s,e)}],toDOM(s){return["td",wc(s,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:s=>vc(s,e)}],toDOM(s){return["th",wc(s,e),0]}}}}function Re(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const s=n.nodes[t],o=s.spec.tableRole;o&&(e[o]=s)}}return e}var rt=new An("selectingCells");function Hn(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 Ws(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 ki(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=Hn(e.$head)||Lm(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Lm(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const s=e.type.spec.tableRole;if(s=="cell"||s=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const s=e.type.spec.tableRole;if(s=="cell"||s=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function Ti(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function Vm(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Mi(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Sc(n,e,t){const s=n.node(-1),o=G.get(s),i=n.start(-1),r=o.nextCell(n.pos-i,e,t);return r==null?null:n.node(0).resolve(i+r)}function dn(n,e,t=1){const s={...n,colspan:n.colspan-t};return s.colwidth&&(s.colwidth=s.colwidth.slice(),s.colwidth.splice(e,t),s.colwidth.some(o=>o>0)||(s.colwidth=null)),s}var K=class qe extends I{constructor(e,t=e){const s=e.node(-1),o=G.get(s),i=e.start(-1),r=o.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=o.cellsInRect(r).filter(d=>d!=t.pos-i);a.unshift(t.pos-i);const c=a.map(d=>{const u=s.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const h=i+d+1;return new Rl(l.resolve(h),l.resolve(h+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const s=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(Ti(s)&&Ti(o)&&Mi(s,o)){const i=this.$anchorCell.node(-1)!=s.node(-1);return i&&this.isRowSelection()?qe.rowSelection(s,o):i&&this.isColSelection()?qe.colSelection(s,o):new qe(s,o)}return R.between(s,o)}content(){const e=this.$anchorCell.node(-1),t=G.get(e),s=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s),i={},r=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let d=a*t.width+o.left,u=o.left;u<o.right;u++,d++){const h=t.map[d];if(i[h])continue;i[h]=!0;const f=t.findCell(h);let p=e.nodeAt(h);if(!p)throw RangeError(`No cell with offset ${h} 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=dn(b,0,m)),g>0&&(b=dn(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(x.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:r;return new M(x.from(l),1,1)}replace(e,t=M.empty){const s=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(s);e.replace(c.map(l.pos),c.map(a.pos),r?M.empty:t)}const i=I.findFrom(e.doc.resolve(e.mapping.slice(s).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new M(x.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),s=G.get(t),o=this.$anchorCell.start(-1),i=s.cellsInRect(s.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let r=0;r<i.length;r++)e(t.nodeAt(i[r]),o+i[r])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const s=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(s,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const s=e.node(-1),o=G.get(s),i=e.start(-1),r=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return r.top<=l.top?(r.top>0&&(e=a.resolve(i+o.map[r.left])),l.bottom<o.height&&(t=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+o.map[l.left])),r.bottom<o.height&&(e=a.resolve(i+o.map[o.width*(o.height-1)+r.right-1]))),new qe(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=G.get(e),s=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-s),i=t.colCount(this.$headCell.pos-s);if(Math.min(o,i)>0)return!1;const r=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(r,l)==t.width}eq(e){return e instanceof qe&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const s=e.node(-1),o=G.get(s),i=e.start(-1),r=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return r.left<=l.left?(r.left>0&&(e=a.resolve(i+o.map[r.top*o.width])),l.right<o.width&&(t=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+o.map[l.top*o.width])),r.right<o.width&&(e=a.resolve(i+o.map[o.width*(r.top+1)-1]))),new qe(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new qe(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,s=t){return new qe(e.resolve(t),e.resolve(s))}getBookmark(){return new Bm(this.$anchorCell.pos,this.$headCell.pos)}};K.prototype.visible=!1,I.jsonID("cell",K);var Bm=class od{constructor(e,t){this.anchor=e,this.head=t}map(e){return new od(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),s=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&s.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&s.index()<s.parent.childCount&&Mi(t,s)?new K(t,s):I.near(s,1)}};function Hm(n){if(!(n.selection instanceof K))return null;const e=[];return n.selection.forEachCell((t,s)=>{e.push(he.node(s,s+t.nodeSize,{class:"selectedCell"}))}),_.create(n.doc,e)}function $m({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,s=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,s--);return t==s&&/row|table/.test(n.node(o).type.spec.tableRole)}function Fm({$from:n,$to:e}){let t,s;for(let o=n.depth;o>0;o--){const i=n.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let o=e.depth;o>0;o--){const i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){s=i;break}}return t!==s&&e.parentOffset===0}function Wm(n,e,t){const s=(e||n).selection,o=(e||n).doc;let i,r;if(s instanceof N&&(r=s.node.type.spec.tableRole)){if(r=="cell"||r=="header_cell")i=K.create(o,s.from);else if(r=="row"){const l=o.resolve(s.from+1);i=K.rowSelection(l,l)}else if(!t){const l=G.get(s.node),a=s.from+1,c=a+l.map[l.width*l.height-1];i=K.create(o,a+1,c)}}else s instanceof R&&$m(s)?i=R.create(o,s.from):s instanceof R&&Fm(s)&&(i=R.create(o,s.$from.start(),s.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var _m=new An("fix-tables");function Cc(n,e,t,s){const o=n.childCount,i=e.childCount;e:for(let r=0,l=0;r<i;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}s(a,t),l<o&&n.child(l).sameMarkup(a)?Cc(n.child(l),a,t+1,s):a.nodesBetween(0,a.content.size,s,t+1),t+=a.nodeSize}}function qm(n,e){let t;const s=(o,i)=>{o.type.spec.tableRole=="table"&&(t=Gm(n,o,i,t))};return e?e.doc!=n.doc&&Cc(e.doc,n.doc,0,s):n.doc.descendants(s),t}function Gm(n,e,t,s){const o=G.get(e);if(!o.problems)return s;s||(s=n.tr);const i=[];for(let a=0;a<o.height;a++)i.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 u=d.attrs;for(let h=0;h<u.rowspan;h++)i[c.row+h]+=c.n;s.setNodeMarkup(s.mapping.map(t+1+c.pos),null,dn(u,u.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;s.setNodeMarkup(s.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;s.setNodeMarkup(s.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}}let r,l;for(let a=0;a<i.length;a++)i[a]&&(r==null&&(r=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const d=e.child(a),u=c+d.nodeSize,h=i[a];if(h>0){let f="cell";d.firstChild&&(f=d.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<h;g++){const b=Re(n.schema)[f].createAndFill();b&&p.push(b)}const m=(a==0||r==a-1)&&l==a?c+1:u-1;s.insert(s.mapping.map(m),p)}c=u}return s.setMeta(_m,{fixTables:!0})}function xc(n){const e=n.selection,t=ki(n),s=t.node(-1),o=t.start(-1),i=G.get(s);return{...e instanceof K?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(t.pos-o),tableStart:o,map:i,table:s}}function jm(n){return function(e,t){if(!Ws(e))return!1;if(t){const s=Re(e.schema),o=xc(e),i=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==s.header_cell&&i.setNodeMarkup(o.tableStart+r[a],s.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<r.length;a++)i.setNodeMarkup(o.tableStart+r[a],s.header_cell,l[a].attrs);t(i)}return!0}}function kc(n,e,t){const s=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<s.length;o++){const i=e.table.nodeAt(s[o]);if(i&&i.type!==t.header_cell)return!1}return!0}function Ai(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?jm(n):function(t,s){if(!Ws(t))return!1;if(s){const o=Re(t.schema),i=xc(t),r=t.tr,l=kc("row",i,o),a=kc("column",i,o),d=(n==="column"?l:n==="row"?a:!1)?1:0,u=n=="column"?{left:0,top:d,right:1,bottom:i.map.height}:n=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,h=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(u).forEach(f=>{const p=f+i.tableStart,m=r.doc.nodeAt(p);m&&r.setNodeMarkup(p,h,m.attrs)}),s(r)}return!0}}Ai("row",{useDeprecatedLogic:!0}),Ai("column",{useDeprecatedLogic:!0}),Ai("cell",{useDeprecatedLogic:!0});function Km(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let s=n.index(-1)-1,o=n.before();s>=0;s--){const i=n.node(-1).child(s),r=i.lastChild;if(r)return o-1-r.nodeSize;o-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let s=n.indexAfter(-1),o=n.after();s<t.childCount;s++){const i=t.child(s);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function Tc(n){return function(e,t){if(!Ws(e))return!1;const s=Km(ki(e),n);if(s==null)return!1;if(t){const o=e.doc.resolve(s);t(e.tr.setSelection(R.between(o,Vm(o))).scrollIntoView())}return!0}}function _s(n,e){const t=n.selection;if(!(t instanceof K))return!1;if(e){const s=n.tr,o=Re(n.schema).cell.createAndFill().content;t.forEachCell((i,r)=>{i.content.eq(o)||s.replace(s.mapping.map(r+1),s.mapping.map(r+i.nodeSize-1),new M(o,0,0))}),s.docChanged&&e(s)}return!0}function Jm(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:s}=n;for(;e.childCount==1&&(t>0&&s>0||e.child(0).type.spec.tableRole=="table");)t--,s--,e=e.child(0).content;const o=e.child(0),i=o.type.spec.tableRole,r=o.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),u=a<e.childCount-1?0:Math.max(0,s-1);(d||u)&&(c=Ei(Re(r).row,new M(c,d,u)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||s?Ei(Re(r).row,new M(e,t,s)).content:e);else return null;return Um(r,l)}function Um(n,e){const t=[];for(let o=0;o<e.length;o++){const i=e[o];for(let r=i.childCount-1;r>=0;r--){const{rowspan:l,colspan:a}=i.child(r).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let s=0;for(let o=0;o<t.length;o++)s=Math.max(s,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(x.empty),t[o]<s){const i=Re(n).cell.createAndFill(),r=[];for(let l=t[o];l<s;l++)r.push(i);e[o]=e[o].append(x.from(r))}return{height:e.length,width:s,rows:e}}function Ei(n,e){const t=n.createAndFill();return new Il(t).replace(0,t.content.size,e).doc}function Zm({width:n,height:e,rows:t},s,o){if(n!=s){const i=[],r=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=i[l]||0,u=0;d<s;u++){let h=a.child(u%a.childCount);d+h.attrs.colspan>s&&(h=h.type.createChecked(dn(h.attrs,h.attrs.colspan,d+h.attrs.colspan-s),h.content)),c.push(h),d+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)i[l+f]=(i[l+f]||0)+h.attrs.colspan}r.push(x.from(c))}t=r,n=s}if(e!=o){const i=[];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 u=c.child(d);r+u.attrs.rowspan>o&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,o-u.attrs.rowspan)},u.content)),a.push(u)}i.push(x.from(a))}t=i,e=o}return{width:n,height:e,rows:t}}function Ym(n,e,t,s,o,i,r){const l=n.doc.type.schema,a=Re(l);let c,d;if(o>e.width)for(let u=0,h=0;u<e.height;u++){const f=t.child(u);h+=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(h-1+s),p)}if(i>e.height){const u=[];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;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,x.from(u)),f=[];for(let p=e.height;p<i;p++)f.push(h);n.insert(n.mapping.slice(r).map(s+t.nodeSize-2),f)}return!!(c||d)}function Mc(n,e,t,s,o,i,r,l){if(r==0||r==e.height)return!1;let a=!1;for(let c=o;c<i;c++){const d=r*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const h=t.nodeAt(u),{top:f,left:p}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(l).map(u+s),null,{...h.attrs,rowspan:r-f}),n.insert(n.mapping.slice(l).map(e.positionAt(r,p,t)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-r})),c+=h.attrs.colspan-1}}return a}function Ac(n,e,t,s,o,i,r,l){if(r==0||r==e.width)return!1;let a=!1;for(let c=o;c<i;c++){const d=c*e.width+r,u=e.map[d];if(e.map[d-1]==u){a=!0;const h=t.nodeAt(u),f=e.colCount(u),p=n.mapping.slice(l).map(u+s);n.setNodeMarkup(p,null,dn(h.attrs,r-f,h.attrs.colspan-(r-f))),n.insert(p+h.nodeSize,h.type.createAndFill(dn(h.attrs,0,r-f))),c+=h.attrs.rowspan-1}}return a}function Ec(n,e,t,s,o){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let r=G.get(i);const{top:l,left:a}=s,c=a+o.width,d=l+o.height,u=n.tr;let h=0;function f(){if(i=t?u.doc.nodeAt(t-1):u.doc,!i)throw new Error("No table found");r=G.get(i),h=u.mapping.maps.length}Ym(u,r,i,t,c,d,h)&&f(),Mc(u,r,i,t,a,c,l,h)&&f(),Mc(u,r,i,t,a,c,d,h)&&f(),Ac(u,r,i,t,l,d,a,h)&&f(),Ac(u,r,i,t,l,d,c,h)&&f();for(let p=l;p<d;p++){const m=r.positionAt(p,a,i),g=r.positionAt(p,c,i);u.replace(u.mapping.slice(h).map(m+t),u.mapping.slice(h).map(g+t),new M(o.rows[p-l],0,0))}f(),u.setSelection(new K(u.doc.resolve(t+r.positionAt(l,a,i)),u.doc.resolve(t+r.positionAt(d-1,c-1,i)))),e(u)}var Xm=oa({ArrowLeft:Gs("horiz",-1),ArrowRight:Gs("horiz",1),ArrowUp:Gs("vert",-1),ArrowDown:Gs("vert",1),"Shift-ArrowLeft":js("horiz",-1),"Shift-ArrowRight":js("horiz",1),"Shift-ArrowUp":js("vert",-1),"Shift-ArrowDown":js("vert",1),Backspace:_s,"Mod-Backspace":_s,Delete:_s,"Mod-Delete":_s});function qs(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Gs(n,e){return(t,s,o)=>{if(!o)return!1;const i=t.selection;if(i instanceof K)return qs(t,s,I.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const r=Oc(o,n,e);if(r==null)return!1;if(n=="horiz")return qs(t,s,I.near(t.doc.resolve(i.head+e),e));{const l=t.doc.resolve(r),a=Sc(l,n,e);let c;return a?c=I.near(a,1):e<0?c=I.near(t.doc.resolve(l.before(-1)),-1):c=I.near(t.doc.resolve(l.after(-1)),1),qs(t,s,c)}}}function js(n,e){return(t,s,o)=>{if(!o)return!1;const i=t.selection;let r;if(i instanceof K)r=i;else{const a=Oc(o,n,e);if(a==null)return!1;r=new K(t.doc.resolve(a))}const l=Sc(r.$headCell,n,e);return l?qs(t,s,new K(r.$anchorCell,l)):!1}}function Qm(n,e){const t=n.state.doc,s=Hn(t.resolve(e));return s?(n.dispatch(n.state.tr.setSelection(new K(s))),!0):!1}function eg(n,e,t){if(!Ws(n.state))return!1;let s=Jm(t);const o=n.state.selection;if(o instanceof K){s||(s={width:1,height:1,rows:[x.from(Ei(Re(n.state.schema).cell,t))]});const i=o.$anchorCell.node(-1),r=o.$anchorCell.start(-1),l=G.get(i).rectBetween(o.$anchorCell.pos-r,o.$headCell.pos-r);return s=Zm(s,l.right-l.left,l.bottom-l.top),Ec(n.state,n.dispatch,r,l,s),!0}else if(s){const i=ki(n.state),r=i.start(-1);return Ec(n.state,n.dispatch,r,G.get(i.node(-1)).findCell(i.pos-r),s),!0}else return!1}function tg(n,e){var t;if(e.ctrlKey||e.metaKey)return;const s=Nc(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof K)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&s&&(o=Hn(n.state.selection.$anchor))!=null&&((t=Oi(n,e))==null?void 0:t.pos)!=o.pos)i(o,e),e.preventDefault();else if(!s)return;function i(a,c){let d=Oi(n,c);const u=rt.getState(n.state)==null;if(!d||!Mi(a,d))if(u)d=a;else return;const h=new K(a,d);if(u||!n.state.selection.eq(h)){const f=n.state.tr.setSelection(h);u&&f.setMeta(rt,a.pos),n.dispatch(f)}}function r(){n.root.removeEventListener("mouseup",r),n.root.removeEventListener("dragstart",r),n.root.removeEventListener("mousemove",l),rt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(rt,-1))}function l(a){const c=a,d=rt.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(Nc(n,c.target)!=s&&(u=Oi(n,e),!u))return r();u&&i(u,c)}n.root.addEventListener("mouseup",r),n.root.addEventListener("dragstart",r),n.root.addEventListener("mousemove",l)}function Oc(n,e,t){if(!(n.state.selection instanceof R))return null;const{$head:s}=n.state.selection;for(let o=s.depth-1;o>=0;o--){const i=s.node(o);if((t<0?s.index(o):s.indexAfter(o))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=s.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Nc(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Oi(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Hn(n.state.doc.resolve(t.pos)):null}var ng=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")),Ni(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,Ni(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Ni(n,e,t,s,o,i){var r;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let u=0,h=0;u<d.childCount;u++){const{colspan:f,colwidth:p}=d.child(u).attrs;for(let m=0;m<f;m++,h++){const g=o==h?i:p&&p[m],b=g?g+"px":"";if(l+=g||s,g||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const S=document.createElement("col");S.style.width=b,e.appendChild(S)}}}for(;c;){const u=c.nextSibling;(r=c.parentNode)==null||r.removeChild(c),c=u}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var me=new An("tableColumnResizing");function sg({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:s=ng,lastColumnResizable:o=!0}={}){const i=new Mn({key:me,state:{init(r,l){var a,c;const d=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,u=Re(l.schema).table.name;return s&&d&&(d[u]=(h,f)=>new s(h,t,f)),new og(-1,!1)},apply(r,l){return l.apply(r)}},props:{attributes:r=>{const l=me.getState(r);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(r,l)=>{ig(r,l,n,o)},mouseleave:r=>{rg(r)},mousedown:(r,l)=>{lg(r,l,e,t)}},decorations:r=>{const l=me.getState(r);if(l&&l.activeHandle>-1)return hg(r,l.activeHandle)},nodeViews:{}}});return i}var og=class Xs{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,s=e.getMeta(me);if(s&&s.setHandle!=null)return new Xs(s.setHandle,!1);if(s&&s.setDragging!==void 0)return new Xs(t.activeHandle,s.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return Ti(e.doc.resolve(o))||(o=-1),new Xs(o,t.dragging)}return t}};function ig(n,e,t,s){const o=me.getState(n.state);if(o&&!o.dragging){const i=cg(e.target);let r=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?r=Pc(n,e,"left",t):a-e.clientX<=t&&(r=Pc(n,e,"right",t))}if(r!=o.activeHandle){if(!s&&r!==-1){const l=n.state.doc.resolve(r),a=l.node(-1),c=G.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Rc(n,r)}}}function rg(n){const e=me.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Rc(n,-1)}function lg(n,e,t,s){var o;const i=(o=n.dom.ownerDocument.defaultView)!=null?o:window,r=me.getState(n.state);if(!r||r.activeHandle==-1||r.dragging)return!1;const l=n.state.doc.nodeAt(r.activeHandle),a=ag(n,r.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(me,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const h=me.getState(n.state);h!=null&&h.dragging&&(dg(n,h.activeHandle,Ic(h.dragging,u,t)),n.dispatch(n.state.tr.setMeta(me,{setDragging:null})))}function d(u){if(!u.which)return c(u);const h=me.getState(n.state);if(h&&h.dragging){const f=Ic(h.dragging,u,t);Dc(n,h.activeHandle,f,s)}}return Dc(n,r.activeHandle,a,s),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function ag(n,e,{colspan:t,colwidth:s}){const o=s&&s[s.length-1];if(o)return o;const i=n.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=t;if(s)for(let c=0;c<t;c++)s[c]&&(l-=s[c],a--);return l/a}function cg(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Pc(n,e,t,s){const o=t=="right"?-s:s,i=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;const{pos:r}=i,l=Hn(n.state.doc.resolve(r));if(!l)return-1;if(t=="right")return l.pos;const a=G.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 Ic(n,e,t){const s=e.clientX-n.startX;return Math.max(t,n.startWidth+s)}function Rc(n,e){n.dispatch(n.state.tr.setMeta(me,{setHandle:e}))}function dg(n,e,t){const s=n.state.doc.resolve(e),o=s.node(-1),i=G.get(o),r=s.start(-1),l=i.colCount(s.pos-r)+s.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){const d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;const u=i.map[d],h=o.nodeAt(u).attrs,f=h.colspan==1?0:l-i.colCount(u);if(h.colwidth&&h.colwidth[f]==t)continue;const p=h.colwidth?h.colwidth.slice():ug(h.colspan);p[f]=t,a.setNodeMarkup(r+u,null,{...h,colwidth:p})}a.docChanged&&n.dispatch(a)}function Dc(n,e,t,s){const o=n.state.doc.resolve(e),i=o.node(-1),r=o.start(-1),l=G.get(i).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&&Ni(i,a.firstChild,a,s,l,t)}function ug(n){return Array(n).fill(0)}function hg(n,e){var t;const s=[],o=n.doc.resolve(e),i=o.node(-1);if(!i)return _.empty;const r=G.get(i),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 u=r.map[d],h=l+u+i.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(t=me.getState(n))!=null&&t.dragging&&s.push(he.node(l+u,l+u+i.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),s.push(he.widget(h,f))}}return _.create(n.doc,s)}function fg({allowTableNodeSelection:n=!1}={}){return new Mn({key:rt,state:{init(){return null},apply(e,t){const s=e.getMeta(rt);if(s!=null)return s==-1?null:s;if(t==null||!e.docChanged)return t;const{deleted:o,pos:i}=e.mapping.mapResult(t);return o?null:i}},props:{decorations:Hm,handleDOMEvents:{mousedown:tg},createSelectionBetween(e){return rt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Qm,handleKeyDown:Xm,handlePaste:eg},appendTransaction(e,t,s){return Wm(s,qm(s,t),n)}})}const $n=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},zc="data-gs-mrk-fs",Lc="data-gs-ib",Ks="data-gs-ifrg",Fe="attrs",Vc={[Fe]:{default:"{}"}},We={[Fe]:{default:{}}},Bc=n=>({[Fe]:JSON.stringify($n(n))}),_e=n=>({attrs:$n(n)}),Fn=n=>e=>[n,e.attrs.attrs,0],lt=n=>n.attrs[Fe]?JSON.parse(n.attrs[Fe]):{},pg={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${Ks}]`,getAttrs:_e}],toDOM:()=>["span",{[Ks]:""},0]},div:{group:"block",content:"inline*",attrs:We,parseDOM:[{tag:"div",getAttrs:_e}],toDOM:Fn("div")},paragraph:{group:"block",content:"inline*",attrs:We,parseDOM:[{tag:"p",getAttrs:_e}],toDOM:Fn("p")},orderedList:{group:"block",content:"listItem+",attrs:We,parseDOM:[{tag:"ol",getAttrs:_e}],toDOM:Fn("ol")},bulletList:{group:"block",content:"listItem+",attrs:We,parseDOM:[{tag:"ul",getAttrs:_e}],toDOM:Fn("ul")},listItem:{content:"block*",group:"block",attrs:We,parseDOM:[{tag:"li",getAttrs:_e}],toDOM:Fn("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:We,parseDOM:[{tag:"pre",getAttrs:_e}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:We,parseDOM:[{tag:"img[src]",getAttrs:_e}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${Lc}]`}],toDOM(){return["br",{[Lc]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:We,parseDOM:[{tag:"br",getAttrs:_e}],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:$n(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...zm({tableGroup:"block",cellContent:"block+",cellAttributes:{[Fe]:{default:We[Fe].default,getFromDOM:$n,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:$n(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},Wn=(n,e)=>({attrs:Vc,parseDOM:n.map(t=>({tag:t,getAttrs:Bc})),toDOM:e}),mg={strong:Wn(["strong","b"],n=>["b",lt(n)]),link:Wn(["a"],n=>["a",lt(n),0]),em:Wn(["em","i"],n=>["em",lt(n)]),underline:Wn(["u"],n=>["u",lt(n),0]),strikethrough:Wn(["s"],n=>["s",lt(n),0]),font_size:{attrs:{...Vc,size:{default:null}},parseDOM:[{tag:`span[${zc}]`,getAttrs:n=>({...Bc(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...lt(n),[zc]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},Hc=new Dh({nodes:pg,marks:mg}),Js=new WeakMap,Pi=new WeakMap,gg=(n,e)=>{Js.set(n,e),Pi.set(e,n)},yg=(n,e)=>{Js.delete(n),Pi.delete(e)},Ii=n=>Js.get(n),bg=n=>Pi.get(n),$c=n=>{var t;const e=bg(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},vg=n=>n.dispatchEvent(new CustomEvent("input"));function wg(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(Ks)){if(t.getAttribute("style")){t.removeAttribute(Ks);return}const s=t.parentElement;if(s){for(;t.firstChild;)s.insertBefore(t.firstChild,t);s.removeChild(t)}}else Array.from(t.children).forEach(s=>e(s))};e(n)}function Sg(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,s=d=>n.getSelectedAll().includes(d),o=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),i=d=>d.isChildOf("text"),r=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{s(d)&&o(d)&&!r(d)&&l(d,u)},c=(d,u)=>{if(s(d)&&!o(d)&&i(d)){const h=d.parents().find(f=>f.isInstanceOf("text"));h&&(l(h,u),setTimeout(()=>n.select(h),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Cg=(n,e)=>{const t=xg(n);return t&&Ig(t)?kg(n,e):t?Kl(()=>({type:n.schema.nodes.div}))(n,e):!1};function xg(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 kg(n,e){const{selection:t,schema:s,tr:o}=n;o.split(t.from,1);const i=t.from+1,r=o.doc.nodeAt(i),l={...r.attrs.attrs,id:void 0},a=r.textContent.length>0,c=r.textContent.length||0,d=r.textContent||" ",u=s.text(d),h=s.nodes.div.create(l,a?u:[],[]);return o.replaceRangeWith(i,i+c+2,h),o.setSelection(R.create(o.doc,i+1)),e==null||e(o.scrollIntoView()),!0}function Tg(n,e,t){const{state:s,dispatch:o}=n,{selection:i,tr:r}=s,l=(a,c,d)=>{const u={};return a.split(";").forEach(h=>{const[f,p]=h.split(":").map(m=>m.trim());f&&(u[f]=p)}),u[c]=d,Object.entries(u).map(([h,f])=>`${h}: ${f}`).join("; ")};if(!i.empty||t)r.doc.nodesBetween(i.from,i.to,(a,c)=>{var d,u;if(a.type===s.schema.nodes.image){const h=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:h}})}else if(a.type.isBlock){const h=l(((u=a.attrs.attrs)==null?void 0:u.style)||"","text-align",e);Fc(a)?r.setBlockType(i.from,void 0,s.schema.nodes.div,{attrs:{style:h}}):r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:h}})}});else{const a=s.doc.resolve(i.from),c=a.start(a.depth),d=s.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const u=l(d.attrs.style||"","text-align",e);r.setNodeMarkup(c,void 0,{...d.attrs,style:u})}}r.docChanged&&o(r.scrollIntoView())}const _n=(n,e)=>{const{from:t,to:s}=n.selection;let o=!1;return n.doc.nodesBetween(t,s,i=>{if(o)return!1;i.marks.some(r=>r.type===e)&&(o=!0)}),o};function Mg(n,e,t="_blank"){const{state:s,dispatch:o}=n,{schema:i,selection:r,tr:l}=s,a=i.marks.link;try{const c=a.create({[Fe]: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 Ag(n,e){const{state:t,dispatch:s}=n,{selection:o,tr:i}=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}i.addMark(o.from,o.to,r.create({size:e})),s(i.scrollIntoView())}const It=(n,e)=>{const{doc:t,selection:s}=n.state,o=t.resolve(s.from);for(let i=o.depth;i>0;i--){const r=o.node(i);if(e(r))return{pos:i>0?o.before(i):0,start:o.start(i),depth:i,node:r}}},Eg=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,s])=>(t=t.replace(/-./g,o=>o.toUpperCase()[1]).trim(),e[t]=`${s}`.trim(),e),{});function Og(...n){return(e,t)=>{const s=r=>{e=e.apply(r),t==null||t(r)},o=n.pop();return n.reduce((r,l)=>r||l(e,s),!1)&&o!==void 0&&o(e,t)}}const Ng=(n,e)=>{const{state:t,dispatch:s}=n;if(e!=null&&e.event){const{event:o}=e,i=n.posAtCoords({left:o.clientX,top:o.clientY});i!=null&&i.pos&&s(t.tr.setSelection(R.create(t.doc,i.pos)))}else Jl(t,s);setTimeout(()=>setTimeout(()=>n.focus()))},Ri=n=>n.isBlock,Fc=n=>n.type.name==="inlineFragment",Pg=n=>Ri(n)&&!Fc(n),Wc=n=>n.type.name==="bulletList",_c=n=>n.type.name==="orderedList",Ig=n=>n.type.name==="heading",Rg=n=>Wc(n)||_c(n),qc=(n,e)=>{var i,r;const t=(i=It(n,l=>l.type===e))==null?void 0:i.node,s=n.state.schema.nodes.listItem;let o;return t?o=Xo(s):(r=It(n,Rg))!=null&&r.node?o=Og(Xo(s),ia(e)):o=ia(e),o(n.state,n.dispatch)},Gc=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(s=>s.type.name===e)},Dg=n=>{var r;const{view:e,prop:t,editor:s,propCSS:o}=n,i=(r=It(e,Pg))==null?void 0:r.node;if(i){const l=i.attrs.attrs||{},a=Eg(l.style);if(t in a)return a[t]||"";if(l.id){const c=s.Components.getById(l.id);return((c==null?void 0:c.getStyle())||{})[o]||""}}return""},zg=n=>{const{view:e,prop:t,markName:s,editor:o,propCSS:i}=n,r=Gc(e,s);if(r){const l=r.attrs;if(l[t])return l[t];if(l[Fe]){const a=lt(r).id;if(a){const c=o.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[i]||""}}}return""},jc=(n,e)=>{const{dispatch:t}=n,{nodes:s,marks:o}=n.state.schema;return{text:{selected:()=>{const{selection:i,doc:r}=n.state;return r.textBetween(i.from,i.to," ")},replace:(i,r={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(i));r.select&&(c=c.setSelection(R.create(c.doc,a,a+i.length))),t==null||t(c)}},bold:{toggle:()=>xt(o.strong)(n.state,t),isActive:()=>_n(n.state,o.strong)},italic:{toggle:()=>xt(o.em)(n.state,t),isActive:()=>_n(n.state,o.em)},underline:{toggle:()=>xt(o.underline)(n.state,t),isActive:()=>_n(n.state,o.underline)},strikethrough:{toggle:()=>xt(o.strikethrough)(n.state,t),isActive:()=>_n(n.state,o.strikethrough)},link:{get:()=>{const i=$c(n);if(i!=null&&i.is("link"))return i.getAttributes();{const r=Gc(n,"link");return r?lt(r):{}}},toggle:()=>xt(o.link)(n.state,t),isActive:()=>_n(n.state,o.link),create:i=>{const r=$c(n);r!=null&&r.is("link")?(r.addAttributes({href:i.url,target:i.target}),n.focus()):Mg(n,i.url,i.target)}},alignText:{get:()=>Dg({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:i=>Tg(n,i.value,!0)},fontSize:{get:()=>zg({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:i=>Ag(n,i.value)},image:{open(){const i="assetLayout",{state:r,dispatch:l}=n,{selection:a,doc:c}=r,d=c.textBetween(a.from,a.to," "),u={id:i,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:h=>{const f={alt:d,src:h.asset.getSrc()};l(r.tr.replaceSelectionWith(s.image.createAndFill({attrs:f})))}}};e.runCommand(B.layoutToggle,u)}},heading:{get:()=>{var r;const i=(r=It(n,Ri))==null?void 0:r.node;return`${(i==null?void 0:i.attrs.level)||""}`},set:({value:i})=>{var a;const{state:r}=n,l=(a=It(n,Ri))==null?void 0:a.node;Ef(r.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:i?parseInt(i,10):0})(r,t)}},listBullet:{isActive:()=>{var i;return!!((i=It(n,Wc))!=null&&i.node)},toggle:()=>qc(n,s.bulletList)},listOrdered:{isActive:()=>{var i;return!!((i=It(n,_c))!=null&&i.node)},toggle:()=>qc(n,s.orderedList)}}},ke="rte:selectionchange",ve={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>'},Lg=(n,e)=>{var a;const{editor:t,el:s}=n,o=Js.get(s),i=jc(o,t),r={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:ve.bold,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:i.bold.isActive()})}},onClick:({setState:c})=>{i.bold.toggle(),c({active:i.bold.isActive()})}},italic:{id:"italic",icon:ve.italic,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:i.italic.isActive()})}},onClick:({setState:c})=>{i.italic.toggle(),c({active:i.italic.isActive()})}},underline:{id:"underline",icon:ve.underline,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:i.underline.isActive()})}},onClick:({setState:c})=>{i.underline.toggle(),c({active:i.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:ve.strikethrough,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:i.strikethrough.isActive()})}},onClick:({setState:c})=>{i.strikethrough.toggle(),c({active:i.strikethrough.isActive()})}},image:{id:"image",icon:ve.image,size:"s",type:"button",onClick:()=>i.image.open()},link:{id:"link",icon:ve.link,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:i.link.isActive(),disabled:o.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:u,y:h,width:f,height:p}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(B.layoutRemove,{id:m}),b=i.link.get(),S={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:u,y:h,w:f,h:p},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:y=>{y.preventDefault();const w=new FormData(y.currentTarget);i.link.create({url:w.get("url"),target:w.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:w})=>w({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:w})=>w({value:y})},{type:"row",style:{gap:10,justifyContent:"end"},children:[i.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{i.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(B.layoutToggle,S)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:ve.alignTextLeft},{id:"center",icon:ve.alignTextCenter},{id:"right",icon:ve.alignTextRight},{id:"justify",icon:ve.alignTextJustify}],editorEvents:{[ke]:({setState:c})=>{c({value:i.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:ve.listBullet,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:i.listBullet.isActive()})}},onClick:({setState:c})=>{i.listBullet.toggle(),c({active:i.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:ve.listOrdered,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:i.listOrdered.isActive()})}},onClick:({setState:c})=>{i.listOrdered.toggle(),c({active:i.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:{[ke]:({setState:c})=>{c({value:i.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.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:{[ke]:({setState:c})=>{c({value:i.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.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:i,layouts:r,proseMirror:{view:o},items:l}))||l};class Vg{constructor(e,t,s){this.editor=s,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:s}=this;jc(s,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 at{constructor(e,t,s={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Bg(t):t,this.undoable=s.undoable!==!1,this.inCode=s.inCode||!1}}function Bg(n){return function(e,t,s,o){let i=n;if(t[1]){let r=t[0].lastIndexOf(t[1]);i+=t[0].slice(r+t[1].length),s+=r;let l=s-o;l>0&&(i=t[0].slice(r-l,r)+i,s=o)}return e.tr.insertText(i,s,o)}}const Hg=500;function $g({rules:n}){let e=new Mn({state:{init(){return null},apply(t,s){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:s)}},props:{handleTextInput(t,s,o,i){return Kc(t,s,o,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:s}=t.state.selection;s&&Kc(t,s.pos,s.pos,"",n,e)})}}},isInputRules:!0});return e}function Kc(n,e,t,s,o,i){if(n.composing)return!1;let r=n.state,l=r.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-Hg),l.parentOffset,null,"")+s;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 u=d.match.exec(a),h=u&&d.handler(r,u,e-(u[0].length-s.length),t);if(h)return d.undoable&&h.setMeta(i,{transform:h,from:e,to:t,text:s}),n.dispatch(h),!0}return!1}const Fg=new at(/--$/,"—"),Wg=new at(/\.\.\.$/,"…"),_g=new at(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),qg=new at(/"$/,"”"),Gg=new at(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),jg=new at(/'$/,"’"),Kg=[_g,qg,Gg,jg];function Di(n,e,t=null,s){return new at(n,(o,i,r,l)=>{let a=t instanceof Function?t(i):t,c=o.tr.delete(r,l),d=c.doc.resolve(r),u=d.blockRange(),h=u&&kl(u,e,a);if(!h)return null;c.wrap(u,h);let f=c.doc.resolve(r-1).nodeBefore;return f&&f.type==e&&Es(c.doc,r-1)&&(!s||s(i,f))&&c.join(r-1),c})}function Jc(n,e,t=null){return new at(n,(s,o,i,r)=>{let l=s.doc.resolve(i),a=t instanceof Function?t(o):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?s.tr.delete(i,r).setBlockType(i,i,e,a):null})}function Jg(n){return Di(/^\s*>\s$/,n)}function Ug(n){return Di(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function Zg(n){return Di(/^\s*([-+*])\s$/,n)}function Yg(n){return Jc(/^```$/,n)}function Xg(n,e){return Jc(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function Qg(n){const e=Kg.concat(Wg,Fg);let t;return(t=n.nodes.blockquote)&&e.push(Jg(t)),(t=n.nodes.orderedList)&&e.push(Ug(t)),(t=n.nodes.bulletList)&&e.push(Zg(t)),(t=n.nodes.codeBlock)&&e.push(Yg(t)),(t=n.nodes.heading)&&e.push(Xg(t,6)),$g({rules:e})}const e1="rteProseMirror",t1=Q(function(n,e={}){const t={plugins:r=>r.plugins,...e},s=(r,l)=>{var p,m;const a=((p=t.schema)==null?void 0:p.call(t,{editor:n,schema:Hc}))||Hc,{nodes:c,marks:d}=a,u=Ut.fromSchema(a).parse(r),h=nn.create({doc:u,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,plugins:[sg(),fg(),Qg(a),Hf(),Yo({Tab:Tc(1),"Shift-Tab":Tc(-1)}),Yo({Enter:En(jl,Kf(c.listItem),Cg),"Shift-Enter":En(Gl,(g,b)=>(b&&b(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":sa,"Mod-y":Jo,"Mod-Shift-z":Jo,"Mod-b":xt(d.strong),"Mod-i":xt(d.em),"Shift-Tab":Xo(c.listItem),Tab:Zf(c.listItem)}),Yo(Nf)]})}),f=new Em({mount:r},{state:h,dispatchTransaction(g){var v;const{state:b}=f,S=b.apply(g),y=!b.doc.eq(S.doc);f.updateState(S);const w=!b.selection.eq(S.selection);y&&(vg(((v=l==null?void 0:l.view)==null?void 0:v.el)||r),f.focus()),(w||y)&&n.trigger(ke)}});return r.__rteView=f,f.setProps({nodeViews:{image(g){return new Vg(g,f,n)}}}),f},o=r=>Lg(r,t);n.setCustomRte({toolbar:o,parseContent:!0,async enable(r,l,a){const c=Ii(r);if(c)return c;const d=s(r,a);return gg(r,d),Ng(d,a),d},disable(r){const l=Ii(r);if(l)return yg(r,l),l.destroy(),{forceSync:!0}},getContent(r){const l=Ii(r);if(l){const{schema:a,doc:c}=l.state,d=document.createElement("div"),u=Ct.fromSchema(a).serializeFragment(c.content);return u.childNodes.forEach(h=>{h.nodeType===Node.ELEMENT_NODE&&h.innerHTML===""&&(h.innerHTML="<br/>")}),d.appendChild(u),wg(d),r.classList.remove("ProseMirror-focused"),d.innerHTML}return r.innerHTML}});const i=Sg(n,t);ee({editor:n,licenseKey:t.licenseKey,plan:F.free,pluginName:e1,cleanup:()=>{n.RichTextEditor.customRte=void 0,i()}})}),n1="canvasEmptyState",s1=Q(function(n,e={}){const t=new WeakMap,s=new WeakMap,o=new WeakMap,i=new Set,r=new WeakMap,l={emptyStates:[],...e},a=(y,w)=>{let v=!1;const{isValid:C}=w;return Array.isArray(C)?v=C.some(k=>y.is(k)):Un(C)?v=C({component:y,editor:n}):v=y.is(C),v},c=y=>{const w=t.get(y);t.delete(y),w==null||w()},d=y=>{y.views.forEach(w=>c(w)),o.delete(y)},u=y=>{if(!(!y||i.has(y)))try{i.add(y);const w=y.components().length>0,v=o.get(y);if(w&&v)d(y);else if(!w&&!v){const C=r.has(y)?r.get(y):l.emptyStates.find(k=>a(y,k));if(r.set(y,C),!C)return;y.views.forEach(k=>{const E=C.render({editor:n,component:y,componentView:k,mount:T=>{s.set(k,T),o.set(y,!0);const A=k.getChildrenContainer();A==null||A.appendChild(T)},unmount:()=>c(k)});t.set(k,()=>{E==null||E();const T=s.get(k);T==null||T.remove()})})}}finally{i.delete(y)}},h=y=>{o.has(y)&&d(y)},f=({model:y})=>{u(y.getComponent())},p=n.Components.events,m=`${p.update}:components`,g="component:mount",b=n.Canvas.events.frameLoadBody,S=p.removed;n.on(m,u),n.on(g,u),n.on(S,h),n.on(b,f),ee({editor:n,licenseKey:l.licenseKey,plan:F.startup,pluginName:n1,cleanup:()=>{n.off(m,u),n.off(g,u),n.off(S,h),n.off(b,f)}})}),Uc="canvasFullSize",o1=Q(function(n,e={}){const{Canvas:t,Commands:s,Devices:o}=n,i={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:r,canvasOffsetX:l,canvasTransition:a,deviceMaxWidth:c,deviceMinHeigth:d,frameBorderRadius:u,frameTransition:h}=i,f=`${d}px`,p=t.events,m="core:preview",g=`${s.events.stopCommand}${m}`,b=t.getConfig(),S=`${Uc}:disable`,y=o.getAll().map(v=>({...v.attributes}));b.scrollableCanvas=!0,o.getAll().map(v=>{!v.get("width")&&v.set("width",`${c}px`),!v.get("height")&&v.set("height","auto"),!v.get("minHeight")&&v.set("minHeight",f)});const w=v=>{const C="data-gs-plg-full-size",k=document.querySelector(`style[${C}]`);if(v&&k)return k.remove();const E=k||document.createElement("style"),T=t.getZoomMultiplier();E.setAttribute(C,"true"),E.innerHTML=`
190
+ `,l.addEventListener("pointerdown",p()),i.appendChild(l)),s.append(i),(w=t.getSpotsEl())==null||w.appendChild(s)},f=w=>C=>{if(!a)return;uo(n,!0),C.stopPropagation(),C.preventDefault(),u.startResize(a,w,C);const E=C.clientX,T=C.clientY;C.target.setPointerCapture(C.pointerId);const A=D=>{const z=n.Canvas.getZoomMultiplier(),H=(D.clientX-E)*z,Te=(D.clientY-T)*z,Me=ho(w)?Te:H;u.updateResizeByDelta(a,w,Me)},P=()=>{uo(n,!1),u.finishResize(a),C.target.releasePointerCapture(C.pointerId),document.removeEventListener("pointermove",A),document.removeEventListener("pointerup",P)};document.addEventListener("pointermove",A),document.addEventListener("pointerup",P)},p=()=>w=>{if(!c)return;const C=c;uo(n,!0),w.stopPropagation(),w.preventDefault();const E=gn(C,e),T=Ts({componentRow:C,isVertical:E},e),A=w.clientX,P=w.clientY;w.target.setPointerCapture(w.pointerId);const D=H=>{const Te=n.Canvas.getZoomMultiplier(),Me=E?(H.clientY-P)*Te:(H.clientX-A)*Te;u.updateGapByDelta(C,Me,T,E)},z=()=>{uo(n,!1),u.finishGapAdjust(C),w.target.releasePointerCapture(w.pointerId),document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",z)};document.addEventListener("pointermove",D),document.addEventListener("pointerup",z)},m=w=>{const C=w.component;if(!C||!s||(a=C,c=C.parent(),!c))return;const E=c;Vr(s);const T=w.getStyle();i&&Object.assign(i.style,T);const A=gn(E,e),P=ju(A);if(Object.values(r).forEach(Lr),P.forEach(z=>{if(Yu(C,z))return;const H=r[z];Vr(H)}),yt(e).gapHandler.isGapSupported()&&l&&Xu(C)){const z=Ts({componentRow:E,isVertical:A},e);g(z,A,Uu(C))}},g=(w,C,E=!1)=>{const T=e.gapHandleSize,A=l.style;if(C){A.height=`${T}px`;const P=l.offsetHeight;E?(A.top=`-${(w+P)/2}px`,A.bottom=""):(A.bottom=`-${(w+P)/2}px`,A.top=""),A.width="50%",A.left="50%",A.transform="translateX(-50%)",A.cursor="row-resize"}else{A.width=`${T}px`;const P=l.offsetWidth;E?(A.left=`-${(w+P)/2}px`,A.right=""):(A.right=`-${(w+P)/2}px`,A.left=""),A.height="50%",A.top="50%",A.transform="translateY(-50%)",A.cursor="col-resize"}},y=()=>{s&&(Lr(s),a=null,c=null)},S=()=>{t.removeSpots({type:o});const w=n.getSelected(),C=w==null?void 0:w.parent();w&&C&&d.isValidRelationship(C,w)?t.addSpot({type:o,component:w}):y()},b=()=>{const w=t.getSpots().filter(C=>C.type===o)[0];w&&m(w)},x=(w,C)=>{d.registerTypeRelationship(w,C)};n.onReady(()=>{h(),Jt(e)?x("mj-section","mj-column"):x(e.typeRow,e.typeColumn)});const v="component:toggled";return n.on(t.events.spot,b),n.on(v,S),()=>{n.off(t.events.spot,b),n.off(v,S)}}const ch="flexComponent",dh=Q(function(n,e={}){const t={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...e},o=[nh(n,t),th(n,t)],s=ah(n,t),i=eh(n,t);ee({editor:n,licenseKey:t.licenseKey,plan:F.startup,pluginName:ch,cleanup:()=>{o.forEach(r=>r==null?void 0:r()),s(),i==null||i()}})}),uh=n=>n.dispatchEvent(new CustomEvent("input"));function hh(n,e){if(!e)return()=>{};const t=n.Components.events,o=d=>n.getSelectedAll().includes(d),s=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),i=d=>d.isChildOf("text"),r=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{o(d)&&s(d)&&!r(d)&&l(d,u)},c=(d,u)=>{if(o(d)&&!s(d)&&i(d)){const h=d.parents().find(f=>f.isInstanceOf("text"));h&&(l(h,u),setTimeout(()=>n.select(h),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const fh=`
191
+ .tox .tox-toolbar,
192
+ .tox .tox-toolbar__overflow,
193
+ .tox .tox-toolbar__primary,
194
+ .tox .tox-menu,
195
+ .tox .tox-dialog,
196
+ .tox .tox-toolbar-overlord,
197
+ .tox .tox-dialog__header,
198
+ .tox .tox-dialog__footer {
199
+ background-color: var(--gs-theme-cl-glb-bg3);
200
+ color: var(--gs-theme-cl-glb-txt);
201
+ }
202
+
203
+ .tox .tox-collection__item,
204
+ .tox .tox-label,
205
+ .tox .tox-toolbar-label {
206
+ color: var(--gs-theme-cl-glb-txt);
207
+ }
208
+
209
+ .tox.tox-tinymce-inline .tox-editor-header {
210
+ border-color: var(--gs-theme-cl-glb-br);
211
+ background-color: var(--gs-theme-cl-glb-bg3);
212
+ }
213
+
214
+ .tox .tox-button {
215
+ background-color: var(--gs-theme-cl-prm-bg1);
216
+ border-color: var(--gs-theme-cl-prm-bg1);
217
+ }
218
+
219
+ .tox .tox-button:hover:not(:disabled) {
220
+ background-color: var(--gs-theme-cl-prm-bgh);
221
+ border-color: var(--gs-theme-cl-prm-bgh);
222
+ }
223
+
224
+ .tox .tox-button--secondary {
225
+ background-color: var(--gs-theme-cl-glb-bg2);
226
+ border-color: var(--gs-theme-cl-glb-br);
227
+ }
228
+
229
+ .tox .tox-button--secondary:hover:not(:disabled) {
230
+ background-color: var(--gs-theme-cl-glb-bgh);
231
+ border-color: var(--gs-theme-cl-glb-bgh);
232
+ }
233
+
234
+ .tox .tox-tbtn {
235
+ color: currentColor;
236
+ }
237
+
238
+ .tox .tox-listboxfield .tox-listbox--select,
239
+ .tox .tox-textarea,
240
+ .tox .tox-tbtn--bespoke,
241
+ .tox .tox-textarea-wrap .tox-textarea:focus,
242
+ .tox .tox-textfield,
243
+ .tox .tox-toolbar-textfield {
244
+ background-color: var(--gs-theme-cl-glb-bgh);
245
+ }
246
+
247
+ .tox .tox-custom-editor:focus-within,
248
+ .tox .tox-listboxfield .tox-listbox--select:focus,
249
+ .tox .tox-textarea-wrap:focus-within,
250
+ .tox .tox-textarea:focus,
251
+ .tox .tox-textfield:focus {
252
+ background-color: var(--gs-theme-cl-glb-bgh);
253
+ border-color: var(--gs-theme-cl-prm-bg1);
254
+ }
255
+
256
+ .tox .tox-tbtn:hover,
257
+ .tox .tox-tbtn--enabled,
258
+ .tox .tox-tbtn--enabled:hover,
259
+ .tox .tox-tbtn:active,
260
+ .tox .tox-tbtn:focus,
261
+ .tox .tox-swatches__picker-btn:hover,
262
+ .tox .tox-collection--list .tox-collection__item--enabled,
263
+ .tox .tox-collection--toolbar .tox-collection__item--enabled,
264
+ .tox .tox-split-button:focus {
265
+ background-color: var(--gs-theme-cl-prm-bg1);
266
+ color: var(--gs-theme-cl-prm-txt);
267
+ }
268
+
269
+ .tox .tox-collection--list .tox-collection__item--active,
270
+ .tox .tox-collection--toolbar .tox-collection__item--active {
271
+ background-color: var(--gs-theme-cl-prm-bgh);
272
+ color: var(--gs-theme-cl-prm-txt) !important;
273
+ }
274
+
275
+ .tox .tox-split-button:hover {
276
+ box-shadow: 0 0 0 1px var(--gs-theme-cl-glb-bgh) inset;
277
+ }
278
+
279
+ .tox .tox-dialog__body-nav-item--active {
280
+ color: var(--gs-theme-cl-prm-bg1);
281
+ border-color: var(--gs-theme-cl-prm-bg1);
282
+ }
283
+
284
+ .tox .tox-tbtn svg,
285
+ .tox .tox-tbtn:hover svg {
286
+ fill: currentColor;
287
+ }
288
+
289
+ .tox .tox-insert-table-picker .tox-insert-table-picker__selected {
290
+ background-color: var(--gs-theme-cl-prm-bg1);
291
+ border-color: var(--gs-theme-cl-prm-bg3);
292
+ opacity: 0.75;
293
+ }`,As=new WeakMap,ph=(n,e)=>{As.set(n,e)},mh=n=>{As.delete(n)},Es=n=>As.get(n),po=n=>{const e=n.target,t=e.closest(".tox"),o=e.matches(".ephox-snooker-resizer-bar");(t||o)&&n.stopPropagation()},Wr=n=>{n.stopPropagation(),n.preventDefault()},gh=(n,e)=>{const t=n.getDoc(),o=n.getWin();if(e!=null&&e.event){const{event:s}=e,{clientX:i,clientY:r}=s;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(i,r);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(i,r);l=t.createRange(),l==null||l.setStart(a.offsetNode,a.offset)}if(l){const a=o.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(l),n.selection.setRng(l)}}else n.execCommand("SelectAll")},yh=n=>{var c,d;const{el:e,editor:t,componentView:o}=n,s=t.runCommand(B.getStateTheme),i=o.model,r={target:e,inline:!0,skin:(s==null?void 0:s.theme)===$i.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:o,component:i}))||{};return{...r,...l}},qr=(n,e=document)=>new Promise((t,o)=>{const s=Array.isArray(n)?[...n]:[n],{head:i}=e,r=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=r.bind(null,l),a.onerror=o,i.appendChild(a)}else t()};r(s)}),bh="rteTinyMce",vh=Q(function(n,e={}){const t={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...e},{cdnScript:o}=t,s=n.Canvas.events,i=!t.skipCustomTheme,r="gs-plg-tinymce-studio-theme",l=async(d,u)=>{const h=d.ownerDocument,f=h.defaultView,p=u==null?void 0:u.view;if(!f||!p){console.warn("Missing required data",{win:f,componentView:p});return}const m=yh({el:d,editor:n,componentView:p,pluginOpts:t}),y=(await f.tinymce.init(m))[0];if(!y)return;const b=(await window.tinymce.init({...m,target:document.createElement("div")}))[0];return y.ui.show(),h.body.addEventListener("mousedown",po),document.body.addEventListener("mousedown",po),y.on("Change",()=>uh(d)),y.on("blur",()=>y.ui.show()),y.on("OpenWindow",function(){var w;const x=(w=h.querySelector(".tox-dialog"))==null?void 0:w.closest(".tox");x&&(x==null?void 0:x.ownerDocument)!==document&&(document.body.appendChild(x),y.once("CloseWindow",()=>{x&&x.ownerDocument===document&&h.body.appendChild(x)}))}),d.addEventListener("dragstart",Wr,{capture:!0}),n.runCommand(B.setStateContextMenu,{enabled:!1}),gh(y,u),{rteEditor:y,rteEditorShallow:b}},a=(d,u)=>{d.ownerDocument.body.removeEventListener("mousedown",po),document.body.removeEventListener("mousedown",po),d.removeEventListener("dragstart",Wr,{capture:!0}),n.runCommand(B.setStateContextMenu,{enabled:!0}),u.rteEditor.destroy(),u.rteEditorShallow.destroy()};n.on(s.frameLoad,async({window:d})=>{const u=d.document;qr(o,u)}),n.onReady(()=>{qr(o,document),i&&yd(r,fh,{target:document.body})}),n.setCustomRte({parseContent:!0,async enable(d,u,h){const f=Es(d);if(f)return f.rteEditor;const p=await l(d,h);return p&&ph(d,p),p==null?void 0:p.rteEditor},disable(d){const u=Es(d);u&&(mh(d),a(d,u))},getContent(d){var h,f;const u=Es(d);return u?(f=(h=u.rteEditor).getContent)==null?void 0:f.call(h):d.innerHTML}});const c=hh(n,t.enableOnClick);ee({editor:n,licenseKey:t.licenseKey,plan:F.startup,pluginName:bh,cleanup:()=>{n.RichTextEditor.customRte=void 0,c()}})});function J(n){this.content=n}J.prototype={constructor:J,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 o=t&&t!=n?this.remove(t):this,s=o.find(n),i=o.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new J(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new J(t)},addToStart:function(n,e){return new J([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new J(t)},addBefore:function(n,e,t){var o=this.remove(e),s=o.content.slice(),i=o.find(n);return s.splice(i==-1?s.length:i,0,e,t),new J(s)},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=J.from(n),n.size?new J(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=J.from(n),n.size?new J(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=J.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}},J.from=function(n){if(n instanceof J)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new J(e)};function Gr(n,e,t){for(let o=0;;o++){if(o==n.childCount||o==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(o),i=e.child(o);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let r=0;s.text[r]==i.text[r];r++)t++;return t}if(s.content.size||i.content.size){let r=Gr(s.content,i.content,t+1);if(r!=null)return r}t+=s.nodeSize}}function jr(n,e,t,o){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:o};let r=n.child(--s),l=e.child(--i),a=r.nodeSize;if(r==l){t-=a,o-=a;continue}if(!r.sameMarkup(l))return{a:t,b:o};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--,o--;return{a:t,b:o}}if(r.content.size||l.content.size){let c=jr(r.content,l.content,t-1,o-1);if(c)return c}t-=a,o-=a}}class k{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let o=0;o<e.length;o++)this.size+=e[o].nodeSize}nodesBetween(e,t,o,s=0,i){for(let r=0,l=0;l<t;r++){let a=this.content[r],c=l+a.nodeSize;if(c>e&&o(a,s+l,i||null,r)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),o,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,o,s){let i="",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?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&o&&(r?r=!1:i+=o),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,o=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(o)&&(s[s.length-1]=t.withText(t.text+o.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new k(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let o=[],s=0;if(t>e)for(let i=0,r=0;r<t;i++){let l=this.content[i],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))),o.push(l),s+=l.nodeSize),r=a}return new k(o,s)}cutByIndex(e,t){return e==t?k.empty:e==0&&t==this.content.length?this:new k(this.content.slice(e,t))}replaceChild(e,t){let o=this.content[e];if(o==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-o.nodeSize;return s[e]=t,new k(s,i)}addToStart(e){return new k([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new k(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,o=0;t<this.content.length;t++){let s=this.content[t];e(s,o,t),o+=s.nodeSize}}findDiffStart(e,t=0){return Gr(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return jr(this,e,t,o)}findIndex(e,t=-1){if(e==0)return mo(0,e);if(e==this.size)return mo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let o=0,s=0;;o++){let i=this.child(o),r=s+i.nodeSize;if(r>=e)return r==e||t>0?mo(o+1,r):mo(o,s);s=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 k.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new k(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return k.empty;let t,o=0;for(let s=0;s<e.length;s++){let i=e[s];o+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new k(t||e,o)}static from(e){if(!e)return k.empty;if(e instanceof k)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new k([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}k.empty=new k([],0);const Os={index:0,offset:0};function mo(n,e){return Os.index=n,Os.offset=e,Os}function go(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 o=0;o<n.length;o++)if(!go(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!go(n[o],e[o]))return!1;for(let o in e)if(!(o in n))return!1}return!0}class V{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,o=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!o&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),o=!0),t&&t.push(i)}}return t||(t=e.slice()),o||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&&go(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 o=e.marks[t.type];if(!o)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=o.create(t.attrs);return o.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let o=0;o<e.length;o++)if(!e[o].eq(t[o]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return V.none;if(e instanceof V)return[e];let t=e.slice();return t.sort((o,s)=>o.type.rank-s.type.rank),t}}V.none=[];class yo extends Error{}class M{constructor(e,t,o){this.content=e,this.openStart=t,this.openEnd=o}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let o=Jr(this.content,e+this.openStart,t);return o&&new M(o,this.openStart,this.openEnd)}removeBetween(e,t){return new M(Kr(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 M.empty;let o=t.openStart||0,s=t.openEnd||0;if(typeof o!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new M(k.fromJSON(e,t.content),o,s)}static maxOpen(e,t=!0){let o=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)o++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new M(e,o,s)}}M.empty=new M(k.empty,0,0);function Kr(n,e,t){let{index:o,offset:s}=n.findIndex(e),i=n.maybeChild(o),{index:r,offset:l}=n.findIndex(t);if(s==e||i.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(o!=r)throw new RangeError("Removing non-flat range");return n.replaceChild(o,i.copy(Kr(i.content,e-s-1,t-s-1)))}function Jr(n,e,t,o){let{index:s,offset:i}=n.findIndex(e),r=n.maybeChild(s);if(i==e||r.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Jr(r.content,e-i-1,t);return l&&n.replaceChild(s,r.copy(l))}function xh(n,e,t){if(t.openStart>n.depth)throw new yo("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new yo("Inconsistent open depths");return Ur(n,e,t,0)}function Ur(n,e,t,o){let s=n.index(o),i=n.node(o);if(s==e.index(o)&&o<n.depth-t.openStart){let r=Ur(n,e,t,o+1);return i.copy(i.content.replaceChild(s,r))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let r=n.parent,l=r.content;return vt(r,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:r,end:l}=wh(t,n);return vt(i,Yr(n,r,l,e,o))}else return vt(i,bo(n,e,o))}function Zr(n,e){if(!e.type.compatibleContent(n.type))throw new yo("Cannot join "+e.type.name+" onto "+n.type.name)}function Ns(n,e,t){let o=n.node(t);return Zr(o,e.node(t)),o}function bt(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 vn(n,e,t,o){let s=(e||n).node(t),i=0,r=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(bt(n.nodeAfter,o),i++));for(let l=i;l<r;l++)bt(s.child(l),o);e&&e.depth==t&&e.textOffset&&bt(e.nodeBefore,o)}function vt(n,e){return n.type.checkContent(e),n.copy(e)}function Yr(n,e,t,o,s){let i=n.depth>s&&Ns(n,e,s+1),r=o.depth>s&&Ns(t,o,s+1),l=[];return vn(null,n,s,l),i&&r&&e.index(s)==t.index(s)?(Zr(i,r),bt(vt(i,Yr(n,e,t,o,s+1)),l)):(i&&bt(vt(i,bo(n,e,s+1)),l),vn(e,t,s,l),r&&bt(vt(r,bo(t,o,s+1)),l)),vn(o,null,s,l),new k(l)}function bo(n,e,t){let o=[];if(vn(null,n,t,o),n.depth>t){let s=Ns(n,e,t+1);bt(vt(s,bo(n,e,t+1)),o)}return vn(e,null,t,o),new k(o)}function wh(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(k.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class xn{constructor(e,t,o){this.pos=e,this.path=t,this.parentOffset=o,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 o=this.pos-this.path[this.path.length-1],s=e.child(t);return o?e.child(t).cut(o):s}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 o=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)s+=o.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return V.none;if(this.textOffset)return e.child(t).marks;let o=e.maybeChild(t-1),s=e.maybeChild(t);if(!o){let l=o;o=s,s=l}let i=o.marks;for(var r=0;r<i.length;r++)i[r].type.spec.inclusive===!1&&(!s||!i[r].isInSet(s.marks))&&(i=i[r--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let o=t.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}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 o=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);o>=0;o--)if(e.pos<=this.end(o)&&(!t||t(this.node(o))))return new vo(this,e,o);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 o=[],s=0,i=t;for(let r=e;;){let{index:l,offset:a}=r.content.findIndex(i),c=i-a;if(o.push(r,l,s+a),!c||(r=r.child(l),r.isText))break;i=c-1,s+=a+1}return new xn(t,o,i)}static resolveCached(e,t){let o=Xr.get(e);if(o)for(let i=0;i<o.elts.length;i++){let r=o.elts[i];if(r.pos==t)return r}else Xr.set(e,o=new Sh);let s=o.elts[o.i]=xn.resolve(e,t);return o.i=(o.i+1)%Ch,s}}class Sh{constructor(){this.elts=[],this.i=0}}const Ch=12,Xr=new WeakMap;class vo{constructor(e,t,o){this.$from=e,this.$to=t,this.depth=o}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 kh=Object.create(null);let xt=class zi{constructor(e,t,o,s=V.none){this.type=e,this.attrs=t,this.marks=s,this.content=o||k.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,o,s=0){this.content.nodesBetween(e,t,o,s,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,o,s){return this.content.textBetween(e,t,o,s)}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,o){return this.type==e&&go(this.attrs,t||e.defaultAttrs||kh)&&V.sameSet(this.marks,o||V.none)}copy(e=null){return e==this.content?this:new zi(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new zi(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,o=!1){if(e==t)return M.empty;let s=this.resolve(e),i=this.resolve(t),r=o?0:s.sharedDepth(t),l=s.start(r),c=s.node(r).content.cut(s.pos-l,i.pos-l);return new M(c,s.depth-r,i.depth-r)}replace(e,t,o){return xh(this.resolve(e),this.resolve(t),o)}nodeAt(e){for(let t=this;;){let{index:o,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(o),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:o}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:o}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:o}=this.content.findIndex(e);if(o<e)return{node:this.content.child(t),index:t,offset:o};let s=this.content.child(t-1);return{node:s,index:t-1,offset:o-s.nodeSize}}resolve(e){return xn.resolveCached(this,e)}resolveNoCache(e){return xn.resolve(this,e)}rangeHasMark(e,t,o){let s=!1;return t>e&&this.nodesBetween(e,t,i=>(o.isInSet(i.marks)&&(s=!0),!s)),s}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()+")"),Qr(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,o=k.empty,s=0,i=o.childCount){let r=this.contentMatchAt(e).matchFragment(o,s,i),l=r&&r.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(o.child(a).marks))return!1;return!0}canReplaceWith(e,t,o,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(o),r=i&&i.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=V.none;for(let t=0;t<this.marks.length;t++){let o=this.marks[t];o.type.checkAttrs(o.attrs),e=o.addToSet(e)}if(!V.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 o;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");o=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,o)}let s=k.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,o);return i.type.checkAttrs(i.attrs),i}};xt.prototype.text=void 0;class xo extends xt{constructor(e,t,o,s){if(super(e,t,null,s),!o)throw new RangeError("Empty text nodes are not allowed");this.text=o}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Qr(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 xo(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new xo(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 Qr(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class wt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new Th(e,t);if(o.next==null)return wt.empty;let s=el(o);o.next&&o.err("Unexpected trailing text");let i=Ih(Ph(s));return Rh(i,o),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,o=e.childCount){let s=this;for(let i=t;s&&i<o;i++)s=s.matchType(e.child(i).type);return s}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 o=0;o<e.next.length;o++)if(this.next[t].type==e.next[o].type)return!0;return!1}fillBefore(e,t=!1,o=0){let s=[this];function i(r,l){let a=r.matchFragment(e,o);if(a&&(!t||a.validEnd))return k.from(l.map(c=>c.createAndFill()));for(let c=0;c<r.next.length;c++){let{type:d,next:u}=r.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let h=i(u,l.concat(d));if(h)return h}}return null}return i(this,[])}findWrapping(e){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==e)return this.wrapCache[o+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let s=o.shift(),i=s.match;if(i.matchType(e)){let r=[];for(let l=s;l.type;l=l.via)r.push(l.type);return r.reverse()}for(let r=0;r<i.next.length;r++){let{type:l,next:a}=i.next[r];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(o.push({match:l.contentMatch,type:l,via:s}),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(o){e.push(o);for(let s=0;s<o.next.length;s++)e.indexOf(o.next[s].next)==-1&&t(o.next[s].next)}return t(this),e.map((o,s)=>{let i=s+(o.validEnd?"*":" ")+" ";for(let r=0;r<o.next.length;r++)i+=(r?", ":"")+o.next[r].type.name+"->"+e.indexOf(o.next[r].next);return i}).join(`
294
+ `)}}wt.empty=new wt(!0);class Th{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 el(n){let e=[];do e.push(Mh(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Mh(n){let e=[];do e.push(Ah(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Ah(n){let e=Nh(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=Eh(n,e);else break;return e}function tl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Eh(n,e){let t=tl(n),o=t;return n.eat(",")&&(n.next!="}"?o=tl(n):o=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:o,expr:e}}function Oh(n,e){let t=n.nodeTypes,o=t[e];if(o)return[o];let s=[];for(let i in t){let r=t[i];r.isInGroup(e)&&s.push(r)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function Nh(n){if(n.eat("(")){let e=el(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=Oh(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 Ph(n){let e=[[]];return s(i(n,0),t()),e;function t(){return e.push([])-1}function o(r,l,a){let c={term:a,to:l};return e[r].push(c),c}function s(r,l){r.forEach(a=>a.to=l)}function i(r,l){if(r.type=="choice")return r.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(r.type=="seq")for(let a=0;;a++){let c=i(r.exprs[a],l);if(a==r.exprs.length-1)return c;s(c,l=t())}else if(r.type=="star"){let a=t();return o(l,a),s(i(r.expr,a),a),[o(a)]}else if(r.type=="plus"){let a=t();return s(i(r.expr,l),a),s(i(r.expr,a),a),[o(a)]}else{if(r.type=="opt")return[o(l)].concat(i(r.expr,l));if(r.type=="range"){let a=l;for(let c=0;c<r.min;c++){let d=t();s(i(r.expr,a),d),a=d}if(r.max==-1)s(i(r.expr,a),a);else for(let c=r.min;c<r.max;c++){let d=t();o(a,d),s(i(r.expr,a),d),a=d}return[o(a)]}else{if(r.type=="name")return[o(l,void 0,r.value)];throw new Error("Unknown expr type")}}}}function nl(n,e){return e-n}function ol(n,e){let t=[];return o(e),t.sort(nl);function o(s){let i=n[s];if(i.length==1&&!i[0].term)return o(i[0].to);t.push(s);for(let r=0;r<i.length;r++){let{term:l,to:a}=i[r];!l&&t.indexOf(a)==-1&&o(a)}}}function Ih(n){let e=Object.create(null);return t(ol(n,0));function t(o){let s=[];o.forEach(r=>{n[r].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);ol(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[o.join(",")]=new wt(o.indexOf(n.length-1)>-1);for(let r=0;r<s.length;r++){let l=s[r][1].sort(nl);i.next.push({type:s[r][0],next:e[l.join(",")]||t(l)})}return i}}function Rh(n,e){for(let t=0,o=[n];t<o.length;t++){let s=o[t],i=!s.validEnd,r=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];r.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),o.indexOf(c)==-1&&o.push(c)}i&&e.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function sl(n){let e=Object.create(null);for(let t in n){let o=n[t];if(!o.hasDefault)return null;e[t]=o.default}return e}function il(n,e){let t=Object.create(null);for(let o in n){let s=e&&e[o];if(s===void 0){let i=n[o];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+o)}t[o]=s}return t}function rl(n,e,t,o){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let i=n[s];i.validate&&i.validate(e[s])}}function ll(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new zh(n,o,e[o]);return t}let al=class od{constructor(e,t,o){this.name=e,this.schema=t,this.spec=o,this.markSet=null,this.groups=o.group?o.group.split(" "):[],this.attrs=ll(e,o.attrs),this.defaultAttrs=sl(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(o.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==wt.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:il(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new xt(this,this.computeAttrs(e),k.from(t),V.setFrom(o))}createChecked(e=null,t,o){return t=k.from(t),this.checkContent(t),new xt(this,this.computeAttrs(e),t,V.setFrom(o))}createAndFill(e=null,t,o){if(e=this.computeAttrs(e),t=k.from(t),t.size){let r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}let s=this.contentMatch.matchFragment(t),i=s&&s.fillBefore(k.empty,!0);return i?new xt(this,e,t.append(i),V.setFrom(o)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let o=0;o<e.childCount;o++)if(!this.allowsMarks(e.child(o).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){rl(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 o=0;o<e.length;o++)this.allowsMarkType(e[o].type)?t&&t.push(e[o]):t||(t=e.slice(0,o));return t?t.length?t:V.none:e}static compile(e,t){let o=Object.create(null);e.forEach((i,r)=>o[i]=new od(i,t,r));let s=t.spec.topNode||"doc";if(!o[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let i in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function Dh(n,e,t){let o=t.split("|");return s=>{let i=s===null?"null":typeof s;if(o.indexOf(i)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${n}, got ${i}`)}}class zh{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?Dh(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class wo{constructor(e,t,o,s){this.name=e,this.rank=t,this.schema=o,this.spec=s,this.attrs=ll(e,s.attrs),this.excluded=null;let i=sl(this.attrs);this.instance=i?new V(this,i):null}create(e=null){return!e&&this.instance?this.instance:new V(this,il(this.attrs,e))}static compile(e,t){let o=Object.create(null),s=0;return e.forEach((i,r)=>o[i]=new wo(i,s++,t,r)),o}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){rl(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Lh{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=J.from(e.nodes),t.marks=J.from(e.marks||{}),this.nodes=al.compile(this.spec.nodes,this),this.marks=wo.compile(this.spec.marks,this);let o=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],r=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=o[r]||(o[r]=wt.parse(r,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?cl(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],r=i.spec.excludes;i.excluded=r==null?[i]:r==""?[]:cl(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,o,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof al){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,o,s)}text(e,t){let o=this.nodes.text;return new xo(o,o.defaultAttrs,e,V.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return xt.fromJSON(this,e)}markFromJSON(e){return V.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function cl(n,e){let t=[];for(let o=0;o<e.length;o++){let s=e[o],i=n.marks[s],r=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(r=a)}if(!r)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function Vh(n){return n.tag!=null}function Bh(n){return n.style!=null}class Ut{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(s=>{if(Vh(s))this.tags.push(s);else if(Bh(s)){let i=/[^=]*/.exec(s.style)[0];o.indexOf(i)<0&&o.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let o=new fl(this,t,!1);return o.addAll(e,V.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new fl(this,t,!0);return o.addAll(e,V.none,t.from,t.to),M.maxOpen(o.finish())}matchTag(e,t,o){for(let s=o?this.tags.indexOf(o)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(Fh(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let r=i.getAttrs(e);if(r===!1)continue;i.attrs=r||void 0}return i}}}matchStyle(e,t,o,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let r=this.styles[i],l=r.style;if(!(l.indexOf(e)!=0||r.context&&!o.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 o(s){let i=s.priority==null?50:s.priority,r=0;for(;r<t.length;r++){let l=t[r];if((l.priority==null?50:l.priority)<i)break}t.splice(r,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(r=>{o(r=pl(r)),r.mark||r.ignore||r.clearMark||(r.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(r=>{o(r=pl(r)),r.node||r.ignore||r.mark||(r.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ut(e,Ut.schemaRules(e)))}}const dl={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},Hh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ul={ol:!0,ul:!0},So=1,Co=2,wn=4;function hl(n,e,t){return e!=null?(e?So:0)|(e==="full"?Co:0):n&&n.whitespace=="pre"?So|Co:t&~wn}class ko{constructor(e,t,o,s,i,r){this.type=e,this.attrs=t,this.marks=o,this.solid=s,this.options=r,this.content=[],this.activeMarks=V.none,this.match=i||(r&wn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(k.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let o=this.type.contentMatch,s;return(s=o.findWrapping(e.type))?(this.match=o,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&So)){let o=this.content[this.content.length-1],s;if(o&&o.isText&&(s=/[ \t\r\n\u000c]+$/.exec(o.text))){let i=o;o.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=k.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(k.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&&!dl.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class fl{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0;let s=t.topNode,i,r=hl(null,t.preserveWhitespace,0)|(o?wn:0);s?i=new ko(s.type,s.attrs,V.none,!0,t.topMatch||s.type.contentMatch,r):o?i=new ko(null,null,V.none,!0,null,r):i=new ko(e.schema.topNodeType,null,V.none,!0,null,r),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let o=e.nodeValue,s=this.top;if(s.options&Co||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(s.options&So)s.options&Co?o=o.replace(/\r\n?/g,`
295
+ `):o=o.replace(/\r?\n|\r/g," ");else if(o=o.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(o)&&this.open==this.nodes.length-1){let i=s.content[s.content.length-1],r=e.previousSibling;(!i||r&&r.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(o=o.slice(1))}o&&this.insertNode(this.parser.schema.text(o),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,o){let s=e.nodeName.toLowerCase(),i;ul.hasOwnProperty(s)&&this.parser.normalizeLists&&$h(e);let r=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,o));if(r?r.ignore:Hh.hasOwnProperty(s))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(dl.hasOwnProperty(s))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?i:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
296
+ `),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 o=e.style;if(o&&o.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],r=o.getPropertyValue(i);if(r)for(let l=void 0;;){let a=this.parser.matchStyle(i,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,o,s){let i,r;if(t.node)if(r=this.parser.schema.nodes[t.node],r.isLeaf)this.insertNode(r.create(t.attrs),o)||this.leafFallback(e,o);else{let a=this.enter(r,t.attrs||null,o,t.preserveWhitespace);a&&(i=!0,o=a)}else{let a=this.parser.schema.marks[t.mark];o=o.concat(a.create(t.attrs))}let l=this.top;if(r&&r.isLeaf)this.findInside(e);else if(s)this.addElement(e,o,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,o));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,o),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,o,s){let i=o||0;for(let r=o?e.childNodes[o]:e.firstChild,l=s==null?null:e.childNodes[s];r!=l;r=r.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(r,t);this.findAtPoint(e,i)}findPlace(e,t){let o,s;for(let i=this.open;i>=0;i--){let r=this.nodes[i],l=r.findWrapping(e);if(l&&(!o||o.length>l.length)&&(o=l,s=r,!l.length)||r.solid)break}if(!o)return null;this.sync(s);for(let i=0;i<o.length;i++)t=this.enterInner(o[i],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let o=this.findPlace(e,t);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=V.none;for(let r of o.concat(e.marks))(s.type?s.type.allowsMarkType(r.type):ml(r.type,e.type))&&(i=r.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,t,o,s){let i=this.findPlace(e.create(t),o);return i&&(i=this.enterInner(e,t,o,!0,s)),i}enterInner(e,t,o,s=!1,i){this.closeExtra();let r=this.top;r.match=r.match&&r.match.matchType(e);let l=hl(e,i,r.options);r.options&wn&&r.content.length==0&&(l|=wn);let a=V.none;return o=o.filter(c=>(r.type?r.type.allowsMarkType(c.type):ml(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new ko(e,t,a,s,null,l)),this.open++,o}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 o=this.nodes[t].content;for(let s=o.length-1;s>=0;s--)e+=o[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let o=0;o<this.find.length;o++)this.find[o].node==e&&this.find[o].offset==t&&(this.find[o].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,o){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(o?2:4)&&(this.find[s].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("/"),o=this.options.context,s=!this.isOpen&&(!o||o.parent.type==this.nodes[0].type),i=-(o?o.depth+1:0)+(s?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>=i;a--)if(r(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:o&&a>=i?o.node(a-i).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 o=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(o&&o.isTextblock&&o.defaultAttrs)return o}for(let t in this.parser.schema.nodes){let o=this.parser.schema.nodes[t];if(o.isTextblock&&o.defaultAttrs)return o}}}function $h(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&ul.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function Fh(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function pl(n){let e={};for(let t in n)e[t]=n[t];return e}function ml(n,e){let t=e.schema.nodes;for(let o in t){let s=t[o];if(!s.allowsMarkType(n))continue;let i=[],r=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&r(d))return!0}};if(r(s.contentMatch))return!0}}class St{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=Ps(t).createDocumentFragment());let s=o,i=[];return e.forEach(r=>{if(i.length||r.marks.length){let l=0,a=0;for(;l<i.length&&a<r.marks.length;){let c=r.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<r.marks.length;){let c=r.marks[a++],d=this.serializeMark(c,r.isInline,t);d&&(i.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(r,t))}),o}serializeNodeInner(e,t){let{dom:o,contentDOM:s}=To(Ps(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return o}serializeNode(e,t={}){let o=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(o),o=i.dom)}return o}serializeMark(e,t,o={}){let s=this.marks[e.type.name];return s&&To(Ps(o),s(e,t),null,e.attrs)}static renderSpec(e,t,o=null,s){return To(e,t,o,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new St(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=gl(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return gl(e.marks)}}function gl(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function Ps(n){return n.document||window.document}const yl=new WeakMap;function _h(n){let e=yl.get(n);return e===void 0&&yl.set(n,e=Wh(n)),e}function Wh(n){let e=null;function t(o){if(o&&typeof o=="object")if(Array.isArray(o))if(typeof o[0]=="string")e||(e=[]),e.push(o);else for(let s=0;s<o.length;s++)t(o[s]);else for(let s in o)t(o[s])}return t(n),e}function To(n,e,t,o){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 s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(i=_h(o))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let r=s.indexOf(" ");r>0&&(t=s.slice(0,r),s=s.slice(r+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let h=u.indexOf(" ");h>0?a.setAttributeNS(u.slice(0,h),u.slice(h+1),c[u]):a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let h=e[u];if(h===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:p}=To(n,h,t,o);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const bl=65535,vl=Math.pow(2,16);function qh(n,e){return n+e*vl}function xl(n){return n&bl}function Gh(n){return(n-(n&bl))/vl}const wl=1,Sl=2,Mo=4,Cl=8;class Is{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&Cl)>0}get deletedBefore(){return(this.delInfo&(wl|Mo))>0}get deletedAfter(){return(this.delInfo&(Sl|Mo))>0}get deletedAcross(){return(this.delInfo&Mo)>0}}class fe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&fe.empty)return fe.empty}recover(e){let t=0,o=xl(e);if(!this.inverted)for(let s=0;s<o;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[o*3]+t+Gh(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,o){let s=0,i=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?s:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+r],u=a+c;if(e<=u){let h=c?e==a?-1:e==u?1:t:t,f=a+s+(h<0?0:d);if(o)return f;let p=e==(t<0?a:u)?null:qh(l/3,e-a),m=e==a?Sl:e==u?wl:Mo;return(t<0?e!=a:e!=u)&&(m|=Cl),new Is(f,m,p)}s+=d-c}return o?e+s:new Is(e+s,0,null)}touches(e,t){let o=0,s=xl(t),i=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+i],d=a+c;if(e<=d&&l==s*3)return!0;o+=this.ranges[l+r]-c}return!1}forEach(e){let t=this.inverted?2:1,o=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let r=this.ranges[s],l=r-(this.inverted?i:0),a=r+(this.inverted?0:i),c=this.ranges[s+t],d=this.ranges[s+o];e(l,l+c,a,a+d),i+=d-c}}invert(){return new fe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?fe.empty:new fe(e<0?[0,-e,0]:[0,0,e])}}fe.empty=new fe([]);class Zt{constructor(e=[],t,o=0,s=e.length){this.maps=e,this.mirror=t,this.from=o,this.to=s}slice(e=0,t=this.maps.length){return new Zt(this.maps,this.mirror,e,t)}copy(){return new Zt(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,o=this.maps.length;t<e.maps.length;t++){let s=e.getMirror(t);this.appendMap(e.maps[t],s!=null&&s<t?o+s: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,o=this.maps.length+e.maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e.maps[t].invert(),s!=null&&s>t?o-s-1:void 0)}}invert(){let e=new Zt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let o=this.from;o<this.to;o++)e=this.maps[o].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,o){let s=0;for(let i=this.from;i<this.to;i++){let r=this.maps[i],l=r.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this.maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return o?e:new Is(e,s,null)}}const Rs=Object.create(null);class te{getMap(){return fe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=Rs[t.stepType];if(!o)throw new RangeError(`No step type ${t.stepType} defined`);return o.fromJSON(e,t)}static jsonID(e,t){if(e in Rs)throw new RangeError("Duplicate use of step JSON ID "+e);return Rs[e]=t,t.prototype.jsonID=e,t}}class q{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new q(e,null)}static fail(e){return new q(null,e)}static fromReplace(e,t,o,s){try{return q.ok(e.replace(t,o,s))}catch(i){if(i instanceof yo)return q.fail(i.message);throw i}}}function Ds(n,e,t){let o=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy(Ds(i.content,e,i))),i.isInline&&(i=e(i,t,s)),o.push(i)}return k.fromArray(o)}class Je extends te{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=e.resolve(this.from),s=o.node(o.sharedDepth(this.to)),i=new M(Ds(t.content,(r,l)=>!r.isAtom||!l.type.allowsMarkType(this.mark.type)?r:r.mark(this.mark.addToSet(r.marks)),s),t.openStart,t.openEnd);return q.fromReplace(e,this.from,this.to,i)}invert(){return new Oe(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deleted&&o.deleted||t.pos>=o.pos?null:new Je(t.pos,o.pos,this.mark)}merge(e){return e instanceof Je&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Je(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 Je(t.from,t.to,e.markFromJSON(t.mark))}}te.jsonID("addMark",Je);class Oe extends te{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=new M(Ds(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return q.fromReplace(e,this.from,this.to,o)}invert(){return new Je(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deleted&&o.deleted||t.pos>=o.pos?null:new Oe(t.pos,o.pos,this.mark)}merge(e){return e instanceof Oe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Oe(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 Oe(t.from,t.to,e.markFromJSON(t.mark))}}te.jsonID("removeMark",Oe);class Ue extends te{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new M(k.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let o=this.mark.addToSet(t.marks);if(o.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(o))return new Ue(this.pos,t.marks[s]);return new Ue(this.pos,this.mark)}}return new Yt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ue(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 Ue(t.pos,e.markFromJSON(t.mark))}}te.jsonID("addNodeMark",Ue);class Yt extends te{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new M(k.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ue(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Yt(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 Yt(t.pos,e.markFromJSON(t.mark))}}te.jsonID("removeNodeMark",Yt);class ne extends te{constructor(e,t,o,s=!1){super(),this.from=e,this.to=t,this.slice=o,this.structure=s}apply(e){return this.structure&&zs(e,this.from,this.to)?q.fail("Structure replace would overwrite content"):q.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new fe([this.from,this.to-this.from,this.slice.size])}invert(e){return new ne(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return t.deletedAcross&&o.deletedAcross?null:new ne(t.pos,Math.max(t.pos,o.pos),this.slice)}merge(e){if(!(e instanceof ne)||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?M.empty:new M(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ne(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?M.empty:new M(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ne(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 ne(t.from,t.to,M.fromJSON(e,t.slice),!!t.structure)}}te.jsonID("replace",ne);class U extends te{constructor(e,t,o,s,i,r,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=s,this.slice=i,this.insert=r,this.structure=l}apply(e){if(this.structure&&(zs(e,this.from,this.gapFrom)||zs(e,this.gapTo,this.to)))return q.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return q.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,t.content);return o?q.fromReplace(e,this.from,this.to,o):q.fail("Content does not fit in gap")}getMap(){return new fe([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 U(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),o=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?o.pos:e.map(this.gapTo,1);return t.deletedAcross&&o.deletedAcross||s<t.pos||i>o.pos?null:new U(t.pos,o.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new U(t.from,t.to,t.gapFrom,t.gapTo,M.fromJSON(e,t.slice),t.insert,!!t.structure)}}te.jsonID("replaceAround",U);function zs(n,e,t){let o=n.resolve(e),s=t-e,i=o.depth;for(;s>0&&i>0&&o.indexAfter(i)==o.node(i).childCount;)i--,s--;if(s>0){let r=o.node(i).maybeChild(o.indexAfter(i));for(;s>0;){if(!r||r.isLeaf)return!0;r=r.firstChild,s--}}return!1}function jh(n,e,t,o){let s=[],i=[],r,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!o.isInSet(u)&&d.type.allowsMarkType(o.type)){let h=Math.max(c,e),f=Math.min(c+a.nodeSize,t),p=o.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(p)||(r&&r.to==h&&r.mark.eq(u[m])?r.to=f:s.push(r=new Oe(h,f,u[m])));l&&l.to==h?l.to=f:i.push(l=new Je(h,f,o))}}),s.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function Kh(n,e,t,o){let s=[],i=0;n.doc.nodesBetween(e,t,(r,l)=>{if(!r.isInline)return;i++;let a=null;if(o instanceof wo){let c=r.marks,d;for(;d=o.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else o?o.isInSet(r.marks)&&(a=[o]):a=r.marks;if(a&&a.length){let c=Math.min(l+r.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],h;for(let f=0;f<s.length;f++){let p=s[f];p.step==i-1&&u.eq(s[f].style)&&(h=p)}h?(h.to=c,h.step=i):s.push({style:u,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(r=>n.step(new Oe(r.from,r.to,r.style)))}function Ls(n,e,t,o=t.contentMatch,s=!0){let i=n.doc.nodeAt(e),r=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,u=o.matchType(c.type);if(!u)r.push(new ne(l,d,M.empty));else{o=u;for(let h=0;h<c.marks.length;h++)t.allowsMarkType(c.marks[h].type)||n.step(new Oe(l,d,c.marks[h]));if(s&&c.isText&&t.whitespace!="pre"){let h,f=/\r?\n|\r/g,p;for(;h=f.exec(c.text);)p||(p=new M(k.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),r.push(new ne(l+h.index,l+h.index+h[0].length,p))}}l=d}if(!o.validEnd){let a=o.fillBefore(k.empty,!0);n.replace(l,l,new M(a,0,0))}for(let a=r.length-1;a>=0;a--)n.step(r[a])}function Jh(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Ao(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth;;--o){let s=n.$from.node(o),i=n.$from.index(o),r=n.$to.indexAfter(o);if(o<n.depth&&s.canReplace(i,r,t))return o;if(o==0||s.type.spec.isolating||!Jh(s,i,r))break}return null}function Uh(n,e,t){let{$from:o,$to:s,depth:i}=e,r=o.before(i+1),l=s.after(i+1),a=r,c=l,d=k.empty,u=0;for(let p=i,m=!1;p>t;p--)m||o.index(p)>0?(m=!0,d=k.from(o.node(p).copy(d)),u++):a--;let h=k.empty,f=0;for(let p=i,m=!1;p>t;p--)m||s.after(p+1)<s.end(p)?(m=!0,h=k.from(s.node(p).copy(h)),f++):c++;n.step(new U(a,c,r,l,new M(d.append(h),u,f),d.size-u,!0))}function kl(n,e,t=null,o=n){let s=Zh(n,e),i=s&&Yh(o,e);return i?s.map(Tl).concat({type:e,attrs:t}).concat(i.map(Tl)):null}function Tl(n){return{type:n,attrs:null}}function Zh(n,e){let{parent:t,startIndex:o,endIndex:s}=n,i=t.contentMatchAt(o).findWrapping(e);if(!i)return null;let r=i.length?i[0]:e;return t.canReplaceWith(o,s,r)?i:null}function Yh(n,e){let{parent:t,startIndex:o,endIndex:s}=n,i=t.child(o),r=e.contentMatch.findWrapping(i.type);if(!r)return null;let a=(r.length?r[r.length-1]:e).contentMatch;for(let c=o;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:r}function Xh(n,e,t){let o=k.empty;for(let r=t.length-1;r>=0;r--){if(o.size){let l=t[r].type.contentMatch.matchFragment(o);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=k.from(t[r].type.create(t[r].attrs,o))}let s=e.start,i=e.end;n.step(new U(s,i,s,i,new M(o,0,0),t.length,!0))}function Qh(n,e,t,o,s){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(r,l)=>{let a=typeof s=="function"?s(r):s;if(r.isTextblock&&!r.hasMarkup(o,a)&&ef(n.doc,n.mapping.slice(i).map(l),o)){let c=null;if(o.schema.linebreakReplacement){let f=o.whitespace=="pre",p=!!o.contentMatch.matchType(o.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&Al(n,r,l,i),Ls(n,n.mapping.slice(i).map(l,1),o,void 0,c===null);let d=n.mapping.slice(i),u=d.map(l,1),h=d.map(l+r.nodeSize,1);return n.step(new U(u,h,u+1,h-1,new M(k.from(o.create(a,null,r.marks)),0,0),1,!0)),c===!0&&Ml(n,r,l,i),!1}})}function Ml(n,e,t,o){e.forEach((s,i)=>{if(s.isText){let r,l=/\r?\n|\r/g;for(;r=l.exec(s.text);){let a=n.mapping.slice(o).map(t+1+i+r.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Al(n,e,t,o){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let r=n.mapping.slice(o).map(t+1+i);n.replaceWith(r,r+1,e.type.schema.text(`
297
+ `))}})}function ef(n,e,t){let o=n.resolve(e),s=o.index();return o.parent.canReplaceWith(s,s+1,t)}function tf(n,e,t,o,s){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let r=t.create(o,null,s||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,r);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new U(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new M(k.from(r),0,0),1,!0))}function Xt(n,e,t=1,o){let s=n.resolve(e),i=s.depth-t,r=o&&o[o.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!r.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>i;c--,d--){let u=s.node(c),h=s.index(c);if(u.type.spec.isolating)return!1;let f=u.content.cutByIndex(h,u.childCount),p=o&&o[d+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let m=o&&o[d]||u;if(!u.canReplace(h+1,u.childCount)||!m.type.validContent(f))return!1}let l=s.indexAfter(i),a=o&&o[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function nf(n,e,t=1,o){let s=n.doc.resolve(e),i=k.empty,r=k.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){i=k.from(s.node(l).copy(i));let d=o&&o[c];r=k.from(d?d.type.create(d.attrs,r):s.node(l).copy(r))}n.step(new ne(e,e,new M(i.append(r),t,t),!0))}function Eo(n,e){let t=n.resolve(e),o=t.index();return sf(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function of(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:o}=n.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),r=i.type==o?n.type.schema.nodes.text:i.type;if(t=t.matchType(r),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function sf(n,e){return!!(n&&e&&!n.isLeaf&&of(n,e))}function rf(n,e,t){let o=null,{linebreakReplacement:s}=n.doc.type.schema,i=n.doc.resolve(e-t),r=i.node().type;if(s&&r.inlineContent){let d=r.whitespace=="pre",u=!!r.contentMatch.matchType(s);d&&!u?o=!1:!d&&u&&(o=!0)}let l=n.steps.length;if(o===!1){let d=n.doc.resolve(e+t);Al(n,d.node(),d.before(),l)}r.inlineContent&&Ls(n,e+t-1,r,i.node().contentMatchAt(i.index()),o==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new ne(c,a.map(e+t,-1),M.empty,!0)),o===!0){let d=n.doc.resolve(c);Ml(n,d.node(),d.before(),n.steps.length)}return n}function lf(n,e,t){let o=n.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),t))return e;if(o.parentOffset==0)for(let s=o.depth-1;s>=0;s--){let i=o.index(s);if(o.node(s).canReplaceWith(i,i,t))return o.before(s+1);if(i>0)return null}if(o.parentOffset==o.parent.content.size)for(let s=o.depth-1;s>=0;s--){let i=o.indexAfter(s);if(o.node(s).canReplaceWith(i,i,t))return o.after(s+1);if(i<o.node(s).childCount)return null}return null}function af(n,e,t){let o=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let i=0;i<t.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let r=o.depth;r>=0;r--){let l=r==o.depth?0:o.pos<=(o.start(r+1)+o.end(r+1))/2?-1:1,a=o.index(r)+(l>0?1:0),c=o.node(r),d=!1;if(i==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?o.pos:l<0?o.before(r+1):o.after(r+1)}return null}function Vs(n,e,t=e,o=M.empty){if(e==t&&!o.size)return null;let s=n.resolve(e),i=n.resolve(t);return El(s,i,o)?new ne(e,t,o):new cf(s,i,o).fit()}function El(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class cf{constructor(e,t,o){this.$from=e,this.$to=t,this.unplaced=o,this.frontier=[],this.placed=k.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=k.from(e.node(s).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,o=this.$from,s=this.close(e<0?this.$to:o.doc.resolve(e));if(!s)return null;let i=this.placed,r=o.depth,l=s.depth;for(;r&&l&&i.childCount==1;)i=i.firstChild.content,r--,l--;let a=new M(i,r,l);return e>-1?new U(o.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||o.pos!=this.$to.pos?new ne(o.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,o=0,s=this.unplaced.openEnd;o<e;o++){let i=t.firstChild;if(t.childCount>1&&(s=0),i.type.spec.isolating&&s<=o){e=o;break}t=i.content}for(let t=1;t<=2;t++)for(let o=t==1?e:this.unplaced.openStart;o>=0;o--){let s,i=null;o?(i=Bs(this.unplaced.content,o-1).firstChild,s=i.content):s=this.unplaced.content;let r=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(r?c.matchType(r.type)||(u=c.fillBefore(k.from(r),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:o,frontierDepth:l,parent:i,inject:u};if(t==2&&r&&(d=c.findWrapping(r.type)))return{sliceDepth:o,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:o}=this.unplaced,s=Bs(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new M(e,t+1,Math.max(o,s.size+t>=e.size-o?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:o}=this.unplaced,s=Bs(e,t);if(s.childCount<=1&&t>0){let i=e.size-t<=t+s.size;this.unplaced=new M(Sn(e,t-1,1),t-1,i?t-1:o)}else this.unplaced=new M(Sn(e,t,1),t,o)}placeNodes({sliceDepth:e,frontierDepth:t,parent:o,inject:s,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let r=this.unplaced,l=o?o.content:r.content,a=r.openStart-e,c=0,d=[],{match:u,type:h}=this.frontier[t];if(s){for(let m=0;m<s.childCount;m++)d.push(s.child(m));u=u.matchFragment(s)}let f=l.size+e-(r.content.size-r.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,d.push(Ol(m.mark(h.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=Cn(this.placed,t,k.from(d)),this.frontier[t].match=u,p&&f<0&&o&&o.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?M.empty:new M(Sn(r.content,e-1,1),e-1,f<0?r.openEnd:e-1):new M(Sn(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||!Hs(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:o}=this.$to,s=this.$to.after(o);for(;o>1&&s==this.$to.end(--o);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:o,type:s}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),r=Hs(e,t,s,o,i);if(r){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Hs(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:r,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Cn(this.placed,t.depth,t.fit)),e=t.move;for(let o=t.depth+1;o<=e.depth;o++){let s=e.node(o),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(o));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,t=null,o){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Cn(this.placed,this.depth,k.from(e.create(t,o))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(k.empty,!0);t.childCount&&(this.placed=Cn(this.placed,this.frontier.length,t))}}function Sn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Sn(n.firstChild.content,e-1,t)))}function Cn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Cn(n.lastChild.content,e-1,t)))}function Bs(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Ol(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,Ol(o.firstChild,e-1,o.childCount==1?t-1:0))),e>0&&(o=n.type.contentMatch.fillBefore(o).append(o),t<=0&&(o=o.append(n.type.contentMatch.matchFragment(o).fillBefore(k.empty,!0)))),n.copy(o)}function Hs(n,e,t,o,s){let i=n.node(e),r=s?n.indexAfter(e):n.index(e);if(r==i.childCount&&!t.compatibleContent(i.type))return null;let l=o.fillBefore(i.content,!0,r);return l&&!df(t,i.content,r)?l:null}function df(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function uf(n){return n.spec.defining||n.spec.definingForContent}function hf(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),i=n.doc.resolve(t);if(El(s,i,o))return n.step(new ne(e,t,o));let r=Pl(s,n.doc.resolve(t));r[r.length-1]==0&&r.pop();let l=-(s.depth+1);r.unshift(l);for(let h=s.depth,f=s.pos-1;h>0;h--,f--){let p=s.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;r.indexOf(h)>-1?l=h:s.before(h)==f&&r.splice(1,0,-h)}let a=r.indexOf(l),c=[],d=o.openStart;for(let h=o.content,f=0;;f++){let p=h.firstChild;if(c.push(p),f==o.openStart)break;h=p.content}for(let h=d-1;h>=0;h--){let f=c[h],p=uf(f.type);if(p&&!f.sameMarkup(s.node(Math.abs(l)-1)))d=h;else if(p||!f.type.isTextblock)break}for(let h=o.openStart;h>=0;h--){let f=(h+d+1)%(o.openStart+1),p=c[f];if(p)for(let m=0;m<r.length;m++){let g=r[(m+a)%r.length],y=!0;g<0&&(y=!1,g=-g);let S=s.node(g-1),b=s.index(g-1);if(S.canReplaceWith(b,b,p.type,p.marks))return n.replace(s.before(g),y?i.after(g):t,new M(Nl(o.content,0,o.openStart,f),f,o.openEnd))}}let u=n.steps.length;for(let h=r.length-1;h>=0&&(n.replace(e,t,o),!(n.steps.length>u));h--){let f=r[h];f<0||(e=s.before(f),t=i.after(f))}}function Nl(n,e,t,o,s){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(Nl(i.content,e+1,t,o,i)))}if(e>o){let i=s.contentMatchAt(0),r=i.fillBefore(n).append(n);n=r.append(i.matchFragment(r).fillBefore(k.empty,!0))}return n}function ff(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=lf(n.doc,e,o.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new M(k.from(o),0,0))}function pf(n,e,t){let o=n.doc.resolve(e),s=n.doc.resolve(t),i=Pl(o,s);for(let r=0;r<i.length;r++){let l=i[r],a=r==i.length-1;if(a&&l==0||o.node(l).type.contentMatch.validEnd)return n.delete(o.start(l),s.end(l));if(l>0&&(a||o.node(l-1).canReplace(o.index(l-1),s.indexAfter(l-1))))return n.delete(o.before(l),s.after(l))}for(let r=1;r<=o.depth&&r<=s.depth;r++)if(e-o.start(r)==o.depth-r&&t>o.end(r)&&s.end(r)-t!=s.depth-r&&o.start(r-1)==s.start(r-1)&&o.node(r-1).canReplace(o.index(r-1),s.index(r-1)))return n.delete(o.before(r),t);n.delete(e,t)}function Pl(n,e){let t=[],o=Math.min(n.depth,e.depth);for(let s=o;s>=0;s--){let i=n.start(s);if(i<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&t.push(s)}return t}class Qt extends te{constructor(e,t,o){super(),this.pos=e,this.attr=t,this.value=o}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at attribute step's position");let o=Object.create(null);for(let i in t.attrs)o[i]=t.attrs[i];o[this.attr]=this.value;let s=t.type.create(o,null,t.marks);return q.fromReplace(e,this.pos,this.pos+1,new M(k.from(s),0,t.isLeaf?0:1))}getMap(){return fe.empty}invert(e){return new Qt(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 Qt(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 Qt(t.pos,t.attr,t.value)}}te.jsonID("attr",Qt);class kn extends te{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let o=e.type.create(t,e.content,e.marks);return q.ok(o)}getMap(){return fe.empty}invert(e){return new kn(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 kn(t.attr,t.value)}}te.jsonID("docAttr",kn);let en=class extends Error{};en=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},en.prototype=Object.create(Error.prototype),en.prototype.constructor=en,en.prototype.name="TransformError";class Il{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Zt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new en(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,o=M.empty){let s=Vs(this.doc,e,t,o);return s&&this.step(s),this}replaceWith(e,t,o){return this.replace(e,t,new M(k.from(o),0,0))}delete(e,t){return this.replace(e,t,M.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,o){return hf(this,e,t,o),this}replaceRangeWith(e,t,o){return ff(this,e,t,o),this}deleteRange(e,t){return pf(this,e,t),this}lift(e,t){return Uh(this,e,t),this}join(e,t=1){return rf(this,e,t),this}wrap(e,t){return Xh(this,e,t),this}setBlockType(e,t=e,o,s=null){return Qh(this,e,t,o,s),this}setNodeMarkup(e,t,o=null,s){return tf(this,e,t,o,s),this}setNodeAttribute(e,t,o){return this.step(new Qt(e,t,o)),this}setDocAttribute(e,t){return this.step(new kn(e,t)),this}addNodeMark(e,t){return this.step(new Ue(e,t)),this}removeNodeMark(e,t){if(!(t instanceof V)){let o=this.doc.nodeAt(e);if(!o)throw new RangeError("No node at position "+e);if(t=t.isInSet(o.marks),!t)return this}return this.step(new Yt(e,t)),this}split(e,t=1,o){return nf(this,e,t,o),this}addMark(e,t,o){return jh(this,e,t,o),this}removeMark(e,t,o){return Kh(this,e,t,o),this}clearIncompatible(e,t,o){return Ls(this,e,t,o),this}}const $s=Object.create(null);class I{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new Rl(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=M.empty){let o=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=o,o=o.lastChild;let i=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(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?M.empty:t),l==0&&Ll(e,i,(o?o.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let o=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:r,$to:l}=s[i],a=e.mapping.slice(o),c=a.map(r.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),Ll(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let s=e.parent.inlineContent?new R(e):tn(e.node(0),e.parent,e.pos,e.index(),t,o);if(s)return s;for(let i=e.depth-1;i>=0;i--){let r=t<0?tn(e.node(0),e.node(i),e.before(i+1),e.index(i),t,o):tn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,o);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new pe(e.node(0))}static atStart(e){return tn(e,e,0,0,1)||new pe(e)}static atEnd(e){return tn(e,e,e.content.size,e.childCount,-1)||new pe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let o=$s[t.type];if(!o)throw new RangeError(`No selection type ${t.type} defined`);return o.fromJSON(e,t)}static jsonID(e,t){if(e in $s)throw new RangeError("Duplicate use of selection JSON ID "+e);return $s[e]=t,t.prototype.jsonID=e,t}getBookmark(){return R.between(this.$anchor,this.$head).getBookmark()}}I.prototype.visible=!0;class Rl{constructor(e,t){this.$from=e,this.$to=t}}let Dl=!1;function zl(n){!Dl&&!n.parent.inlineContent&&(Dl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class R extends I{constructor(e,t=e){zl(e),zl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let o=e.resolve(t.map(this.head));if(!o.parent.inlineContent)return I.near(o);let s=e.resolve(t.map(this.anchor));return new R(s.parent.inlineContent?s:o,o)}replace(e,t=M.empty){if(super.replace(e,t),t==M.empty){let o=this.$from.marksAcross(this.$to);o&&e.ensureMarks(o)}}eq(e){return e instanceof R&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Oo(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 R(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){let s=e.resolve(t);return new this(s,o==t?s:e.resolve(o))}static between(e,t,o){let s=e.pos-t.pos;if((!o||s)&&(o=s>=0?1:-1),!t.parent.inlineContent){let i=I.findFrom(t,o,!0)||I.findFrom(t,-o,!0);if(i)t=i.$head;else return I.near(t,o)}return e.parent.inlineContent||(s==0?e=t:(e=(I.findFrom(e,-o,!0)||I.findFrom(e,o,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new R(e,t)}}I.jsonID("text",R);class Oo{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Oo(e.map(this.anchor),e.map(this.head))}resolve(e){return R.between(e.resolve(this.anchor),e.resolve(this.head))}}class N extends I{constructor(e){let t=e.nodeAfter,o=e.node(0).resolve(e.pos+t.nodeSize);super(e,o),this.node=t}map(e,t){let{deleted:o,pos:s}=t.mapResult(this.anchor),i=e.resolve(s);return o?I.near(i):new N(i)}content(){return new M(k.from(this.node),0,0)}eq(e){return e instanceof N&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Fs(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new N(e.resolve(t.anchor))}static create(e,t){return new N(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}N.prototype.visible=!1,I.jsonID("node",N);class Fs{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new Oo(o,o):new Fs(o)}resolve(e){let t=e.resolve(this.anchor),o=t.nodeAfter;return o&&N.isSelectable(o)?new N(t):I.near(t)}}class pe extends I{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=M.empty){if(t==M.empty){e.delete(0,e.doc.content.size);let o=I.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new pe(e)}map(e){return new pe(e)}eq(e){return e instanceof pe}getBookmark(){return mf}}I.jsonID("all",pe);const mf={map(){return this},resolve(n){return new pe(n)}};function tn(n,e,t,o,s,i=!1){if(e.inlineContent)return R.create(n,t);for(let r=o-(s>0?0:1);s>0?r<e.childCount:r>=0;r+=s){let l=e.child(r);if(l.isAtom){if(!i&&N.isSelectable(l))return N.create(n,t-(s<0?l.nodeSize:0))}else{let a=tn(n,l,t+s,s<0?l.childCount:0,s,i);if(a)return a}t+=l.nodeSize*s}return null}function Ll(n,e,t){let o=n.steps.length-1;if(o<e)return;let s=n.steps[o];if(!(s instanceof ne||s instanceof U))return;let i=n.mapping.maps[o],r;i.forEach((l,a,c,d)=>{r==null&&(r=d)}),n.setSelection(I.near(n.doc.resolve(r),t))}const Vl=1,No=2,Bl=4;class gf extends Il{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|Vl)&~No,this.storedMarks=null,this}get selectionSet(){return(this.updated&Vl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=No,this}ensureMarks(e){return V.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&No)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~No,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let o=this.selection;return t&&(e=e.mark(this.storedMarks||(o.empty?o.$from.marks():o.$from.marksAcross(o.$to)||V.none))),o.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,o){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(o==null&&(o=t),o=o??t,!e)return this.deleteRange(t,o);let i=this.storedMarks;if(!i){let r=this.doc.resolve(t);i=o==t?r.marks():r.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(t,o,s.text(e,i)),this.selection.empty||this.setSelection(I.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Bl,this}get scrolledIntoView(){return(this.updated&Bl)>0}}function Hl(n,e){return!e||!n?n:n.bind(e)}class Tn{constructor(e,t,o){this.name=e,this.init=Hl(t.init,o),this.apply=Hl(t.apply,o)}}const yf=[new Tn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Tn("selection",{init(n,e){return n.selection||I.atStart(e.doc)},apply(n){return n.selection}}),new Tn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new Tn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class _s{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=yf.slice(),t&&t.forEach(o=>{if(this.pluginsByKey[o.key])throw new RangeError("Adding different instances of a keyed plugin ("+o.key+")");this.plugins.push(o),this.pluginsByKey[o.key]=o,o.spec.state&&this.fields.push(new Tn(o.key,o.spec.state,o))})}}class nn{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 o=0;o<this.config.plugins.length;o++)if(o!=t){let s=this.config.plugins[o];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],o=this.applyInner(e),s=null;for(;;){let i=!1;for(let r=0;r<this.config.plugins.length;r++){let l=this.config.plugins[r];if(l.spec.appendTransaction){let a=s?s[r].n:0,c=s?s[r].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,o);if(d&&o.filterTransaction(d,r)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<r?{state:o,n:t.length}:{state:this,n:0})}t.push(d),o=o.applyInner(d),i=!0}s&&(s[r]={state:o,n:t.length})}}if(!i)return{state:o,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new nn(this.config),o=this.config.fields;for(let s=0;s<o.length;s++){let i=o[s];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new gf(this)}static create(e){let t=new _s(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new nn(t);for(let s=0;s<t.fields.length;s++)o[t.fields[s].name]=t.fields[s].init(e,o);return o}reconfigure(e){let t=new _s(this.schema,e.plugins),o=t.fields,s=new nn(t);for(let i=0;i<o.length;i++){let r=o[i].name;s[r]=this.hasOwnProperty(r)?this[r]:o[i].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(o=>o.toJSON())),e&&typeof e=="object")for(let o in e){if(o=="doc"||o=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[o],i=s.spec.state;i&&i.toJSON&&(t[o]=i.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,o){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new _s(e.schema,e.plugins),i=new nn(s);return s.fields.forEach(r=>{if(r.name=="doc")i.doc=xt.fromJSON(e.schema,t.doc);else if(r.name=="selection")i.selection=I.fromJSON(i.doc,t.selection);else if(r.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(o)for(let l in o){let a=o[l],c=a.spec.state;if(a.key==r.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[r.name]=c.fromJSON.call(a,e,t[l],i);return}}i[r.name]=r.init(e,i)}}),i}}function $l(n,e,t){for(let o in n){let s=n[o];s instanceof Function?s=s.bind(e):o=="handleDOMEvents"&&(s=$l(s,e,{})),t[o]=s}return t}class Mn{constructor(e){this.spec=e,this.props={},e.props&&$l(e.props,this,this.props),this.key=e.key?e.key.key:Fl("plugin")}getState(e){return e[this.key]}}const Ws=Object.create(null);function Fl(n){return n in Ws?n+"$"+ ++Ws[n]:(Ws[n]=0,n+"$")}class An{constructor(e="key"){this.key=Fl(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const _l=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function bf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const vf=(n,e,t)=>{let o=bf(n,t);if(!o)return!1;let s=Wl(o);if(!s){let r=o.blockRange(),l=r&&Ao(r);return l==null?!1:(e&&e(n.tr.lift(r,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(Ul(n,s,e,-1))return!0;if(o.parent.content.size==0&&(on(i,"end")||N.isSelectable(i)))for(let r=o.depth;;r--){let l=Vs(n.doc,o.before(r),o.after(r),M.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(on(i,"end")?I.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):N.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(r==1||o.node(r-1).childCount>1)break}return i.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1};function on(n,e,t=!1){for(let o=n;o;o=e=="start"?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(t&&o.childCount!=1)return!1}return!1}const xf=(n,e,t)=>{let{$head:o,empty:s}=n.selection,i=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):o.parentOffset>0)return!1;i=Wl(o)}let r=i&&i.nodeBefore;return!r||!N.isSelectable(r)?!1:(e&&e(n.tr.setSelection(N.create(n.doc,i.pos-r.nodeSize)).scrollIntoView()),!0)};function Wl(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 wf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Sf=(n,e,t)=>{let o=wf(n,t);if(!o)return!1;let s=ql(o);if(!s)return!1;let i=s.nodeAfter;if(Ul(n,s,e,1))return!0;if(o.parent.content.size==0&&(on(i,"start")||N.isSelectable(i))){let r=Vs(n.doc,o.before(),o.after(),M.empty);if(r&&r.slice.size<r.to-r.from){if(e){let l=n.tr.step(r);l.setSelection(on(i,"start")?I.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):N.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},Cf=(n,e,t)=>{let{$head:o,empty:s}=n.selection,i=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):o.parentOffset<o.parent.content.size)return!1;i=ql(o)}let r=i&&i.nodeAfter;return!r||!N.isSelectable(r)?!1:(e&&e(n.tr.setSelection(N.create(n.doc,i.pos)).scrollIntoView()),!0)};function ql(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 kf=(n,e)=>{let{$head:t,$anchor:o}=n.selection;return!t.parent.type.spec.code||!t.sameParent(o)?!1:(e&&e(n.tr.insertText(`
298
+ `).scrollIntoView()),!0)};function qs(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 Gl=(n,e)=>{let{$head:t,$anchor:o}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(o))return!1;let s=t.node(-1),i=t.indexAfter(-1),r=qs(s.contentMatchAt(i));if(!r||!s.canReplaceWith(i,i,r))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,r.createAndFill());a.setSelection(I.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Tf=(n,e)=>{let t=n.selection,{$from:o,$to:s}=t;if(t instanceof pe||o.parent.inlineContent||s.parent.inlineContent)return!1;let i=qs(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let r=(!o.parentOffset&&s.index()<s.parent.childCount?o:s).pos,l=n.tr.insert(r,i.createAndFill());l.setSelection(R.create(l.doc,r+1)),e(l.scrollIntoView())}return!0},jl=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(Xt(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let o=t.blockRange(),s=o&&Ao(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)};function Kl(n){return(e,t)=>{let{$from:o,$to:s}=e.selection;if(e.selection instanceof N&&e.selection.node.isBlock)return!o.parentOffset||!Xt(e.doc,o.pos)?!1:(t&&t(e.tr.split(o.pos).scrollIntoView()),!0);if(!o.depth)return!1;let i=[],r,l,a=!1,c=!1;for(let f=o.depth;;f--)if(o.node(f).isBlock){a=o.end(f)==o.pos+(o.depth-f),c=o.start(f)==o.pos-(o.depth-f),l=qs(o.node(f-1).contentMatchAt(o.indexAfter(f-1)));let m=n&&n(s.parent,a,o);i.unshift(m||(a&&l?{type:l}:null)),r=f;break}else{if(f==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof R||e.selection instanceof pe)&&d.deleteSelection();let u=d.mapping.map(o.pos),h=Xt(d.doc,u,i.length,i);if(h||(i[0]=l?{type:l}:null,h=Xt(d.doc,u,i.length,i)),d.split(u,i.length,i),!a&&c&&o.node(r).type!=l){let f=d.mapping.map(o.before(r)),p=d.doc.resolve(f);l&&o.node(r-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(o.before(r)),l)}return t&&t(d.scrollIntoView()),!0}}const Mf=Kl(),Jl=(n,e)=>(e&&e(n.tr.setSelection(new pe(n.doc))),!0);function Af(n,e,t){let o=e.nodeBefore,s=e.nodeAfter,i=e.index();return!o||!s||!o.type.compatibleContent(s.type)?!1:!o.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||Eo(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Ul(n,e,t,o){let s=e.nodeBefore,i=e.nodeAfter,r,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&Af(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(r=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(r[0]||i.type).validEnd){if(t){let f=e.pos+i.nodeSize,p=k.empty;for(let y=r.length-1;y>=0;y--)p=k.from(r[y].create(null,p));p=k.from(s.copy(p));let m=n.tr.step(new U(e.pos-1,f,e.pos,f,new M(p,1,0),r.length,!0)),g=m.doc.resolve(f+2*r.length);g.nodeAfter&&g.nodeAfter.type==s.type&&Eo(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||o>0&&a?null:I.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),h=u&&Ao(u);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&on(i,"start",!0)&&on(s,"end")){let f=s,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(t){let y=k.empty;for(let b=p.length-1;b>=0;b--)y=k.from(p[b].copy(y));let S=n.tr.step(new U(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new M(y,p.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function Zl(n){return function(e,t){let o=e.selection,s=n<0?o.$from:o.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(t&&t(e.tr.setSelection(R.create(e.doc,n<0?s.start(i):s.end(i)))),!0):!1}}const Ef=Zl(-1),Of=Zl(1);function Nf(n,e=null){return function(t,o){let s=!1;for(let i=0;i<t.selection.ranges.length&&!s;i++){let{$from:{pos:r},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(r,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let d=t.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,n)}})}if(!s)return!1;if(o){let i=t.tr;for(let r=0;r<t.selection.ranges.length;r++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[r];i.setBlockType(l,a,n,e)}o(i.scrollIntoView())}return!0}}function Pf(n,e,t,o){for(let s=0;s<e.length;s++){let{$from:i,$to:r}=e[s],l=i.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(i.pos,r.pos,(a,c)=>{if(l||!o)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function Ct(n,e=null,t){let o=t!==!1;return function(s,i){let{empty:r,$cursor:l,ranges:a}=s.selection;if(r&&!l||!Pf(s.doc,a,n,o))return!1;if(i)if(l)n.isInSet(s.storedMarks||l.marks())?i(s.tr.removeStoredMark(n)):i(s.tr.addStoredMark(n.create(e)));else{let c,d=s.tr;c=!a.some(u=>s.doc.rangeHasMark(u.$from.pos,u.$to.pos,n));for(let u=0;u<a.length;u++){let{$from:h,$to:f}=a[u];if(!c)d.removeMark(h.pos,f.pos,n);else{let p=h.pos,m=f.pos,g=h.nodeAfter,y=f.nodeBefore,S=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,b=y&&y.isText?/\s*$/.exec(y.text)[0].length:0;p+S<m&&(p+=S,m-=b),d.addMark(p,m,n.create(e))}}i(d.scrollIntoView())}return!0}}function En(...n){return function(e,t,o){for(let s=0;s<n.length;s++)if(n[s](e,t,o))return!0;return!1}}let Gs=En(_l,vf,xf),Yl=En(_l,Sf,Cf);const Ve={Enter:En(kf,Tf,jl,Mf),"Mod-Enter":Gl,Backspace:Gs,"Mod-Backspace":Gs,"Shift-Backspace":Gs,Delete:Yl,"Mod-Delete":Yl,"Mod-a":Jl},Xl={"Ctrl-h":Ve.Backspace,"Alt-Backspace":Ve["Mod-Backspace"],"Ctrl-d":Ve.Delete,"Ctrl-Alt-Backspace":Ve["Mod-Delete"],"Alt-Delete":Ve["Mod-Delete"],"Alt-d":Ve["Mod-Delete"],"Ctrl-a":Ef,"Ctrl-e":Of};for(let n in Ve)Xl[n]=Ve[n];const If=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?Xl:Ve;var Po=200,j=function(){};j.prototype.append=function(e){return e.length?(e=j.from(e),!this.length&&e||e.length<Po&&this.leafAppend(e)||this.length<Po&&e.leafPrepend(this)||this.appendInner(e)):this},j.prototype.prepend=function(e){return e.length?j.from(e).append(this):this},j.prototype.appendInner=function(e){return new Rf(this,e)},j.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?j.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},j.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},j.prototype.forEach=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length),t<=o?this.forEachInner(e,t,o,0):this.forEachInvertedInner(e,t,o,0)},j.prototype.map=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length);var s=[];return this.forEach(function(i,r){return s.push(e(i,r))},t,o),s},j.from=function(e){return e instanceof j?e:e&&e.length?new Ql(e):j.empty};var Ql=function(n){function e(o){n.call(this),this.values=o}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(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,r,l){for(var a=i;a<r;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,r,l){for(var a=i-1;a>=r;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Po)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Po)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(j);j.empty=new Ql([]);var Rf=function(n){function e(t,o){n.call(this),this.left=t,this.right=o,this.length=t.length+o.length,this.depth=Math.max(t.depth,o.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(o){return o<this.left.length?this.left.get(o):this.right.get(o-this.left.length)},e.prototype.forEachInner=function(o,s,i,r){var l=this.left.length;if(s<l&&this.left.forEachInner(o,s,Math.min(i,l),r)===!1||i>l&&this.right.forEachInner(o,Math.max(s-l,0),Math.min(this.length,i)-l,r+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,i,r){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(o,s-l,Math.max(i,l)-l,r+l)===!1||i<l&&this.left.forEachInvertedInner(o,Math.min(s,l),i,r)===!1)return!1},e.prototype.sliceInner=function(o,s){if(o==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(o,s):o>=i?this.right.slice(o-i,s-i):this.left.slice(o,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(o){var s=this.right.leafAppend(o);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(o){var s=this.left.leafPrepend(o);if(s)return new e(s,this.right)},e.prototype.appendInner=function(o){return this.left.depth>=Math.max(this.right.depth,o.depth)+1?new e(this.left,new e(this.right,o)):new e(this,o)},e}(j);const Df=500;class we{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}let s,i;t&&(s=this.remapping(o,this.items.length),i=s.maps.length);let r=e.tr,l,a,c=[],d=[];return this.items.forEach((u,h)=>{if(!u.step){s||(s=this.remapping(o,h+1),i=s.maps.length),i--,d.push(u);return}if(s){d.push(new Ne(u.map));let f=u.step.map(s.slice(i)),p;f&&r.maybeStep(f).doc&&(p=r.mapping.maps[r.mapping.maps.length-1],c.push(new Ne(p,void 0,void 0,c.length+d.length))),i--,p&&s.appendMap(p,i)}else r.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(i)):u.selection,a=new we(this.items.slice(0,o).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:r,selection:l}}addTransform(e,t,o,s){let i=[],r=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),h=new Ne(e.mapping.maps[d],u,t),f;(f=a&&a.merge(h))&&(h=f,d?i.pop():l=l.slice(0,l.length-1)),i.push(h),t&&(r++,t=void 0),s||(a=h)}let c=r-o.depth;return c>Lf&&(l=zf(l,c),r-=c),new we(l.append(i),r)}remapping(e,t){let o=new Zt;return this.items.forEach((s,i)=>{let r=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?o.maps.length-s.mirrorOffset:void 0;o.appendMap(s.map,r)},e,t),o}addMaps(e){return this.eventCount==0?this:new we(this.items.append(e.map(t=>new Ne(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],s=Math.max(0,this.items.length-t),i=e.mapping,r=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},s);let a=t;this.items.forEach(h=>{let f=i.getMirror(--a);if(f==null)return;r=Math.min(r,f);let p=i.maps[f];if(h.step){let m=e.steps[f].invert(e.docs[f]),g=h.selection&&h.selection.map(i.slice(a+1,f));g&&l++,o.push(new Ne(p,m,g))}else o.push(new Ne(p))},s);let c=[];for(let h=t;h<r;h++)c.push(new Ne(i.maps[h]));let d=this.items.slice(0,s).append(c).append(o),u=new we(d,l);return u.emptyItemCount()>Df&&(u=u.compress(this.items.length-o.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),o=t.maps.length,s=[],i=0;return this.items.forEach((r,l)=>{if(l>=e)s.push(r),r.selection&&i++;else if(r.step){let a=r.step.map(t.slice(o)),c=a&&a.getMap();if(o--,c&&t.appendMap(c,o),a){let d=r.selection&&r.selection.map(t.slice(o));d&&i++;let u=new Ne(c.invert(),a,d),h,f=s.length-1;(h=s.length&&s[f].merge(u))?s[f]=h:s.push(u)}}else r.map&&o--},this.items.length,0),new we(j.from(s.reverse()),i)}}we.empty=new we(j.empty,0);function zf(n,e){let t;return n.forEach((o,s)=>{if(o.selection&&e--==0)return t=s,!1}),n.slice(t)}class Ne{constructor(e,t,o,s){this.map=e,this.step=t,this.selection=o,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Ne(t.getMap().invert(),t,this.selection)}}}class Ze{constructor(e,t,o,s,i){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=s,this.prevComposition=i}}const Lf=20;function Vf(n,e,t,o){let s=t.getMeta(kt),i;if(s)return s.historyState;t.getMeta($f)&&(n=new Ze(n.done,n.undone,null,0,-1));let r=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(r&&r.getMeta(kt))return r.getMeta(kt).redo?new Ze(n.done.addTransform(t,void 0,o,Io(e)),n.undone,ea(t.mapping.maps),n.prevTime,n.prevComposition):new Ze(n.done,n.undone.addTransform(t,void 0,o,Io(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)-o.newGroupDelay||!Bf(t,n.prevRanges)),c=r?js(n.prevRanges,t.mapping):ea(t.mapping.maps);return new Ze(n.done.addTransform(t,a?e.selection.getBookmark():void 0,o,Io(e)),we.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new Ze(n.done.rebased(t,i),n.undone.rebased(t,i),js(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Ze(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),js(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Bf(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((o,s)=>{for(let i=0;i<e.length;i+=2)o<=e[i+1]&&s>=e[i]&&(t=!0)}),t}function ea(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,s,i,r)=>e.push(i,r));return e}function js(n,e){if(!n)return null;let t=[];for(let o=0;o<n.length;o+=2){let s=e.map(n[o],1),i=e.map(n[o+1],-1);s<=i&&t.push(s,i)}return t}function Hf(n,e,t){let o=Io(e),s=kt.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,o);if(!i)return null;let r=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),s,o),a=new Ze(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(r).setMeta(kt,{redo:t,historyState:a})}let Ks=!1,ta=null;function Io(n){let e=n.plugins;if(ta!=e){Ks=!1,ta=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ks=!0;break}}return Ks}const kt=new An("history"),$f=new An("closeHistory");function Ff(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Mn({key:kt,state:{init(){return new Ze(we.empty,we.empty,null,0,-1)},apply(e,t,o){return Vf(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,s=o=="historyUndo"?oa:o=="historyRedo"?Js:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function na(n,e){return(t,o)=>{let s=kt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(o){let i=Hf(s,t,n);i&&o(e?i.scrollIntoView():i)}return!0}}const oa=na(!1,!0),Js=na(!0,!0);for(var Ye={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:"'"},Ro={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},_f=typeof navigator<"u"&&/Mac/.test(navigator.platform),Wf=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Z=0;Z<10;Z++)Ye[48+Z]=Ye[96+Z]=String(Z);for(var Z=1;Z<=24;Z++)Ye[Z+111]="F"+Z;for(var Z=65;Z<=90;Z++)Ye[Z]=String.fromCharCode(Z+32),Ro[Z]=String.fromCharCode(Z);for(var Us in Ye)Ro.hasOwnProperty(Us)||(Ro[Us]=Ye[Us]);function qf(n){var e=_f&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Wf&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Ro:Ye)[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 Gf=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function jf(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let o,s,i,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))o=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Gf?r=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return o&&(t="Alt-"+t),s&&(t="Ctrl-"+t),r&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function Kf(n){let e=Object.create(null);for(let t in n)e[jf(t)]=n[t];return e}function Zs(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 Ys(n){return new Mn({props:{handleKeyDown:sa(n)}})}function sa(n){let e=Kf(n);return function(t,o){let s=qf(o),i,r=e[Zs(s,o)];if(r&&r(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(o.shiftKey){let l=e[Zs(s,o,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((o.shiftKey||o.altKey||o.metaKey||s.charCodeAt(0)>127)&&(i=Ye[o.keyCode])&&i!=s){let l=e[Zs(i,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function ia(n,e=null){return function(t,o){let{$from:s,$to:i}=t.selection,r=s.blockRange(i),l=!1,a=r;if(!r)return!1;if(r.depth>=2&&s.node(r.depth-1).type.compatibleContent(n)&&r.startIndex==0){if(s.index(r.depth-1)==0)return!1;let d=t.doc.resolve(r.start-2);a=new vo(d,d,r.depth),r.endIndex<r.parent.childCount&&(r=new vo(s,t.doc.resolve(i.end(r.depth)),r.depth)),l=!0}let c=kl(a,n,e,r);return c?(o&&o(Jf(t.tr,r,c,l,n).scrollIntoView()),!0):!1}}function Jf(n,e,t,o,s){let i=k.empty;for(let d=t.length-1;d>=0;d--)i=k.from(t[d].type.create(t[d].attrs,i));n.step(new U(e.start-(o?2:0),e.end,e.start,e.end,new M(i,0,0),t.length,!0));let r=0;for(let d=0;d<t.length;d++)t[d].type==s&&(r=d+1);let l=t.length-r,a=e.start+t.length-(o?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,h=!0;d<u;d++,h=!1)!h&&Xt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function Uf(n,e){return function(t,o){let{$from:s,$to:i,node:r}=t.selection;if(r&&r.isBlock||s.depth<2||!s.sameParent(i))return!1;let l=s.node(-1);if(l.type!=n)return!1;if(s.parent.content.size==0&&s.node(-1).childCount==s.indexAfter(-1)){if(s.depth==3||s.node(-3).type!=n||s.index(-2)!=s.node(-2).childCount-1)return!1;if(o){let u=k.empty,h=s.index(-1)?1:s.index(-2)?2:3;for(let y=s.depth-h;y>=s.depth-3;y--)u=k.from(s.node(y).copy(u));let f=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3;u=u.append(k.from(n.createAndFill()));let p=s.before(s.depth-(h-1)),m=t.tr.replace(p,s.after(-f),new M(u,4-h,0)),g=-1;m.doc.nodesBetween(p,m.doc.content.size,(y,S)=>{if(g>-1)return!1;y.isTextblock&&y.content.size==0&&(g=S+1)}),g>-1&&m.setSelection(I.near(m.doc.resolve(g))),o(m.scrollIntoView())}return!0}let a=i.pos==s.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(s.pos,i.pos),d=a?[null,{type:a}]:void 0;return Xt(c.doc,s.pos,2,d)?(o&&o(c.split(s.pos,2,d).scrollIntoView()),!0):!1}}function Xs(n){return function(e,t){let{$from:o,$to:s}=e.selection,i=o.blockRange(s,r=>r.childCount>0&&r.firstChild.type==n);return i?t?o.node(i.depth-1).type==n?Zf(e,t,n,i):Yf(e,t,i):!0:!1}}function Zf(n,e,t,o){let s=n.tr,i=o.end,r=o.$to.end(o.depth);i<r&&(s.step(new U(i-1,r,i,r,new M(k.from(t.create(null,o.parent.copy())),1,0),1,!0)),o=new vo(s.doc.resolve(o.$from.pos),s.doc.resolve(r),o.depth));const l=Ao(o);if(l==null)return!1;s.lift(o,l);let a=s.mapping.map(i,-1)-1;return Eo(s.doc,a)&&s.join(a),e(s.scrollIntoView()),!0}function Yf(n,e,t){let o=n.tr,s=t.parent;for(let f=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)f-=s.child(p).nodeSize,o.delete(f-1,f+1);let i=o.doc.resolve(t.start),r=i.nodeAfter;if(o.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,r.content.append(a?k.empty:k.from(s))))return!1;let u=i.pos,h=u+r.nodeSize;return o.step(new U(u-(l?1:0),h+(a?1:0),u+1,h-1,new M((l?k.empty:k.from(s.copy(k.empty))).append(a?k.empty:k.from(s.copy(k.empty))),l?0:1,a?0:1),l?0:1)),e(o.scrollIntoView()),!0}function Xf(n){return function(e,t){let{$from:o,$to:s}=e.selection,i=o.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let r=i.startIndex;if(r==0)return!1;let l=i.parent,a=l.child(r-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=k.from(c?n.create():null),u=new M(k.from(n.create(null,k.from(l.type.create(null,d)))),c?3:1,0),h=i.start,f=i.end;t(e.tr.step(new U(h-(c?3:1),f,h,f,u,1,!0)).scrollIntoView())}return!0}}const Y=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},On=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Qs=null;const Be=function(n,e,t){let o=Qs||(Qs=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o},Qf=function(){Qs=null},Tt=function(n,e,t,o){return t&&(ra(n,e,t,o,-1)||ra(n,e,t,o,1))},ep=/^(img|br|input|textarea|hr)$/i;function ra(n,e,t,o,s){for(;;){if(n==t&&e==o)return!0;if(e==(s<0?0:ge(n))){let i=n.parentNode;if(!i||i.nodeType!=1||Nn(n)||ep.test(n.nodeName)||n.contentEditable=="false")return!1;e=Y(n)+(s<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.contentEditable=="false")return!1;e=s<0?ge(n):0}else return!1}}function ge(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function tp(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=ge(n)}else if(n.parentNode&&!Nn(n))e=Y(n),n=n.parentNode;else return null}}function np(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&&!Nn(n))e=Y(n)+1,n=n.parentNode;else return null}}function op(n,e,t){for(let o=e==0,s=e==ge(n);o||s;){if(n==t)return!0;let i=Y(n);if(n=n.parentNode,!n)return!1;o=o&&i==0,s=s&&i==ge(n)}}function Nn(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 Do=function(n){return n.focusNode&&Tt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Mt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function sp(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ip(n,e,t){if(n.caretPositionFromPoint)try{let o=n.caretPositionFromPoint(e,t);if(o)return{node:o.offsetNode,offset:Math.min(ge(o.offsetNode),o.offset)}}catch{}if(n.caretRangeFromPoint){let o=n.caretRangeFromPoint(e,t);if(o)return{node:o.startContainer,offset:Math.min(ge(o.startContainer),o.startOffset)}}}const Pe=typeof navigator<"u"?navigator:null,la=typeof document<"u"?document:null,Xe=Pe&&Pe.userAgent||"",ei=/Edge\/(\d+)/.exec(Xe),aa=/MSIE \d/.exec(Xe),ti=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Xe),ue=!!(aa||ti||ei),Qe=aa?document.documentMode:ti?+ti[1]:ei?+ei[1]:0,Se=!ue&&/gecko\/(\d+)/i.test(Xe);Se&&+(/Firefox\/(\d+)/.exec(Xe)||[0,0])[1];const ni=!ue&&/Chrome\/(\d+)/.exec(Xe),oe=!!ni,ca=ni?+ni[1]:0,re=!ue&&!!Pe&&/Apple Computer/.test(Pe.vendor),sn=re&&(/Mobile\/\w+/.test(Xe)||!!Pe&&Pe.maxTouchPoints>2),ye=sn||(Pe?/Mac/.test(Pe.platform):!1),rp=Pe?/Win/.test(Pe.platform):!1,Ce=/Android \d/.test(Xe),Pn=!!la&&"webkitFontSmoothing"in la.documentElement.style,lp=Pn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ap(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 He(n,e){return typeof n=="number"?n:n[e]}function cp(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,o=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*o}}function da(n,e,t){let o=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let r=t||n.dom;r;r=On(r)){if(r.nodeType!=1)continue;let l=r,a=l==i.body,c=a?ap(i):cp(l),d=0,u=0;if(e.top<c.top+He(o,"top")?u=-(c.top-e.top+He(s,"top")):e.bottom>c.bottom-He(o,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+He(s,"top")-c.top:e.bottom-c.bottom+He(s,"bottom")),e.left<c.left+He(o,"left")?d=-(c.left-e.left+He(s,"left")):e.right>c.right-He(o,"right")&&(d=e.right-c.right+He(s,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,f=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let p=l.scrollLeft-h,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 dp(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),o,s;for(let i=(e.left+e.right)/2,r=t+1;r<Math.min(innerHeight,e.bottom);r+=5){let l=n.root.elementFromPoint(i,r);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){o=l,s=a.top;break}}return{refDOM:o,refTop:s,stack:ua(n.dom)}}function ua(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=On(o));return e}function up({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;ha(t,o==0?0:o-e)}function ha(n,e){for(let t=0;t<n.length;t++){let{dom:o,top:s,left:i}=n[t];o.scrollTop!=s+e&&(o.scrollTop=s+e),o.scrollLeft!=i&&(o.scrollLeft=i)}}let rn=null;function hp(n){if(n.setActive)return n.setActive();if(rn)return n.focus(rn);let e=ua(n);n.focus(rn==null?{get preventScroll(){return rn={preventScroll:!0},!0}}:void 0),rn||(rn=!1,ha(e,0))}function fa(n,e){let t,o=2e8,s,i=0,r=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let h;if(d.nodeType==1)h=d.getClientRects();else if(d.nodeType==3)h=Be(d).getClientRects();else continue;for(let f=0;f<h.length;f++){let p=h[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<o){t=d,o=m,s=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&m&&(i=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!t&&a&&(t=a,s=c,o=0),t&&t.nodeType==3?fp(t,s):!t||o&&t.nodeType==1?{node:n,offset:i}:fa(t,s)}function fp(n,e){let t=n.nodeValue.length,o=document.createRange();for(let s=0;s<t;s++){o.setEnd(n,s+1),o.setStart(n,s);let i=et(o,1);if(i.top!=i.bottom&&oi(e,i))return{node:n,offset:s+(e.left>=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function oi(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function pp(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function mp(n,e,t){let{node:o,offset:s}=fa(e,t),i=-1;if(o.nodeType==1&&!o.firstChild){let r=o.getBoundingClientRect();i=r.left!=r.right&&t.left>(r.left+r.right)/2?1:-1}return n.docView.posFromDOM(o,s,i)}function gp(n,e,t,o){let s=-1;for(let i=e,r=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!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>o.left||a.top>o.top?s=l.posBefore:(!r&&a.right<o.left||a.bottom<o.top)&&(s=l.posAfter),r=!0),!l.contentDOM&&s<0&&!l.node.isText)return(l.node.isBlock?o.top<(a.top+a.bottom)/2:o.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}i=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function pa(n,e,t){let o=n.childNodes.length;if(o&&t.top<t.bottom)for(let s=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-t.top)/(t.bottom-t.top))-2)),i=s;;){let r=n.childNodes[i];if(r.nodeType==1){let l=r.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(oi(e,c))return pa(r,e,c)}}if((i=(i+1)%o)==s)break}return n}function yp(n,e){let t=n.dom.ownerDocument,o,s=0,i=ip(t,e.left,e.top);i&&({node:o,offset:s}=i);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(!oi(e,c)||(r=pa(n.dom,e,c),!r))return null}if(re)for(let c=r;o&&c;c=On(c))c.draggable&&(o=void 0);if(r=pp(r,e),o){if(Se&&o.nodeType==1&&(s=Math.min(s,o.childNodes.length),s<o.childNodes.length)){let d=o.childNodes[s],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&s++}let c;Pn&&s&&o.nodeType==1&&(c=o.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,o==n.dom&&s==o.childNodes.length-1&&o.lastChild.nodeType==1&&e.top>o.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(s==0||o.nodeType!=1||o.childNodes[s-1].nodeName!="BR")&&(l=gp(n,o,s,e))}l==null&&(l=mp(n,r,e));let a=n.docView.nearestDesc(r,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function ma(n){return n.top<n.bottom||n.left<n.right}function et(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(ma(o))return o}return Array.prototype.find.call(t,ma)||n.getBoundingClientRect()}const bp=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ga(n,e,t){let{node:o,offset:s,atom:i}=n.docView.domFromPos(e,t<0?-1:1),r=Pn||Se;if(o.nodeType==3)if(r&&(bp.test(o.nodeValue)||(t<0?!s:s==o.nodeValue.length))){let a=et(Be(o,s,s),t);if(Se&&s&&/\s/.test(o.nodeValue[s-1])&&s<o.nodeValue.length){let c=et(Be(o,s-1,s-1),-1);if(c.top==a.top){let d=et(Be(o,s,s+1),-1);if(d.top!=a.top)return In(d,d.left<c.left)}}return a}else{let a=s,c=s,d=t<0?1:-1;return t<0&&!s?(c++,d=-1):t>=0&&s==o.nodeValue.length?(a--,d=1):t<0?a--:c++,In(et(Be(o,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(t<0||s==ge(o))){let a=o.childNodes[s-1];if(a.nodeType==1)return si(a.getBoundingClientRect(),!1)}if(i==null&&s<ge(o)){let a=o.childNodes[s];if(a.nodeType==1)return si(a.getBoundingClientRect(),!0)}return si(o.getBoundingClientRect(),t>=0)}if(i==null&&s&&(t<0||s==ge(o))){let a=o.childNodes[s-1],c=a.nodeType==3?Be(a,ge(a)-(r?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return In(et(c,1),!1)}if(i==null&&s<ge(o)){let a=o.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Be(a,0,r?0:1):a.nodeType==1?a:null:null;if(c)return In(et(c,-1),!0)}return In(et(o.nodeType==3?Be(o):o,-t),t>=0)}function In(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 si(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 ya(n,e,t){let o=n.state,s=n.root.activeElement;o!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{o!=e&&n.updateState(o),s!=n.dom&&s&&s.focus()}}function vp(n,e,t){let o=e.selection,s=t=="up"?o.$from:o.$to;return ya(n,e,()=>{let{node:i}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let r=ga(n,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Be(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 xp=/[\u0590-\u08ac]/;function wp(n,e,t){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let s=o.parentOffset,i=!s,r=s==o.parent.content.size,l=n.domSelection();return l?!xp.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:r:ya(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",t,"character");let f=o.depth?n.docView.domAfterPos(o.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,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return h!=null&&(l.caretBidiLevel=h),g}):o.pos==o.start()||o.pos==o.end()}let ba=null,va=null,xa=!1;function Sp(n,e,t){return ba==e&&va==t?xa:(ba=e,va=t,xa=t=="up"||t=="down"?vp(n,e,t):wp(n,e,t))}const be=0,wa=1,At=2,Ie=3;class Rn{constructor(e,t,o,s){this.parent=e,this.children=t,this.dom=o,this.contentDOM=s,this.dirty=be,o.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,o){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,o=this.posAtStart;;t++){let s=this.children[t];if(s==e)return o;o+=s.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,o){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(o<0){let i,r;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((r=i.pmViewDesc)&&r.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(r)+r.size:this.posAtStart}else{let i,r;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((r=i.pmViewDesc)&&r.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(r):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>Y(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??o>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let o=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),r;if(i&&(!t||i.node))if(o&&(r=i.nodeDOM)&&!(r.nodeType==1?r.contains(e.nodeType==1?e:e.parentNode):r==e))o=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let o=t;o;o=o.parent)if(o==this)return t}posFromDOM(e,t,o){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,t,o)}return-1}descAt(e){for(let t=0,o=0;t<this.children.length;t++){let s=this.children[t],i=o+s.size;if(o==e&&i!=o){for(;!s.border&&s.children.length;)s=s.children[0];return s}if(e<i)return s.descAt(e-o-s.border);o=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let o=0,s=0;for(let i=0;o<this.children.length;o++){let r=this.children[o],l=i+r.size;if(l>e||r instanceof ka){s=e-i;break}i=l}if(s)return this.children[o].domFromPos(s-this.children[o].border,t);for(let i;o&&!(i=this.children[o-1]).size&&i instanceof Sa&&i.side>=0;o--);if(t<=0){let i,r=!0;for(;i=o?this.children[o-1]:null,!(!i||i.dom.parentNode==this.contentDOM);o--,r=!1);return i&&t&&r&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?Y(i.dom)+1:0}}else{let i,r=!0;for(;i=o<this.children.length?this.children[o]:null,!(!i||i.dom.parentNode==this.contentDOM);o++,r=!1);return i&&r&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?Y(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,o=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let r=o,l=0;;l++){let a=this.children[l],c=r+a.size;if(s==-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 u=l;u>0;u--){let h=this.children[u-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){s=Y(h.dom)+1;break}e-=h.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=Y(u.dom);break}t+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}r=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:o}=this.domFromPos(e,0);if(t.nodeType!=1||o==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[o]}setSelection(e,t,o,s=!1){let i=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(i>p&&r<g)return m.setSelection(e-p-m.border,t-p-m.border,o,s);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=o.root.getSelection(),d=o.domSelectionRange(),u=!1;if((Se||re)&&e==t){let{node:f,offset:p}=l;if(f.nodeType==3){if(u=!!(p&&f.nodeValue[p-1]==`
299
+ `),u&&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:Y(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=f.childNodes[p-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Se&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let f=d.focusNode.childNodes[d.focusOffset];f&&f.contentEditable=="false"&&(s=!0)}if(!(s||u&&re)&&Tt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Tt(a.node,a.offset,d.focusNode,d.focusOffset))return;let h=!1;if((c.extend||e==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),h=!0}catch{}}if(!h){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 o=0,s=0;s<this.children.length;s++){let i=this.children[s],r=o+i.size;if(o==r?e<=r&&t>=o:e<r&&t>o){let l=o+i.border,a=r-i.border;if(e>=l&&t<=a){this.dirty=e==o||t==r?At:wa,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ie:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?At:Ie}o=r}this.dirty=At}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?At:wa;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Sa extends Rn{constructor(e,t,o,s){let i,r=t.type.toDOM;if(typeof r=="function"&&(r=r(o,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!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,i=this}matchesWidget(e){return this.dirty==be&&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 Cp extends Rn{constructor(e,t,o,s){super(e,[],t,null),this.textDOM=o,this.text=s}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 Et extends Rn{constructor(e,t,o,s,i){super(e,[],o,s),this.mark=t,this.spec=i}static create(e,t,o,s){let i=s.nodeViews[t.type.name],r=i&&i(t,s,o);return(!r||!r.dom)&&(r=St.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new Et(e,t,r.dom,r.contentDOM||r.dom,r)}parseRule(){return this.dirty&Ie||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ie&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=be){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=be}}slice(e,t,o){let s=Et.create(this.parent,this.mark,!0,o),i=this.children,r=this.size;t<r&&(i=ri(i,t,r,o)),e>0&&(i=ri(i,0,e,o));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class tt extends Rn{constructor(e,t,o,s,i,r,l,a,c){super(e,[],i,r),this.node=t,this.outerDeco=o,this.innerDeco=s,this.nodeDOM=l}static create(e,t,o,s,i,r){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return r;if(a.parent)return a.parent.posBeforeChild(a)},o,s),d=c&&c.dom,u=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:u}=St.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let h=d;return d=Aa(d,o,t),c?a=new kp(e,t,o,s,d,u||null,h,c,i,r+1):t.isText?new zo(e,t,o,s,d,h,i):new tt(e,t,o,s,d,u||null,h,i,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 o=this.children[t];if(this.dom.contains(o.dom.parentNode)){e.contentElement=o.dom.parentNode;break}}e.contentElement||(e.getContent=()=>k.empty)}return e}matchesNode(e,t,o){return this.dirty==be&&e.eq(this.node)&&Lo(t,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let o=this.node.inlineContent,s=t,i=e.composing?this.localCompositionInfo(e,t):null,r=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Mp(this,r&&r.node,e);Op(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,o,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?V.none:this.node.child(d).marks,o,e),a.placeWidget(c,e,s)},(c,d,u,h)=>{a.syncToMarks(c.marks,o,e);let f;a.findNodeMatch(c,d,u,h)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(f=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,u,f,e)||a.updateNextNode(c,d,u,e,h,s)||a.addNode(c,d,u,e,s),s+=c.nodeSize}),a.syncToMarks([],o,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==At)&&(r&&this.protectLocalComposition(e,r),Ta(this.contentDOM,this.children,e),sn&&Np(this.dom))}localCompositionInfo(e,t){let{from:o,to:s}=e.state.selection;if(!(e.state.selection instanceof R)||o<t||s>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let r=i.nodeValue,l=Pp(this.node.content,r,o-t,s-t);return l<0?null:{node:i,pos:l,text:r}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:o,text:s}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let r=new Cp(this,i,t,s);e.input.compositionNodes.push(r),this.children=ri(this.children,o,o+s.length,e,r)}update(e,t,o,s){return this.dirty==Ie||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,o,s),!0)}updateInner(e,t,o,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=o,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=be}updateOuterDeco(e){if(Lo(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=Ma(this.dom,this.nodeDOM,ii(this.outerDeco,this.node,t),ii(e,this.node,t)),this.dom!=o&&(o.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 Ca(n,e,t,o,s){Aa(o,e,n);let i=new tt(void 0,n,e,t,o,o,o,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class zo extends tt{constructor(e,t,o,s,i,r,l){super(e,t,o,s,i,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,o,s){return this.dirty==Ie||this.dirty!=be&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=be||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=be,!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,o){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,o)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,o){let s=this.node.cut(e,t),i=document.createTextNode(s.text);return new zo(this.parent,s,this.outerDeco,this.innerDeco,i,i,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ie)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ka extends Rn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==be&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class kp extends tt{constructor(e,t,o,s,i,r,l,a,c,d){super(e,t,o,s,i,r,l,c,d),this.spec=a}update(e,t,o,s){if(this.dirty==Ie)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,o);return i&&this.updateInner(e,t,o,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,o,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,o,s){this.spec.setSelection?this.spec.setSelection(e,t,o.root):super.setSelection(e,t,o,s)}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 Ta(n,e,t){let o=n.firstChild,s=!1;for(let i=0;i<e.length;i++){let r=e[i],l=r.dom;if(l.parentNode==n){for(;l!=o;)o=Ea(o),s=!0;o=o.nextSibling}else s=!0,n.insertBefore(l,o);if(r instanceof Et){let a=o?o.previousSibling:n.lastChild;Ta(r.contentDOM,r.children,t),o=a?a.nextSibling:n.firstChild}}for(;o;)o=Ea(o),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const Dn=function(n){n&&(this.nodeName=n)};Dn.prototype=Object.create(null);const Ot=[new Dn];function ii(n,e,t){if(n.length==0)return Ot;let o=t?Ot[0]:new Dn,s=[o];for(let i=0;i<n.length;i++){let r=n[i].type.attrs;if(r){r.nodeName&&s.push(o=new Dn(r.nodeName));for(let l in r){let a=r[l];a!=null&&(t&&s.length==1&&s.push(o=new Dn(e.isInline?"span":"div")),l=="class"?o.class=(o.class?o.class+" ":"")+a:l=="style"?o.style=(o.style?o.style+";":"")+a:l!="nodeName"&&(o[l]=a))}}}return s}function Ma(n,e,t,o){if(t==Ot&&o==Ot)return e;let s=e;for(let i=0;i<o.length;i++){let r=o[i],l=t[i];if(i){let a;l&&l.nodeName==r.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==r.nodeName||(a=document.createElement(r.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=Ot[0]),s=a}Tp(s,l||Ot[0],r)}return s}function Tp(n,e,t){for(let o in e)o!="class"&&o!="style"&&o!="nodeName"&&!(o in t)&&n.removeAttribute(o);for(let o in t)o!="class"&&o!="style"&&o!="nodeName"&&t[o]!=e[o]&&n.setAttribute(o,t[o]);if(e.class!=t.class){let o=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<o.length;i++)s.indexOf(o[i])==-1&&n.classList.remove(o[i]);for(let i=0;i<s.length;i++)o.indexOf(s[i])==-1&&n.classList.add(s[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=o.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function Aa(n,e,t){return Ma(n,n,Ot,ii(e,t,n.nodeType!=1))}function Lo(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 Ea(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Mp{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Ap(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let o=e;o<t;o++)this.top.children[o].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,o){let s=0,i=this.stack.length>>1,r=Math.min(i,e.length);for(;s<r&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=be,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<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[i])&&!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=Et.create(this.top,e[i],t,o);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,o,s){let i=-1,r;if(s>=this.preMatch.index&&(r=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,o))i=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,o)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,o,s,i){let r=this.top.children[s];return r.dirty==Ie&&r.dom==r.contentDOM&&(r.dirty=At),r.update(e,t,o,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let o=e.pmViewDesc;if(o){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==o)return s}return-1}e=t}}updateNextNode(e,t,o,s,i,r){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof tt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,u,h=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Ie&&Lo(t,a.outerDeco));if(!h&&a.update(e,t,o,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(u=this.recreateWrapper(a,e,t,o,s,r)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=At,u.updateChildren(s,r+1),u.dirty=be),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,s,i,r){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Lo(o,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=tt.create(this.top,t,o,s,i,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,o,s,i){let r=tt.create(this.top,e,t,o,s,i);r.contentDOM&&r.updateChildren(s,i+1),this.top.children.splice(this.index++,0,r),this.changed=!0}placeWidget(e,t,o){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new Sa(this.top,e,t,o);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Et;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof zo)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((re||oe)&&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 o=document.createElement(e);e=="IMG"&&(o.className="ProseMirror-separator",o.alt=""),e=="BR"&&(o.className="ProseMirror-trailingBreak");let s=new ka(this.top,[],o,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Ap(n,e){let t=e,o=t.children.length,s=n.childCount,i=new Map,r=[];e:for(;s>0;){let l;for(;;)if(o){let c=t.children[o-1];if(c instanceof Et)t=c,o=c.children.length;else{l=c,o--;break}}else{if(t==e)break e;o=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,i.set(l,s),r.push(l)}}return{index:s,matched:i,matches:r.reverse()}}function Ep(n,e){return n.type.side-e.type.side}function Op(n,e,t,o){let s=e.locals(n),i=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);o(d,s,e.forChild(i,d),c),i+=d.nodeSize}return}let r=0,l=[],a=null;for(let c=0;;){let d,u;for(;r<s.length&&s[r].to==i;){let g=s[r++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(Ep);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let h,f;if(a)f=-1,h=a,a=null;else if(c<n.childCount)f=c,h=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;r<s.length&&s[r].from<=i&&s[r].to>i;)l.push(s[r++]);let p=i+h.nodeSize;if(h.isText){let g=p;r<s.length&&s[r].from<g&&(g=s[r].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=h.cut(g-i),h=h.cut(0,g-i),p=g,f=-1)}else for(;r<s.length&&s[r].to<p;)r++;let m=h.isInline&&!h.isLeaf?l.filter(g=>!g.inline):l.slice();o(h,m,e.forChild(i,h),f),i=p}}function Np(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 Pp(n,e,t,o){for(let s=0,i=0;s<n.childCount&&i<=o;){let r=n.child(s++),l=i;if(i+=r.nodeSize,!r.isText)continue;let a=r.text;for(;s<n.childCount;){let c=n.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=o&&a.slice(o-e.length-l,o-l)==e)return o-e.length;let c=l<o?a.lastIndexOf(e,o-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==o&&a.length>=o+e.length-l&&a.slice(o-l,o-l+e.length)==e)return o}}return-1}function ri(n,e,t,o,s){let i=[];for(let r=0,l=0;r<n.length;r++){let a=n[r],c=l,d=l+=a.size;c>=t||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,o)),s&&(i.push(s),s=void 0),d>t&&i.push(a.slice(t-c,a.size,o)))}return i}function li(n,e=null){let t=n.domSelectionRange(),o=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),i=s&&s.size==0,r=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(r<0)return null;let l=o.resolve(r),a,c;if(Do(t)){for(a=r;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&N.isSelectable(u)&&s.parent&&!(u.isInline&&op(t.focusNode,t.focusOffset,s.dom))){let h=s.posBefore;c=new N(r==h?l:o.resolve(h))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=r,h=r;for(let f=0;f<t.rangeCount;f++){let p=t.getRangeAt(f);u=Math.min(u,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),h=Math.max(h,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,r]=h==n.state.selection.anchor?[h,u]:[u,h],l=o.resolve(r)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=o.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=ci(n,d,l,u)}return c}function Oa(n){return n.editable?n.hasFocus():La(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function $e(n,e=!1){let t=n.state.selection;if(Ra(n,t),!!Oa(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&oe){let o=n.domSelectionRange(),s=n.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&Tt(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Rp(n);else{let{anchor:o,head:s}=t,i,r;Na&&!(t instanceof R)&&(t.$from.parent.inlineContent||(i=Pa(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(r=Pa(n,t.to))),n.docView.setSelection(o,s,n,e),Na&&(i&&Ia(i),r&&Ia(r)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ip(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Na=re||oe&&ca<63;function Pa(n,e){let{node:t,offset:o}=n.docView.domFromPos(e,0),s=o<t.childNodes.length?t.childNodes[o]:null,i=o?t.childNodes[o-1]:null;if(re&&s&&s.contentEditable=="false")return ai(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return ai(s);if(i)return ai(i)}}function ai(n){return n.contentEditable="true",re&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ia(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Ip(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),o=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=o||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Oa(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Rp(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let o=n.cursorWrapper.dom,s=o.nodeName=="IMG";s?t.setStart(o.parentNode,Y(o)+1):t.setStart(o,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&ue&&Qe<=11&&(o.disabled=!0,o.disabled=!1)}function Ra(n,e){if(e instanceof N){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Da(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Da(n)}function Da(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function ci(n,e,t,o){return n.someProp("createSelectionBetween",s=>s(n,e,t))||R.between(e,t,o)}function za(n){return n.editable&&!n.hasFocus()?!1:La(n)}function La(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 Dp(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Tt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function di(n,e){let{$anchor:t,$head:o}=n.selection,s=e>0?t.max(o):t.min(o),i=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return i&&I.findFrom(i,e)}function nt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Va(n,e,t){let o=n.state.selection;if(o instanceof R)if(t.indexOf("s")>-1){let{$head:s}=o,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let r=n.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return nt(n,new R(o.$anchor,r))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=di(n.state,e);return s&&s instanceof N?nt(n,s):!1}else if(!(ye&&t.indexOf("m")>-1)){let s=o.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,r;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(r=n.docView.descAt(l))&&!r.contentDOM?N.isSelectable(i)?nt(n,new N(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):Pn?nt(n,new R(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(o instanceof N&&o.node.isInline)return nt(n,new R(e>0?o.$to:o.$from));{let s=di(n.state,e);return s?nt(n,s):!1}}}function Vo(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function zn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function ln(n,e){return e<0?zp(n):Lp(n)}function zp(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s,i,r=!1;for(Se&&t.nodeType==1&&o<Vo(t)&&zn(t.childNodes[o],-1)&&(r=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(zn(l,-1))s=t,i=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if(Ba(t))break;{let l=t.previousSibling;for(;l&&zn(l,-1);)s=t.parentNode,i=Y(l),l=l.previousSibling;if(l)t=l,o=Vo(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}r?ui(n,t,o):s&&ui(n,s,i)}function Lp(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s=Vo(t),i,r;for(;;)if(o<s){if(t.nodeType!=1)break;let l=t.childNodes[o];if(zn(l,1))i=t,r=++o;else break}else{if(Ba(t))break;{let l=t.nextSibling;for(;l&&zn(l,1);)i=l.parentNode,r=Y(l)+1,l=l.nextSibling;if(l)t=l,o=0,s=Vo(t);else{if(t=t.parentNode,t==n.dom)break;o=s=0}}}i&&ui(n,i,r)}function Ba(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Vp(n,e){for(;n&&e==n.childNodes.length&&!Nn(n);)e=Y(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 Bp(n,e){for(;n&&!e&&!Nn(n);)e=Y(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 ui(n,e,t){if(e.nodeType!=3){let i,r;(r=Vp(e,t))?(e=r,t=0):(i=Bp(e,t))&&(e=i,t=i.nodeValue.length)}let o=n.domSelection();if(!o)return;if(Do(o)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),o.removeAllRanges(),o.addRange(i)}else o.extend&&o.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&$e(n)},50)}function Ha(n,e){let t=n.state.doc.resolve(e);if(!(oe||rp)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),r=(i.top+i.bottom)/2;if(r>s.top&&r<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),r=(i.top+i.bottom)/2;if(r>s.top&&r<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function $a(n,e,t){let o=n.state.selection;if(o instanceof R&&!o.empty||t.indexOf("s")>-1||ye&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=o;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let r=di(n.state,e);if(r&&r instanceof N)return nt(n,r)}if(!s.parent.inlineContent){let r=e<0?s:i,l=o instanceof pe?I.near(r,e):I.findFrom(r,e);return l?nt(n,l):!1}return!1}function Fa(n,e){if(!(n.state.selection instanceof R))return!0;let{$head:t,$anchor:o,empty:s}=n.state.selection;if(!t.sameParent(o))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let r=n.state.tr;return e<0?r.delete(t.pos-i.nodeSize,t.pos):r.delete(t.pos,t.pos+i.nodeSize),n.dispatch(r),!0}return!1}function _a(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Hp(n){if(!re||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 o=e.firstChild;_a(n,o,"true"),setTimeout(()=>_a(n,o,"false"),20)}return!1}function $p(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Fp(n,e){let t=e.keyCode,o=$p(e);if(t==8||ye&&t==72&&o=="c")return Fa(n,-1)||ln(n,-1);if(t==46&&!e.shiftKey||ye&&t==68&&o=="c")return Fa(n,1)||ln(n,1);if(t==13||t==27)return!0;if(t==37||ye&&t==66&&o=="c"){let s=t==37?Ha(n,n.state.selection.from)=="ltr"?-1:1:-1;return Va(n,s,o)||ln(n,s)}else if(t==39||ye&&t==70&&o=="c"){let s=t==39?Ha(n,n.state.selection.from)=="ltr"?1:-1:1;return Va(n,s,o)||ln(n,s)}else{if(t==38||ye&&t==80&&o=="c")return $a(n,-1,o)||ln(n,-1);if(t==40||ye&&t==78&&o=="c")return Hp(n)||$a(n,1,o)||ln(n,1);if(o==(ye?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Wa(n,e){n.someProp("transformCopied",f=>{e=f(e,n)});let t=[],{content:o,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&o.childCount==1&&o.firstChild.childCount==1;){s--,i--;let f=o.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),o=f.content}let r=n.someProp("clipboardSerializer")||St.fromSchema(n.state.schema),l=Ya(),a=l.createElement("div");a.appendChild(r.serializeFragment(o,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Ua[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),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${u?` -${u}`:""} ${JSON.stringify(t)}`);let h=n.someProp("clipboardTextSerializer",f=>f(e,n))||e.content.textBetween(0,e.content.size,`
300
+
301
+ `);return{dom:a,text:h,slice:e}}function qa(n,e,t,o,s){let i=s.parent.type.spec.code,r,l;if(!t&&!e)return null;let a=e&&(o||i||!t);if(a){if(n.someProp("transformPastedText",h=>{e=h(e,i||o,n)}),i)return e?new M(k.from(n.state.schema.text(e.replace(/\r\n?/g,`
302
+ `))),0,0):M.empty;let u=n.someProp("clipboardTextParser",h=>h(e,s,o,n));if(u)l=u;else{let h=s.marks(),{schema:f}=n.state,p=St.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,h)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),r=Gp(t),Pn&&jp(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 u=+d[3];u>0;u--){let h=r.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;r=h}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Ut.fromSchema(n.state.schema)).parseSlice(r,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!_p.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Kp(Ja(l,+d[1],+d[2]),d[4]);else if(l=M.maxOpen(Wp(l.content,s),!0),l.openStart||l.openEnd){let u=0,h=0;for(let f=l.content.firstChild;u<l.openStart&&!f.type.spec.isolating;u++,f=f.firstChild);for(let f=l.content.lastChild;h<l.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);l=Ja(l,u,h)}return n.someProp("transformPasted",u=>{l=u(l,n)}),l}const _p=/^(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 Wp(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,r=[];if(n.forEach(l=>{if(!r)return;let a=s.findWrapping(l.type),c;if(!a)return r=null;if(c=r.length&&i.length&&ja(a,i,l,r[r.length-1],0))r[r.length-1]=c;else{r.length&&(r[r.length-1]=Ka(r[r.length-1],i.length));let d=Ga(l,a);r.push(d),s=s.matchType(d.type),i=a}}),r)return k.from(r)}return n}function Ga(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,k.from(n));return n}function ja(n,e,t,o,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let i=ja(n,e,t,o.lastChild,s+1);if(i)return o.copy(o.content.replaceChild(o.childCount-1,i));if(o.contentMatchAt(o.childCount).matchType(s==n.length-1?t.type:n[s+1]))return o.copy(o.content.append(k.from(Ga(t,n,s+1))))}}function Ka(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Ka(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(k.empty,!0);return n.copy(t.append(o))}function hi(n,e,t,o,s,i){let r=e<0?n.firstChild:n.lastChild,l=r.content;return n.childCount>1&&(i=0),s<o-1&&(l=hi(l,e,t,o,s+1,i)),s>=t&&(l=e<0?r.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(r.contentMatchAt(r.childCount).fillBefore(k.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,r.copy(l))}function Ja(n,e,t){return e<n.openStart&&(n=new M(hi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new M(hi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Ua={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 Za=null;function Ya(){return Za||(Za=document.implementation.createHTMLDocument("title"))}let fi=null;function qp(n){let e=window.trustedTypes;return e?(fi||(fi=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),fi.createHTML(n)):n}function Gp(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Ya().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(n),s;if((s=o&&Ua[o[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=qp(n),s)for(let i=0;i<s.length;i++)t=t.querySelector(s[i])||t;return t}function jp(n){let e=n.querySelectorAll(oe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let o=e[t];o.childNodes.length==1&&o.textContent==" "&&o.parentNode&&o.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),o)}}function Kp(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,o;try{o=JSON.parse(e)}catch{return n}let{content:s,openStart:i,openEnd:r}=n;for(let l=o.length-2;l>=0;l-=2){let a=t.nodes[o[l]];if(!a||a.hasRequiredAttrs())break;s=k.from(a.create(o[l+1],s)),i++,r++}return new M(s,i,r)}const le={},ae={},Jp={touchstart:!0,touchmove:!0};class Up{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 Zp(n){for(let e in le){let t=le[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{Xp(n,o)&&!mi(n,o)&&(n.editable||!(o.type in ae))&&t(n,o)},Jp[e]?{passive:!0}:void 0)}re&&n.dom.addEventListener("input",()=>null),pi(n)}function ot(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Yp(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 pi(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>mi(n,o))})}function mi(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function Xp(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 Qp(n,e){!mi(n,e)&&le[e.type]&&(n.editable||!(e.type in ae))&&le[e.type](n,e)}ae.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Qa(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Ce&&oe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),sn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let o=Date.now();n.input.lastIOSEnter=o,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==o&&(n.someProp("handleKeyDown",s=>s(n,Mt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",o=>o(n,t))||Fp(n,t)?t.preventDefault():ot(n,"key")},ae.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},ae.keypress=(n,e)=>{let t=e;if(Qa(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ye&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let o=n.state.selection;if(!(o instanceof R)||!o.$from.sameParent(o.$to)){let s=String.fromCharCode(t.charCode);!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",i=>i(n,o.$from.pos,o.$to.pos,s))&&n.dispatch(n.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function Bo(n){return{left:n.clientX,top:n.clientY}}function em(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function gi(n,e,t,o,s){if(o==-1)return!1;let i=n.state.doc.resolve(o);for(let r=i.depth+1;r>0;r--)if(n.someProp(e,l=>r>i.depth?l(n,t,i.nodeAfter,i.before(r),s,!0):l(n,t,i.node(r),i.before(r),s,!1)))return!0;return!1}function an(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let o=n.state.tr.setSelection(e);o.setMeta("pointer",!0),n.dispatch(o)}function tm(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&N.isSelectable(o)?(an(n,new N(t)),!0):!1}function nm(n,e){if(e==-1)return!1;let t=n.state.selection,o,s;t instanceof N&&(o=t.node);let i=n.state.doc.resolve(e);for(let r=i.depth+1;r>0;r--){let l=r>i.depth?i.nodeAfter:i.node(r);if(N.isSelectable(l)){o&&t.$from.depth>0&&r>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(r);break}}return s!=null?(an(n,N.create(n.state.doc,s)),!0):!1}function om(n,e,t,o,s){return gi(n,"handleClickOn",e,t,o)||n.someProp("handleClick",i=>i(n,e,o))||(s?nm(n,t):tm(n,t))}function sm(n,e,t,o){return gi(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",s=>s(n,e,o))}function im(n,e,t,o){return gi(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",s=>s(n,e,o))||rm(n,t,o)}function rm(n,e,t){if(t.button!=0)return!1;let o=n.state.doc;if(e==-1)return o.inlineContent?(an(n,R.create(o,0,o.content.size)),!0):!1;let s=o.resolve(e);for(let i=s.depth+1;i>0;i--){let r=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(r.inlineContent)an(n,R.create(o,l+1,l+1+r.content.size));else if(N.isSelectable(r))an(n,N.create(o,l));else continue;return!0}}function yi(n){return Ho(n)}const Xa=ye?"metaKey":"ctrlKey";le.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=yi(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&em(t,n.input.lastClick)&&!t[Xa]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i};let r=n.posAtCoords(Bo(t));r&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new lm(n,r,t,!!o)):(i=="doubleClick"?sm:im)(n,r.pos,r.inside,t)?t.preventDefault():ot(n,"pointer"))};class lm{constructor(e,t,o,s){this.view=e,this.pos=t,this.event=o,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!o[Xa],this.allowDefault=o.shiftKey;let i,r;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),r=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,r=d.depth?d.before():0}const l=s?null:o.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(o.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof N&&c.from<=r&&c.to>r)&&(this.mightDrag={node:i,pos:r,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Se&&!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)),ot(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(()=>$e(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(Bo(e))),this.updateAllowDefault(e),this.allowDefault||!t?ot(this.view,"pointer"):om(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||re&&this.mightDrag&&!this.mightDrag.node.isAtom||oe&&!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)?(an(this.view,I.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ot(this.view,"pointer")}move(e){this.updateAllowDefault(e),ot(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)}}le.touchstart=n=>{n.input.lastTouch=Date.now(),yi(n),ot(n,"pointer")},le.touchmove=n=>{n.input.lastTouch=Date.now(),ot(n,"pointer")},le.contextmenu=n=>yi(n);function Qa(n,e){return n.composing?!0:re&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const am=Ce?5e3:-1;ae.compositionstart=ae.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof R&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Ho(n,!0),n.markCursor=null;else if(Ho(n,!e.selection.empty),Se&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let o=n.domSelectionRange();for(let s=o.focusNode,i=o.focusOffset;s&&s.nodeType==1&&i!=0;){let r=i<0?s.lastChild:s.childNodes[i-1];if(!r)break;if(r.nodeType==3){let l=n.domSelection();l&&l.collapse(r,r.nodeValue.length);break}else s=r,i=-1}}n.input.composing=!0}ec(n,am)},ae.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++,ec(n,20))};function ec(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Ho(n),e))}function tc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=dm());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function cm(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=tp(e.focusNode,e.focusOffset),o=np(e.focusNode,e.focusOffset);if(t&&o&&t!=o){let s=o.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||o==i)return i;if(!s||!s.isText(o.nodeValue))return o;if(n.input.compositionNode==o){let r=t.pmViewDesc;if(!(!r||!r.isText(t.nodeValue)))return o}}return t||o}function dm(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Ho(n,e=!1){if(!(Ce&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),tc(n),e||n.docView&&n.docView.dirty){let t=li(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 um(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 o=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),o.removeAllRanges(),o.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Ln=ue&&Qe<15||sn&&lp<604;le.copy=ae.cut=(n,e)=>{let t=e,o=n.state.selection,s=t.type=="cut";if(o.empty)return;let i=Ln?null:t.clipboardData,r=o.content(),{dom:l,text:a}=Wa(n,r);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):um(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function hm(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function fm(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,o=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),o.parentNode&&o.parentNode.removeChild(o),t?Vn(n,o.value,null,s,e):Vn(n,o.textContent,o.innerHTML,s,e)},50)}function Vn(n,e,t,o,s){let i=qa(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,i||M.empty)))return!0;if(!i)return!1;let r=hm(i),l=r?n.state.tr.replaceSelectionWith(r,o):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function nc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ae.paste=(n,e)=>{let t=e;if(n.composing&&!Ce)return;let o=Ln?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&Vn(n,nc(o),o.getData("text/html"),s,t)?t.preventDefault():fm(n,t)};class oc{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const sc=ye?"altKey":"ctrlKey";le.dragstart=(n,e)=>{let t=e,o=n.input.mouseDown;if(o&&o.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(Bo(t)),r;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof N?s.to-1:s.to))){if(o&&o.mightDrag)r=N.create(n.state.doc,o.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(r=N.create(n.state.doc,u.posBefore))}}let l=(r||n.state.selection).content(),{dom:a,text:c,slice:d}=Wa(n,l);(!t.dataTransfer.files.length||!oe||ca>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Ln?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Ln||t.dataTransfer.setData("text/plain",c),n.dragging=new oc(d,!t[sc],r)},le.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},ae.dragover=ae.dragenter=(n,e)=>e.preventDefault(),ae.drop=(n,e)=>{let t=e,o=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(Bo(t));if(!s)return;let i=n.state.doc.resolve(s.pos),r=o&&o.slice;r?n.someProp("transformPasted",p=>{r=p(r,n)}):r=qa(n,nc(t.dataTransfer),Ln?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(o&&!t[sc]);if(n.someProp("handleDrop",p=>p(n,t,r||M.empty,l))){t.preventDefault();return}if(!r)return;t.preventDefault();let a=r?af(n.state.doc,i.pos,r):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:p}=o;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,r.content.firstChild):c.replaceRange(d,d,r),c.doc.eq(h))return;let f=c.doc.resolve(d);if(u&&N.isSelectable(r.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(r.content.firstChild))c.setSelection(new N(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,S)=>p=S),c.setSelection(ci(n,f,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},le.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&$e(n)},20))},le.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},le.beforeinput=(n,e)=>{if(oe&&Ce&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:o}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=o||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,Mt(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in ae)le[n]=ae[n];function Bn(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 $o{constructor(e,t){this.toDOM=e,this.spec=t||Nt,this.side=this.spec.side||0}map(e,t,o,s){let{pos:i,deleted:r}=e.mapResult(t.from+s,this.side<0?-1:1);return r?null:new he(i-o,i-o,this)}valid(){return!0}eq(e){return this==e||e instanceof $o&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Bn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class st{constructor(e,t){this.attrs=e,this.spec=t||Nt}map(e,t,o,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-o,r=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-o;return i>=r?null:new he(i,r,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof st&&Bn(this.attrs,e.attrs)&&Bn(this.spec,e.spec)}static is(e){return e.type instanceof st}destroy(){}}class bi{constructor(e,t){this.attrs=e,this.spec=t||Nt}map(e,t,o,s){let i=e.mapResult(t.from+s,1);if(i.deleted)return null;let r=e.mapResult(t.to+s,-1);return r.deleted||r.pos<=i.pos?null:new he(i.pos-o,r.pos-o,this)}valid(e,t){let{index:o,offset:s}=e.content.findIndex(t.from),i;return s==t.from&&!(i=e.child(o)).isText&&s+i.nodeSize==t.to}eq(e){return this==e||e instanceof bi&&Bn(this.attrs,e.attrs)&&Bn(this.spec,e.spec)}destroy(){}}class he{constructor(e,t,o){this.from=e,this.to=t,this.type=o}copy(e,t){return new he(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,o){return this.type.map(e,this,t,o)}static widget(e,t,o){return new he(e,e,new $o(t,o))}static inline(e,t,o,s){return new he(e,t,new st(o,s))}static node(e,t,o,s){return new he(e,t,new bi(o,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof st}get widget(){return this.type instanceof $o}}const cn=[],Nt={};class W{constructor(e,t){this.local=e.length?e:cn,this.children=t.length?t:cn}static create(e,t){return t.length?Fo(t,e,0,Nt):se}find(e,t,o){let s=[];return this.findInner(e??0,t??1e9,s,0,o),s}findInner(e,t,o,s,i){for(let r=0;r<this.local.length;r++){let l=this.local[r];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&o.push(l.copy(l.from+s,l.to+s))}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,o,s+l,i)}}map(e,t,o){return this==se||e.maps.length==0?this:this.mapInner(e,t,0,0,o||Nt)}mapInner(e,t,o,s,i){let r;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,o,s);a&&a.type.valid(t,a)?(r||(r=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?pm(this.children,r||[],e,t,o,s,i):r?new W(r.sort(Pt),cn):se}add(e,t){return t.length?this==se?W.create(e,t):this.addInner(e,t,0):this}addInner(e,t,o){let s,i=0;e.forEach((l,a)=>{let c=a+o,d;if(d=rc(t,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,d,c+1):s.splice(i,0,a,a+l.nodeSize,Fo(d,l,c+1,Nt)),i+=3}});let r=ic(i?lc(t):t,-o);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||r.splice(l--,1);return new W(r.length?this.local.concat(r).sort(Pt):this.local,s||this.children)}remove(e){return e.length==0||this==se?this:this.removeInner(e,0)}removeInner(e,t){let o=this.children,s=this.local;for(let i=0;i<o.length;i+=3){let r,l=o[i]+t,a=o[i+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(r||(r=[])).push(u));if(!r)continue;o==this.children&&(o=this.children.slice());let c=o[i+2].removeInner(r,l+1);c!=se?o[i+2]=c:(o.splice(i,3),i-=3)}if(s.length){for(let i=0,r;i<e.length;i++)if(r=e[i])for(let l=0;l<s.length;l++)s[l].eq(r,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return o==this.children&&s==this.local?this:s.length||o.length?new W(s,o):se}forChild(e,t){if(this==se)return this;if(t.isLeaf)return W.empty;let o,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(o=this.children[l+2]);break}let i=e+1,r=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<r&&a.to>i&&a.type instanceof st){let c=Math.max(i,a.from)-i,d=Math.min(r,a.to)-i;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new W(s.sort(Pt),cn);return o?new it([l,o]):l}return o||se}eq(e){if(this==e)return!0;if(!(e instanceof W)||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 vi(this.localsInner(e))}localsInner(e){if(this==se)return cn;if(e.inlineContent||!this.local.some(st.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof st||t.push(this.local[o]);return t}forEachSet(e){e(this)}}W.empty=new W([],[]),W.removeOverlap=vi;const se=W.empty;class it{constructor(e){this.members=e}map(e,t){const o=this.members.map(s=>s.map(e,t,Nt));return it.from(o)}forChild(e,t){if(t.isLeaf)return W.empty;let o=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,t);i!=se&&(i instanceof it?o=o.concat(i.members):o.push(i))}return it.from(o)}eq(e){if(!(e instanceof it)||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,o=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!t)t=i;else{o&&(t=t.slice(),o=!1);for(let r=0;r<i.length;r++)t.push(i[r])}}return t?vi(o?t:t.sort(Pt)):cn}static from(e){switch(e.length){case 0:return se;case 1:return e[0];default:return new it(e.every(t=>t instanceof W)?e:e.reduce((t,o)=>t.concat(o instanceof W?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function pm(n,e,t,o,s,i,r){let l=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let u=0;t.maps[c].forEach((h,f,p,m)=>{let g=m-p-(f-h);for(let y=0;y<l.length;y+=3){let S=l[y+1];if(S<0||h>S+d-u)continue;let b=l[y]+d-u;f>=b?l[y+1]=h<=b?-2:-1:h>=d&&g&&(l[y]+=g,l[y+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+i),u=d-s;if(u<0||u>=o.content.size){a=!0;continue}let h=t.map(n[c+1]+i,-1),f=h-s,{index:p,offset:m}=o.content.findIndex(u),g=o.maybeChild(p);if(g&&m==u&&m+g.nodeSize==f){let y=l[c+2].mapInner(t,g,d+1,n[c]+i+1,r);y!=se?(l[c]=u,l[c+1]=f,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=mm(l,n,e,t,s,i,r),d=Fo(c,o,0,r);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,h=0;u<d.children.length;u+=3){let f=d.children[u];for(;h<l.length&&l[h]<f;)h+=3;l.splice(h,0,d.children[u],d.children[u+1],d.children[u+2])}}return new W(e.sort(Pt),l)}function ic(n,e){if(!e||!n.length)return n;let t=[];for(let o=0;o<n.length;o++){let s=n[o];t.push(new he(s.from+e,s.to+e,s.type))}return t}function mm(n,e,t,o,s,i,r){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(o,s,c);u?t.push(u):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]+i+1);return t}function rc(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,s=null;for(let i=0,r;i<n.length;i++)(r=n[i])&&r.from>t&&r.to<o&&((s||(s=[])).push(r),n[i]=null);return s}function lc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Fo(n,e,t,o){let s=[],i=!1;e.forEach((l,a)=>{let c=rc(n,l,a+t);if(c){i=!0;let d=Fo(c,l,t+a+1,o);d!=se&&s.push(a,a+l.nodeSize,d)}});let r=ic(i?lc(n):n,-t).sort(Pt);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||(o.onRemove&&o.onRemove(r[l].spec),r.splice(l--,1));return r.length||s.length?new W(r,s):se}function Pt(n,e){return n.from-e.from||n.to-e.to}function vi(n){let e=n;for(let t=0;t<e.length-1;t++){let o=e[t];if(o.from!=o.to)for(let s=t+1;s<e.length;s++){let i=e[s];if(i.from==o.from){i.to!=o.to&&(e==n&&(e=n.slice()),e[s]=i.copy(i.from,o.to),ac(e,s+1,i.copy(o.to,i.to)));continue}else{i.from<o.to&&(e==n&&(e=n.slice()),e[t]=o.copy(o.from,i.from),ac(e,s,o.copy(i.from,o.to)));break}}}return e}function ac(n,e,t){for(;e<n.length&&Pt(t,n[e])>0;)e++;n.splice(e,0,t)}function xi(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=se&&e.push(o)}),n.cursorWrapper&&e.push(W.create(n.state.doc,[n.cursorWrapper.deco])),it.from(e)}const gm={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ym=ue&&Qe<=11;class bm{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 vm{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new bm,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(o=>{for(let s=0;s<o.length;s++)this.queue.push(o[s]);ue&&Qe<=11&&o.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),ym&&(this.onCharData=o=>{this.queue.push({target:o.target,type:"characterData",oldValue:o.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,gm)),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(za(this.view)){if(this.suppressingSelectionUpdates)return $e(this.view);if(ue&&Qe<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Tt(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,o;for(let i=e.focusNode;i;i=On(i))t.add(i);for(let i=e.anchorNode;i;i=On(i))if(t.has(i)){o=i;break}let s=o&&this.view.docView.nearestDesc(o);if(s&&s.ignoreMutation({type:"selection",target:o.nodeType==3?o.parentNode:o}))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 o=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&za(e)&&!this.ignoreSelectionChange(o),i=-1,r=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(i=i<0?u.from:Math.min(u.from,i),r=r<0?u.to:Math.max(u.to,r),u.typeOver&&(l=!0))}if(Se&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,h]=d;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let h of d){let f=h.parentNode;f&&f.nodeName=="LI"&&(!u||Sm(e,u)!=f)&&h.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Do(o)&&(c=li(e))&&c.eq(I.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,$e(e),this.currentSelection.set(o),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,r),xm(e)),this.handleDOMChange(i,r,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(o)||$e(e),this.currentSelection.set(o))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let o=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return{from:o.posBefore,to:o.posAfter};let s=e.previousSibling,i=e.nextSibling;if(ue&&Qe<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:h}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h)}let r=s&&s.parentNode==e.target?Y(s)+1:0,l=o.localPosFromDOM(e.target,r,-1),a=i&&i.parentNode==e.target?Y(i):e.target.childNodes.length,c=o.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}:(this.lastChangedTextNode=e.target,{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let cc=new WeakMap,dc=!1;function xm(n){if(!cc.has(n)&&(cc.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Se,dc)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."),dc=!0}}function uc(n,e){let t=e.startContainer,o=e.startOffset,s=e.endContainer,i=e.endOffset,r=n.domAtPos(n.state.selection.anchor);return Tt(r.node,r.offset,s,i)&&([t,o,s,i]=[s,i,t,o]),{anchorNode:t,anchorOffset:o,focusNode:s,focusOffset:i}}function wm(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return uc(n,s)}let t;function o(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",o,!0),t?uc(n,t):null}function Sm(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let o=n.docView.nearestDesc(t,!0);if(o&&o.node.isBlock)return t}return null}function Cm(n,e,t){let{node:o,fromOffset:s,toOffset:i,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}],Do(a)||c.push({node:a.focusNode,offset:a.focusOffset})),oe&&n.input.lastKeyCode===8)for(let g=i;g>s;g--){let y=o.childNodes[g-1],S=y.pmViewDesc;if(y.nodeName=="BR"&&!S){i=g;break}if(!S||S.size)break}let u=n.state.doc,h=n.someProp("domParser")||Ut.fromSchema(n.state.schema),f=u.resolve(r),p=null,m=h.parse(o,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:km,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+r,head:y+r}}return{doc:m,sel:p,from:r,to:l}}function km(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(re&&/^(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||re&&/^(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 Tm=/^(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 Mm(n,e,t,o,s){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,A=li(n,T);if(A&&!n.state.selection.eq(A)){if(oe&&Ce&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",D=>D(n,Mt(13,"Enter"))))return;let P=n.state.tr.setSelection(A);T=="pointer"?P.setMeta("pointer",!0):T=="key"&&P.scrollIntoView(),i&&P.setMeta("composition",i),n.dispatch(P)}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=Cm(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),h,f;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(h=n.state.selection.to,f="end"):(h=n.state.selection.from,f="start"),n.input.lastKeyCode=null;let p=Om(u.content,c.doc.content,c.from,h,f);if(p&&n.input.domChangeCount++,(sn&&n.input.lastIOSEnter>Date.now()-225||Ce)&&s.some(T=>T.nodeType==1&&!Tm.test(T.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",T=>T(n,Mt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(o&&a instanceof R&&!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 T=hc(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let A=n.state.tr.setSelection(T);i&&A.setMeta("composition",i),n.dispatch(A)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof R&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ue&&Qe<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(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),S=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA,b;if((sn&&n.input.lastIOSEnter>Date.now()-225&&(!S||s.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!S&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(b=I.findFrom(c.doc.resolve(m.pos+1),1,!0))&&b.head==g.pos)&&n.someProp("handleKeyDown",T=>T(n,Mt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Em(d,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",T=>T(n,Mt(8,"Backspace")))){Ce&&oe&&n.domObserver.suppressSelectionUpdates();return}oe&&Ce&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),Ce&&!S&&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(T){return T(n,Mt(13,"Enter"))})},20));let x=p.start,v=p.endA,w,C,E;if(S){if(m.pos==g.pos)ue&&Qe<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>$e(n),20)),w=n.state.tr.delete(x,v),C=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(E=Am(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))w=n.state.tr,E.type=="add"?w.addMark(x,v,E.mark):w.removeMark(x,v,E.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",A=>A(n,x,v,T)))return;w=n.state.tr.insertText(T,x,v)}}if(w||(w=n.state.tr.replace(x,v,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let T=hc(n,w.doc,c.sel);T&&!(oe&&Ce&&n.composing&&T.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(T.head==x||T.head==w.mapping.map(v)-1)||ue&&T.empty&&T.head==x)&&w.setSelection(T)}C&&w.ensureMarks(C),i&&w.setMeta("composition",i),n.dispatch(w.scrollIntoView())}function hc(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:ci(n,e.resolve(t.anchor),e.resolve(t.head))}function Am(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,s=t,i=o,r,l,a;for(let d=0;d<o.length;d++)s=o[d].removeFromSet(s);for(let d=0;d<t.length;d++)i=t[d].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],r="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&i.length==1)l=i[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(k.from(c).eq(n))return{mark:l,type:r}}function Em(n,e,t,o,s){if(t-e<=s.pos-o.pos||wi(o,!0,!1)<s.pos)return!1;let i=n.resolve(e);if(!o.parent.isTextblock){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let r=n.resolve(wi(i,!0,!0));return!r.parent.isTextblock||r.pos>t||wi(r,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(r.parent.content)}function wi(n,e,t){let o=n.depth,s=e?n.end():n.pos;for(;o>0&&(e||n.indexAfter(o)==n.node(o).childCount);)o--,s++,e=!1;if(t){let i=n.node(o).maybeChild(n.indexAfter(o));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function Om(n,e,t,o,s){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:r,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,i-Math.min(r,l));o-=r+a-i}if(r<i&&n.size<e.size){let a=o<=i&&o>=r?i-o:0;i-=a,i&&i<e.size&&fc(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-r),r=i}else if(l<i){let a=o<=i&&o>=l?i-o:0;i-=a,i&&i<n.size&&fc(n.textBetween(i-1,i+1))&&(i+=a?1:-1),r=i+(r-l),l=i}return{start:i,endA:r,endB:l}}function fc(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 Nm{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 Up,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(bc),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=gc(this),mc(this),this.nodeViews=yc(this),this.docView=Ca(this.state.doc,pc(this),xi(this),this.dom,this),this.domObserver=new vm(this,(o,s,i,r)=>Mm(this,o,s,i,r)),this.domObserver.start(),Zp(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&pi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(bc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let o in this._props)t[o]=this._props[o];t.state=this.state;for(let o in e)t[o]=e[o];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var o;let s=this.state,i=!1,r=!1;e.storedMarks&&this.composing&&(tc(this),r=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=yc(this);Im(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&pi(this),this.editable=gc(this),mc(this);let a=xi(this),c=pc(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(r=!0);let h=d=="preserve"&&r&&this.dom.style.overflowAnchor==null&&dp(this);if(r){this.domObserver.stop();let f=u&&(ue||oe)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&Pm(s.selection,e.selection);if(u){let p=oe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=cm(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ca(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Dp(this))?$e(this,f):(Ra(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((o=this.dragging)===null||o===void 0)&&o.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():h&&up(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof N){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&da(this,t.getBoundingClientRect(),e)}else da(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 o=this.directPlugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let o=this.state.plugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let o=this.pluginViews[t];o.update&&o.update(this,e)}}updateDraggedNode(e,t){let o=e.node,s=-1;if(this.state.doc.nodeAt(o.from)==o.node)s=o.from;else{let i=o.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==o.node&&(s=i)}this.dragging=new oc(e.slice,e.move,s<0?void 0:N.create(this.state.doc,s))}someProp(e,t){let o=this._props&&this._props[e],s;if(o!=null&&(s=t?t(o):o))return s;for(let r=0;r<this.directPlugins.length;r++){let l=this.directPlugins[r].props[e];if(l!=null&&(s=t?t(l):l))return s}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let l=i[r].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(ue){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&hp(this.dom),$e(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 yp(this,e)}coordsAtPos(e,t=1){return ga(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,o=-1){let s=this.docView.posFromDOM(e,t,o);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return Sp(this,t||this.state,e)}pasteHTML(e,t){return Vn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Vn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Yp(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],xi(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Qf())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Qp(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?re&&this.root.nodeType===11&&sp(this.dom.ownerDocument)==this.dom&&wm(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function pc(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 o in t)o=="class"?e.class+=" "+t[o]:o=="style"?e.style=(e.style?e.style+";":"")+t[o]:!e[o]&&o!="contenteditable"&&o!="nodeName"&&(e[o]=String(t[o]))}),e.translate||(e.translate="no"),[he.node(0,n.state.doc.content.size,e)]}function mc(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:he.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function gc(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Pm(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 yc(n){let e=Object.create(null);function t(o){for(let s in o)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=o[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Im(n,e){let t=0,o=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)o++;return t!=o}function bc(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 Si,Ci;if(typeof WeakMap<"u"){let n=new WeakMap;Si=e=>n.get(e),Ci=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Si=o=>{for(let s=0;s<n.length;s+=2)if(n[s]==o)return n[s+1]},Ci=(o,s)=>(t==10&&(t=0),n[t++]=o,n[t++]=s)}var G=class{constructor(n,e,t,o){this.width=n,this.height=e,this.map=t,this.problems=o}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const o=e%this.width,s=e/this.width|0;let i=o+1,r=s+1;for(let l=1;i<this.width&&this.map[e+l]==t;l++)i++;for(let l=1;r<this.height&&this.map[e+this.width*l]==t;l++)r++;return{left:o,top:s,right:i,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:o,right:s,top:i,bottom:r}=this.findCell(n);return e=="horiz"?(t<0?o==0:s==this.width)?null:this.map[i*this.width+(t<0?o-1:s)]:(t<0?i==0:r==this.height)?null:this.map[o+this.width*(t<0?i-1:r)]}rectBetween(n,e){const{left:t,right:o,top:s,bottom:i}=this.findCell(n),{left:r,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,r),top:Math.min(s,a),right:Math.max(o,l),bottom:Math.max(i,c)}}cellsInRect(n){const e=[],t={};for(let o=n.top;o<n.bottom;o++)for(let s=n.left;s<n.right;s++){const i=o*this.width+s,r=this.map[i];t[r]||(t[r]=!0,!(s==n.left&&s&&this.map[i-1]==r||o==n.top&&o&&this.map[i-this.width]==r)&&e.push(r))}return e}positionAt(n,e,t){for(let o=0,s=0;;o++){const i=s+t.child(o).nodeSize;if(o==n){let r=e+n*this.width;const l=(n+1)*this.width;for(;r<l&&this.map[r]<s;)r++;return r==l?i-1:this.map[r]}s=i}}static get(n){return Si(n)||Ci(n,Rm(n))}};function Rm(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=Dm(n),t=n.childCount,o=[];let s=0,i=null;const r=[];for(let c=0,d=e*t;c<d;c++)o[c]=0;for(let c=0,d=0;c<t;c++){const u=n.child(c);d++;for(let p=0;;p++){for(;s<o.length&&o[s]!=0;)s++;if(p==u.childCount)break;const m=u.child(p),{colspan:g,rowspan:y,colwidth:S}=m.attrs;for(let b=0;b<y;b++){if(b+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:y-b});break}const x=s+b*e;for(let v=0;v<g;v++){o[x+v]==0?o[x+v]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:g-v});const w=S&&S[v];if(w){const C=(x+v)%e*2,E=r[C];E==null||E!=w&&r[C+1]==1?(r[C]=w,r[C+1]=1):E==w&&r[C+1]++}}}s+=g,d+=m.nodeSize}const h=(c+1)*e;let f=0;for(;s<h;)o[s++]==0&&f++;f&&(i||(i=[])).push({type:"missing",row:c,n:f}),d++}const l=new G(e,t,o,i);let a=!1;for(let c=0;!a&&c<r.length;c+=2)r[c]!=null&&r[c+1]<t&&(a=!0);return a&&zm(l,r,n),l}function Dm(n){let e=-1,t=!1;for(let o=0;o<n.childCount;o++){const s=n.child(o);let i=0;if(t)for(let r=0;r<o;r++){const l=n.child(r);for(let a=0;a<l.childCount;a++){const c=l.child(a);r+c.attrs.rowspan>o&&(i+=c.attrs.colspan)}}for(let r=0;r<s.childCount;r++){const l=s.child(r);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function zm(n,e,t){n.problems||(n.problems=[]);const o={};for(let s=0;s<n.map.length;s++){const i=n.map[s];if(o[i])continue;o[i]=!0;const r=t.nodeAt(i);if(!r)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=r.attrs;for(let c=0;c<a.colspan;c++){const d=(s+c)%n.width,u=e[d*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=Lm(a)))[c]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function Lm(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function vc(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),o=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(r=>Number(r)):null,s=Number(n.getAttribute("colspan")||1),i={colspan:s,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:o&&o.length==s?o:null};for(const r in e){const l=e[r].getFromDOM,a=l&&l(n);a!=null&&(i[r]=a)}return i}function xc(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 o in e){const s=e[o].setDOMAttr;s&&s(n.attrs[o],t)}return t}function Vm(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const o in e)t[o]={default:e[o].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:o=>vc(o,e)}],toDOM(o){return["td",xc(o,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:o=>vc(o,e)}],toDOM(o){return["th",xc(o,e),0]}}}}function Re(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const o=n.nodes[t],s=o.spec.tableRole;s&&(e[s]=o)}}return e}var rt=new An("selectingCells");function Hn(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 _o(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 ki(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=Hn(e.$head)||Bm(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Bm(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function Ti(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function Hm(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Mi(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function wc(n,e,t){const o=n.node(-1),s=G.get(o),i=n.start(-1),r=s.nextCell(n.pos-i,e,t);return r==null?null:n.node(0).resolve(i+r)}function dn(n,e,t=1){const o={...n,colspan:n.colspan-t};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(e,t),o.colwidth.some(s=>s>0)||(o.colwidth=null)),o}var K=class qe extends I{constructor(e,t=e){const o=e.node(-1),s=G.get(o),i=e.start(-1),r=s.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=s.cellsInRect(r).filter(d=>d!=t.pos-i);a.unshift(t.pos-i);const c=a.map(d=>{const u=o.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const h=i+d+1;return new Rl(l.resolve(h),l.resolve(h+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const o=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(Ti(o)&&Ti(s)&&Mi(o,s)){const i=this.$anchorCell.node(-1)!=o.node(-1);return i&&this.isRowSelection()?qe.rowSelection(o,s):i&&this.isColSelection()?qe.colSelection(o,s):new qe(o,s)}return R.between(o,s)}content(){const e=this.$anchorCell.node(-1),t=G.get(e),o=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),i={},r=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let d=a*t.width+s.left,u=s.left;u<s.right;u++,d++){const h=t.map[d];if(i[h])continue;i[h]=!0;const f=t.findCell(h);let p=e.nodeAt(h);if(!p)throw RangeError(`No cell with offset ${h} found`);const m=s.left-f.left,g=f.right-s.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=dn(y,0,m)),g>0&&(y=dn(y,y.colspan-g,g)),f.left<s.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<s.top||f.bottom>s.bottom){const y={...p.attrs,rowspan:Math.min(f.bottom,s.bottom)-Math.max(f.top,s.top)};f.top<s.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}r.push(e.child(a).copy(k.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:r;return new M(k.from(l),1,1)}replace(e,t=M.empty){const o=e.steps.length,s=this.ranges;for(let r=0;r<s.length;r++){const{$from:l,$to:a}=s[r],c=e.mapping.slice(o);e.replace(c.map(l.pos),c.map(a.pos),r?M.empty:t)}const i=I.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new M(k.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),o=G.get(t),s=this.$anchorCell.start(-1),i=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let r=0;r<i.length;r++)e(t.nodeAt(i[r]),s+i[r])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const o=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const o=e.node(-1),s=G.get(o),i=e.start(-1),r=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return r.top<=l.top?(r.top>0&&(e=a.resolve(i+s.map[r.left])),l.bottom<s.height&&(t=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+s.map[l.left])),r.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+r.right-1]))),new qe(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=G.get(e),o=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-o),i=t.colCount(this.$headCell.pos-o);if(Math.min(s,i)>0)return!1;const r=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(r,l)==t.width}eq(e){return e instanceof qe&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const o=e.node(-1),s=G.get(o),i=e.start(-1),r=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return r.left<=l.left?(r.left>0&&(e=a.resolve(i+s.map[r.top*s.width])),l.right<s.width&&(t=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+s.map[l.top*s.width])),r.right<s.width&&(e=a.resolve(i+s.map[s.width*(r.top+1)-1]))),new qe(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new qe(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){return new qe(e.resolve(t),e.resolve(o))}getBookmark(){return new $m(this.$anchorCell.pos,this.$headCell.pos)}};K.prototype.visible=!1,I.jsonID("cell",K);var $m=class sd{constructor(e,t){this.anchor=e,this.head=t}map(e){return new sd(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),o=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&o.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&o.index()<o.parent.childCount&&Mi(t,o)?new K(t,o):I.near(o,1)}};function Fm(n){if(!(n.selection instanceof K))return null;const e=[];return n.selection.forEachCell((t,o)=>{e.push(he.node(o,o+t.nodeSize,{class:"selectedCell"}))}),W.create(n.doc,e)}function _m({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,o=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,o--);return t==o&&/row|table/.test(n.node(s).type.spec.tableRole)}function Wm({$from:n,$to:e}){let t,o;for(let s=n.depth;s>0;s--){const i=n.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){o=i;break}}return t!==o&&e.parentOffset===0}function qm(n,e,t){const o=(e||n).selection,s=(e||n).doc;let i,r;if(o instanceof N&&(r=o.node.type.spec.tableRole)){if(r=="cell"||r=="header_cell")i=K.create(s,o.from);else if(r=="row"){const l=s.resolve(o.from+1);i=K.rowSelection(l,l)}else if(!t){const l=G.get(o.node),a=o.from+1,c=a+l.map[l.width*l.height-1];i=K.create(s,a+1,c)}}else o instanceof R&&_m(o)?i=R.create(s,o.from):o instanceof R&&Wm(o)&&(i=R.create(s,o.$from.start(),o.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var Gm=new An("fix-tables");function Sc(n,e,t,o){const s=n.childCount,i=e.childCount;e:for(let r=0,l=0;r<i;r++){const a=e.child(r);for(let c=l,d=Math.min(s,r+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}o(a,t),l<s&&n.child(l).sameMarkup(a)?Sc(n.child(l),a,t+1,o):a.nodesBetween(0,a.content.size,o,t+1),t+=a.nodeSize}}function jm(n,e){let t;const o=(s,i)=>{s.type.spec.tableRole=="table"&&(t=Km(n,s,i,t))};return e?e.doc!=n.doc&&Sc(e.doc,n.doc,0,o):n.doc.descendants(o),t}function Km(n,e,t,o){const s=G.get(e);if(!s.problems)return o;o||(o=n.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let h=0;h<u.rowspan;h++)i[c.row+h]+=c.n;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,dn(u,u.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;o.setNodeMarkup(o.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;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}}let r,l;for(let a=0;a<i.length;a++)i[a]&&(r==null&&(r=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const d=e.child(a),u=c+d.nodeSize,h=i[a];if(h>0){let f="cell";d.firstChild&&(f=d.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<h;g++){const y=Re(n.schema)[f].createAndFill();y&&p.push(y)}const m=(a==0||r==a-1)&&l==a?c+1:u-1;o.insert(o.mapping.map(m),p)}c=u}return o.setMeta(Gm,{fixTables:!0})}function Cc(n){const e=n.selection,t=ki(n),o=t.node(-1),s=t.start(-1),i=G.get(o);return{...e instanceof K?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(t.pos-s),tableStart:s,map:i,table:o}}function Jm(n){return function(e,t){if(!_o(e))return!1;if(t){const o=Re(e.schema),s=Cc(e),i=e.tr,r=s.map.cellsInRect(n=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:n=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=r.map(a=>s.table.nodeAt(a));for(let a=0;a<r.length;a++)l[a].type==o.header_cell&&i.setNodeMarkup(s.tableStart+r[a],o.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<r.length;a++)i.setNodeMarkup(s.tableStart+r[a],o.header_cell,l[a].attrs);t(i)}return!0}}function kc(n,e,t){const o=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<o.length;s++){const i=e.table.nodeAt(o[s]);if(i&&i.type!==t.header_cell)return!1}return!0}function Ai(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Jm(n):function(t,o){if(!_o(t))return!1;if(o){const s=Re(t.schema),i=Cc(t),r=t.tr,l=kc("row",i,s),a=kc("column",i,s),d=(n==="column"?l:n==="row"?a:!1)?1:0,u=n=="column"?{left:0,top:d,right:1,bottom:i.map.height}:n=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,h=n=="column"?a?s.cell:s.header_cell:n=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(u).forEach(f=>{const p=f+i.tableStart,m=r.doc.nodeAt(p);m&&r.setNodeMarkup(p,h,m.attrs)}),o(r)}return!0}}Ai("row",{useDeprecatedLogic:!0}),Ai("column",{useDeprecatedLogic:!0}),Ai("cell",{useDeprecatedLogic:!0});function Um(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let o=n.index(-1)-1,s=n.before();o>=0;o--){const i=n.node(-1).child(o),r=i.lastChild;if(r)return s-1-r.nodeSize;s-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let o=n.indexAfter(-1),s=n.after();o<t.childCount;o++){const i=t.child(o);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Tc(n){return function(e,t){if(!_o(e))return!1;const o=Um(ki(e),n);if(o==null)return!1;if(t){const s=e.doc.resolve(o);t(e.tr.setSelection(R.between(s,Hm(s))).scrollIntoView())}return!0}}function Wo(n,e){const t=n.selection;if(!(t instanceof K))return!1;if(e){const o=n.tr,s=Re(n.schema).cell.createAndFill().content;t.forEachCell((i,r)=>{i.content.eq(s)||o.replace(o.mapping.map(r+1),o.mapping.map(r+i.nodeSize-1),new M(s,0,0))}),o.docChanged&&e(o)}return!0}function Zm(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:o}=n;for(;e.childCount==1&&(t>0&&o>0||e.child(0).type.spec.tableRole=="table");)t--,o--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,r=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),u=a<e.childCount-1?0:Math.max(0,o-1);(d||u)&&(c=Ei(Re(r).row,new M(c,d,u)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||o?Ei(Re(r).row,new M(e,t,o)).content:e);else return null;return Ym(r,l)}function Ym(n,e){const t=[];for(let s=0;s<e.length;s++){const i=e[s];for(let r=i.childCount-1;r>=0;r--){const{rowspan:l,colspan:a}=i.child(r).attrs;for(let c=s;c<s+l;c++)t[c]=(t[c]||0)+a}}let o=0;for(let s=0;s<t.length;s++)o=Math.max(o,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(k.empty),t[s]<o){const i=Re(n).cell.createAndFill(),r=[];for(let l=t[s];l<o;l++)r.push(i);e[s]=e[s].append(k.from(r))}return{height:e.length,width:o,rows:e}}function Ei(n,e){const t=n.createAndFill();return new Il(t).replace(0,t.content.size,e).doc}function Xm({width:n,height:e,rows:t},o,s){if(n!=o){const i=[],r=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=i[l]||0,u=0;d<o;u++){let h=a.child(u%a.childCount);d+h.attrs.colspan>o&&(h=h.type.createChecked(dn(h.attrs,h.attrs.colspan,d+h.attrs.colspan-o),h.content)),c.push(h),d+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)i[l+f]=(i[l+f]||0)+h.attrs.colspan}r.push(k.from(c))}t=r,n=o}if(e!=s){const i=[];for(let r=0,l=0;r<s;r++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);r+u.attrs.rowspan>s&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,s-u.attrs.rowspan)},u.content)),a.push(u)}i.push(k.from(a))}t=i,e=s}return{width:n,height:e,rows:t}}function Qm(n,e,t,o,s,i,r){const l=n.doc.type.schema,a=Re(l);let c,d;if(s>e.width)for(let u=0,h=0;u<e.height;u++){const f=t.child(u);h+=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<s;g++)p.push(m);n.insert(n.mapping.slice(r).map(h-1+o),p)}if(i>e.height){const u=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,s);p++){const g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,k.from(u)),f=[];for(let p=e.height;p<i;p++)f.push(h);n.insert(n.mapping.slice(r).map(o+t.nodeSize-2),f)}return!!(c||d)}function Mc(n,e,t,o,s,i,r,l){if(r==0||r==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const d=r*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const h=t.nodeAt(u),{top:f,left:p}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(l).map(u+o),null,{...h.attrs,rowspan:r-f}),n.insert(n.mapping.slice(l).map(e.positionAt(r,p,t)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-r})),c+=h.attrs.colspan-1}}return a}function Ac(n,e,t,o,s,i,r,l){if(r==0||r==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const d=c*e.width+r,u=e.map[d];if(e.map[d-1]==u){a=!0;const h=t.nodeAt(u),f=e.colCount(u),p=n.mapping.slice(l).map(u+o);n.setNodeMarkup(p,null,dn(h.attrs,r-f,h.attrs.colspan-(r-f))),n.insert(p+h.nodeSize,h.type.createAndFill(dn(h.attrs,0,r-f))),c+=h.attrs.rowspan-1}}return a}function Ec(n,e,t,o,s){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let r=G.get(i);const{top:l,left:a}=o,c=a+s.width,d=l+s.height,u=n.tr;let h=0;function f(){if(i=t?u.doc.nodeAt(t-1):u.doc,!i)throw new Error("No table found");r=G.get(i),h=u.mapping.maps.length}Qm(u,r,i,t,c,d,h)&&f(),Mc(u,r,i,t,a,c,l,h)&&f(),Mc(u,r,i,t,a,c,d,h)&&f(),Ac(u,r,i,t,l,d,a,h)&&f(),Ac(u,r,i,t,l,d,c,h)&&f();for(let p=l;p<d;p++){const m=r.positionAt(p,a,i),g=r.positionAt(p,c,i);u.replace(u.mapping.slice(h).map(m+t),u.mapping.slice(h).map(g+t),new M(s.rows[p-l],0,0))}f(),u.setSelection(new K(u.doc.resolve(t+r.positionAt(l,a,i)),u.doc.resolve(t+r.positionAt(d-1,c-1,i)))),e(u)}var eg=sa({ArrowLeft:Go("horiz",-1),ArrowRight:Go("horiz",1),ArrowUp:Go("vert",-1),ArrowDown:Go("vert",1),"Shift-ArrowLeft":jo("horiz",-1),"Shift-ArrowRight":jo("horiz",1),"Shift-ArrowUp":jo("vert",-1),"Shift-ArrowDown":jo("vert",1),Backspace:Wo,"Mod-Backspace":Wo,Delete:Wo,"Mod-Delete":Wo});function qo(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Go(n,e){return(t,o,s)=>{if(!s)return!1;const i=t.selection;if(i instanceof K)return qo(t,o,I.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const r=Oc(s,n,e);if(r==null)return!1;if(n=="horiz")return qo(t,o,I.near(t.doc.resolve(i.head+e),e));{const l=t.doc.resolve(r),a=wc(l,n,e);let c;return a?c=I.near(a,1):e<0?c=I.near(t.doc.resolve(l.before(-1)),-1):c=I.near(t.doc.resolve(l.after(-1)),1),qo(t,o,c)}}}function jo(n,e){return(t,o,s)=>{if(!s)return!1;const i=t.selection;let r;if(i instanceof K)r=i;else{const a=Oc(s,n,e);if(a==null)return!1;r=new K(t.doc.resolve(a))}const l=wc(r.$headCell,n,e);return l?qo(t,o,new K(r.$anchorCell,l)):!1}}function tg(n,e){const t=n.state.doc,o=Hn(t.resolve(e));return o?(n.dispatch(n.state.tr.setSelection(new K(o))),!0):!1}function ng(n,e,t){if(!_o(n.state))return!1;let o=Zm(t);const s=n.state.selection;if(s instanceof K){o||(o={width:1,height:1,rows:[k.from(Ei(Re(n.state.schema).cell,t))]});const i=s.$anchorCell.node(-1),r=s.$anchorCell.start(-1),l=G.get(i).rectBetween(s.$anchorCell.pos-r,s.$headCell.pos-r);return o=Xm(o,l.right-l.left,l.bottom-l.top),Ec(n.state,n.dispatch,r,l,o),!0}else if(o){const i=ki(n.state),r=i.start(-1);return Ec(n.state,n.dispatch,r,G.get(i.node(-1)).findCell(i.pos-r),o),!0}else return!1}function og(n,e){var t;if(e.ctrlKey||e.metaKey)return;const o=Nc(n,e.target);let s;if(e.shiftKey&&n.state.selection instanceof K)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(s=Hn(n.state.selection.$anchor))!=null&&((t=Oi(n,e))==null?void 0:t.pos)!=s.pos)i(s,e),e.preventDefault();else if(!o)return;function i(a,c){let d=Oi(n,c);const u=rt.getState(n.state)==null;if(!d||!Mi(a,d))if(u)d=a;else return;const h=new K(a,d);if(u||!n.state.selection.eq(h)){const f=n.state.tr.setSelection(h);u&&f.setMeta(rt,a.pos),n.dispatch(f)}}function r(){n.root.removeEventListener("mouseup",r),n.root.removeEventListener("dragstart",r),n.root.removeEventListener("mousemove",l),rt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(rt,-1))}function l(a){const c=a,d=rt.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(Nc(n,c.target)!=o&&(u=Oi(n,e),!u))return r();u&&i(u,c)}n.root.addEventListener("mouseup",r),n.root.addEventListener("dragstart",r),n.root.addEventListener("mousemove",l)}function Oc(n,e,t){if(!(n.state.selection instanceof R))return null;const{$head:o}=n.state.selection;for(let s=o.depth-1;s>=0;s--){const i=o.node(s);if((t<0?o.index(s):o.indexAfter(s))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=o.before(s),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Nc(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Oi(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Hn(n.state.doc.resolve(t.pos)):null}var sg=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")),Ni(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,Ni(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Ni(n,e,t,o,s,i){var r;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let u=0,h=0;u<d.childCount;u++){const{colspan:f,colwidth:p}=d.child(u).attrs;for(let m=0;m<f;m++,h++){const g=s==h?i:p&&p[m],y=g?g+"px":"";if(l+=g||o,g||(a=!1),c)c.style.width!=y&&(c.style.width=y),c=c.nextSibling;else{const S=document.createElement("col");S.style.width=y,e.appendChild(S)}}}for(;c;){const u=c.nextSibling;(r=c.parentNode)==null||r.removeChild(c),c=u}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var me=new An("tableColumnResizing");function ig({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:o=sg,lastColumnResizable:s=!0}={}){const i=new Mn({key:me,state:{init(r,l){var a,c;const d=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,u=Re(l.schema).table.name;return o&&d&&(d[u]=(h,f)=>new o(h,t,f)),new rg(-1,!1)},apply(r,l){return l.apply(r)}},props:{attributes:r=>{const l=me.getState(r);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(r,l)=>{lg(r,l,n,s)},mouseleave:r=>{ag(r)},mousedown:(r,l)=>{cg(r,l,e,t)}},decorations:r=>{const l=me.getState(r);if(l&&l.activeHandle>-1)return pg(r,l.activeHandle)},nodeViews:{}}});return i}var rg=class Xo{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,o=e.getMeta(me);if(o&&o.setHandle!=null)return new Xo(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new Xo(t.activeHandle,o.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);return Ti(e.doc.resolve(s))||(s=-1),new Xo(s,t.dragging)}return t}};function lg(n,e,t,o){const s=me.getState(n.state);if(s&&!s.dragging){const i=ug(e.target);let r=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?r=Pc(n,e,"left",t):a-e.clientX<=t&&(r=Pc(n,e,"right",t))}if(r!=s.activeHandle){if(!o&&r!==-1){const l=n.state.doc.resolve(r),a=l.node(-1),c=G.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Rc(n,r)}}}function ag(n){const e=me.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Rc(n,-1)}function cg(n,e,t,o){var s;const i=(s=n.dom.ownerDocument.defaultView)!=null?s:window,r=me.getState(n.state);if(!r||r.activeHandle==-1||r.dragging)return!1;const l=n.state.doc.nodeAt(r.activeHandle),a=dg(n,r.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(me,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const h=me.getState(n.state);h!=null&&h.dragging&&(hg(n,h.activeHandle,Ic(h.dragging,u,t)),n.dispatch(n.state.tr.setMeta(me,{setDragging:null})))}function d(u){if(!u.which)return c(u);const h=me.getState(n.state);if(h&&h.dragging){const f=Ic(h.dragging,u,t);Dc(n,h.activeHandle,f,o)}}return Dc(n,r.activeHandle,a,o),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function dg(n,e,{colspan:t,colwidth:o}){const s=o&&o[o.length-1];if(s)return s;const i=n.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=t;if(o)for(let c=0;c<t;c++)o[c]&&(l-=o[c],a--);return l/a}function ug(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Pc(n,e,t,o){const s=t=="right"?-o:o,i=n.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:r}=i,l=Hn(n.state.doc.resolve(r));if(!l)return-1;if(t=="right")return l.pos;const a=G.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 Ic(n,e,t){const o=e.clientX-n.startX;return Math.max(t,n.startWidth+o)}function Rc(n,e){n.dispatch(n.state.tr.setMeta(me,{setHandle:e}))}function hg(n,e,t){const o=n.state.doc.resolve(e),s=o.node(-1),i=G.get(s),r=o.start(-1),l=i.colCount(o.pos-r)+o.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){const d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;const u=i.map[d],h=s.nodeAt(u).attrs,f=h.colspan==1?0:l-i.colCount(u);if(h.colwidth&&h.colwidth[f]==t)continue;const p=h.colwidth?h.colwidth.slice():fg(h.colspan);p[f]=t,a.setNodeMarkup(r+u,null,{...h,colwidth:p})}a.docChanged&&n.dispatch(a)}function Dc(n,e,t,o){const s=n.state.doc.resolve(e),i=s.node(-1),r=s.start(-1),l=G.get(i).colCount(s.pos-r)+s.nodeAfter.attrs.colspan-1;let a=n.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Ni(i,a.firstChild,a,o,l,t)}function fg(n){return Array(n).fill(0)}function pg(n,e){var t;const o=[],s=n.doc.resolve(e),i=s.node(-1);if(!i)return W.empty;const r=G.get(i),l=s.start(-1),a=r.colCount(s.pos-l)+s.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 u=r.map[d],h=l+u+i.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(t=me.getState(n))!=null&&t.dragging&&o.push(he.node(l+u,l+u+i.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),o.push(he.widget(h,f))}}return W.create(n.doc,o)}function mg({allowTableNodeSelection:n=!1}={}){return new Mn({key:rt,state:{init(){return null},apply(e,t){const o=e.getMeta(rt);if(o!=null)return o==-1?null:o;if(t==null||!e.docChanged)return t;const{deleted:s,pos:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:Fm,handleDOMEvents:{mousedown:og},createSelectionBetween(e){return rt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:tg,handleKeyDown:eg,handlePaste:ng},appendTransaction(e,t,o){return qm(o,jm(o,t),n)}})}const $n=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},zc="data-gs-mrk-fs",Lc="data-gs-ib",Ko="data-gs-ifrg",Fe="attrs",Vc={[Fe]:{default:"{}"}},_e={[Fe]:{default:{}}},Bc=n=>({[Fe]:JSON.stringify($n(n))}),We=n=>({attrs:$n(n)}),Fn=n=>e=>[n,e.attrs.attrs,0],lt=n=>n.attrs[Fe]?JSON.parse(n.attrs[Fe]):{},gg={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${Ko}]`,getAttrs:We}],toDOM:()=>["span",{[Ko]:""},0]},div:{group:"block",content:"inline*",attrs:_e,parseDOM:[{tag:"div",getAttrs:We}],toDOM:Fn("div")},paragraph:{group:"block",content:"inline*",attrs:_e,parseDOM:[{tag:"p",getAttrs:We}],toDOM:Fn("p")},orderedList:{group:"block",content:"listItem+",attrs:_e,parseDOM:[{tag:"ol",getAttrs:We}],toDOM:Fn("ol")},bulletList:{group:"block",content:"listItem+",attrs:_e,parseDOM:[{tag:"ul",getAttrs:We}],toDOM:Fn("ul")},listItem:{content:"block*",group:"block",attrs:_e,parseDOM:[{tag:"li",getAttrs:We}],toDOM:Fn("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:_e,parseDOM:[{tag:"pre",getAttrs:We}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:_e,parseDOM:[{tag:"img[src]",getAttrs:We}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${Lc}]`}],toDOM(){return["br",{[Lc]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:_e,parseDOM:[{tag:"br",getAttrs:We}],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:$n(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...Vm({tableGroup:"block",cellContent:"block+",cellAttributes:{[Fe]:{default:_e[Fe].default,getFromDOM:$n,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:$n(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},_n=(n,e)=>({attrs:Vc,parseDOM:n.map(t=>({tag:t,getAttrs:Bc})),toDOM:e}),yg={strong:_n(["strong","b"],n=>["b",lt(n)]),link:_n(["a"],n=>["a",lt(n),0]),em:_n(["em","i"],n=>["em",lt(n)]),underline:_n(["u"],n=>["u",lt(n),0]),strikethrough:_n(["s"],n=>["s",lt(n),0]),font_size:{attrs:{...Vc,size:{default:null}},parseDOM:[{tag:`span[${zc}]`,getAttrs:n=>({...Bc(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...lt(n),[zc]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},Hc=new Lh({nodes:gg,marks:yg}),Jo=new WeakMap,Pi=new WeakMap,bg=(n,e)=>{Jo.set(n,e),Pi.set(e,n)},vg=(n,e)=>{Jo.delete(n),Pi.delete(e)},Ii=n=>Jo.get(n),xg=n=>Pi.get(n),$c=n=>{var t;const e=xg(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},wg=n=>n.dispatchEvent(new CustomEvent("input"));function Sg(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(Ko)){if(t.getAttribute("style")){t.removeAttribute(Ko);return}const o=t.parentElement;if(o){for(;t.firstChild;)o.insertBefore(t.firstChild,t);o.removeChild(t)}}else Array.from(t.children).forEach(o=>e(o))};e(n)}function Cg(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,o=d=>n.getSelectedAll().includes(d),s=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),i=d=>d.isChildOf("text"),r=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{o(d)&&s(d)&&!r(d)&&l(d,u)},c=(d,u)=>{if(o(d)&&!s(d)&&i(d)){const h=d.parents().find(f=>f.isInstanceOf("text"));h&&(l(h,u),setTimeout(()=>n.select(h),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const kg=(n,e)=>{const t=Tg(n);return t&&Dg(t)?Mg(n,e):t?Kl(()=>({type:n.schema.nodes.div}))(n,e):!1};function Tg(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 Mg(n,e){const{selection:t,schema:o,tr:s}=n;s.split(t.from,1);const i=t.from+1,r=s.doc.nodeAt(i),l={...r.attrs.attrs,id:void 0},a=r.textContent.length>0,c=r.textContent.length||0,d=r.textContent||" ",u=o.text(d),h=o.nodes.div.create(l,a?u:[],[]);return s.replaceRangeWith(i,i+c+2,h),s.setSelection(R.create(s.doc,i+1)),e==null||e(s.scrollIntoView()),!0}function Ag(n,e,t){const{state:o,dispatch:s}=n,{selection:i,tr:r}=o,l=(a,c,d)=>{const u={};return a.split(";").forEach(h=>{const[f,p]=h.split(":").map(m=>m.trim());f&&(u[f]=p)}),u[c]=d,Object.entries(u).map(([h,f])=>`${h}: ${f}`).join("; ")};if(!i.empty||t)r.doc.nodesBetween(i.from,i.to,(a,c)=>{var d,u;if(a.type===o.schema.nodes.image){const h=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:h}})}else if(a.type.isBlock){const h=l(((u=a.attrs.attrs)==null?void 0:u.style)||"","text-align",e);Fc(a)?r.setBlockType(i.from,void 0,o.schema.nodes.div,{attrs:{style:h}}):r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:h}})}});else{const a=o.doc.resolve(i.from),c=a.start(a.depth),d=o.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const u=l(d.attrs.style||"","text-align",e);r.setNodeMarkup(c,void 0,{...d.attrs,style:u})}}r.docChanged&&s(r.scrollIntoView())}const Wn=(n,e)=>{const{from:t,to:o}=n.selection;let s=!1;return n.doc.nodesBetween(t,o,i=>{if(s)return!1;i.marks.some(r=>r.type===e)&&(s=!0)}),s};function Eg(n,e,t="_blank"){const{state:o,dispatch:s}=n,{schema:i,selection:r,tr:l}=o,a=i.marks.link;try{const c=a.create({[Fe]:JSON.stringify({href:e,target:t})});l.addMark(r.from,r.to,c),s(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function Og(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:i}=t;if(s.empty)return;const r=t.schema.marks.font_size;if(!r){console.error("Font size mark is not defined in the schema.");return}i.addMark(s.from,s.to,r.create({size:e})),o(i.scrollIntoView())}const It=(n,e)=>{const{doc:t,selection:o}=n.state,s=t.resolve(o.from);for(let i=s.depth;i>0;i--){const r=s.node(i);if(e(r))return{pos:i>0?s.before(i):0,start:s.start(i),depth:i,node:r}}},Ng=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,o])=>(t=t.replace(/-./g,s=>s.toUpperCase()[1]).trim(),e[t]=`${o}`.trim(),e),{});function Pg(...n){return(e,t)=>{const o=r=>{e=e.apply(r),t==null||t(r)},s=n.pop();return n.reduce((r,l)=>r||l(e,o),!1)&&s!==void 0&&s(e,t)}}const Ig=(n,e)=>{const{state:t,dispatch:o}=n;if(e!=null&&e.event){const{event:s}=e,i=n.posAtCoords({left:s.clientX,top:s.clientY});i!=null&&i.pos&&o(t.tr.setSelection(R.create(t.doc,i.pos)))}else Jl(t,o);setTimeout(()=>setTimeout(()=>n.focus()))},Ri=n=>n.isBlock,Fc=n=>n.type.name==="inlineFragment",Rg=n=>Ri(n)&&!Fc(n),_c=n=>n.type.name==="bulletList",Wc=n=>n.type.name==="orderedList",Dg=n=>n.type.name==="heading",zg=n=>_c(n)||Wc(n),qc=(n,e)=>{var i,r;const t=(i=It(n,l=>l.type===e))==null?void 0:i.node,o=n.state.schema.nodes.listItem;let s;return t?s=Xs(o):(r=It(n,zg))!=null&&r.node?s=Pg(Xs(o),ia(e)):s=ia(e),s(n.state,n.dispatch)},Gc=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(o=>o.type.name===e)},Lg=n=>{var r;const{view:e,prop:t,editor:o,propCSS:s}=n,i=(r=It(e,Rg))==null?void 0:r.node;if(i){const l=i.attrs.attrs||{},a=Ng(l.style);if(t in a)return a[t]||"";if(l.id){const c=o.Components.getById(l.id);return((c==null?void 0:c.getStyle())||{})[s]||""}}return""},Vg=n=>{const{view:e,prop:t,markName:o,editor:s,propCSS:i}=n,r=Gc(e,o);if(r){const l=r.attrs;if(l[t])return l[t];if(l[Fe]){const a=lt(r).id;if(a){const c=s.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[i]||""}}}return""},jc=(n,e)=>{const{dispatch:t}=n,{nodes:o,marks:s}=n.state.schema;return{text:{selected:()=>{const{selection:i,doc:r}=n.state;return r.textBetween(i.from,i.to," ")},replace:(i,r={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(i));r.select&&(c=c.setSelection(R.create(c.doc,a,a+i.length))),t==null||t(c)}},bold:{toggle:()=>Ct(s.strong)(n.state,t),isActive:()=>Wn(n.state,s.strong)},italic:{toggle:()=>Ct(s.em)(n.state,t),isActive:()=>Wn(n.state,s.em)},underline:{toggle:()=>Ct(s.underline)(n.state,t),isActive:()=>Wn(n.state,s.underline)},strikethrough:{toggle:()=>Ct(s.strikethrough)(n.state,t),isActive:()=>Wn(n.state,s.strikethrough)},link:{get:()=>{const i=$c(n);if(i!=null&&i.is("link"))return i.getAttributes();{const r=Gc(n,"link");return r?lt(r):{}}},toggle:()=>Ct(s.link)(n.state,t),isActive:()=>Wn(n.state,s.link),create:i=>{const r=$c(n);r!=null&&r.is("link")?(r.addAttributes({href:i.url,target:i.target}),n.focus()):Eg(n,i.url,i.target)}},alignText:{get:()=>Lg({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:i=>Ag(n,i.value,!0)},fontSize:{get:()=>Vg({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:i=>Og(n,i.value)},image:{open(){const i="assetLayout",{state:r,dispatch:l}=n,{selection:a,doc:c}=r,d=c.textBetween(a.from,a.to," "),u={id:i,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:h=>{const f={alt:d,src:h.asset.getSrc()};l(r.tr.replaceSelectionWith(o.image.createAndFill({attrs:f})))}}};e.runCommand(B.layoutToggle,u)}},heading:{get:()=>{var r;const i=(r=It(n,Ri))==null?void 0:r.node;return`${(i==null?void 0:i.attrs.level)||""}`},set:({value:i})=>{var a;const{state:r}=n,l=(a=It(n,Ri))==null?void 0:a.node;Nf(r.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:i?parseInt(i,10):0})(r,t)}},listBullet:{isActive:()=>{var i;return!!((i=It(n,_c))!=null&&i.node)},toggle:()=>qc(n,o.bulletList)},listOrdered:{isActive:()=>{var i;return!!((i=It(n,Wc))!=null&&i.node)},toggle:()=>qc(n,o.orderedList)}}},ke="rte:selectionchange",ve={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>'},Bg=(n,e)=>{var a;const{editor:t,el:o}=n,s=Jo.get(o),i=jc(s,t),r={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:ve.bold,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:i.bold.isActive()})}},onClick:({setState:c})=>{i.bold.toggle(),c({active:i.bold.isActive()})}},italic:{id:"italic",icon:ve.italic,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:i.italic.isActive()})}},onClick:({setState:c})=>{i.italic.toggle(),c({active:i.italic.isActive()})}},underline:{id:"underline",icon:ve.underline,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:i.underline.isActive()})}},onClick:({setState:c})=>{i.underline.toggle(),c({active:i.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:ve.strikethrough,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:i.strikethrough.isActive()})}},onClick:({setState:c})=>{i.strikethrough.toggle(),c({active:i.strikethrough.isActive()})}},image:{id:"image",icon:ve.image,size:"s",type:"button",onClick:()=>i.image.open()},link:{id:"link",icon:ve.link,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:i.link.isActive(),disabled:s.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:u,y:h,width:f,height:p}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(B.layoutRemove,{id:m}),y=i.link.get(),S={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:u,y:h,w:f,h:p},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:b=>{b.preventDefault();const x=new FormData(b.currentTarget);i.link.create({url:x.get("url"),target:x.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:x})=>x({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:x})=>x({value:b})},{type:"row",style:{gap:10,justifyContent:"end"},children:[i.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{i.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(B.layoutToggle,S)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:ve.alignTextLeft},{id:"center",icon:ve.alignTextCenter},{id:"right",icon:ve.alignTextRight},{id:"justify",icon:ve.alignTextJustify}],editorEvents:{[ke]:({setState:c})=>{c({value:i.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:ve.listBullet,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:i.listBullet.isActive()})}},onClick:({setState:c})=>{i.listBullet.toggle(),c({active:i.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:ve.listOrdered,size:"s",type:"button",editorEvents:{[ke]:({setState:c})=>{c({active:i.listOrdered.isActive()})}},onClick:({setState:c})=>{i.listOrdered.toggle(),c({active:i.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:{[ke]:({setState:c})=>{c({value:i.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.heading.set({value:c}),s.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:{[ke]:({setState:c})=>{c({value:i.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.fontSize.set({value:c}),s.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:i,layouts:r,proseMirror:{view:s},items:l}))||l};class Hg{constructor(e,t,o){this.editor=o,this.node=e,this.dom=document.createElement("img"),this.view=t,Object.keys(e.attrs.attrs).forEach(s=>{this.dom.setAttribute(s,e.attrs.attrs[s])}),this.dom.addEventListener("dblclick",s=>this.handleDoubleClick(s))}handleDoubleClick(e){const{editor:t,view:o}=this;jc(o,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 at{constructor(e,t,o={}){this.match=e,this.match=e,this.handler=typeof t=="string"?$g(t):t,this.undoable=o.undoable!==!1,this.inCode=o.inCode||!1}}function $g(n){return function(e,t,o,s){let i=n;if(t[1]){let r=t[0].lastIndexOf(t[1]);i+=t[0].slice(r+t[1].length),o+=r;let l=o-s;l>0&&(i=t[0].slice(r-l,r)+i,o=s)}return e.tr.insertText(i,o,s)}}const Fg=500;function _g({rules:n}){let e=new Mn({state:{init(){return null},apply(t,o){let s=t.getMeta(this);return s||(t.selectionSet||t.docChanged?null:o)}},props:{handleTextInput(t,o,s,i){return Kc(t,o,s,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:o}=t.state.selection;o&&Kc(t,o.pos,o.pos,"",n,e)})}}},isInputRules:!0});return e}function Kc(n,e,t,o,s,i){if(n.composing)return!1;let r=n.state,l=r.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-Fg),l.parentOffset,null,"")+o;for(let c=0;c<s.length;c++){let d=s[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let u=d.match.exec(a),h=u&&d.handler(r,u,e-(u[0].length-o.length),t);if(h)return d.undoable&&h.setMeta(i,{transform:h,from:e,to:t,text:o}),n.dispatch(h),!0}return!1}const Wg=new at(/--$/,"—"),qg=new at(/\.\.\.$/,"…"),Gg=new at(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),jg=new at(/"$/,"”"),Kg=new at(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),Jg=new at(/'$/,"’"),Ug=[Gg,jg,Kg,Jg];function Di(n,e,t=null,o){return new at(n,(s,i,r,l)=>{let a=t instanceof Function?t(i):t,c=s.tr.delete(r,l),d=c.doc.resolve(r),u=d.blockRange(),h=u&&kl(u,e,a);if(!h)return null;c.wrap(u,h);let f=c.doc.resolve(r-1).nodeBefore;return f&&f.type==e&&Eo(c.doc,r-1)&&(!o||o(i,f))&&c.join(r-1),c})}function Jc(n,e,t=null){return new at(n,(o,s,i,r)=>{let l=o.doc.resolve(i),a=t instanceof Function?t(s):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?o.tr.delete(i,r).setBlockType(i,i,e,a):null})}function Zg(n){return Di(/^\s*>\s$/,n)}function Yg(n){return Di(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function Xg(n){return Di(/^\s*([-+*])\s$/,n)}function Qg(n){return Jc(/^```$/,n)}function e1(n,e){return Jc(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function t1(n){const e=Ug.concat(qg,Wg);let t;return(t=n.nodes.blockquote)&&e.push(Zg(t)),(t=n.nodes.orderedList)&&e.push(Yg(t)),(t=n.nodes.bulletList)&&e.push(Xg(t)),(t=n.nodes.codeBlock)&&e.push(Qg(t)),(t=n.nodes.heading)&&e.push(e1(t,6)),_g({rules:e})}const n1="rteProseMirror",o1=Q(function(n,e={}){const t={plugins:r=>r.plugins,...e},o=(r,l)=>{var p,m;const a=((p=t.schema)==null?void 0:p.call(t,{editor:n,schema:Hc}))||Hc,{nodes:c,marks:d}=a,u=Ut.fromSchema(a).parse(r),h=nn.create({doc:u,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,plugins:[ig(),mg(),t1(a),Ff(),Ys({Tab:Tc(1),"Shift-Tab":Tc(-1)}),Ys({Enter:En(jl,Uf(c.listItem),kg),"Shift-Enter":En(Gl,(g,y)=>(y&&y(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":oa,"Mod-y":Js,"Mod-Shift-z":Js,"Mod-b":Ct(d.strong),"Mod-i":Ct(d.em),"Shift-Tab":Xs(c.listItem),Tab:Xf(c.listItem)}),Ys(If)]})}),f=new Nm({mount:r},{state:h,dispatchTransaction(g){var v;const{state:y}=f,S=y.apply(g),b=!y.doc.eq(S.doc);f.updateState(S);const x=!y.selection.eq(S.selection);b&&(wg(((v=l==null?void 0:l.view)==null?void 0:v.el)||r),f.focus()),(x||b)&&n.trigger(ke)}});return r.__rteView=f,f.setProps({nodeViews:{image(g){return new Hg(g,f,n)}}}),f},s=r=>Bg(r,t);n.setCustomRte({toolbar:s,parseContent:!0,async enable(r,l,a){const c=Ii(r);if(c)return c;const d=o(r,a);return bg(r,d),Ig(d,a),d},disable(r){const l=Ii(r);if(l)return vg(r,l),l.destroy(),{forceSync:!0}},getContent(r){const l=Ii(r);if(l){const{schema:a,doc:c}=l.state,d=document.createElement("div"),u=St.fromSchema(a).serializeFragment(c.content);return u.childNodes.forEach(h=>{h.nodeType===Node.ELEMENT_NODE&&h.innerHTML===""&&(h.innerHTML="<br/>")}),d.appendChild(u),Sg(d),r.classList.remove("ProseMirror-focused"),d.innerHTML}return r.innerHTML}});const i=Cg(n,t);ee({editor:n,licenseKey:t.licenseKey,plan:F.free,pluginName:n1,cleanup:()=>{n.RichTextEditor.customRte=void 0,i()}})}),s1="canvasEmptyState",i1=Q(function(n,e={}){const t=new WeakMap,o=new WeakMap,s=new WeakMap,i=new Set,r=new WeakMap,l={emptyStates:[],...e},a=(b,x)=>{let v=!1;const{isValid:w}=x;return Array.isArray(w)?v=w.some(C=>b.is(C)):Un(w)?v=w({component:b,editor:n}):v=b.is(w),v},c=b=>{const x=t.get(b);t.delete(b),x==null||x()},d=b=>{b.views.forEach(x=>c(x)),s.delete(b)},u=b=>{if(!(!b||i.has(b)))try{i.add(b);const x=b.components().length>0,v=s.get(b);if(x&&v)d(b);else if(!x&&!v){const w=r.has(b)?r.get(b):l.emptyStates.find(C=>a(b,C));if(r.set(b,w),!w)return;b.views.forEach(C=>{const E=w.render({editor:n,component:b,componentView:C,mount:T=>{o.set(C,T),s.set(b,!0);const A=C.getChildrenContainer();A==null||A.appendChild(T)},unmount:()=>c(C)});t.set(C,()=>{E==null||E();const T=o.get(C);T==null||T.remove()})})}}finally{i.delete(b)}},h=b=>{s.has(b)&&d(b)},f=({model:b})=>{u(b.getComponent())},p=n.Components.events,m=`${p.update}:components`,g="component:mount",y=n.Canvas.events.frameLoadBody,S=p.removed;n.on(m,u),n.on(g,u),n.on(S,h),n.on(y,f),ee({editor:n,licenseKey:l.licenseKey,plan:F.startup,pluginName:s1,cleanup:()=>{n.off(m,u),n.off(g,u),n.off(S,h),n.off(y,f)}})}),Uc="canvasFullSize",r1=Q(function(n,e={}){const{Canvas:t,Commands:o,Devices:s}=n,i={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:r,canvasOffsetX:l,canvasTransition:a,deviceMaxWidth:c,deviceMinHeigth:d,frameBorderRadius:u,frameTransition:h}=i,f=`${d}px`,p=t.events,m="core:preview",g=`${o.events.stopCommand}${m}`,y=t.getConfig(),S=`${Uc}:disable`,b=s.getAll().map(v=>({...v.attributes}));y.scrollableCanvas=!0,s.getAll().map(v=>{!v.get("width")&&v.set("width",`${c}px`),!v.get("height")&&v.set("height","auto"),!v.get("minHeight")&&v.set("minHeight",f)});const x=v=>{const w="data-gs-plg-full-size",C=document.querySelector(`style[${w}]`);if(v&&C)return C.remove();const E=C||document.createElement("style"),T=t.getZoomMultiplier();E.setAttribute(w,"true"),E.innerHTML=`
200
303
  .gjs-frame-wrapper { transition: width ${h}s !important; }
201
304
  .gjs-frame-wrapper__bottom { height: ${r*T}px }
202
305
  .gjs-frame { border-radius: ${u}px }
203
- `,!k&&document.body.appendChild(E)};n.on(p.frameLoadHead,v=>{if(!b.scrollableCanvas)return;const{window:C}=v,k=C.document,E=k.head,T="data-gs-plg-wrapper-style",A=E.querySelector(`style[${T}]`)||k.createElement("style");A.setAttribute(T,"true"),A.innerHTML=`
306
+ `,!C&&document.body.appendChild(E)};n.on(p.frameLoadHead,v=>{if(!y.scrollableCanvas)return;const{window:w}=v,C=w.document,E=C.head,T="data-gs-plg-wrapper-style",A=E.querySelector(`style[${T}]`)||C.createElement("style");A.setAttribute(T,"true"),A.innerHTML=`
204
307
  [data-gjs-type="wrapper"] { min-height: ${f}; }
205
308
  [data-gjs-type="mjml"] { min-height: ${f} !important; }
206
309
  [data-gjs-type="mj-body"] { min-height: ${f} !important; }
207
- `,!E.contains(A)&&E.appendChild(A)}),n.onReady(()=>{const v=t.getSpotsEl(),C=t.getElement(),k=t.getFramesEl(),E=a*1e3,T=C.style;T.overflowX="hidden",k.style.transition=`transform ${a}s`;const A={x:l,y:r};w();const P=()=>v.style.display="none",D=()=>v.style.display="",z=oo(()=>{t.fitViewport({zoom:X=>X>100?100:X,ignoreHeight:!0,gap:A}),w(),setTimeout(()=>{var Ae,nd;const{em:X}=n;X.destroyed||((nd=(Ae=n.getSelected())==null?void 0:Ae.getEl())==null||nd.scrollIntoView({block:"nearest"}),n.refresh({tools:!0}),D(),s.isActive(m)?X.stopDefault():X.runDefault())},E)},100),H=new ResizeObserver(()=>{P(),z()});H.observe(C.parentElement);const Te=()=>{P(),z()},Me=(X={})=>{X.options&&X.options.from!=="fitViewport"&&t.fitViewport({zoom:t.getZoom(),ignoreHeight:!0,gap:A})},Rt=()=>{T.overflowX="hidden",T.overflowY="auto"},Jn=()=>{H.disconnect(),z.clear()};n.on(o.events.select,Te),n.on(p.zoom,Me),n.on(g,Rt),n.on(n.events.destroy,Jn),z(),s.add(S,()=>{o.devices.reset(y),b.scrollableCanvas=!1,t.getModel().updateDevice(),t.setZoom(100),t.setCoords(0,0),T.overflowY="hidden",w(!0),n.off(o.events.select,Te),n.off(p.zoom,Me),n.off(g,Rt),Jn(),s.run("studio:canvasReload")})}),ee({editor:n,licenseKey:i.licenseKey,plan:F.startup,pluginName:Uc,cleanup:()=>{n.runCommand(S)}})});var De=(n=>(n.panelBlocks="panelBlocks",n.panelPagesLayers="panelPagesLayers",n.panelGlobalStyles="panelGlobalStyles",n.panelSidebarTabs="panelSidebarTabs",n.panelAssets="panelAssets",n))(De||{});const Zc="sidebarButtonsTarget",Us=n=>{const{id:e,icon:t,label:s,tooltip:o,className:i,skipSelfClose:r,removeLayouts:l,layoutComponent:a,layoutCommand:c}=n,d=e;return{id:Yc(e),type:"button",icon:t,tooltip:s||o,className:i,editorEvents:{[`${Hi.layoutToggleId}${d}`]:({fromEvent:u,setState:h,editor:f})=>{h({active:u.isOpen}),setTimeout(()=>f.refresh({tools:!0}),20)}},onClick:({editor:u,state:h})=>{if(h.active&&r)return;const f=(c==null?void 0:c.placer)||{type:"static",layoutId:Zc},p={...f,skipCleanup:f.type==="static"},m=l||Object.keys(De).filter(b=>b!==d);Xc(u,{removeLayouts:m,layout:{placer:p}});const g={id:d,placer:f,header:(c==null?void 0:c.header)??{label:s,close:!r},layout:a,style:{width:280,height:"100%",borderRightWidth:1,...c==null?void 0:c.style}};u.runCommand(B.layoutToggle,g)}}},Yc=n=>`button__${n}`,Xc=(n,e={})=>{(e.removeLayouts||Object.keys(De)).forEach(s=>n.runCommand(B.layoutRemove,{id:s,layout:e.layout}))},Qc=n=>{const e=(n==null?void 0:n.breakpointTablet)??1024,t=(n==null?void 0:n.breakpointMobile)??768,s={breakpointTablet:e,breakpointMobile:t},o={},i=[{id:De.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:De.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:De.panelGlobalStyles,icon:'<svg viewBox="0 0 24 24"> <path d="M20 14H6c-2.2 0-4 1.8-4 4s1.8 4 4 4h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2M6 20c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m.3-8L13 5.3a2 2 0 0 1 2.8 0l2.8 2.8c.8.8.8 2 0 2.8l-.9 1.1H6.3M2 13.5V4c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v1.5l-8 8Z"/></svg>',label:"Global Styles",layoutComponent:{type:"panelGlobalStyles"}},{id:De.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:f,editor:p})=>{var b;const m=p.getSelected(),g={type:"image",src:f.src};if(m!=null&&m.is("image"))return m.set("src",f.src);if(m&&p.Components.canMove(m,g)){const S=m.append(g)[0];S&&p.select(S)}else if(!m){const S=(b=p.getWrapper())==null?void 0:b.append(g)[0];S&&p.select(S)}}}}],r=[...i,{id:De.panelSidebarTabs,layoutCommand:{header:!1},icon:'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',label:"Styles & Props",layoutComponent:{type:"panelSidebarTabs"}}],l={id:Zc,type:"column",style:{overflow:"hidden"}},a={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},c={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},d=(f,p)=>{const m=f.map(b=>{const S=Us(b);return n!=null&&n.sidebarButton?n.sidebarButton({id:b.id,buttonIds:De,breakpoint:p,buttonProps:S,sidebarButtonProps:b,...s,createSidebarButton:y=>Us({...b,...y})}):S}).filter(Boolean);return(n!=null&&n.sidebarButtons?n==null?void 0:n.sidebarButtons({buttonIds:De,breakpoint:p,sidebarButtons:m,...s,createSidebarButton:b=>Us({...b})}):m).filter(Boolean)},u=(f,p,m)=>{var g;return((g=n==null?void 0:n.rootLayout)==null?void 0:g.call(n,{breakpoint:m,sidebarButtons:p,rootLayout:f,layoutSidebarLeft:a,layoutSidebarTarget:l,...s,createSidebarButton:b=>Us({...b})}))??f};if(e){const f=d(r,e);o[e]=u({type:"row",style:{height:"100%"},children:[{...a,children:f},l,c]},f,e)}if(t){const f=r.map(m=>({...m,layoutCommand:{placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}}})),p=d(f,t);o[t]=u({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas"},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:p}]},p,t)}const h=d(i,0);return{default:u({type:"row",style:{height:"100%"},children:[{...a,children:h},l,c,{type:"sidebarRight"}]},h,0),responsive:o}},ed="layoutSidebarButtons",td=Q(function(n,e={}){const{Commands:t}=n,s=t.events,o={...e};(()=>{if(n.runCommand(B.layoutConfigGet)||o.skipLayoutConfig===!0)return;const l=Qc(o);n.runCommand(B.layoutConfigSet,{...l})})(),t.add(`${ed}:toggleButton`,(r,l,a)=>{const c=document.getElementById(Yc(a==null?void 0:a.id));c==null||c.click()}),n.on(`${s.runCommand}core:preview`,()=>{Xc(n)}),ee({editor:n,licenseKey:o.licenseKey,plan:F.free,pluginName:ed,cleanup:()=>{n.runCommand(B.layoutConfigSet)}})});td.createLayoutConfig=n=>Qc(n);const i1=n=>{const e={};for(const t of Object.keys(n)){let s=n[t];s&&(Array.isArray(s)?s=s.map(o=>o.toString()).join(","):s=s.toString(),e[t]=s)}return new URLSearchParams(e)},r1=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:s="high"}=n,o=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=i1(l);return`${c}?${d}`},i=l=>{var a,c,d;return((a=l[s])==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=i(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}),u={...c,...d};u.part?u.part.includes("snippet")||u.part.push("snippet"):u.part=["snippet"];const f=await(await fetch(o(u))).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:{borderWidth:"1px",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}}]})}},l1={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},a1="youtubeAssetProvider",c1=Q(function(n,e){var c;const{skipVideoComponent:t,i18n:s={}}=e,o=r1(e);n.runCommand(B.assetProviderAdd,{provider:o});const i="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:u=>{n.Assets.close(),d.set({videoId:u.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){const[d,...u]=l.getYoutubeTraits.apply(this);return[d,{id:i,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...u]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:d}=this,u=d.get("provider")||"";u!=null&&u.startsWith("yt")&&a(d)}}}),n.I18n.addMessages({en:l1,...s}),ee({editor:n,licenseKey:e.licenseKey,plan:F.startup,pluginName:a1,cleanup:()=>{n.runCommand(B.assetProviderRemove,{id:o.id}),!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==i)}}})}})}),d1=n=>{const{family:e,menu:t,axes:s}=n,o=!!s,i=Object.assign({},...n.variants.map(r=>{var d,u;let l,a;if(o){const h=s.find(f=>f.tag==="wght");if(h){const{start:f,end:p}=h;l=`${f} ${p}`}}return l||(l=((d=r.match(/\d+/))==null?void 0:d[0])??"400"),a=((u=r.match(/[a-zA-Z]+/))==null?void 0:u[0])==="italic"?"italic":void 0,{[r]:{family:e,source:n.files[r],variant:r,options:{style:a,weight:l}}}}));return{family:e,menuVariant:{family:`assetManagerMenu-${e}`,source:t,variant:"menu"},variants:i}},u1=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:d1(n),needsLoading:!0}}),h1=n=>{if(n.customData.needsLoading){n.customData.needsLoading=!1;const{font:e}=n.customData,{family:t,source:s,options:o}=e.menuVariant,i=new FontFace(t,`url("${s}")`,o);document.fonts.add(i),i.load().catch(()=>{})}};let qn;const f1=n=>{const e=[];for(const t of Object.keys(n)){let s=n[t];s&&(Array.isArray(s)?e.push(...s.map(o=>[t,o.toString()])):(s=s.toString(),e.push([t,s])))}return new URLSearchParams(e)},p1=n=>{const{apiKey:e,searchParams:t}=n,s=(o={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",r=f1(o);return`${i}?${r}`};return{id:"google-fonts",types:["font"],label:({editor:o})=>o.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var c;if(qn)return qn;const o={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=t==null?void 0:t(),r={...o,...i},a=await(await fetch(s(r))).json();return(c=a.items)!=null&&c.length?(qn=a.items.map(u1),qn):[]},itemLayout:o=>{const i=qn.find(r=>r.id===o.assetProps.id);return h1(i),{type:"column",onClick:()=>o.onSelect(i),htmlAttrs:{title:i.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i.customData.font.menuVariant.family,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},m1={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},g1="googleFontsAssetProvider",y1=Q(function(n,e){const{i18n:t={}}=e,s=p1(e);n.runCommand(B.assetProviderAdd,{provider:s}),n.I18n.addMessages({en:m1,...t}),ee({editor:n,licenseKey:e.licenseKey,plan:F.startup,pluginName:g1,cleanup:()=>{n.runCommand(B.assetProviderRemove,{id:s.id})}})});$.accordionComponent=_u,$.canvasEmptyState=s1,$.canvasFullSize=o1,$.dialogComponent=vd,$.flexComponent=ch,$.fsLightboxComponent=hu,$.googleFontsAssetProvider=y1,$.iconifyComponent=Rd,$.layoutSidebarButtons=td,$.lightGalleryComponent=Su,$.listPagesComponent=cu,$.rteProseMirror=t1,$.rteTinyMce=yh,$.swiperComponent=zu,$.tableComponent=su,$.youtubeAssetProvider=c1,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})});
310
+ `,!E.contains(A)&&E.appendChild(A)}),n.onReady(()=>{const v=t.getSpotsEl(),w=t.getElement(),C=t.getFramesEl(),E=a*1e3,T=w.style;T.overflowX="hidden",C.style.transition=`transform ${a}s`;const A={x:l,y:r};x();const P=()=>v.style.display="none",D=()=>v.style.display="",z=is(()=>{t.fitViewport({zoom:X=>X>100?100:X,ignoreHeight:!0,gap:A}),x(),setTimeout(()=>{var Ae,nd;const{em:X}=n;X.destroyed||((nd=(Ae=n.getSelected())==null?void 0:Ae.getEl())==null||nd.scrollIntoView({block:"nearest"}),n.refresh({tools:!0}),D(),o.isActive(m)?X.stopDefault():X.runDefault())},E)},100),H=new ResizeObserver(()=>{P(),z()});H.observe(w.parentElement);const Te=()=>{P(),z()},Me=(X={})=>{X.options&&X.options.from!=="fitViewport"&&t.fitViewport({zoom:t.getZoom(),ignoreHeight:!0,gap:A})},Rt=()=>{T.overflowX="hidden",T.overflowY="auto"},Jn=()=>{H.disconnect(),z.clear()};n.on(s.events.select,Te),n.on(p.zoom,Me),n.on(g,Rt),n.on(n.events.destroy,Jn),z(),o.add(S,()=>{s.devices.reset(b),y.scrollableCanvas=!1,t.getModel().updateDevice(),t.setZoom(100),t.setCoords(0,0),T.overflowY="hidden",x(!0),n.off(s.events.select,Te),n.off(p.zoom,Me),n.off(g,Rt),Jn(),o.run("studio:canvasReload")})}),ee({editor:n,licenseKey:i.licenseKey,plan:F.startup,pluginName:Uc,cleanup:()=>{n.runCommand(S)}})});var De=(n=>(n.panelBlocks="panelBlocks",n.panelPagesLayers="panelPagesLayers",n.panelGlobalStyles="panelGlobalStyles",n.panelSidebarTabs="panelSidebarTabs",n.panelAssets="panelAssets",n))(De||{});const Zc="sidebarButtonsTarget",Uo=n=>{const{id:e,icon:t,label:o,tooltip:s,className:i,skipSelfClose:r,removeLayouts:l,layoutComponent:a,layoutCommand:c}=n,d=e;return{id:Yc(e),type:"button",icon:t,tooltip:o||s,className:i,editorEvents:{[`${Hi.layoutToggleId}${d}`]:({fromEvent:u,setState:h,editor:f})=>{h({active:u.isOpen}),setTimeout(()=>f.refresh({tools:!0}),20)}},onClick:({editor:u,state:h})=>{if(h.active&&r)return;const f=(c==null?void 0:c.placer)||{type:"static",layoutId:Zc},p={...f,skipCleanup:f.type==="static"},m=l||Object.keys(De).filter(y=>y!==d);Xc(u,{removeLayouts:m,layout:{placer:p}});const g={id:d,placer:f,header:(c==null?void 0:c.header)??{label:o,close:!r},layout:a,style:{width:280,height:"100%",borderRightWidth:1,...c==null?void 0:c.style}};u.runCommand(B.layoutToggle,g)}}},Yc=n=>`button__${n}`,Xc=(n,e={})=>{(e.removeLayouts||Object.keys(De)).forEach(o=>n.runCommand(B.layoutRemove,{id:o,layout:e.layout}))},Qc=n=>{const e=(n==null?void 0:n.breakpointTablet)??1024,t=(n==null?void 0:n.breakpointMobile)??768,o={breakpointTablet:e,breakpointMobile:t},s={},i=[{id:De.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:De.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:De.panelGlobalStyles,icon:'<svg viewBox="0 0 24 24"> <path d="M20 14H6c-2.2 0-4 1.8-4 4s1.8 4 4 4h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2M6 20c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m.3-8L13 5.3a2 2 0 0 1 2.8 0l2.8 2.8c.8.8.8 2 0 2.8l-.9 1.1H6.3M2 13.5V4c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v1.5l-8 8Z"/></svg>',label:"Global Styles",layoutComponent:{type:"panelGlobalStyles"}},{id:De.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:f,editor:p})=>{var y;const m=p.getSelected(),g={type:"image",src:f.src};if(m!=null&&m.is("image"))return m.set("src",f.src);if(m&&p.Components.canMove(m,g)){const S=m.append(g)[0];S&&p.select(S)}else if(!m){const S=(y=p.getWrapper())==null?void 0:y.append(g)[0];S&&p.select(S)}}}}],r=[...i,{id:De.panelSidebarTabs,layoutCommand:{header:!1},icon:'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',label:"Styles & Props",layoutComponent:{type:"panelSidebarTabs"}}],l={id:Zc,type:"column",style:{overflow:"hidden"}},a={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},c={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},d=(f,p)=>{const m=f.map(y=>{const S=Uo(y);return n!=null&&n.sidebarButton?n.sidebarButton({id:y.id,buttonIds:De,breakpoint:p,buttonProps:S,sidebarButtonProps:y,...o,createSidebarButton:b=>Uo({...y,...b})}):S}).filter(Boolean);return(n!=null&&n.sidebarButtons?n==null?void 0:n.sidebarButtons({buttonIds:De,breakpoint:p,sidebarButtons:m,...o,createSidebarButton:y=>Uo({...y})}):m).filter(Boolean)},u=(f,p,m)=>{var g;return((g=n==null?void 0:n.rootLayout)==null?void 0:g.call(n,{breakpoint:m,sidebarButtons:p,rootLayout:f,layoutSidebarLeft:a,layoutSidebarTarget:l,...o,createSidebarButton:y=>Uo({...y})}))??f};if(e){const f=d(r,e);s[e]=u({type:"row",style:{height:"100%"},children:[{...a,children:f},l,c]},f,e)}if(t){const f=r.map(m=>({...m,layoutCommand:{placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}}})),p=d(f,t);s[t]=u({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas"},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:p}]},p,t)}const h=d(i,0);return{default:u({type:"row",style:{height:"100%"},children:[{...a,children:h},l,c,{type:"sidebarRight"}]},h,0),responsive:s}},ed="layoutSidebarButtons",td=Q(function(n,e={}){const{Commands:t}=n,o=t.events,s={...e};(()=>{if(n.runCommand(B.layoutConfigGet)||s.skipLayoutConfig===!0)return;const l=Qc(s);n.runCommand(B.layoutConfigSet,{...l})})(),t.add(`${ed}:toggleButton`,(r,l,a)=>{const c=document.getElementById(Yc(a==null?void 0:a.id));c==null||c.click()}),n.on(`${o.runCommand}core:preview`,()=>{Xc(n)}),ee({editor:n,licenseKey:s.licenseKey,plan:F.free,pluginName:ed,cleanup:()=>{n.runCommand(B.layoutConfigSet)}})});td.createLayoutConfig=n=>Qc(n);const l1=n=>{const e={};for(const t of Object.keys(n)){let o=n[t];o&&(Array.isArray(o)?o=o.map(s=>s.toString()).join(","):o=o.toString(),e[t]=o)}return new URLSearchParams(e)},a1=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:o="high"}=n,s=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=l1(l);return`${c}?${d}`},i=l=>{var a,c,d;return((a=l[o])==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=i(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}),u={...c,...d};u.part?u.part.includes("snippet")||u.part.push("snippet"):u.part=["snippet"];const f=await(await fetch(s(u))).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:{borderWidth:"1px",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}}]})}},c1={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},d1="youtubeAssetProvider",u1=Q(function(n,e){var c;const{skipVideoComponent:t,i18n:o={}}=e,s=a1(e);n.runCommand(B.assetProviderAdd,{provider:s});const i="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:s.id,providers:[],types:[],select:u=>{n.Assets.close(),d.set({videoId:u.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){const[d,...u]=l.getYoutubeTraits.apply(this);return[d,{id:i,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...u]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:d}=this,u=d.get("provider")||"";u!=null&&u.startsWith("yt")&&a(d)}}}),n.I18n.addMessages({en:c1,...o}),ee({editor:n,licenseKey:e.licenseKey,plan:F.startup,pluginName:d1,cleanup:()=>{n.runCommand(B.assetProviderRemove,{id:s.id}),!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==i)}}})}})}),h1=n=>{const{family:e,menu:t,axes:o}=n,s=!!o,i=Object.assign({},...n.variants.map(r=>{var d,u;let l,a;if(s){const h=o.find(f=>f.tag==="wght");if(h){const{start:f,end:p}=h;l=`${f} ${p}`}}return l||(l=((d=r.match(/\d+/))==null?void 0:d[0])??"400"),a=((u=r.match(/[a-zA-Z]+/))==null?void 0:u[0])==="italic"?"italic":void 0,{[r]:{family:e,source:n.files[r],variant:r,options:{style:a,weight:l}}}}));return{family:e,menuVariant:{family:`assetManagerMenu-${e}`,source:t,variant:"menu"},variants:i}},f1=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:h1(n),needsLoading:!0}}),p1=n=>{if(n.customData.needsLoading){n.customData.needsLoading=!1;const{font:e}=n.customData,{family:t,source:o,options:s}=e.menuVariant,i=new FontFace(t,`url("${o}")`,s);document.fonts.add(i),i.load().catch(()=>{})}};let qn;const m1=n=>{const e=[];for(const t of Object.keys(n)){let o=n[t];o&&(Array.isArray(o)?e.push(...o.map(s=>[t,s.toString()])):(o=o.toString(),e.push([t,o])))}return new URLSearchParams(e)},g1=n=>{const{apiKey:e,searchParams:t}=n,o=(s={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",r=m1(s);return`${i}?${r}`};return{id:"google-fonts",types:["font"],label:({editor:s})=>s.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var c;if(qn)return qn;const s={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=t==null?void 0:t(),r={...s,...i},a=await(await fetch(o(r))).json();return(c=a.items)!=null&&c.length?(qn=a.items.map(f1),qn):[]},itemLayout:s=>{const i=qn.find(r=>r.id===s.assetProps.id);return p1(i),{type:"column",onClick:()=>s.onSelect(i),htmlAttrs:{title:i.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i.customData.font.menuVariant.family,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},y1={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},b1="googleFontsAssetProvider",v1=Q(function(n,e){const{i18n:t={}}=e,o=g1(e);n.runCommand(B.assetProviderAdd,{provider:o}),n.I18n.addMessages({en:y1,...t}),ee({editor:n,licenseKey:e.licenseKey,plan:F.startup,pluginName:b1,cleanup:()=>{n.runCommand(B.assetProviderRemove,{id:o.id})}})});$.accordionComponent=qu,$.canvasEmptyState=i1,$.canvasFullSize=r1,$.dialogComponent=xd,$.flexComponent=dh,$.fsLightboxComponent=fu,$.googleFontsAssetProvider=v1,$.iconifyComponent=Dd,$.layoutSidebarButtons=td,$.lightGalleryComponent=Su,$.listPagesComponent=du,$.rteProseMirror=o1,$.rteTinyMce=vh,$.swiperComponent=Lu,$.tableComponent=su,$.youtubeAssetProvider=u1,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})});