@grapesjs/studio-sdk-plugins 1.0.23 → 1.0.24

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(H,vn){typeof exports=="object"&&typeof module<"u"?vn(exports,require("handlebars/dist/cjs/handlebars")):typeof define=="function"&&define.amd?define(["exports","handlebars/dist/cjs/handlebars"],vn):(H=typeof globalThis<"u"?globalThis:H||self,vn(H.StudioSdkPlugins={},H.Handlebars))})(this,function(H,vn){"use strict";const gi="app.grapesjs.com",yi="app-stage.grapesjs.com",bi=[gi,yi,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],gu="license:check:start",yu="license:check:end",bu=()=>typeof window<"u",Si=(n,e={})=>{const t=Cu(n)?{id:n,src:n}:n;return new Promise((o,s)=>{var a,c;const r=document.querySelector(`script[src="${t.src}"]`),{id:i}=t;if(r)return(a=e.onScript)==null||a.call(e,r),o(i);const l=document.createElement("script");l.src=t.src,l.onload=()=>o(i),l.onerror=()=>s(i),document.head.appendChild(l),(c=e.onScript)==null||c.call(e,l)})},Su=({isDev:n,isStage:e})=>`${n?"":`https://${e?yi:gi}`}/api`,vu=()=>{const n=bu()&&window.location.hostname;return!!n&&(bi.includes(n)||bi.some(e=>n.endsWith(e)))},xu=n=>n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?"-":"")+e.toLowerCase()),wu=n=>typeof n<"u",Cu=n=>typeof n=="string";function yt(n){return typeof n=="function"}async function ku({path:n,baseApiUrl:e,method:t="GET",headers:o={},params:s,body:r}){const l=`${e||Su({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...o}};r&&(a.body=JSON.stringify(r));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||{}),vi=(n=>(n.Info="info",n.Error="error",n.Success="success",n.Warning="warning",n))(vi||{}),_=(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.fontManagerOpen="studio:fontManagerOpen",n.menuFontLoad="studio:menuFontLoad",n.toggleStateDataSource="studio:toggleStateDataSource",n.getStateDataSource="studio:getStateDataSource",n.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",n.dataSourceSetImporter="studio:dataSourceSetImporter",n.dataSourceSetExporter="studio:dataSourceSetExporter",n.setDragAbsolute="studio:setDragAbsolute",n))(_||{}),xi=(n=>(n.layoutToggleId="studio:layoutToggle:",n.toggleBlocksPanel="studio:toggleBlocksPanel",n.pageSettingsUpdate="studio:pageSettingsUpdate",n.toggleDataSourcesPreview="studio:toggleDataSourcesPreview",n))(xi||{}),wi=(n=>(n.dark="dark",n.light="light",n.auto="auto",n))(wi||{}),Ci=(n=>(n.web="web",n.email="email",n.document="document",n))(Ci||{});const ki={[F.free]:0,[F.startup]:10,[F.business]:20,[F.enterprise]:30};function Tu(n){const e=n;return e.init=t=>o=>n(o,t),e}const G=n=>Tu(n);async function W({editor:n,plan:e,pluginName:t,licenseKey:o,cleanup:s}){let r="",i=!1;const l=vu(),a=d=>{console.warn("Cleanup plugin:",t,"Reason:",d),s()},c=(d={})=>{var m;const{error:u,sdkLicense:p}=d,h=(m=d.plan)==null?void 0:m.category;if(!(p||d.license)||u)a(u||"Invalid license");else if(h){const g=ki[e],b=ki[h];g>b&&a({pluginRequiredPlan:e,licensePlan:h})}};n.on(gu,d=>{r=d==null?void 0:d.baseApiUrl,i=!0}),n.on(yu,d=>{c(d)}),setTimeout(async()=>{if(!i){if(l)return;if(o){const d=await Eu({licenseKey:o,pluginName:t,baseApiUrl:r});d&&c(d)}else a("The `licenseKey` option not provided")}},2e3)}async function Eu(n){const{licenseKey:e,pluginName:t,baseApiUrl:o}=n;try{return(await ku({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 ao=(n,e)=>{var t;return!!((t=n==null?void 0:n.hasAttribute)!=null&&t.call(n,e))},bt=(n,e)=>{var t;return!!((t=n==null?void 0:n.classList)!=null&&t.contains(e))},Xe=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,_e))===n},co=(...n)=>e=>n.some(t=>e.is(t)),gs=(...n)=>(e,t)=>n.some(o=>t.is(o)),Mu=(n,e={})=>{var r;const t={},o=[],s=[];for(const i in n){const{value:l,...a}=n[i];o.push({id:i,name:i,changeProp:!0,category:e.category,...a}),t[i]=l,!wu(l)&&s.push(i);const{subTraits:c={}}=a;for(const d in a.subTraits)(r=c[d])==null||r.forEach(u=>{const p=u.id||u.name;t[p]=u.value})}return{propKeys:Object.keys(t),propsNoValues:s,props:t,traits:o}},Au=(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,()=>Ti(n,o)),Ti(n,o)}})},Ti=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},i=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(i);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},ys=(n,e,t)=>{const{doc:o=document}=t,s=t.target||o.head,r=s.querySelector(`style[${n}]`)||o.createElement("style");r.setAttribute(n,"true"),r.innerHTML=e,!s.contains(r)&&s.appendChild(r)},Pu=(n,e)=>{e.forEach(t=>{const o=xu(t);o!==t&&n.has(o)&&n.set({[t]:n.get(o),[o]:void 0})})},Ne="gjs-plg-",Ei="data-gs-plg-",_e="data-type-role",Mi=(...n)=>n.map(e=>`[data-gjs-type="${e}"]`).join(","),Ou="dialogComponent",Nu=G(function(n,e={}){const{Blocks:t,Components:o}=n,{licenseKey:s}=e,r="gjs-plg-dialog",i="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",p="gjs-plg-dialog-placeholder";t.add(r,{label:"Dialog",media:`
1
+ (function(F,wn){typeof exports=="object"&&typeof module<"u"?wn(exports,require("handlebars/dist/cjs/handlebars")):typeof define=="function"&&define.amd?define(["exports","handlebars/dist/cjs/handlebars"],wn):(F=typeof globalThis<"u"?globalThis:F||self,wn(F.StudioSdkPlugins={},F.Handlebars))})(this,function(F,wn){"use strict";const yi="app.grapesjs.com",bi="app-stage.grapesjs.com",Si=[yi,bi,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],gu="license:check:start",yu="license:check:end",bu=()=>typeof window<"u",vi=(n,e={})=>{const t=Cu(n)?{id:n,src:n}:n;return new Promise((o,s)=>{var a,c;const r=document.querySelector(`script[src="${t.src}"]`),{id:i}=t;if(r)return(a=e.onScript)==null||a.call(e,r),o(i);const l=document.createElement("script");l.src=t.src,l.onload=()=>o(i),l.onerror=()=>s(i),document.head.appendChild(l),(c=e.onScript)==null||c.call(e,l)})},Su=({isDev:n,isStage:e})=>`${n?"":`https://${e?bi:yi}`}/api`,vu=()=>{const n=bu()&&window.location.hostname;return!!n&&(Si.includes(n)||Si.some(e=>n.endsWith(e)))},xu=n=>n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?"-":"")+e.toLowerCase()),wu=n=>typeof n<"u",Cu=n=>typeof n=="string";function bt(n){return typeof n=="function"}async function ku({path:n,baseApiUrl:e,method:t="GET",headers:o={},params:s,body:r}){const l=`${e||Su({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...o}};r&&(a.body=JSON.stringify(r));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 _=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(_||{}),xi=(n=>(n.Info="info",n.Error="error",n.Success="success",n.Warning="warning",n))(xi||{}),G=(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.fontManagerOpen="studio:fontManagerOpen",n.menuFontLoad="studio:menuFontLoad",n.toggleStateDataSource="studio:toggleStateDataSource",n.getStateDataSource="studio:getStateDataSource",n.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",n.dataSourceSetImporter="studio:dataSourceSetImporter",n.dataSourceSetExporter="studio:dataSourceSetExporter",n.setDragAbsolute="studio:setDragAbsolute",n))(G||{}),wi=(n=>(n.layoutToggleId="studio:layoutToggle:",n.toggleBlocksPanel="studio:toggleBlocksPanel",n.pageSettingsUpdate="studio:pageSettingsUpdate",n.toggleDataSourcesPreview="studio:toggleDataSourcesPreview",n))(wi||{}),Ci=(n=>(n.dark="dark",n.light="light",n.auto="auto",n))(Ci||{}),ki=(n=>(n.web="web",n.email="email",n.document="document",n))(ki||{});const Ti={[_.free]:0,[_.startup]:10,[_.business]:20,[_.enterprise]:30};function Tu(n){const e=n;return e.init=t=>o=>n(o,t),e}const j=n=>Tu(n);async function q({editor:n,plan:e,pluginName:t,licenseKey:o,cleanup:s}){let r="",i=!1;const l=vu(),a=d=>{console.warn("Cleanup plugin:",t,"Reason:",d),s()},c=(d={})=>{var m;const{error:u,sdkLicense:p}=d,h=(m=d.plan)==null?void 0:m.category;if(!(p||d.license)||u)a(u||"Invalid license");else if(h){const g=Ti[e],b=Ti[h];g>b&&a({pluginRequiredPlan:e,licensePlan:h})}};n.on(gu,d=>{r=d==null?void 0:d.baseApiUrl,i=!0}),n.on(yu,d=>{c(d)}),setTimeout(async()=>{if(!i){if(l)return;if(o){const d=await Eu({licenseKey:o,pluginName:t,baseApiUrl:r});d&&c(d)}else a("The `licenseKey` option not provided")}},2e3)}async function Eu(n){const{licenseKey:e,pluginName:t,baseApiUrl:o}=n;try{return(await ku({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 co=(n,e)=>{var t;return!!((t=n==null?void 0:n.hasAttribute)!=null&&t.call(n,e))},St=(n,e)=>{var t;return!!((t=n==null?void 0:n.classList)!=null&&t.contains(e))},Qe=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,Ge))===n},uo=(...n)=>e=>n.some(t=>e.is(t)),bs=(...n)=>(e,t)=>n.some(o=>t.is(o)),Mu=(n,e={})=>{var r;const t={},o=[],s=[];for(const i in n){const{value:l,...a}=n[i];o.push({id:i,name:i,changeProp:!0,category:e.category,...a}),t[i]=l,!wu(l)&&s.push(i);const{subTraits:c={}}=a;for(const d in a.subTraits)(r=c[d])==null||r.forEach(u=>{const p=u.id||u.name;t[p]=u.value})}return{propKeys:Object.keys(t),propsNoValues:s,props:t,traits:o}},Au=(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,()=>Ei(n,o)),Ei(n,o)}})},Ei=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},i=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(i);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},Ss=(n,e,t)=>{const{doc:o=document}=t,s=t.target||o.head,r=s.querySelector(`style[${n}]`)||o.createElement("style");r.setAttribute(n,"true"),r.innerHTML=e,!s.contains(r)&&s.appendChild(r)},Pu=(n,e)=>{e.forEach(t=>{const o=xu(t);o!==t&&n.has(o)&&n.set({[t]:n.get(o),[o]:void 0})})},Oe="gjs-plg-",Mi="data-gs-plg-",Ge="data-type-role",Ai=(...n)=>n.map(e=>`[data-gjs-type="${e}"]`).join(","),Nu="dialogComponent",Ou=j(function(n,e={}){const{Blocks:t,Components:o}=n,{licenseKey:s}=e,r="gjs-plg-dialog",i="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",p="gjs-plg-dialog-placeholder";t.add(r,{label:"Dialog",media:`
2
2
  <svg viewBox="0 0 24 24">
3
3
  <path d="M4 4h16v10H8l-4 4V4z"></path>
4
4
  </svg>
5
- `,category:"Extra",content:{type:r},activate:!0,...e.block}),o.addType(r,{model:{defaults:{tagName:"div",attributes:{class:r,"data-type-role":r},components:[{type:i},{type:p}],draggable:Mi("wrapper"),droppable:Mi(r),styles:`
5
+ `,category:"Extra",content:{type:r},activate:!0,...e.block}),o.addType(r,{model:{defaults:{tagName:"div",attributes:{class:r,"data-type-role":r},components:[{type:i},{type:p}],draggable:Ai("wrapper"),droppable:Ai(r),styles:`
6
6
  .${r} {
7
7
  position: relative;
8
8
  z-index: 1;
9
9
  }
10
- `,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(f){var m;(m=f.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(f){const m=this;function g(S){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),w=m.querySelector('[data-type-role="gjs-plg-dialog-close"]');function x(){v.style.display="none"}S?(m._onCloseWhenPressingX=x,w.addEventListener("click",m._onCloseWhenPressingX)):(w.removeEventListener("click",m._onCloseWhenPressingX),m._onCloseWhenPressingX=null)}function b(S){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function w(x){x.key==="Escape"&&(v.style.display="none")}S?(m._onCloseWhenPressingEsc=w,m.addEventListener("keydown",m._onCloseWhenPressingEsc)):(m.removeEventListener("keydown",m._onCloseWhenPressingEsc),m._onCloseWhenPressingEsc=null)}function C(S){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function w(){v.style.display="flex"}S?(m._onOpenWhenLeavingWindow=w,document.addEventListener("mouseleave",m._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",m._onOpenWhenLeavingWindow),m._onOpenWhenLeavingWindow=null)}function y(S){const v=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function w(){const x=document.documentElement.scrollTop;S&&x>=Number(S)&&(v.style.display="flex")}S?(m._onOpenWhenScrollingToLevel=w,document.addEventListener("scroll",m._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",m._onOpenWhenScrollingToLevel),m._onOpenWhenScrollingToLevel=null)}g(f.closeWhenPressingX),b(f.closeWhenPressingEsc),C(f.openWhenLeavingWindow),y(f.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 f=this.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');f.style.display="flex"}}}),o.addType(i,{model:{defaults:{tagName:"div",attributes:{class:i,"data-type-role":i},components:{type:l},droppable:!1,draggable:!1,styles:`
10
+ `,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(f){var m;(m=f.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(f){const m=this;function g(S){const x=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),w=m.querySelector('[data-type-role="gjs-plg-dialog-close"]');function v(){x.style.display="none"}S?(m._onCloseWhenPressingX=v,w.addEventListener("click",m._onCloseWhenPressingX)):(w.removeEventListener("click",m._onCloseWhenPressingX),m._onCloseWhenPressingX=null)}function b(S){const x=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function w(v){v.key==="Escape"&&(x.style.display="none")}S?(m._onCloseWhenPressingEsc=w,m.addEventListener("keydown",m._onCloseWhenPressingEsc)):(m.removeEventListener("keydown",m._onCloseWhenPressingEsc),m._onCloseWhenPressingEsc=null)}function C(S){const x=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function w(){x.style.display="flex"}S?(m._onOpenWhenLeavingWindow=w,document.addEventListener("mouseleave",m._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",m._onOpenWhenLeavingWindow),m._onOpenWhenLeavingWindow=null)}function y(S){const x=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function w(){const v=document.documentElement.scrollTop;S&&v>=Number(S)&&(x.style.display="flex")}S?(m._onOpenWhenScrollingToLevel=w,document.addEventListener("scroll",m._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",m._onOpenWhenScrollingToLevel),m._onOpenWhenScrollingToLevel=null)}g(f.closeWhenPressingX),b(f.closeWhenPressingEsc),C(f.openWhenLeavingWindow),y(f.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 f=this.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');f.style.display="flex"}}}),o.addType(i,{model:{defaults:{tagName:"div",attributes:{class:i,"data-type-role":i},components:{type:l},droppable:!1,draggable:!1,styles:`
11
11
  .${i} {
12
12
  position: fixed;
13
13
  top: 0;
@@ -56,24 +56,24 @@
56
56
  .${u} {
57
57
  margin: 0;
58
58
  }
59
- `}}}),o.addType(p,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:p,"data-type-role":p},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){const{em:f,el:m}=this,g="core:preview",b=f.Commands.events;this.listenTo(f,`${b.runCommand}${g}`,()=>{m.style.display="none"}),this.listenTo(f,`${b.stopCommand}${g}`,()=>{m.style.display=""})}}}),W({editor:n,licenseKey:s,plan:F.startup,pluginName:Ou,cleanup:()=>{t.remove(r),o.removeType(r)}})}),Iu="iconifyComponent",Ru=F.startup,Du={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},bs=`<svg viewBox="0 0 24 24">
59
+ `}}}),o.addType(p,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:p,"data-type-role":p},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){const{em:f,el:m}=this,g="core:preview",b=f.Commands.events;this.listenTo(f,`${b.runCommand}${g}`,()=>{m.style.display="none"}),this.listenTo(f,`${b.stopCommand}${g}`,()=>{m.style.display=""})}}}),q({editor:n,licenseKey:s,plan:_.startup,pluginName:Nu,cleanup:()=>{t.remove(r),o.removeType(r)}})}),Iu="iconifyComponent",Ru=_.startup,Du={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},vs=`<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>`,Ai="layout-icon-picker",Lu="icons-layout-",Pi="icons-list-layout",Oi="gs-iconify-picker",Ss="__iconify_collection",$u="https://api.iconify.design",vs=new Map;let uo;const zu=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function Ni({collectionId:n,editor:e}){try{if(vs.has(n))return vs.get(n);const t=await fetch(zu({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const o=await t.json();return vs.set(n,o),o}catch(t){console.error("Error fetching collection",t),e.runCommand(_.toastAdd,ju());return}}async function Bu({collectionIds:n,editor:e}){try{if(uo)return uo;const t=n?`?prefixes=${n.join(",")}`:"",o=await fetch(`${$u}/collections${t}`);if(!o.ok)throw new Error(`Failed to fetch collections: ${o.statusText}`);return uo=await o.json(),uo}catch(t){console.error("Error fetching collections",t),e.runCommand(_.toastAdd,Ri());return}}function Ii(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function Vu({collectionIds:n,editor:e,component:t}){const o=await Bu({collectionIds:n,editor:e});if(!o)return;const s=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},r=Object.entries(o).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),i=t.get("collectionId")??r[0].id;e.runCommand(_.layoutToggle,{id:Ai,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[_u({collectionsList:r,collectionId:i,editor:e,handleClick:s}),{id:Pi,type:"column",grow:!0}]}});const l=await Ni({collectionId:i,editor:e});l&&xs({editor:e,collection:l,handleClick:s,collectionId:i})}function Hu({editor:n,collection:e}){n.em.set(Ss,e)}function Fu(n){return n.em.get(Ss)}function xs(n){const{editor:e}=n,t={id:Lu,layout:Gu(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:Pi}};e.runCommand(_.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>e.runCommand(_.layoutAdd,t),10)}function _u(n){const{collectionsList:e,collectionId:t,editor:o,handleClick:s}=n,r=e.map(({id:i,name:l,total:a})=>({id:i,label:`${l} (${a})`})).sort((i,l)=>i.label.localeCompare(l.label));return{type:"column",style:{gap:10},className:`${Oi}__header`,children:[{type:"selectField",value:t,options:r,emptyState:"Select an icon collection",onChange:async({setState:i,value:l})=>{const a=await Ni({collectionId:l,editor:o});a&&(i({value:l}),Hu({editor:o,collection:a}),xs({editor:o,collection:a,handleClick:s,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${Ss}`]:({setState:i})=>i({value:""})},onInput:({setState:i,value:l,editor:a})=>{const c=Fu(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([u])=>u.includes(l)));i({value:l}),xs({editor:a,collection:c,handleClick:s,collectionId:l,collectionFiltered:{...c,icons:d}})}}]}}function Gu({collection:n,collectionFiltered:e,handleClick:t}){const{height:o=24,width:s=24,icons:r,prefix:i}=e||n,l=Object.entries(r).map(([a,{body:c}])=>({name:a,body:c}),{});return{type:"column",className:`${Oi}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>[{type:"custom",render:c=>{const{editor:d,addEl:u,removeEl:p}=c,h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.setAttribute("xmlns","http://www.w3.org/2000/svg"),h.innerHTML=a.body,h.setAttribute("viewBox",`0 0 ${s} ${o}`);const{cssWidth:f,cssHeight:m}=Wu(s,o);h.style.cssText=`width: ${f}px; height: ${m}px; cursor: pointer;`,h.addEventListener("mouseover",()=>{h.style.border="2px solid currentColor",h.style.borderRadius="4px",h.style.padding="4px"}),h.addEventListener("mouseout",()=>{h.style.border="none"});const g=()=>{const b=h.cloneNode(!0);b.removeAttribute("style");const C=b.outerHTML;t({icon:C,collectionId:i,iconId:a.name}),d==null||d.runCommand(_.layoutRemove,{id:Ai})};return h.addEventListener("click",g),u(h),()=>{h.removeEventListener("click",g),p(h)}}}]}}}function Wu(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 Ri(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:vi.Error}}function ju(){return{...Ri(),id:"toast-error-getCollection",content:"Error fetching collection"}}const qu=G(function(n,e={}){var h;const{Components:t,Blocks:o}=n,{collections:s,extendIconComponent:r=!0,licenseKey:i,block:l={}}=e,a="icon",c="iconify",d="Iconify",u="data-type-iconify",p={events:()=>({dblclick:"onActive"}),onActive(){Vu({collectionIds:s,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:bs,content:{type:c},category:"Extra",activate:!0,...l},isComponent:f=>ao(f,u),model:{defaults:{name:d,icon:bs,droppable:!1,attributes:{[u]:!0},resizable:Du,components:bs,style:{width:"50px",height:"50px"},traits:[Ii()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:p}),r){const f=(h=t.getType(a))==null?void 0:h.model,[m,g,...b]=f.getDefaults().traits;t.addType(a,{model:{defaults:{traits:[m,g,Ii(),...b]}},view:p})}W({editor:n,licenseKey:i,plan:Ru,pluginName:Iu,cleanup:()=>{o.remove(c),t.removeType(c)}})});function xn(n,e,t){let o,s,r,i,l;const a=e===void 0?100:e;function c(){const u=Date.now()-i;u<a&&u>=0?o=setTimeout(c,a-u):(o=null,l=n.apply(r,s),r=s=null)}const d=function(){return r=this,s=arguments,i=Date.now(),o||(o=setTimeout(c,a)),l};return d.clear=function(){o&&(clearTimeout(o),o=null)},d.flush=function(){o&&(l=n.apply(r,s),r=s=null,clearTimeout(o),o=null)},d}const Uu="tableComponent",Ku=F.startup;var I=(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))(I||{});const B={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>'},Ie="table",Di="thead",Li="tfoot",ws="tbody",pe="row",j="cell",Cs="clipboardTable",Ju=[Ie,Di,Li,ws,pe,j],po=n=>n.em.get(Cs)||[],Zu=n=>n.every(e=>e.is(j)),ks=(n,e)=>{const{editor:t,event:o,opts:s}=n,r=o.currentTarget||o.target,{x:i,y:l,width:a,height:c}=r.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:i,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};yt(s.openSettings)?s.openSettings({...n,layoutProps:d}):t.runCommand(_.layoutToggle,d)},Yu=(n,{rows:e=1,cells:t=5,text:o}={})=>({type:n,components:Array.from(Array(e).keys()).map(s=>({type:pe,components:Array.from(Array(t).keys()).map(r=>({type:j,components:o?{type:"text",content:yt(o)?o({y:s,x:r}):o}:void 0}))}))}),$i="Table settings",zi=n=>{const{component:e}=n;return e.is(Ie)?e:e.closestType(Ie)},Xu=n=>{var e;(e=zi(n))==null||e.remove(n.opts)},Qu=n=>{const e=zi(n);e&&(n.editor.select(e),ks(n,{id:"tableSettings",header:{label:$i}}))},Bi=n=>[{id:I.table,icon:B[I.table],label:"Table",items:[{id:I.tableSettings,label:$i,icon:B[I.tableSettings],onClick:({event:t})=>Qu({...n,event:t})},{id:I.tableDelete,label:"Delete table",icon:B[I.tableDelete],onClick:()=>Xu(n)}]}],Vi=({editor:n})=>{const e=po(n);return e.length&&Zu(e)},Hi=({component:n,editor:e,after:t})=>{if(!n.is(j))return;const o=n.closestType(Ie),s=n.closestType(pe),r=n.index()+(t?1:0);o==null||o.findType(pe).forEach(l=>l.append({type:j},{at:r}));const i=s==null?void 0:s.components().at(r);i&&e.select(i)},Fi=({component:n,opts:e})=>{if(!n.is(j))return;const t=n.closestType(Ie),o=n.index();t==null||t.findType(pe).forEach(s=>{var r;return(r=s.components().at(o))==null?void 0:r.remove(e)})},_i=({component:n,editor:e})=>{if(!n.is(j))return;const t=n.closestType(Ie),o=n.index(),s=(t==null?void 0:t.findType(pe).map(r=>r.components().at(o)))||[];s.length&&e.em.set(Cs,s)},Gi=n=>{const{component:e,editor:t,after:o}=n;if(!e.is(j)||!Vi(n))return;const s=po(t),r=e.closestType(Ie),i=e.index()+(o?1:0);r==null||r.findType(pe).forEach((l,a)=>{const c=s[a],d=(c==null?void 0:c.clone())||{type:j};l.append(d,{at:i})})},ep=n=>{const{component:e}=n;e.is(j)&&(_i(n),Fi({...n,opts:{temporary:!0}}))},tp=n=>{const e=Vi(n);return[{id:I.tableColumnItems,icon:B[I.tableColumn],label:"Column",items:[{id:I.tableColumnInsertBefore,label:"Insert column before",icon:B[I.tableColumnInsertBefore],onClick:()=>Hi(n)},{id:I.tableColumnInsertAfter,label:"Insert column after",icon:B[I.tableColumnInsertAfter],onClick:()=>Hi({...n,after:!0})},{id:I.tableColumnDelete,label:"Delete column",icon:B[I.tableColumnDelete],onClick:()=>Fi(n)},{id:I.tableColumnCut,label:"Cut column",icon:B[I.tableColumnCut],onClick:()=>ep(n)},{id:I.tableColumnCopy,label:"Copy column",icon:B[I.tableColumnCopy],onClick:()=>_i(n)},{id:I.tableColumnPasteBefore,label:"Paste column before",icon:B[I.tableColumnPasteBefore],disabled:!e,onClick:()=>Gi(n)},{id:I.tableColumnPasteAfter,label:"Paste column after",icon:B[I.tableColumnPasteAfter],disabled:!e,onClick:()=>Gi({...n,after:!0})}]}]},Wi="Row settings",np=n=>n.every(e=>e.is(pe)),_t=n=>{const{component:e}=n,t=e.is(j),o=e.is(pe);if(!(!t&&!o))return o?e:e.closestType(pe)},ji=n=>{const{component:e,editor:t,after:o}=n,s=_t(n);if(!s)return;const r=s.index()+(o?1:0),i=s.components().length,l=Array.from(Array(i).keys()).map(()=>({type:j})),a=s.parent();if(a){const c=a.append({type:pe,components:l},{at:r})[0];if(e.is(j)&&c){const d=e.index(),u=c.components().at(d);u&&t.select(u)}}},qi=n=>{var e;(e=_t(n))==null||e.remove(n.opts)},Ui=n=>{const e=_t(n);e&&n.editor.em.set(Cs,[e])},Ki=n=>{var l;const{editor:e,after:t}=n,o=_t(n);if(!o||!Ji(n))return;const r=po(e)[0],i=o.index()+(t?1:0);r&&((l=o.parent())==null||l.append(r.clone(),{at:i}))},op=n=>{_t(n)&&(Ui(n),qi({...n,opts:{temporary:!0}}))},Ji=({editor:n})=>{const e=po(n);return e.length&&np(e)},sp=n=>{const e=_t(n);e&&(n.editor.select(e),ks(n,{id:"tableRowSettings",header:{label:Wi}}))},Zi=n=>{const e=Ji(n);return[{id:I.tableRowItems,icon:B[I.tableRowProperties],label:"Row",items:[{id:I.tableRowInsertBefore,label:"Insert row before",icon:B[I.tableRowInsertBefore],onClick:()=>ji(n)},{id:I.tableRowInsertAfter,label:"Insert row after",icon:B[I.tableRowInsertAfter],onClick:()=>ji({...n,after:!0})},{id:I.tableRowDelete,label:"Delete row",icon:B[I.tableRowDelete],onClick:()=>qi(n)},{id:I.tableRowProperties,label:Wi,icon:B[I.tableRowProperties],onClick:({event:o})=>sp({...n,event:o})},{id:I.tableRowCut,label:"Cut row",icon:B[I.tableRowCut],onClick:()=>op(n)},{id:I.tableRowCopy,label:"Copy row",icon:B[I.tableRowCopy],onClick:()=>Ui(n)},{id:I.tableRowPasteBefore,label:"Paste row before",icon:B[I.tableRowPasteBefore],disabled:!e,onClick:()=>Ki(n)},{id:I.tableRowPasteAfter,label:"Paste row after",icon:B[I.tableRowPasteAfter],disabled:!e,onClick:()=>Ki({...n,after:!0})}]},...Bi(n)]},Ts=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),o=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:o}};function Yi(n){const e=[];return n.components().forEach((t,o)=>{t.components().each((s,r)=>{const{rowspan:i,colspan:l}=Ts(s);if(e[o])for(;e[o][r];)r++;for(let a=o;a<o+i;a++){e[a]||(e[a]=[]);for(let c=r;c<r+l;c++)e[a][c]={real:a===o&&c===r,cell:s,rowspan:i,colspan:l}}})}),e}function Gt(n,e,t){var o;return(o=n[t])==null?void 0:o[e]}const Es=n=>n.closestType(pe);function rp(n,{x:e,y:t,rows:o,cols:s}){var l;let r=Es(n[t][e].cell),i;for(let a=1;a<=o;a++)if(r=(l=r==null?void 0:r.parent())==null?void 0:l.components().at(r.index()+1),r){for(i=e;i>=0;i--){const{cell:c}=n[t+a][i],d=Es(c);if(d===r){for(let u=1;u<=s;u++){const p=c.index();d.append({type:j},{at:p+1})}break}}if(i===-1){const d=r.components().at(0).index();for(let u=1;u<=s;u++)r.append({type:j},{at:d})}}}function Xi(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:r,colspan:i}=Ts(s);if(i>1||r>1){s.addAttributes({colspan:1,rowspan:1});for(let l=0;l<i-1;l++){const a=s.index();Es(s).append({type:j},{at:a+1})}rp(n,{x:t,y:e,rows:r-1,cols:i})}}}}function ip(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const ho=(n,e={})=>{var i;const t=Yi(n),{em:o}=n;let s,r;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((i=e.selected)!=null&&i.includes(c.cell)||o.selected.hasComponent(c.cell)){const d={x:a,y:l};s||(s=d),r=d}}return{grid:t,startPos:s,endPos:r}};function lp(n,e={}){const t=ho(n),{startPos:o,endPos:s}=t;let{grid:r}=t;const{em:i}=n;if(!o||!s)return;const l=o.x,a=o.y,c=s.x,d=s.y,u=Gt(r,l,a),p=Gt(r,c,d);if(u&&p){Xi(r),r=Yi(n);const h=[],f=Gt(r,l,a).cell;f.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=Gt(r,g,m);if(!b)continue;const{cell:C}=b;C!==f&&h.push(C)}h.forEach(m=>{e.mergeContent&&f.append(m.components().models),m.remove()}),i.setSelected(f),ip(n)}}const Qi="Cell settings",ap="Merge cells",cp="Split cell",dp=n=>n.closestType(pe),Wt=n=>{var e;return(e=dp(n))==null?void 0:e.parent()},up=n=>{const e=n.editor.getSelectedAll(),t=Wt(e[0]),o=e[0];if(!t||!(o!=null&&o.is(j))||e.length>1)return!1;const{rowspan:s,colspan:r}=Ts(o);return!(r<2&&s<2)},pp=n=>{const t=n.editor.getSelectedAll()[0],o=Wt(t),{grid:s}=ho(o);Xi(s)},el=n=>{const e=n.editor.getSelectedAll(),t=Wt(e[0]);if(!t||e.length<2||e.some(l=>!l.is(j)||Wt(l)!==t))return!1;const{grid:o,startPos:s,endPos:r}=ho(t),{em:i}=t;if(!s||!r)return!1;for(let l=s.y;l<=r.y;l++)for(let a=s.x;a<=r.x;a++){const c=Gt(o,a,l);if(!c||!i.selected.hasComponent(c.cell))return!1}return!0},hp=n=>{const{editor:e}=n;if(!el(n))return;const t=e.getSelectedAll(),o=Wt(t[0]);lp(o,{mergeContent:!0})},fp=n=>{ks(n,{id:"tableCellSettings",header:{label:Qi}})},mp=n=>[{id:I.tableCellItems,icon:B[I.tableCellProperties],label:"Cell",items:[{id:I.tableCellProperties,label:Qi,icon:B[I.tableCellProperties],onClick:({event:t})=>fp({...n,event:t})},{id:I.tableCellMerge,label:ap,icon:B[I.tableCellMerge],onClick:()=>hp(n),disabled:!el(n)},{id:I.tableCellSplit,label:cp,icon:B[I.tableCellSplit],onClick:()=>pp(n),disabled:!up(n)}]},...tp(n),...Zi(n)],gp=n=>{const e=n[0]&&Wt(n[0]);if(!e)return;const{grid:t,startPos:o,endPos:s}=ho(e,{selected:n});if(!o||!s)return;const r=[];for(let i=o.y;i<=s.y;i++)for(let l=o.x;l<=s.x;l++){const a=Gt(t,l,i);a&&r.push(a.cell)}r.length&&e.em.setSelected(r,{fromCell:!0})},yp=G(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(Ie,{block:t.block&&{label:"Table",media:B.table,category:"Extra",content:{type:Ie,style:{width:"100%"}},select:!0,...t.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:B.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:i,value:l,emitUpdate:a}){const c=i.find("caption")[0];l?!c&&i.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):c==null||c.remove(),a(),n.refresh({tools:!0})},getValue(i){return!!i.component.find("caption")[0]}}],components:Yu(ws,{rows:5}),contextMenu:({items:i,editor:l,component:a})=>[...Bi({editor:l,component:a,opts:t}),...i]}}}),o.addType(Di,{model:{defaults:{icon:B.tableHead,...s}}}),o.addType(Li,{model:{defaults:{icon:B.tableFoot,...s}}}),o.addType(ws,{model:{defaults:{icon:B.tableRowProperties,...s}}}),o.addType(pe,{model:{defaults:{icon:B.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:i,editor:l,component:a})=>[...Zi({editor:l,component:a,opts:t}),...i]}}}),o.addType(j,{model:{defaults:{icon:B.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:i,editor:l,component:a})=>[...mp({editor:l,component:a,opts:t}),...i]}}});const r=xn((i,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(p=>p.is(j)?p:p.closestType(j)).filter(Boolean);d.length===a.length&&gp(d)},0);n.on("component:select",r),W({editor:n,plan:Ku,pluginName:Uu,licenseKey:t.licenseKey,cleanup:()=>{n.off("component:select",r),n.Blocks.remove(Ie),Ju.forEach(i=>o.removeType(i))}})}),bp="listPagesComponent",Sp=F.startup,tl="page://",St="list-pages",jt="list-pages-item",vt="list-pages-link",vp=n=>n.components().reduce((e,t)=>{var i;const o=t.findFirstType(vt),s=(i=o==null?void 0:o.attributes.attributes)==null?void 0:i.href,r=s!=null&&s.startsWith(tl)?s.replace(tl,""):"";if(r&&o){const l=e[r];l?l.push(o):e[r]=[o]}return e},{}),fo="data-type-role",xp="page_root",wp=n=>e=>e.is(n),Cp=n=>(e,t)=>t.is(n),Ms=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,fo))===n},kp=G(function(n,e={}){const{Blocks:t,Components:o,Pages:s}=n,{licenseKey:r,block:i={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${Ne}${St}`,u=`${Ne}${vt}`,p='<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>',h='<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(St,{block:i&&{label:l,media:p,category:"Extra",select:!0,...e.block},isComponent:Ms(St),model:{defaults:{tagName:"ul",name:l,[xp]:"",classes:d,attributes:{[fo]:St,role:"navigation"},droppable:wp(jt),styles:`
61
+ </svg>`,Pi="layout-icon-picker",Lu="icons-layout-",Ni="icons-list-layout",Oi="gs-iconify-picker",xs="__iconify_collection",$u="https://api.iconify.design",ws=new Map;let po;const zu=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function Ii({collectionId:n,editor:e}){try{if(ws.has(n))return ws.get(n);const t=await fetch(zu({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const o=await t.json();return ws.set(n,o),o}catch(t){console.error("Error fetching collection",t),e.runCommand(G.toastAdd,ju());return}}async function Bu({collectionIds:n,editor:e}){try{if(po)return po;const t=n?`?prefixes=${n.join(",")}`:"",o=await fetch(`${$u}/collections${t}`);if(!o.ok)throw new Error(`Failed to fetch collections: ${o.statusText}`);return po=await o.json(),po}catch(t){console.error("Error fetching collections",t),e.runCommand(G.toastAdd,Di());return}}function Ri(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function Vu({collectionIds:n,editor:e,component:t}){const o=await Bu({collectionIds:n,editor:e});if(!o)return;const s=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},r=Object.entries(o).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),i=t.get("collectionId")??r[0].id;e.runCommand(G.layoutToggle,{id:Pi,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[_u({collectionsList:r,collectionId:i,editor:e,handleClick:s}),{id:Ni,type:"column",grow:!0}]}});const l=await Ii({collectionId:i,editor:e});l&&Cs({editor:e,collection:l,handleClick:s,collectionId:i})}function Hu({editor:n,collection:e}){n.em.set(xs,e)}function Fu(n){return n.em.get(xs)}function Cs(n){const{editor:e}=n,t={id:Lu,layout:Gu(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:Ni}};e.runCommand(G.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>e.runCommand(G.layoutAdd,t),10)}function _u(n){const{collectionsList:e,collectionId:t,editor:o,handleClick:s}=n,r=e.map(({id:i,name:l,total:a})=>({id:i,label:`${l} (${a})`})).sort((i,l)=>i.label.localeCompare(l.label));return{type:"column",style:{gap:10},className:`${Oi}__header`,children:[{type:"selectField",value:t,options:r,emptyState:"Select an icon collection",onChange:async({setState:i,value:l})=>{const a=await Ii({collectionId:l,editor:o});a&&(i({value:l}),Hu({editor:o,collection:a}),Cs({editor:o,collection:a,handleClick:s,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${xs}`]:({setState:i})=>i({value:""})},onInput:({setState:i,value:l,editor:a})=>{const c=Fu(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([u])=>u.includes(l)));i({value:l}),Cs({editor:a,collection:c,handleClick:s,collectionId:l,collectionFiltered:{...c,icons:d}})}}]}}function Gu({collection:n,collectionFiltered:e,handleClick:t}){const{height:o=24,width:s=24,icons:r,prefix:i}=e||n,l=Object.entries(r).map(([a,{body:c}])=>({name:a,body:c}),{});return{type:"column",className:`${Oi}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>[{type:"custom",render:c=>{const{editor:d,addEl:u,removeEl:p}=c,h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.setAttribute("xmlns","http://www.w3.org/2000/svg"),h.innerHTML=a.body,h.setAttribute("viewBox",`0 0 ${s} ${o}`);const{cssWidth:f,cssHeight:m}=Wu(s,o);h.style.cssText=`width: ${f}px; height: ${m}px; cursor: pointer;`,h.addEventListener("mouseover",()=>{h.style.border="2px solid currentColor",h.style.borderRadius="4px",h.style.padding="4px"}),h.addEventListener("mouseout",()=>{h.style.border="none"});const g=()=>{const b=h.cloneNode(!0);b.removeAttribute("style");const C=b.outerHTML;t({icon:C,collectionId:i,iconId:a.name}),d==null||d.runCommand(G.layoutRemove,{id:Pi})};return h.addEventListener("click",g),u(h),()=>{h.removeEventListener("click",g),p(h)}}}]}}}function Wu(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 Di(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:xi.Error}}function ju(){return{...Di(),id:"toast-error-getCollection",content:"Error fetching collection"}}const qu=j(function(n,e={}){var h;const{Components:t,Blocks:o}=n,{collections:s,extendIconComponent:r=!0,licenseKey:i,block:l={}}=e,a="icon",c="iconify",d="Iconify",u="data-type-iconify",p={events:()=>({dblclick:"onActive"}),onActive(){Vu({collectionIds:s,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:vs,content:{type:c},category:"Extra",activate:!0,...l},isComponent:f=>co(f,u),model:{defaults:{name:d,icon:vs,droppable:!1,attributes:{[u]:!0},resizable:Du,components:vs,style:{width:"50px",height:"50px"},traits:[Ri()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:p}),r){const f=(h=t.getType(a))==null?void 0:h.model,[m,g,...b]=f.getDefaults().traits;t.addType(a,{model:{defaults:{traits:[m,g,Ri(),...b]}},view:p})}q({editor:n,licenseKey:i,plan:Ru,pluginName:Iu,cleanup:()=>{o.remove(c),t.removeType(c)}})});function Cn(n,e,t){let o,s,r,i,l;const a=e===void 0?100:e;function c(){const u=Date.now()-i;u<a&&u>=0?o=setTimeout(c,a-u):(o=null,l=n.apply(r,s),r=s=null)}const d=function(){return r=this,s=arguments,i=Date.now(),o||(o=setTimeout(c,a)),l};return d.clear=function(){o&&(clearTimeout(o),o=null)},d.flush=function(){o&&(l=n.apply(r,s),r=s=null,clearTimeout(o),o=null)},d}const Uu="tableComponent",Ku=_.startup;var I=(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))(I||{});const V={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>'},Ie="table",Li="thead",$i="tfoot",ks="tbody",he="row",U="cell",Ts="clipboardTable",Ju=[Ie,Li,$i,ks,he,U],ho=n=>n.em.get(Ts)||[],Zu=n=>n.every(e=>e.is(U)),Es=(n,e)=>{const{editor:t,event:o,opts:s}=n,r=o.currentTarget||o.target,{x:i,y:l,width:a,height:c}=r.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:i,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};bt(s.openSettings)?s.openSettings({...n,layoutProps:d}):t.runCommand(G.layoutToggle,d)},Yu=(n,{rows:e=1,cells:t=5,text:o}={})=>({type:n,components:Array.from(Array(e).keys()).map(s=>({type:he,components:Array.from(Array(t).keys()).map(r=>({type:U,components:o?{type:"text",content:bt(o)?o({y:s,x:r}):o}:void 0}))}))}),zi="Table settings",Bi=n=>{const{component:e}=n;return e.is(Ie)?e:e.closestType(Ie)},Xu=n=>{var e;(e=Bi(n))==null||e.remove(n.opts)},Qu=n=>{const e=Bi(n);e&&(n.editor.select(e),Es(n,{id:"tableSettings",header:{label:zi}}))},Vi=n=>[{id:I.table,icon:V[I.table],label:"Table",items:[{id:I.tableSettings,label:zi,icon:V[I.tableSettings],onClick:({event:t})=>Qu({...n,event:t})},{id:I.tableDelete,label:"Delete table",icon:V[I.tableDelete],onClick:()=>Xu(n)}]}],Hi=({editor:n})=>{const e=ho(n);return e.length&&Zu(e)},Fi=({component:n,editor:e,after:t})=>{if(!n.is(U))return;const o=n.closestType(Ie),s=n.closestType(he),r=n.index()+(t?1:0);o==null||o.findType(he).forEach(l=>l.append({type:U},{at:r}));const i=s==null?void 0:s.components().at(r);i&&e.select(i)},_i=({component:n,opts:e})=>{if(!n.is(U))return;const t=n.closestType(Ie),o=n.index();t==null||t.findType(he).forEach(s=>{var r;return(r=s.components().at(o))==null?void 0:r.remove(e)})},Gi=({component:n,editor:e})=>{if(!n.is(U))return;const t=n.closestType(Ie),o=n.index(),s=(t==null?void 0:t.findType(he).map(r=>r.components().at(o)))||[];s.length&&e.em.set(Ts,s)},Wi=n=>{const{component:e,editor:t,after:o}=n;if(!e.is(U)||!Hi(n))return;const s=ho(t),r=e.closestType(Ie),i=e.index()+(o?1:0);r==null||r.findType(he).forEach((l,a)=>{const c=s[a],d=(c==null?void 0:c.clone())||{type:U};l.append(d,{at:i})})},ep=n=>{const{component:e}=n;e.is(U)&&(Gi(n),_i({...n,opts:{temporary:!0}}))},tp=n=>{const e=Hi(n);return[{id:I.tableColumnItems,icon:V[I.tableColumn],label:"Column",items:[{id:I.tableColumnInsertBefore,label:"Insert column before",icon:V[I.tableColumnInsertBefore],onClick:()=>Fi(n)},{id:I.tableColumnInsertAfter,label:"Insert column after",icon:V[I.tableColumnInsertAfter],onClick:()=>Fi({...n,after:!0})},{id:I.tableColumnDelete,label:"Delete column",icon:V[I.tableColumnDelete],onClick:()=>_i(n)},{id:I.tableColumnCut,label:"Cut column",icon:V[I.tableColumnCut],onClick:()=>ep(n)},{id:I.tableColumnCopy,label:"Copy column",icon:V[I.tableColumnCopy],onClick:()=>Gi(n)},{id:I.tableColumnPasteBefore,label:"Paste column before",icon:V[I.tableColumnPasteBefore],disabled:!e,onClick:()=>Wi(n)},{id:I.tableColumnPasteAfter,label:"Paste column after",icon:V[I.tableColumnPasteAfter],disabled:!e,onClick:()=>Wi({...n,after:!0})}]}]},ji="Row settings",np=n=>n.every(e=>e.is(he)),Wt=n=>{const{component:e}=n,t=e.is(U),o=e.is(he);if(!(!t&&!o))return o?e:e.closestType(he)},qi=n=>{const{component:e,editor:t,after:o}=n,s=Wt(n);if(!s)return;const r=s.index()+(o?1:0),i=s.components().length,l=Array.from(Array(i).keys()).map(()=>({type:U})),a=s.parent();if(a){const c=a.append({type:he,components:l},{at:r})[0];if(e.is(U)&&c){const d=e.index(),u=c.components().at(d);u&&t.select(u)}}},Ui=n=>{var e;(e=Wt(n))==null||e.remove(n.opts)},Ki=n=>{const e=Wt(n);e&&n.editor.em.set(Ts,[e])},Ji=n=>{var l;const{editor:e,after:t}=n,o=Wt(n);if(!o||!Zi(n))return;const r=ho(e)[0],i=o.index()+(t?1:0);r&&((l=o.parent())==null||l.append(r.clone(),{at:i}))},op=n=>{Wt(n)&&(Ki(n),Ui({...n,opts:{temporary:!0}}))},Zi=({editor:n})=>{const e=ho(n);return e.length&&np(e)},sp=n=>{const e=Wt(n);e&&(n.editor.select(e),Es(n,{id:"tableRowSettings",header:{label:ji}}))},Yi=n=>{const e=Zi(n);return[{id:I.tableRowItems,icon:V[I.tableRowProperties],label:"Row",items:[{id:I.tableRowInsertBefore,label:"Insert row before",icon:V[I.tableRowInsertBefore],onClick:()=>qi(n)},{id:I.tableRowInsertAfter,label:"Insert row after",icon:V[I.tableRowInsertAfter],onClick:()=>qi({...n,after:!0})},{id:I.tableRowDelete,label:"Delete row",icon:V[I.tableRowDelete],onClick:()=>Ui(n)},{id:I.tableRowProperties,label:ji,icon:V[I.tableRowProperties],onClick:({event:o})=>sp({...n,event:o})},{id:I.tableRowCut,label:"Cut row",icon:V[I.tableRowCut],onClick:()=>op(n)},{id:I.tableRowCopy,label:"Copy row",icon:V[I.tableRowCopy],onClick:()=>Ki(n)},{id:I.tableRowPasteBefore,label:"Paste row before",icon:V[I.tableRowPasteBefore],disabled:!e,onClick:()=>Ji(n)},{id:I.tableRowPasteAfter,label:"Paste row after",icon:V[I.tableRowPasteAfter],disabled:!e,onClick:()=>Ji({...n,after:!0})}]},...Vi(n)]},Ms=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),o=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:o}};function Xi(n){const e=[];return n.components().forEach((t,o)=>{t.components().each((s,r)=>{const{rowspan:i,colspan:l}=Ms(s);if(e[o])for(;e[o][r];)r++;for(let a=o;a<o+i;a++){e[a]||(e[a]=[]);for(let c=r;c<r+l;c++)e[a][c]={real:a===o&&c===r,cell:s,rowspan:i,colspan:l}}})}),e}function jt(n,e,t){var o;return(o=n[t])==null?void 0:o[e]}const As=n=>n.closestType(he);function rp(n,{x:e,y:t,rows:o,cols:s}){var l;let r=As(n[t][e].cell),i;for(let a=1;a<=o;a++)if(r=(l=r==null?void 0:r.parent())==null?void 0:l.components().at(r.index()+1),r){for(i=e;i>=0;i--){const{cell:c}=n[t+a][i],d=As(c);if(d===r){for(let u=1;u<=s;u++){const p=c.index();d.append({type:U},{at:p+1})}break}}if(i===-1){const d=r.components().at(0).index();for(let u=1;u<=s;u++)r.append({type:U},{at:d})}}}function Qi(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:r,colspan:i}=Ms(s);if(i>1||r>1){s.addAttributes({colspan:1,rowspan:1});for(let l=0;l<i-1;l++){const a=s.index();As(s).append({type:U},{at:a+1})}rp(n,{x:t,y:e,rows:r-1,cols:i})}}}}function ip(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const fo=(n,e={})=>{var i;const t=Xi(n),{em:o}=n;let s,r;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((i=e.selected)!=null&&i.includes(c.cell)||o.selected.hasComponent(c.cell)){const d={x:a,y:l};s||(s=d),r=d}}return{grid:t,startPos:s,endPos:r}};function lp(n,e={}){const t=fo(n),{startPos:o,endPos:s}=t;let{grid:r}=t;const{em:i}=n;if(!o||!s)return;const l=o.x,a=o.y,c=s.x,d=s.y,u=jt(r,l,a),p=jt(r,c,d);if(u&&p){Qi(r),r=Xi(n);const h=[],f=jt(r,l,a).cell;f.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=jt(r,g,m);if(!b)continue;const{cell:C}=b;C!==f&&h.push(C)}h.forEach(m=>{e.mergeContent&&f.append(m.components().models),m.remove()}),i.setSelected(f),ip(n)}}const el="Cell settings",ap="Merge cells",cp="Split cell",dp=n=>n.closestType(he),qt=n=>{var e;return(e=dp(n))==null?void 0:e.parent()},up=n=>{const e=n.editor.getSelectedAll(),t=qt(e[0]),o=e[0];if(!t||!(o!=null&&o.is(U))||e.length>1)return!1;const{rowspan:s,colspan:r}=Ms(o);return!(r<2&&s<2)},pp=n=>{const t=n.editor.getSelectedAll()[0],o=qt(t),{grid:s}=fo(o);Qi(s)},tl=n=>{const e=n.editor.getSelectedAll(),t=qt(e[0]);if(!t||e.length<2||e.some(l=>!l.is(U)||qt(l)!==t))return!1;const{grid:o,startPos:s,endPos:r}=fo(t),{em:i}=t;if(!s||!r)return!1;for(let l=s.y;l<=r.y;l++)for(let a=s.x;a<=r.x;a++){const c=jt(o,a,l);if(!c||!i.selected.hasComponent(c.cell))return!1}return!0},hp=n=>{const{editor:e}=n;if(!tl(n))return;const t=e.getSelectedAll(),o=qt(t[0]);lp(o,{mergeContent:!0})},fp=n=>{Es(n,{id:"tableCellSettings",header:{label:el}})},mp=n=>[{id:I.tableCellItems,icon:V[I.tableCellProperties],label:"Cell",items:[{id:I.tableCellProperties,label:el,icon:V[I.tableCellProperties],onClick:({event:t})=>fp({...n,event:t})},{id:I.tableCellMerge,label:ap,icon:V[I.tableCellMerge],onClick:()=>hp(n),disabled:!tl(n)},{id:I.tableCellSplit,label:cp,icon:V[I.tableCellSplit],onClick:()=>pp(n),disabled:!up(n)}]},...tp(n),...Yi(n)],gp=n=>{const e=n[0]&&qt(n[0]);if(!e)return;const{grid:t,startPos:o,endPos:s}=fo(e,{selected:n});if(!o||!s)return;const r=[];for(let i=o.y;i<=s.y;i++)for(let l=o.x;l<=s.x;l++){const a=jt(t,l,i);a&&r.push(a.cell)}r.length&&e.em.setSelected(r,{fromCell:!0})},yp=j(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(Ie,{block:t.block&&{label:"Table",media:V.table,category:"Extra",content:{type:Ie,style:{width:"100%"}},select:!0,...t.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:V.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:i,value:l,emitUpdate:a}){const c=i.find("caption")[0];l?!c&&i.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):c==null||c.remove(),a(),n.refresh({tools:!0})},getValue(i){return!!i.component.find("caption")[0]}}],components:Yu(ks,{rows:5}),contextMenu:({items:i,editor:l,component:a})=>[...Vi({editor:l,component:a,opts:t}),...i]}}}),o.addType(Li,{model:{defaults:{icon:V.tableHead,...s}}}),o.addType($i,{model:{defaults:{icon:V.tableFoot,...s}}}),o.addType(ks,{model:{defaults:{icon:V.tableRowProperties,...s}}}),o.addType(he,{model:{defaults:{icon:V.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:i,editor:l,component:a})=>[...Yi({editor:l,component:a,opts:t}),...i]}}}),o.addType(U,{model:{defaults:{icon:V.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:i,editor:l,component:a})=>[...mp({editor:l,component:a,opts:t}),...i]}}});const r=Cn((i,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(p=>p.is(U)?p:p.closestType(U)).filter(Boolean);d.length===a.length&&gp(d)},0);n.on("component:select",r),q({editor:n,plan:Ku,pluginName:Uu,licenseKey:t.licenseKey,cleanup:()=>{n.off("component:select",r),n.Blocks.remove(Ie),Ju.forEach(i=>o.removeType(i))}})}),bp="listPagesComponent",Sp=_.startup,nl="page://",vt="list-pages",Ut="list-pages-item",xt="list-pages-link",vp=n=>n.components().reduce((e,t)=>{var i;const o=t.findFirstType(xt),s=(i=o==null?void 0:o.attributes.attributes)==null?void 0:i.href,r=s!=null&&s.startsWith(nl)?s.replace(nl,""):"";if(r&&o){const l=e[r];l?l.push(o):e[r]=[o]}return e},{}),mo="data-type-role",xp="page_root",wp=n=>e=>e.is(n),Cp=n=>(e,t)=>t.is(n),Ps=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,mo))===n},kp=j(function(n,e={}){const{Blocks:t,Components:o,Pages:s}=n,{licenseKey:r,block:i={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${Oe}${vt}`,u=`${Oe}${xt}`,p='<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>',h='<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(vt,{block:i&&{label:l,media:p,category:"Extra",select:!0,...e.block},isComponent:Ps(vt),model:{defaults:{tagName:"ul",name:l,[xp]:"",classes:d,attributes:{[mo]:vt,role:"navigation"},droppable:wp(Ut),styles:`
62
62
  .${d} {
63
63
  list-style: none;
64
64
  margin: 0;
65
65
  padding: 0;
66
66
  }
67
- `},init(){this.syncPageItems=xn(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 f=this.em.Pages.getAll(),m=this.components(),g=vp(this);f.forEach((b,C)=>{const y=b.id,S=b.getName(),v=g[y];v?v==null||v.forEach(w=>{w.getInnerHTML()!==S&&w.components(S)}):m.add({type:jt,components:[{type:vt,attributes:{href:`page://${y}`},components:{type:"textnode",content:S}}]},{at:C})})}}}),o.addType(jt,{isComponent:Ms(jt),model:{defaults:{name:a,tagName:"li",icon:h,attributes:{[fo]:jt},components:{type:vt},draggable:Cp(St)}}}),o.addType(vt,{extend:"link",isComponent:Ms(vt),model:{defaults:{removable:!1,copyable:!1,delegate:{move:f=>f.closestType(jt)},name:c,classes:u,attributes:{[fo]:vt},components:{type:"textnode",content:"Item"},styles:`
67
+ `},init(){this.syncPageItems=Cn(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 f=this.em.Pages.getAll(),m=this.components(),g=vp(this);f.forEach((b,C)=>{const y=b.id,S=b.getName(),x=g[y];x?x==null||x.forEach(w=>{w.getInnerHTML()!==S&&w.components(S)}):m.add({type:Ut,components:[{type:xt,attributes:{href:`page://${y}`},components:{type:"textnode",content:S}}]},{at:C})})}}}),o.addType(Ut,{isComponent:Ps(Ut),model:{defaults:{name:a,tagName:"li",icon:h,attributes:{[mo]:Ut},components:{type:xt},draggable:Cp(vt)}}}),o.addType(xt,{extend:"link",isComponent:Ps(xt),model:{defaults:{removable:!1,copyable:!1,delegate:{move:f=>f.closestType(Ut)},name:c,classes:u,attributes:{[mo]:xt},components:{type:"textnode",content:"Item"},styles:`
68
68
  .${u} {
69
69
  text-decoration: none;
70
70
  }
71
- `}}}),W({editor:n,licenseKey:r,plan:Sp,pluginName:bp,cleanup:()=>{t.remove(St),o.removeType(St)}})}),Tp="fsLightboxComponent",Ep=F.startup,mo="data-fslightbox",go="data-type",Mp="fslightbox-open",qt="fslightbox",Ut={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>'},Ap=G(function(n,e={}){const{Blocks:t,Components:o}=n,s="Lightbox",r=`${Ne}${qt}`,i={toolbarIconOpen:Ut.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}=i,d=function(C){const y=this,S="data-fslightbox",v=window,w=()=>{var M;const x=v.refreshFsLightbox;x==null||x();const T=y.getAttribute(S);if((M=v.fsLightboxInstances)==null||M[T],!v._isEditor)return;Array.from(document.querySelectorAll(`[${S}]`)).forEach(P=>{const O=P.onclick;P.onclick=function(N){N.preventDefault();const L=P;!L.__skipLb&&(O==null||O(N)),L.__skipLb=!0}})};if(v.refreshFsLightbox)w();else{const x=document.createElement("script");x.src=C.cdnScript,x.onload=w,document.head.appendChild(x)}},u=C=>({id:`${qt}-open-lb`,label:a,command:()=>{const y=C.getView();y==null||y.toggleLightbox()}}),p="source-type",h={type:"radio",name:p,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:Ut.image},{id:"video",label:"Video",icon:Ut.video},{id:"el",label:"Custom Element",icon:Ut.external}],labelToTitle:!0},f={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:[f],video:[m],el:[g]};o.addType(qt,{block:l&&{label:s,media:Ut.imageLightbox,category:"Extra",select:!0,...i.block},isComponent:C=>{var y;return(y=C.hasAttribute)==null?void 0:y.call(C,mo)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:s,icon:Ut.imageLightbox,classes:r,draggable:(C,y)=>!y.is(qt),attributes:{[mo]:"lightbox",[go]:"image",href:c},components:{type:"image",src:c},script:d,cdnScript:i.cdnScript,"script-props":["attributes","cdnScript"],[p]:"image",traits:[h,{name:mo,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(C,y){var v;const S=(v=y.target)==null?void 0:v.getView();S==null||S.toggleLightbox()}}],styles:`
71
+ `}}}),q({editor:n,licenseKey:r,plan:Sp,pluginName:bp,cleanup:()=>{t.remove(vt),o.removeType(vt)}})}),Tp="fsLightboxComponent",Ep=_.startup,go="data-fslightbox",yo="data-type",Mp="fslightbox-open",Kt="fslightbox",Jt={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>'},Ap=j(function(n,e={}){const{Blocks:t,Components:o}=n,s="Lightbox",r=`${Oe}${Kt}`,i={toolbarIconOpen:Jt.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}=i,d=function(C){const y=this,S="data-fslightbox",x=window,w=()=>{var M;const v=x.refreshFsLightbox;v==null||v();const E=y.getAttribute(S);if((M=x.fsLightboxInstances)==null||M[E],!x._isEditor)return;Array.from(document.querySelectorAll(`[${S}]`)).forEach(P=>{const N=P.onclick;P.onclick=function(O){O.preventDefault();const $=P;!$.__skipLb&&(N==null||N(O)),$.__skipLb=!0}})};if(x.refreshFsLightbox)w();else{const v=document.createElement("script");v.src=C.cdnScript,v.onload=w,document.head.appendChild(v)}},u=C=>({id:`${Kt}-open-lb`,label:a,command:()=>{const y=C.getView();y==null||y.toggleLightbox()}}),p="source-type",h={type:"radio",name:p,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:Jt.image},{id:"video",label:"Video",icon:Jt.video},{id:"el",label:"Custom Element",icon:Jt.external}],labelToTitle:!0},f={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:[f],video:[m],el:[g]};o.addType(Kt,{block:l&&{label:s,media:Jt.imageLightbox,category:"Extra",select:!0,...i.block},isComponent:C=>{var y;return(y=C.hasAttribute)==null?void 0:y.call(C,go)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:s,icon:Jt.imageLightbox,classes:r,draggable:(C,y)=>!y.is(Kt),attributes:{[go]:"lightbox",[yo]:"image",href:c},components:{type:"image",src:c},script:d,cdnScript:i.cdnScript,"script-props":["attributes","cdnScript"],[p]:"image",traits:[h,{name:go,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(C,y){var x;const S=(x=y.target)==null?void 0:x.getView();S==null||S.toggleLightbox()}}],styles:`
72
72
  .${r} {
73
73
  display: inline-block;
74
74
  padding: 10px;
75
75
  }
76
- `},init(){const C=[p].map(y=>`change:${y}`).join(" ");this.on(C,this.updateTraits),this.on(`change:${p}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(C,y,S){if(S.adjust)return;const w=this.get(p)==="video"?"video":"image";this.addAttributes({[go]:w,href:""})},adjustSourceType(){const C=this.get(p),y=this.getAttributes().href||"",S={adjust:!0};if(C==="video"){const v=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[go]:v},S)}else C!=="el"&&y.startsWith("#")?this.set(p,"el",S):C==="image"&&this.addAttributes({[go]:"image"},S)},updateTraits(C={}){const{changed:y}=this,{init:S}=C;if(y[h.name]||S){this.removeTrait([f.name,m.name,g.name]);const v=this.get(p)||"image",w=this.getTraitIndex(p)+1;this.addTrait(b[v],{at:w})}},initToolbar(){if(!a)return;const{toolbar:C}=this,y=u(this);!C.find(v=>v.id===y.id)&&(C==null||C.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:C,el:y,model:S}=this,{Canvas:v}=C,w=S.getAttributes()[mo],{defaultView:x,documentElement:T}=y.ownerDocument,k=(P=x.fsLightboxInstances)==null?void 0:P[w];if(T.classList.contains(Mp))k.close();else{y.__skipLb=!1;let O;k.props.onOpen=()=>{O=v.getSpots(),setTimeout(()=>v.removeSpots())},k.props.onClose=()=>{O.forEach(N=>v.addSpot(N.attributes))},y.click()}}}}),W({editor:n,plan:Ep,licenseKey:i.licenseKey,pluginName:Tp,cleanup:()=>{t.remove(qt),o.removeType(qt)}})}),Pp="lightGalleryComponent",Op=F.startup;var Kt=(n=>(n.image="image",n.video="video",n.external="external",n))(Kt||{});const xt="lightGallery",nl=`${xt}-item`,yo="data-lightgallery",ol=`${yo}-item`,bo="toggle",wt={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>'},As={propKeys:[],props:{},traits:[]},wn=(n,e={})=>{var s;const t={},o=[];for(const r in n){const{value:i,...l}=n[r];o.push({id:r,name:r,changeProp:!0,category:e.category,...l}),t[r]=i;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}},Ps=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},i=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(i);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},Os=(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,()=>Ps(n,t)),Ps(n,t)})},Np=(n,e,t)=>{const s=n.getTrait(e).get("subTraits")||{},i=(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(i));l.length&&n.on(l.join(" "),t)},Ip={[bo]:{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}},Rp={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"}]}}},Dp={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}]}}},Lp={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}]}}},Qe="sourceType",So="data-iframe",Ns={name:"href",type:"file",label:"Image Source"},vo={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},Is={name:"data-poster",label:"Video Poster",type:"file"},sl={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},rl={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},$p={[bo]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var s,r;const t=e.target,o=(s=t==null?void 0:t.closestType(xt))==null?void 0:s.getView();if(o&&t){const i=((r=o.getLightGallery())==null?void 0:r.items)||[],l=Array.from(i).indexOf(t.getEl());l>=0&&o.toggleGallery(l)}}},[Qe]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[Ns],video:[vo,Is],external:[sl]},options:[{id:"image",label:Ns.label||"",icon:wt.image},{id:"video",label:vo.label||"",icon:wt.video},{id:"external",label:sl.label||"",icon:wt.external}]},subHtml:rl},il="lgThumbnail",zp="lgVideo",ll="lgAutoplay",al="lgZoom",Jt="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Bp=G(function(n,e={}){const{Blocks:t,Components:o}=n,s="LightGallery",r="LightGallery Item",i={toolbarIconOpen:wt.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[il,zp,ll,al],cdnScript:[`${Jt}/lightgallery.min.js`,`${Jt}/plugins/thumbnail/lg-thumbnail.min.js`,`${Jt}/plugins/video/lg-video.min.js`,`${Jt}/plugins/autoplay/lg-autoplay.min.js`,`${Jt}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${Jt}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=i,d=function(y){const S=this,v=window,{plugins:w,cdnScript:x,cdnStyle:T,inline:k,lgLicenseKey:M,...P}=y||{},O=L=>isNaN(L)?void 0:parseInt(L,10),N=()=>{var Z;const L={...P,licenseKey:M,speed:O(P.speed),startAnimationDuration:O(P.startAnimationDuration),thumbMargin:O(P.thumbMargin),thumbWidth:O(P.thumbWidth),slideShowInterval:O(P.slideShowInterval),scale:O(P.scale),enableZoomAfter:O(P.enableZoomAfter),plugins:(w||[]).map(le=>v[le])};k&&(L.container=S,L.closable=!1);const z=(Z=v.lightGallery)==null?void 0:Z.call(v,S,L);k&&z.openGallery()};if(v.lightGallery)N();else{const{head:L}=document,z=Array.isArray(x)?[...x]:[x],Z=Array.isArray(T)?[...T]:[T],le=J=>{if(J.length){const ke=document.createElement("link");ke.href=J.shift(),ke.rel="stylesheet",L.appendChild(ke),le(J)}},Fe=J=>{if(J.length){const ke=document.createElement("script");ke.src=J.shift(),ke.onerror=ke.onload=Fe.bind(null,J),L.appendChild(ke)}else N()};le(Z),Fe(z)}},u=y=>{const S=y.getTrait(bo);if(!a||!S)return;const{toolbar:v}=y,w={id:bo,label:a,command:()=>setTimeout(()=>S.runCommand(),100)};!v.find(T=>T.id===w.id)&&(v==null||v.unshift(w))};let p=[];const h=i.plugins||[],f=wn(Ip),m=h.includes(il)?wn(Rp):As,g=h.includes(ll)?wn(Dp):As,b=h.includes(al)?wn(Lp):As;o.addType(xt,{block:l&&{label:s,media:wt.gallery,category:"Extra",select:!0,...i.block},isComponent:y=>ao(y,yo),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:wt.gallery,draggable:(y,S)=>!S.is(xt),attributes:{[yo]:!0},components:{type:nl},script:d,selector:"",exThumbImage:"",cdnScript:i.cdnScript,cdnStyle:i.cdnStyle,plugins:i.plugins,lgLicenseKey:i.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...f.propKeys,...m.propKeys,...g.propKeys,...b.propKeys],...f.props,...m.props,...g.props,...b.props,traits:[...f.traits,...m.traits,...g.traits,...b.traits]},init(){Os(this,["thumbnail"]),Os(this,["autoplay"]),Os(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 y=this.getLightGallery();y==null||y.destroy()},disableLgInCanvas(){const y=this.getLightGallery();y.lgOpened=!0},isInlineGallery(){var S;const y=this.getLightGallery();return((S=y==null?void 0:y.settings)==null?void 0:S.container)===this.el},onLgInit(y){this.el.__lg=y.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:y}=this,{Canvas:S}=y,v=this.getLightGallery();p=S.getSpots(),setTimeout(()=>S.removeSpots()),v.__lgOpened=!0},onLgClose(){const y=this.getLightGallery();p.forEach(S=>this.em.Canvas.addSpot(S.attributes)),p=[],y.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(y){const S=this.getLightGallery();if(S.__lgOpened)return S.closeGallery(!0);S.lgOpened=!1,S.openGallery(y)}}});const C=wn($p);o.addType(nl,{isComponent:y=>ao(y,ol)||y.tagName==="A"&&ao(y.parentElement,yo),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:r,icon:wt.galleryItem,attributes:{[ol]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...C.props,traits:[...C.traits]},init(){const y=[Qe].map(S=>`change:${S}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Np(this,Qe,this.triggerGalleryUpdate)},initToolbar(){u(this)},initScriptUpdate(){const y=[rl.name].map(S=>`change:attributes:${S}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var S;(S=this.closestType(xt))==null||S.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:S}=this,{init:v}=y;if(S[Qe]||v){Ps(this,Qe);const w=this.getTrait(Qe).getValue();if(w===Kt.image){this.removeAttributes([vo.name,Is.name,So]);const x=this.getTrait(Ns.name);x.setValue(x.getValue()||c)}else w===Kt.video?this.removeAttributes([So]):w===Kt.external&&this.addAttributes({[So]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[So]?this.set(Qe,Kt.external):(y[vo.name]||y[Is.name])&&this.set(Qe,Kt.video)}}}),W({editor:n,plan:Op,licenseKey:i.licenseKey,pluginName:Pp,cleanup:()=>{t.remove(xt),o.removeType(xt)}})}),Te="swiper",Cn=`${Te}-slide`,Zt=`${Te}-wrapper`,Yt=`${Te}-nav-prev`,xo=`${Te}-nav-next`,Xt=`${Te}-pagination`,kn=`${Te}-scrollbar`,ae={slider:`<svg viewBox="0 0 24 24">
76
+ `},init(){const C=[p].map(y=>`change:${y}`).join(" ");this.on(C,this.updateTraits),this.on(`change:${p}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(C,y,S){if(S.adjust)return;const w=this.get(p)==="video"?"video":"image";this.addAttributes({[yo]:w,href:""})},adjustSourceType(){const C=this.get(p),y=this.getAttributes().href||"",S={adjust:!0};if(C==="video"){const x=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[yo]:x},S)}else C!=="el"&&y.startsWith("#")?this.set(p,"el",S):C==="image"&&this.addAttributes({[yo]:"image"},S)},updateTraits(C={}){const{changed:y}=this,{init:S}=C;if(y[h.name]||S){this.removeTrait([f.name,m.name,g.name]);const x=this.get(p)||"image",w=this.getTraitIndex(p)+1;this.addTrait(b[x],{at:w})}},initToolbar(){if(!a)return;const{toolbar:C}=this,y=u(this);!C.find(x=>x.id===y.id)&&(C==null||C.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:C,el:y,model:S}=this,{Canvas:x}=C,w=S.getAttributes()[go],{defaultView:v,documentElement:E}=y.ownerDocument,k=(P=v.fsLightboxInstances)==null?void 0:P[w];if(E.classList.contains(Mp))k.close();else{y.__skipLb=!1;let N;k.props.onOpen=()=>{N=x.getSpots(),setTimeout(()=>x.removeSpots())},k.props.onClose=()=>{N.forEach(O=>x.addSpot(O.attributes))},y.click()}}}}),q({editor:n,plan:Ep,licenseKey:i.licenseKey,pluginName:Tp,cleanup:()=>{t.remove(Kt),o.removeType(Kt)}})}),Pp="lightGalleryComponent",Np=_.startup;var Zt=(n=>(n.image="image",n.video="video",n.external="external",n))(Zt||{});const wt="lightGallery",ol=`${wt}-item`,bo="data-lightgallery",sl=`${bo}-item`,So="toggle",Ct={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>'},Ns={propKeys:[],props:{},traits:[]},kn=(n,e={})=>{var s;const t={},o=[];for(const r in n){const{value:i,...l}=n[r];o.push({id:r,name:r,changeProp:!0,category:e.category,...l}),t[r]=i;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}},Os=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},i=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(i);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},Is=(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,()=>Os(n,t)),Os(n,t)})},Op=(n,e,t)=>{const s=n.getTrait(e).get("subTraits")||{},i=(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(i));l.length&&n.on(l.join(" "),t)},Ip={[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}},Rp={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"}]}}},Dp={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}]}}},Lp={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}]}}},et="sourceType",vo="data-iframe",Rs={name:"href",type:"file",label:"Image Source"},xo={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},Ds={name:"data-poster",label:"Video Poster",type:"file"},rl={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},il={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},$p={[So]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var s,r;const t=e.target,o=(s=t==null?void 0:t.closestType(wt))==null?void 0:s.getView();if(o&&t){const i=((r=o.getLightGallery())==null?void 0:r.items)||[],l=Array.from(i).indexOf(t.getEl());l>=0&&o.toggleGallery(l)}}},[et]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[Rs],video:[xo,Ds],external:[rl]},options:[{id:"image",label:Rs.label||"",icon:Ct.image},{id:"video",label:xo.label||"",icon:Ct.video},{id:"external",label:rl.label||"",icon:Ct.external}]},subHtml:il},ll="lgThumbnail",zp="lgVideo",al="lgAutoplay",cl="lgZoom",Yt="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Bp=j(function(n,e={}){const{Blocks:t,Components:o}=n,s="LightGallery",r="LightGallery Item",i={toolbarIconOpen:Ct.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[ll,zp,al,cl],cdnScript:[`${Yt}/lightgallery.min.js`,`${Yt}/plugins/thumbnail/lg-thumbnail.min.js`,`${Yt}/plugins/video/lg-video.min.js`,`${Yt}/plugins/autoplay/lg-autoplay.min.js`,`${Yt}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${Yt}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=i,d=function(y){const S=this,x=window,{plugins:w,cdnScript:v,cdnStyle:E,inline:k,lgLicenseKey:M,...P}=y||{},N=$=>isNaN($)?void 0:parseInt($,10),O=()=>{var Q;const $={...P,licenseKey:M,speed:N(P.speed),startAnimationDuration:N(P.startAnimationDuration),thumbMargin:N(P.thumbMargin),thumbWidth:N(P.thumbWidth),slideShowInterval:N(P.slideShowInterval),scale:N(P.scale),enableZoomAfter:N(P.enableZoomAfter),plugins:(w||[]).map(ae=>x[ae])};k&&($.container=S,$.closable=!1);const B=(Q=x.lightGallery)==null?void 0:Q.call(x,S,$);k&&B.openGallery()};if(x.lightGallery)O();else{const{head:$}=document,B=Array.isArray(v)?[...v]:[v],Q=Array.isArray(E)?[...E]:[E],ae=L=>{if(L.length){const W=document.createElement("link");W.href=L.shift(),W.rel="stylesheet",$.appendChild(W),ae(L)}},Fe=L=>{if(L.length){const W=document.createElement("script");W.src=L.shift(),W.onerror=W.onload=Fe.bind(null,L),$.appendChild(W)}else O()};ae(Q),Fe(B)}},u=y=>{const S=y.getTrait(So);if(!a||!S)return;const{toolbar:x}=y,w={id:So,label:a,command:()=>setTimeout(()=>S.runCommand(),100)};!x.find(E=>E.id===w.id)&&(x==null||x.unshift(w))};let p=[];const h=i.plugins||[],f=kn(Ip),m=h.includes(ll)?kn(Rp):Ns,g=h.includes(al)?kn(Dp):Ns,b=h.includes(cl)?kn(Lp):Ns;o.addType(wt,{block:l&&{label:s,media:Ct.gallery,category:"Extra",select:!0,...i.block},isComponent:y=>co(y,bo),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:Ct.gallery,draggable:(y,S)=>!S.is(wt),attributes:{[bo]:!0},components:{type:ol},script:d,selector:"",exThumbImage:"",cdnScript:i.cdnScript,cdnStyle:i.cdnStyle,plugins:i.plugins,lgLicenseKey:i.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...f.propKeys,...m.propKeys,...g.propKeys,...b.propKeys],...f.props,...m.props,...g.props,...b.props,traits:[...f.traits,...m.traits,...g.traits,...b.traits]},init(){Is(this,["thumbnail"]),Is(this,["autoplay"]),Is(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 y=this.getLightGallery();y==null||y.destroy()},disableLgInCanvas(){const y=this.getLightGallery();y.lgOpened=!0},isInlineGallery(){var S;const y=this.getLightGallery();return((S=y==null?void 0:y.settings)==null?void 0:S.container)===this.el},onLgInit(y){this.el.__lg=y.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:y}=this,{Canvas:S}=y,x=this.getLightGallery();p=S.getSpots(),setTimeout(()=>S.removeSpots()),x.__lgOpened=!0},onLgClose(){const y=this.getLightGallery();p.forEach(S=>this.em.Canvas.addSpot(S.attributes)),p=[],y.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(y){const S=this.getLightGallery();if(S.__lgOpened)return S.closeGallery(!0);S.lgOpened=!1,S.openGallery(y)}}});const C=kn($p);o.addType(ol,{isComponent:y=>co(y,sl)||y.tagName==="A"&&co(y.parentElement,bo),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:r,icon:Ct.galleryItem,attributes:{[sl]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...C.props,traits:[...C.traits]},init(){const y=[et].map(S=>`change:${S}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Op(this,et,this.triggerGalleryUpdate)},initToolbar(){u(this)},initScriptUpdate(){const y=[il.name].map(S=>`change:attributes:${S}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var S;(S=this.closestType(wt))==null||S.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:S}=this,{init:x}=y;if(S[et]||x){Os(this,et);const w=this.getTrait(et).getValue();if(w===Zt.image){this.removeAttributes([xo.name,Ds.name,vo]);const v=this.getTrait(Rs.name);v.setValue(v.getValue()||c)}else w===Zt.video?this.removeAttributes([vo]):w===Zt.external&&this.addAttributes({[vo]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[vo]?this.set(et,Zt.external):(y[xo.name]||y[Ds.name])&&this.set(et,Zt.video)}}}),q({editor:n,plan:Np,licenseKey:i.licenseKey,pluginName:Pp,cleanup:()=>{t.remove(wt),o.removeType(wt)}})}),Te="swiper",Tn=`${Te}-slide`,Xt=`${Te}-wrapper`,Qt=`${Te}-nav-prev`,wo=`${Te}-nav-next`,en=`${Te}-pagination`,En=`${Te}-scrollbar`,ce={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>`},cl={id:"swiper-responsive",label:"Responsive",icon:ae.responsive},dl={id:"swiper-extra",label:"Extra",icon:ae.extra},Vp={actions:{type:"radio",label:!1,labelToTitle:!0,options:[{id:"r",label:"Reload slider",icon:ae.reload},{id:"p",label:"Previous slide",icon:ae.prev},{id:"n",label:"Next slide",icon:ae.next},{id:"a",label:"Add new slide",icon:ae.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(Yt),setValue:({component:n,value:e})=>{var t,o;e?n.append([{type:Yt},{type:xo}]):((t=n.findFirstType(Yt))==null||t.remove(),(o=n.findFirstType(xo))==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:ae.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:ae.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:ae.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(Xt)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(Xt);t==null||t.remove(),e!=="none"&&n.append({type:Xt}),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:ae.scrollbar},type:"checkbox",label:"Enable Scrollbar",getValue:({component:n})=>!!n.findFirstType(kn),setValue:({component:n,value:e})=>{const t=n.findFirstType(kn);t==null||t.remove(),e&&n.append({type:kn}),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:ae.parallax},type:"checkbox",label:"Enable Parallax",value:!1},mobile:{category:cl,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:cl,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:dl,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:dl,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},ul="Slider",Rs="swiper",Qt=`${Rs}-`,Hp=(n,e)=>{const{Components:t,Blocks:o,Commands:s}=n,{block:r}=e,i=Mu(Vp),l="core:preview",a=s.events,c=function(p){const h=this,f=window,m=h.__onLoad,g=h.__activeSlide,b=h.__inPreview,{cdnScript:C,cdnStyle:y,slidesPerView:S}=p||{},v=x=>isNaN(x)?void 0:parseFloat(x),w=()=>{const x={loop:p.loop,speed:p.speed,initialSlide:p.initialSlide,direction:p.vertical?"vertical":"horizontal",effect:p.effect,freeMode:p.freeMode,parallax:p.parallax,autoHeight:p.autoHeight,allowTouchMove:p.allowTouchMove,grabCursor:p.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(S)?S:v(S),slidesPerGroup:v(p.slidesPerGroup),spaceBetween:v(p.spaceBetween),slidesOffsetBefore:v(p.slidesOffsetBefore),slidesOffsetAfter:v(p.slidesOffsetAfter),centeredSlides:p.centeredSlides,fadeEffect:{crossFade:p.crossFade},cubeEffect:{shadow:p.cubeEffectShadow,slideShadows:p.cubeEffectSlideShadows,shadowOffset:v(p.cubeEffectShadowOffset),shadowScale:v(p.cubeEffectShadowScale)},coverflowEffect:{depth:v(p.coverflowEffectDepth),modifier:v(p.coverflowEffectModifier),rotate:v(p.coverflowEffectRotate),scale:v(p.coverflowEffectScale),stretch:v(p.coverflowEffectStretch),slideShadows:p.coverflowEffectSlideShadows},flipEffect:{limitRotation:p.flipEffectLimitRotation,slideShadows:p.flipEffectSlideShadows},cardsEffect:{perSlideOffset:v(p.cardsEffectPerSlideOffset),perSlideRotate:v(p.cardsEffectPerSlideRotate),rotate:p.cardsEffectRotate,slideShadows:p.cardsEffectSlideShadows},navigation:{nextEl:h.querySelector(".swiper-button-next"),prevEl:h.querySelector(".swiper-button-prev")},pagination:{type:p.pagination||"bullets",dynamicBullets:p.dynamicBullets,clickable:p.clickableBullets,progressbarOpposite:p.progressbarOpposite,el:h.querySelector(".swiper-pagination")},scrollbar:{el:h.querySelector(".swiper-scrollbar"),draggable:p.scrollbarDraggable,hide:p.scrollbarHide},autoplay:p.autoplay&&{delay:p.autoplayDelay,disableOnInteraction:p.autoplayDisableOnInteraction,pauseOnMouseEnter:p.autoplayPauseOnMouseEnter,reverseDirection:p.autoplayReverseDirection,stopOnLastSlide:p.autoplayStopOnLastSlide,waitForTransition:p.autoplayWaitForTransition}};if(p.tablet){const{tabletBreakpoint:k,tabletSlidesPerView:M}=p,P=v(k);x.breakpoints[P]={slidesPerView:isNaN(M)?M:v(M),slidesPerGroup:v(p.tabletSlidesPerGroup),spaceBetween:v(p.tabletSpaceBetween)}}if(p.mobile){const{mobileBreakpoint:k,mobileSlidesPerView:M}=p,P=v(k);x.breakpoints[P]={slidesPerView:isNaN(M)?M:v(M),slidesPerGroup:v(p.mobileSlidesPerGroup),spaceBetween:v(p.mobileSpaceBetween)}}m&&!b&&(x.simulateTouch=!1),g&&(x.initialSlide=g);const T=new f.Swiper(h,x);m==null||m(T)};if(f.Swiper)w();else{const{head:x}=document,T=Array.isArray(C)?[...C]:[C],k=Array.isArray(y)?[...y]:[y],M=O=>{if(O.length){const N=document.createElement("link");N.href=O.shift(),N.rel="stylesheet",x.appendChild(N),M(O)}},P=O=>{if(O.length){const N=document.createElement("script");N.src=O.shift(),N.onerror=N.onload=P.bind(null,O),x.appendChild(N)}else w()};M(k),P(T)}},d=(p=0)=>({type:Cn,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${p}`}}}),u=t.getType("default").model;return t.addType(Te,{block:r&&{label:ul,media:ae.slider,category:"Extra",select:!0,...e.block},isComponent:p=>bt(p,Rs),model:{defaults:()=>({name:ul,icon:ae.slider,classes:Rs,draggable:(p,h)=>!h.is(Te),components:[{type:Zt,components:[d(1),d(2),d(3)]},{type:Xt}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...i.propKeys],...i.props,traits:[...i.traits]}),init(){const{em:p}=this;Au(this,i.traits),Pu(this,i.propKeys),this.listenTo(p,`${a.runCommand}${l}`,this.onPreviewOn),this.listenTo(p,`${a.stopCommand}${l}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const p=this.findFirstType(Zt);p==null||p.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var h;const p=((h=this.findFirstType(Zt))==null?void 0:h.components().length)||0;return{type:Cn,components:{type:"text",components:{type:"textnode",content:`Slide ${p+1}`}}}},toJSON(...p){const h=u.prototype.toJSON.apply(this,p);return i.propsNoValues.forEach(f=>delete h[f]),delete h["script-props"],h}},view:{init(){this.listenTo(this.model,t.events.scriptUnmount,this.destroySwiper)},getSwiper(){return this.el.swiper},destroySwiper(){var p;(p=this.getSwiper())==null||p.destroy()},onRender(){const p=this.el;p.__onLoad=h=>h.on("slideChange",()=>this.__activeSlide=h.activeIndex),p.__activeSlide=this.__activeSlide,p.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(Te),o.remove(Te)}},Fp="Nav Prev",_p="Nav Next",wo=`${Qt}button-prev`,Co=`${Qt}button-next`,Gp=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(Yt,{isComponent:o=>bt(o,wo),model:{defaults:{name:Fp,classes:wo,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
- .${wo} {
99
+ </svg>`},dl={id:"swiper-responsive",label:"Responsive",icon:ce.responsive},ul={id:"swiper-extra",label:"Extra",icon:ce.extra},Vp={actions:{type:"radio",label:!1,labelToTitle:!0,options:[{id:"r",label:"Reload slider",icon:ce.reload},{id:"p",label:"Previous slide",icon:ce.prev},{id:"n",label:"Next slide",icon:ce.next},{id:"a",label:"Add new slide",icon:ce.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:wo}]):((t=n.findFirstType(Qt))==null||t.remove(),(o=n.findFirstType(wo))==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:ce.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:ce.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:ce.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(en)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(en);t==null||t.remove(),e!=="none"&&n.append({type:en}),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:ce.scrollbar},type:"checkbox",label:"Enable Scrollbar",getValue:({component:n})=>!!n.findFirstType(En),setValue:({component:n,value:e})=>{const t=n.findFirstType(En);t==null||t.remove(),e&&n.append({type:En}),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:ce.parallax},type:"checkbox",label:"Enable Parallax",value:!1},mobile:{category:dl,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:dl,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:ul,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:ul,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},pl="Slider",Ls="swiper",tn=`${Ls}-`,Hp=(n,e)=>{const{Components:t,Blocks:o,Commands:s}=n,{block:r}=e,i=Mu(Vp),l="core:preview",a=s.events,c=function(p){const h=this,f=window,m=h.__onLoad,g=h.__activeSlide,b=h.__inPreview,{cdnScript:C,cdnStyle:y,slidesPerView:S}=p||{},x=v=>isNaN(v)?void 0:parseFloat(v),w=()=>{const v={loop:p.loop,speed:p.speed,initialSlide:p.initialSlide,direction:p.vertical?"vertical":"horizontal",effect:p.effect,freeMode:p.freeMode,parallax:p.parallax,autoHeight:p.autoHeight,allowTouchMove:p.allowTouchMove,grabCursor:p.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(S)?S:x(S),slidesPerGroup:x(p.slidesPerGroup),spaceBetween:x(p.spaceBetween),slidesOffsetBefore:x(p.slidesOffsetBefore),slidesOffsetAfter:x(p.slidesOffsetAfter),centeredSlides:p.centeredSlides,fadeEffect:{crossFade:p.crossFade},cubeEffect:{shadow:p.cubeEffectShadow,slideShadows:p.cubeEffectSlideShadows,shadowOffset:x(p.cubeEffectShadowOffset),shadowScale:x(p.cubeEffectShadowScale)},coverflowEffect:{depth:x(p.coverflowEffectDepth),modifier:x(p.coverflowEffectModifier),rotate:x(p.coverflowEffectRotate),scale:x(p.coverflowEffectScale),stretch:x(p.coverflowEffectStretch),slideShadows:p.coverflowEffectSlideShadows},flipEffect:{limitRotation:p.flipEffectLimitRotation,slideShadows:p.flipEffectSlideShadows},cardsEffect:{perSlideOffset:x(p.cardsEffectPerSlideOffset),perSlideRotate:x(p.cardsEffectPerSlideRotate),rotate:p.cardsEffectRotate,slideShadows:p.cardsEffectSlideShadows},navigation:{nextEl:h.querySelector(".swiper-button-next"),prevEl:h.querySelector(".swiper-button-prev")},pagination:{type:p.pagination||"bullets",dynamicBullets:p.dynamicBullets,clickable:p.clickableBullets,progressbarOpposite:p.progressbarOpposite,el:h.querySelector(".swiper-pagination")},scrollbar:{el:h.querySelector(".swiper-scrollbar"),draggable:p.scrollbarDraggable,hide:p.scrollbarHide},autoplay:p.autoplay&&{delay:p.autoplayDelay,disableOnInteraction:p.autoplayDisableOnInteraction,pauseOnMouseEnter:p.autoplayPauseOnMouseEnter,reverseDirection:p.autoplayReverseDirection,stopOnLastSlide:p.autoplayStopOnLastSlide,waitForTransition:p.autoplayWaitForTransition}};if(p.tablet){const{tabletBreakpoint:k,tabletSlidesPerView:M}=p,P=x(k);v.breakpoints[P]={slidesPerView:isNaN(M)?M:x(M),slidesPerGroup:x(p.tabletSlidesPerGroup),spaceBetween:x(p.tabletSpaceBetween)}}if(p.mobile){const{mobileBreakpoint:k,mobileSlidesPerView:M}=p,P=x(k);v.breakpoints[P]={slidesPerView:isNaN(M)?M:x(M),slidesPerGroup:x(p.mobileSlidesPerGroup),spaceBetween:x(p.mobileSpaceBetween)}}m&&!b&&(v.simulateTouch=!1),g&&(v.initialSlide=g);const E=new f.Swiper(h,v);m==null||m(E)};if(f.Swiper)w();else{const{head:v}=document,E=Array.isArray(C)?[...C]:[C],k=Array.isArray(y)?[...y]:[y],M=N=>{if(N.length){const O=document.createElement("link");O.href=N.shift(),O.rel="stylesheet",v.appendChild(O),M(N)}},P=N=>{if(N.length){const O=document.createElement("script");O.src=N.shift(),O.onerror=O.onload=P.bind(null,N),v.appendChild(O)}else w()};M(k),P(E)}},d=(p=0)=>({type:Tn,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${p}`}}}),u=t.getType("default").model;return t.addType(Te,{block:r&&{label:pl,media:ce.slider,category:"Extra",select:!0,...e.block},isComponent:p=>St(p,Ls),model:{defaults:()=>({name:pl,icon:ce.slider,classes:Ls,draggable:(p,h)=>!h.is(Te),components:[{type:Xt,components:[d(1),d(2),d(3)]},{type:en}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...i.propKeys],...i.props,traits:[...i.traits]}),init(){const{em:p}=this;Au(this,i.traits),Pu(this,i.propKeys),this.listenTo(p,`${a.runCommand}${l}`,this.onPreviewOn),this.listenTo(p,`${a.stopCommand}${l}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const p=this.findFirstType(Xt);p==null||p.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var h;const p=((h=this.findFirstType(Xt))==null?void 0:h.components().length)||0;return{type:Tn,components:{type:"text",components:{type:"textnode",content:`Slide ${p+1}`}}}},toJSON(...p){const h=u.prototype.toJSON.apply(this,p);return i.propsNoValues.forEach(f=>delete h[f]),delete h["script-props"],h}},view:{init(){this.listenTo(this.model,t.events.scriptUnmount,this.destroySwiper)},getSwiper(){return this.el.swiper},destroySwiper(){var p;(p=this.getSwiper())==null||p.destroy()},onRender(){const p=this.el;p.__onLoad=h=>h.on("slideChange",()=>this.__activeSlide=h.activeIndex),p.__activeSlide=this.__activeSlide,p.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(Te),o.remove(Te)}},Fp="Nav Prev",_p="Nav Next",Co=`${tn}button-prev`,ko=`${tn}button-next`,Gp=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=>St(o,Co),model:{defaults:{name:Fp,classes:Co,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
+ .${Co} {
101
101
  color: inherit;
102
102
  }
103
- .${wo}:after {
103
+ .${Co}:after {
104
104
  content: none;
105
105
  }
106
- `}}}),e.addType(xo,{extend:Yt,isComponent:o=>bt(o,Co),model:{defaults:{name:_p,classes:Co,components:t("M27,22L27,22L5,44l-2.1-2.1L22.8,22L2.9,2.1L5,0L27,22L27,22z"),styles:`
107
- .${Co} {
106
+ `}}}),e.addType(wo,{extend:Qt,isComponent:o=>St(o,ko),model:{defaults:{name:_p,classes:ko,components:t("M27,22L27,22L5,44l-2.1-2.1L22.8,22L2.9,2.1L5,0L27,22L27,22z"),styles:`
107
+ .${ko} {
108
108
  color: inherit;
109
109
  }
110
- .${Co}:after {
110
+ .${ko}:after {
111
111
  content: none;
112
112
  }
113
- `}}}),()=>{e.removeType(Yt),e.removeType(xo)}},Wp=n=>{const{Components:e}=n,t=`${Qt}pagination`;return e.addType(Xt,{isComponent:o=>bt(o,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(wo)}},Wp=n=>{const{Components:e}=n,t=`${tn}pagination`;return e.addType(en,{isComponent:o=>St(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(Xt)}},jp="Scrollbar",pl=`${Qt}scrollbar`,qp=n=>{const{Components:e}=n;return e.addType(kn,{isComponent:t=>bt(t,pl),model:{defaults:{name:jp,classes:pl,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{e.removeType(kn)}},Up="Slide",hl=`${Qt}slide`,Kp=n=>{const{Components:e}=n;return e.addType(Cn,{isComponent:t=>bt(t,hl),model:{defaults:{name:Up,classes:hl,icon:ae.slider,draggable:(t,o)=>o.is(Zt)}}}),()=>{e.removeType(Cn)}},Jp="Wrapper",fl=`${Qt}wrapper`,Zp=n=>{const{Components:e}=n,{events:t}=e;return e.addType(Zt,{isComponent:o=>bt(o,fl),model:{defaults:{name:Jp,icon:ae.slider,classes:fl,copyable:!1,removable:!1,draggable:!1,highlightable:!1,droppable:o=>o.is(Cn)},init(){const o=this.components();this.listenTo(o,"add remove",this.updateSlider)},updateSlider(o){const s=this.closestType(Te);if(s){const r=s.getView();s.reloadSlider(),this.em.once(t.scriptMount,()=>{setTimeout(()=>{var i;return(i=r.getSwiper())==null?void 0:i.slideTo(o.index())},100)})}}}}),()=>{e.removeType(Zt)}},Yp="swiperComponent",Xp=F.startup,Qp=G(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=[Hp(n,t),Gp(n),Zp(n),Kp(n),Wp(n),qp(n)];W({editor:n,plan:Xp,licenseKey:t.licenseKey,pluginName:Yp,cleanup:()=>{o.forEach(s=>s())}})}),he="accordion",Tn=`${he}-group`,Ge=`${he}-header`,et=`${he}-content`,Ct=`${he}-marker`,ml=`${Ne}${Ge}`,Ds=`${Ne}${Ct}`,eh=`${Ne}${et}`,gl=`${Ds}-open`,kt={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>'},yl=(n,e)=>{const{toolbarIconOpen:t=kt.eye}=e,o=n.is(he)?n:n.closestType(he);if(!t||!o)return;const{toolbar:s}=n,r={id:"accordion-toggle-open",label:t,command:()=>o.toggleOpen()};!s.find(l=>l.id===r.id)&&(s==null||s.unshift(r))},th=(n,e)=>{const{Components:t,Blocks:o}=n,{block:s={}}=e,r="Accordion",i=`${Ne}${he}`,l=function(a={}){const c=this,d=()=>{const{clsMarkerOpen:u}=a,p=c.querySelector('[data-type-role="accordion-marker"]');!p||!u||(c.open?p.classList.add(u):p.classList.remove(u))};c.addEventListener("toggle",()=>{d(),c.dispatchEvent(new CustomEvent("details-toggle",{bubbles:!0}))}),d()};return t.addType(he,{block:s&&{label:r,media:kt.accordion,category:"Extra",select:!0,...s},isComponent:Xe(he),extendFn:["initToolbar"],model:{defaults:{tagName:"details",name:r,classes:i,emptyState:!0,clsMarkerOpen:gl,attributes:{[_e]:he},droppable:co(Ge,et),components:[{type:Ge},{type:et}],"script-props":["clsMarkerOpen"],script:l,traits:[{type:"checkbox",name:"open",label:"Open"}],styles:`
120
+ `}}}),()=>{e.removeType(en)}},jp="Scrollbar",hl=`${tn}scrollbar`,qp=n=>{const{Components:e}=n;return e.addType(En,{isComponent:t=>St(t,hl),model:{defaults:{name:jp,classes:hl,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{e.removeType(En)}},Up="Slide",fl=`${tn}slide`,Kp=n=>{const{Components:e}=n;return e.addType(Tn,{isComponent:t=>St(t,fl),model:{defaults:{name:Up,classes:fl,icon:ce.slider,draggable:(t,o)=>o.is(Xt)}}}),()=>{e.removeType(Tn)}},Jp="Wrapper",ml=`${tn}wrapper`,Zp=n=>{const{Components:e}=n,{events:t}=e;return e.addType(Xt,{isComponent:o=>St(o,ml),model:{defaults:{name:Jp,icon:ce.slider,classes:ml,copyable:!1,removable:!1,draggable:!1,highlightable:!1,droppable:o=>o.is(Tn)},init(){const o=this.components();this.listenTo(o,"add remove",this.updateSlider)},updateSlider(o){const s=this.closestType(Te);if(s){const r=s.getView();s.reloadSlider(),this.em.once(t.scriptMount,()=>{setTimeout(()=>{var i;return(i=r.getSwiper())==null?void 0:i.slideTo(o.index())},100)})}}}}),()=>{e.removeType(Xt)}},Yp="swiperComponent",Xp=_.startup,Qp=j(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=[Hp(n,t),Gp(n),Zp(n),Kp(n),Wp(n),qp(n)];q({editor:n,plan:Xp,licenseKey:t.licenseKey,pluginName:Yp,cleanup:()=>{o.forEach(s=>s())}})}),fe="accordion",Mn=`${fe}-group`,We=`${fe}-header`,tt=`${fe}-content`,kt=`${fe}-marker`,gl=`${Oe}${We}`,$s=`${Oe}${kt}`,eh=`${Oe}${tt}`,yl=`${$s}-open`,Tt={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>'},bl=(n,e)=>{const{toolbarIconOpen:t=Tt.eye}=e,o=n.is(fe)?n:n.closestType(fe);if(!t||!o)return;const{toolbar:s}=n,r={id:"accordion-toggle-open",label:t,command:()=>o.toggleOpen()};!s.find(l=>l.id===r.id)&&(s==null||s.unshift(r))},th=(n,e)=>{const{Components:t,Blocks:o}=n,{block:s={}}=e,r="Accordion",i=`${Oe}${fe}`,l=function(a={}){const c=this,d=()=>{const{clsMarkerOpen:u}=a,p=c.querySelector('[data-type-role="accordion-marker"]');!p||!u||(c.open?p.classList.add(u):p.classList.remove(u))};c.addEventListener("toggle",()=>{d(),c.dispatchEvent(new CustomEvent("details-toggle",{bubbles:!0}))}),d()};return t.addType(fe,{block:s&&{label:r,media:Tt.accordion,category:"Extra",select:!0,...s},isComponent:Qe(fe),extendFn:["initToolbar"],model:{defaults:{tagName:"details",name:r,classes:i,emptyState:!0,clsMarkerOpen:yl,attributes:{[Ge]:fe},droppable:uo(We,tt),components:[{type:We},{type:tt}],"script-props":["clsMarkerOpen"],script:l,traits:[{type:"checkbox",name:"open",label:"Open"}],styles:`
121
121
  .${i}::details-content {
122
122
  opacity: 0;
123
123
  block-size: 0;
@@ -134,40 +134,40 @@
134
134
  transform: translateY(0);
135
135
  block-size: auto;
136
136
  }
137
- `},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){yl(this,e)}}}),()=>{o.remove(he),t.removeType(he)}},nh=n=>{const{Components:e}=n;return e.addType(et,{isComponent:Xe(et),model:{defaults:{name:"Accordion Content",removable:!1,copyable:!1,draggable:!1,emptyState:!0,classes:eh,icon:kt.accordionContent,attributes:{[_e]:et},components:"<div>Accordion content</div>"}}}),()=>{e.removeType(et)}},oh=(n,e)=>{const{Components:t,Blocks:o}=n,{blockGroup:s={}}=e,r="Accordion Group",i=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(h=>{u!==h&&h.open&&(h.open=!1)})})},l=(a={})=>({type:he,attributes:{open:a.open},components:[{type:Ge,components:[`<div>${a.header}</div>`,{type:Ct}]},{type:et,components:`<div>${a.content}</div>`}]});return t.addType(Tn,{block:s&&{label:r,media:kt.accordionGroup,category:"Extra",select:!0,...s},isComponent:Xe(Tn),model:{defaults:{name:r,attributes:{[_e]:Tn},droppable:co(he),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:i}}}),()=>{o.remove(Tn),t.removeType(Tn)}},sh=(n,e)=>{const{Components:t}=n;return t.addType(Ge,{isComponent:Xe(Ge),extendFn:["initToolbar"],model:{defaults:{tagName:"summary",name:"Accordion Header",removable:!1,copyable:!1,draggable:!1,emptyState:!0,icon:kt.accordionHeader,classes:ml,attributes:{[_e]:Ge},components:["<div>Accordion header</div>",{type:Ct}],styles:`
137
+ `},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){bl(this,e)}}}),()=>{o.remove(fe),t.removeType(fe)}},nh=n=>{const{Components:e}=n;return e.addType(tt,{isComponent:Qe(tt),model:{defaults:{name:"Accordion Content",removable:!1,copyable:!1,draggable:!1,emptyState:!0,classes:eh,icon:Tt.accordionContent,attributes:{[Ge]:tt},components:"<div>Accordion content</div>"}}}),()=>{e.removeType(tt)}},oh=(n,e)=>{const{Components:t,Blocks:o}=n,{blockGroup:s={}}=e,r="Accordion Group",i=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(h=>{u!==h&&h.open&&(h.open=!1)})})},l=(a={})=>({type:fe,attributes:{open:a.open},components:[{type:We,components:[`<div>${a.header}</div>`,{type:kt}]},{type:tt,components:`<div>${a.content}</div>`}]});return t.addType(Mn,{block:s&&{label:r,media:Tt.accordionGroup,category:"Extra",select:!0,...s},isComponent:Qe(Mn),model:{defaults:{name:r,attributes:{[Ge]:Mn},droppable:uo(fe),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:i}}}),()=>{o.remove(Mn),t.removeType(Mn)}},sh=(n,e)=>{const{Components:t}=n;return t.addType(We,{isComponent:Qe(We),extendFn:["initToolbar"],model:{defaults:{tagName:"summary",name:"Accordion Header",removable:!1,copyable:!1,draggable:!1,emptyState:!0,icon:Tt.accordionHeader,classes:gl,attributes:{[Ge]:We},components:["<div>Accordion header</div>",{type:kt}],styles:`
138
138
  summary {
139
139
  list-style: none;
140
140
  }
141
- .${ml} {
141
+ .${gl} {
142
142
  cursor: pointer;
143
143
  display: flex;
144
144
  align-items: center;
145
145
  justify-content: space-between;
146
146
  gap: 1rem;
147
147
  }
148
- `},initToolbar(){yl(this,e)}}}),()=>{t.removeType(Ge)}},rh=n=>{const{Components:e}=n;return e.addType(Ct,{extend:"icon",isComponent:Xe(Ct),model:{defaults:{name:"Accordion Marker",icon:kt.accordionMarker,classes:Ds,attributes:{[_e]:Ct},components:kt.caret,droppable:!1,draggable:gs(Ge),styles:`
149
- .${Ds} {
148
+ `},initToolbar(){bl(this,e)}}}),()=>{t.removeType(We)}},rh=n=>{const{Components:e}=n;return e.addType(kt,{extend:"icon",isComponent:Qe(kt),model:{defaults:{name:"Accordion Marker",icon:Tt.accordionMarker,classes:$s,attributes:{[Ge]:kt},components:Tt.caret,droppable:!1,draggable:bs(We),styles:`
149
+ .${$s} {
150
150
  min-width: 24px;
151
151
  width: 24px;
152
152
  height: 24px;
153
153
  transition: transform 0.2s ease-in-out;
154
154
  }
155
- .${gl} {
155
+ .${yl} {
156
156
  transform: rotateZ(180deg);
157
157
  }
158
- `}}}),()=>{e.removeType(Ct)}},ih="accordionComponent",lh=F.startup,ah=G(function(n,e={}){const t=[th(n,e),oh(n,e),sh(n,e),rh(n),nh(n)];W({editor:n,licenseKey:e.licenseKey,plan:lh,pluginName:ih,cleanup:()=>{t.forEach(o=>o())}})}),ro=class ro{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):Hs(e.componentColumn,ro.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:r}=e;o.addStyle({[ro.CSS_FLEX_BASIS]:s},{partial:r})}}};ro.CSS_FLEX_BASIS="flex-basis";let Ls=ro;const io=class io{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):Hs(e.componentRow,io.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:o,gapValue:s,partial:r}=e;o.addStyle({[io.CSS_GAP]:s},{partial:r})}}};io.CSS_GAP="gap";let $s=io;const hs=class hs{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();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=Hs(e.componentRow,hs.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};hs.CSS_FLEX_DIRECTION="flex-direction";let zs=hs;const lo=class lo{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(lo.MJML_COLUMN_TYPE)){const r=t.getAttributes().width;if(r&&(r.includes("%")||!isNaN(parseFloat(r))))return parseFloat(r);const i=t.parent();return 100/(i?i.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:r}=e;o.is(lo.MJML_COLUMN_TYPE)&&o.addAttributes({width:`${parseFloat(s)}%`},{partial:r})}}};lo.MJML_COLUMN_TYPE="mj-column";let Bs=lo;const fs=class fs{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(fs.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)}};fs.MJML_SECTION_TYPE="mj-section";let Vs=fs;class ch{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();if(!s)return 0;let r=s;if(s.tagName!=="TABLE"){const l=s.querySelectorAll("table");l.length&&(r=l[0])}return o?r.clientHeight:r.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class en{constructor(){this.handlerCache=new Map}static getInstance(){return en.instance||(en.instance=new en),en.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(tn(e)?this.handlerCache.set(t,{sizeHandler:new Bs(e),gapHandler:new Vs(e),parentSizeHandler:new ch(e)}):this.handlerCache.set(t,{sizeHandler:new Ls(e),gapHandler:new $s(e),parentSizeHandler:new zs(e)})),this.handlerCache.get(t)}}function Tt(n){return en.getInstance().getHandlers(n)}const bl=n=>{n.style.display="none"},Sl=n=>{n.style.display="block"},En=n=>+parseFloat(`${n}`).toFixed(2),tn=n=>n.projectType===Ci.email,ko=(n,e)=>{const t=n.Canvas.getFramesEl();t&&(t.style.pointerEvents=e?"none":"")},dh=n=>n?["top","bottom"]:["left","right"],uh=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},ph=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},hh=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},fh=(n,e,t,o)=>{const r=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return r>=0&&r<o?r:-1},To=n=>n==="top"||n==="bottom",mh=(n,e)=>!!(uh(n)&&(e==="left"||e==="top")||ph(n)&&(e==="right"||e==="bottom")),gh=n=>{const e=n.parent();return e?e.components().models.length>1:!1},vl=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,Hs=(n,e,t=!1)=>{const o=!t,s=n.getEl();if(!s)return o?0:"";const i=window.getComputedStyle(s)[e]||"";if(o){let l;return typeof i=="string"?(l=parseFloat(i.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(i)||0,l}return i},xl=(n,e,t)=>{const o=Fs({componentRow:n,isVertical:e},t),s=n.components().models;return o*(s.length-1)},Mn=(n,e)=>Tt(e).parentSizeHandler.isLayoutVertical({componentRow:n}),An=(n,e)=>Tt(e).sizeHandler.getSize(n),Fs=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:o}=Tt(e);if(!t.isGapSupported())return 0;const s=t.getGap(n),r=o.getParentSize(n);return s/100*r},_s=(n,e)=>Tt(e).parentSizeHandler.getParentSize(n),Pn=(n,e)=>{Tt(e).sizeHandler.setSize(n)},wl=(n,e)=>{const t=An(n,e);Pn({...n,sizeValue:`${t}%`,partial:!1},e)},Cl=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=Tt(e);t.isGapSupported()&&t.setGap(n)},yh=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const o=n.components().models,s={componentRow:n,isVertical:Mn(n,e)};o.map(r=>wl({...s,componentColumn:r},e)),Cl({...s,gapValue:String(t),partial:!1},e)};function bh(n,e){const{Blocks:t}=n,{typeColumn:o,typeRow:s,blocks:r}=e;if(r===!1||tn(e))return;const i=u=>({type:s,components:u.map(p=>({type:o,style:{"flex-basis":`${p}%`}}))}),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(kt)}},ih="accordionComponent",lh=_.startup,ah=j(function(n,e={}){const t=[th(n,e),oh(n,e),sh(n,e),rh(n),nh(n)];q({editor:n,licenseKey:e.licenseKey,plan:lh,pluginName:ih,cleanup:()=>{t.forEach(o=>o())}})}),io=class io{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):_s(e.componentColumn,io.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:r}=e;o.addStyle({[io.CSS_FLEX_BASIS]:s},{partial:r})}}};io.CSS_FLEX_BASIS="flex-basis";let zs=io;const lo=class lo{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):_s(e.componentRow,lo.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:o,gapValue:s,partial:r}=e;o.addStyle({[lo.CSS_GAP]:s},{partial:r})}}};lo.CSS_GAP="gap";let Bs=lo;const hs=class hs{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();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=_s(e.componentRow,hs.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};hs.CSS_FLEX_DIRECTION="flex-direction";let Vs=hs;const ao=class ao{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(ao.MJML_COLUMN_TYPE)){const r=t.getAttributes().width;if(r&&(r.includes("%")||!isNaN(parseFloat(r))))return parseFloat(r);const i=t.parent();return 100/(i?i.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:r}=e;o.is(ao.MJML_COLUMN_TYPE)&&o.addAttributes({width:`${parseFloat(s)}%`},{partial:r})}}};ao.MJML_COLUMN_TYPE="mj-column";let Hs=ao;const fs=class fs{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(fs.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)}};fs.MJML_SECTION_TYPE="mj-section";let Fs=fs;class ch{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();if(!s)return 0;let r=s;if(s.tagName!=="TABLE"){const l=s.querySelectorAll("table");l.length&&(r=l[0])}return o?r.clientHeight:r.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class nn{constructor(){this.handlerCache=new Map}static getInstance(){return nn.instance||(nn.instance=new nn),nn.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(on(e)?this.handlerCache.set(t,{sizeHandler:new Hs(e),gapHandler:new Fs(e),parentSizeHandler:new ch(e)}):this.handlerCache.set(t,{sizeHandler:new zs(e),gapHandler:new Bs(e),parentSizeHandler:new Vs(e)})),this.handlerCache.get(t)}}function Et(n){return nn.getInstance().getHandlers(n)}const Sl=n=>{n.style.display="none"},vl=n=>{n.style.display="block"},An=n=>+parseFloat(`${n}`).toFixed(2),on=n=>n.projectType===ki.email,To=(n,e)=>{const t=n.Canvas.getFramesEl();t&&(t.style.pointerEvents=e?"none":"")},dh=n=>n?["top","bottom"]:["left","right"],uh=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},ph=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},hh=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},fh=(n,e,t,o)=>{const r=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return r>=0&&r<o?r:-1},Eo=n=>n==="top"||n==="bottom",mh=(n,e)=>!!(uh(n)&&(e==="left"||e==="top")||ph(n)&&(e==="right"||e==="bottom")),gh=n=>{const e=n.parent();return e?e.components().models.length>1:!1},xl=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,_s=(n,e,t=!1)=>{const o=!t,s=n.getEl();if(!s)return o?0:"";const i=window.getComputedStyle(s)[e]||"";if(o){let l;return typeof i=="string"?(l=parseFloat(i.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(i)||0,l}return i},wl=(n,e,t)=>{const o=Gs({componentRow:n,isVertical:e},t),s=n.components().models;return o*(s.length-1)},Pn=(n,e)=>Et(e).parentSizeHandler.isLayoutVertical({componentRow:n}),Nn=(n,e)=>Et(e).sizeHandler.getSize(n),Gs=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:o}=Et(e);if(!t.isGapSupported())return 0;const s=t.getGap(n),r=o.getParentSize(n);return s/100*r},Ws=(n,e)=>Et(e).parentSizeHandler.getParentSize(n),On=(n,e)=>{Et(e).sizeHandler.setSize(n)},Cl=(n,e)=>{const t=Nn(n,e);On({...n,sizeValue:`${t}%`,partial:!1},e)},kl=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=Et(e);t.isGapSupported()&&t.setGap(n)},yh=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const o=n.components().models,s={componentRow:n,isVertical:Pn(n,e)};o.map(r=>Cl({...s,componentColumn:r},e)),kl({...s,gapValue:String(t),partial:!1},e)};function bh(n,e){const{Blocks:t}=n,{typeColumn:o,typeRow:s,blocks:r}=e;if(r===!1||on(e))return;const i=u=>({type:s,components:u.map(p=>({type:o,style:{"flex-basis":`${p}%`}}))}),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(p=>`<div style="flex-basis: ${p}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
160
- </div>`,a=(u,p)=>({id:`flex-row-${p.join("-")}`,label:u,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(p),content:i(p)}),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=yt(r)?r({blocks:c}):c;return d.forEach(u=>t.add(u.id,u)),()=>{d.forEach(u=>t.remove(u.id))}}const Sh=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:s,extendTypeColumn:r}=e,i=`${Ne}${s}`,a=!!s&&!!t.getType(s)&&!r;if(!(!s||a||tn(e)))return t.addType(s,{isComponent:Xe(s),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:i,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:gs(o),attributes:{[_e]:s},styles:`
160
+ </div>`,a=(u,p)=>({id:`flex-row-${p.join("-")}`,label:u,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(p),content:i(p)}),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=bt(r)?r({blocks:c}):c;return d.forEach(u=>t.add(u.id,u)),()=>{d.forEach(u=>t.remove(u.id))}}const Sh=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:s,extendTypeColumn:r}=e,i=`${Oe}${s}`,a=!!s&&!!t.getType(s)&&!r;if(!(!s||a||on(e)))return t.addType(s,{isComponent:Qe(s),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:i,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:bs(o),attributes:{[Ge]:s},styles:`
161
161
  .${i} {
162
162
  flex-grow: 1;
163
163
  }
164
- `}}}),()=>{t.removeType(s)}},vh=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:s,extendTypeRow:r}=e,i=`${Ne}${o}`,a=!!o&&!!t.getType(o)&&!r;if(!(!o||a||tn(e)))return t.addType(o,{isComponent:Xe(o),model:{defaults:{name:"Row",classes:i,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:{[_e]:o},droppable:co(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:`
164
+ `}}}),()=>{t.removeType(s)}},vh=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:s,extendTypeRow:r}=e,i=`${Oe}${o}`,a=!!o&&!!t.getType(o)&&!r;if(!(!o||a||on(e)))return t.addType(o,{isComponent:Qe(o),model:{defaults:{name:"Row",classes:i,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:uo(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
  .${i} {
166
166
  display: flex;
167
167
  align-items: stretch;
168
168
  flex-wrap: nowrap;
169
169
  }
170
- `}}}),()=>{t.removeType(o)}},xh="flexComponent",wh=F.startup;class Ch{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 kh{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,r=this.getState(e);r.direction=t,r.startX=o.clientX,r.startY=o.clientY,r.resizing=!0,r.lastSnappedPercent=void 0;const i=e.parent();if(!i||!this.registry.isValidRelationship(i,e))return;r.snapEnabled=i.get("snap")??s.snapEnabled,r.snapDivisions=i.get("snap-divisions")??s.snapDivisions??12;const l=i.components().models,a=l.findIndex(p=>p.cid===e.cid),c=Mn(i,s),d=fh(a,t,c,l.length);d!==-1&&(r.adjacentIdx=d);const u={componentColumn:e,componentRow:i,isVertical:c};if(r.startPercent=An(u,s),typeof r.adjacentIdx<"u"){const p=l[r.adjacentIdx];r.neighborStartPercent=An({...u,componentColumn:p},s)}}updateResizeByDelta(e,t,o){const s=this.getState(e),r=e.parent();!s.resizing||!r||(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&&Mn(t,this.opts)};o==null||o.forEach(r=>wl({...s,componentColumn:r},this.opts)),this.clearState(e)}updateContinuesResize(e,t,o){const s=this.getState(e),r=e.parent(),{opts:i}=this;if(!r)return;const l=i.minItemPercent??0,a=To(t),c=_s({componentRow:r,isVertical:a},i),d=xl(r,a,this.opts),p=100-d/c*100,h=o/(c-d)*p,{startPercent:f=0,neighborStartPercent:m=0}=s,g={componentRow:r,isVertical:a,componentColumn:e,partial:!0},b=vl(t,o)?f+Math.abs(h):f-Math.abs(h);if(typeof s.adjacentIdx<"u"){const C=r.components().models[s.adjacentIdx],y=f+m,S=y-l,w=Math.min(S,Math.max(l,b)),x=y-w;Pn({...g,sizeValue:`${En(w)}%`},i),Pn({...g,componentColumn:C,sizeValue:`${En(x)}%`},i)}else{const C=Math.max(l,Math.min(p,b));Pn({...g,sizeValue:`${En(C)}%`},i)}}updateSnapResize(e,t,o){const s=this.getState(e),r=e.parent(),i=To(t),l=_s({componentRow:r,isVertical:i},this.opts),a=xl(r,i,this.opts),c=l-a,d=o/c*100,u=vl(t,o),{startPercent:p=0,snapDivisions:h=12}=s,f=u?p+Math.abs(d):p-Math.abs(d),m=100/h,g=Math.floor(f/m)*m,b=Math.ceil(f/m)*m,C=Math.abs(b-f),y=Math.abs(f-g),S=m*.2,v=C<y?b:g;if(v>0&&v<100&&(C<S||y<S)&&s.lastSnappedPercent!==v){s.lastSnappedPercent=v;let T=Math.abs(v-p)/100*c;(u&&(t==="left"||t==="top")||!u&&(t==="right"||t==="bottom"))&&(T=-T),this.updateContinuesResize(e,t,T)}else C>=S&&y>=S&&(s.lastSnappedPercent=void 0)}}class Th{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:r}=this,i=Math.max(0,o+t),l=_s({componentRow:e,isVertical:s},r),a=i/l*100,c=e.components().models,d=c.length-1,u={componentRow:e,isVertical:s},p=c.reduce((S,v)=>S+An({...u,componentColumn:v},r),0),f=100-a*d,m=r.minItemPercent||5;if(f<m*c.length)return;const b=100-d*a,C=p-b,y={componentRow:e,isVertical:s,partial:!0};c.map(S=>{const v=An({...u,componentColumn:S},r),w=v-v/p*C;Pn({...y,componentColumn:S,sizeValue:`${En(w)}%`},r)}),Cl({...y,gapValue:`${En(a)}%`},r)}finishGapAdjust(e){yh(e,this.opts)}}class Eh{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o,this.resizeHandler=new kh(e,t,o),this.gapHandler=new Th(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 Eo="gs-flex-spots",kl=`${Eo}__handle-size`,Mh=`${Eo}__handle-gap`;function Ah(n,e){const{Canvas:t}=n,o="flex-resize-spot";let s,r,i,l,a=null,c=null;const d=new Ch,u=new Eh(n,d,e),p=()=>{var w;s=document.createElement("div"),s.className=Eo,s.style.display="none",r=document.createElement("div"),r.className=`${Eo}__handles`,r.style.position="absolute",r.style.pointerEvents="none",r.style.zIndex="21",i={left:document.createElement("div"),right:document.createElement("div"),top:document.createElement("div"),bottom:document.createElement("div")},Object.entries(i).forEach(([x,T])=>{const k=x,M=To(k);T.className=`${kl} ${kl}-${k} gjs-resizer-h gjs-cv-unscale`,T.style.cssText=`
170
+ `}}}),()=>{t.removeType(o)}},xh="flexComponent",wh=_.startup;class Ch{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 kh{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,r=this.getState(e);r.direction=t,r.startX=o.clientX,r.startY=o.clientY,r.resizing=!0,r.lastSnappedPercent=void 0;const i=e.parent();if(!i||!this.registry.isValidRelationship(i,e))return;r.snapEnabled=i.get("snap")??s.snapEnabled,r.snapDivisions=i.get("snap-divisions")??s.snapDivisions??12;const l=i.components().models,a=l.findIndex(p=>p.cid===e.cid),c=Pn(i,s),d=fh(a,t,c,l.length);d!==-1&&(r.adjacentIdx=d);const u={componentColumn:e,componentRow:i,isVertical:c};if(r.startPercent=Nn(u,s),typeof r.adjacentIdx<"u"){const p=l[r.adjacentIdx];r.neighborStartPercent=Nn({...u,componentColumn:p},s)}}updateResizeByDelta(e,t,o){const s=this.getState(e),r=e.parent();!s.resizing||!r||(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&&Pn(t,this.opts)};o==null||o.forEach(r=>Cl({...s,componentColumn:r},this.opts)),this.clearState(e)}updateContinuesResize(e,t,o){const s=this.getState(e),r=e.parent(),{opts:i}=this;if(!r)return;const l=i.minItemPercent??0,a=Eo(t),c=Ws({componentRow:r,isVertical:a},i),d=wl(r,a,this.opts),p=100-d/c*100,h=o/(c-d)*p,{startPercent:f=0,neighborStartPercent:m=0}=s,g={componentRow:r,isVertical:a,componentColumn:e,partial:!0},b=xl(t,o)?f+Math.abs(h):f-Math.abs(h);if(typeof s.adjacentIdx<"u"){const C=r.components().models[s.adjacentIdx],y=f+m,S=y-l,w=Math.min(S,Math.max(l,b)),v=y-w;On({...g,sizeValue:`${An(w)}%`},i),On({...g,componentColumn:C,sizeValue:`${An(v)}%`},i)}else{const C=Math.max(l,Math.min(p,b));On({...g,sizeValue:`${An(C)}%`},i)}}updateSnapResize(e,t,o){const s=this.getState(e),r=e.parent(),i=Eo(t),l=Ws({componentRow:r,isVertical:i},this.opts),a=wl(r,i,this.opts),c=l-a,d=o/c*100,u=xl(t,o),{startPercent:p=0,snapDivisions:h=12}=s,f=u?p+Math.abs(d):p-Math.abs(d),m=100/h,g=Math.floor(f/m)*m,b=Math.ceil(f/m)*m,C=Math.abs(b-f),y=Math.abs(f-g),S=m*.2,x=C<y?b:g;if(x>0&&x<100&&(C<S||y<S)&&s.lastSnappedPercent!==x){s.lastSnappedPercent=x;let E=Math.abs(x-p)/100*c;(u&&(t==="left"||t==="top")||!u&&(t==="right"||t==="bottom"))&&(E=-E),this.updateContinuesResize(e,t,E)}else C>=S&&y>=S&&(s.lastSnappedPercent=void 0)}}class Th{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:r}=this,i=Math.max(0,o+t),l=Ws({componentRow:e,isVertical:s},r),a=i/l*100,c=e.components().models,d=c.length-1,u={componentRow:e,isVertical:s},p=c.reduce((S,x)=>S+Nn({...u,componentColumn:x},r),0),f=100-a*d,m=r.minItemPercent||5;if(f<m*c.length)return;const b=100-d*a,C=p-b,y={componentRow:e,isVertical:s,partial:!0};c.map(S=>{const x=Nn({...u,componentColumn:S},r),w=x-x/p*C;On({...y,componentColumn:S,sizeValue:`${An(w)}%`},r)}),kl({...y,gapValue:`${An(a)}%`},r)}finishGapAdjust(e){yh(e,this.opts)}}class Eh{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o,this.resizeHandler=new kh(e,t,o),this.gapHandler=new Th(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 Mo="gs-flex-spots",Tl=`${Mo}__handle-size`,Mh=`${Mo}__handle-gap`;function Ah(n,e){const{Canvas:t}=n,o="flex-resize-spot";let s,r,i,l,a=null,c=null;const d=new Ch,u=new Eh(n,d,e),p=()=>{var w;s=document.createElement("div"),s.className=Mo,s.style.display="none",r=document.createElement("div"),r.className=`${Mo}__handles`,r.style.position="absolute",r.style.pointerEvents="none",r.style.zIndex="21",i={left:document.createElement("div"),right:document.createElement("div"),top:document.createElement("div"),bottom:document.createElement("div")},Object.entries(i).forEach(([v,E])=>{const k=v,M=Eo(k);E.className=`${Tl} ${Tl}-${k} gjs-resizer-h gjs-cv-unscale`,E.style.cssText=`
171
171
  pointer-events: all;
172
172
  position: absolute;
173
173
  z-index: 1;
@@ -177,7 +177,7 @@
177
177
  ${k==="right"?"right: 0px;":""}
178
178
  ${k==="top"?"top: 0px;":""}
179
179
  ${k==="bottom"?"bottom: 0px;":""}
180
- `,T.addEventListener("pointerdown",h(k)),r.appendChild(T)}),!e.disableGapHandler&&!tn(e)&&(l=document.createElement("div"),l.className=Mh,l.style.cssText=`
180
+ `,E.addEventListener("pointerdown",h(k)),r.appendChild(E)}),!e.disableGapHandler&&!on(e)&&(l=document.createElement("div"),l.className=Mh,l.style.cssText=`
181
181
  position: absolute;
182
182
  background-color: var(--gs-theme-cl-cmp-bg1, #3b97e3);
183
183
  border-width: 2px;
@@ -187,7 +187,7 @@
187
187
  pointer-events: all;
188
188
  max-width: 3rem;
189
189
  max-height: 3rem;
190
- `,l.addEventListener("pointerdown",f()),r.appendChild(l)),s.append(r),(w=t.getSpotsEl())==null||w.appendChild(s)},h=w=>x=>{if(!a)return;ko(n,!0),x.stopPropagation(),x.preventDefault(),u.startResize(a,w,x);const T=x.clientX,k=x.clientY;x.target.setPointerCapture(x.pointerId);const M=O=>{const N=n.Canvas.getZoomMultiplier(),L=(O.clientX-T)*N,z=(O.clientY-k)*N,Z=To(w)?z:L;u.updateResizeByDelta(a,w,Z)},P=()=>{ko(n,!1),u.finishResize(a),x.target.releasePointerCapture(x.pointerId),document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",P)};document.addEventListener("pointermove",M),document.addEventListener("pointerup",P)},f=()=>w=>{if(!c)return;const x=c;ko(n,!0),w.stopPropagation(),w.preventDefault();const T=Mn(x,e),k=Fs({componentRow:x,isVertical:T},e),M=w.clientX,P=w.clientY;w.target.setPointerCapture(w.pointerId);const O=L=>{const z=n.Canvas.getZoomMultiplier(),Z=T?(L.clientY-P)*z:(L.clientX-M)*z;u.updateGapByDelta(x,Z,k,T)},N=()=>{ko(n,!1),u.finishGapAdjust(x),w.target.releasePointerCapture(w.pointerId),document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",N)};document.addEventListener("pointermove",O),document.addEventListener("pointerup",N)},m=w=>{const x=w.component;if(!x||!s||(a=x,c=x.parent(),!c))return;const T=c;Sl(s);const k=w.getStyle();r&&Object.assign(r.style,k);const M=Mn(T,e),P=dh(M);if(Object.values(i).forEach(bl),P.forEach(N=>{if(mh(x,N))return;const L=i[N];Sl(L)}),Tt(e).gapHandler.isGapSupported()&&l&&gh(x)){const N=Fs({componentRow:T,isVertical:M},e);g(N,M,hh(x))}},g=(w,x,T=!1)=>{const k=e.gapHandleSize,M=l.style;if(x){M.height=`${k}px`;const P=l.offsetHeight;T?(M.top=`-${(w+P)/2}px`,M.bottom=""):(M.bottom=`-${(w+P)/2}px`,M.top=""),M.width="50%",M.left="50%",M.transform="translateX(-50%)",M.cursor="row-resize"}else{M.width=`${k}px`;const P=l.offsetWidth;T?(M.left=`-${(w+P)/2}px`,M.right=""):(M.right=`-${(w+P)/2}px`,M.left=""),M.height="50%",M.top="50%",M.transform="translateY(-50%)",M.cursor="col-resize"}},b=()=>{s&&(bl(s),a=null,c=null)},C=()=>{t.removeSpots({type:o});const w=n.getSelected(),x=w==null?void 0:w.parent();w&&x&&d.isValidRelationship(x,w)?t.addSpot({type:o,component:w}):b()},y=()=>{const w=t.getSpots().filter(x=>x.type===o)[0];w&&m(w)},S=(w,x)=>{d.registerTypeRelationship(w,x)};n.onReady(()=>{p(),tn(e)?S("mj-section","mj-column"):S(e.typeRow,e.typeColumn)});const v="component:toggled";return n.on(t.events.spot,y),n.on(v,C),()=>{n.off(t.events.spot,y),n.off(v,C)}}const Ph=G(function(n,e={}){const t={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...e},o=[vh(n,t),Sh(n,t)],s=Ah(n,t),r=bh(n,t);W({editor:n,licenseKey:t.licenseKey,plan:wh,pluginName:xh,cleanup:()=>{o.forEach(i=>i==null?void 0:i()),s(),r==null||r()}})});var Re=(n=>(n.name="animation-name",n.duration="animation-duration",n.delay="animation-delay",n.fillMode="animation-fill-mode",n))(Re||{}),Tl=(n=>(n.staggerDelay="--stagger-delay",n))(Tl||{}),Se=(n=>(n.onScroll="--animation-on-scroll",n.threshold="--animation-threshold",n.repeat="--animation-repeat",n))(Se||{});const De="animation",nn="animation-group",El="animation:update",Gs="animation-group:update",Ml={category:{id:"animations",label:"Animations"},select:!0},Ws=n=>(n==null?void 0:n.type)===De,js=n=>(n==null?void 0:n.type)===nn,Al=n=>Ws(n)||js(n),Oh={isVisible:({component:n})=>Al(n)},qs={isVisible:({component:n})=>Ws(n)},Nh={isVisible:({component:n})=>js(n)},Pl={isVisible:({component:n,sector:e})=>{var t;return Ws(n)&&js(n==null?void 0:n.parent())?!1:Al(n)&&((t=e.getProperty(Se.onScroll))==null?void 0:t.getValue())==="true"}},Ol={animation:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M16.5 14a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13"/><path fill="currentColor" d="M17.14 15.98a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/><path fill="currentColor" d="M12.64 20.48a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/></svg>',animationGroup:'<svg viewBox="0 0 24 24"><path d="M4 2a2 2 0 0 0-2 2v10h2V4h10V2H4m4 4a2 2 0 0 0-2 2v10h2V8h10V6H8m4 4a2 2 0 0 0-2 2v8c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2v-8a2 2 0 0 0-2-2h-8Z"/></svg>'},Nl=[{id:"bounce",name:"Bounce",css:`@keyframes bounce {
190
+ `,l.addEventListener("pointerdown",f()),r.appendChild(l)),s.append(r),(w=t.getSpotsEl())==null||w.appendChild(s)},h=w=>v=>{if(!a)return;To(n,!0),v.stopPropagation(),v.preventDefault(),u.startResize(a,w,v);const E=v.clientX,k=v.clientY;v.target.setPointerCapture(v.pointerId);const M=N=>{const O=n.Canvas.getZoomMultiplier(),$=(N.clientX-E)*O,B=(N.clientY-k)*O,Q=Eo(w)?B:$;u.updateResizeByDelta(a,w,Q)},P=()=>{To(n,!1),u.finishResize(a),v.target.releasePointerCapture(v.pointerId),document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",P)};document.addEventListener("pointermove",M),document.addEventListener("pointerup",P)},f=()=>w=>{if(!c)return;const v=c;To(n,!0),w.stopPropagation(),w.preventDefault();const E=Pn(v,e),k=Gs({componentRow:v,isVertical:E},e),M=w.clientX,P=w.clientY;w.target.setPointerCapture(w.pointerId);const N=$=>{const B=n.Canvas.getZoomMultiplier(),Q=E?($.clientY-P)*B:($.clientX-M)*B;u.updateGapByDelta(v,Q,k,E)},O=()=>{To(n,!1),u.finishGapAdjust(v),w.target.releasePointerCapture(w.pointerId),document.removeEventListener("pointermove",N),document.removeEventListener("pointerup",O)};document.addEventListener("pointermove",N),document.addEventListener("pointerup",O)},m=w=>{const v=w.component;if(!v||!s||(a=v,c=v.parent(),!c))return;const E=c;vl(s);const k=w.getStyle();r&&Object.assign(r.style,k);const M=Pn(E,e),P=dh(M);if(Object.values(i).forEach(Sl),P.forEach(O=>{if(mh(v,O))return;const $=i[O];vl($)}),Et(e).gapHandler.isGapSupported()&&l&&gh(v)){const O=Gs({componentRow:E,isVertical:M},e);g(O,M,hh(v))}},g=(w,v,E=!1)=>{const k=e.gapHandleSize,M=l.style;if(v){M.height=`${k}px`;const P=l.offsetHeight;E?(M.top=`-${(w+P)/2}px`,M.bottom=""):(M.bottom=`-${(w+P)/2}px`,M.top=""),M.width="50%",M.left="50%",M.transform="translateX(-50%)",M.cursor="row-resize"}else{M.width=`${k}px`;const P=l.offsetWidth;E?(M.left=`-${(w+P)/2}px`,M.right=""):(M.right=`-${(w+P)/2}px`,M.left=""),M.height="50%",M.top="50%",M.transform="translateY(-50%)",M.cursor="col-resize"}},b=()=>{s&&(Sl(s),a=null,c=null)},C=()=>{t.removeSpots({type:o});const w=n.getSelected(),v=w==null?void 0:w.parent();w&&v&&d.isValidRelationship(v,w)?t.addSpot({type:o,component:w}):b()},y=()=>{const w=t.getSpots().filter(v=>v.type===o)[0];w&&m(w)},S=(w,v)=>{d.registerTypeRelationship(w,v)};n.onReady(()=>{p(),on(e)?S("mj-section","mj-column"):S(e.typeRow,e.typeColumn)});const x="component:toggled";return n.on(t.events.spot,y),n.on(x,C),()=>{n.off(t.events.spot,y),n.off(x,C)}}const Ph=j(function(n,e={}){const t={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...e},o=[vh(n,t),Sh(n,t)],s=Ah(n,t),r=bh(n,t);q({editor:n,licenseKey:t.licenseKey,plan:wh,pluginName:xh,cleanup:()=>{o.forEach(i=>i==null?void 0:i()),s(),r==null||r()}})});var Re=(n=>(n.name="animation-name",n.duration="animation-duration",n.delay="animation-delay",n.fillMode="animation-fill-mode",n))(Re||{}),El=(n=>(n.staggerDelay="--stagger-delay",n))(El||{}),ve=(n=>(n.onScroll="--animation-on-scroll",n.threshold="--animation-threshold",n.repeat="--animation-repeat",n))(ve||{});const De="animation",sn="animation-group",Ml="animation:update",js="animation-group:update",Al={category:{id:"animations",label:"Animations"},select:!0},qs=n=>(n==null?void 0:n.type)===De,Us=n=>(n==null?void 0:n.type)===sn,Pl=n=>qs(n)||Us(n),Nh={isVisible:({component:n})=>Pl(n)},Ks={isVisible:({component:n})=>qs(n)},Oh={isVisible:({component:n})=>Us(n)},Nl={isVisible:({component:n,sector:e})=>{var t;return qs(n)&&Us(n==null?void 0:n.parent())?!1:Pl(n)&&((t=e.getProperty(ve.onScroll))==null?void 0:t.getValue())==="true"}},Ol={animation:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M16.5 14a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13"/><path fill="currentColor" d="M17.14 15.98a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/><path fill="currentColor" d="M12.64 20.48a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/></svg>',animationGroup:'<svg viewBox="0 0 24 24"><path d="M4 2a2 2 0 0 0-2 2v10h2V4h10V2H4m4 4a2 2 0 0 0-2 2v10h2V8h10V6H8m4 4a2 2 0 0 0-2 2v8c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2v-8a2 2 0 0 0-2-2h-8Z"/></svg>'},Il=[{id:"bounce",name:"Bounce",css:`@keyframes bounce {
191
191
  0%, 20%, 53%, 80%, to {
192
192
  animation-timing-function: cubic-bezier(.215, .61, .355, 1);
193
193
  transform:translateZ(0)
@@ -692,8 +692,8 @@
692
692
  transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0);
693
693
  animation-timing-function:cubic-bezier(.175, .885, .32, 1)
694
694
  }
695
- }`}],Ih=function(n){const e=this;let t=null;const o=()=>{t==null||t.disconnect(),t=null},s=()=>{o();const r=e.style;r.animationName="",requestAnimationFrame(()=>{const i=getComputedStyle(e),l=i.getPropertyValue("animation-name").trim(),a=i.getPropertyValue("--animation-on-scroll").trim()!=="false",c=parseFloat(i.getPropertyValue("--animation-threshold").trim())||.2,d=i.getPropertyValue("--animation-repeat").trim()==="true",u=()=>{r.animationName="none",e.offsetWidth,r.animationName=l,r.animationPlayState="running"};if(!l||l==="none"){r.animationName="none",r.animationPlayState="paused";return}if(!a){u();return}r.animationPlayState="paused",t=new IntersectionObserver(p=>{p.forEach(h=>{h.isIntersecting&&(u(),!d&&o())})},{threshold:c}),t.observe(e)})};e.addEventListener(n.animationUpdateEvent,s),s()},Rh=(n,e)=>{const{Components:t,Blocks:o,Canvas:s}=n,{block:r={},animationList:i=[]}=e,l="Animation",a=Object.values(Se),c=Object.values(Re);return t.addType(De,{block:r?{label:l,media:Ol.animation,content:{type:De},...Ml,...r}:void 0,model:{defaults:{emptyState:!0,name:l,traits:[],script:Ih,animationUpdateEvent:El,"script-props":["animationUpdateEvent"],styles:i.map(d=>d.css).join(`
696
- `),style:{[Re.name]:"fadeIn",[Re.duration]:"1s",[Re.delay]:"0s",[Re.fillMode]:"both",[Se.onScroll]:"true",[Se.threshold]:"0.2",[Se.repeat]:"false",...e.animationStyle}},init(){const{em:d}=this;this.listenTo(d,"component:mount",u=>{var h;if(u!==this)return;((h=this.parent())==null?void 0:h.get("type"))!==nn||a.forEach(f=>this.removeStyle(f))})}},view:{events:()=>({animationstart:"onAnimationStart",animationend:"onAnimationEnd"}),init(){const{model:d}=this;this.listenTo(d,"component:styleUpdate",this.handleStyleChange)},onAnimationStart(){var u;if((u=this.cmpSpots)!=null&&u.length)return;const d=s.getSpots({component:this.model});this.cmpSpots=d,s.removeSpots(d),this.el.ownerDocument.body.style.overflowX="hidden"},onAnimationEnd(){const d=this.cmpSpots||[];s.spots.add(d),this.cmpSpots=[],this.el.ownerDocument.body.style.overflowX=""},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(El))},handleStyleChange(d,u){Object.keys((u==null?void 0:u.style)||{}).some(f=>c.includes(f)||a.includes(f))&&this.triggerAnimation()},onRender(){this.triggerAnimation()}}}),()=>{o.remove(De),t.removeType(De)}},Dh=function(n){const e=this,t="--animation-on-scroll",o="--animation-threshold",s="--animation-repeat";let r=null;const i=()=>{r==null||r.disconnect(),r=null},l=()=>{i();const a=getComputedStyle(e),c=a.getPropertyValue(t).trim()!=="false",d=parseFloat(a.getPropertyValue(o).trim())||.2,u=a.getPropertyValue(s).trim()==="true",p=()=>{Array.from(e.children).forEach(h=>{h instanceof HTMLElement&&typeof h.dispatchEvent=="function"&&h.dispatchEvent(new CustomEvent(Gs,{bubbles:!1}))})};if(!c){p();return}r=new IntersectionObserver(h=>{h.forEach(f=>{f.isIntersecting?(p(),!u&&i()):u&&Array.from(e.children).forEach(m=>{m instanceof HTMLElement&&getComputedStyle(m).getPropertyValue(t).trim()!=="false"&&(m.style.opacity="0",m.style.animationPlayState="paused")})})},{threshold:d}),r.observe(e)};e.addEventListener(n.animationGroupUpdateEvent,l),l()},Lh=(n,e)=>{const{Components:t,Blocks:o}=n,{blockGroup:s={}}=e,r="Animation Group";return t.addType(nn,{block:s?{label:r,media:Ol.animationGroup,content:{type:nn,components:[{type:De},{type:De},{type:De}]},...Ml,...s}:void 0,model:{defaults:{name:r,emptyState:!0,traits:[],script:Dh,animationGroupUpdateEvent:Gs,"script-props":["animationGroupUpdateEvent"],droppable:co(De),style:{[Tl.staggerDelay]:"0.3s",[Se.onScroll]:"true",[Se.threshold]:"0.2",[Se.repeat]:"false",...e.animationGroupStyle}},init(){const i=this.components();this.listenTo(i,"add remove",this.updateChildrenStaggerStyles),this.updateChildrenStaggerStyles()},updateChildrenStaggerStyles(){this.components().forEach((i,l)=>{i.is(De)&&i.addStyle({"--stagger-index":l.toString(),[Re.delay]:"calc(var(--stagger-index, 0) * var(--stagger-delay, 0s))"},{partial:!0})})}},view:{init(){const{model:i}=this;this.listenTo(i,"component:styleUpdate",this.handleStyleChange)},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(Gs))},handleStyleChange(){this.triggerAnimation(),this.model.updateChildrenStaggerStyles()},onRender(){this.triggerAnimation()}}}),()=>{o.remove(nn),t.removeType(nn)}},$h="animationComponent",zh=F.startup,Bh=G(function(n,e={}){var s;const t=((s=e.animations)==null?void 0:s.call(e,{items:Nl}))||Nl,o=[Rh(n,{...e,animationList:t}),Lh(n,e)];n.Styles.addSector("animation",{name:"Animation",properties:[{...qs,name:"Type",property:Re.name,type:"select",full:!0,default:"fadeIn",options:t},{...qs,name:"Duration",property:Re.duration,type:"number",units:["s"],min:.1,max:10,step:.1,default:"1s"},{...qs,name:"Fill Mode",property:Re.fillMode,type:"select",default:"both",options:[{name:"None",id:"none"},{name:"Forwards",id:"forwards"},{name:"Backwards",id:"backwards"},{name:"Both",id:"both"}]},{...Nh,name:"Stagger Delay",property:"--stagger-delay",type:"slider",units:["s"],min:.1,max:5,step:.1,default:"0.1s"},{...Oh,name:"Animate on Scroll",property:Se.onScroll,type:"radio",default:"true",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]},{...Pl,name:"Scroll Threshold",property:Se.threshold,type:"number",full:!0,min:.1,max:1,step:.01,default:"0.2"},{...Pl,name:"Repeat on Scroll",property:Se.repeat,type:"radio",default:"false",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]}]}),W({editor:n,licenseKey:e.licenseKey,plan:zh,pluginName:$h,cleanup:()=>{o.forEach(r=>r())}})}),Vh=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"),r=d=>d.isChildOf("text"),i=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{o(d)&&s(d)&&!i(d)&&l(d,u)},c=(d,u)=>{if(o(d)&&!s(d)&&r(d)){const p=d.parents().find(h=>h.isInstanceOf("text"));p&&(l(p,u),setTimeout(()=>n.select(p),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Fh="rteTinyMce",_h=F.startup,Gh=`
695
+ }`}],Ih=function(n){const e=this;let t=null;const o=()=>{t==null||t.disconnect(),t=null},s=()=>{o();const r=e.style;r.animationName="",requestAnimationFrame(()=>{const i=getComputedStyle(e),l=i.getPropertyValue("animation-name").trim(),a=i.getPropertyValue("--animation-on-scroll").trim()!=="false",c=parseFloat(i.getPropertyValue("--animation-threshold").trim())||.2,d=i.getPropertyValue("--animation-repeat").trim()==="true",u=()=>{r.animationName="none",e.offsetWidth,r.animationName=l,r.animationPlayState="running"};if(!l||l==="none"){r.animationName="none",r.animationPlayState="paused";return}if(!a){u();return}r.animationPlayState="paused",t=new IntersectionObserver(p=>{p.forEach(h=>{h.isIntersecting&&(u(),!d&&o())})},{threshold:c}),t.observe(e)})};e.addEventListener(n.animationUpdateEvent,s),s()},Rh=(n,e)=>{const{Components:t,Blocks:o,Canvas:s}=n,{block:r={},animationList:i=[]}=e,l="Animation",a=Object.values(ve),c=Object.values(Re);return t.addType(De,{block:r?{label:l,media:Ol.animation,content:{type:De},...Al,...r}:void 0,model:{defaults:{emptyState:!0,name:l,traits:[],script:Ih,animationUpdateEvent:Ml,"script-props":["animationUpdateEvent"],styles:i.map(d=>d.css).join(`
696
+ `),style:{[Re.name]:"fadeIn",[Re.duration]:"1s",[Re.delay]:"0s",[Re.fillMode]:"both",[ve.onScroll]:"true",[ve.threshold]:"0.2",[ve.repeat]:"false",...e.animationStyle}},init(){const{em:d}=this;this.listenTo(d,"component:mount",u=>{var h;if(u!==this)return;((h=this.parent())==null?void 0:h.get("type"))!==sn||a.forEach(f=>this.removeStyle(f))})}},view:{events:()=>({animationstart:"onAnimationStart",animationend:"onAnimationEnd"}),init(){const{model:d}=this;this.listenTo(d,"component:styleUpdate",this.handleStyleChange)},onAnimationStart(){var u;if((u=this.cmpSpots)!=null&&u.length)return;const d=s.getSpots({component:this.model});this.cmpSpots=d,s.removeSpots(d),this.el.ownerDocument.body.style.overflowX="hidden"},onAnimationEnd(){const d=this.cmpSpots||[];s.spots.add(d),this.cmpSpots=[],this.el.ownerDocument.body.style.overflowX=""},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(Ml))},handleStyleChange(d,u){Object.keys((u==null?void 0:u.style)||{}).some(f=>c.includes(f)||a.includes(f))&&this.triggerAnimation()},onRender(){this.triggerAnimation()}}}),()=>{o.remove(De),t.removeType(De)}},Dh=function(n){const e=this,t="--animation-on-scroll",o="--animation-threshold",s="--animation-repeat";let r=null;const i=()=>{r==null||r.disconnect(),r=null},l=()=>{i();const a=getComputedStyle(e),c=a.getPropertyValue(t).trim()!=="false",d=parseFloat(a.getPropertyValue(o).trim())||.2,u=a.getPropertyValue(s).trim()==="true",p=()=>{Array.from(e.children).forEach(h=>{h instanceof HTMLElement&&typeof h.dispatchEvent=="function"&&h.dispatchEvent(new CustomEvent(js,{bubbles:!1}))})};if(!c){p();return}r=new IntersectionObserver(h=>{h.forEach(f=>{f.isIntersecting?(p(),!u&&i()):u&&Array.from(e.children).forEach(m=>{m instanceof HTMLElement&&getComputedStyle(m).getPropertyValue(t).trim()!=="false"&&(m.style.opacity="0",m.style.animationPlayState="paused")})})},{threshold:d}),r.observe(e)};e.addEventListener(n.animationGroupUpdateEvent,l),l()},Lh=(n,e)=>{const{Components:t,Blocks:o}=n,{blockGroup:s={}}=e,r="Animation Group";return t.addType(sn,{block:s?{label:r,media:Ol.animationGroup,content:{type:sn,components:[{type:De},{type:De},{type:De}]},...Al,...s}:void 0,model:{defaults:{name:r,emptyState:!0,traits:[],script:Dh,animationGroupUpdateEvent:js,"script-props":["animationGroupUpdateEvent"],droppable:uo(De),style:{[El.staggerDelay]:"0.3s",[ve.onScroll]:"true",[ve.threshold]:"0.2",[ve.repeat]:"false",...e.animationGroupStyle}},init(){const i=this.components();this.listenTo(i,"add remove",this.updateChildrenStaggerStyles),this.updateChildrenStaggerStyles()},updateChildrenStaggerStyles(){this.components().forEach((i,l)=>{i.is(De)&&i.addStyle({"--stagger-index":l.toString(),[Re.delay]:"calc(var(--stagger-index, 0) * var(--stagger-delay, 0s))"},{partial:!0})})}},view:{init(){const{model:i}=this;this.listenTo(i,"component:styleUpdate",this.handleStyleChange)},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(js))},handleStyleChange(){this.triggerAnimation(),this.model.updateChildrenStaggerStyles()},onRender(){this.triggerAnimation()}}}),()=>{o.remove(sn),t.removeType(sn)}},$h="animationComponent",zh=_.startup,Bh=j(function(n,e={}){var s;const t=((s=e.animations)==null?void 0:s.call(e,{items:Il}))||Il,o=[Rh(n,{...e,animationList:t}),Lh(n,e)];n.Styles.addSector("animation",{name:"Animation",properties:[{...Ks,name:"Type",property:Re.name,type:"select",full:!0,default:"fadeIn",options:t},{...Ks,name:"Duration",property:Re.duration,type:"number",units:["s"],min:.1,max:10,step:.1,default:"1s"},{...Ks,name:"Fill Mode",property:Re.fillMode,type:"select",default:"both",options:[{name:"None",id:"none"},{name:"Forwards",id:"forwards"},{name:"Backwards",id:"backwards"},{name:"Both",id:"both"}]},{...Oh,name:"Stagger Delay",property:"--stagger-delay",type:"slider",units:["s"],min:.1,max:5,step:.1,default:"0.1s"},{...Nh,name:"Animate on Scroll",property:ve.onScroll,type:"radio",default:"true",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]},{...Nl,name:"Scroll Threshold",property:ve.threshold,type:"number",full:!0,min:.1,max:1,step:.01,default:"0.2"},{...Nl,name:"Repeat on Scroll",property:ve.repeat,type:"radio",default:"false",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]}]}),q({editor:n,licenseKey:e.licenseKey,plan:zh,pluginName:$h,cleanup:()=>{o.forEach(r=>r())}})}),Vh=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"),r=d=>d.isChildOf("text"),i=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{o(d)&&s(d)&&!i(d)&&l(d,u)},c=(d,u)=>{if(o(d)&&!s(d)&&r(d)){const p=d.parents().find(h=>h.isInstanceOf("text"));p&&(l(p,u),setTimeout(()=>n.select(p),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Fh="rteTinyMce",_h=_.startup,Gh=`
697
697
  .tox .tox-toolbar,
698
698
  .tox .tox-toolbar__overflow,
699
699
  .tox .tox-toolbar__primary,
@@ -796,25 +796,25 @@
796
796
  background-color: var(--gs-theme-cl-prm-bg1);
797
797
  border-color: var(--gs-theme-cl-prm-bg3);
798
798
  opacity: 0.75;
799
- }`,Us=new WeakMap,Wh=(n,e)=>{Us.set(n,e)},jh=n=>{Us.delete(n)},Ks=n=>Us.get(n),Mo=n=>{const e=n.target,t=e.closest(".tox"),o=e.matches(".ephox-snooker-resizer-bar");(t||o)&&n.stopPropagation()},Il=n=>{n.stopPropagation(),n.preventDefault()},qh=(n,e)=>{const t=n.getDoc(),o=n.getWin();if(e!=null&&e.event){const{event:s}=e,{clientX:r,clientY:i}=s;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(r,i);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(r,i);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")},Uh=n=>{var c,d;const{el:e,editor:t,componentView:o}=n,s=t.runCommand(_.getStateTheme),r=o.model,i={target:e,inline:!0,skin:(s==null?void 0:s.theme)===wi.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:i,editor:t,componentView:o,component:r}))||{};return{...i,...l}},Rl=(n,e=document)=>new Promise((t,o)=>{const s=Array.isArray(n)?[...n]:[n],{head:r}=e,i=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=i.bind(null,l),a.onerror=o,r.appendChild(a)}else t()};i(s)}),Kh=G(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,r=!t.skipCustomTheme,i="gs-plg-tinymce-studio-theme",l=async(d,u)=>{const p=d.ownerDocument,h=p.defaultView,f=u==null?void 0:u.view;if(!h||!f){console.warn("Missing required data",{win:h,componentView:f});return}const m=Uh({el:d,editor:n,componentView:f,pluginOpts:t}),b=(await h.tinymce.init(m))[0];if(!b)return;const y=(await window.tinymce.init({...m,target:document.createElement("div")}))[0];return b.ui.show(),p.body.addEventListener("mousedown",Mo),document.body.addEventListener("mousedown",Mo),b.on("Change",()=>Vh(d)),b.on("blur",()=>b.ui.show()),b.on("OpenWindow",function(){var w;const S=(w=p.querySelector(".tox-dialog"))==null?void 0:w.closest(".tox");S&&(S==null?void 0:S.ownerDocument)!==document&&(document.body.appendChild(S),b.once("CloseWindow",()=>{S&&S.ownerDocument===document&&p.body.appendChild(S)}))}),d.addEventListener("dragstart",Il,{capture:!0}),n.runCommand(_.setStateContextMenu,{enabled:!1}),qh(b,u),{rteEditor:b,rteEditorShallow:y}},a=(d,u)=>{d.ownerDocument.body.removeEventListener("mousedown",Mo),document.body.removeEventListener("mousedown",Mo),d.removeEventListener("dragstart",Il,{capture:!0}),n.runCommand(_.setStateContextMenu,{enabled:!0}),u.rteEditor.destroy(),u.rteEditorShallow.destroy()};n.on(s.frameLoad,async({window:d})=>{const u=d.document;Rl(o,u)}),n.onReady(()=>{Rl(o,document),r&&ys(i,Gh,{target:document.body})}),n.setCustomRte({parseContent:!0,async enable(d,u,p){const h=Ks(d);if(h)return h.rteEditor;const f=await l(d,p);return f&&Wh(d,f),f==null?void 0:f.rteEditor},disable(d){const u=Ks(d);u&&(jh(d),a(d,u))},getContent(d){var p,h;const u=Ks(d);return u?(h=(p=u.rteEditor).getContent)==null?void 0:h.call(p):d.innerHTML}});const c=Hh(n,t.enableOnClick);W({editor:n,licenseKey:t.licenseKey,plan:_h,pluginName:Fh,cleanup:()=>{n.RichTextEditor.customRte=void 0,c()}})});function Q(n){this.content=n}Q.prototype={constructor:Q,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),r=o.content.slice();return s==-1?r.push(t||n,e):(r[s+1]=e,t&&(r[s]=t)),new Q(r)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Q(t)},addToStart:function(n,e){return new Q([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Q(t)},addBefore:function(n,e,t){var o=this.remove(e),s=o.content.slice(),r=o.find(n);return s.splice(r==-1?s.length:r,0,e,t),new Q(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=Q.from(n),n.size?new Q(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Q.from(n),n.size?new Q(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Q.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}},Q.from=function(n){if(n instanceof Q)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Q(e)};function Dl(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),r=e.child(o);if(s==r){t+=s.nodeSize;continue}if(!s.sameMarkup(r))return t;if(s.isText&&s.text!=r.text){for(let i=0;s.text[i]==r.text[i];i++)t++;return t}if(s.content.size||r.content.size){let i=Dl(s.content,r.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function Ll(n,e,t,o){for(let s=n.childCount,r=e.childCount;;){if(s==0||r==0)return s==r?null:{a:t,b:o};let i=n.child(--s),l=e.child(--r),a=i.nodeSize;if(i==l){t-=a,o-=a;continue}if(!i.sameMarkup(l))return{a:t,b:o};if(i.isText&&i.text!=l.text){let c=0,d=Math.min(i.text.length,l.text.length);for(;c<d&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,o--;return{a:t,b:o}}if(i.content.size||l.content.size){let c=Ll(i.content,l.content,t-1,o-1);if(c)return c}t-=a,o-=a}}class E{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,r){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&o(a,s+l,r||null,i)!==!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 r="",i=!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&&(i?i=!1:r+=o),r+=c},0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,o=e.firstChild,s=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(o)&&(s[s.length-1]=t.withText(t.text+o.text),r=1);r<e.content.length;r++)s.push(e.content[r]);return new E(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 r=0,i=0;i<t;r++){let l=this.content[r],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),o.push(l),s+=l.nodeSize),i=a}return new E(o,s)}cutByIndex(e,t){return e==t?E.empty:e==0&&t==this.content.length?this:new E(this.content.slice(e,t))}replaceChild(e,t){let o=this.content[e];if(o==t)return this;let s=this.content.slice(),r=this.size+t.nodeSize-o.nodeSize;return s[e]=t,new E(s,r)}addToStart(e){return new E([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new E(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let 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 Dl(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return Ll(this,e,t,o)}findIndex(e,t=-1){if(e==0)return Ao(0,e);if(e==this.size)return Ao(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 r=this.child(o),i=s+r.nodeSize;if(i>=e)return i==e||t>0?Ao(o+1,i):Ao(o,s);s=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return E.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new E(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return E.empty;let t,o=0;for(let s=0;s<e.length;s++){let r=e[s];o+=r.nodeSize,s&&r.isText&&e[s-1].sameMarkup(r)?(t||(t=e.slice(0,s)),t[t.length-1]=r.withText(t[t.length-1].text+r.text)):t&&t.push(r)}return new E(t||e,o)}static from(e){if(!e)return E.empty;if(e instanceof E)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new E([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}E.empty=new E([],0);const Js={index:0,offset:0};function Ao(n,e){return Js.index=n,Js.offset=e,Js}function Po(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(!Po(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!Po(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 r=e[s];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,s));else{if(r.type.excludes(this.type))return e;!o&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),o=!0),t&&t.push(r)}}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&&Po(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 Oo extends Error{}class A{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=zl(this.content,e+this.openStart,t);return o&&new A(o,this.openStart,this.openEnd)}removeBetween(e,t){return new A($l(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 A.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 A(E.fromJSON(e,t.content),o,s)}static maxOpen(e,t=!0){let o=0,s=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)o++;for(let r=e.lastChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.lastChild)s++;return new A(e,o,s)}}A.empty=new A(E.empty,0,0);function $l(n,e,t){let{index:o,offset:s}=n.findIndex(e),r=n.maybeChild(o),{index:i,offset:l}=n.findIndex(t);if(s==e||r.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(o!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(o,r.copy($l(r.content,e-s-1,t-s-1)))}function zl(n,e,t,o){let{index:s,offset:r}=n.findIndex(e),i=n.maybeChild(s);if(r==e||i.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=zl(i.content,e-r-1,t);return l&&n.replaceChild(s,i.copy(l))}function Jh(n,e,t){if(t.openStart>n.depth)throw new Oo("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Oo("Inconsistent open depths");return Bl(n,e,t,0)}function Bl(n,e,t,o){let s=n.index(o),r=n.node(o);if(s==e.index(o)&&o<n.depth-t.openStart){let i=Bl(n,e,t,o+1);return r.copy(r.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let i=n.parent,l=i.content;return Mt(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=Zh(t,n);return Mt(r,Hl(n,i,l,e,o))}else return Mt(r,No(n,e,o))}function Vl(n,e){if(!e.type.compatibleContent(n.type))throw new Oo("Cannot join "+e.type.name+" onto "+n.type.name)}function Zs(n,e,t){let o=n.node(t);return Vl(o,e.node(t)),o}function Et(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 On(n,e,t,o){let s=(e||n).node(t),r=0,i=e?e.index(t):s.childCount;n&&(r=n.index(t),n.depth>t?r++:n.textOffset&&(Et(n.nodeAfter,o),r++));for(let l=r;l<i;l++)Et(s.child(l),o);e&&e.depth==t&&e.textOffset&&Et(e.nodeBefore,o)}function Mt(n,e){return n.type.checkContent(e),n.copy(e)}function Hl(n,e,t,o,s){let r=n.depth>s&&Zs(n,e,s+1),i=o.depth>s&&Zs(t,o,s+1),l=[];return On(null,n,s,l),r&&i&&e.index(s)==t.index(s)?(Vl(r,i),Et(Mt(r,Hl(n,e,t,o,s+1)),l)):(r&&Et(Mt(r,No(n,e,s+1)),l),On(e,t,s,l),i&&Et(Mt(i,No(t,o,s+1)),l)),On(o,null,s,l),new E(l)}function No(n,e,t){let o=[];if(On(null,n,t,o),n.depth>t){let s=Zs(n,e,t+1);Et(Mt(s,No(n,e,t+1)),o)}return On(e,null,t,o),new E(o)}function Zh(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let r=t-1;r>=0;r--)s=e.node(r).copy(E.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class Nn{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 r=0;r<e;r++)s+=o.child(r).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 r=o.marks;for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}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 r=0;r<o.length;r++)o[r].type.spec.inclusive===!1&&(!s||!o[r].isInSet(s.marks))&&(o=o[r--].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 Io(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,r=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(r),c=r-a;if(o.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;r=c-1,s+=a+1}return new Nn(t,o,r)}static resolveCached(e,t){let o=Fl.get(e);if(o)for(let r=0;r<o.elts.length;r++){let i=o.elts[r];if(i.pos==t)return i}else Fl.set(e,o=new Yh);let s=o.elts[o.i]=Nn.resolve(e,t);return o.i=(o.i+1)%Xh,s}}class Yh{constructor(){this.elts=[],this.i=0}}const Xh=12,Fl=new WeakMap;class Io{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 Qh=Object.create(null);let At=class mi{constructor(e,t,o,s=V.none){this.type=e,this.attrs=t,this.marks=s,this.content=o||E.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,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&&Po(this.attrs,t||e.defaultAttrs||Qh)&&V.sameSet(this.marks,o||V.none)}copy(e=null){return e==this.content?this:new mi(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new mi(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 A.empty;let s=this.resolve(e),r=this.resolve(t),i=o?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,r.pos-l);return new A(c,s.depth-i,r.depth-i)}replace(e,t,o){return Jh(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 Nn.resolveCached(this,e)}resolveNoCache(e){return Nn.resolve(this,e)}rangeHasMark(e,t,o){let s=!1;return t>e&&this.nodesBetween(e,t,r=>(o.isInSet(r.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()+")"),_l(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=E.empty,s=0,r=o.childCount){let i=this.contentMatchAt(e).matchFragment(o,s,r),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<r;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 r=this.contentMatchAt(e).matchType(o),i=r&&r.matchFragment(this.content,t);return i?i.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=E.fromJSON(e,t.content),r=e.nodeType(t.type).create(t.attrs,s,o);return r.type.checkAttrs(r.attrs),r}};At.prototype.text=void 0;class Ro extends At{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):_l(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 Ro(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Ro(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 _l(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Pt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new ef(e,t);if(o.next==null)return Pt.empty;let s=Gl(o);o.next&&o.err("Unexpected trailing text");let r=af(lf(s));return cf(r,o),r}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,o=e.childCount){let s=this;for(let r=t;s&&r<o;r++)s=s.matchType(e.child(r).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 r(i,l){let a=i.matchFragment(e,o);if(a&&(!t||a.validEnd))return E.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:d,next:u}=i.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let p=r(u,l.concat(d));if(p)return p}}return null}return r(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(),r=s.match;if(r.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<r.next.length;i++){let{type:l,next:a}=r.next[i];!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 r=s+(o.validEnd?"*":" ")+" ";for(let i=0;i<o.next.length;i++)r+=(i?", ":"")+o.next[i].type.name+"->"+e.indexOf(o.next[i].next);return r}).join(`
800
- `)}}Pt.empty=new Pt(!0);class ef{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 Gl(n){let e=[];do e.push(tf(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function tf(n){let e=[];do e.push(nf(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function nf(n){let e=rf(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=of(n,e);else break;return e}function Wl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function of(n,e){let t=Wl(n),o=t;return n.eat(",")&&(n.next!="}"?o=Wl(n):o=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:o,expr:e}}function sf(n,e){let t=n.nodeTypes,o=t[e];if(o)return[o];let s=[];for(let r in t){let i=t[r];i.isInGroup(e)&&s.push(i)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function rf(n){if(n.eat("(")){let e=Gl(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=sf(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 lf(n){let e=[[]];return s(r(n,0),t()),e;function t(){return e.push([])-1}function o(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function s(i,l){i.forEach(a=>a.to=l)}function r(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(r(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=r(i.exprs[a],l);if(a==i.exprs.length-1)return c;s(c,l=t())}else if(i.type=="star"){let a=t();return o(l,a),s(r(i.expr,a),a),[o(a)]}else if(i.type=="plus"){let a=t();return s(r(i.expr,l),a),s(r(i.expr,a),a),[o(a)]}else{if(i.type=="opt")return[o(l)].concat(r(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let d=t();s(r(i.expr,a),d),a=d}if(i.max==-1)s(r(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let d=t();o(a,d),s(r(i.expr,a),d),a=d}return[o(a)]}else{if(i.type=="name")return[o(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function jl(n,e){return e-n}function ql(n,e){let t=[];return o(e),t.sort(jl);function o(s){let r=n[s];if(r.length==1&&!r[0].term)return o(r[0].to);t.push(s);for(let i=0;i<r.length;i++){let{term:l,to:a}=r[i];!l&&t.indexOf(a)==-1&&o(a)}}}function af(n){let e=Object.create(null);return t(ql(n,0));function t(o){let s=[];o.forEach(i=>{n[i].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]);ql(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let r=e[o.join(",")]=new Pt(o.indexOf(n.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(jl);r.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return r}}function cf(n,e){for(let t=0,o=[n];t<o.length;t++){let s=o[t],r=!s.validEnd,i=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];i.push(a.name),r&&!(a.isText||a.hasRequiredAttrs())&&(r=!1),o.indexOf(c)==-1&&o.push(c)}r&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ul(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 Kl(n,e){let t=Object.create(null);for(let o in n){let s=e&&e[o];if(s===void 0){let r=n[o];if(r.hasDefault)s=r.default;else throw new RangeError("No value supplied for attribute "+o)}t[o]=s}return t}function Jl(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 r=n[s];r.validate&&r.validate(e[s])}}function Zl(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new uf(n,o,e[o]);return t}let Yl=class fu{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=Zl(e,o.attrs),this.defaultAttrs=Ul(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==Pt.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:Kl(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new At(this,this.computeAttrs(e),E.from(t),V.setFrom(o))}createChecked(e=null,t,o){return t=E.from(t),this.checkContent(t),new At(this,this.computeAttrs(e),t,V.setFrom(o))}createAndFill(e=null,t,o){if(e=this.computeAttrs(e),t=E.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let s=this.contentMatch.matchFragment(t),r=s&&s.fillBefore(E.empty,!0);return r?new At(this,e,t.append(r),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){Jl(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((r,i)=>o[r]=new fu(r,t,i));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 r in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function df(n,e,t){let o=t.split("|");return s=>{let r=s===null?"null":typeof s;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${n}, got ${r}`)}}class uf{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?df(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class Do{constructor(e,t,o,s){this.name=e,this.rank=t,this.schema=o,this.spec=s,this.attrs=Zl(e,s.attrs),this.excluded=null;let r=Ul(this.attrs);this.instance=r?new V(this,r):null}create(e=null){return!e&&this.instance?this.instance:new V(this,Kl(this.attrs,e))}static compile(e,t){let o=Object.create(null),s=0;return e.forEach((r,i)=>o[r]=new Do(r,s++,t,i)),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){Jl(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class pf{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=Q.from(e.nodes),t.marks=Q.from(e.marks||{}),this.nodes=Yl.compile(this.spec.nodes,this),this.marks=Do.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 r=this.nodes[s],i=r.spec.content||"",l=r.spec.marks;if(r.contentMatch=o[i]||(o[i]=Pt.parse(i,this.nodes)),r.inlineContent=r.contentMatch.inlineContent,r.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!r.isInline||!r.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=r}r.markSet=l=="_"?null:l?Xl(this,l.split(" ")):l==""||!r.inlineContent?[]:null}for(let s in this.marks){let r=this.marks[s],i=r.spec.excludes;r.excluded=i==null?[r]:i==""?[]:Xl(this,i.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 Yl){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 Ro(o,o.defaultAttrs,e,V.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return At.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 Xl(n,e){let t=[];for(let o=0;o<e.length;o++){let s=e[o],r=n.marks[s],i=r;if(r)t.push(r);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(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function hf(n){return n.tag!=null}function ff(n){return n.style!=null}class on{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(s=>{if(hf(s))this.tags.push(s);else if(ff(s)){let r=/[^=]*/.exec(s.style)[0];o.indexOf(r)<0&&o.push(r),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let r=e.nodes[s.node];return r.contentMatch.matchType(r)})}parse(e,t={}){let o=new na(this,t,!1);return o.addAll(e,V.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new na(this,t,!0);return o.addAll(e,V.none,t.from,t.to),A.maxOpen(o.finish())}matchTag(e,t,o){for(let s=o?this.tags.indexOf(o)+1:0;s<this.tags.length;s++){let r=this.tags[s];if(yf(e,r.tag)&&(r.namespace===void 0||e.namespaceURI==r.namespace)&&(!r.context||t.matchesContext(r.context))){if(r.getAttrs){let i=r.getAttrs(e);if(i===!1)continue;r.attrs=i||void 0}return r}}}matchStyle(e,t,o,s){for(let r=s?this.styles.indexOf(s)+1:0;r<this.styles.length;r++){let i=this.styles[r],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!o.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function o(s){let r=s.priority==null?50:s.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<r)break}t.splice(i,0,s)}for(let s in e.marks){let r=e.marks[s].spec.parseDOM;r&&r.forEach(i=>{o(i=oa(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in e.nodes){let r=e.nodes[s].spec.parseDOM;r&&r.forEach(i=>{o(i=oa(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new on(e,on.schemaRules(e)))}}const Ql={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},mf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ea={ol:!0,ul:!0},Lo=1,$o=2,In=4;function ta(n,e,t){return e!=null?(e?Lo:0)|(e==="full"?$o:0):n&&n.whitespace=="pre"?Lo|$o:t&~In}class zo{constructor(e,t,o,s,r,i){this.type=e,this.attrs=t,this.marks=o,this.solid=s,this.options=i,this.content=[],this.activeMarks=V.none,this.match=r||(i&In?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(E.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&Lo)){let o=this.content[this.content.length-1],s;if(o&&o.isText&&(s=/[ \t\r\n\u000c]+$/.exec(o.text))){let r=o;o.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-s[0].length))}}let t=E.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(E.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&&!Ql.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class na{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0;let s=t.topNode,r,i=ta(null,t.preserveWhitespace,0)|(o?In:0);s?r=new zo(s.type,s.attrs,V.none,!0,t.topMatch||s.type.contentMatch,i):o?r=new zo(null,null,V.none,!0,null,i):r=new zo(e.schema.topNodeType,null,V.none,!0,null,i),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let o=e.nodeValue,s=this.top;if(s.options&$o||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(s.options&Lo)s.options&$o?o=o.replace(/\r\n?/g,`
801
- `):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 r=s.content[s.content.length-1],i=e.previousSibling;(!r||i&&i.nodeName=="BR"||r.isText&&/[ \t\r\n\u000c]$/.test(r.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(),r;ea.hasOwnProperty(s)&&this.parser.normalizeLists&&gf(e);let i=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(r=this.parser.matchTag(e,this,o));if(i?i.ignore:mf.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!i||i.skip||i.closeParent){i&&i.closeParent?this.open=Math.max(0,this.open-1):i&&i.skip.nodeType&&(e=i.skip);let l,a=this.top,c=this.needsBlock;if(Ql.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=i&&i.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,i,l,i.consuming===!1?r:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
802
- `),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 r=this.parser.matchedStyles[s],i=o.getPropertyValue(r);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(r,i,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 r,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),o)||this.leafFallback(e,o);else{let a=this.enter(i,t.attrs||null,o,t.preserveWhitespace);a&&(r=!0,o=a)}else{let a=this.parser.schema.marks[t.mark];o=o.concat(a.create(t.attrs))}let l=this.top;if(i&&i.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)}r&&this.sync(l)&&this.open--}addAll(e,t,o,s){let r=o||0;for(let i=o?e.childNodes[o]:e.firstChild,l=s==null?null:e.childNodes[s];i!=l;i=i.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(i,t);this.findAtPoint(e,r)}findPlace(e,t){let o,s;for(let r=this.open;r>=0;r--){let i=this.nodes[r],l=i.findWrapping(e);if(l&&(!o||o.length>l.length)&&(o=l,s=i,!l.length)||i.solid)break}if(!o)return null;this.sync(s);for(let r=0;r<o.length;r++)t=this.enterInner(o[r],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 r=V.none;for(let i of o.concat(e.marks))(s.type?s.type.allowsMarkType(i.type):sa(i.type,e.type))&&(r=i.addToSet(r));return s.content.push(e.mark(r)),!0}return!1}enter(e,t,o,s){let r=this.findPlace(e.create(t),o);return r&&(r=this.enterInner(e,t,o,!0,s)),r}enterInner(e,t,o,s=!1,r){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=ta(e,r,i.options);i.options&In&&i.content.length==0&&(l|=In);let a=V.none;return o=o.filter(c=>(i.type?i.type.allowsMarkType(c.type):sa(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new zo(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),r=-(o?o.depth+1:0)+(s?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=r;a--)if(i(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:o&&a>=r?o.node(a-r).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return i(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 gf(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&ea.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function yf(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function oa(n){let e={};for(let t in n)e[t]=n[t];return e}function sa(n,e){let t=e.schema.nodes;for(let o in t){let s=t[o];if(!s.allowsMarkType(n))continue;let r=[],i=l=>{r.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||r.indexOf(d)<0&&i(d))return!0}};if(i(s.contentMatch))return!0}}class Ot{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=Ys(t).createDocumentFragment());let s=o,r=[];return e.forEach(i=>{if(r.length||i.marks.length){let l=0,a=0;for(;l<r.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(r[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<r.length;)s=r.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],d=this.serializeMark(c,i.isInline,t);d&&(r.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(i,t))}),o}serializeNodeInner(e,t){let{dom:o,contentDOM:s}=Bo(Ys(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 r=this.serializeMark(e.marks[s],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(o),o=r.dom)}return o}serializeMark(e,t,o={}){let s=this.marks[e.type.name];return s&&Bo(Ys(o),s(e,t),null,e.attrs)}static renderSpec(e,t,o=null,s){return Bo(e,t,o,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ot(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=ra(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return ra(e.marks)}}function ra(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function Ys(n){return n.document||window.document}const ia=new WeakMap;function bf(n){let e=ia.get(n);return e===void 0&&ia.set(n,e=Sf(n)),e}function Sf(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 Bo(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],r;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=bf(o))&&r.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=s.indexOf(" ");i>0&&(t=s.slice(0,i),s=s.slice(i+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 p=u.indexOf(" ");p>0?a.setAttributeNS(u.slice(0,p),u.slice(p+1),c[u]):a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let p=e[u];if(p===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:h,contentDOM:f}=Bo(n,p,t,o);if(a.appendChild(h),f){if(l)throw new RangeError("Multiple content holes");l=f}}}return{dom:a,contentDOM:l}}const la=65535,aa=Math.pow(2,16);function vf(n,e){return n+e*aa}function ca(n){return n&la}function xf(n){return(n-(n&la))/aa}const da=1,ua=2,Vo=4,pa=8;class Xs{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&pa)>0}get deletedBefore(){return(this.delInfo&(da|Vo))>0}get deletedAfter(){return(this.delInfo&(ua|Vo))>0}get deletedAcross(){return(this.delInfo&Vo)>0}}class ge{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&ge.empty)return ge.empty}recover(e){let t=0,o=ca(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+xf(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,r=this.inverted?2:1,i=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+r],d=this.ranges[l+i],u=a+c;if(e<=u){let p=c?e==a?-1:e==u?1:t:t,h=a+s+(p<0?0:d);if(o)return h;let f=e==(t<0?a:u)?null:vf(l/3,e-a),m=e==a?ua:e==u?da:Vo;return(t<0?e!=a:e!=u)&&(m|=pa),new Xs(h,m,f)}s+=d-c}return o?e+s:new Xs(e+s,0,null)}touches(e,t){let o=0,s=ca(t),r=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+r],d=a+c;if(e<=d&&l==s*3)return!0;o+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,o=this.inverted?1:2;for(let s=0,r=0;s<this.ranges.length;s+=3){let i=this.ranges[s],l=i-(this.inverted?r:0),a=i+(this.inverted?0:r),c=this.ranges[s+t],d=this.ranges[s+o];e(l,l+c,a,a+d),r+=d-c}}invert(){return new ge(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ge.empty:new ge(e<0?[0,-e,0]:[0,0,e])}}ge.empty=new ge([]);class sn{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 sn(this.maps,this.mirror,e,t)}copy(){return new sn(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 sn;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 r=this.from;r<this.to;r++){let i=this.maps[r],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(r);if(a!=null&&a>r&&a<this.to){r=a,e=this.maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return o?e:new Xs(e,s,null)}}const Qs=Object.create(null);class oe{getMap(){return ge.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=Qs[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 Qs)throw new RangeError("Duplicate use of step JSON ID "+e);return Qs[e]=t,t.prototype.jsonID=e,t}}class U{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new U(e,null)}static fail(e){return new U(null,e)}static fromReplace(e,t,o,s){try{return U.ok(e.replace(t,o,s))}catch(r){if(r instanceof Oo)return U.fail(r.message);throw r}}}function er(n,e,t){let o=[];for(let s=0;s<n.childCount;s++){let r=n.child(s);r.content.size&&(r=r.copy(er(r.content,e,r))),r.isInline&&(r=e(r,t,s)),o.push(r)}return E.fromArray(o)}class tt extends oe{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)),r=new A(er(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),t.openStart,t.openEnd);return U.fromReplace(e,this.from,this.to,r)}invert(){return new Le(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 tt(t.pos,o.pos,this.mark)}merge(e){return e instanceof tt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new tt(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 tt(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("addMark",tt);class Le extends oe{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 A(er(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return U.fromReplace(e,this.from,this.to,o)}invert(){return new tt(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 Le(t.pos,o.pos,this.mark)}merge(e){return e instanceof Le&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Le(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 Le(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("removeMark",Le);class nt extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return U.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return U.fromReplace(e,this.pos,this.pos+1,new A(E.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 nt(this.pos,t.marks[s]);return new nt(this.pos,this.mark)}}return new rn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new nt(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 nt(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("addNodeMark",nt);class rn extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return U.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return U.fromReplace(e,this.pos,this.pos+1,new A(E.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new nt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new rn(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 rn(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("removeNodeMark",rn);class se extends oe{constructor(e,t,o,s=!1){super(),this.from=e,this.to=t,this.slice=o,this.structure=s}apply(e){return this.structure&&tr(e,this.from,this.to)?U.fail("Structure replace would overwrite content"):U.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ge([this.from,this.to-this.from,this.slice.size])}invert(e){return new se(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 se(t.pos,Math.max(t.pos,o.pos),this.slice)}merge(e){if(!(e instanceof se)||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?A.empty:new A(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new se(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?A.empty:new A(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new se(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 se(t.from,t.to,A.fromJSON(e,t.slice),!!t.structure)}}oe.jsonID("replace",se);class ee extends oe{constructor(e,t,o,s,r,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=s,this.slice=r,this.insert=i,this.structure=l}apply(e){if(this.structure&&(tr(e,this.from,this.gapFrom)||tr(e,this.gapTo,this.to)))return U.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return U.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,t.content);return o?U.fromReplace(e,this.from,this.to,o):U.fail("Content does not fit in gap")}getMap(){return new ge([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 ee(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),r=this.to==this.gapTo?o.pos:e.map(this.gapTo,1);return t.deletedAcross&&o.deletedAcross||s<t.pos||r>o.pos?null:new ee(t.pos,o.pos,s,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ee(t.from,t.to,t.gapFrom,t.gapTo,A.fromJSON(e,t.slice),t.insert,!!t.structure)}}oe.jsonID("replaceAround",ee);function tr(n,e,t){let o=n.resolve(e),s=t-e,r=o.depth;for(;s>0&&r>0&&o.indexAfter(r)==o.node(r).childCount;)r--,s--;if(s>0){let i=o.node(r).maybeChild(o.indexAfter(r));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function wf(n,e,t,o){let s=[],r=[],i,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 p=Math.max(c,e),h=Math.min(c+a.nodeSize,t),f=o.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(f)||(i&&i.to==p&&i.mark.eq(u[m])?i.to=h:s.push(i=new Le(p,h,u[m])));l&&l.to==p?l.to=h:r.push(l=new tt(p,h,o))}}),s.forEach(a=>n.step(a)),r.forEach(a=>n.step(a))}function Cf(n,e,t,o){let s=[],r=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;r++;let a=null;if(o instanceof Do){let c=i.marks,d;for(;d=o.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else o?o.isInSet(i.marks)&&(a=[o]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],p;for(let h=0;h<s.length;h++){let f=s[h];f.step==r-1&&u.eq(s[h].style)&&(p=f)}p?(p.to=c,p.step=r):s.push({style:u,from:Math.max(l,e),to:c,step:r})}}}),s.forEach(i=>n.step(new Le(i.from,i.to,i.style)))}function nr(n,e,t,o=t.contentMatch,s=!0){let r=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<r.childCount;a++){let c=r.child(a),d=l+c.nodeSize,u=o.matchType(c.type);if(!u)i.push(new se(l,d,A.empty));else{o=u;for(let p=0;p<c.marks.length;p++)t.allowsMarkType(c.marks[p].type)||n.step(new Le(l,d,c.marks[p]));if(s&&c.isText&&t.whitespace!="pre"){let p,h=/\r?\n|\r/g,f;for(;p=h.exec(c.text);)f||(f=new A(E.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new se(l+p.index,l+p.index+p[0].length,f))}}l=d}if(!o.validEnd){let a=o.fillBefore(E.empty,!0);n.replace(l,l,new A(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function kf(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Ho(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth;;--o){let s=n.$from.node(o),r=n.$from.index(o),i=n.$to.indexAfter(o);if(o<n.depth&&s.canReplace(r,i,t))return o;if(o==0||s.type.spec.isolating||!kf(s,r,i))break}return null}function Tf(n,e,t){let{$from:o,$to:s,depth:r}=e,i=o.before(r+1),l=s.after(r+1),a=i,c=l,d=E.empty,u=0;for(let f=r,m=!1;f>t;f--)m||o.index(f)>0?(m=!0,d=E.from(o.node(f).copy(d)),u++):a--;let p=E.empty,h=0;for(let f=r,m=!1;f>t;f--)m||s.after(f+1)<s.end(f)?(m=!0,p=E.from(s.node(f).copy(p)),h++):c++;n.step(new ee(a,c,i,l,new A(d.append(p),u,h),d.size-u,!0))}function ha(n,e,t=null,o=n){let s=Ef(n,e),r=s&&Mf(o,e);return r?s.map(fa).concat({type:e,attrs:t}).concat(r.map(fa)):null}function fa(n){return{type:n,attrs:null}}function Ef(n,e){let{parent:t,startIndex:o,endIndex:s}=n,r=t.contentMatchAt(o).findWrapping(e);if(!r)return null;let i=r.length?r[0]:e;return t.canReplaceWith(o,s,i)?r:null}function Mf(n,e){let{parent:t,startIndex:o,endIndex:s}=n,r=t.child(o),i=e.contentMatch.findWrapping(r.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=o;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Af(n,e,t){let o=E.empty;for(let i=t.length-1;i>=0;i--){if(o.size){let l=t[i].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=E.from(t[i].type.create(t[i].attrs,o))}let s=e.start,r=e.end;n.step(new ee(s,r,s,r,new A(o,0,0),t.length,!0))}function Pf(n,e,t,o,s){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let r=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(o,a)&&Of(n.doc,n.mapping.slice(r).map(l),o)){let c=null;if(o.schema.linebreakReplacement){let h=o.whitespace=="pre",f=!!o.contentMatch.matchType(o.schema.linebreakReplacement);h&&!f?c=!1:!h&&f&&(c=!0)}c===!1&&ga(n,i,l,r),nr(n,n.mapping.slice(r).map(l,1),o,void 0,c===null);let d=n.mapping.slice(r),u=d.map(l,1),p=d.map(l+i.nodeSize,1);return n.step(new ee(u,p,u+1,p-1,new A(E.from(o.create(a,null,i.marks)),0,0),1,!0)),c===!0&&ma(n,i,l,r),!1}})}function ma(n,e,t,o){e.forEach((s,r)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=n.mapping.slice(o).map(t+1+r+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function ga(n,e,t,o){e.forEach((s,r)=>{if(s.type==s.type.schema.linebreakReplacement){let i=n.mapping.slice(o).map(t+1+r);n.replaceWith(i,i+1,e.type.schema.text(`
803
- `))}})}function Of(n,e,t){let o=n.resolve(e),s=o.index();return o.parent.canReplaceWith(s,s+1,t)}function Nf(n,e,t,o,s){let r=n.doc.nodeAt(e);if(!r)throw new RangeError("No node at given position");t||(t=r.type);let i=t.create(o,null,s||r.marks);if(r.isLeaf)return n.replaceWith(e,e+r.nodeSize,i);if(!t.validContent(r.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ee(e,e+r.nodeSize,e+1,e+r.nodeSize-1,new A(E.from(i),0,0),1,!0))}function ln(n,e,t=1,o){let s=n.resolve(e),r=s.depth-t,i=o&&o[o.length-1]||s.parent;if(r<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>r;c--,d--){let u=s.node(c),p=s.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(p,u.childCount),f=o&&o[d+1];f&&(h=h.replaceChild(0,f.type.create(f.attrs)));let m=o&&o[d]||u;if(!u.canReplace(p+1,u.childCount)||!m.type.validContent(h))return!1}let l=s.indexAfter(r),a=o&&o[0];return s.node(r).canReplaceWith(l,l,a?a.type:s.node(r+1).type)}function If(n,e,t=1,o){let s=n.doc.resolve(e),r=E.empty,i=E.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){r=E.from(s.node(l).copy(r));let d=o&&o[c];i=E.from(d?d.type.create(d.attrs,i):s.node(l).copy(i))}n.step(new se(e,e,new A(r.append(i),t,t),!0))}function Fo(n,e){let t=n.resolve(e),o=t.index();return Df(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function Rf(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 r=e.child(s),i=r.type==o?n.type.schema.nodes.text:r.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(r.marks))return!1}return t.validEnd}function Df(n,e){return!!(n&&e&&!n.isLeaf&&Rf(n,e))}function Lf(n,e,t){let o=null,{linebreakReplacement:s}=n.doc.type.schema,r=n.doc.resolve(e-t),i=r.node().type;if(s&&i.inlineContent){let d=i.whitespace=="pre",u=!!i.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);ga(n,d.node(),d.before(),l)}i.inlineContent&&nr(n,e+t-1,i,r.node().contentMatchAt(r.index()),o==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new se(c,a.map(e+t,-1),A.empty,!0)),o===!0){let d=n.doc.resolve(c);ma(n,d.node(),d.before(),n.steps.length)}return n}function $f(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 r=o.index(s);if(o.node(s).canReplaceWith(r,r,t))return o.before(s+1);if(r>0)return null}if(o.parentOffset==o.parent.content.size)for(let s=o.depth-1;s>=0;s--){let r=o.indexAfter(s);if(o.node(s).canReplaceWith(r,r,t))return o.after(s+1);if(r<o.node(s).childCount)return null}return null}function zf(n,e,t){let o=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let r=0;r<t.openStart;r++)s=s.firstChild.content;for(let r=1;r<=(t.openStart==0&&t.size?2:1);r++)for(let i=o.depth;i>=0;i--){let l=i==o.depth?0:o.pos<=(o.start(i+1)+o.end(i+1))/2?-1:1,a=o.index(i)+(l>0?1:0),c=o.node(i),d=!1;if(r==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(i+1):o.after(i+1)}return null}function or(n,e,t=e,o=A.empty){if(e==t&&!o.size)return null;let s=n.resolve(e),r=n.resolve(t);return ya(s,r,o)?new se(e,t,o):new Bf(s,r,o).fit()}function ya(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Bf{constructor(e,t,o){this.$from=e,this.$to=t,this.unplaced=o,this.frontier=[],this.placed=E.empty;for(let s=0;s<=e.depth;s++){let r=e.node(s);this.frontier.push({type:r.type,match:r.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=E.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 r=this.placed,i=o.depth,l=s.depth;for(;i&&l&&r.childCount==1;)r=r.firstChild.content,i--,l--;let a=new A(r,i,l);return e>-1?new ee(o.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||o.pos!=this.$to.pos?new se(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 r=t.firstChild;if(t.childCount>1&&(s=0),r.type.spec.isolating&&s<=o){e=o;break}t=r.content}for(let t=1;t<=2;t++)for(let o=t==1?e:this.unplaced.openStart;o>=0;o--){let s,r=null;o?(r=sr(this.unplaced.content,o-1).firstChild,s=r.content):s=this.unplaced.content;let i=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(i?c.matchType(i.type)||(u=c.fillBefore(E.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:o,frontierDepth:l,parent:r,inject:u};if(t==2&&i&&(d=c.findWrapping(i.type)))return{sliceDepth:o,frontierDepth:l,parent:r,wrap:d};if(r&&c.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:o}=this.unplaced,s=sr(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new A(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=sr(e,t);if(s.childCount<=1&&t>0){let r=e.size-t<=t+s.size;this.unplaced=new A(Rn(e,t-1,1),t-1,r?t-1:o)}else this.unplaced=new A(Rn(e,t,1),t,o)}placeNodes({sliceDepth:e,frontierDepth:t,parent:o,inject:s,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let m=0;m<r.length;m++)this.openFrontierNode(r[m]);let i=this.unplaced,l=o?o.content:i.content,a=i.openStart-e,c=0,d=[],{match:u,type:p}=this.frontier[t];if(s){for(let m=0;m<s.childCount;m++)d.push(s.child(m));u=u.matchFragment(s)}let h=l.size+e-(i.content.size-i.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(ba(m.mark(p.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let f=c==l.childCount;f||(h=-1),this.placed=Dn(this.placed,t,E.from(d)),this.frontier[t].match=u,f&&h<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=f?e==0?A.empty:new A(Rn(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new A(Rn(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!rr(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],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=rr(e,t,s,o,r);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=rr(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:i,move:r?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Dn(this.placed,t.depth,t.fit)),e=t.move;for(let o=t.depth+1;o<=e.depth;o++){let s=e.node(o),r=s.type.contentMatch.fillBefore(s.content,!0,e.index(o));this.openFrontierNode(s.type,s.attrs,r)}return e}openFrontierNode(e,t=null,o){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Dn(this.placed,this.depth,E.from(e.create(t,o))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(E.empty,!0);t.childCount&&(this.placed=Dn(this.placed,this.frontier.length,t))}}function Rn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Rn(n.firstChild.content,e-1,t)))}function Dn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Dn(n.lastChild.content,e-1,t)))}function sr(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function ba(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,ba(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(E.empty,!0)))),n.copy(o)}function rr(n,e,t,o,s){let r=n.node(e),i=s?n.indexAfter(e):n.index(e);if(i==r.childCount&&!t.compatibleContent(r.type))return null;let l=o.fillBefore(r.content,!0,i);return l&&!Vf(t,r.content,i)?l:null}function Vf(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function Hf(n){return n.spec.defining||n.spec.definingForContent}function Ff(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),r=n.doc.resolve(t);if(ya(s,r,o))return n.step(new se(e,t,o));let i=va(s,n.doc.resolve(t));i[i.length-1]==0&&i.pop();let l=-(s.depth+1);i.unshift(l);for(let p=s.depth,h=s.pos-1;p>0;p--,h--){let f=s.node(p).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;i.indexOf(p)>-1?l=p:s.before(p)==h&&i.splice(1,0,-p)}let a=i.indexOf(l),c=[],d=o.openStart;for(let p=o.content,h=0;;h++){let f=p.firstChild;if(c.push(f),h==o.openStart)break;p=f.content}for(let p=d-1;p>=0;p--){let h=c[p],f=Hf(h.type);if(f&&!h.sameMarkup(s.node(Math.abs(l)-1)))d=p;else if(f||!h.type.isTextblock)break}for(let p=o.openStart;p>=0;p--){let h=(p+d+1)%(o.openStart+1),f=c[h];if(f)for(let m=0;m<i.length;m++){let g=i[(m+a)%i.length],b=!0;g<0&&(b=!1,g=-g);let C=s.node(g-1),y=s.index(g-1);if(C.canReplaceWith(y,y,f.type,f.marks))return n.replace(s.before(g),b?r.after(g):t,new A(Sa(o.content,0,o.openStart,h),h,o.openEnd))}}let u=n.steps.length;for(let p=i.length-1;p>=0&&(n.replace(e,t,o),!(n.steps.length>u));p--){let h=i[p];h<0||(e=s.before(h),t=r.after(h))}}function Sa(n,e,t,o,s){if(e<t){let r=n.firstChild;n=n.replaceChild(0,r.copy(Sa(r.content,e+1,t,o,r)))}if(e>o){let r=s.contentMatchAt(0),i=r.fillBefore(n).append(n);n=i.append(r.matchFragment(i).fillBefore(E.empty,!0))}return n}function _f(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=$f(n.doc,e,o.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new A(E.from(o),0,0))}function Gf(n,e,t){let o=n.doc.resolve(e),s=n.doc.resolve(t),r=va(o,s);for(let i=0;i<r.length;i++){let l=r[i],a=i==r.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 i=1;i<=o.depth&&i<=s.depth;i++)if(e-o.start(i)==o.depth-i&&t>o.end(i)&&s.end(i)-t!=s.depth-i&&o.start(i-1)==s.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),s.index(i-1)))return n.delete(o.before(i),t);n.delete(e,t)}function va(n,e){let t=[],o=Math.min(n.depth,e.depth);for(let s=o;s>=0;s--){let r=n.start(s);if(r<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;(r==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==r-1)&&t.push(s)}return t}class an extends oe{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 U.fail("No node at attribute step's position");let o=Object.create(null);for(let r in t.attrs)o[r]=t.attrs[r];o[this.attr]=this.value;let s=t.type.create(o,null,t.marks);return U.fromReplace(e,this.pos,this.pos+1,new A(E.from(s),0,t.isLeaf?0:1))}getMap(){return ge.empty}invert(e){return new an(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 an(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 an(t.pos,t.attr,t.value)}}oe.jsonID("attr",an);class Ln extends oe{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 U.ok(o)}getMap(){return ge.empty}invert(e){return new Ln(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 Ln(t.attr,t.value)}}oe.jsonID("docAttr",Ln);let cn=class extends Error{};cn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},cn.prototype=Object.create(Error.prototype),cn.prototype.constructor=cn,cn.prototype.name="TransformError";class xa{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new sn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new cn(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=A.empty){let s=or(this.doc,e,t,o);return s&&this.step(s),this}replaceWith(e,t,o){return this.replace(e,t,new A(E.from(o),0,0))}delete(e,t){return this.replace(e,t,A.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,o){return Ff(this,e,t,o),this}replaceRangeWith(e,t,o){return _f(this,e,t,o),this}deleteRange(e,t){return Gf(this,e,t),this}lift(e,t){return Tf(this,e,t),this}join(e,t=1){return Lf(this,e,t),this}wrap(e,t){return Af(this,e,t),this}setBlockType(e,t=e,o,s=null){return Pf(this,e,t,o,s),this}setNodeMarkup(e,t,o=null,s){return Nf(this,e,t,o,s),this}setNodeAttribute(e,t,o){return this.step(new an(e,t,o)),this}setDocAttribute(e,t){return this.step(new Ln(e,t)),this}addNodeMark(e,t){return this.step(new nt(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 rn(e,t)),this}split(e,t=1,o){return If(this,e,t,o),this}addMark(e,t,o){return wf(this,e,t,o),this}removeMark(e,t,o){return Cf(this,e,t,o),this}clearIncompatible(e,t,o){return nr(this,e,t,o),this}}const ir=Object.create(null);class D{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new wa(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=A.empty){let o=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=o,o=o.lastChild;let r=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],d=e.mapping.slice(r);e.replaceRange(d.map(a.pos),d.map(c.pos),l?A.empty:t),l==0&&Ta(e,r,(o?o.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let o=e.steps.length,s=this.ranges;for(let r=0;r<s.length;r++){let{$from:i,$to:l}=s[r],a=e.mapping.slice(o),c=a.map(i.pos),d=a.map(l.pos);r?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),Ta(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let s=e.parent.inlineContent?new $(e):dn(e.node(0),e.parent,e.pos,e.index(),t,o);if(s)return s;for(let r=e.depth-1;r>=0;r--){let i=t<0?dn(e.node(0),e.node(r),e.before(r+1),e.index(r),t,o):dn(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,o);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ye(e.node(0))}static atStart(e){return dn(e,e,0,0,1)||new ye(e)}static atEnd(e){return dn(e,e,e.content.size,e.childCount,-1)||new ye(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let o=ir[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 ir)throw new RangeError("Duplicate use of selection JSON ID "+e);return ir[e]=t,t.prototype.jsonID=e,t}getBookmark(){return $.between(this.$anchor,this.$head).getBookmark()}}D.prototype.visible=!0;class wa{constructor(e,t){this.$from=e,this.$to=t}}let Ca=!1;function ka(n){!Ca&&!n.parent.inlineContent&&(Ca=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class $ extends D{constructor(e,t=e){ka(e),ka(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 D.near(o);let s=e.resolve(t.map(this.anchor));return new $(s.parent.inlineContent?s:o,o)}replace(e,t=A.empty){if(super.replace(e,t),t==A.empty){let o=this.$from.marksAcross(this.$to);o&&e.ensureMarks(o)}}eq(e){return e instanceof $&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new _o(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 $(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 r=D.findFrom(t,o,!0)||D.findFrom(t,-o,!0);if(r)t=r.$head;else return D.near(t,o)}return e.parent.inlineContent||(s==0?e=t:(e=(D.findFrom(e,-o,!0)||D.findFrom(e,o,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new $(e,t)}}D.jsonID("text",$);class _o{constructor(e,t){this.anchor=e,this.head=t}map(e){return new _o(e.map(this.anchor),e.map(this.head))}resolve(e){return $.between(e.resolve(this.anchor),e.resolve(this.head))}}class R extends D{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),r=e.resolve(s);return o?D.near(r):new R(r)}content(){return new A(E.from(this.node),0,0)}eq(e){return e instanceof R&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new lr(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new R(e.resolve(t.anchor))}static create(e,t){return new R(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}R.prototype.visible=!1,D.jsonID("node",R);class lr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new _o(o,o):new lr(o)}resolve(e){let t=e.resolve(this.anchor),o=t.nodeAfter;return o&&R.isSelectable(o)?new R(t):D.near(t)}}class ye extends D{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=A.empty){if(t==A.empty){e.delete(0,e.doc.content.size);let o=D.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ye(e)}map(e){return new ye(e)}eq(e){return e instanceof ye}getBookmark(){return Wf}}D.jsonID("all",ye);const Wf={map(){return this},resolve(n){return new ye(n)}};function dn(n,e,t,o,s,r=!1){if(e.inlineContent)return $.create(n,t);for(let i=o-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let l=e.child(i);if(l.isAtom){if(!r&&R.isSelectable(l))return R.create(n,t-(s<0?l.nodeSize:0))}else{let a=dn(n,l,t+s,s<0?l.childCount:0,s,r);if(a)return a}t+=l.nodeSize*s}return null}function Ta(n,e,t){let o=n.steps.length-1;if(o<e)return;let s=n.steps[o];if(!(s instanceof se||s instanceof ee))return;let r=n.mapping.maps[o],i;r.forEach((l,a,c,d)=>{i==null&&(i=d)}),n.setSelection(D.near(n.doc.resolve(i),t))}const Ea=1,Go=2,Ma=4;class jf extends xa{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|Ea)&~Go,this.storedMarks=null,this}get selectionSet(){return(this.updated&Ea)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Go,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&Go)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Go,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 r=this.storedMarks;if(!r){let i=this.doc.resolve(t);r=o==t?i.marks():i.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(t,o,s.text(e,r)),this.selection.empty||this.setSelection(D.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|=Ma,this}get scrolledIntoView(){return(this.updated&Ma)>0}}function Aa(n,e){return!e||!n?n:n.bind(e)}class $n{constructor(e,t,o){this.name=e,this.init=Aa(t.init,o),this.apply=Aa(t.apply,o)}}const qf=[new $n("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new $n("selection",{init(n,e){return n.selection||D.atStart(e.doc)},apply(n){return n.selection}}),new $n("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new $n("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class ar{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=qf.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 $n(o.key,o.spec.state,o))})}}class un{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 r=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=s?s[i].n:0,c=s?s[i].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,o);if(d&&o.filterTransaction(d,i)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<i?{state:o,n:t.length}:{state:this,n:0})}t.push(d),o=o.applyInner(d),r=!0}s&&(s[i]={state:o,n:t.length})}}if(!r)return{state:o,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new un(this.config),o=this.config.fields;for(let s=0;s<o.length;s++){let r=o[s];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new jf(this)}static create(e){let t=new ar(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new un(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 ar(this.schema,e.plugins),o=t.fields,s=new un(t);for(let r=0;r<o.length;r++){let i=o[r].name;s[i]=this.hasOwnProperty(i)?this[i]:o[r].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],r=s.spec.state;r&&r.toJSON&&(t[o]=r.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 ar(e.schema,e.plugins),r=new un(s);return s.fields.forEach(i=>{if(i.name=="doc")r.doc=At.fromJSON(e.schema,t.doc);else if(i.name=="selection")r.selection=D.fromJSON(r.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(r.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==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){r[i.name]=c.fromJSON.call(a,e,t[l],r);return}}r[i.name]=i.init(e,r)}}),r}}function Pa(n,e,t){for(let o in n){let s=n[o];s instanceof Function?s=s.bind(e):o=="handleDOMEvents"&&(s=Pa(s,e,{})),t[o]=s}return t}class pn{constructor(e){this.spec=e,this.props={},e.props&&Pa(e.props,this,this.props),this.key=e.key?e.key.key:Oa("plugin")}getState(e){return e[this.key]}}const cr=Object.create(null);function Oa(n){return n in cr?n+"$"+ ++cr[n]:(cr[n]=0,n+"$")}class zn{constructor(e="key"){this.key=Oa(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Na=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Uf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Kf=(n,e,t)=>{let o=Uf(n,t);if(!o)return!1;let s=Ia(o);if(!s){let i=o.blockRange(),l=i&&Ho(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let r=s.nodeBefore;if(Ba(n,s,e,-1))return!0;if(o.parent.content.size==0&&(hn(r,"end")||R.isSelectable(r)))for(let i=o.depth;;i--){let l=or(n.doc,o.before(i),o.after(i),A.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(hn(r,"end")?D.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):R.create(a.doc,s.pos-r.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||o.node(i-1).childCount>1)break}return r.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos-r.nodeSize,s.pos).scrollIntoView()),!0):!1};function hn(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 Jf=(n,e,t)=>{let{$head:o,empty:s}=n.selection,r=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):o.parentOffset>0)return!1;r=Ia(o)}let i=r&&r.nodeBefore;return!i||!R.isSelectable(i)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,r.pos-i.nodeSize)).scrollIntoView()),!0)};function Ia(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 Zf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Yf=(n,e,t)=>{let o=Zf(n,t);if(!o)return!1;let s=Ra(o);if(!s)return!1;let r=s.nodeAfter;if(Ba(n,s,e,1))return!0;if(o.parent.content.size==0&&(hn(r,"start")||R.isSelectable(r))){let i=or(n.doc,o.before(),o.after(),A.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(hn(r,"start")?D.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):R.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return r.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+r.nodeSize).scrollIntoView()),!0):!1},Xf=(n,e,t)=>{let{$head:o,empty:s}=n.selection,r=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):o.parentOffset<o.parent.content.size)return!1;r=Ra(o)}let i=r&&r.nodeAfter;return!i||!R.isSelectable(i)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,r.pos)).scrollIntoView()),!0)};function Ra(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 Qf=(n,e)=>{let{$head:t,$anchor:o}=n.selection;return!t.parent.type.spec.code||!t.sameParent(o)?!1:(e&&e(n.tr.insertText(`
804
- `).scrollIntoView()),!0)};function dr(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 Da=(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),r=t.indexAfter(-1),i=dr(s.contentMatchAt(r));if(!i||!s.canReplaceWith(r,r,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(D.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},em=(n,e)=>{let t=n.selection,{$from:o,$to:s}=t;if(t instanceof ye||o.parent.inlineContent||s.parent.inlineContent)return!1;let r=dr(s.parent.contentMatchAt(s.indexAfter()));if(!r||!r.isTextblock)return!1;if(e){let i=(!o.parentOffset&&s.index()<s.parent.childCount?o:s).pos,l=n.tr.insert(i,r.createAndFill());l.setSelection($.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},La=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let r=t.before();if(ln(n.doc,r))return e&&e(n.tr.split(r).scrollIntoView()),!0}let o=t.blockRange(),s=o&&Ho(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)};function $a(n){return(e,t)=>{let{$from:o,$to:s}=e.selection;if(e.selection instanceof R&&e.selection.node.isBlock)return!o.parentOffset||!ln(e.doc,o.pos)?!1:(t&&t(e.tr.split(o.pos).scrollIntoView()),!0);if(!o.depth)return!1;let r=[],i,l,a=!1,c=!1;for(let h=o.depth;;h--)if(o.node(h).isBlock){a=o.end(h)==o.pos+(o.depth-h),c=o.start(h)==o.pos-(o.depth-h),l=dr(o.node(h-1).contentMatchAt(o.indexAfter(h-1)));let m=n&&n(s.parent,a,o);r.unshift(m||(a&&l?{type:l}:null)),i=h;break}else{if(h==1)return!1;r.unshift(null)}let d=e.tr;(e.selection instanceof $||e.selection instanceof ye)&&d.deleteSelection();let u=d.mapping.map(o.pos),p=ln(d.doc,u,r.length,r);if(p||(r[0]=l?{type:l}:null,p=ln(d.doc,u,r.length,r)),d.split(u,r.length,r),!a&&c&&o.node(i).type!=l){let h=d.mapping.map(o.before(i)),f=d.doc.resolve(h);l&&o.node(i-1).canReplaceWith(f.index(),f.index()+1,l)&&d.setNodeMarkup(d.mapping.map(o.before(i)),l)}return t&&t(d.scrollIntoView()),!0}}const tm=$a(),za=(n,e)=>(e&&e(n.tr.setSelection(new ye(n.doc))),!0);function nm(n,e,t){let o=e.nodeBefore,s=e.nodeAfter,r=e.index();return!o||!s||!o.type.compatibleContent(s.type)?!1:!o.content.size&&e.parent.canReplace(r-1,r)?(t&&t(n.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(r,r+1)||!(s.isTextblock||Fo(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Ba(n,e,t,o){let s=e.nodeBefore,r=e.nodeAfter,i,l,a=s.type.spec.isolating||r.type.spec.isolating;if(!a&&nm(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=s.contentMatchAt(s.childCount)).findWrapping(r.type))&&l.matchType(i[0]||r.type).validEnd){if(t){let h=e.pos+r.nodeSize,f=E.empty;for(let b=i.length-1;b>=0;b--)f=E.from(i[b].create(null,f));f=E.from(s.copy(f));let m=n.tr.step(new ee(e.pos-1,h,e.pos,h,new A(f,1,0),i.length,!0)),g=m.doc.resolve(h+2*i.length);g.nodeAfter&&g.nodeAfter.type==s.type&&Fo(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=r.type.spec.isolating||o>0&&a?null:D.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),p=u&&Ho(u);if(p!=null&&p>=e.depth)return t&&t(n.tr.lift(u,p).scrollIntoView()),!0;if(c&&hn(r,"start",!0)&&hn(s,"end")){let h=s,f=[];for(;f.push(h),!h.isTextblock;)h=h.lastChild;let m=r,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let b=E.empty;for(let y=f.length-1;y>=0;y--)b=E.from(f[y].copy(b));let C=n.tr.step(new ee(e.pos-f.length,e.pos+r.nodeSize,e.pos+g,e.pos+r.nodeSize-g,new A(b,f.length,0),0,!0));t(C.scrollIntoView())}return!0}}return!1}function Va(n){return function(e,t){let o=e.selection,s=n<0?o.$from:o.$to,r=s.depth;for(;s.node(r).isInline;){if(!r)return!1;r--}return s.node(r).isTextblock?(t&&t(e.tr.setSelection($.create(e.doc,n<0?s.start(r):s.end(r)))),!0):!1}}const om=Va(-1),sm=Va(1);function rm(n,e=null){return function(t,o){let s=!1;for(let r=0;r<t.selection.ranges.length&&!s;r++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[r];t.doc.nodesBetween(i,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 r=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];r.setBlockType(l,a,n,e)}o(r.scrollIntoView())}return!0}}function im(n,e,t,o){for(let s=0;s<e.length;s++){let{$from:r,$to:i}=e[s],l=r.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(r.pos,i.pos,(a,c)=>{if(l||!o)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function Nt(n,e=null,t){let o=t!==!1;return function(s,r){let{empty:i,$cursor:l,ranges:a}=s.selection;if(i&&!l||!im(s.doc,a,n,o))return!1;if(r)if(l)n.isInSet(s.storedMarks||l.marks())?r(s.tr.removeStoredMark(n)):r(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:p,$to:h}=a[u];if(!c)d.removeMark(p.pos,h.pos,n);else{let f=p.pos,m=h.pos,g=p.nodeAfter,b=h.nodeBefore,C=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,y=b&&b.isText?/\s*$/.exec(b.text)[0].length:0;f+C<m&&(f+=C,m-=y),d.addMark(f,m,n.create(e))}}r(d.scrollIntoView())}return!0}}function Bn(...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 ur=Bn(Na,Kf,Jf),Ha=Bn(Na,Yf,Xf);const We={Enter:Bn(Qf,em,La,tm),"Mod-Enter":Da,Backspace:ur,"Mod-Backspace":ur,"Shift-Backspace":ur,Delete:Ha,"Mod-Delete":Ha,"Mod-a":za},Fa={"Ctrl-h":We.Backspace,"Alt-Backspace":We["Mod-Backspace"],"Ctrl-d":We.Delete,"Ctrl-Alt-Backspace":We["Mod-Delete"],"Alt-Delete":We["Mod-Delete"],"Alt-d":We["Mod-Delete"],"Ctrl-a":om,"Ctrl-e":sm};for(let n in We)Fa[n]=We[n];const lm=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?Fa:We;var Wo=200,Y=function(){};Y.prototype.append=function(e){return e.length?(e=Y.from(e),!this.length&&e||e.length<Wo&&this.leafAppend(e)||this.length<Wo&&e.leafPrepend(this)||this.appendInner(e)):this},Y.prototype.prepend=function(e){return e.length?Y.from(e).append(this):this},Y.prototype.appendInner=function(e){return new am(this,e)},Y.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Y.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Y.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Y.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)},Y.prototype.map=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length);var s=[];return this.forEach(function(r,i){return s.push(e(r,i))},t,o),s},Y.from=function(e){return e instanceof Y?e:e&&e.length?new _a(e):Y.empty};var _a=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,r){return s==0&&r==this.length?this:new e(this.values.slice(s,r))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,r,i,l){for(var a=r;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,r,i,l){for(var a=r-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Wo)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Wo)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}(Y);Y.empty=new _a([]);var am=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,r,i){var l=this.left.length;if(s<l&&this.left.forEachInner(o,s,Math.min(r,l),i)===!1||r>l&&this.right.forEachInner(o,Math.max(s-l,0),Math.min(this.length,r)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,r,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(o,s-l,Math.max(r,l)-l,i+l)===!1||r<l&&this.left.forEachInvertedInner(o,Math.min(s,l),r,i)===!1)return!1},e.prototype.sliceInner=function(o,s){if(o==0&&s==this.length)return this;var r=this.left.length;return s<=r?this.left.slice(o,s):o>=r?this.right.slice(o-r,s-r):this.left.slice(o,r).append(this.right.slice(0,s-r))},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}(Y);const cm=500;class Ee{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,r;t&&(s=this.remapping(o,this.items.length),r=s.maps.length);let i=e.tr,l,a,c=[],d=[];return this.items.forEach((u,p)=>{if(!u.step){s||(s=this.remapping(o,p+1),r=s.maps.length),r--,d.push(u);return}if(s){d.push(new $e(u.map));let h=u.step.map(s.slice(r)),f;h&&i.maybeStep(h).doc&&(f=i.mapping.maps[i.mapping.maps.length-1],c.push(new $e(f,void 0,void 0,c.length+d.length))),r--,f&&s.appendMap(f,r)}else i.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(r)):u.selection,a=new Ee(this.items.slice(0,o).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,o,s){let r=[],i=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]),p=new $e(e.mapping.maps[d],u,t),h;(h=a&&a.merge(p))&&(p=h,d?r.pop():l=l.slice(0,l.length-1)),r.push(p),t&&(i++,t=void 0),s||(a=p)}let c=i-o.depth;return c>um&&(l=dm(l,c),i-=c),new Ee(l.append(r),i)}remapping(e,t){let o=new sn;return this.items.forEach((s,r)=>{let i=s.mirrorOffset!=null&&r-s.mirrorOffset>=e?o.maps.length-s.mirrorOffset:void 0;o.appendMap(s.map,i)},e,t),o}addMaps(e){return this.eventCount==0?this:new Ee(this.items.append(e.map(t=>new $e(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],s=Math.max(0,this.items.length-t),r=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},s);let a=t;this.items.forEach(p=>{let h=r.getMirror(--a);if(h==null)return;i=Math.min(i,h);let f=r.maps[h];if(p.step){let m=e.steps[h].invert(e.docs[h]),g=p.selection&&p.selection.map(r.slice(a+1,h));g&&l++,o.push(new $e(f,m,g))}else o.push(new $e(f))},s);let c=[];for(let p=t;p<i;p++)c.push(new $e(r.maps[p]));let d=this.items.slice(0,s).append(c).append(o),u=new Ee(d,l);return u.emptyItemCount()>cm&&(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=[],r=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&r++;else if(i.step){let a=i.step.map(t.slice(o)),c=a&&a.getMap();if(o--,c&&t.appendMap(c,o),a){let d=i.selection&&i.selection.map(t.slice(o));d&&r++;let u=new $e(c.invert(),a,d),p,h=s.length-1;(p=s.length&&s[h].merge(u))?s[h]=p:s.push(u)}}else i.map&&o--},this.items.length,0),new Ee(Y.from(s.reverse()),r)}}Ee.empty=new Ee(Y.empty,0);function dm(n,e){let t;return n.forEach((o,s)=>{if(o.selection&&e--==0)return t=s,!1}),n.slice(t)}class $e{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 $e(t.getMap().invert(),t,this.selection)}}}class ot{constructor(e,t,o,s,r){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=s,this.prevComposition=r}}const um=20;function pm(n,e,t,o){let s=t.getMeta(It),r;if(s)return s.historyState;t.getMeta(mm)&&(n=new ot(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(It))return i.getMeta(It).redo?new ot(n.done.addTransform(t,void 0,o,jo(e)),n.undone,Ga(t.mapping.maps),n.prevTime,n.prevComposition):new ot(n.done,n.undone.addTransform(t,void 0,o,jo(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!hm(t,n.prevRanges)),c=i?pr(n.prevRanges,t.mapping):Ga(t.mapping.maps);return new ot(n.done.addTransform(t,a?e.selection.getBookmark():void 0,o,jo(e)),Ee.empty,c,t.time,l??n.prevComposition)}else return(r=t.getMeta("rebased"))?new ot(n.done.rebased(t,r),n.undone.rebased(t,r),pr(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new ot(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),pr(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function hm(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((o,s)=>{for(let r=0;r<e.length;r+=2)o<=e[r+1]&&s>=e[r]&&(t=!0)}),t}function Ga(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,s,r,i)=>e.push(r,i));return e}function pr(n,e){if(!n)return null;let t=[];for(let o=0;o<n.length;o+=2){let s=e.map(n[o],1),r=e.map(n[o+1],-1);s<=r&&t.push(s,r)}return t}function fm(n,e,t){let o=jo(e),s=It.get(e).spec.config,r=(t?n.undone:n.done).popEvent(e,o);if(!r)return null;let i=r.selection.resolve(r.transform.doc),l=(t?n.done:n.undone).addTransform(r.transform,e.selection.getBookmark(),s,o),a=new ot(t?l:r.remaining,t?r.remaining:l,null,0,-1);return r.transform.setSelection(i).setMeta(It,{redo:t,historyState:a})}let hr=!1,Wa=null;function jo(n){let e=n.plugins;if(Wa!=e){hr=!1,Wa=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){hr=!0;break}}return hr}const It=new zn("history"),mm=new zn("closeHistory");function gm(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new pn({key:It,state:{init(){return new ot(Ee.empty,Ee.empty,null,0,-1)},apply(e,t,o){return pm(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,s=o=="historyUndo"?qa:o=="historyRedo"?fr:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function ja(n,e){return(t,o)=>{let s=It.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(o){let r=fm(s,t,n);r&&o(e?r.scrollIntoView():r)}return!0}}const qa=ja(!1,!0),fr=ja(!0,!0);for(var st={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:"'"},qo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ym=typeof navigator<"u"&&/Mac/.test(navigator.platform),bm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),te=0;te<10;te++)st[48+te]=st[96+te]=String(te);for(var te=1;te<=24;te++)st[te+111]="F"+te;for(var te=65;te<=90;te++)st[te]=String.fromCharCode(te+32),qo[te]=String.fromCharCode(te);for(var mr in st)qo.hasOwnProperty(mr)||(qo[mr]=st[mr]);function Sm(n){var e=ym&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||bm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?qo:st)[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 vm=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function xm(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let o,s,r,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!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))r=!0;else if(/^mod$/i.test(a))vm?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return o&&(t="Alt-"+t),s&&(t="Ctrl-"+t),i&&(t="Meta-"+t),r&&(t="Shift-"+t),t}function wm(n){let e=Object.create(null);for(let t in n)e[xm(t)]=n[t];return e}function gr(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 yr(n){return new pn({props:{handleKeyDown:Ua(n)}})}function Ua(n){let e=wm(n);return function(t,o){let s=Sm(o),r,i=e[gr(s,o)];if(i&&i(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(o.shiftKey){let l=e[gr(s,o,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((o.shiftKey||o.altKey||o.metaKey||s.charCodeAt(0)>127)&&(r=st[o.keyCode])&&r!=s){let l=e[gr(r,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function Ka(n,e=null){return function(t,o){let{$from:s,$to:r}=t.selection,i=s.blockRange(r),l=!1,a=i;if(!i)return!1;if(i.depth>=2&&s.node(i.depth-1).type.compatibleContent(n)&&i.startIndex==0){if(s.index(i.depth-1)==0)return!1;let d=t.doc.resolve(i.start-2);a=new Io(d,d,i.depth),i.endIndex<i.parent.childCount&&(i=new Io(s,t.doc.resolve(r.end(i.depth)),i.depth)),l=!0}let c=ha(a,n,e,i);return c?(o&&o(Cm(t.tr,i,c,l,n).scrollIntoView()),!0):!1}}function Cm(n,e,t,o,s){let r=E.empty;for(let d=t.length-1;d>=0;d--)r=E.from(t[d].type.create(t[d].attrs,r));n.step(new ee(e.start-(o?2:0),e.end,e.start,e.end,new A(r,0,0),t.length,!0));let i=0;for(let d=0;d<t.length;d++)t[d].type==s&&(i=d+1);let l=t.length-i,a=e.start+t.length-(o?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,p=!0;d<u;d++,p=!1)!p&&ln(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function km(n,e){return function(t,o){let{$from:s,$to:r,node:i}=t.selection;if(i&&i.isBlock||s.depth<2||!s.sameParent(r))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=E.empty,p=s.index(-1)?1:s.index(-2)?2:3;for(let b=s.depth-p;b>=s.depth-3;b--)u=E.from(s.node(b).copy(u));let h=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3;u=u.append(E.from(n.createAndFill()));let f=s.before(s.depth-(p-1)),m=t.tr.replace(f,s.after(-h),new A(u,4-p,0)),g=-1;m.doc.nodesBetween(f,m.doc.content.size,(b,C)=>{if(g>-1)return!1;b.isTextblock&&b.content.size==0&&(g=C+1)}),g>-1&&m.setSelection(D.near(m.doc.resolve(g))),o(m.scrollIntoView())}return!0}let a=r.pos==s.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(s.pos,r.pos),d=a?[null,{type:a}]:void 0;return ln(c.doc,s.pos,2,d)?(o&&o(c.split(s.pos,2,d).scrollIntoView()),!0):!1}}function br(n){return function(e,t){let{$from:o,$to:s}=e.selection,r=o.blockRange(s,i=>i.childCount>0&&i.firstChild.type==n);return r?t?o.node(r.depth-1).type==n?Tm(e,t,n,r):Em(e,t,r):!0:!1}}function Tm(n,e,t,o){let s=n.tr,r=o.end,i=o.$to.end(o.depth);r<i&&(s.step(new ee(r-1,i,r,i,new A(E.from(t.create(null,o.parent.copy())),1,0),1,!0)),o=new Io(s.doc.resolve(o.$from.pos),s.doc.resolve(i),o.depth));const l=Ho(o);if(l==null)return!1;s.lift(o,l);let a=s.mapping.map(r,-1)-1;return Fo(s.doc,a)&&s.join(a),e(s.scrollIntoView()),!0}function Em(n,e,t){let o=n.tr,s=t.parent;for(let h=t.end,f=t.endIndex-1,m=t.startIndex;f>m;f--)h-=s.child(f).nodeSize,o.delete(h-1,h+1);let r=o.doc.resolve(t.start),i=r.nodeAfter;if(o.mapping.map(t.end)!=t.start+r.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=r.node(-1),d=r.index(-1);if(!c.canReplace(d+(l?0:1),d+1,i.content.append(a?E.empty:E.from(s))))return!1;let u=r.pos,p=u+i.nodeSize;return o.step(new ee(u-(l?1:0),p+(a?1:0),u+1,p-1,new A((l?E.empty:E.from(s.copy(E.empty))).append(a?E.empty:E.from(s.copy(E.empty))),l?0:1,a?0:1),l?0:1)),e(o.scrollIntoView()),!0}function Mm(n){return function(e,t){let{$from:o,$to:s}=e.selection,r=o.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!r)return!1;let i=r.startIndex;if(i==0)return!1;let l=r.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=E.from(c?n.create():null),u=new A(E.from(n.create(null,E.from(l.type.create(null,d)))),c?3:1,0),p=r.start,h=r.end;t(e.tr.step(new ee(p-(c?3:1),h,p,h,u,1,!0)).scrollIntoView())}return!0}}const ne=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Vn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Sr=null;const je=function(n,e,t){let o=Sr||(Sr=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o},Am=function(){Sr=null},Rt=function(n,e,t,o){return t&&(Ja(n,e,t,o,-1)||Ja(n,e,t,o,1))},Pm=/^(img|br|input|textarea|hr)$/i;function Ja(n,e,t,o,s){for(;;){if(n==t&&e==o)return!0;if(e==(s<0?0:ve(n))){let r=n.parentNode;if(!r||r.nodeType!=1||Hn(n)||Pm.test(n.nodeName)||n.contentEditable=="false")return!1;e=ne(n)+(s<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.contentEditable=="false")return!1;e=s<0?ve(n):0}else return!1}}function ve(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Om(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=ve(n)}else if(n.parentNode&&!Hn(n))e=ne(n),n=n.parentNode;else return null}}function Nm(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&&!Hn(n))e=ne(n)+1,n=n.parentNode;else return null}}function Im(n,e,t){for(let o=e==0,s=e==ve(n);o||s;){if(n==t)return!0;let r=ne(n);if(n=n.parentNode,!n)return!1;o=o&&r==0,s=s&&r==ve(n)}}function Hn(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 Uo=function(n){return n.focusNode&&Rt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Dt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Rm(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Dm(n,e,t){if(n.caretPositionFromPoint)try{let o=n.caretPositionFromPoint(e,t);if(o)return{node:o.offsetNode,offset:Math.min(ve(o.offsetNode),o.offset)}}catch{}if(n.caretRangeFromPoint){let o=n.caretRangeFromPoint(e,t);if(o)return{node:o.startContainer,offset:Math.min(ve(o.startContainer),o.startOffset)}}}const ze=typeof navigator<"u"?navigator:null,Za=typeof document<"u"?document:null,rt=ze&&ze.userAgent||"",vr=/Edge\/(\d+)/.exec(rt),Ya=/MSIE \d/.exec(rt),xr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(rt),fe=!!(Ya||xr||vr),it=Ya?document.documentMode:xr?+xr[1]:vr?+vr[1]:0,Me=!fe&&/gecko\/(\d+)/i.test(rt);Me&&+(/Firefox\/(\d+)/.exec(rt)||[0,0])[1];const wr=!fe&&/Chrome\/(\d+)/.exec(rt),re=!!wr,Xa=wr?+wr[1]:0,ce=!fe&&!!ze&&/Apple Computer/.test(ze.vendor),fn=ce&&(/Mobile\/\w+/.test(rt)||!!ze&&ze.maxTouchPoints>2),xe=fn||(ze?/Mac/.test(ze.platform):!1),Lm=ze?/Win/.test(ze.platform):!1,Ae=/Android \d/.test(rt),Fn=!!Za&&"webkitFontSmoothing"in Za.documentElement.style,$m=Fn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function zm(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 qe(n,e){return typeof n=="number"?n:n[e]}function Bm(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 Qa(n,e,t){let o=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,r=n.dom.ownerDocument;for(let i=t||n.dom;i;i=Vn(i)){if(i.nodeType!=1)continue;let l=i,a=l==r.body,c=a?zm(r):Bm(l),d=0,u=0;if(e.top<c.top+qe(o,"top")?u=-(c.top-e.top+qe(s,"top")):e.bottom>c.bottom-qe(o,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+qe(s,"top")-c.top:e.bottom-c.bottom+qe(s,"bottom")),e.left<c.left+qe(o,"left")?d=-(c.left-e.left+qe(s,"left")):e.right>c.right-qe(o,"right")&&(d=e.right-c.right+qe(s,"right")),d||u)if(a)r.defaultView.scrollBy(d,u);else{let p=l.scrollLeft,h=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let f=l.scrollLeft-p,m=l.scrollTop-h;e={left:e.left-f,top:e.top-m,right:e.right-f,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(i).position))break}}function Vm(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),o,s;for(let r=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(r,i);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:ec(n.dom)}}function ec(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=Vn(o));return e}function Hm({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;tc(t,o==0?0:o-e)}function tc(n,e){for(let t=0;t<n.length;t++){let{dom:o,top:s,left:r}=n[t];o.scrollTop!=s+e&&(o.scrollTop=s+e),o.scrollLeft!=r&&(o.scrollLeft=r)}}let mn=null;function Fm(n){if(n.setActive)return n.setActive();if(mn)return n.focus(mn);let e=ec(n);n.focus(mn==null?{get preventScroll(){return mn={preventScroll:!0},!0}}:void 0),mn||(mn=!1,tc(e,0))}function nc(n,e){let t,o=2e8,s,r=0,i=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let p;if(d.nodeType==1)p=d.getClientRects();else if(d.nodeType==3)p=je(d).getClientRects();else continue;for(let h=0;h<p.length;h++){let f=p[h];if(f.top<=i&&f.bottom>=l){i=Math.max(f.bottom,i),l=Math.min(f.top,l);let m=f.left>e.left?f.left-e.left:f.right<e.left?e.left-f.right:0;if(m<o){t=d,o=m,s=m&&t.nodeType==3?{left:f.right<e.left?f.right:f.left,top:e.top}:e,d.nodeType==1&&m&&(r=u+(e.left>=(f.left+f.right)/2?1:0));continue}}else f.top>e.top&&!a&&f.left<=e.left&&f.right>=e.left&&(a=d,c={left:Math.max(f.left,Math.min(f.right,e.left)),top:f.top});!t&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(r=u+1)}}return!t&&a&&(t=a,s=c,o=0),t&&t.nodeType==3?_m(t,s):!t||o&&t.nodeType==1?{node:n,offset:r}:nc(t,s)}function _m(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 r=lt(o,1);if(r.top!=r.bottom&&Cr(e,r))return{node:n,offset:s+(e.left>=(r.left+r.right)/2?1:0)}}return{node:n,offset:0}}function Cr(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Gm(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Wm(n,e,t){let{node:o,offset:s}=nc(e,t),r=-1;if(o.nodeType==1&&!o.firstChild){let i=o.getBoundingClientRect();r=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(o,s,r)}function jm(n,e,t,o){let s=-1;for(let r=e,i=!1;r!=n.dom;){let l=n.docView.nearestDesc(r,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!i&&a.left>o.left||a.top>o.top?s=l.posBefore:(!i&&a.right<o.left||a.bottom<o.top)&&(s=l.posAfter),i=!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}r=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function oc(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)),r=s;;){let i=n.childNodes[r];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Cr(e,c))return oc(i,e,c)}}if((r=(r+1)%o)==s)break}return n}function qm(n,e){let t=n.dom.ownerDocument,o,s=0,r=Dm(t,e.left,e.top);r&&({node:o,offset:s}=r);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!Cr(e,c)||(i=oc(n.dom,e,c),!i))return null}if(ce)for(let c=i;o&&c;c=Vn(c))c.draggable&&(o=void 0);if(i=Gm(i,e),o){if(Me&&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;Fn&&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=jm(n,o,s,e))}l==null&&(l=Wm(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function sc(n){return n.top<n.bottom||n.left<n.right}function lt(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(sc(o))return o}return Array.prototype.find.call(t,sc)||n.getBoundingClientRect()}const Um=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function rc(n,e,t){let{node:o,offset:s,atom:r}=n.docView.domFromPos(e,t<0?-1:1),i=Fn||Me;if(o.nodeType==3)if(i&&(Um.test(o.nodeValue)||(t<0?!s:s==o.nodeValue.length))){let a=lt(je(o,s,s),t);if(Me&&s&&/\s/.test(o.nodeValue[s-1])&&s<o.nodeValue.length){let c=lt(je(o,s-1,s-1),-1);if(c.top==a.top){let d=lt(je(o,s,s+1),-1);if(d.top!=a.top)return _n(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++,_n(lt(je(o,a,c),d),d<0)}if(!n.state.doc.resolve(e-(r||0)).parent.inlineContent){if(r==null&&s&&(t<0||s==ve(o))){let a=o.childNodes[s-1];if(a.nodeType==1)return kr(a.getBoundingClientRect(),!1)}if(r==null&&s<ve(o)){let a=o.childNodes[s];if(a.nodeType==1)return kr(a.getBoundingClientRect(),!0)}return kr(o.getBoundingClientRect(),t>=0)}if(r==null&&s&&(t<0||s==ve(o))){let a=o.childNodes[s-1],c=a.nodeType==3?je(a,ve(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return _n(lt(c,1),!1)}if(r==null&&s<ve(o)){let a=o.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?je(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return _n(lt(c,-1),!0)}return _n(lt(o.nodeType==3?je(o):o,-t),t>=0)}function _n(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 kr(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 ic(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 Km(n,e,t){let o=e.selection,s=t=="up"?o.$from:o.$to;return ic(n,e,()=>{let{node:r}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(r,!0);if(!l)break;if(l.node.isBlock){r=l.contentDOM||l.dom;break}r=l.dom.parentNode}let i=rc(n,s.pos,1);for(let l=r.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=je(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"?i.top-d.top>(d.bottom-i.top)*2:d.bottom-i.bottom>(i.bottom-d.top)*2))return!1}}return!0})}const Jm=/[\u0590-\u08ac]/;function Zm(n,e,t){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let s=o.parentOffset,r=!s,i=s==o.parent.content.size,l=n.domSelection();return l?!Jm.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?r:i:ic(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",t,"character");let h=o.depth?n.docView.domAfterPos(o.before()):n.dom,{focusNode:f,focusOffset:m}=n.domSelectionRange(),g=f&&!h.contains(f.nodeType==1?f:f.parentNode)||a==f&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return p!=null&&(l.caretBidiLevel=p),g}):o.pos==o.start()||o.pos==o.end()}let lc=null,ac=null,cc=!1;function Ym(n,e,t){return lc==e&&ac==t?cc:(lc=e,ac=t,cc=t=="up"||t=="down"?Km(n,e,t):Zm(n,e,t))}const we=0,dc=1,Lt=2,Be=3;class Gn{constructor(e,t,o,s){this.parent=e,this.children=t,this.dom=o,this.contentDOM=s,this.dirty=we,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 r,i;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&!((i=r.pmViewDesc)&&i.parent==this);)r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}else{let r,i;if(e==this.contentDOM)r=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.nextSibling}for(;r&&!((i=r.pmViewDesc)&&i.parent==this);)r=r.nextSibling;return r?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>ne(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 r=e;;r=r.parentNode){if(r==this.dom){s=!1;break}if(r.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let r=e;;r=r.parentNode){if(r==this.dom){s=!0;break}if(r.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 r=this.getDesc(s),i;if(r&&(!t||r.node))if(o&&(i=r.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))o=!1;else return r}}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 r=this.getDesc(s);if(r)return r.localPosFromDOM(e,t,o)}return-1}descAt(e){for(let t=0,o=0;t<this.children.length;t++){let s=this.children[t],r=o+s.size;if(o==e&&r!=o){for(;!s.border&&s.children.length;)s=s.children[0];return s}if(e<r)return s.descAt(e-o-s.border);o=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let o=0,s=0;for(let r=0;o<this.children.length;o++){let i=this.children[o],l=r+i.size;if(l>e||i instanceof hc){s=e-r;break}r=l}if(s)return this.children[o].domFromPos(s-this.children[o].border,t);for(let r;o&&!(r=this.children[o-1]).size&&r instanceof uc&&r.side>=0;o--);if(t<=0){let r,i=!0;for(;r=o?this.children[o-1]:null,!(!r||r.dom.parentNode==this.contentDOM);o--,i=!1);return r&&t&&i&&!r.border&&!r.domAtom?r.domFromPos(r.size,t):{node:this.contentDOM,offset:r?ne(r.dom)+1:0}}else{let r,i=!0;for(;r=o<this.children.length?this.children[o]:null,!(!r||r.dom.parentNode==this.contentDOM);o++,i=!1);return r&&i&&!r.border&&!r.domAtom?r.domFromPos(0,t):{node:this.contentDOM,offset:r?ne(r.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,r=-1;for(let i=o,l=0;;l++){let a=this.children[l],c=i+a.size;if(s==-1&&e<=c){let d=i+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=i;for(let u=l;u>0;u--){let p=this.children[u-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){s=ne(p.dom)+1;break}e-=p.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)){r=ne(u.dom);break}t+=u.size}r==-1&&(r=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:r}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset: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 r=Math.min(e,t),i=Math.max(e,t);for(let h=0,f=0;h<this.children.length;h++){let m=this.children[h],g=f+m.size;if(r>f&&i<g)return m.setSelection(e-f-m.border,t-f-m.border,o,s);f=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((Me||ce)&&e==t){let{node:h,offset:f}=l;if(h.nodeType==3){if(u=!!(f&&h.nodeValue[f-1]==`
805
- `),u&&f==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:ne(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=h.childNodes[f-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Me&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||u&&ce)&&Rt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Rt(a.node,a.offset,d.focusNode,d.focusOffset))return;let p=!1;if((c.extend||e==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),p=!0}catch{}}if(!p){if(e>t){let f=l;l=a,a=f}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let o=0,s=0;s<this.children.length;s++){let r=this.children[s],i=o+r.size;if(o==i?e<=i&&t>=o:e<i&&t>o){let l=o+r.border,a=i-r.border;if(e>=l&&t<=a){this.dirty=e==o||t==i?Lt:dc,e==l&&t==a&&(r.contentLost||r.dom.parentNode!=this.contentDOM)?r.dirty=Be:r.markDirty(e-l,t-l);return}else r.dirty=r.dom==r.contentDOM&&r.dom.parentNode==this.contentDOM&&!r.children.length?Lt:Be}o=i}this.dirty=Lt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?Lt:dc;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class uc extends Gn{constructor(e,t,o,s){let r,i=t.type.toDOM;if(typeof i=="function"&&(i=i(o,()=>{if(!r)return s;if(r.parent)return r.parent.posBeforeChild(r)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==we&&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 Xm extends Gn{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 $t extends Gn{constructor(e,t,o,s,r){super(e,[],o,s),this.mark=t,this.spec=r}static create(e,t,o,s){let r=s.nodeViews[t.type.name],i=r&&r(t,s,o);return(!i||!i.dom)&&(i=Ot.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new $t(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Be||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Be&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=we){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=we}}slice(e,t,o){let s=$t.create(this.parent,this.mark,!0,o),r=this.children,i=this.size;t<i&&(r=Er(r,t,i,o)),e>0&&(r=Er(r,0,e,o));for(let l=0;l<r.length;l++)r[l].parent=s;return s.children=r,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class at extends Gn{constructor(e,t,o,s,r,i,l,a,c){super(e,[],r,i),this.node=t,this.outerDeco=o,this.innerDeco=s,this.nodeDOM=l}static create(e,t,o,s,r,i){let l=r.nodeViews[t.type.name],a,c=l&&l(t,r,()=>{if(!a)return i;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}=Ot.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 p=d;return d=gc(d,o,t),c?a=new Qm(e,t,o,s,d,u||null,p,c,r,i+1):t.isText?new Ko(e,t,o,s,d,p,r):new at(e,t,o,s,d,u||null,p,r,i+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=()=>E.empty)}return e}matchesNode(e,t,o){return this.dirty==we&&e.eq(this.node)&&Jo(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,r=e.composing?this.localCompositionInfo(e,t):null,i=r&&r.pos>-1?r:null,l=r&&r.pos<0,a=new tg(this,i&&i.node,e);sg(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,p)=>{a.syncToMarks(c.marks,o,e);let h;a.findNodeMatch(c,d,u,p)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(r.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,p,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==Lt)&&(i&&this.protectLocalComposition(e,i),fc(this.contentDOM,this.children,e),fn&&rg(this.dom))}localCompositionInfo(e,t){let{from:o,to:s}=e.state.selection;if(!(e.state.selection instanceof $)||o<t||s>t+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let i=r.nodeValue,l=ig(this.node.content,i,o-t,s-t);return l<0?null:{node:r,pos:l,text:i}}else return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:o,text:s}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let i=new Xm(this,r,t,s);e.input.compositionNodes.push(i),this.children=Er(this.children,o,o+s.length,e,i)}update(e,t,o,s){return this.dirty==Be||!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=we}updateOuterDeco(e){if(Jo(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=mc(this.dom,this.nodeDOM,Tr(this.outerDeco,this.node,t),Tr(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 pc(n,e,t,o,s){gc(o,e,n);let r=new at(void 0,n,e,t,o,o,o,s,0);return r.contentDOM&&r.updateChildren(s,0),r}class Ko extends at{constructor(e,t,o,s,r,i,l){super(e,t,o,s,r,null,i,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==Be||this.dirty!=we&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=we||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=we,!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),r=document.createTextNode(s.text);return new Ko(this.parent,s,this.outerDeco,this.innerDeco,r,r,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Be)}get domAtom(){return!1}isText(e){return this.node.text==e}}class hc extends Gn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==we&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Qm extends at{constructor(e,t,o,s,r,i,l,a,c,d){super(e,t,o,s,r,i,l,c,d),this.spec=a}update(e,t,o,s){if(this.dirty==Be)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,o);return r&&this.updateInner(e,t,o,s),r}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 fc(n,e,t){let o=n.firstChild,s=!1;for(let r=0;r<e.length;r++){let i=e[r],l=i.dom;if(l.parentNode==n){for(;l!=o;)o=yc(o),s=!0;o=o.nextSibling}else s=!0,n.insertBefore(l,o);if(i instanceof $t){let a=o?o.previousSibling:n.lastChild;fc(i.contentDOM,i.children,t),o=a?a.nextSibling:n.firstChild}}for(;o;)o=yc(o),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const Wn=function(n){n&&(this.nodeName=n)};Wn.prototype=Object.create(null);const zt=[new Wn];function Tr(n,e,t){if(n.length==0)return zt;let o=t?zt[0]:new Wn,s=[o];for(let r=0;r<n.length;r++){let i=n[r].type.attrs;if(i){i.nodeName&&s.push(o=new Wn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&s.length==1&&s.push(o=new Wn(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 mc(n,e,t,o){if(t==zt&&o==zt)return e;let s=e;for(let r=0;r<o.length;r++){let i=o[r],l=t[r];if(r){let a;l&&l.nodeName==i.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=zt[0]),s=a}eg(s,l||zt[0],i)}return s}function eg(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 r=0;r<o.length;r++)s.indexOf(o[r])==-1&&n.classList.remove(o[r]);for(let r=0;r<s.length;r++)o.indexOf(s[r])==-1&&n.classList.add(s[r]);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 gc(n,e,t){return mc(n,n,zt,Tr(e,t,n.nodeType!=1))}function Jo(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 yc(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class tg{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=ng(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,r=this.stack.length>>1,i=Math.min(r,e.length);for(;s<i&&(s==r-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<r;)this.destroyRest(),this.top.dirty=we,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[r])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=$t.create(this.top,e[r],t,o);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,o,s){let r=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,o))r=this.top.children.indexOf(i,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)){r=l;break}}return r<0?!1:(this.destroyBetween(this.index,r),this.index++,!0)}updateNodeAt(e,t,o,s,r){let i=this.top.children[s];return i.dirty==Be&&i.dom==i.contentDOM&&(i.dirty=Lt),i.update(e,t,o,r)?(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,r,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof at){let c=this.preMatch.matched.get(a);if(c!=null&&c!=r)return!1;let d=a.dom,u,p=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Be&&Jo(t,a.outerDeco));if(!p&&a.update(e,t,o,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!p&&(u=this.recreateWrapper(a,e,t,o,s,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Lt,u.updateChildren(s,i+1),u.dirty=we),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,s,r,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Jo(o,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=at.create(this.top,t,o,s,r,i);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,r){let i=at.create(this.top,e,t,o,s,r);i.contentDOM&&i.updateChildren(s,r+1),this.top.children.splice(this.index++,0,i),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 r=new uc(this.top,e,t,o);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof $t;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ko)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ce||re)&&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 hc(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 ng(n,e){let t=e,o=t.children.length,s=n.childCount,r=new Map,i=[];e:for(;s>0;){let l;for(;;)if(o){let c=t.children[o-1];if(c instanceof $t)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,r.set(l,s),i.push(l)}}return{index:s,matched:r,matches:i.reverse()}}function og(n,e){return n.type.side-e.type.side}function sg(n,e,t,o){let s=e.locals(n),r=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);o(d,s,e.forChild(r,d),c),r+=d.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let d,u;for(;i<s.length&&s[i].to==r;){let g=s[i++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(og);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let p,h;if(a)h=-1,p=a,a=null;else if(c<n.childCount)h=c,p=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=r&&l.splice(g--,1);for(;i<s.length&&s[i].from<=r&&s[i].to>r;)l.push(s[i++]);let f=r+p.nodeSize;if(p.isText){let g=f;i<s.length&&s[i].from<g&&(g=s[i].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<f&&(a=p.cut(g-r),p=p.cut(0,g-r),f=g,h=-1)}else for(;i<s.length&&s[i].to<f;)i++;let m=p.isInline&&!p.isLeaf?l.filter(g=>!g.inline):l.slice();o(p,m,e.forChild(r,p),h),r=f}}function rg(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 ig(n,e,t,o){for(let s=0,r=0;s<n.childCount&&r<=o;){let i=n.child(s++),l=r;if(r+=i.nodeSize,!i.isText)continue;let a=i.text;for(;s<n.childCount;){let c=n.child(s++);if(r+=c.nodeSize,!c.isText)break;a+=c.text}if(r>=t){if(r>=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 Er(n,e,t,o,s){let r=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,d=l+=a.size;c>=t||d<=e?r.push(a):(c<e&&r.push(a.slice(0,e-c,o)),s&&(r.push(s),s=void 0),d>t&&r.push(a.slice(t-c,a.size,o)))}return r}function Mr(n,e=null){let t=n.domSelectionRange(),o=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),r=s&&s.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=o.resolve(i),a,c;if(Uo(t)){for(a=i;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&R.isSelectable(u)&&s.parent&&!(u.isInline&&Im(t.focusNode,t.focusOffset,s.dom))){let p=s.posBefore;c=new R(i==p?l:o.resolve(p))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=i,p=i;for(let h=0;h<t.rangeCount;h++){let f=t.getRangeAt(h);u=Math.min(u,n.docView.posFromDOM(f.startContainer,f.startOffset,1)),p=Math.max(p,n.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(u<0)return null;[a,i]=p==n.state.selection.anchor?[p,u]:[u,p],l=o.resolve(i)}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&&!r?1:-1;c=Pr(n,d,l,u)}return c}function bc(n){return n.editable?n.hasFocus():Tc(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Ue(n,e=!1){let t=n.state.selection;if(wc(n,t),!!bc(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&re){let o=n.domSelectionRange(),s=n.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&Rt(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)ag(n);else{let{anchor:o,head:s}=t,r,i;Sc&&!(t instanceof $)&&(t.$from.parent.inlineContent||(r=vc(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=vc(n,t.to))),n.docView.setSelection(o,s,n,e),Sc&&(r&&xc(r),i&&xc(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&lg(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Sc=ce||re&&Xa<63;function vc(n,e){let{node:t,offset:o}=n.docView.domFromPos(e,0),s=o<t.childNodes.length?t.childNodes[o]:null,r=o?t.childNodes[o-1]:null;if(ce&&s&&s.contentEditable=="false")return Ar(s);if((!s||s.contentEditable=="false")&&(!r||r.contentEditable=="false")){if(s)return Ar(s);if(r)return Ar(r)}}function Ar(n){return n.contentEditable="true",ce&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function xc(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function lg(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(()=>{(!bc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function ag(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,ne(o)+1):t.setStart(o,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&fe&&it<=11&&(o.disabled=!0,o.disabled=!1)}function wc(n,e){if(e instanceof R){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Cc(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Cc(n)}function Cc(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Pr(n,e,t,o){return n.someProp("createSelectionBetween",s=>s(n,e,t))||$.between(e,t,o)}function kc(n){return n.editable&&!n.hasFocus()?!1:Tc(n)}function Tc(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 cg(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Rt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Or(n,e){let{$anchor:t,$head:o}=n.selection,s=e>0?t.max(o):t.min(o),r=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return r&&D.findFrom(r,e)}function ct(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Ec(n,e,t){let o=n.state.selection;if(o instanceof $)if(t.indexOf("s")>-1){let{$head:s}=o,r=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let i=n.state.doc.resolve(s.pos+r.nodeSize*(e<0?-1:1));return ct(n,new $(o.$anchor,i))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=Or(n.state,e);return s&&s instanceof R?ct(n,s):!1}else if(!(xe&&t.indexOf("m")>-1)){let s=o.$head,r=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!r||r.isText)return!1;let l=e<0?s.pos-r.nodeSize:s.pos;return r.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?R.isSelectable(r)?ct(n,new R(e<0?n.state.doc.resolve(s.pos-r.nodeSize):s)):Fn?ct(n,new $(n.state.doc.resolve(e<0?l:l+r.nodeSize))):!1:!1}}else return!1;else{if(o instanceof R&&o.node.isInline)return ct(n,new $(e>0?o.$to:o.$from));{let s=Or(n.state,e);return s?ct(n,s):!1}}}function Zo(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function jn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function gn(n,e){return e<0?dg(n):ug(n)}function dg(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s,r,i=!1;for(Me&&t.nodeType==1&&o<Zo(t)&&jn(t.childNodes[o],-1)&&(i=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(jn(l,-1))s=t,r=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if(Mc(t))break;{let l=t.previousSibling;for(;l&&jn(l,-1);)s=t.parentNode,r=ne(l),l=l.previousSibling;if(l)t=l,o=Zo(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}i?Nr(n,t,o):s&&Nr(n,s,r)}function ug(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s=Zo(t),r,i;for(;;)if(o<s){if(t.nodeType!=1)break;let l=t.childNodes[o];if(jn(l,1))r=t,i=++o;else break}else{if(Mc(t))break;{let l=t.nextSibling;for(;l&&jn(l,1);)r=l.parentNode,i=ne(l)+1,l=l.nextSibling;if(l)t=l,o=0,s=Zo(t);else{if(t=t.parentNode,t==n.dom)break;o=s=0}}}r&&Nr(n,r,i)}function Mc(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function pg(n,e){for(;n&&e==n.childNodes.length&&!Hn(n);)e=ne(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 hg(n,e){for(;n&&!e&&!Hn(n);)e=ne(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 Nr(n,e,t){if(e.nodeType!=3){let r,i;(i=pg(e,t))?(e=i,t=0):(r=hg(e,t))&&(e=r,t=r.nodeValue.length)}let o=n.domSelection();if(!o)return;if(Uo(o)){let r=document.createRange();r.setEnd(e,t),r.setStart(e,t),o.removeAllRanges(),o.addRange(r)}else o.extend&&o.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&Ue(n)},50)}function Ac(n,e){let t=n.state.doc.resolve(e);if(!(re||Lm)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let r=n.coordsAtPos(e-1),i=(r.top+r.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(r.left-s.left)>1)return r.left<s.left?"ltr":"rtl"}if(e<t.end()){let r=n.coordsAtPos(e+1),i=(r.top+r.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(r.left-s.left)>1)return r.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Pc(n,e,t){let o=n.state.selection;if(o instanceof $&&!o.empty||t.indexOf("s")>-1||xe&&t.indexOf("m")>-1)return!1;let{$from:s,$to:r}=o;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Or(n.state,e);if(i&&i instanceof R)return ct(n,i)}if(!s.parent.inlineContent){let i=e<0?s:r,l=o instanceof ye?D.near(i,e):D.findFrom(i,e);return l?ct(n,l):!1}return!1}function Oc(n,e){if(!(n.state.selection instanceof $))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 r=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(r&&!r.isText){let i=n.state.tr;return e<0?i.delete(t.pos-r.nodeSize,t.pos):i.delete(t.pos,t.pos+r.nodeSize),n.dispatch(i),!0}return!1}function Nc(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function fg(n){if(!ce||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;Nc(n,o,"true"),setTimeout(()=>Nc(n,o,"false"),20)}return!1}function mg(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function gg(n,e){let t=e.keyCode,o=mg(e);if(t==8||xe&&t==72&&o=="c")return Oc(n,-1)||gn(n,-1);if(t==46&&!e.shiftKey||xe&&t==68&&o=="c")return Oc(n,1)||gn(n,1);if(t==13||t==27)return!0;if(t==37||xe&&t==66&&o=="c"){let s=t==37?Ac(n,n.state.selection.from)=="ltr"?-1:1:-1;return Ec(n,s,o)||gn(n,s)}else if(t==39||xe&&t==70&&o=="c"){let s=t==39?Ac(n,n.state.selection.from)=="ltr"?1:-1:1;return Ec(n,s,o)||gn(n,s)}else{if(t==38||xe&&t==80&&o=="c")return Pc(n,-1,o)||gn(n,-1);if(t==40||xe&&t==78&&o=="c")return fg(n)||Pc(n,1,o)||gn(n,1);if(o==(xe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ic(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:o,openStart:s,openEnd:r}=e;for(;s>1&&r>1&&o.childCount==1&&o.firstChild.childCount==1;){s--,r--;let h=o.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),o=h.content}let i=n.someProp("clipboardSerializer")||Ot.fromSchema(n.state.schema),l=Hc(),a=l.createElement("div");a.appendChild(i.serializeFragment(o,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Bc[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let f=l.createElement(d[h]);for(;a.firstChild;)f.appendChild(a.firstChild);a.appendChild(f),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${r}${u?` -${u}`:""} ${JSON.stringify(t)}`);let p=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
806
-
807
- `);return{dom:a,text:p,slice:e}}function Rc(n,e,t,o,s){let r=s.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=e&&(o||r||!t);if(a){if(n.someProp("transformPastedText",p=>{e=p(e,r||o,n)}),r)return e?new A(E.from(n.state.schema.text(e.replace(/\r\n?/g,`
808
- `))),0,0):A.empty;let u=n.someProp("clipboardTextParser",p=>p(e,s,o,n));if(u)l=u;else{let p=s.marks(),{schema:h}=n.state,f=Ot.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=i.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(h.text(m,p)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),i=vg(t),Fn&&xg(i);let c=i&&i.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 p=i.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;i=p}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||on.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!yg.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=wg(zc(l,+d[1],+d[2]),d[4]);else if(l=A.maxOpen(bg(l.content,s),!0),l.openStart||l.openEnd){let u=0,p=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;p<l.openEnd&&!h.type.spec.isolating;p++,h=h.lastChild);l=zc(l,u,p)}return n.someProp("transformPasted",u=>{l=u(l,n)}),l}const yg=/^(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 bg(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)),r,i=[];if(n.forEach(l=>{if(!i)return;let a=s.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&r.length&&Lc(a,r,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=$c(i[i.length-1],r.length));let d=Dc(l,a);i.push(d),s=s.matchType(d.type),r=a}}),i)return E.from(i)}return n}function Dc(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,E.from(n));return n}function Lc(n,e,t,o,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let r=Lc(n,e,t,o.lastChild,s+1);if(r)return o.copy(o.content.replaceChild(o.childCount-1,r));if(o.contentMatchAt(o.childCount).matchType(s==n.length-1?t.type:n[s+1]))return o.copy(o.content.append(E.from(Dc(t,n,s+1))))}}function $c(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,$c(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(E.empty,!0);return n.copy(t.append(o))}function Ir(n,e,t,o,s,r){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(r=0),s<o-1&&(l=Ir(l,e,t,o,s+1,r)),s>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,r<=s).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(E.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function zc(n,e,t){return e<n.openStart&&(n=new A(Ir(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(Ir(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Bc={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 Vc=null;function Hc(){return Vc||(Vc=document.implementation.createHTMLDocument("title"))}let Rr=null;function Sg(n){let e=window.trustedTypes;return e?(Rr||(Rr=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Rr.createHTML(n)):n}function vg(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Hc().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(n),s;if((s=o&&Bc[o[1].toLowerCase()])&&(n=s.map(r=>"<"+r+">").join("")+n+s.map(r=>"</"+r+">").reverse().join("")),t.innerHTML=Sg(n),s)for(let r=0;r<s.length;r++)t=t.querySelector(s[r])||t;return t}function xg(n){let e=n.querySelectorAll(re?"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 wg(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:r,openEnd:i}=n;for(let l=o.length-2;l>=0;l-=2){let a=t.nodes[o[l]];if(!a||a.hasRequiredAttrs())break;s=E.from(a.create(o[l+1],s)),r++,i++}return new A(s,r,i)}const de={},ue={},Cg={touchstart:!0,touchmove:!0};class kg{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 Tg(n){for(let e in de){let t=de[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{Mg(n,o)&&!Lr(n,o)&&(n.editable||!(o.type in ue))&&t(n,o)},Cg[e]?{passive:!0}:void 0)}ce&&n.dom.addEventListener("input",()=>null),Dr(n)}function dt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Eg(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 Dr(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>Lr(n,o))})}function Lr(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function Mg(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 Ag(n,e){!Lr(n,e)&&de[e.type]&&(n.editable||!(e.type in ue))&&de[e.type](n,e)}ue.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!_c(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Ae&&re&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),fn&&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,Dt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",o=>o(n,t))||gg(n,t)?t.preventDefault():dt(n,"key")},ue.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},ue.keypress=(n,e)=>{let t=e;if(_c(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||xe&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let o=n.state.selection;if(!(o instanceof $)||!o.$from.sameParent(o.$to)){let s=String.fromCharCode(t.charCode);!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",r=>r(n,o.$from.pos,o.$to.pos,s))&&n.dispatch(n.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function Yo(n){return{left:n.clientX,top:n.clientY}}function Pg(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function $r(n,e,t,o,s){if(o==-1)return!1;let r=n.state.doc.resolve(o);for(let i=r.depth+1;i>0;i--)if(n.someProp(e,l=>i>r.depth?l(n,t,r.nodeAfter,r.before(i),s,!0):l(n,t,r.node(i),r.before(i),s,!1)))return!0;return!1}function yn(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 Og(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&R.isSelectable(o)?(yn(n,new R(t)),!0):!1}function Ng(n,e){if(e==-1)return!1;let t=n.state.selection,o,s;t instanceof R&&(o=t.node);let r=n.state.doc.resolve(e);for(let i=r.depth+1;i>0;i--){let l=i>r.depth?r.nodeAfter:r.node(i);if(R.isSelectable(l)){o&&t.$from.depth>0&&i>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?s=r.before(t.$from.depth):s=r.before(i);break}}return s!=null?(yn(n,R.create(n.state.doc,s)),!0):!1}function Ig(n,e,t,o,s){return $r(n,"handleClickOn",e,t,o)||n.someProp("handleClick",r=>r(n,e,o))||(s?Ng(n,t):Og(n,t))}function Rg(n,e,t,o){return $r(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",s=>s(n,e,o))}function Dg(n,e,t,o){return $r(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",s=>s(n,e,o))||Lg(n,t,o)}function Lg(n,e,t){if(t.button!=0)return!1;let o=n.state.doc;if(e==-1)return o.inlineContent?(yn(n,$.create(o,0,o.content.size)),!0):!1;let s=o.resolve(e);for(let r=s.depth+1;r>0;r--){let i=r>s.depth?s.nodeAfter:s.node(r),l=s.before(r);if(i.inlineContent)yn(n,$.create(o,l+1,l+1+i.content.size));else if(R.isSelectable(i))yn(n,R.create(o,l));else continue;return!0}}function zr(n){return Xo(n)}const Fc=xe?"metaKey":"ctrlKey";de.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=zr(n),s=Date.now(),r="singleClick";s-n.input.lastClick.time<500&&Pg(t,n.input.lastClick)&&!t[Fc]&&(n.input.lastClick.type=="singleClick"?r="doubleClick":n.input.lastClick.type=="doubleClick"&&(r="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:r};let i=n.posAtCoords(Yo(t));i&&(r=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new $g(n,i,t,!!o)):(r=="doubleClick"?Rg:Dg)(n,i.pos,i.inside,t)?t.preventDefault():dt(n,"pointer"))};class $g{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[Fc],this.allowDefault=o.shiftKey;let r,i;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),i=t.inside;else{let d=e.state.doc.resolve(t.pos);r=d.parent,i=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&&r.type.spec.draggable&&r.type.spec.selectable!==!1||c instanceof R&&c.from<=i&&c.to>i)&&(this.mightDrag={node:r,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Me&&!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)),dt(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(()=>Ue(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(Yo(e))),this.updateAllowDefault(e),this.allowDefault||!t?dt(this.view,"pointer"):Ig(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ce&&this.mightDrag&&!this.mightDrag.node.isAtom||re&&!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)?(yn(this.view,D.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):dt(this.view,"pointer")}move(e){this.updateAllowDefault(e),dt(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)}}de.touchstart=n=>{n.input.lastTouch=Date.now(),zr(n),dt(n,"pointer")},de.touchmove=n=>{n.input.lastTouch=Date.now(),dt(n,"pointer")},de.contextmenu=n=>zr(n);function _c(n,e){return n.composing?!0:ce&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const zg=Ae?5e3:-1;ue.compositionstart=ue.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof $&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Xo(n,!0),n.markCursor=null;else if(Xo(n,!e.selection.empty),Me&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let o=n.domSelectionRange();for(let s=o.focusNode,r=o.focusOffset;s&&s.nodeType==1&&r!=0;){let i=r<0?s.lastChild:s.childNodes[r-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else s=i,r=-1}}n.input.composing=!0}Gc(n,zg)},ue.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++,Gc(n,20))};function Gc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Xo(n),e))}function Wc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Vg());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Bg(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Om(e.focusNode,e.focusOffset),o=Nm(e.focusNode,e.focusOffset);if(t&&o&&t!=o){let s=o.pmViewDesc,r=n.domObserver.lastChangedTextNode;if(t==r||o==r)return r;if(!s||!s.isText(o.nodeValue))return o;if(n.input.compositionNode==o){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return o}}return t||o}function Vg(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Xo(n,e=!1){if(!(Ae&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Wc(n),e||n.docView&&n.docView.dirty){let t=Mr(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 Hg(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 qn=fe&&it<15||fn&&$m<604;de.copy=ue.cut=(n,e)=>{let t=e,o=n.state.selection,s=t.type=="cut";if(o.empty)return;let r=qn?null:t.clipboardData,i=o.content(),{dom:l,text:a}=Ic(n,i);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",a)):Hg(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Fg(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function _g(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?Un(n,o.value,null,s,e):Un(n,o.textContent,o.innerHTML,s,e)},50)}function Un(n,e,t,o,s){let r=Rc(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,r||A.empty)))return!0;if(!r)return!1;let i=Fg(r),l=i?n.state.tr.replaceSelectionWith(i,o):n.state.tr.replaceSelection(r);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function jc(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," "):""}ue.paste=(n,e)=>{let t=e;if(n.composing&&!Ae)return;let o=qn?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&Un(n,jc(o),o.getData("text/html"),s,t)?t.preventDefault():_g(n,t)};class qc{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const Uc=xe?"altKey":"ctrlKey";de.dragstart=(n,e)=>{let t=e,o=n.input.mouseDown;if(o&&o.done(),!t.dataTransfer)return;let s=n.state.selection,r=s.empty?null:n.posAtCoords(Yo(t)),i;if(!(r&&r.pos>=s.from&&r.pos<=(s instanceof R?s.to-1:s.to))){if(o&&o.mightDrag)i=R.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&&(i=R.create(n.state.doc,u.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:d}=Ic(n,l);(!t.dataTransfer.files.length||!re||Xa>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(qn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",qn||t.dataTransfer.setData("text/plain",c),n.dragging=new qc(d,!t[Uc],i)},de.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},ue.dragover=ue.dragenter=(n,e)=>e.preventDefault(),ue.drop=(n,e)=>{let t=e,o=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(Yo(t));if(!s)return;let r=n.state.doc.resolve(s.pos),i=o&&o.slice;i?n.someProp("transformPasted",f=>{i=f(i,n)}):i=Rc(n,jc(t.dataTransfer),qn?null:t.dataTransfer.getData("text/html"),!1,r);let l=!!(o&&!t[Uc]);if(n.someProp("handleDrop",f=>f(n,t,i||A.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?zf(n.state.doc,r.pos,i):r.pos;a==null&&(a=r.pos);let c=n.state.tr;if(l){let{node:f}=o;f?f.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,p=c.doc;if(u?c.replaceRangeWith(d,d,i.content.firstChild):c.replaceRange(d,d,i),c.doc.eq(p))return;let h=c.doc.resolve(d);if(u&&R.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new R(h));else{let f=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,C)=>f=C),c.setSelection(Pr(n,h,c.doc.resolve(f)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},de.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())&&Ue(n)},20))},de.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)},de.beforeinput=(n,e)=>{if(re&&Ae&&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",r=>r(n,Dt(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 ue)de[n]=ue[n];function Kn(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 Qo{constructor(e,t){this.toDOM=e,this.spec=t||Bt,this.side=this.spec.side||0}map(e,t,o,s){let{pos:r,deleted:i}=e.mapResult(t.from+s,this.side<0?-1:1);return i?null:new me(r-o,r-o,this)}valid(){return!0}eq(e){return this==e||e instanceof Qo&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Kn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ut{constructor(e,t){this.attrs=e,this.spec=t||Bt}map(e,t,o,s){let r=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-o,i=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-o;return r>=i?null:new me(r,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof ut&&Kn(this.attrs,e.attrs)&&Kn(this.spec,e.spec)}static is(e){return e.type instanceof ut}destroy(){}}class Br{constructor(e,t){this.attrs=e,this.spec=t||Bt}map(e,t,o,s){let r=e.mapResult(t.from+s,1);if(r.deleted)return null;let i=e.mapResult(t.to+s,-1);return i.deleted||i.pos<=r.pos?null:new me(r.pos-o,i.pos-o,this)}valid(e,t){let{index:o,offset:s}=e.content.findIndex(t.from),r;return s==t.from&&!(r=e.child(o)).isText&&s+r.nodeSize==t.to}eq(e){return this==e||e instanceof Br&&Kn(this.attrs,e.attrs)&&Kn(this.spec,e.spec)}destroy(){}}class me{constructor(e,t,o){this.from=e,this.to=t,this.type=o}copy(e,t){return new me(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 me(e,e,new Qo(t,o))}static inline(e,t,o,s){return new me(e,t,new ut(o,s))}static node(e,t,o,s){return new me(e,t,new Br(o,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof ut}get widget(){return this.type instanceof Qo}}const bn=[],Bt={};class q{constructor(e,t){this.local=e.length?e:bn,this.children=t.length?t:bn}static create(e,t){return t.length?es(t,e,0,Bt):ie}find(e,t,o){let s=[];return this.findInner(e??0,t??1e9,s,0,o),s}findInner(e,t,o,s,r){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!r||r(l.spec))&&o.push(l.copy(l.from+s,l.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,o,s+l,r)}}map(e,t,o){return this==ie||e.maps.length==0?this:this.mapInner(e,t,0,0,o||Bt)}mapInner(e,t,o,s,r){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,o,s);a&&a.type.valid(t,a)?(i||(i=[])).push(a):r.onRemove&&r.onRemove(this.local[l].spec)}return this.children.length?Gg(this.children,i||[],e,t,o,s,r):i?new q(i.sort(Vt),bn):ie}add(e,t){return t.length?this==ie?q.create(e,t):this.addInner(e,t,0):this}addInner(e,t,o){let s,r=0;e.forEach((l,a)=>{let c=a+o,d;if(d=Jc(t,l,c)){for(s||(s=this.children.slice());r<s.length&&s[r]<a;)r+=3;s[r]==a?s[r+2]=s[r+2].addInner(l,d,c+1):s.splice(r,0,a,a+l.nodeSize,es(d,l,c+1,Bt)),r+=3}});let i=Kc(r?Zc(t):t,-o);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new q(i.length?this.local.concat(i).sort(Vt):this.local,s||this.children)}remove(e){return e.length==0||this==ie?this:this.removeInner(e,0)}removeInner(e,t){let o=this.children,s=this.local;for(let r=0;r<o.length;r+=3){let i,l=o[r]+t,a=o[r+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(i||(i=[])).push(u));if(!i)continue;o==this.children&&(o=this.children.slice());let c=o[r+2].removeInner(i,l+1);c!=ie?o[r+2]=c:(o.splice(r,3),r-=3)}if(s.length){for(let r=0,i;r<e.length;r++)if(i=e[r])for(let l=0;l<s.length;l++)s[l].eq(i,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 q(s,o):ie}forChild(e,t){if(this==ie)return this;if(t.isLeaf)return q.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 r=e+1,i=r+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>r&&a.type instanceof ut){let c=Math.max(r,a.from)-r,d=Math.min(i,a.to)-r;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new q(s.sort(Vt),bn);return o?new pt([l,o]):l}return o||ie}eq(e){if(this==e)return!0;if(!(e instanceof q)||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 Vr(this.localsInner(e))}localsInner(e){if(this==ie)return bn;if(e.inlineContent||!this.local.some(ut.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof ut||t.push(this.local[o]);return t}forEachSet(e){e(this)}}q.empty=new q([],[]),q.removeOverlap=Vr;const ie=q.empty;class pt{constructor(e){this.members=e}map(e,t){const o=this.members.map(s=>s.map(e,t,Bt));return pt.from(o)}forChild(e,t){if(t.isLeaf)return q.empty;let o=[];for(let s=0;s<this.members.length;s++){let r=this.members[s].forChild(e,t);r!=ie&&(r instanceof pt?o=o.concat(r.members):o.push(r))}return pt.from(o)}eq(e){if(!(e instanceof pt)||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 r=this.members[s].localsInner(e);if(r.length)if(!t)t=r;else{o&&(t=t.slice(),o=!1);for(let i=0;i<r.length;i++)t.push(r[i])}}return t?Vr(o?t:t.sort(Vt)):bn}static from(e){switch(e.length){case 0:return ie;case 1:return e[0];default:return new pt(e.every(t=>t instanceof q)?e:e.reduce((t,o)=>t.concat(o instanceof q?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Gg(n,e,t,o,s,r,i){let l=n.slice();for(let c=0,d=r;c<t.maps.length;c++){let u=0;t.maps[c].forEach((p,h,f,m)=>{let g=m-f-(h-p);for(let b=0;b<l.length;b+=3){let C=l[b+1];if(C<0||p>C+d-u)continue;let y=l[b]+d-u;h>=y?l[b+1]=p<=y?-2:-1:p>=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]+r),u=d-s;if(u<0||u>=o.content.size){a=!0;continue}let p=t.map(n[c+1]+r,-1),h=p-s,{index:f,offset:m}=o.content.findIndex(u),g=o.maybeChild(f);if(g&&m==u&&m+g.nodeSize==h){let b=l[c+2].mapInner(t,g,d+1,n[c]+r+1,i);b!=ie?(l[c]=u,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Wg(l,n,e,t,s,r,i),d=es(c,o,0,i);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,p=0;u<d.children.length;u+=3){let h=d.children[u];for(;p<l.length&&l[p]<h;)p+=3;l.splice(p,0,d.children[u],d.children[u+1],d.children[u+2])}}return new q(e.sort(Vt),l)}function Kc(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 me(s.from+e,s.to+e,s.type))}return t}function Wg(n,e,t,o,s,r,i){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):i.onRemove&&i.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+r+1);return t}function Jc(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,s=null;for(let r=0,i;r<n.length;r++)(i=n[r])&&i.from>t&&i.to<o&&((s||(s=[])).push(i),n[r]=null);return s}function Zc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function es(n,e,t,o){let s=[],r=!1;e.forEach((l,a)=>{let c=Jc(n,l,a+t);if(c){r=!0;let d=es(c,l,t+a+1,o);d!=ie&&s.push(a,a+l.nodeSize,d)}});let i=Kc(r?Zc(n):n,-t).sort(Vt);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(o.onRemove&&o.onRemove(i[l].spec),i.splice(l--,1));return i.length||s.length?new q(i,s):ie}function Vt(n,e){return n.from-e.from||n.to-e.to}function Vr(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 r=e[s];if(r.from==o.from){r.to!=o.to&&(e==n&&(e=n.slice()),e[s]=r.copy(r.from,o.to),Yc(e,s+1,r.copy(o.to,r.to)));continue}else{r.from<o.to&&(e==n&&(e=n.slice()),e[t]=o.copy(o.from,r.from),Yc(e,s,o.copy(r.from,o.to)));break}}}return e}function Yc(n,e,t){for(;e<n.length&&Vt(t,n[e])>0;)e++;n.splice(e,0,t)}function Hr(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=ie&&e.push(o)}),n.cursorWrapper&&e.push(q.create(n.state.doc,[n.cursorWrapper.deco])),pt.from(e)}const jg={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},qg=fe&&it<=11;class Ug{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 Kg{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Ug,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]);fe&&it<=11&&o.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),qg&&(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,jg)),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(kc(this.view)){if(this.suppressingSelectionUpdates)return Ue(this.view);if(fe&&it<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Rt(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 r=e.focusNode;r;r=Vn(r))t.add(r);for(let r=e.anchorNode;r;r=Vn(r))if(t.has(r)){o=r;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)&&kc(e)&&!this.ignoreSelectionChange(o),r=-1,i=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(r=r<0?u.from:Math.min(u.from,r),i=i<0?u.to:Math.max(u.to,i),u.typeOver&&(l=!0))}if(Me&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,p]=d;u.parentNode&&u.parentNode.parentNode==p.parentNode?p.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let p of d){let h=p.parentNode;h&&h.nodeName=="LI"&&(!u||Yg(e,u)!=h)&&p.remove()}}}let c=null;r<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Uo(o)&&(c=Mr(e))&&c.eq(D.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ue(e),this.currentSelection.set(o),e.scrollToSelection()):(r>-1||s)&&(r>-1&&(e.docView.markDirty(r,i),Jg(e)),this.handleDOMChange(r,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(o)||Ue(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,r=e.nextSibling;if(fe&&it<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:p}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(r=p)}let i=s&&s.parentNode==e.target?ne(s)+1:0,l=o.localPosFromDOM(e.target,i,-1),a=r&&r.parentNode==e.target?ne(r):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 Xc=new WeakMap,Qc=!1;function Jg(n){if(!Xc.has(n)&&(Xc.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Me,Qc)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."),Qc=!0}}function ed(n,e){let t=e.startContainer,o=e.startOffset,s=e.endContainer,r=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Rt(i.node,i.offset,s,r)&&([t,o,s,r]=[s,r,t,o]),{anchorNode:t,anchorOffset:o,focusNode:s,focusOffset:r}}function Zg(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return ed(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?ed(n,t):null}function Yg(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 Xg(n,e,t){let{node:o,fromOffset:s,toOffset:r,from:i,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}],Uo(a)||c.push({node:a.focusNode,offset:a.focusOffset})),re&&n.input.lastKeyCode===8)for(let g=r;g>s;g--){let b=o.childNodes[g-1],C=b.pmViewDesc;if(b.nodeName=="BR"&&!C){r=g;break}if(!C||C.size)break}let u=n.state.doc,p=n.someProp("domParser")||on.fromSchema(n.state.schema),h=u.resolve(i),f=null,m=p.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:r,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Qg,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),f={anchor:g+i,head:b+i}}return{doc:m,sel:f,from:i,to:l}}function Qg(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ce&&/^(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||ce&&/^(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 e1=/^(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 t1(n,e,t,o,s){let r=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let k=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,M=Mr(n,k);if(M&&!n.state.selection.eq(M)){if(re&&Ae&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",O=>O(n,Dt(13,"Enter"))))return;let P=n.state.tr.setSelection(M);k=="pointer"?P.setMeta("pointer",!0):k=="key"&&P.scrollIntoView(),r&&P.setMeta("composition",r),n.dispatch(P)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Xg(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),p,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(p=n.state.selection.to,h="end"):(p=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let f=s1(u.content,c.doc.content,c.from,p,h);if(f&&n.input.domChangeCount++,(fn&&n.input.lastIOSEnter>Date.now()-225||Ae)&&s.some(k=>k.nodeType==1&&!e1.test(k.nodeName))&&(!f||f.endA>=f.endB)&&n.someProp("handleKeyDown",k=>k(n,Dt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!f)if(o&&a instanceof $&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))f={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let k=td(n,n.state.doc,c.sel);if(k&&!k.eq(n.state.selection)){let M=n.state.tr.setSelection(k);r&&M.setMeta("composition",r),n.dispatch(M)}}return}n.state.selection.from<n.state.selection.to&&f.start==f.endB&&n.state.selection instanceof $&&(f.start>n.state.selection.from&&f.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?f.start=n.state.selection.from:f.endA<n.state.selection.to&&f.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(f.endB+=n.state.selection.to-f.endA,f.endA=n.state.selection.to)),fe&&it<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>c.from&&c.doc.textBetween(f.start-c.from-1,f.start-c.from+1)=="  "&&(f.start--,f.endA--,f.endB--);let m=c.doc.resolveNoCache(f.start-c.from),g=c.doc.resolveNoCache(f.endB-c.from),b=d.resolve(f.start),C=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=f.endA,y;if((fn&&n.input.lastIOSEnter>Date.now()-225&&(!C||s.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!C&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(y=D.findFrom(c.doc.resolve(m.pos+1),1,!0))&&y.head==g.pos)&&n.someProp("handleKeyDown",k=>k(n,Dt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>f.start&&o1(d,f.start,f.endA,m,g)&&n.someProp("handleKeyDown",k=>k(n,Dt(8,"Backspace")))){Ae&&re&&n.domObserver.suppressSelectionUpdates();return}re&&Ae&&f.endB==f.start&&(n.input.lastAndroidDelete=Date.now()),Ae&&!C&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==f.endA&&(f.endB-=2,g=c.doc.resolveNoCache(f.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(k){return k(n,Dt(13,"Enter"))})},20));let S=f.start,v=f.endA,w,x,T;if(C){if(m.pos==g.pos)fe&&it<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ue(n),20)),w=n.state.tr.delete(S,v),x=d.resolve(f.start).marksAcross(d.resolve(f.endA));else if(f.endA==f.endB&&(T=n1(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start()))))w=n.state.tr,T.type=="add"?w.addMark(S,v,T.mark):w.removeMark(S,v,T.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let k=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",M=>M(n,S,v,k)))return;w=n.state.tr.insertText(k,S,v)}}if(w||(w=n.state.tr.replace(S,v,c.doc.slice(f.start-c.from,f.endB-c.from))),c.sel){let k=td(n,w.doc,c.sel);k&&!(re&&Ae&&n.composing&&k.empty&&(f.start!=f.endB||n.input.lastAndroidDelete<Date.now()-100)&&(k.head==S||k.head==w.mapping.map(v)-1)||fe&&k.empty&&k.head==S)&&w.setSelection(k)}x&&w.ensureMarks(x),r&&w.setMeta("composition",r),n.dispatch(w.scrollIntoView())}function td(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Pr(n,e.resolve(t.anchor),e.resolve(t.head))}function n1(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,s=t,r=o,i,l,a;for(let d=0;d<o.length;d++)s=o[d].removeFromSet(s);for(let d=0;d<t.length;d++)r=t[d].removeFromSet(r);if(s.length==1&&r.length==0)l=s[0],i="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&r.length==1)l=r[0],i="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(E.from(c).eq(n))return{mark:l,type:i}}function o1(n,e,t,o,s){if(t-e<=s.pos-o.pos||Fr(o,!0,!1)<s.pos)return!1;let r=n.resolve(e);if(!o.parent.isTextblock){let l=r.nodeAfter;return l!=null&&t==e+l.nodeSize}if(r.parentOffset<r.parent.content.size||!r.parent.isTextblock)return!1;let i=n.resolve(Fr(r,!0,!0));return!i.parent.isTextblock||i.pos>t||Fr(i,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(i.parent.content)}function Fr(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 r=n.node(o).maybeChild(n.indexAfter(o));for(;r&&!r.isLeaf;)r=r.firstChild,s++}return s}function s1(n,e,t,o,s){let r=n.findDiffStart(e,t);if(r==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,r-Math.min(i,l));o-=i+a-r}if(i<r&&n.size<e.size){let a=o<=r&&o>=i?r-o:0;r-=a,r&&r<e.size&&nd(e.textBetween(r-1,r+1))&&(r+=a?1:-1),l=r+(l-i),i=r}else if(l<r){let a=o<=r&&o>=l?r-o:0;r-=a,r&&r<n.size&&nd(n.textBetween(r-1,r+1))&&(r+=a?1:-1),i=r+(i-l),l=r}return{start:r,endA:i,endB:l}}function nd(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 r1{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 kg,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ld),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=rd(this),sd(this),this.nodeViews=id(this),this.docView=pc(this.state.doc,od(this),Hr(this),this.dom,this),this.domObserver=new Kg(this,(o,s,r,i)=>t1(this,o,s,r,i)),this.domObserver.start(),Tg(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&&Dr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ld),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,r=!1,i=!1;e.storedMarks&&this.composing&&(Wc(this),i=!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 h=id(this);l1(h,this.nodeViews)&&(this.nodeViews=h,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Dr(this),this.editable=rd(this),sd(this);let a=Hr(this),c=od(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=r||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(i=!0);let p=d=="preserve"&&i&&this.dom.style.overflowAnchor==null&&Vm(this);if(i){this.domObserver.stop();let h=u&&(fe||re)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&i1(s.selection,e.selection);if(u){let f=re?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Bg(this)),(r||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=pc(e.doc,c,a,this.dom,this)),f&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&cg(this))?Ue(this,h):(wc(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():p&&Hm(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof R){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Qa(this,t.getBoundingClientRect(),e)}else Qa(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 r=o.from+(this.state.doc.content.size-t.doc.content.size);(r>0&&this.state.doc.nodeAt(r))==o.node&&(s=r)}this.dragging=new qc(e.slice,e.move,s<0?void 0:R.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 i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(s=t?t(l):l))return s}let r=this.state.plugins;if(r)for(let i=0;i<r.length;i++){let l=r[i].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(fe){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&&Fm(this.dom),Ue(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 qm(this,e)}coordsAtPos(e,t=1){return rc(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 Ym(this,t||this.state,e)}pasteHTML(e,t){return Un(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Un(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Eg(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Hr(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Am())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ag(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?ce&&this.root.nodeType===11&&Rm(this.dom.ownerDocument)==this.dom&&Zg(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function od(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"),[me.node(0,n.state.doc.content.size,e)]}function sd(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:me.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function rd(n){return!n.someProp("editable",e=>e(n.state)===!1)}function i1(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 id(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 l1(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 ld(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 _r,Gr;if(typeof WeakMap<"u"){let n=new WeakMap;_r=e=>n.get(e),Gr=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;_r=o=>{for(let s=0;s<n.length;s+=2)if(n[s]==o)return n[s+1]},Gr=(o,s)=>(t==10&&(t=0),n[t++]=o,n[t++]=s)}var K=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 r=o+1,i=s+1;for(let l=1;r<this.width&&this.map[e+l]==t;l++)r++;for(let l=1;i<this.height&&this.map[e+this.width*l]==t;l++)i++;return{left:o,top:s,right:r,bottom:i}}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:r,bottom:i}=this.findCell(n);return e=="horiz"?(t<0?o==0:s==this.width)?null:this.map[r*this.width+(t<0?o-1:s)]:(t<0?r==0:i==this.height)?null:this.map[o+this.width*(t<0?r-1:i)]}rectBetween(n,e){const{left:t,right:o,top:s,bottom:r}=this.findCell(n),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(s,a),right:Math.max(o,l),bottom:Math.max(r,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 r=o*this.width+s,i=this.map[r];t[i]||(t[i]=!0,!(s==n.left&&s&&this.map[r-1]==i||o==n.top&&o&&this.map[r-this.width]==i)&&e.push(i))}return e}positionAt(n,e,t){for(let o=0,s=0;;o++){const r=s+t.child(o).nodeSize;if(o==n){let i=e+n*this.width;const l=(n+1)*this.width;for(;i<l&&this.map[i]<s;)i++;return i==l?r-1:this.map[i]}s=r}}static get(n){return _r(n)||Gr(n,a1(n))}};function a1(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=c1(n),t=n.childCount,o=[];let s=0,r=null;const i=[];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 f=0;;f++){for(;s<o.length&&o[s]!=0;)s++;if(f==u.childCount)break;const m=u.child(f),{colspan:g,rowspan:b,colwidth:C}=m.attrs;for(let y=0;y<b;y++){if(y+c>=t){(r||(r=[])).push({type:"overlong_rowspan",pos:d,n:b-y});break}const S=s+y*e;for(let v=0;v<g;v++){o[S+v]==0?o[S+v]=d:(r||(r=[])).push({type:"collision",row:c,pos:d,n:g-v});const w=C&&C[v];if(w){const x=(S+v)%e*2,T=i[x];T==null||T!=w&&i[x+1]==1?(i[x]=w,i[x+1]=1):T==w&&i[x+1]++}}}s+=g,d+=m.nodeSize}const p=(c+1)*e;let h=0;for(;s<p;)o[s++]==0&&h++;h&&(r||(r=[])).push({type:"missing",row:c,n:h}),d++}const l=new K(e,t,o,r);let a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(a=!0);return a&&d1(l,i,n),l}function c1(n){let e=-1,t=!1;for(let o=0;o<n.childCount;o++){const s=n.child(o);let r=0;if(t)for(let i=0;i<o;i++){const l=n.child(i);for(let a=0;a<l.childCount;a++){const c=l.child(a);i+c.attrs.rowspan>o&&(r+=c.attrs.colspan)}}for(let i=0;i<s.childCount;i++){const l=s.child(i);r+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=r:e!=r&&(e=Math.max(e,r))}return e}function d1(n,e,t){n.problems||(n.problems=[]);const o={};for(let s=0;s<n.map.length;s++){const r=n.map[s];if(o[r])continue;o[r]=!0;const i=t.nodeAt(r);if(!i)throw new RangeError(`No cell with offset ${r} found`);let l=null;const a=i.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=u1(a)))[c]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:l})}}function u1(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function ad(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),o=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(i=>Number(i)):null,s=Number(n.getAttribute("colspan")||1),r={colspan:s,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:o&&o.length==s?o:null};for(const i in e){const l=e[i].getFromDOM,a=l&&l(n);a!=null&&(r[i]=a)}return r}function cd(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 p1(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=>ad(o,e)}],toDOM(o){return["td",cd(o,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:o=>ad(o,e)}],toDOM(o){return["th",cd(o,e),0]}}}}function Ve(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 ht=new zn("selectingCells");function Jn(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 ts(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 Wr(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=Jn(e.$head)||h1(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function h1(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 jr(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function f1(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function qr(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function dd(n,e,t){const o=n.node(-1),s=K.get(o),r=n.start(-1),i=s.nextCell(n.pos-r,e,t);return i==null?null:n.node(0).resolve(r+i)}function Sn(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 X=class Ye extends D{constructor(e,t=e){const o=e.node(-1),s=K.get(o),r=e.start(-1),i=s.rectBetween(e.pos-r,t.pos-r),l=e.node(0),a=s.cellsInRect(i).filter(d=>d!=t.pos-r);a.unshift(t.pos-r);const c=a.map(d=>{const u=o.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const p=r+d+1;return new wa(l.resolve(p),l.resolve(p+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(jr(o)&&jr(s)&&qr(o,s)){const r=this.$anchorCell.node(-1)!=o.node(-1);return r&&this.isRowSelection()?Ye.rowSelection(o,s):r&&this.isColSelection()?Ye.colSelection(o,s):new Ye(o,s)}return $.between(o,s)}content(){const e=this.$anchorCell.node(-1),t=K.get(e),o=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),r={},i=[];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 p=t.map[d];if(r[p])continue;r[p]=!0;const h=t.findCell(p);let f=e.nodeAt(p);if(!f)throw RangeError(`No cell with offset ${p} found`);const m=s.left-h.left,g=h.right-s.right;if(m>0||g>0){let b=f.attrs;if(m>0&&(b=Sn(b,0,m)),g>0&&(b=Sn(b,b.colspan-g,g)),h.left<s.left){if(f=f.type.createAndFill(b),!f)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else f=f.type.create(b,f.content)}if(h.top<s.top||h.bottom>s.bottom){const b={...f.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?f=f.type.createAndFill(b):f=f.type.create(b,f.content)}c.push(f)}i.push(e.child(a).copy(E.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new A(E.from(l),1,1)}replace(e,t=A.empty){const o=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){const{$from:l,$to:a}=s[i],c=e.mapping.slice(o);e.replace(c.map(l.pos),c.map(a.pos),i?A.empty:t)}const r=D.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,t){this.replace(e,new A(E.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),o=K.get(t),s=this.$anchorCell.start(-1),r=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let i=0;i<r.length;i++)e(t.nodeAt(r[i]),s+r[i])}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=K.get(o),r=e.start(-1),i=s.findCell(e.pos-r),l=s.findCell(t.pos-r),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(r+s.map[i.left])),l.bottom<s.height&&(t=a.resolve(r+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(r+s.map[l.left])),i.bottom<s.height&&(e=a.resolve(r+s.map[s.width*(s.height-1)+i.right-1]))),new Ye(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=K.get(e),o=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-o),r=t.colCount(this.$headCell.pos-o);if(Math.min(s,r)>0)return!1;const i=s+this.$anchorCell.nodeAfter.attrs.colspan,l=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==t.width}eq(e){return e instanceof Ye&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const o=e.node(-1),s=K.get(o),r=e.start(-1),i=s.findCell(e.pos-r),l=s.findCell(t.pos-r),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(r+s.map[i.top*s.width])),l.right<s.width&&(t=a.resolve(r+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(r+s.map[l.top*s.width])),i.right<s.width&&(e=a.resolve(r+s.map[s.width*(i.top+1)-1]))),new Ye(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Ye(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){return new Ye(e.resolve(t),e.resolve(o))}getBookmark(){return new m1(this.$anchorCell.pos,this.$headCell.pos)}};X.prototype.visible=!1,D.jsonID("cell",X);var m1=class mu{constructor(e,t){this.anchor=e,this.head=t}map(e){return new mu(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&&qr(t,o)?new X(t,o):D.near(o,1)}};function g1(n){if(!(n.selection instanceof X))return null;const e=[];return n.selection.forEachCell((t,o)=>{e.push(me.node(o,o+t.nodeSize,{class:"selectedCell"}))}),q.create(n.doc,e)}function y1({$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 r=e.depth;r>=0&&!(e.before(r+1)>e.start(r));r--,o--);return t==o&&/row|table/.test(n.node(s).type.spec.tableRole)}function b1({$from:n,$to:e}){let t,o;for(let s=n.depth;s>0;s--){const r=n.node(s);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){t=r;break}}for(let s=e.depth;s>0;s--){const r=e.node(s);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){o=r;break}}return t!==o&&e.parentOffset===0}function S1(n,e,t){const o=(e||n).selection,s=(e||n).doc;let r,i;if(o instanceof R&&(i=o.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")r=X.create(s,o.from);else if(i=="row"){const l=s.resolve(o.from+1);r=X.rowSelection(l,l)}else if(!t){const l=K.get(o.node),a=o.from+1,c=a+l.map[l.width*l.height-1];r=X.create(s,a+1,c)}}else o instanceof $&&y1(o)?r=$.create(s,o.from):o instanceof $&&b1(o)&&(r=$.create(s,o.$from.start(),o.$from.end()));return r&&(e||(e=n.tr)).setSelection(r),e}var v1=new zn("fix-tables");function ud(n,e,t,o){const s=n.childCount,r=e.childCount;e:for(let i=0,l=0;i<r;i++){const a=e.child(i);for(let c=l,d=Math.min(s,i+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)?ud(n.child(l),a,t+1,o):a.nodesBetween(0,a.content.size,o,t+1),t+=a.nodeSize}}function x1(n,e){let t;const o=(s,r)=>{s.type.spec.tableRole=="table"&&(t=w1(n,s,r,t))};return e?e.doc!=n.doc&&ud(e.doc,n.doc,0,o):n.doc.descendants(o),t}function w1(n,e,t,o){const s=K.get(e);if(!s.problems)return o;o||(o=n.tr);const r=[];for(let a=0;a<s.height;a++)r.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 p=0;p<u.rowspan;p++)r[c.row+p]+=c.n;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,Sn(u,u.colspan-c.n,c.n))}else if(c.type=="missing")r[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;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 i,l;for(let a=0;a<r.length;a++)r[a]&&(i==null&&(i=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const d=e.child(a),u=c+d.nodeSize,p=r[a];if(p>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const f=[];for(let g=0;g<p;g++){const b=Ve(n.schema)[h].createAndFill();b&&f.push(b)}const m=(a==0||i==a-1)&&l==a?c+1:u-1;o.insert(o.mapping.map(m),f)}c=u}return o.setMeta(v1,{fixTables:!0})}function pd(n){const e=n.selection,t=Wr(n),o=t.node(-1),s=t.start(-1),r=K.get(o);return{...e instanceof X?r.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):r.findCell(t.pos-s),tableStart:s,map:r,table:o}}function C1(n){return function(e,t){if(!ts(e))return!1;if(t){const o=Ve(e.schema),s=pd(e),r=e.tr,i=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=i.map(a=>s.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==o.header_cell&&r.setNodeMarkup(s.tableStart+i[a],o.cell,l[a].attrs);if(r.steps.length==0)for(let a=0;a<i.length;a++)r.setNodeMarkup(s.tableStart+i[a],o.header_cell,l[a].attrs);t(r)}return!0}}function hd(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 r=e.table.nodeAt(o[s]);if(r&&r.type!==t.header_cell)return!1}return!0}function Ur(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?C1(n):function(t,o){if(!ts(t))return!1;if(o){const s=Ve(t.schema),r=pd(t),i=t.tr,l=hd("row",r,s),a=hd("column",r,s),d=(n==="column"?l:n==="row"?a:!1)?1:0,u=n=="column"?{left:0,top:d,right:1,bottom:r.map.height}:n=="row"?{left:d,top:0,right:r.map.width,bottom:1}:r,p=n=="column"?a?s.cell:s.header_cell:n=="row"?l?s.cell:s.header_cell:s.cell;r.map.cellsInRect(u).forEach(h=>{const f=h+r.tableStart,m=i.doc.nodeAt(f);m&&i.setNodeMarkup(f,p,m.attrs)}),o(i)}return!0}}Ur("row",{useDeprecatedLogic:!0}),Ur("column",{useDeprecatedLogic:!0}),Ur("cell",{useDeprecatedLogic:!0});function k1(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 r=n.node(-1).child(o),i=r.lastChild;if(i)return s-1-i.nodeSize;s-=r.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 r=t.child(o);if(r.childCount)return s+1;s+=r.nodeSize}}return null}function fd(n){return function(e,t){if(!ts(e))return!1;const o=k1(Wr(e),n);if(o==null)return!1;if(t){const s=e.doc.resolve(o);t(e.tr.setSelection($.between(s,f1(s))).scrollIntoView())}return!0}}function ns(n,e){const t=n.selection;if(!(t instanceof X))return!1;if(e){const o=n.tr,s=Ve(n.schema).cell.createAndFill().content;t.forEachCell((r,i)=>{r.content.eq(s)||o.replace(o.mapping.map(i+1),o.mapping.map(i+r.nodeSize-1),new A(s,0,0))}),o.docChanged&&e(o)}return!0}function T1(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),r=s.type.spec.tableRole,i=s.type.schema,l=[];if(r=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),u=a<e.childCount-1?0:Math.max(0,o-1);(d||u)&&(c=Kr(Ve(i).row,new A(c,d,u)).content),l.push(c)}else if(r=="cell"||r=="header_cell")l.push(t||o?Kr(Ve(i).row,new A(e,t,o)).content:e);else return null;return E1(i,l)}function E1(n,e){const t=[];for(let s=0;s<e.length;s++){const r=e[s];for(let i=r.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=r.child(i).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(E.empty),t[s]<o){const r=Ve(n).cell.createAndFill(),i=[];for(let l=t[s];l<o;l++)i.push(r);e[s]=e[s].append(E.from(i))}return{height:e.length,width:o,rows:e}}function Kr(n,e){const t=n.createAndFill();return new xa(t).replace(0,t.content.size,e).doc}function M1({width:n,height:e,rows:t},o,s){if(n!=o){const r=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=r[l]||0,u=0;d<o;u++){let p=a.child(u%a.childCount);d+p.attrs.colspan>o&&(p=p.type.createChecked(Sn(p.attrs,p.attrs.colspan,d+p.attrs.colspan-o),p.content)),c.push(p),d+=p.attrs.colspan;for(let h=1;h<p.attrs.rowspan;h++)r[l+h]=(r[l+h]||0)+p.attrs.colspan}i.push(E.from(c))}t=i,n=o}if(e!=s){const r=[];for(let i=0,l=0;i<s;i++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);i+u.attrs.rowspan>s&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,s-u.attrs.rowspan)},u.content)),a.push(u)}r.push(E.from(a))}t=r,e=s}return{width:n,height:e,rows:t}}function A1(n,e,t,o,s,r,i){const l=n.doc.type.schema,a=Ve(l);let c,d;if(s>e.width)for(let u=0,p=0;u<e.height;u++){const h=t.child(u);p+=h.nodeSize;const f=[];let m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<s;g++)f.push(m);n.insert(n.mapping.slice(i).map(p-1+o),f)}if(r>e.height){const u=[];for(let f=0,m=(e.height-1)*e.width;f<Math.max(e.width,s);f++){const g=f>=e.width?!1:t.nodeAt(e.map[m+f]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const p=a.row.create(null,E.from(u)),h=[];for(let f=e.height;f<r;f++)h.push(p);n.insert(n.mapping.slice(i).map(o+t.nodeSize-2),h)}return!!(c||d)}function md(n,e,t,o,s,r,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=s;c<r;c++){const d=i*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const p=t.nodeAt(u),{top:h,left:f}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(l).map(u+o),null,{...p.attrs,rowspan:i-h}),n.insert(n.mapping.slice(l).map(e.positionAt(i,f,t)),p.type.createAndFill({...p.attrs,rowspan:h+p.attrs.rowspan-i})),c+=p.attrs.colspan-1}}return a}function gd(n,e,t,o,s,r,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=s;c<r;c++){const d=c*e.width+i,u=e.map[d];if(e.map[d-1]==u){a=!0;const p=t.nodeAt(u),h=e.colCount(u),f=n.mapping.slice(l).map(u+o);n.setNodeMarkup(f,null,Sn(p.attrs,i-h,p.attrs.colspan-(i-h))),n.insert(f+p.nodeSize,p.type.createAndFill(Sn(p.attrs,0,i-h))),c+=p.attrs.rowspan-1}}return a}function yd(n,e,t,o,s){let r=t?n.doc.nodeAt(t-1):n.doc;if(!r)throw new Error("No table found");let i=K.get(r);const{top:l,left:a}=o,c=a+s.width,d=l+s.height,u=n.tr;let p=0;function h(){if(r=t?u.doc.nodeAt(t-1):u.doc,!r)throw new Error("No table found");i=K.get(r),p=u.mapping.maps.length}A1(u,i,r,t,c,d,p)&&h(),md(u,i,r,t,a,c,l,p)&&h(),md(u,i,r,t,a,c,d,p)&&h(),gd(u,i,r,t,l,d,a,p)&&h(),gd(u,i,r,t,l,d,c,p)&&h();for(let f=l;f<d;f++){const m=i.positionAt(f,a,r),g=i.positionAt(f,c,r);u.replace(u.mapping.slice(p).map(m+t),u.mapping.slice(p).map(g+t),new A(s.rows[f-l],0,0))}h(),u.setSelection(new X(u.doc.resolve(t+i.positionAt(l,a,r)),u.doc.resolve(t+i.positionAt(d-1,c-1,r)))),e(u)}var P1=Ua({ArrowLeft:rs("horiz",-1),ArrowRight:rs("horiz",1),ArrowUp:rs("vert",-1),ArrowDown:rs("vert",1),"Shift-ArrowLeft":is("horiz",-1),"Shift-ArrowRight":is("horiz",1),"Shift-ArrowUp":is("vert",-1),"Shift-ArrowDown":is("vert",1),Backspace:ns,"Mod-Backspace":ns,Delete:ns,"Mod-Delete":ns});function ss(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function rs(n,e){return(t,o,s)=>{if(!s)return!1;const r=t.selection;if(r instanceof X)return ss(t,o,D.near(r.$headCell,e));if(n!="horiz"&&!r.empty)return!1;const i=bd(s,n,e);if(i==null)return!1;if(n=="horiz")return ss(t,o,D.near(t.doc.resolve(r.head+e),e));{const l=t.doc.resolve(i),a=dd(l,n,e);let c;return a?c=D.near(a,1):e<0?c=D.near(t.doc.resolve(l.before(-1)),-1):c=D.near(t.doc.resolve(l.after(-1)),1),ss(t,o,c)}}}function is(n,e){return(t,o,s)=>{if(!s)return!1;const r=t.selection;let i;if(r instanceof X)i=r;else{const a=bd(s,n,e);if(a==null)return!1;i=new X(t.doc.resolve(a))}const l=dd(i.$headCell,n,e);return l?ss(t,o,new X(i.$anchorCell,l)):!1}}function O1(n,e){const t=n.state.doc,o=Jn(t.resolve(e));return o?(n.dispatch(n.state.tr.setSelection(new X(o))),!0):!1}function N1(n,e,t){if(!ts(n.state))return!1;let o=T1(t);const s=n.state.selection;if(s instanceof X){o||(o={width:1,height:1,rows:[E.from(Kr(Ve(n.state.schema).cell,t))]});const r=s.$anchorCell.node(-1),i=s.$anchorCell.start(-1),l=K.get(r).rectBetween(s.$anchorCell.pos-i,s.$headCell.pos-i);return o=M1(o,l.right-l.left,l.bottom-l.top),yd(n.state,n.dispatch,i,l,o),!0}else if(o){const r=Wr(n.state),i=r.start(-1);return yd(n.state,n.dispatch,i,K.get(r.node(-1)).findCell(r.pos-i),o),!0}else return!1}function I1(n,e){var t;if(e.ctrlKey||e.metaKey)return;const o=Sd(n,e.target);let s;if(e.shiftKey&&n.state.selection instanceof X)r(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(s=Jn(n.state.selection.$anchor))!=null&&((t=Jr(n,e))==null?void 0:t.pos)!=s.pos)r(s,e),e.preventDefault();else if(!o)return;function r(a,c){let d=Jr(n,c);const u=ht.getState(n.state)==null;if(!d||!qr(a,d))if(u)d=a;else return;const p=new X(a,d);if(u||!n.state.selection.eq(p)){const h=n.state.tr.setSelection(p);u&&h.setMeta(ht,a.pos),n.dispatch(h)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",l),ht.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(ht,-1))}function l(a){const c=a,d=ht.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(Sd(n,c.target)!=o&&(u=Jr(n,e),!u))return i();u&&r(u,c)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",l)}function bd(n,e,t){if(!(n.state.selection instanceof $))return null;const{$head:o}=n.state.selection;for(let s=o.depth-1;s>=0;s--){const r=o.node(s);if((t<0?o.index(s):o.indexAfter(s))!=(t<0?0:r.childCount))return null;if(r.type.spec.tableRole=="cell"||r.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 Sd(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Jr(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Jn(n.state.doc.resolve(t.pos)):null}var R1=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")),Zr(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,Zr(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Zr(n,e,t,o,s,r){var i;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let u=0,p=0;u<d.childCount;u++){const{colspan:h,colwidth:f}=d.child(u).attrs;for(let m=0;m<h;m++,p++){const g=s==p?r:f&&f[m],b=g?g+"px":"";if(l+=g||o,g||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const C=document.createElement("col");C.style.width=b,e.appendChild(C)}}}for(;c;){const u=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=u}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var be=new zn("tableColumnResizing");function D1({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:o=R1,lastColumnResizable:s=!0}={}){const r=new pn({key:be,state:{init(i,l){var a,c;const d=(c=(a=r.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,u=Ve(l.schema).table.name;return o&&d&&(d[u]=(p,h)=>new o(p,t,h)),new L1(-1,!1)},apply(i,l){return l.apply(i)}},props:{attributes:i=>{const l=be.getState(i);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(i,l)=>{$1(i,l,n,s)},mouseleave:i=>{z1(i)},mousedown:(i,l)=>{B1(i,l,e,t)}},decorations:i=>{const l=be.getState(i);if(l&&l.activeHandle>-1)return G1(i,l.activeHandle)},nodeViews:{}}});return r}var L1=class ms{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,o=e.getMeta(be);if(o&&o.setHandle!=null)return new ms(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new ms(t.activeHandle,o.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);return jr(e.doc.resolve(s))||(s=-1),new ms(s,t.dragging)}return t}};function $1(n,e,t,o){const s=be.getState(n.state);if(s&&!s.dragging){const r=H1(e.target);let i=-1;if(r){const{left:l,right:a}=r.getBoundingClientRect();e.clientX-l<=t?i=vd(n,e,"left",t):a-e.clientX<=t&&(i=vd(n,e,"right",t))}if(i!=s.activeHandle){if(!o&&i!==-1){const l=n.state.doc.resolve(i),a=l.node(-1),c=K.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}wd(n,i)}}}function z1(n){const e=be.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&wd(n,-1)}function B1(n,e,t,o){var s;const r=(s=n.dom.ownerDocument.defaultView)!=null?s:window,i=be.getState(n.state);if(!i||i.activeHandle==-1||i.dragging)return!1;const l=n.state.doc.nodeAt(i.activeHandle),a=V1(n,i.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(be,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){r.removeEventListener("mouseup",c),r.removeEventListener("mousemove",d);const p=be.getState(n.state);p!=null&&p.dragging&&(F1(n,p.activeHandle,xd(p.dragging,u,t)),n.dispatch(n.state.tr.setMeta(be,{setDragging:null})))}function d(u){if(!u.which)return c(u);const p=be.getState(n.state);if(p&&p.dragging){const h=xd(p.dragging,u,t);Cd(n,p.activeHandle,h,o)}}return Cd(n,i.activeHandle,a,o),r.addEventListener("mouseup",c),r.addEventListener("mousemove",d),e.preventDefault(),!0}function V1(n,e,{colspan:t,colwidth:o}){const s=o&&o[o.length-1];if(s)return s;const r=n.domAtPos(e);let l=r.node.childNodes[r.offset].offsetWidth,a=t;if(o)for(let c=0;c<t;c++)o[c]&&(l-=o[c],a--);return l/a}function H1(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function vd(n,e,t,o){const s=t=="right"?-o:o,r=n.posAtCoords({left:e.clientX+s,top:e.clientY});if(!r)return-1;const{pos:i}=r,l=Jn(n.state.doc.resolve(i));if(!l)return-1;if(t=="right")return l.pos;const a=K.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 xd(n,e,t){const o=e.clientX-n.startX;return Math.max(t,n.startWidth+o)}function wd(n,e){n.dispatch(n.state.tr.setMeta(be,{setHandle:e}))}function F1(n,e,t){const o=n.state.doc.resolve(e),s=o.node(-1),r=K.get(s),i=o.start(-1),l=r.colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<r.height;c++){const d=c*r.width+l;if(c&&r.map[d]==r.map[d-r.width])continue;const u=r.map[d],p=s.nodeAt(u).attrs,h=p.colspan==1?0:l-r.colCount(u);if(p.colwidth&&p.colwidth[h]==t)continue;const f=p.colwidth?p.colwidth.slice():_1(p.colspan);f[h]=t,a.setNodeMarkup(i+u,null,{...p,colwidth:f})}a.docChanged&&n.dispatch(a)}function Cd(n,e,t,o){const s=n.state.doc.resolve(e),r=s.node(-1),i=s.start(-1),l=K.get(r).colCount(s.pos-i)+s.nodeAfter.attrs.colspan-1;let a=n.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Zr(r,a.firstChild,a,o,l,t)}function _1(n){return Array(n).fill(0)}function G1(n,e){var t;const o=[],s=n.doc.resolve(e),r=s.node(-1);if(!r)return q.empty;const i=K.get(r),l=s.start(-1),a=i.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){const d=a+c*i.width;if((a==i.width-1||i.map[d]!=i.map[d+1])&&(c==0||i.map[d]!=i.map[d-i.width])){const u=i.map[d],p=l+u+r.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(t=be.getState(n))!=null&&t.dragging&&o.push(me.node(l+u,l+u+r.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),o.push(me.widget(p,h))}}return q.create(n.doc,o)}function W1({allowTableNodeSelection:n=!1}={}){return new pn({key:ht,state:{init(){return null},apply(e,t){const o=e.getMeta(ht);if(o!=null)return o==-1?null:o;if(t==null||!e.docChanged)return t;const{deleted:s,pos:r}=e.mapping.mapResult(t);return s?null:r}},props:{decorations:g1,handleDOMEvents:{mousedown:I1},createSelectionBetween(e){return ht.getState(e.state)!=null?e.state.selection:null},handleTripleClick:O1,handleKeyDown:P1,handlePaste:N1},appendTransaction(e,t,o){return S1(o,x1(o,t),n)}})}const Zn=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},kd="data-gs-mrk-fs",Td="data-gs-ib",ls="data-gs-ifrg",Ke="attrs",Ed={[Ke]:{default:"{}"}},Je={[Ke]:{default:{}}},Md=n=>({[Ke]:JSON.stringify(Zn(n))}),Ze=n=>({attrs:Zn(n)}),Yn=n=>e=>[n,e.attrs.attrs,0],ft=n=>n.attrs[Ke]?JSON.parse(n.attrs[Ke]):{},j1={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${ls}]`,getAttrs:Ze}],toDOM:()=>["span",{[ls]:""},0]},div:{group:"block",content:"inline*",attrs:Je,parseDOM:[{tag:"div",getAttrs:Ze}],toDOM:Yn("div")},paragraph:{group:"block",content:"inline*",attrs:Je,parseDOM:[{tag:"p",getAttrs:Ze}],toDOM:Yn("p")},orderedList:{group:"block",content:"listItem+",attrs:Je,parseDOM:[{tag:"ol",getAttrs:Ze}],toDOM:Yn("ol")},bulletList:{group:"block",content:"listItem+",attrs:Je,parseDOM:[{tag:"ul",getAttrs:Ze}],toDOM:Yn("ul")},listItem:{content:"block*",group:"block",attrs:Je,parseDOM:[{tag:"li",getAttrs:Ze}],toDOM:Yn("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:Je,parseDOM:[{tag:"pre",getAttrs:Ze}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:Je,parseDOM:[{tag:"img[src]",getAttrs:Ze}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${Td}]`}],toDOM(){return["br",{[Td]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:Je,parseDOM:[{tag:"br",getAttrs:Ze}],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:Zn(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...p1({tableGroup:"block",cellContent:"block+",cellAttributes:{[Ke]:{default:Je[Ke].default,getFromDOM:Zn,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:Zn(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},Xn=(n,e)=>({attrs:Ed,parseDOM:n.map(t=>({tag:t,getAttrs:Md})),toDOM:e}),q1={strong:Xn(["strong","b"],n=>["b",ft(n)]),link:Xn(["a"],n=>["a",ft(n),0]),em:Xn(["em","i"],n=>["em",ft(n)]),underline:Xn(["u"],n=>["u",ft(n),0]),strikethrough:Xn(["s"],n=>["s",ft(n),0]),font_size:{attrs:{...Ed,size:{default:null}},parseDOM:[{tag:`span[${kd}]`,getAttrs:n=>({...Md(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...ft(n),[kd]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},Ad=new pf({nodes:j1,marks:q1}),as=new WeakMap,Yr=new WeakMap,U1=(n,e)=>{as.set(n,e),Yr.set(e,n)},K1=(n,e)=>{as.delete(n),Yr.delete(e)},Xr=n=>as.get(n),J1=n=>Yr.get(n),Pd=n=>{var t;const e=J1(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},Z1=n=>n.dispatchEvent(new CustomEvent("input"));function Y1(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(ls)){if(t.getAttribute("style")){t.removeAttribute(ls);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 X1(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"),r=d=>d.isChildOf("text"),i=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{o(d)&&s(d)&&!i(d)&&l(d,u)},c=(d,u)=>{if(o(d)&&!s(d)&&r(d)){const p=d.parents().find(h=>h.isInstanceOf("text"));p&&(l(p,u),setTimeout(()=>n.select(p),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Q1=(n,e)=>{const t=e0(n);return t&&c0(t)?t0(n,e):t?$a(()=>({type:n.schema.nodes.div}))(n,e):!1};function e0(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 t0(n,e){const{selection:t,schema:o,tr:s}=n;s.split(t.from,1);const r=t.from+1,i=s.doc.nodeAt(r),l={...i.attrs.attrs,id:void 0},a=i.textContent.length>0,c=i.textContent.length||0,d=i.textContent||" ",u=o.text(d),p=o.nodes.div.create(l,a?u:[],[]);return s.replaceRangeWith(r,r+c+2,p),s.setSelection($.create(s.doc,r+1)),e==null||e(s.scrollIntoView()),!0}function n0(n,e,t){const{state:o,dispatch:s}=n,{selection:r,tr:i}=o,l=(a,c,d)=>{const u={};return a.split(";").forEach(p=>{const[h,f]=p.split(":").map(m=>m.trim());h&&(u[h]=f)}),u[c]=d,Object.entries(u).map(([p,h])=>`${p}: ${h}`).join("; ")};if(!r.empty||t)i.doc.nodesBetween(r.from,r.to,(a,c)=>{var d,u;if(a.type===o.schema.nodes.image){const p=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);i.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:p}})}else if(a.type.isBlock){const p=l(((u=a.attrs.attrs)==null?void 0:u.style)||"","text-align",e);Od(a)?i.setBlockType(r.from,void 0,o.schema.nodes.div,{attrs:{style:p}}):i.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:p}})}});else{const a=o.doc.resolve(r.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);i.setNodeMarkup(c,void 0,{...d.attrs,style:u})}}i.docChanged&&s(i.scrollIntoView())}const Qn=(n,e)=>{const{from:t,to:o}=n.selection;let s=!1;return n.doc.nodesBetween(t,o,r=>{if(s)return!1;r.marks.some(i=>i.type===e)&&(s=!0)}),s};function o0(n,e,t="_blank"){const{state:o,dispatch:s}=n,{schema:r,selection:i,tr:l}=o,a=r.marks.link;try{const c=a.create({[Ke]:JSON.stringify({href:e,target:t})});l.addMark(i.from,i.to,c),s(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function s0(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:r}=t;if(s.empty)return;const i=t.schema.marks.font_size;if(!i){console.error("Font size mark is not defined in the schema.");return}r.addMark(s.from,s.to,i.create({size:e})),o(r.scrollIntoView())}const Ht=(n,e)=>{const{doc:t,selection:o}=n.state,s=t.resolve(o.from);for(let r=s.depth;r>0;r--){const i=s.node(r);if(e(i))return{pos:r>0?s.before(r):0,start:s.start(r),depth:r,node:i}}},r0=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 i0(...n){return(e,t)=>{const o=i=>{e=e.apply(i),t==null||t(i)},s=n.pop();return n.reduce((i,l)=>i||l(e,o),!1)&&s!==void 0&&s(e,t)}}const l0=(n,e)=>{const{state:t,dispatch:o}=n;if(e!=null&&e.event){const{event:s}=e,r=n.posAtCoords({left:s.clientX,top:s.clientY});r!=null&&r.pos&&o(t.tr.setSelection($.create(t.doc,r.pos)))}else za(t,o);setTimeout(()=>setTimeout(()=>n.focus()))},Qr=n=>n.isBlock,Od=n=>n.type.name==="inlineFragment",a0=n=>Qr(n)&&!Od(n),Nd=n=>n.type.name==="bulletList",Id=n=>n.type.name==="orderedList",c0=n=>n.type.name==="heading",d0=n=>Nd(n)||Id(n),Rd=(n,e)=>{var r,i;const t=(r=Ht(n,l=>l.type===e))==null?void 0:r.node,o=n.state.schema.nodes.listItem;let s;return t?s=br(o):(i=Ht(n,d0))!=null&&i.node?s=i0(br(o),Ka(e)):s=Ka(e),s(n.state,n.dispatch)},Dd=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(o=>o.type.name===e)},u0=n=>{var i;const{view:e,prop:t,editor:o,propCSS:s}=n,r=(i=Ht(e,a0))==null?void 0:i.node;if(r){const l=r.attrs.attrs||{},a=r0(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""},p0=n=>{const{view:e,prop:t,markName:o,editor:s,propCSS:r}=n,i=Dd(e,o);if(i){const l=i.attrs;if(l[t])return l[t];if(l[Ke]){const a=ft(i).id;if(a){const c=s.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[r]||""}}}return""},Ld=(n,e)=>{const{dispatch:t}=n,{nodes:o,marks:s}=n.state.schema;return{text:{selected:()=>{const{selection:r,doc:i}=n.state;return i.textBetween(r.from,r.to," ")},replace:(r,i={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(r));i.select&&(c=c.setSelection($.create(c.doc,a,a+r.length))),t==null||t(c)}},bold:{toggle:()=>Nt(s.strong)(n.state,t),isActive:()=>Qn(n.state,s.strong)},italic:{toggle:()=>Nt(s.em)(n.state,t),isActive:()=>Qn(n.state,s.em)},underline:{toggle:()=>Nt(s.underline)(n.state,t),isActive:()=>Qn(n.state,s.underline)},strikethrough:{toggle:()=>Nt(s.strikethrough)(n.state,t),isActive:()=>Qn(n.state,s.strikethrough)},link:{get:()=>{const r=Pd(n);if(r!=null&&r.is("link"))return r.getAttributes();{const i=Dd(n,"link");return i?ft(i):{}}},toggle:()=>Nt(s.link)(n.state,t),isActive:()=>Qn(n.state,s.link),create:r=>{const i=Pd(n);i!=null&&i.is("link")?(i.addAttributes({href:r.url,target:r.target}),n.focus()):o0(n,r.url,r.target)}},alignText:{get:()=>u0({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:r=>n0(n,r.value,!0)},fontSize:{get:()=>p0({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:r=>s0(n,r.value)},image:{open(){const r="assetLayout",{state:i,dispatch:l}=n,{selection:a,doc:c}=i,d=c.textBetween(a.from,a.to," "),u={id:r,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:p=>{const h={alt:d,src:p.asset.getSrc()};l(i.tr.replaceSelectionWith(o.image.createAndFill({attrs:h})))}}};e.runCommand(_.layoutToggle,u)}},heading:{get:()=>{var i;const r=(i=Ht(n,Qr))==null?void 0:i.node;return`${(r==null?void 0:r.attrs.level)||""}`},set:({value:r})=>{var a;const{state:i}=n,l=(a=Ht(n,Qr))==null?void 0:a.node;rm(i.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:r?parseInt(r,10):0})(i,t)}},listBullet:{isActive:()=>{var r;return!!((r=Ht(n,Nd))!=null&&r.node)},toggle:()=>Rd(n,o.bulletList)},listOrdered:{isActive:()=>{var r;return!!((r=Ht(n,Id))!=null&&r.node)},toggle:()=>Rd(n,o.orderedList)}}};class mt{constructor(e,t,o={}){this.match=e,this.match=e,this.handler=typeof t=="string"?h0(t):t,this.undoable=o.undoable!==!1,this.inCode=o.inCode||!1}}function h0(n){return function(e,t,o,s){let r=n;if(t[1]){let i=t[0].lastIndexOf(t[1]);r+=t[0].slice(i+t[1].length),o+=i;let l=o-s;l>0&&(r=t[0].slice(i-l,i)+r,o=s)}return e.tr.insertText(r,o,s)}}const f0=500;function m0({rules:n}){let e=new pn({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,r){return $d(t,o,s,r,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:o}=t.state.selection;o&&$d(t,o.pos,o.pos,"",n,e)})}}},isInputRules:!0});return e}function $d(n,e,t,o,s,r){if(n.composing)return!1;let i=n.state,l=i.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-f0),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),p=u&&d.handler(i,u,e-(u[0].length-o.length),t);if(p)return d.undoable&&p.setMeta(r,{transform:p,from:e,to:t,text:o}),n.dispatch(p),!0}return!1}const g0=new mt(/--$/,"—"),y0=new mt(/\.\.\.$/,"…"),b0=new mt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),S0=new mt(/"$/,"”"),v0=new mt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),x0=new mt(/'$/,"’"),w0=[b0,S0,v0,x0];function ei(n,e,t=null,o){return new mt(n,(s,r,i,l)=>{let a=t instanceof Function?t(r):t,c=s.tr.delete(i,l),d=c.doc.resolve(i),u=d.blockRange(),p=u&&ha(u,e,a);if(!p)return null;c.wrap(u,p);let h=c.doc.resolve(i-1).nodeBefore;return h&&h.type==e&&Fo(c.doc,i-1)&&(!o||o(r,h))&&c.join(i-1),c})}function zd(n,e,t=null){return new mt(n,(o,s,r,i)=>{let l=o.doc.resolve(r),a=t instanceof Function?t(s):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?o.tr.delete(r,i).setBlockType(r,r,e,a):null})}function C0(n){return ei(/^\s*>\s$/,n)}function k0(n){return ei(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function T0(n){return ei(/^\s*([-+*])\s$/,n)}function E0(n){return zd(/^```$/,n)}function M0(n,e){return zd(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function A0(n){const e=w0.concat(y0,g0);let t;return(t=n.nodes.blockquote)&&e.push(C0(t)),(t=n.nodes.orderedList)&&e.push(k0(t)),(t=n.nodes.bulletList)&&e.push(T0(t)),(t=n.nodes.codeBlock)&&e.push(E0(t)),(t=n.nodes.heading)&&e.push(M0(t,6)),m0({rules:e})}const P0="rteProseMirror",O0=F.free,Pe="rte:selectionchange",Ce={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>'},N0=(n,e)=>{var a;const{editor:t,el:o}=n,s=as.get(o),r=Ld(s,t),i={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:Ce.bold,size:"s",type:"button",editorEvents:{[Pe]:({setState:c})=>{c({active:r.bold.isActive()})}},onClick:({setState:c})=>{r.bold.toggle(),c({active:r.bold.isActive()})}},italic:{id:"italic",icon:Ce.italic,size:"s",type:"button",editorEvents:{[Pe]:({setState:c})=>{c({active:r.italic.isActive()})}},onClick:({setState:c})=>{r.italic.toggle(),c({active:r.italic.isActive()})}},underline:{id:"underline",icon:Ce.underline,size:"s",type:"button",editorEvents:{[Pe]:({setState:c})=>{c({active:r.underline.isActive()})}},onClick:({setState:c})=>{r.underline.toggle(),c({active:r.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:Ce.strikethrough,size:"s",type:"button",editorEvents:{[Pe]:({setState:c})=>{c({active:r.strikethrough.isActive()})}},onClick:({setState:c})=>{r.strikethrough.toggle(),c({active:r.strikethrough.isActive()})}},image:{id:"image",icon:Ce.image,size:"s",type:"button",onClick:()=>r.image.open()},link:{id:"link",icon:Ce.link,size:"s",type:"button",editorEvents:{[Pe]:({setState:c})=>{c({active:r.link.isActive(),disabled:s.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:u,y:p,width:h,height:f}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(_.layoutRemove,{id:m}),b=r.link.get(),C={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:u,y:p,w:h,h:f},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:y=>{y.preventDefault();const S=new FormData(y.currentTarget);r.link.create({url:S.get("url"),target:S.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(b==null?void 0:b.href)||"",onChange:({value:y,setState:S})=>S({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:S})=>S({value:y})},{type:"row",style:{gap:10,justifyContent:"end"},children:[r.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{r.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(_.layoutToggle,C)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:Ce.alignTextLeft},{id:"center",icon:Ce.alignTextCenter},{id:"right",icon:Ce.alignTextRight},{id:"justify",icon:Ce.alignTextJustify}],editorEvents:{[Pe]:({setState:c})=>{c({value:r.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:Ce.listBullet,size:"s",type:"button",editorEvents:{[Pe]:({setState:c})=>{c({active:r.listBullet.isActive()})}},onClick:({setState:c})=>{r.listBullet.toggle(),c({active:r.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:Ce.listOrdered,size:"s",type:"button",editorEvents:{[Pe]:({setState:c})=>{c({active:r.listOrdered.isActive()})}},onClick:({setState:c})=>{r.listOrdered.toggle(),c({active:r.listOrdered.isActive()})}},heading:{id:"heading",type:"selectField",size:"s",value:"",emptyState:"Heading",options:[{id:"",label:"Normal"},{id:"1",label:"Heading 1"},{id:"2",label:"Heading 2"},{id:"3",label:"Heading 3"},{id:"4",label:"Heading 4"},{id:"5",label:"Heading 5"},{id:"6",label:"Heading 6"}],editorEvents:{[Pe]:({setState:c})=>{c({value:r.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.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:{[Pe]:({setState:c})=>{c({value:r.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.fontSize.set({value:c}),s.focus()}}},l=[i.bold,i.italic,i.underline,i.strikethrough,i.image,i.link,i.listBullet,i.listOrdered,i.alignText,i.heading,i.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:r,layouts:i,proseMirror:{view:s},items:l}))||l};class I0{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;Ld(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=""}}const R0=G(function(n,e={}){const t={plugins:i=>i.plugins,...e},o=(i,l)=>{var f,m;const a=((f=t.schema)==null?void 0:f.call(t,{editor:n,schema:Ad}))||Ad,{nodes:c,marks:d}=a,u=on.fromSchema(a).parse(i),p=un.create({doc:u,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,Plugin:pn,plugins:[D1(),W1(),A0(a),gm(),yr({Tab:fd(1),"Shift-Tab":fd(-1)}),yr({Enter:Bn(La,km(c.listItem),Q1),"Shift-Enter":Bn(Da,(g,b)=>(b&&b(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":qa,"Mod-y":fr,"Mod-Shift-z":fr,"Mod-b":Nt(d.strong),"Mod-i":Nt(d.em),"Shift-Tab":br(c.listItem),Tab:Mm(c.listItem)}),yr(lm)]})}),h=new r1({mount:i},{state:p,dispatchTransaction(g){var v;const{state:b}=h,C=b.apply(g),y=!b.doc.eq(C.doc);h.updateState(C);const S=!b.selection.eq(C.selection);y&&(Z1(((v=l==null?void 0:l.view)==null?void 0:v.el)||i),h.focus()),(S||y)&&n.trigger(Pe)}});return i.__rteView=h,h.setProps({nodeViews:{image(g){return new I0(g,h,n)}}}),h},s=i=>N0(i,t);n.setCustomRte({toolbar:s,parseContent:!0,async enable(i,l,a){const c=Xr(i);if(c)return c;const d=o(i,a);return U1(i,d),l0(d,a),d},disable(i){const l=Xr(i);if(l)return K1(i,l),l.destroy(),{forceSync:!0}},getContent(i){const l=Xr(i);if(l){const{schema:a,doc:c}=l.state,d=document.createElement("div"),u=Ot.fromSchema(a).serializeFragment(c.content);return u.childNodes.forEach(p=>{p.nodeType===Node.ELEMENT_NODE&&p.innerHTML===""&&(p.innerHTML="<br/>")}),d.appendChild(u),Y1(d),i.classList.remove("ProseMirror-focused"),d.innerHTML}return i.innerHTML}});const r=X1(n,t);W({editor:n,licenseKey:t.licenseKey,plan:O0,pluginName:P0,cleanup:()=>{n.RichTextEditor.customRte=void 0,r()}})}),D0="canvasEmptyState",L0=F.startup,$0=G(function(n,e={}){const t=new WeakMap,o=new WeakMap,s=new WeakMap,r=new Set,i=new WeakMap,l={emptyStates:[],...e},a=(y,S)=>{let v=!1;const{isValid:w}=S;return Array.isArray(w)?v=w.some(x=>y.is(x)):yt(w)?v=w({component:y,editor:n}):v=y.is(w),v},c=y=>{const S=t.get(y);t.delete(y),S==null||S()},d=y=>{y.views.forEach(S=>c(S)),s.delete(y)},u=y=>{if(!(!y||r.has(y)))try{r.add(y);const S=y.components().length>0,v=s.get(y);if(S&&v)d(y);else if(!S&&!v){const w=i.has(y)?i.get(y):l.emptyStates.find(x=>a(y,x));if(i.set(y,w),!w)return;y.views.forEach(x=>{const T=w.render({editor:n,component:y,componentView:x,mount:k=>{o.set(x,k),s.set(y,!0);const M=x.getChildrenContainer();M==null||M.appendChild(k)},unmount:()=>c(x)});t.set(x,()=>{T==null||T();const k=o.get(x);k==null||k.remove()})})}}finally{r.delete(y)}},p=y=>{s.has(y)&&d(y)},h=({model:y})=>{u(y.getComponent())},f=n.Components.events,m=`${f.update}:components`,g="component:mount",b=n.Canvas.events.frameLoadBody,C=f.removed;n.on(m,u),n.on(g,u),n.on(C,p),n.on(b,h),W({editor:n,licenseKey:l.licenseKey,plan:L0,pluginName:D0,cleanup:()=>{n.off(m,u),n.off(g,u),n.off(C,p),n.off(b,h)}})}),Bd="canvasFullSize",z0=F.startup,B0=G(function(n,e={}){const{Canvas:t,Commands:o,Devices:s}=n,r={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:i,canvasOffsetX:l,canvasTransition:a,deviceMaxWidth:c,deviceMinHeigth:d,frameBorderRadius:u,frameTransition:p}=r,h=`${d}px`,f=t.events,m="core:preview",g=`${o.events.stopCommand}${m}`,b=t.getConfig(),C=`${Bd}:disable`,y=s.getAll().map(v=>({...v.attributes}));b.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",h)});const S=v=>{const w="data-gs-plg-full-size",x=document.querySelector(`style[${w}]`);if(v&&x)return x.remove();const T=x||document.createElement("style"),k=t.getZoomMultiplier();T.setAttribute(w,"true"),T.innerHTML=`
809
- .gjs-frame-wrapper { transition: width ${p}s !important; }
810
- .gjs-frame-wrapper__bottom { height: ${i*k}px }
811
- .gjs-frame { border-radius: ${u}px }
812
- `,!x&&document.body.appendChild(T)};n.on(f.frameLoadHead,v=>{if(!b.scrollableCanvas)return;const{window:w}=v,x=w.document,T=x.head,k="data-gs-plg-wrapper-style",M=T.querySelector(`style[${k}]`)||x.createElement("style");M.setAttribute(k,"true"),M.innerHTML=`
813
- [data-gjs-type="wrapper"] { min-height: ${h}; }
814
- [data-gjs-type="mjml"] { min-height: ${h} !important; }
815
- [data-gjs-type="mj-body"] { min-height: ${h} !important; }
816
- `,!T.contains(M)&&T.appendChild(M)}),n.onReady(()=>{const v=t.getSpotsEl(),w=t.getElement(),x=t.getFramesEl(),T=a*1e3,k=w.style;k.overflowX="hidden",x.style.transition=`transform ${a}s`;const M={x:l,y:i};S();const P=()=>v.style.display="none",O=()=>v.style.display="",N=xn(()=>{t.fitViewport({zoom:J=>J>100?100:J,ignoreHeight:!0,gap:M}),S(),setTimeout(()=>{var ke,hu;const{em:J}=n;J.destroyed||((hu=(ke=n.getSelected())==null?void 0:ke.getEl())==null||hu.scrollIntoView({block:"nearest"}),n.refresh({tools:!0}),O(),o.isActive(m)?J.stopDefault():J.runDefault())},T)},100),L=new ResizeObserver(()=>{P(),N()});L.observe(w.parentElement);const z=()=>{P(),N()},Z=(J={})=>{J.options&&J.options.from!=="fitViewport"&&t.fitViewport({zoom:t.getZoom(),ignoreHeight:!0,gap:M})},le=()=>{k.overflowX="hidden",k.overflowY="auto"},Fe=()=>{L.disconnect(),N.clear()};n.on(s.events.select,z),n.on(f.zoom,Z),n.on(g,le),n.on(n.events.destroy,Fe),N(),o.add(C,()=>{s.devices.reset(y),b.scrollableCanvas=!1,t.getModel().updateDevice(),t.setZoom(100),t.setCoords(0,0),k.overflowY="hidden",S(!0),n.off(s.events.select,z),n.off(f.zoom,Z),n.off(g,le),Fe(),o.run("studio:canvasReload")})}),W({editor:n,licenseKey:r.licenseKey,plan:z0,pluginName:Bd,cleanup:()=>{n.runCommand(C)}})}),ti="canvasGridMode",V0=F.startup,ni="component-grid-mode",eo="grid-mode",to="gjs-drag-grid-spot",Vd=`${to}__grid-item`,Hd=`${to}__grid-target`,Fd=`${to}__snapped`,H0=`${to}__container`,F0=()=>{const n="data-gjs-drag-grid-style",e=document,t="var(--gs-theme-cl-cmp-bg1, var(--gjs-color-highlight))",o="var(--gs-theme-cl-cmp-bg2, var(--gjs-color-blue))",s=e.querySelector(`style[${n}]`)||e.createElement("style");s.setAttribute(n,"true"),s.innerHTML=`
817
- .${Vd} {
799
+ }`,Js=new WeakMap,Wh=(n,e)=>{Js.set(n,e)},jh=n=>{Js.delete(n)},Zs=n=>Js.get(n),Ao=n=>{const e=n.target,t=e.closest(".tox"),o=e.matches(".ephox-snooker-resizer-bar");(t||o)&&n.stopPropagation()},Rl=n=>{n.stopPropagation(),n.preventDefault()},qh=(n,e)=>{const t=n.getDoc(),o=n.getWin();if(e!=null&&e.event){const{event:s}=e,{clientX:r,clientY:i}=s;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(r,i);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(r,i);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")},Uh=n=>{var c,d;const{el:e,editor:t,componentView:o}=n,s=t.runCommand(G.getStateTheme),r=o.model,i={target:e,inline:!0,skin:(s==null?void 0:s.theme)===Ci.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:i,editor:t,componentView:o,component:r}))||{};return{...i,...l}},Dl=(n,e=document)=>new Promise((t,o)=>{const s=Array.isArray(n)?[...n]:[n],{head:r}=e,i=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=i.bind(null,l),a.onerror=o,r.appendChild(a)}else t()};i(s)}),Kh=j(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,r=!t.skipCustomTheme,i="gs-plg-tinymce-studio-theme",l=async(d,u)=>{const p=d.ownerDocument,h=p.defaultView,f=u==null?void 0:u.view;if(!h||!f){console.warn("Missing required data",{win:h,componentView:f});return}const m=Uh({el:d,editor:n,componentView:f,pluginOpts:t}),b=(await h.tinymce.init(m))[0];if(!b)return;const y=(await window.tinymce.init({...m,target:document.createElement("div")}))[0];return b.ui.show(),p.body.addEventListener("mousedown",Ao),document.body.addEventListener("mousedown",Ao),b.on("Change",()=>Vh(d)),b.on("blur",()=>b.ui.show()),b.on("OpenWindow",function(){var w;const S=(w=p.querySelector(".tox-dialog"))==null?void 0:w.closest(".tox");S&&(S==null?void 0:S.ownerDocument)!==document&&(document.body.appendChild(S),b.once("CloseWindow",()=>{S&&S.ownerDocument===document&&p.body.appendChild(S)}))}),d.addEventListener("dragstart",Rl,{capture:!0}),n.runCommand(G.setStateContextMenu,{enabled:!1}),qh(b,u),{rteEditor:b,rteEditorShallow:y}},a=(d,u)=>{d.ownerDocument.body.removeEventListener("mousedown",Ao),document.body.removeEventListener("mousedown",Ao),d.removeEventListener("dragstart",Rl,{capture:!0}),n.runCommand(G.setStateContextMenu,{enabled:!0}),u.rteEditor.destroy(),u.rteEditorShallow.destroy()};n.on(s.frameLoad,async({window:d})=>{const u=d.document;Dl(o,u)}),n.onReady(()=>{Dl(o,document),r&&Ss(i,Gh,{target:document.body})}),n.setCustomRte({parseContent:!0,async enable(d,u,p){const h=Zs(d);if(h)return h.rteEditor;const f=await l(d,p);return f&&Wh(d,f),f==null?void 0:f.rteEditor},disable(d){const u=Zs(d);u&&(jh(d),a(d,u))},getContent(d){var p,h;const u=Zs(d);return u?(h=(p=u.rteEditor).getContent)==null?void 0:h.call(p):d.innerHTML}});const c=Hh(n,t.enableOnClick);q({editor:n,licenseKey:t.licenseKey,plan:_h,pluginName:Fh,cleanup:()=>{n.RichTextEditor.customRte=void 0,c()}})});function ee(n){this.content=n}ee.prototype={constructor:ee,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),r=o.content.slice();return s==-1?r.push(t||n,e):(r[s+1]=e,t&&(r[s]=t)),new ee(r)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new ee(t)},addToStart:function(n,e){return new ee([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new ee(t)},addBefore:function(n,e,t){var o=this.remove(e),s=o.content.slice(),r=o.find(n);return s.splice(r==-1?s.length:r,0,e,t),new ee(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=ee.from(n),n.size?new ee(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ee.from(n),n.size?new ee(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=ee.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}},ee.from=function(n){if(n instanceof ee)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ee(e)};function Ll(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),r=e.child(o);if(s==r){t+=s.nodeSize;continue}if(!s.sameMarkup(r))return t;if(s.isText&&s.text!=r.text){for(let i=0;s.text[i]==r.text[i];i++)t++;return t}if(s.content.size||r.content.size){let i=Ll(s.content,r.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function $l(n,e,t,o){for(let s=n.childCount,r=e.childCount;;){if(s==0||r==0)return s==r?null:{a:t,b:o};let i=n.child(--s),l=e.child(--r),a=i.nodeSize;if(i==l){t-=a,o-=a;continue}if(!i.sameMarkup(l))return{a:t,b:o};if(i.isText&&i.text!=l.text){let c=0,d=Math.min(i.text.length,l.text.length);for(;c<d&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,o--;return{a:t,b:o}}if(i.content.size||l.content.size){let c=$l(i.content,l.content,t-1,o-1);if(c)return c}t-=a,o-=a}}class T{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,r){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&o(a,s+l,r||null,i)!==!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 r="",i=!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&&(i?i=!1:r+=o),r+=c},0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,o=e.firstChild,s=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(o)&&(s[s.length-1]=t.withText(t.text+o.text),r=1);r<e.content.length;r++)s.push(e.content[r]);return new T(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 r=0,i=0;i<t;r++){let l=this.content[r],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),o.push(l),s+=l.nodeSize),i=a}return new T(o,s)}cutByIndex(e,t){return e==t?T.empty:e==0&&t==this.content.length?this:new T(this.content.slice(e,t))}replaceChild(e,t){let o=this.content[e];if(o==t)return this;let s=this.content.slice(),r=this.size+t.nodeSize-o.nodeSize;return s[e]=t,new T(s,r)}addToStart(e){return new T([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new T(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 Ll(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return $l(this,e,t,o)}findIndex(e,t=-1){if(e==0)return Po(0,e);if(e==this.size)return Po(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 r=this.child(o),i=s+r.nodeSize;if(i>=e)return i==e||t>0?Po(o+1,i):Po(o,s);s=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return T.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new T(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return T.empty;let t,o=0;for(let s=0;s<e.length;s++){let r=e[s];o+=r.nodeSize,s&&r.isText&&e[s-1].sameMarkup(r)?(t||(t=e.slice(0,s)),t[t.length-1]=r.withText(t[t.length-1].text+r.text)):t&&t.push(r)}return new T(t||e,o)}static from(e){if(!e)return T.empty;if(e instanceof T)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new T([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}T.empty=new T([],0);const Ys={index:0,offset:0};function Po(n,e){return Ys.index=n,Ys.offset=e,Ys}function No(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(!No(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!No(n[o],e[o]))return!1;for(let o in e)if(!(o in n))return!1}return!0}class H{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,o=!1;for(let s=0;s<e.length;s++){let r=e[s];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,s));else{if(r.type.excludes(this.type))return e;!o&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),o=!0),t&&t.push(r)}}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&&No(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 H.none;if(e instanceof H)return[e];let t=e.slice();return t.sort((o,s)=>o.type.rank-s.type.rank),t}}H.none=[];class Oo extends Error{}class A{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=Bl(this.content,e+this.openStart,t);return o&&new A(o,this.openStart,this.openEnd)}removeBetween(e,t){return new A(zl(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 A.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 A(T.fromJSON(e,t.content),o,s)}static maxOpen(e,t=!0){let o=0,s=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)o++;for(let r=e.lastChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.lastChild)s++;return new A(e,o,s)}}A.empty=new A(T.empty,0,0);function zl(n,e,t){let{index:o,offset:s}=n.findIndex(e),r=n.maybeChild(o),{index:i,offset:l}=n.findIndex(t);if(s==e||r.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(o!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(o,r.copy(zl(r.content,e-s-1,t-s-1)))}function Bl(n,e,t,o){let{index:s,offset:r}=n.findIndex(e),i=n.maybeChild(s);if(r==e||i.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Bl(i.content,e-r-1,t);return l&&n.replaceChild(s,i.copy(l))}function Jh(n,e,t){if(t.openStart>n.depth)throw new Oo("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Oo("Inconsistent open depths");return Vl(n,e,t,0)}function Vl(n,e,t,o){let s=n.index(o),r=n.node(o);if(s==e.index(o)&&o<n.depth-t.openStart){let i=Vl(n,e,t,o+1);return r.copy(r.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let i=n.parent,l=i.content;return At(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=Zh(t,n);return At(r,Fl(n,i,l,e,o))}else return At(r,Io(n,e,o))}function Hl(n,e){if(!e.type.compatibleContent(n.type))throw new Oo("Cannot join "+e.type.name+" onto "+n.type.name)}function Xs(n,e,t){let o=n.node(t);return Hl(o,e.node(t)),o}function Mt(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 In(n,e,t,o){let s=(e||n).node(t),r=0,i=e?e.index(t):s.childCount;n&&(r=n.index(t),n.depth>t?r++:n.textOffset&&(Mt(n.nodeAfter,o),r++));for(let l=r;l<i;l++)Mt(s.child(l),o);e&&e.depth==t&&e.textOffset&&Mt(e.nodeBefore,o)}function At(n,e){return n.type.checkContent(e),n.copy(e)}function Fl(n,e,t,o,s){let r=n.depth>s&&Xs(n,e,s+1),i=o.depth>s&&Xs(t,o,s+1),l=[];return In(null,n,s,l),r&&i&&e.index(s)==t.index(s)?(Hl(r,i),Mt(At(r,Fl(n,e,t,o,s+1)),l)):(r&&Mt(At(r,Io(n,e,s+1)),l),In(e,t,s,l),i&&Mt(At(i,Io(t,o,s+1)),l)),In(o,null,s,l),new T(l)}function Io(n,e,t){let o=[];if(In(null,n,t,o),n.depth>t){let s=Xs(n,e,t+1);Mt(At(s,Io(n,e,t+1)),o)}return In(e,null,t,o),new T(o)}function Zh(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let r=t-1;r>=0;r--)s=e.node(r).copy(T.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class Rn{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 r=0;r<e;r++)s+=o.child(r).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return H.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 r=o.marks;for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}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 r=0;r<o.length;r++)o[r].type.spec.inclusive===!1&&(!s||!o[r].isInSet(s.marks))&&(o=o[r--].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 Ro(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,r=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(r),c=r-a;if(o.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;r=c-1,s+=a+1}return new Rn(t,o,r)}static resolveCached(e,t){let o=_l.get(e);if(o)for(let r=0;r<o.elts.length;r++){let i=o.elts[r];if(i.pos==t)return i}else _l.set(e,o=new Yh);let s=o.elts[o.i]=Rn.resolve(e,t);return o.i=(o.i+1)%Xh,s}}class Yh{constructor(){this.elts=[],this.i=0}}const Xh=12,_l=new WeakMap;class Ro{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 Qh=Object.create(null);let Pt=class gi{constructor(e,t,o,s=H.none){this.type=e,this.attrs=t,this.marks=s,this.content=o||T.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&&No(this.attrs,t||e.defaultAttrs||Qh)&&H.sameSet(this.marks,o||H.none)}copy(e=null){return e==this.content?this:new gi(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new gi(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 A.empty;let s=this.resolve(e),r=this.resolve(t),i=o?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,r.pos-l);return new A(c,s.depth-i,r.depth-i)}replace(e,t,o){return Jh(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 Rn.resolveCached(this,e)}resolveNoCache(e){return Rn.resolve(this,e)}rangeHasMark(e,t,o){let s=!1;return t>e&&this.nodesBetween(e,t,r=>(o.isInSet(r.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()+")"),Gl(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=T.empty,s=0,r=o.childCount){let i=this.contentMatchAt(e).matchFragment(o,s,r),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<r;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 r=this.contentMatchAt(e).matchType(o),i=r&&r.matchFragment(this.content,t);return i?i.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=H.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(!H.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=T.fromJSON(e,t.content),r=e.nodeType(t.type).create(t.attrs,s,o);return r.type.checkAttrs(r.attrs),r}};Pt.prototype.text=void 0;class Do extends Pt{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):Gl(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 Do(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Do(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 Gl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Nt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new ef(e,t);if(o.next==null)return Nt.empty;let s=Wl(o);o.next&&o.err("Unexpected trailing text");let r=af(lf(s));return cf(r,o),r}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,o=e.childCount){let s=this;for(let r=t;s&&r<o;r++)s=s.matchType(e.child(r).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 r(i,l){let a=i.matchFragment(e,o);if(a&&(!t||a.validEnd))return T.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:d,next:u}=i.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let p=r(u,l.concat(d));if(p)return p}}return null}return r(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(),r=s.match;if(r.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<r.next.length;i++){let{type:l,next:a}=r.next[i];!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 r=s+(o.validEnd?"*":" ")+" ";for(let i=0;i<o.next.length;i++)r+=(i?", ":"")+o.next[i].type.name+"->"+e.indexOf(o.next[i].next);return r}).join(`
800
+ `)}}Nt.empty=new Nt(!0);class ef{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 Wl(n){let e=[];do e.push(tf(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function tf(n){let e=[];do e.push(nf(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function nf(n){let e=rf(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=of(n,e);else break;return e}function jl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function of(n,e){let t=jl(n),o=t;return n.eat(",")&&(n.next!="}"?o=jl(n):o=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:o,expr:e}}function sf(n,e){let t=n.nodeTypes,o=t[e];if(o)return[o];let s=[];for(let r in t){let i=t[r];i.isInGroup(e)&&s.push(i)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function rf(n){if(n.eat("(")){let e=Wl(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=sf(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 lf(n){let e=[[]];return s(r(n,0),t()),e;function t(){return e.push([])-1}function o(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function s(i,l){i.forEach(a=>a.to=l)}function r(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(r(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=r(i.exprs[a],l);if(a==i.exprs.length-1)return c;s(c,l=t())}else if(i.type=="star"){let a=t();return o(l,a),s(r(i.expr,a),a),[o(a)]}else if(i.type=="plus"){let a=t();return s(r(i.expr,l),a),s(r(i.expr,a),a),[o(a)]}else{if(i.type=="opt")return[o(l)].concat(r(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let d=t();s(r(i.expr,a),d),a=d}if(i.max==-1)s(r(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let d=t();o(a,d),s(r(i.expr,a),d),a=d}return[o(a)]}else{if(i.type=="name")return[o(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function ql(n,e){return e-n}function Ul(n,e){let t=[];return o(e),t.sort(ql);function o(s){let r=n[s];if(r.length==1&&!r[0].term)return o(r[0].to);t.push(s);for(let i=0;i<r.length;i++){let{term:l,to:a}=r[i];!l&&t.indexOf(a)==-1&&o(a)}}}function af(n){let e=Object.create(null);return t(Ul(n,0));function t(o){let s=[];o.forEach(i=>{n[i].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]);Ul(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let r=e[o.join(",")]=new Nt(o.indexOf(n.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(ql);r.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return r}}function cf(n,e){for(let t=0,o=[n];t<o.length;t++){let s=o[t],r=!s.validEnd,i=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];i.push(a.name),r&&!(a.isText||a.hasRequiredAttrs())&&(r=!1),o.indexOf(c)==-1&&o.push(c)}r&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Kl(n){let e=Object.create(null);for(let t in n){let o=n[t];if(!o.hasDefault)return null;e[t]=o.default}return e}function Jl(n,e){let t=Object.create(null);for(let o in n){let s=e&&e[o];if(s===void 0){let r=n[o];if(r.hasDefault)s=r.default;else throw new RangeError("No value supplied for attribute "+o)}t[o]=s}return t}function Zl(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 r=n[s];r.validate&&r.validate(e[s])}}function Yl(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new uf(n,o,e[o]);return t}let Xl=class fu{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=Yl(e,o.attrs),this.defaultAttrs=Kl(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==Nt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Jl(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Pt(this,this.computeAttrs(e),T.from(t),H.setFrom(o))}createChecked(e=null,t,o){return t=T.from(t),this.checkContent(t),new Pt(this,this.computeAttrs(e),t,H.setFrom(o))}createAndFill(e=null,t,o){if(e=this.computeAttrs(e),t=T.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let s=this.contentMatch.matchFragment(t),r=s&&s.fillBefore(T.empty,!0);return r?new Pt(this,e,t.append(r),H.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){Zl(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:H.none:e}static compile(e,t){let o=Object.create(null);e.forEach((r,i)=>o[r]=new fu(r,t,i));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 r in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function df(n,e,t){let o=t.split("|");return s=>{let r=s===null?"null":typeof s;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${n}, got ${r}`)}}class uf{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?df(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class Lo{constructor(e,t,o,s){this.name=e,this.rank=t,this.schema=o,this.spec=s,this.attrs=Yl(e,s.attrs),this.excluded=null;let r=Kl(this.attrs);this.instance=r?new H(this,r):null}create(e=null){return!e&&this.instance?this.instance:new H(this,Jl(this.attrs,e))}static compile(e,t){let o=Object.create(null),s=0;return e.forEach((r,i)=>o[r]=new Lo(r,s++,t,i)),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){Zl(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class pf{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=ee.from(e.nodes),t.marks=ee.from(e.marks||{}),this.nodes=Xl.compile(this.spec.nodes,this),this.marks=Lo.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 r=this.nodes[s],i=r.spec.content||"",l=r.spec.marks;if(r.contentMatch=o[i]||(o[i]=Nt.parse(i,this.nodes)),r.inlineContent=r.contentMatch.inlineContent,r.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!r.isInline||!r.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=r}r.markSet=l=="_"?null:l?Ql(this,l.split(" ")):l==""||!r.inlineContent?[]:null}for(let s in this.marks){let r=this.marks[s],i=r.spec.excludes;r.excluded=i==null?[r]:i==""?[]:Ql(this,i.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 Xl){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 Do(o,o.defaultAttrs,e,H.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Pt.fromJSON(this,e)}markFromJSON(e){return H.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Ql(n,e){let t=[];for(let o=0;o<e.length;o++){let s=e[o],r=n.marks[s],i=r;if(r)t.push(r);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(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function hf(n){return n.tag!=null}function ff(n){return n.style!=null}class rn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(s=>{if(hf(s))this.tags.push(s);else if(ff(s)){let r=/[^=]*/.exec(s.style)[0];o.indexOf(r)<0&&o.push(r),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let r=e.nodes[s.node];return r.contentMatch.matchType(r)})}parse(e,t={}){let o=new oa(this,t,!1);return o.addAll(e,H.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new oa(this,t,!0);return o.addAll(e,H.none,t.from,t.to),A.maxOpen(o.finish())}matchTag(e,t,o){for(let s=o?this.tags.indexOf(o)+1:0;s<this.tags.length;s++){let r=this.tags[s];if(yf(e,r.tag)&&(r.namespace===void 0||e.namespaceURI==r.namespace)&&(!r.context||t.matchesContext(r.context))){if(r.getAttrs){let i=r.getAttrs(e);if(i===!1)continue;r.attrs=i||void 0}return r}}}matchStyle(e,t,o,s){for(let r=s?this.styles.indexOf(s)+1:0;r<this.styles.length;r++){let i=this.styles[r],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!o.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function o(s){let r=s.priority==null?50:s.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<r)break}t.splice(i,0,s)}for(let s in e.marks){let r=e.marks[s].spec.parseDOM;r&&r.forEach(i=>{o(i=sa(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in e.nodes){let r=e.nodes[s].spec.parseDOM;r&&r.forEach(i=>{o(i=sa(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new rn(e,rn.schemaRules(e)))}}const ea={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},mf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ta={ol:!0,ul:!0},$o=1,zo=2,Dn=4;function na(n,e,t){return e!=null?(e?$o:0)|(e==="full"?zo:0):n&&n.whitespace=="pre"?$o|zo:t&~Dn}class Bo{constructor(e,t,o,s,r,i){this.type=e,this.attrs=t,this.marks=o,this.solid=s,this.options=i,this.content=[],this.activeMarks=H.none,this.match=r||(i&Dn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(T.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&$o)){let o=this.content[this.content.length-1],s;if(o&&o.isText&&(s=/[ \t\r\n\u000c]+$/.exec(o.text))){let r=o;o.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-s[0].length))}}let t=T.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(T.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&&!ea.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class oa{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0;let s=t.topNode,r,i=na(null,t.preserveWhitespace,0)|(o?Dn:0);s?r=new Bo(s.type,s.attrs,H.none,!0,t.topMatch||s.type.contentMatch,i):o?r=new Bo(null,null,H.none,!0,null,i):r=new Bo(e.schema.topNodeType,null,H.none,!0,null,i),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let o=e.nodeValue,s=this.top;if(s.options&zo||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(s.options&$o)s.options&zo?o=o.replace(/\r\n?/g,`
801
+ `):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 r=s.content[s.content.length-1],i=e.previousSibling;(!r||i&&i.nodeName=="BR"||r.isText&&/[ \t\r\n\u000c]$/.test(r.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(),r;ta.hasOwnProperty(s)&&this.parser.normalizeLists&&gf(e);let i=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(r=this.parser.matchTag(e,this,o));if(i?i.ignore:mf.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!i||i.skip||i.closeParent){i&&i.closeParent?this.open=Math.max(0,this.open-1):i&&i.skip.nodeType&&(e=i.skip);let l,a=this.top,c=this.needsBlock;if(ea.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=i&&i.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,i,l,i.consuming===!1?r:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
802
+ `),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 r=this.parser.matchedStyles[s],i=o.getPropertyValue(r);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(r,i,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 r,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),o)||this.leafFallback(e,o);else{let a=this.enter(i,t.attrs||null,o,t.preserveWhitespace);a&&(r=!0,o=a)}else{let a=this.parser.schema.marks[t.mark];o=o.concat(a.create(t.attrs))}let l=this.top;if(i&&i.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)}r&&this.sync(l)&&this.open--}addAll(e,t,o,s){let r=o||0;for(let i=o?e.childNodes[o]:e.firstChild,l=s==null?null:e.childNodes[s];i!=l;i=i.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(i,t);this.findAtPoint(e,r)}findPlace(e,t){let o,s;for(let r=this.open;r>=0;r--){let i=this.nodes[r],l=i.findWrapping(e);if(l&&(!o||o.length>l.length)&&(o=l,s=i,!l.length)||i.solid)break}if(!o)return null;this.sync(s);for(let r=0;r<o.length;r++)t=this.enterInner(o[r],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 r=H.none;for(let i of o.concat(e.marks))(s.type?s.type.allowsMarkType(i.type):ra(i.type,e.type))&&(r=i.addToSet(r));return s.content.push(e.mark(r)),!0}return!1}enter(e,t,o,s){let r=this.findPlace(e.create(t),o);return r&&(r=this.enterInner(e,t,o,!0,s)),r}enterInner(e,t,o,s=!1,r){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=na(e,r,i.options);i.options&Dn&&i.content.length==0&&(l|=Dn);let a=H.none;return o=o.filter(c=>(i.type?i.type.allowsMarkType(c.type):ra(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Bo(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),r=-(o?o.depth+1:0)+(s?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=r;a--)if(i(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:o&&a>=r?o.node(a-r).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return i(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 gf(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&ta.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function yf(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function sa(n){let e={};for(let t in n)e[t]=n[t];return e}function ra(n,e){let t=e.schema.nodes;for(let o in t){let s=t[o];if(!s.allowsMarkType(n))continue;let r=[],i=l=>{r.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||r.indexOf(d)<0&&i(d))return!0}};if(i(s.contentMatch))return!0}}class Ot{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=Qs(t).createDocumentFragment());let s=o,r=[];return e.forEach(i=>{if(r.length||i.marks.length){let l=0,a=0;for(;l<r.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(r[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<r.length;)s=r.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],d=this.serializeMark(c,i.isInline,t);d&&(r.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(i,t))}),o}serializeNodeInner(e,t){let{dom:o,contentDOM:s}=Vo(Qs(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 r=this.serializeMark(e.marks[s],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(o),o=r.dom)}return o}serializeMark(e,t,o={}){let s=this.marks[e.type.name];return s&&Vo(Qs(o),s(e,t),null,e.attrs)}static renderSpec(e,t,o=null,s){return Vo(e,t,o,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ot(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=ia(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return ia(e.marks)}}function ia(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function Qs(n){return n.document||window.document}const la=new WeakMap;function bf(n){let e=la.get(n);return e===void 0&&la.set(n,e=Sf(n)),e}function Sf(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 Vo(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],r;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=bf(o))&&r.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=s.indexOf(" ");i>0&&(t=s.slice(0,i),s=s.slice(i+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 p=u.indexOf(" ");p>0?a.setAttributeNS(u.slice(0,p),u.slice(p+1),c[u]):a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let p=e[u];if(p===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:h,contentDOM:f}=Vo(n,p,t,o);if(a.appendChild(h),f){if(l)throw new RangeError("Multiple content holes");l=f}}}return{dom:a,contentDOM:l}}const aa=65535,ca=Math.pow(2,16);function vf(n,e){return n+e*ca}function da(n){return n&aa}function xf(n){return(n-(n&aa))/ca}const ua=1,pa=2,Ho=4,ha=8;class er{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&ha)>0}get deletedBefore(){return(this.delInfo&(ua|Ho))>0}get deletedAfter(){return(this.delInfo&(pa|Ho))>0}get deletedAcross(){return(this.delInfo&Ho)>0}}class ye{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&ye.empty)return ye.empty}recover(e){let t=0,o=da(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+xf(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,r=this.inverted?2:1,i=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+r],d=this.ranges[l+i],u=a+c;if(e<=u){let p=c?e==a?-1:e==u?1:t:t,h=a+s+(p<0?0:d);if(o)return h;let f=e==(t<0?a:u)?null:vf(l/3,e-a),m=e==a?pa:e==u?ua:Ho;return(t<0?e!=a:e!=u)&&(m|=ha),new er(h,m,f)}s+=d-c}return o?e+s:new er(e+s,0,null)}touches(e,t){let o=0,s=da(t),r=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+r],d=a+c;if(e<=d&&l==s*3)return!0;o+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,o=this.inverted?1:2;for(let s=0,r=0;s<this.ranges.length;s+=3){let i=this.ranges[s],l=i-(this.inverted?r:0),a=i+(this.inverted?0:r),c=this.ranges[s+t],d=this.ranges[s+o];e(l,l+c,a,a+d),r+=d-c}}invert(){return new ye(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ye.empty:new ye(e<0?[0,-e,0]:[0,0,e])}}ye.empty=new ye([]);class ln{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 ln(this.maps,this.mirror,e,t)}copy(){return new ln(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 ln;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 r=this.from;r<this.to;r++){let i=this.maps[r],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(r);if(a!=null&&a>r&&a<this.to){r=a,e=this.maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return o?e:new er(e,s,null)}}const tr=Object.create(null);class se{getMap(){return ye.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=tr[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 tr)throw new RangeError("Duplicate use of step JSON ID "+e);return tr[e]=t,t.prototype.jsonID=e,t}}class J{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new J(e,null)}static fail(e){return new J(null,e)}static fromReplace(e,t,o,s){try{return J.ok(e.replace(t,o,s))}catch(r){if(r instanceof Oo)return J.fail(r.message);throw r}}}function nr(n,e,t){let o=[];for(let s=0;s<n.childCount;s++){let r=n.child(s);r.content.size&&(r=r.copy(nr(r.content,e,r))),r.isInline&&(r=e(r,t,s)),o.push(r)}return T.fromArray(o)}class nt extends se{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)),r=new A(nr(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),t.openStart,t.openEnd);return J.fromReplace(e,this.from,this.to,r)}invert(){return new Le(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 nt(t.pos,o.pos,this.mark)}merge(e){return e instanceof nt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new nt(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 nt(t.from,t.to,e.markFromJSON(t.mark))}}se.jsonID("addMark",nt);class Le extends se{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 A(nr(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return J.fromReplace(e,this.from,this.to,o)}invert(){return new nt(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 Le(t.pos,o.pos,this.mark)}merge(e){return e instanceof Le&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Le(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 Le(t.from,t.to,e.markFromJSON(t.mark))}}se.jsonID("removeMark",Le);class ot extends se{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return J.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return J.fromReplace(e,this.pos,this.pos+1,new A(T.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 ot(this.pos,t.marks[s]);return new ot(this.pos,this.mark)}}return new an(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ot(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 ot(t.pos,e.markFromJSON(t.mark))}}se.jsonID("addNodeMark",ot);class an extends se{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return J.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return J.fromReplace(e,this.pos,this.pos+1,new A(T.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new ot(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new an(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 an(t.pos,e.markFromJSON(t.mark))}}se.jsonID("removeNodeMark",an);class re extends se{constructor(e,t,o,s=!1){super(),this.from=e,this.to=t,this.slice=o,this.structure=s}apply(e){return this.structure&&or(e,this.from,this.to)?J.fail("Structure replace would overwrite content"):J.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ye([this.from,this.to-this.from,this.slice.size])}invert(e){return new re(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 re(t.pos,Math.max(t.pos,o.pos),this.slice)}merge(e){if(!(e instanceof re)||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?A.empty:new A(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new re(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?A.empty:new A(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new re(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 re(t.from,t.to,A.fromJSON(e,t.slice),!!t.structure)}}se.jsonID("replace",re);class te extends se{constructor(e,t,o,s,r,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=s,this.slice=r,this.insert=i,this.structure=l}apply(e){if(this.structure&&(or(e,this.from,this.gapFrom)||or(e,this.gapTo,this.to)))return J.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return J.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,t.content);return o?J.fromReplace(e,this.from,this.to,o):J.fail("Content does not fit in gap")}getMap(){return new ye([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 te(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),r=this.to==this.gapTo?o.pos:e.map(this.gapTo,1);return t.deletedAcross&&o.deletedAcross||s<t.pos||r>o.pos?null:new te(t.pos,o.pos,s,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new te(t.from,t.to,t.gapFrom,t.gapTo,A.fromJSON(e,t.slice),t.insert,!!t.structure)}}se.jsonID("replaceAround",te);function or(n,e,t){let o=n.resolve(e),s=t-e,r=o.depth;for(;s>0&&r>0&&o.indexAfter(r)==o.node(r).childCount;)r--,s--;if(s>0){let i=o.node(r).maybeChild(o.indexAfter(r));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function wf(n,e,t,o){let s=[],r=[],i,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 p=Math.max(c,e),h=Math.min(c+a.nodeSize,t),f=o.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(f)||(i&&i.to==p&&i.mark.eq(u[m])?i.to=h:s.push(i=new Le(p,h,u[m])));l&&l.to==p?l.to=h:r.push(l=new nt(p,h,o))}}),s.forEach(a=>n.step(a)),r.forEach(a=>n.step(a))}function Cf(n,e,t,o){let s=[],r=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;r++;let a=null;if(o instanceof Lo){let c=i.marks,d;for(;d=o.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else o?o.isInSet(i.marks)&&(a=[o]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],p;for(let h=0;h<s.length;h++){let f=s[h];f.step==r-1&&u.eq(s[h].style)&&(p=f)}p?(p.to=c,p.step=r):s.push({style:u,from:Math.max(l,e),to:c,step:r})}}}),s.forEach(i=>n.step(new Le(i.from,i.to,i.style)))}function sr(n,e,t,o=t.contentMatch,s=!0){let r=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<r.childCount;a++){let c=r.child(a),d=l+c.nodeSize,u=o.matchType(c.type);if(!u)i.push(new re(l,d,A.empty));else{o=u;for(let p=0;p<c.marks.length;p++)t.allowsMarkType(c.marks[p].type)||n.step(new Le(l,d,c.marks[p]));if(s&&c.isText&&t.whitespace!="pre"){let p,h=/\r?\n|\r/g,f;for(;p=h.exec(c.text);)f||(f=new A(T.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new re(l+p.index,l+p.index+p[0].length,f))}}l=d}if(!o.validEnd){let a=o.fillBefore(T.empty,!0);n.replace(l,l,new A(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function kf(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Fo(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth;;--o){let s=n.$from.node(o),r=n.$from.index(o),i=n.$to.indexAfter(o);if(o<n.depth&&s.canReplace(r,i,t))return o;if(o==0||s.type.spec.isolating||!kf(s,r,i))break}return null}function Tf(n,e,t){let{$from:o,$to:s,depth:r}=e,i=o.before(r+1),l=s.after(r+1),a=i,c=l,d=T.empty,u=0;for(let f=r,m=!1;f>t;f--)m||o.index(f)>0?(m=!0,d=T.from(o.node(f).copy(d)),u++):a--;let p=T.empty,h=0;for(let f=r,m=!1;f>t;f--)m||s.after(f+1)<s.end(f)?(m=!0,p=T.from(s.node(f).copy(p)),h++):c++;n.step(new te(a,c,i,l,new A(d.append(p),u,h),d.size-u,!0))}function fa(n,e,t=null,o=n){let s=Ef(n,e),r=s&&Mf(o,e);return r?s.map(ma).concat({type:e,attrs:t}).concat(r.map(ma)):null}function ma(n){return{type:n,attrs:null}}function Ef(n,e){let{parent:t,startIndex:o,endIndex:s}=n,r=t.contentMatchAt(o).findWrapping(e);if(!r)return null;let i=r.length?r[0]:e;return t.canReplaceWith(o,s,i)?r:null}function Mf(n,e){let{parent:t,startIndex:o,endIndex:s}=n,r=t.child(o),i=e.contentMatch.findWrapping(r.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=o;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Af(n,e,t){let o=T.empty;for(let i=t.length-1;i>=0;i--){if(o.size){let l=t[i].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=T.from(t[i].type.create(t[i].attrs,o))}let s=e.start,r=e.end;n.step(new te(s,r,s,r,new A(o,0,0),t.length,!0))}function Pf(n,e,t,o,s){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let r=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(o,a)&&Nf(n.doc,n.mapping.slice(r).map(l),o)){let c=null;if(o.schema.linebreakReplacement){let h=o.whitespace=="pre",f=!!o.contentMatch.matchType(o.schema.linebreakReplacement);h&&!f?c=!1:!h&&f&&(c=!0)}c===!1&&ya(n,i,l,r),sr(n,n.mapping.slice(r).map(l,1),o,void 0,c===null);let d=n.mapping.slice(r),u=d.map(l,1),p=d.map(l+i.nodeSize,1);return n.step(new te(u,p,u+1,p-1,new A(T.from(o.create(a,null,i.marks)),0,0),1,!0)),c===!0&&ga(n,i,l,r),!1}})}function ga(n,e,t,o){e.forEach((s,r)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=n.mapping.slice(o).map(t+1+r+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function ya(n,e,t,o){e.forEach((s,r)=>{if(s.type==s.type.schema.linebreakReplacement){let i=n.mapping.slice(o).map(t+1+r);n.replaceWith(i,i+1,e.type.schema.text(`
803
+ `))}})}function Nf(n,e,t){let o=n.resolve(e),s=o.index();return o.parent.canReplaceWith(s,s+1,t)}function Of(n,e,t,o,s){let r=n.doc.nodeAt(e);if(!r)throw new RangeError("No node at given position");t||(t=r.type);let i=t.create(o,null,s||r.marks);if(r.isLeaf)return n.replaceWith(e,e+r.nodeSize,i);if(!t.validContent(r.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new te(e,e+r.nodeSize,e+1,e+r.nodeSize-1,new A(T.from(i),0,0),1,!0))}function cn(n,e,t=1,o){let s=n.resolve(e),r=s.depth-t,i=o&&o[o.length-1]||s.parent;if(r<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>r;c--,d--){let u=s.node(c),p=s.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(p,u.childCount),f=o&&o[d+1];f&&(h=h.replaceChild(0,f.type.create(f.attrs)));let m=o&&o[d]||u;if(!u.canReplace(p+1,u.childCount)||!m.type.validContent(h))return!1}let l=s.indexAfter(r),a=o&&o[0];return s.node(r).canReplaceWith(l,l,a?a.type:s.node(r+1).type)}function If(n,e,t=1,o){let s=n.doc.resolve(e),r=T.empty,i=T.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){r=T.from(s.node(l).copy(r));let d=o&&o[c];i=T.from(d?d.type.create(d.attrs,i):s.node(l).copy(i))}n.step(new re(e,e,new A(r.append(i),t,t),!0))}function _o(n,e){let t=n.resolve(e),o=t.index();return Df(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function Rf(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 r=e.child(s),i=r.type==o?n.type.schema.nodes.text:r.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(r.marks))return!1}return t.validEnd}function Df(n,e){return!!(n&&e&&!n.isLeaf&&Rf(n,e))}function Lf(n,e,t){let o=null,{linebreakReplacement:s}=n.doc.type.schema,r=n.doc.resolve(e-t),i=r.node().type;if(s&&i.inlineContent){let d=i.whitespace=="pre",u=!!i.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);ya(n,d.node(),d.before(),l)}i.inlineContent&&sr(n,e+t-1,i,r.node().contentMatchAt(r.index()),o==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new re(c,a.map(e+t,-1),A.empty,!0)),o===!0){let d=n.doc.resolve(c);ga(n,d.node(),d.before(),n.steps.length)}return n}function $f(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 r=o.index(s);if(o.node(s).canReplaceWith(r,r,t))return o.before(s+1);if(r>0)return null}if(o.parentOffset==o.parent.content.size)for(let s=o.depth-1;s>=0;s--){let r=o.indexAfter(s);if(o.node(s).canReplaceWith(r,r,t))return o.after(s+1);if(r<o.node(s).childCount)return null}return null}function zf(n,e,t){let o=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let r=0;r<t.openStart;r++)s=s.firstChild.content;for(let r=1;r<=(t.openStart==0&&t.size?2:1);r++)for(let i=o.depth;i>=0;i--){let l=i==o.depth?0:o.pos<=(o.start(i+1)+o.end(i+1))/2?-1:1,a=o.index(i)+(l>0?1:0),c=o.node(i),d=!1;if(r==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(i+1):o.after(i+1)}return null}function rr(n,e,t=e,o=A.empty){if(e==t&&!o.size)return null;let s=n.resolve(e),r=n.resolve(t);return ba(s,r,o)?new re(e,t,o):new Bf(s,r,o).fit()}function ba(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Bf{constructor(e,t,o){this.$from=e,this.$to=t,this.unplaced=o,this.frontier=[],this.placed=T.empty;for(let s=0;s<=e.depth;s++){let r=e.node(s);this.frontier.push({type:r.type,match:r.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=T.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 r=this.placed,i=o.depth,l=s.depth;for(;i&&l&&r.childCount==1;)r=r.firstChild.content,i--,l--;let a=new A(r,i,l);return e>-1?new te(o.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||o.pos!=this.$to.pos?new re(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 r=t.firstChild;if(t.childCount>1&&(s=0),r.type.spec.isolating&&s<=o){e=o;break}t=r.content}for(let t=1;t<=2;t++)for(let o=t==1?e:this.unplaced.openStart;o>=0;o--){let s,r=null;o?(r=ir(this.unplaced.content,o-1).firstChild,s=r.content):s=this.unplaced.content;let i=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(i?c.matchType(i.type)||(u=c.fillBefore(T.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:o,frontierDepth:l,parent:r,inject:u};if(t==2&&i&&(d=c.findWrapping(i.type)))return{sliceDepth:o,frontierDepth:l,parent:r,wrap:d};if(r&&c.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:o}=this.unplaced,s=ir(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new A(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=ir(e,t);if(s.childCount<=1&&t>0){let r=e.size-t<=t+s.size;this.unplaced=new A(Ln(e,t-1,1),t-1,r?t-1:o)}else this.unplaced=new A(Ln(e,t,1),t,o)}placeNodes({sliceDepth:e,frontierDepth:t,parent:o,inject:s,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let m=0;m<r.length;m++)this.openFrontierNode(r[m]);let i=this.unplaced,l=o?o.content:i.content,a=i.openStart-e,c=0,d=[],{match:u,type:p}=this.frontier[t];if(s){for(let m=0;m<s.childCount;m++)d.push(s.child(m));u=u.matchFragment(s)}let h=l.size+e-(i.content.size-i.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(Sa(m.mark(p.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let f=c==l.childCount;f||(h=-1),this.placed=$n(this.placed,t,T.from(d)),this.frontier[t].match=u,f&&h<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=f?e==0?A.empty:new A(Ln(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new A(Ln(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!lr(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],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=lr(e,t,s,o,r);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=lr(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:i,move:r?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=$n(this.placed,t.depth,t.fit)),e=t.move;for(let o=t.depth+1;o<=e.depth;o++){let s=e.node(o),r=s.type.contentMatch.fillBefore(s.content,!0,e.index(o));this.openFrontierNode(s.type,s.attrs,r)}return e}openFrontierNode(e,t=null,o){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=$n(this.placed,this.depth,T.from(e.create(t,o))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(T.empty,!0);t.childCount&&(this.placed=$n(this.placed,this.frontier.length,t))}}function Ln(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Ln(n.firstChild.content,e-1,t)))}function $n(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy($n(n.lastChild.content,e-1,t)))}function ir(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Sa(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,Sa(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(T.empty,!0)))),n.copy(o)}function lr(n,e,t,o,s){let r=n.node(e),i=s?n.indexAfter(e):n.index(e);if(i==r.childCount&&!t.compatibleContent(r.type))return null;let l=o.fillBefore(r.content,!0,i);return l&&!Vf(t,r.content,i)?l:null}function Vf(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function Hf(n){return n.spec.defining||n.spec.definingForContent}function Ff(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),r=n.doc.resolve(t);if(ba(s,r,o))return n.step(new re(e,t,o));let i=xa(s,n.doc.resolve(t));i[i.length-1]==0&&i.pop();let l=-(s.depth+1);i.unshift(l);for(let p=s.depth,h=s.pos-1;p>0;p--,h--){let f=s.node(p).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;i.indexOf(p)>-1?l=p:s.before(p)==h&&i.splice(1,0,-p)}let a=i.indexOf(l),c=[],d=o.openStart;for(let p=o.content,h=0;;h++){let f=p.firstChild;if(c.push(f),h==o.openStart)break;p=f.content}for(let p=d-1;p>=0;p--){let h=c[p],f=Hf(h.type);if(f&&!h.sameMarkup(s.node(Math.abs(l)-1)))d=p;else if(f||!h.type.isTextblock)break}for(let p=o.openStart;p>=0;p--){let h=(p+d+1)%(o.openStart+1),f=c[h];if(f)for(let m=0;m<i.length;m++){let g=i[(m+a)%i.length],b=!0;g<0&&(b=!1,g=-g);let C=s.node(g-1),y=s.index(g-1);if(C.canReplaceWith(y,y,f.type,f.marks))return n.replace(s.before(g),b?r.after(g):t,new A(va(o.content,0,o.openStart,h),h,o.openEnd))}}let u=n.steps.length;for(let p=i.length-1;p>=0&&(n.replace(e,t,o),!(n.steps.length>u));p--){let h=i[p];h<0||(e=s.before(h),t=r.after(h))}}function va(n,e,t,o,s){if(e<t){let r=n.firstChild;n=n.replaceChild(0,r.copy(va(r.content,e+1,t,o,r)))}if(e>o){let r=s.contentMatchAt(0),i=r.fillBefore(n).append(n);n=i.append(r.matchFragment(i).fillBefore(T.empty,!0))}return n}function _f(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=$f(n.doc,e,o.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new A(T.from(o),0,0))}function Gf(n,e,t){let o=n.doc.resolve(e),s=n.doc.resolve(t),r=xa(o,s);for(let i=0;i<r.length;i++){let l=r[i],a=i==r.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 i=1;i<=o.depth&&i<=s.depth;i++)if(e-o.start(i)==o.depth-i&&t>o.end(i)&&s.end(i)-t!=s.depth-i&&o.start(i-1)==s.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),s.index(i-1)))return n.delete(o.before(i),t);n.delete(e,t)}function xa(n,e){let t=[],o=Math.min(n.depth,e.depth);for(let s=o;s>=0;s--){let r=n.start(s);if(r<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;(r==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==r-1)&&t.push(s)}return t}class dn extends se{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 J.fail("No node at attribute step's position");let o=Object.create(null);for(let r in t.attrs)o[r]=t.attrs[r];o[this.attr]=this.value;let s=t.type.create(o,null,t.marks);return J.fromReplace(e,this.pos,this.pos+1,new A(T.from(s),0,t.isLeaf?0:1))}getMap(){return ye.empty}invert(e){return new dn(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 dn(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 dn(t.pos,t.attr,t.value)}}se.jsonID("attr",dn);class zn extends se{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 J.ok(o)}getMap(){return ye.empty}invert(e){return new zn(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 zn(t.attr,t.value)}}se.jsonID("docAttr",zn);let un=class extends Error{};un=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},un.prototype=Object.create(Error.prototype),un.prototype.constructor=un,un.prototype.name="TransformError";class wa{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ln}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new un(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=A.empty){let s=rr(this.doc,e,t,o);return s&&this.step(s),this}replaceWith(e,t,o){return this.replace(e,t,new A(T.from(o),0,0))}delete(e,t){return this.replace(e,t,A.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,o){return Ff(this,e,t,o),this}replaceRangeWith(e,t,o){return _f(this,e,t,o),this}deleteRange(e,t){return Gf(this,e,t),this}lift(e,t){return Tf(this,e,t),this}join(e,t=1){return Lf(this,e,t),this}wrap(e,t){return Af(this,e,t),this}setBlockType(e,t=e,o,s=null){return Pf(this,e,t,o,s),this}setNodeMarkup(e,t,o=null,s){return Of(this,e,t,o,s),this}setNodeAttribute(e,t,o){return this.step(new dn(e,t,o)),this}setDocAttribute(e,t){return this.step(new zn(e,t)),this}addNodeMark(e,t){return this.step(new ot(e,t)),this}removeNodeMark(e,t){if(!(t instanceof H)){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 an(e,t)),this}split(e,t=1,o){return If(this,e,t,o),this}addMark(e,t,o){return wf(this,e,t,o),this}removeMark(e,t,o){return Cf(this,e,t,o),this}clearIncompatible(e,t,o){return sr(this,e,t,o),this}}const ar=Object.create(null);class D{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new Ca(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=A.empty){let o=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=o,o=o.lastChild;let r=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],d=e.mapping.slice(r);e.replaceRange(d.map(a.pos),d.map(c.pos),l?A.empty:t),l==0&&Ea(e,r,(o?o.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let o=e.steps.length,s=this.ranges;for(let r=0;r<s.length;r++){let{$from:i,$to:l}=s[r],a=e.mapping.slice(o),c=a.map(i.pos),d=a.map(l.pos);r?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),Ea(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let s=e.parent.inlineContent?new z(e):pn(e.node(0),e.parent,e.pos,e.index(),t,o);if(s)return s;for(let r=e.depth-1;r>=0;r--){let i=t<0?pn(e.node(0),e.node(r),e.before(r+1),e.index(r),t,o):pn(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,o);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new be(e.node(0))}static atStart(e){return pn(e,e,0,0,1)||new be(e)}static atEnd(e){return pn(e,e,e.content.size,e.childCount,-1)||new be(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let o=ar[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 ar)throw new RangeError("Duplicate use of selection JSON ID "+e);return ar[e]=t,t.prototype.jsonID=e,t}getBookmark(){return z.between(this.$anchor,this.$head).getBookmark()}}D.prototype.visible=!0;class Ca{constructor(e,t){this.$from=e,this.$to=t}}let ka=!1;function Ta(n){!ka&&!n.parent.inlineContent&&(ka=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class z extends D{constructor(e,t=e){Ta(e),Ta(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 D.near(o);let s=e.resolve(t.map(this.anchor));return new z(s.parent.inlineContent?s:o,o)}replace(e,t=A.empty){if(super.replace(e,t),t==A.empty){let o=this.$from.marksAcross(this.$to);o&&e.ensureMarks(o)}}eq(e){return e instanceof z&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Go(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 z(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 r=D.findFrom(t,o,!0)||D.findFrom(t,-o,!0);if(r)t=r.$head;else return D.near(t,o)}return e.parent.inlineContent||(s==0?e=t:(e=(D.findFrom(e,-o,!0)||D.findFrom(e,o,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new z(e,t)}}D.jsonID("text",z);class Go{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Go(e.map(this.anchor),e.map(this.head))}resolve(e){return z.between(e.resolve(this.anchor),e.resolve(this.head))}}class R extends D{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),r=e.resolve(s);return o?D.near(r):new R(r)}content(){return new A(T.from(this.node),0,0)}eq(e){return e instanceof R&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new cr(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new R(e.resolve(t.anchor))}static create(e,t){return new R(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}R.prototype.visible=!1,D.jsonID("node",R);class cr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new Go(o,o):new cr(o)}resolve(e){let t=e.resolve(this.anchor),o=t.nodeAfter;return o&&R.isSelectable(o)?new R(t):D.near(t)}}class be extends D{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=A.empty){if(t==A.empty){e.delete(0,e.doc.content.size);let o=D.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new be(e)}map(e){return new be(e)}eq(e){return e instanceof be}getBookmark(){return Wf}}D.jsonID("all",be);const Wf={map(){return this},resolve(n){return new be(n)}};function pn(n,e,t,o,s,r=!1){if(e.inlineContent)return z.create(n,t);for(let i=o-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let l=e.child(i);if(l.isAtom){if(!r&&R.isSelectable(l))return R.create(n,t-(s<0?l.nodeSize:0))}else{let a=pn(n,l,t+s,s<0?l.childCount:0,s,r);if(a)return a}t+=l.nodeSize*s}return null}function Ea(n,e,t){let o=n.steps.length-1;if(o<e)return;let s=n.steps[o];if(!(s instanceof re||s instanceof te))return;let r=n.mapping.maps[o],i;r.forEach((l,a,c,d)=>{i==null&&(i=d)}),n.setSelection(D.near(n.doc.resolve(i),t))}const Ma=1,Wo=2,Aa=4;class jf extends wa{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|Ma)&~Wo,this.storedMarks=null,this}get selectionSet(){return(this.updated&Ma)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Wo,this}ensureMarks(e){return H.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&Wo)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Wo,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)||H.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 r=this.storedMarks;if(!r){let i=this.doc.resolve(t);r=o==t?i.marks():i.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(t,o,s.text(e,r)),this.selection.empty||this.setSelection(D.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|=Aa,this}get scrolledIntoView(){return(this.updated&Aa)>0}}function Pa(n,e){return!e||!n?n:n.bind(e)}class Bn{constructor(e,t,o){this.name=e,this.init=Pa(t.init,o),this.apply=Pa(t.apply,o)}}const qf=[new Bn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Bn("selection",{init(n,e){return n.selection||D.atStart(e.doc)},apply(n){return n.selection}}),new Bn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new Bn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class dr{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=qf.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 Bn(o.key,o.spec.state,o))})}}class hn{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 r=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=s?s[i].n:0,c=s?s[i].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,o);if(d&&o.filterTransaction(d,i)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<i?{state:o,n:t.length}:{state:this,n:0})}t.push(d),o=o.applyInner(d),r=!0}s&&(s[i]={state:o,n:t.length})}}if(!r)return{state:o,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new hn(this.config),o=this.config.fields;for(let s=0;s<o.length;s++){let r=o[s];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new jf(this)}static create(e){let t=new dr(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new hn(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 dr(this.schema,e.plugins),o=t.fields,s=new hn(t);for(let r=0;r<o.length;r++){let i=o[r].name;s[i]=this.hasOwnProperty(i)?this[i]:o[r].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],r=s.spec.state;r&&r.toJSON&&(t[o]=r.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 dr(e.schema,e.plugins),r=new hn(s);return s.fields.forEach(i=>{if(i.name=="doc")r.doc=Pt.fromJSON(e.schema,t.doc);else if(i.name=="selection")r.selection=D.fromJSON(r.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(r.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==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){r[i.name]=c.fromJSON.call(a,e,t[l],r);return}}r[i.name]=i.init(e,r)}}),r}}function Na(n,e,t){for(let o in n){let s=n[o];s instanceof Function?s=s.bind(e):o=="handleDOMEvents"&&(s=Na(s,e,{})),t[o]=s}return t}class fn{constructor(e){this.spec=e,this.props={},e.props&&Na(e.props,this,this.props),this.key=e.key?e.key.key:Oa("plugin")}getState(e){return e[this.key]}}const ur=Object.create(null);function Oa(n){return n in ur?n+"$"+ ++ur[n]:(ur[n]=0,n+"$")}class Vn{constructor(e="key"){this.key=Oa(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ia=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Uf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Kf=(n,e,t)=>{let o=Uf(n,t);if(!o)return!1;let s=Ra(o);if(!s){let i=o.blockRange(),l=i&&Fo(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let r=s.nodeBefore;if(Va(n,s,e,-1))return!0;if(o.parent.content.size==0&&(mn(r,"end")||R.isSelectable(r)))for(let i=o.depth;;i--){let l=rr(n.doc,o.before(i),o.after(i),A.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(mn(r,"end")?D.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):R.create(a.doc,s.pos-r.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||o.node(i-1).childCount>1)break}return r.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos-r.nodeSize,s.pos).scrollIntoView()),!0):!1};function mn(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 Jf=(n,e,t)=>{let{$head:o,empty:s}=n.selection,r=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):o.parentOffset>0)return!1;r=Ra(o)}let i=r&&r.nodeBefore;return!i||!R.isSelectable(i)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,r.pos-i.nodeSize)).scrollIntoView()),!0)};function Ra(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 Zf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Yf=(n,e,t)=>{let o=Zf(n,t);if(!o)return!1;let s=Da(o);if(!s)return!1;let r=s.nodeAfter;if(Va(n,s,e,1))return!0;if(o.parent.content.size==0&&(mn(r,"start")||R.isSelectable(r))){let i=rr(n.doc,o.before(),o.after(),A.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(mn(r,"start")?D.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):R.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return r.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+r.nodeSize).scrollIntoView()),!0):!1},Xf=(n,e,t)=>{let{$head:o,empty:s}=n.selection,r=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):o.parentOffset<o.parent.content.size)return!1;r=Da(o)}let i=r&&r.nodeAfter;return!i||!R.isSelectable(i)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,r.pos)).scrollIntoView()),!0)};function Da(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 Qf=(n,e)=>{let{$head:t,$anchor:o}=n.selection;return!t.parent.type.spec.code||!t.sameParent(o)?!1:(e&&e(n.tr.insertText(`
804
+ `).scrollIntoView()),!0)};function pr(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 La=(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),r=t.indexAfter(-1),i=pr(s.contentMatchAt(r));if(!i||!s.canReplaceWith(r,r,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(D.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},em=(n,e)=>{let t=n.selection,{$from:o,$to:s}=t;if(t instanceof be||o.parent.inlineContent||s.parent.inlineContent)return!1;let r=pr(s.parent.contentMatchAt(s.indexAfter()));if(!r||!r.isTextblock)return!1;if(e){let i=(!o.parentOffset&&s.index()<s.parent.childCount?o:s).pos,l=n.tr.insert(i,r.createAndFill());l.setSelection(z.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},$a=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let r=t.before();if(cn(n.doc,r))return e&&e(n.tr.split(r).scrollIntoView()),!0}let o=t.blockRange(),s=o&&Fo(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)};function za(n){return(e,t)=>{let{$from:o,$to:s}=e.selection;if(e.selection instanceof R&&e.selection.node.isBlock)return!o.parentOffset||!cn(e.doc,o.pos)?!1:(t&&t(e.tr.split(o.pos).scrollIntoView()),!0);if(!o.depth)return!1;let r=[],i,l,a=!1,c=!1;for(let h=o.depth;;h--)if(o.node(h).isBlock){a=o.end(h)==o.pos+(o.depth-h),c=o.start(h)==o.pos-(o.depth-h),l=pr(o.node(h-1).contentMatchAt(o.indexAfter(h-1)));let m=n&&n(s.parent,a,o);r.unshift(m||(a&&l?{type:l}:null)),i=h;break}else{if(h==1)return!1;r.unshift(null)}let d=e.tr;(e.selection instanceof z||e.selection instanceof be)&&d.deleteSelection();let u=d.mapping.map(o.pos),p=cn(d.doc,u,r.length,r);if(p||(r[0]=l?{type:l}:null,p=cn(d.doc,u,r.length,r)),d.split(u,r.length,r),!a&&c&&o.node(i).type!=l){let h=d.mapping.map(o.before(i)),f=d.doc.resolve(h);l&&o.node(i-1).canReplaceWith(f.index(),f.index()+1,l)&&d.setNodeMarkup(d.mapping.map(o.before(i)),l)}return t&&t(d.scrollIntoView()),!0}}const tm=za(),Ba=(n,e)=>(e&&e(n.tr.setSelection(new be(n.doc))),!0);function nm(n,e,t){let o=e.nodeBefore,s=e.nodeAfter,r=e.index();return!o||!s||!o.type.compatibleContent(s.type)?!1:!o.content.size&&e.parent.canReplace(r-1,r)?(t&&t(n.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(r,r+1)||!(s.isTextblock||_o(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Va(n,e,t,o){let s=e.nodeBefore,r=e.nodeAfter,i,l,a=s.type.spec.isolating||r.type.spec.isolating;if(!a&&nm(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=s.contentMatchAt(s.childCount)).findWrapping(r.type))&&l.matchType(i[0]||r.type).validEnd){if(t){let h=e.pos+r.nodeSize,f=T.empty;for(let b=i.length-1;b>=0;b--)f=T.from(i[b].create(null,f));f=T.from(s.copy(f));let m=n.tr.step(new te(e.pos-1,h,e.pos,h,new A(f,1,0),i.length,!0)),g=m.doc.resolve(h+2*i.length);g.nodeAfter&&g.nodeAfter.type==s.type&&_o(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=r.type.spec.isolating||o>0&&a?null:D.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),p=u&&Fo(u);if(p!=null&&p>=e.depth)return t&&t(n.tr.lift(u,p).scrollIntoView()),!0;if(c&&mn(r,"start",!0)&&mn(s,"end")){let h=s,f=[];for(;f.push(h),!h.isTextblock;)h=h.lastChild;let m=r,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let b=T.empty;for(let y=f.length-1;y>=0;y--)b=T.from(f[y].copy(b));let C=n.tr.step(new te(e.pos-f.length,e.pos+r.nodeSize,e.pos+g,e.pos+r.nodeSize-g,new A(b,f.length,0),0,!0));t(C.scrollIntoView())}return!0}}return!1}function Ha(n){return function(e,t){let o=e.selection,s=n<0?o.$from:o.$to,r=s.depth;for(;s.node(r).isInline;){if(!r)return!1;r--}return s.node(r).isTextblock?(t&&t(e.tr.setSelection(z.create(e.doc,n<0?s.start(r):s.end(r)))),!0):!1}}const om=Ha(-1),sm=Ha(1);function rm(n,e=null){return function(t,o){let s=!1;for(let r=0;r<t.selection.ranges.length&&!s;r++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[r];t.doc.nodesBetween(i,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 r=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];r.setBlockType(l,a,n,e)}o(r.scrollIntoView())}return!0}}function im(n,e,t,o){for(let s=0;s<e.length;s++){let{$from:r,$to:i}=e[s],l=r.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(r.pos,i.pos,(a,c)=>{if(l||!o)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function It(n,e=null,t){let o=t!==!1;return function(s,r){let{empty:i,$cursor:l,ranges:a}=s.selection;if(i&&!l||!im(s.doc,a,n,o))return!1;if(r)if(l)n.isInSet(s.storedMarks||l.marks())?r(s.tr.removeStoredMark(n)):r(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:p,$to:h}=a[u];if(!c)d.removeMark(p.pos,h.pos,n);else{let f=p.pos,m=h.pos,g=p.nodeAfter,b=h.nodeBefore,C=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,y=b&&b.isText?/\s*$/.exec(b.text)[0].length:0;f+C<m&&(f+=C,m-=y),d.addMark(f,m,n.create(e))}}r(d.scrollIntoView())}return!0}}function Hn(...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 hr=Hn(Ia,Kf,Jf),Fa=Hn(Ia,Yf,Xf);const je={Enter:Hn(Qf,em,$a,tm),"Mod-Enter":La,Backspace:hr,"Mod-Backspace":hr,"Shift-Backspace":hr,Delete:Fa,"Mod-Delete":Fa,"Mod-a":Ba},_a={"Ctrl-h":je.Backspace,"Alt-Backspace":je["Mod-Backspace"],"Ctrl-d":je.Delete,"Ctrl-Alt-Backspace":je["Mod-Delete"],"Alt-Delete":je["Mod-Delete"],"Alt-d":je["Mod-Delete"],"Ctrl-a":om,"Ctrl-e":sm};for(let n in je)_a[n]=je[n];const lm=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?_a:je;var jo=200,Y=function(){};Y.prototype.append=function(e){return e.length?(e=Y.from(e),!this.length&&e||e.length<jo&&this.leafAppend(e)||this.length<jo&&e.leafPrepend(this)||this.appendInner(e)):this},Y.prototype.prepend=function(e){return e.length?Y.from(e).append(this):this},Y.prototype.appendInner=function(e){return new am(this,e)},Y.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Y.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Y.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Y.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)},Y.prototype.map=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length);var s=[];return this.forEach(function(r,i){return s.push(e(r,i))},t,o),s},Y.from=function(e){return e instanceof Y?e:e&&e.length?new Ga(e):Y.empty};var Ga=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,r){return s==0&&r==this.length?this:new e(this.values.slice(s,r))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,r,i,l){for(var a=r;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,r,i,l){for(var a=r-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=jo)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=jo)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}(Y);Y.empty=new Ga([]);var am=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,r,i){var l=this.left.length;if(s<l&&this.left.forEachInner(o,s,Math.min(r,l),i)===!1||r>l&&this.right.forEachInner(o,Math.max(s-l,0),Math.min(this.length,r)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,r,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(o,s-l,Math.max(r,l)-l,i+l)===!1||r<l&&this.left.forEachInvertedInner(o,Math.min(s,l),r,i)===!1)return!1},e.prototype.sliceInner=function(o,s){if(o==0&&s==this.length)return this;var r=this.left.length;return s<=r?this.left.slice(o,s):o>=r?this.right.slice(o-r,s-r):this.left.slice(o,r).append(this.right.slice(0,s-r))},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}(Y);const cm=500;class Ee{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,r;t&&(s=this.remapping(o,this.items.length),r=s.maps.length);let i=e.tr,l,a,c=[],d=[];return this.items.forEach((u,p)=>{if(!u.step){s||(s=this.remapping(o,p+1),r=s.maps.length),r--,d.push(u);return}if(s){d.push(new $e(u.map));let h=u.step.map(s.slice(r)),f;h&&i.maybeStep(h).doc&&(f=i.mapping.maps[i.mapping.maps.length-1],c.push(new $e(f,void 0,void 0,c.length+d.length))),r--,f&&s.appendMap(f,r)}else i.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(r)):u.selection,a=new Ee(this.items.slice(0,o).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,o,s){let r=[],i=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]),p=new $e(e.mapping.maps[d],u,t),h;(h=a&&a.merge(p))&&(p=h,d?r.pop():l=l.slice(0,l.length-1)),r.push(p),t&&(i++,t=void 0),s||(a=p)}let c=i-o.depth;return c>um&&(l=dm(l,c),i-=c),new Ee(l.append(r),i)}remapping(e,t){let o=new ln;return this.items.forEach((s,r)=>{let i=s.mirrorOffset!=null&&r-s.mirrorOffset>=e?o.maps.length-s.mirrorOffset:void 0;o.appendMap(s.map,i)},e,t),o}addMaps(e){return this.eventCount==0?this:new Ee(this.items.append(e.map(t=>new $e(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],s=Math.max(0,this.items.length-t),r=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},s);let a=t;this.items.forEach(p=>{let h=r.getMirror(--a);if(h==null)return;i=Math.min(i,h);let f=r.maps[h];if(p.step){let m=e.steps[h].invert(e.docs[h]),g=p.selection&&p.selection.map(r.slice(a+1,h));g&&l++,o.push(new $e(f,m,g))}else o.push(new $e(f))},s);let c=[];for(let p=t;p<i;p++)c.push(new $e(r.maps[p]));let d=this.items.slice(0,s).append(c).append(o),u=new Ee(d,l);return u.emptyItemCount()>cm&&(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=[],r=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&r++;else if(i.step){let a=i.step.map(t.slice(o)),c=a&&a.getMap();if(o--,c&&t.appendMap(c,o),a){let d=i.selection&&i.selection.map(t.slice(o));d&&r++;let u=new $e(c.invert(),a,d),p,h=s.length-1;(p=s.length&&s[h].merge(u))?s[h]=p:s.push(u)}}else i.map&&o--},this.items.length,0),new Ee(Y.from(s.reverse()),r)}}Ee.empty=new Ee(Y.empty,0);function dm(n,e){let t;return n.forEach((o,s)=>{if(o.selection&&e--==0)return t=s,!1}),n.slice(t)}class $e{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 $e(t.getMap().invert(),t,this.selection)}}}class st{constructor(e,t,o,s,r){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=s,this.prevComposition=r}}const um=20;function pm(n,e,t,o){let s=t.getMeta(Rt),r;if(s)return s.historyState;t.getMeta(mm)&&(n=new st(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(Rt))return i.getMeta(Rt).redo?new st(n.done.addTransform(t,void 0,o,qo(e)),n.undone,Wa(t.mapping.maps),n.prevTime,n.prevComposition):new st(n.done,n.undone.addTransform(t,void 0,o,qo(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!hm(t,n.prevRanges)),c=i?fr(n.prevRanges,t.mapping):Wa(t.mapping.maps);return new st(n.done.addTransform(t,a?e.selection.getBookmark():void 0,o,qo(e)),Ee.empty,c,t.time,l??n.prevComposition)}else return(r=t.getMeta("rebased"))?new st(n.done.rebased(t,r),n.undone.rebased(t,r),fr(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new st(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),fr(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function hm(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((o,s)=>{for(let r=0;r<e.length;r+=2)o<=e[r+1]&&s>=e[r]&&(t=!0)}),t}function Wa(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,s,r,i)=>e.push(r,i));return e}function fr(n,e){if(!n)return null;let t=[];for(let o=0;o<n.length;o+=2){let s=e.map(n[o],1),r=e.map(n[o+1],-1);s<=r&&t.push(s,r)}return t}function fm(n,e,t){let o=qo(e),s=Rt.get(e).spec.config,r=(t?n.undone:n.done).popEvent(e,o);if(!r)return null;let i=r.selection.resolve(r.transform.doc),l=(t?n.done:n.undone).addTransform(r.transform,e.selection.getBookmark(),s,o),a=new st(t?l:r.remaining,t?r.remaining:l,null,0,-1);return r.transform.setSelection(i).setMeta(Rt,{redo:t,historyState:a})}let mr=!1,ja=null;function qo(n){let e=n.plugins;if(ja!=e){mr=!1,ja=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){mr=!0;break}}return mr}const Rt=new Vn("history"),mm=new Vn("closeHistory");function gm(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new fn({key:Rt,state:{init(){return new st(Ee.empty,Ee.empty,null,0,-1)},apply(e,t,o){return pm(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,s=o=="historyUndo"?Ua:o=="historyRedo"?gr:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function qa(n,e){return(t,o)=>{let s=Rt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(o){let r=fm(s,t,n);r&&o(e?r.scrollIntoView():r)}return!0}}const Ua=qa(!1,!0),gr=qa(!0,!0);for(var rt={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:"'"},Uo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ym=typeof navigator<"u"&&/Mac/.test(navigator.platform),bm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ne=0;ne<10;ne++)rt[48+ne]=rt[96+ne]=String(ne);for(var ne=1;ne<=24;ne++)rt[ne+111]="F"+ne;for(var ne=65;ne<=90;ne++)rt[ne]=String.fromCharCode(ne+32),Uo[ne]=String.fromCharCode(ne);for(var yr in rt)Uo.hasOwnProperty(yr)||(Uo[yr]=rt[yr]);function Sm(n){var e=ym&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||bm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Uo:rt)[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 vm=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function xm(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let o,s,r,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!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))r=!0;else if(/^mod$/i.test(a))vm?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return o&&(t="Alt-"+t),s&&(t="Ctrl-"+t),i&&(t="Meta-"+t),r&&(t="Shift-"+t),t}function wm(n){let e=Object.create(null);for(let t in n)e[xm(t)]=n[t];return e}function br(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 Sr(n){return new fn({props:{handleKeyDown:Ka(n)}})}function Ka(n){let e=wm(n);return function(t,o){let s=Sm(o),r,i=e[br(s,o)];if(i&&i(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(o.shiftKey){let l=e[br(s,o,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((o.shiftKey||o.altKey||o.metaKey||s.charCodeAt(0)>127)&&(r=rt[o.keyCode])&&r!=s){let l=e[br(r,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function Ja(n,e=null){return function(t,o){let{$from:s,$to:r}=t.selection,i=s.blockRange(r),l=!1,a=i;if(!i)return!1;if(i.depth>=2&&s.node(i.depth-1).type.compatibleContent(n)&&i.startIndex==0){if(s.index(i.depth-1)==0)return!1;let d=t.doc.resolve(i.start-2);a=new Ro(d,d,i.depth),i.endIndex<i.parent.childCount&&(i=new Ro(s,t.doc.resolve(r.end(i.depth)),i.depth)),l=!0}let c=fa(a,n,e,i);return c?(o&&o(Cm(t.tr,i,c,l,n).scrollIntoView()),!0):!1}}function Cm(n,e,t,o,s){let r=T.empty;for(let d=t.length-1;d>=0;d--)r=T.from(t[d].type.create(t[d].attrs,r));n.step(new te(e.start-(o?2:0),e.end,e.start,e.end,new A(r,0,0),t.length,!0));let i=0;for(let d=0;d<t.length;d++)t[d].type==s&&(i=d+1);let l=t.length-i,a=e.start+t.length-(o?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,p=!0;d<u;d++,p=!1)!p&&cn(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function km(n,e){return function(t,o){let{$from:s,$to:r,node:i}=t.selection;if(i&&i.isBlock||s.depth<2||!s.sameParent(r))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=T.empty,p=s.index(-1)?1:s.index(-2)?2:3;for(let b=s.depth-p;b>=s.depth-3;b--)u=T.from(s.node(b).copy(u));let h=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3;u=u.append(T.from(n.createAndFill()));let f=s.before(s.depth-(p-1)),m=t.tr.replace(f,s.after(-h),new A(u,4-p,0)),g=-1;m.doc.nodesBetween(f,m.doc.content.size,(b,C)=>{if(g>-1)return!1;b.isTextblock&&b.content.size==0&&(g=C+1)}),g>-1&&m.setSelection(D.near(m.doc.resolve(g))),o(m.scrollIntoView())}return!0}let a=r.pos==s.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(s.pos,r.pos),d=a?[null,{type:a}]:void 0;return cn(c.doc,s.pos,2,d)?(o&&o(c.split(s.pos,2,d).scrollIntoView()),!0):!1}}function vr(n){return function(e,t){let{$from:o,$to:s}=e.selection,r=o.blockRange(s,i=>i.childCount>0&&i.firstChild.type==n);return r?t?o.node(r.depth-1).type==n?Tm(e,t,n,r):Em(e,t,r):!0:!1}}function Tm(n,e,t,o){let s=n.tr,r=o.end,i=o.$to.end(o.depth);r<i&&(s.step(new te(r-1,i,r,i,new A(T.from(t.create(null,o.parent.copy())),1,0),1,!0)),o=new Ro(s.doc.resolve(o.$from.pos),s.doc.resolve(i),o.depth));const l=Fo(o);if(l==null)return!1;s.lift(o,l);let a=s.mapping.map(r,-1)-1;return _o(s.doc,a)&&s.join(a),e(s.scrollIntoView()),!0}function Em(n,e,t){let o=n.tr,s=t.parent;for(let h=t.end,f=t.endIndex-1,m=t.startIndex;f>m;f--)h-=s.child(f).nodeSize,o.delete(h-1,h+1);let r=o.doc.resolve(t.start),i=r.nodeAfter;if(o.mapping.map(t.end)!=t.start+r.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=r.node(-1),d=r.index(-1);if(!c.canReplace(d+(l?0:1),d+1,i.content.append(a?T.empty:T.from(s))))return!1;let u=r.pos,p=u+i.nodeSize;return o.step(new te(u-(l?1:0),p+(a?1:0),u+1,p-1,new A((l?T.empty:T.from(s.copy(T.empty))).append(a?T.empty:T.from(s.copy(T.empty))),l?0:1,a?0:1),l?0:1)),e(o.scrollIntoView()),!0}function Mm(n){return function(e,t){let{$from:o,$to:s}=e.selection,r=o.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!r)return!1;let i=r.startIndex;if(i==0)return!1;let l=r.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=T.from(c?n.create():null),u=new A(T.from(n.create(null,T.from(l.type.create(null,d)))),c?3:1,0),p=r.start,h=r.end;t(e.tr.step(new te(p-(c?3:1),h,p,h,u,1,!0)).scrollIntoView())}return!0}}const oe=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Fn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let xr=null;const qe=function(n,e,t){let o=xr||(xr=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o},Am=function(){xr=null},Dt=function(n,e,t,o){return t&&(Za(n,e,t,o,-1)||Za(n,e,t,o,1))},Pm=/^(img|br|input|textarea|hr)$/i;function Za(n,e,t,o,s){for(;;){if(n==t&&e==o)return!0;if(e==(s<0?0:xe(n))){let r=n.parentNode;if(!r||r.nodeType!=1||_n(n)||Pm.test(n.nodeName)||n.contentEditable=="false")return!1;e=oe(n)+(s<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.contentEditable=="false")return!1;e=s<0?xe(n):0}else return!1}}function xe(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Nm(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=xe(n)}else if(n.parentNode&&!_n(n))e=oe(n),n=n.parentNode;else return null}}function Om(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&&!_n(n))e=oe(n)+1,n=n.parentNode;else return null}}function Im(n,e,t){for(let o=e==0,s=e==xe(n);o||s;){if(n==t)return!0;let r=oe(n);if(n=n.parentNode,!n)return!1;o=o&&r==0,s=s&&r==xe(n)}}function _n(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 Ko=function(n){return n.focusNode&&Dt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Lt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Rm(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Dm(n,e,t){if(n.caretPositionFromPoint)try{let o=n.caretPositionFromPoint(e,t);if(o)return{node:o.offsetNode,offset:Math.min(xe(o.offsetNode),o.offset)}}catch{}if(n.caretRangeFromPoint){let o=n.caretRangeFromPoint(e,t);if(o)return{node:o.startContainer,offset:Math.min(xe(o.startContainer),o.startOffset)}}}const ze=typeof navigator<"u"?navigator:null,Ya=typeof document<"u"?document:null,it=ze&&ze.userAgent||"",wr=/Edge\/(\d+)/.exec(it),Xa=/MSIE \d/.exec(it),Cr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(it),me=!!(Xa||Cr||wr),lt=Xa?document.documentMode:Cr?+Cr[1]:wr?+wr[1]:0,Me=!me&&/gecko\/(\d+)/i.test(it);Me&&+(/Firefox\/(\d+)/.exec(it)||[0,0])[1];const kr=!me&&/Chrome\/(\d+)/.exec(it),ie=!!kr,Qa=kr?+kr[1]:0,de=!me&&!!ze&&/Apple Computer/.test(ze.vendor),gn=de&&(/Mobile\/\w+/.test(it)||!!ze&&ze.maxTouchPoints>2),we=gn||(ze?/Mac/.test(ze.platform):!1),Lm=ze?/Win/.test(ze.platform):!1,Ae=/Android \d/.test(it),Gn=!!Ya&&"webkitFontSmoothing"in Ya.documentElement.style,$m=Gn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function zm(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 Ue(n,e){return typeof n=="number"?n:n[e]}function Bm(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 ec(n,e,t){let o=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,r=n.dom.ownerDocument;for(let i=t||n.dom;i;i=Fn(i)){if(i.nodeType!=1)continue;let l=i,a=l==r.body,c=a?zm(r):Bm(l),d=0,u=0;if(e.top<c.top+Ue(o,"top")?u=-(c.top-e.top+Ue(s,"top")):e.bottom>c.bottom-Ue(o,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Ue(s,"top")-c.top:e.bottom-c.bottom+Ue(s,"bottom")),e.left<c.left+Ue(o,"left")?d=-(c.left-e.left+Ue(s,"left")):e.right>c.right-Ue(o,"right")&&(d=e.right-c.right+Ue(s,"right")),d||u)if(a)r.defaultView.scrollBy(d,u);else{let p=l.scrollLeft,h=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let f=l.scrollLeft-p,m=l.scrollTop-h;e={left:e.left-f,top:e.top-m,right:e.right-f,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(i).position))break}}function Vm(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),o,s;for(let r=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(r,i);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:tc(n.dom)}}function tc(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=Fn(o));return e}function Hm({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;nc(t,o==0?0:o-e)}function nc(n,e){for(let t=0;t<n.length;t++){let{dom:o,top:s,left:r}=n[t];o.scrollTop!=s+e&&(o.scrollTop=s+e),o.scrollLeft!=r&&(o.scrollLeft=r)}}let yn=null;function Fm(n){if(n.setActive)return n.setActive();if(yn)return n.focus(yn);let e=tc(n);n.focus(yn==null?{get preventScroll(){return yn={preventScroll:!0},!0}}:void 0),yn||(yn=!1,nc(e,0))}function oc(n,e){let t,o=2e8,s,r=0,i=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let p;if(d.nodeType==1)p=d.getClientRects();else if(d.nodeType==3)p=qe(d).getClientRects();else continue;for(let h=0;h<p.length;h++){let f=p[h];if(f.top<=i&&f.bottom>=l){i=Math.max(f.bottom,i),l=Math.min(f.top,l);let m=f.left>e.left?f.left-e.left:f.right<e.left?e.left-f.right:0;if(m<o){t=d,o=m,s=m&&t.nodeType==3?{left:f.right<e.left?f.right:f.left,top:e.top}:e,d.nodeType==1&&m&&(r=u+(e.left>=(f.left+f.right)/2?1:0));continue}}else f.top>e.top&&!a&&f.left<=e.left&&f.right>=e.left&&(a=d,c={left:Math.max(f.left,Math.min(f.right,e.left)),top:f.top});!t&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(r=u+1)}}return!t&&a&&(t=a,s=c,o=0),t&&t.nodeType==3?_m(t,s):!t||o&&t.nodeType==1?{node:n,offset:r}:oc(t,s)}function _m(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 r=at(o,1);if(r.top!=r.bottom&&Tr(e,r))return{node:n,offset:s+(e.left>=(r.left+r.right)/2?1:0)}}return{node:n,offset:0}}function Tr(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Gm(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Wm(n,e,t){let{node:o,offset:s}=oc(e,t),r=-1;if(o.nodeType==1&&!o.firstChild){let i=o.getBoundingClientRect();r=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(o,s,r)}function jm(n,e,t,o){let s=-1;for(let r=e,i=!1;r!=n.dom;){let l=n.docView.nearestDesc(r,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!i&&a.left>o.left||a.top>o.top?s=l.posBefore:(!i&&a.right<o.left||a.bottom<o.top)&&(s=l.posAfter),i=!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}r=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function sc(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)),r=s;;){let i=n.childNodes[r];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Tr(e,c))return sc(i,e,c)}}if((r=(r+1)%o)==s)break}return n}function qm(n,e){let t=n.dom.ownerDocument,o,s=0,r=Dm(t,e.left,e.top);r&&({node:o,offset:s}=r);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!Tr(e,c)||(i=sc(n.dom,e,c),!i))return null}if(de)for(let c=i;o&&c;c=Fn(c))c.draggable&&(o=void 0);if(i=Gm(i,e),o){if(Me&&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;Gn&&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=jm(n,o,s,e))}l==null&&(l=Wm(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function rc(n){return n.top<n.bottom||n.left<n.right}function at(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(rc(o))return o}return Array.prototype.find.call(t,rc)||n.getBoundingClientRect()}const Um=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ic(n,e,t){let{node:o,offset:s,atom:r}=n.docView.domFromPos(e,t<0?-1:1),i=Gn||Me;if(o.nodeType==3)if(i&&(Um.test(o.nodeValue)||(t<0?!s:s==o.nodeValue.length))){let a=at(qe(o,s,s),t);if(Me&&s&&/\s/.test(o.nodeValue[s-1])&&s<o.nodeValue.length){let c=at(qe(o,s-1,s-1),-1);if(c.top==a.top){let d=at(qe(o,s,s+1),-1);if(d.top!=a.top)return Wn(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++,Wn(at(qe(o,a,c),d),d<0)}if(!n.state.doc.resolve(e-(r||0)).parent.inlineContent){if(r==null&&s&&(t<0||s==xe(o))){let a=o.childNodes[s-1];if(a.nodeType==1)return Er(a.getBoundingClientRect(),!1)}if(r==null&&s<xe(o)){let a=o.childNodes[s];if(a.nodeType==1)return Er(a.getBoundingClientRect(),!0)}return Er(o.getBoundingClientRect(),t>=0)}if(r==null&&s&&(t<0||s==xe(o))){let a=o.childNodes[s-1],c=a.nodeType==3?qe(a,xe(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Wn(at(c,1),!1)}if(r==null&&s<xe(o)){let a=o.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?qe(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return Wn(at(c,-1),!0)}return Wn(at(o.nodeType==3?qe(o):o,-t),t>=0)}function Wn(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 Er(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 lc(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 Km(n,e,t){let o=e.selection,s=t=="up"?o.$from:o.$to;return lc(n,e,()=>{let{node:r}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(r,!0);if(!l)break;if(l.node.isBlock){r=l.contentDOM||l.dom;break}r=l.dom.parentNode}let i=ic(n,s.pos,1);for(let l=r.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=qe(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"?i.top-d.top>(d.bottom-i.top)*2:d.bottom-i.bottom>(i.bottom-d.top)*2))return!1}}return!0})}const Jm=/[\u0590-\u08ac]/;function Zm(n,e,t){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let s=o.parentOffset,r=!s,i=s==o.parent.content.size,l=n.domSelection();return l?!Jm.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?r:i:lc(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",t,"character");let h=o.depth?n.docView.domAfterPos(o.before()):n.dom,{focusNode:f,focusOffset:m}=n.domSelectionRange(),g=f&&!h.contains(f.nodeType==1?f:f.parentNode)||a==f&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return p!=null&&(l.caretBidiLevel=p),g}):o.pos==o.start()||o.pos==o.end()}let ac=null,cc=null,dc=!1;function Ym(n,e,t){return ac==e&&cc==t?dc:(ac=e,cc=t,dc=t=="up"||t=="down"?Km(n,e,t):Zm(n,e,t))}const Ce=0,uc=1,$t=2,Be=3;class jn{constructor(e,t,o,s){this.parent=e,this.children=t,this.dom=o,this.contentDOM=s,this.dirty=Ce,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 r,i;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&!((i=r.pmViewDesc)&&i.parent==this);)r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}else{let r,i;if(e==this.contentDOM)r=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.nextSibling}for(;r&&!((i=r.pmViewDesc)&&i.parent==this);)r=r.nextSibling;return r?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>oe(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 r=e;;r=r.parentNode){if(r==this.dom){s=!1;break}if(r.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let r=e;;r=r.parentNode){if(r==this.dom){s=!0;break}if(r.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 r=this.getDesc(s),i;if(r&&(!t||r.node))if(o&&(i=r.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))o=!1;else return r}}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 r=this.getDesc(s);if(r)return r.localPosFromDOM(e,t,o)}return-1}descAt(e){for(let t=0,o=0;t<this.children.length;t++){let s=this.children[t],r=o+s.size;if(o==e&&r!=o){for(;!s.border&&s.children.length;)s=s.children[0];return s}if(e<r)return s.descAt(e-o-s.border);o=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let o=0,s=0;for(let r=0;o<this.children.length;o++){let i=this.children[o],l=r+i.size;if(l>e||i instanceof fc){s=e-r;break}r=l}if(s)return this.children[o].domFromPos(s-this.children[o].border,t);for(let r;o&&!(r=this.children[o-1]).size&&r instanceof pc&&r.side>=0;o--);if(t<=0){let r,i=!0;for(;r=o?this.children[o-1]:null,!(!r||r.dom.parentNode==this.contentDOM);o--,i=!1);return r&&t&&i&&!r.border&&!r.domAtom?r.domFromPos(r.size,t):{node:this.contentDOM,offset:r?oe(r.dom)+1:0}}else{let r,i=!0;for(;r=o<this.children.length?this.children[o]:null,!(!r||r.dom.parentNode==this.contentDOM);o++,i=!1);return r&&i&&!r.border&&!r.domAtom?r.domFromPos(0,t):{node:this.contentDOM,offset:r?oe(r.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,r=-1;for(let i=o,l=0;;l++){let a=this.children[l],c=i+a.size;if(s==-1&&e<=c){let d=i+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=i;for(let u=l;u>0;u--){let p=this.children[u-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){s=oe(p.dom)+1;break}e-=p.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)){r=oe(u.dom);break}t+=u.size}r==-1&&(r=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:r}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset: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 r=Math.min(e,t),i=Math.max(e,t);for(let h=0,f=0;h<this.children.length;h++){let m=this.children[h],g=f+m.size;if(r>f&&i<g)return m.setSelection(e-f-m.border,t-f-m.border,o,s);f=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((Me||de)&&e==t){let{node:h,offset:f}=l;if(h.nodeType==3){if(u=!!(f&&h.nodeValue[f-1]==`
805
+ `),u&&f==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:oe(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=h.childNodes[f-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Me&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||u&&de)&&Dt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Dt(a.node,a.offset,d.focusNode,d.focusOffset))return;let p=!1;if((c.extend||e==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),p=!0}catch{}}if(!p){if(e>t){let f=l;l=a,a=f}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let o=0,s=0;s<this.children.length;s++){let r=this.children[s],i=o+r.size;if(o==i?e<=i&&t>=o:e<i&&t>o){let l=o+r.border,a=i-r.border;if(e>=l&&t<=a){this.dirty=e==o||t==i?$t:uc,e==l&&t==a&&(r.contentLost||r.dom.parentNode!=this.contentDOM)?r.dirty=Be:r.markDirty(e-l,t-l);return}else r.dirty=r.dom==r.contentDOM&&r.dom.parentNode==this.contentDOM&&!r.children.length?$t:Be}o=i}this.dirty=$t}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?$t:uc;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class pc extends jn{constructor(e,t,o,s){let r,i=t.type.toDOM;if(typeof i=="function"&&(i=i(o,()=>{if(!r)return s;if(r.parent)return r.parent.posBeforeChild(r)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==Ce&&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 Xm extends jn{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 zt extends jn{constructor(e,t,o,s,r){super(e,[],o,s),this.mark=t,this.spec=r}static create(e,t,o,s){let r=s.nodeViews[t.type.name],i=r&&r(t,s,o);return(!i||!i.dom)&&(i=Ot.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new zt(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Be||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Be&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ce){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=Ce}}slice(e,t,o){let s=zt.create(this.parent,this.mark,!0,o),r=this.children,i=this.size;t<i&&(r=Ar(r,t,i,o)),e>0&&(r=Ar(r,0,e,o));for(let l=0;l<r.length;l++)r[l].parent=s;return s.children=r,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class ct extends jn{constructor(e,t,o,s,r,i,l,a,c){super(e,[],r,i),this.node=t,this.outerDeco=o,this.innerDeco=s,this.nodeDOM=l}static create(e,t,o,s,r,i){let l=r.nodeViews[t.type.name],a,c=l&&l(t,r,()=>{if(!a)return i;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}=Ot.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 p=d;return d=yc(d,o,t),c?a=new Qm(e,t,o,s,d,u||null,p,c,r,i+1):t.isText?new Jo(e,t,o,s,d,p,r):new ct(e,t,o,s,d,u||null,p,r,i+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=()=>T.empty)}return e}matchesNode(e,t,o){return this.dirty==Ce&&e.eq(this.node)&&Zo(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,r=e.composing?this.localCompositionInfo(e,t):null,i=r&&r.pos>-1?r:null,l=r&&r.pos<0,a=new tg(this,i&&i.node,e);sg(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?H.none:this.node.child(d).marks,o,e),a.placeWidget(c,e,s)},(c,d,u,p)=>{a.syncToMarks(c.marks,o,e);let h;a.findNodeMatch(c,d,u,p)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(r.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,p,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==$t)&&(i&&this.protectLocalComposition(e,i),mc(this.contentDOM,this.children,e),gn&&rg(this.dom))}localCompositionInfo(e,t){let{from:o,to:s}=e.state.selection;if(!(e.state.selection instanceof z)||o<t||s>t+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let i=r.nodeValue,l=ig(this.node.content,i,o-t,s-t);return l<0?null:{node:r,pos:l,text:i}}else return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:o,text:s}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let i=new Xm(this,r,t,s);e.input.compositionNodes.push(i),this.children=Ar(this.children,o,o+s.length,e,i)}update(e,t,o,s){return this.dirty==Be||!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=Ce}updateOuterDeco(e){if(Zo(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=gc(this.dom,this.nodeDOM,Mr(this.outerDeco,this.node,t),Mr(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 hc(n,e,t,o,s){yc(o,e,n);let r=new ct(void 0,n,e,t,o,o,o,s,0);return r.contentDOM&&r.updateChildren(s,0),r}class Jo extends ct{constructor(e,t,o,s,r,i,l){super(e,t,o,s,r,null,i,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==Be||this.dirty!=Ce&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ce||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=Ce,!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),r=document.createTextNode(s.text);return new Jo(this.parent,s,this.outerDeco,this.innerDeco,r,r,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Be)}get domAtom(){return!1}isText(e){return this.node.text==e}}class fc extends jn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ce&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Qm extends ct{constructor(e,t,o,s,r,i,l,a,c,d){super(e,t,o,s,r,i,l,c,d),this.spec=a}update(e,t,o,s){if(this.dirty==Be)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,o);return r&&this.updateInner(e,t,o,s),r}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 mc(n,e,t){let o=n.firstChild,s=!1;for(let r=0;r<e.length;r++){let i=e[r],l=i.dom;if(l.parentNode==n){for(;l!=o;)o=bc(o),s=!0;o=o.nextSibling}else s=!0,n.insertBefore(l,o);if(i instanceof zt){let a=o?o.previousSibling:n.lastChild;mc(i.contentDOM,i.children,t),o=a?a.nextSibling:n.firstChild}}for(;o;)o=bc(o),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const qn=function(n){n&&(this.nodeName=n)};qn.prototype=Object.create(null);const Bt=[new qn];function Mr(n,e,t){if(n.length==0)return Bt;let o=t?Bt[0]:new qn,s=[o];for(let r=0;r<n.length;r++){let i=n[r].type.attrs;if(i){i.nodeName&&s.push(o=new qn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&s.length==1&&s.push(o=new qn(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 gc(n,e,t,o){if(t==Bt&&o==Bt)return e;let s=e;for(let r=0;r<o.length;r++){let i=o[r],l=t[r];if(r){let a;l&&l.nodeName==i.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=Bt[0]),s=a}eg(s,l||Bt[0],i)}return s}function eg(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 r=0;r<o.length;r++)s.indexOf(o[r])==-1&&n.classList.remove(o[r]);for(let r=0;r<s.length;r++)o.indexOf(s[r])==-1&&n.classList.add(s[r]);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 yc(n,e,t){return gc(n,n,Bt,Mr(e,t,n.nodeType!=1))}function Zo(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 bc(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class tg{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=ng(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,r=this.stack.length>>1,i=Math.min(r,e.length);for(;s<i&&(s==r-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<r;)this.destroyRest(),this.top.dirty=Ce,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[r])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=zt.create(this.top,e[r],t,o);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,o,s){let r=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,o))r=this.top.children.indexOf(i,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)){r=l;break}}return r<0?!1:(this.destroyBetween(this.index,r),this.index++,!0)}updateNodeAt(e,t,o,s,r){let i=this.top.children[s];return i.dirty==Be&&i.dom==i.contentDOM&&(i.dirty=$t),i.update(e,t,o,r)?(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,r,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof ct){let c=this.preMatch.matched.get(a);if(c!=null&&c!=r)return!1;let d=a.dom,u,p=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Be&&Zo(t,a.outerDeco));if(!p&&a.update(e,t,o,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!p&&(u=this.recreateWrapper(a,e,t,o,s,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=$t,u.updateChildren(s,i+1),u.dirty=Ce),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,s,r,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Zo(o,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=ct.create(this.top,t,o,s,r,i);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,r){let i=ct.create(this.top,e,t,o,s,r);i.contentDOM&&i.updateChildren(s,r+1),this.top.children.splice(this.index++,0,i),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 r=new pc(this.top,e,t,o);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof zt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Jo)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((de||ie)&&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 fc(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 ng(n,e){let t=e,o=t.children.length,s=n.childCount,r=new Map,i=[];e:for(;s>0;){let l;for(;;)if(o){let c=t.children[o-1];if(c instanceof zt)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,r.set(l,s),i.push(l)}}return{index:s,matched:r,matches:i.reverse()}}function og(n,e){return n.type.side-e.type.side}function sg(n,e,t,o){let s=e.locals(n),r=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);o(d,s,e.forChild(r,d),c),r+=d.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let d,u;for(;i<s.length&&s[i].to==r;){let g=s[i++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(og);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let p,h;if(a)h=-1,p=a,a=null;else if(c<n.childCount)h=c,p=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=r&&l.splice(g--,1);for(;i<s.length&&s[i].from<=r&&s[i].to>r;)l.push(s[i++]);let f=r+p.nodeSize;if(p.isText){let g=f;i<s.length&&s[i].from<g&&(g=s[i].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<f&&(a=p.cut(g-r),p=p.cut(0,g-r),f=g,h=-1)}else for(;i<s.length&&s[i].to<f;)i++;let m=p.isInline&&!p.isLeaf?l.filter(g=>!g.inline):l.slice();o(p,m,e.forChild(r,p),h),r=f}}function rg(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 ig(n,e,t,o){for(let s=0,r=0;s<n.childCount&&r<=o;){let i=n.child(s++),l=r;if(r+=i.nodeSize,!i.isText)continue;let a=i.text;for(;s<n.childCount;){let c=n.child(s++);if(r+=c.nodeSize,!c.isText)break;a+=c.text}if(r>=t){if(r>=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 Ar(n,e,t,o,s){let r=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,d=l+=a.size;c>=t||d<=e?r.push(a):(c<e&&r.push(a.slice(0,e-c,o)),s&&(r.push(s),s=void 0),d>t&&r.push(a.slice(t-c,a.size,o)))}return r}function Pr(n,e=null){let t=n.domSelectionRange(),o=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),r=s&&s.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=o.resolve(i),a,c;if(Ko(t)){for(a=i;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&R.isSelectable(u)&&s.parent&&!(u.isInline&&Im(t.focusNode,t.focusOffset,s.dom))){let p=s.posBefore;c=new R(i==p?l:o.resolve(p))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=i,p=i;for(let h=0;h<t.rangeCount;h++){let f=t.getRangeAt(h);u=Math.min(u,n.docView.posFromDOM(f.startContainer,f.startOffset,1)),p=Math.max(p,n.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(u<0)return null;[a,i]=p==n.state.selection.anchor?[p,u]:[u,p],l=o.resolve(i)}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&&!r?1:-1;c=Or(n,d,l,u)}return c}function Sc(n){return n.editable?n.hasFocus():Ec(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Ke(n,e=!1){let t=n.state.selection;if(Cc(n,t),!!Sc(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ie){let o=n.domSelectionRange(),s=n.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&Dt(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)ag(n);else{let{anchor:o,head:s}=t,r,i;vc&&!(t instanceof z)&&(t.$from.parent.inlineContent||(r=xc(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=xc(n,t.to))),n.docView.setSelection(o,s,n,e),vc&&(r&&wc(r),i&&wc(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&lg(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const vc=de||ie&&Qa<63;function xc(n,e){let{node:t,offset:o}=n.docView.domFromPos(e,0),s=o<t.childNodes.length?t.childNodes[o]:null,r=o?t.childNodes[o-1]:null;if(de&&s&&s.contentEditable=="false")return Nr(s);if((!s||s.contentEditable=="false")&&(!r||r.contentEditable=="false")){if(s)return Nr(s);if(r)return Nr(r)}}function Nr(n){return n.contentEditable="true",de&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function wc(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function lg(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(()=>{(!Sc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function ag(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,oe(o)+1):t.setStart(o,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&me&&lt<=11&&(o.disabled=!0,o.disabled=!1)}function Cc(n,e){if(e instanceof R){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(kc(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else kc(n)}function kc(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Or(n,e,t,o){return n.someProp("createSelectionBetween",s=>s(n,e,t))||z.between(e,t,o)}function Tc(n){return n.editable&&!n.hasFocus()?!1:Ec(n)}function Ec(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 cg(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Dt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ir(n,e){let{$anchor:t,$head:o}=n.selection,s=e>0?t.max(o):t.min(o),r=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return r&&D.findFrom(r,e)}function dt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Mc(n,e,t){let o=n.state.selection;if(o instanceof z)if(t.indexOf("s")>-1){let{$head:s}=o,r=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let i=n.state.doc.resolve(s.pos+r.nodeSize*(e<0?-1:1));return dt(n,new z(o.$anchor,i))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=Ir(n.state,e);return s&&s instanceof R?dt(n,s):!1}else if(!(we&&t.indexOf("m")>-1)){let s=o.$head,r=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!r||r.isText)return!1;let l=e<0?s.pos-r.nodeSize:s.pos;return r.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?R.isSelectable(r)?dt(n,new R(e<0?n.state.doc.resolve(s.pos-r.nodeSize):s)):Gn?dt(n,new z(n.state.doc.resolve(e<0?l:l+r.nodeSize))):!1:!1}}else return!1;else{if(o instanceof R&&o.node.isInline)return dt(n,new z(e>0?o.$to:o.$from));{let s=Ir(n.state,e);return s?dt(n,s):!1}}}function Yo(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Un(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function bn(n,e){return e<0?dg(n):ug(n)}function dg(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s,r,i=!1;for(Me&&t.nodeType==1&&o<Yo(t)&&Un(t.childNodes[o],-1)&&(i=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(Un(l,-1))s=t,r=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if(Ac(t))break;{let l=t.previousSibling;for(;l&&Un(l,-1);)s=t.parentNode,r=oe(l),l=l.previousSibling;if(l)t=l,o=Yo(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}i?Rr(n,t,o):s&&Rr(n,s,r)}function ug(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s=Yo(t),r,i;for(;;)if(o<s){if(t.nodeType!=1)break;let l=t.childNodes[o];if(Un(l,1))r=t,i=++o;else break}else{if(Ac(t))break;{let l=t.nextSibling;for(;l&&Un(l,1);)r=l.parentNode,i=oe(l)+1,l=l.nextSibling;if(l)t=l,o=0,s=Yo(t);else{if(t=t.parentNode,t==n.dom)break;o=s=0}}}r&&Rr(n,r,i)}function Ac(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function pg(n,e){for(;n&&e==n.childNodes.length&&!_n(n);)e=oe(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 hg(n,e){for(;n&&!e&&!_n(n);)e=oe(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 Rr(n,e,t){if(e.nodeType!=3){let r,i;(i=pg(e,t))?(e=i,t=0):(r=hg(e,t))&&(e=r,t=r.nodeValue.length)}let o=n.domSelection();if(!o)return;if(Ko(o)){let r=document.createRange();r.setEnd(e,t),r.setStart(e,t),o.removeAllRanges(),o.addRange(r)}else o.extend&&o.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&Ke(n)},50)}function Pc(n,e){let t=n.state.doc.resolve(e);if(!(ie||Lm)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let r=n.coordsAtPos(e-1),i=(r.top+r.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(r.left-s.left)>1)return r.left<s.left?"ltr":"rtl"}if(e<t.end()){let r=n.coordsAtPos(e+1),i=(r.top+r.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(r.left-s.left)>1)return r.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Nc(n,e,t){let o=n.state.selection;if(o instanceof z&&!o.empty||t.indexOf("s")>-1||we&&t.indexOf("m")>-1)return!1;let{$from:s,$to:r}=o;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Ir(n.state,e);if(i&&i instanceof R)return dt(n,i)}if(!s.parent.inlineContent){let i=e<0?s:r,l=o instanceof be?D.near(i,e):D.findFrom(i,e);return l?dt(n,l):!1}return!1}function Oc(n,e){if(!(n.state.selection instanceof z))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 r=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(r&&!r.isText){let i=n.state.tr;return e<0?i.delete(t.pos-r.nodeSize,t.pos):i.delete(t.pos,t.pos+r.nodeSize),n.dispatch(i),!0}return!1}function Ic(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function fg(n){if(!de||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;Ic(n,o,"true"),setTimeout(()=>Ic(n,o,"false"),20)}return!1}function mg(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function gg(n,e){let t=e.keyCode,o=mg(e);if(t==8||we&&t==72&&o=="c")return Oc(n,-1)||bn(n,-1);if(t==46&&!e.shiftKey||we&&t==68&&o=="c")return Oc(n,1)||bn(n,1);if(t==13||t==27)return!0;if(t==37||we&&t==66&&o=="c"){let s=t==37?Pc(n,n.state.selection.from)=="ltr"?-1:1:-1;return Mc(n,s,o)||bn(n,s)}else if(t==39||we&&t==70&&o=="c"){let s=t==39?Pc(n,n.state.selection.from)=="ltr"?1:-1:1;return Mc(n,s,o)||bn(n,s)}else{if(t==38||we&&t==80&&o=="c")return Nc(n,-1,o)||bn(n,-1);if(t==40||we&&t==78&&o=="c")return fg(n)||Nc(n,1,o)||bn(n,1);if(o==(we?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Rc(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:o,openStart:s,openEnd:r}=e;for(;s>1&&r>1&&o.childCount==1&&o.firstChild.childCount==1;){s--,r--;let h=o.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),o=h.content}let i=n.someProp("clipboardSerializer")||Ot.fromSchema(n.state.schema),l=Fc(),a=l.createElement("div");a.appendChild(i.serializeFragment(o,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Vc[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let f=l.createElement(d[h]);for(;a.firstChild;)f.appendChild(a.firstChild);a.appendChild(f),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${r}${u?` -${u}`:""} ${JSON.stringify(t)}`);let p=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
806
+
807
+ `);return{dom:a,text:p,slice:e}}function Dc(n,e,t,o,s){let r=s.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=e&&(o||r||!t);if(a){if(n.someProp("transformPastedText",p=>{e=p(e,r||o,n)}),r)return e?new A(T.from(n.state.schema.text(e.replace(/\r\n?/g,`
808
+ `))),0,0):A.empty;let u=n.someProp("clipboardTextParser",p=>p(e,s,o,n));if(u)l=u;else{let p=s.marks(),{schema:h}=n.state,f=Ot.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=i.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(h.text(m,p)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),i=vg(t),Gn&&xg(i);let c=i&&i.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 p=i.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;i=p}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||rn.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!yg.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=wg(Bc(l,+d[1],+d[2]),d[4]);else if(l=A.maxOpen(bg(l.content,s),!0),l.openStart||l.openEnd){let u=0,p=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;p<l.openEnd&&!h.type.spec.isolating;p++,h=h.lastChild);l=Bc(l,u,p)}return n.someProp("transformPasted",u=>{l=u(l,n)}),l}const yg=/^(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 bg(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)),r,i=[];if(n.forEach(l=>{if(!i)return;let a=s.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&r.length&&$c(a,r,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=zc(i[i.length-1],r.length));let d=Lc(l,a);i.push(d),s=s.matchType(d.type),r=a}}),i)return T.from(i)}return n}function Lc(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,T.from(n));return n}function $c(n,e,t,o,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let r=$c(n,e,t,o.lastChild,s+1);if(r)return o.copy(o.content.replaceChild(o.childCount-1,r));if(o.contentMatchAt(o.childCount).matchType(s==n.length-1?t.type:n[s+1]))return o.copy(o.content.append(T.from(Lc(t,n,s+1))))}}function zc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,zc(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(T.empty,!0);return n.copy(t.append(o))}function Dr(n,e,t,o,s,r){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(r=0),s<o-1&&(l=Dr(l,e,t,o,s+1,r)),s>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,r<=s).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(T.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function Bc(n,e,t){return e<n.openStart&&(n=new A(Dr(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(Dr(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Vc={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 Hc=null;function Fc(){return Hc||(Hc=document.implementation.createHTMLDocument("title"))}let Lr=null;function Sg(n){let e=window.trustedTypes;return e?(Lr||(Lr=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Lr.createHTML(n)):n}function vg(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Fc().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(n),s;if((s=o&&Vc[o[1].toLowerCase()])&&(n=s.map(r=>"<"+r+">").join("")+n+s.map(r=>"</"+r+">").reverse().join("")),t.innerHTML=Sg(n),s)for(let r=0;r<s.length;r++)t=t.querySelector(s[r])||t;return t}function xg(n){let e=n.querySelectorAll(ie?"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 wg(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:r,openEnd:i}=n;for(let l=o.length-2;l>=0;l-=2){let a=t.nodes[o[l]];if(!a||a.hasRequiredAttrs())break;s=T.from(a.create(o[l+1],s)),r++,i++}return new A(s,r,i)}const ue={},pe={},Cg={touchstart:!0,touchmove:!0};class kg{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 Tg(n){for(let e in ue){let t=ue[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{Mg(n,o)&&!zr(n,o)&&(n.editable||!(o.type in pe))&&t(n,o)},Cg[e]?{passive:!0}:void 0)}de&&n.dom.addEventListener("input",()=>null),$r(n)}function ut(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Eg(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 $r(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>zr(n,o))})}function zr(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function Mg(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 Ag(n,e){!zr(n,e)&&ue[e.type]&&(n.editable||!(e.type in pe))&&ue[e.type](n,e)}pe.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Gc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Ae&&ie&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),gn&&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,Lt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",o=>o(n,t))||gg(n,t)?t.preventDefault():ut(n,"key")},pe.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},pe.keypress=(n,e)=>{let t=e;if(Gc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||we&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let o=n.state.selection;if(!(o instanceof z)||!o.$from.sameParent(o.$to)){let s=String.fromCharCode(t.charCode);!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",r=>r(n,o.$from.pos,o.$to.pos,s))&&n.dispatch(n.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function Xo(n){return{left:n.clientX,top:n.clientY}}function Pg(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function Br(n,e,t,o,s){if(o==-1)return!1;let r=n.state.doc.resolve(o);for(let i=r.depth+1;i>0;i--)if(n.someProp(e,l=>i>r.depth?l(n,t,r.nodeAfter,r.before(i),s,!0):l(n,t,r.node(i),r.before(i),s,!1)))return!0;return!1}function Sn(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 Ng(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&R.isSelectable(o)?(Sn(n,new R(t)),!0):!1}function Og(n,e){if(e==-1)return!1;let t=n.state.selection,o,s;t instanceof R&&(o=t.node);let r=n.state.doc.resolve(e);for(let i=r.depth+1;i>0;i--){let l=i>r.depth?r.nodeAfter:r.node(i);if(R.isSelectable(l)){o&&t.$from.depth>0&&i>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?s=r.before(t.$from.depth):s=r.before(i);break}}return s!=null?(Sn(n,R.create(n.state.doc,s)),!0):!1}function Ig(n,e,t,o,s){return Br(n,"handleClickOn",e,t,o)||n.someProp("handleClick",r=>r(n,e,o))||(s?Og(n,t):Ng(n,t))}function Rg(n,e,t,o){return Br(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",s=>s(n,e,o))}function Dg(n,e,t,o){return Br(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",s=>s(n,e,o))||Lg(n,t,o)}function Lg(n,e,t){if(t.button!=0)return!1;let o=n.state.doc;if(e==-1)return o.inlineContent?(Sn(n,z.create(o,0,o.content.size)),!0):!1;let s=o.resolve(e);for(let r=s.depth+1;r>0;r--){let i=r>s.depth?s.nodeAfter:s.node(r),l=s.before(r);if(i.inlineContent)Sn(n,z.create(o,l+1,l+1+i.content.size));else if(R.isSelectable(i))Sn(n,R.create(o,l));else continue;return!0}}function Vr(n){return Qo(n)}const _c=we?"metaKey":"ctrlKey";ue.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=Vr(n),s=Date.now(),r="singleClick";s-n.input.lastClick.time<500&&Pg(t,n.input.lastClick)&&!t[_c]&&(n.input.lastClick.type=="singleClick"?r="doubleClick":n.input.lastClick.type=="doubleClick"&&(r="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:r};let i=n.posAtCoords(Xo(t));i&&(r=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new $g(n,i,t,!!o)):(r=="doubleClick"?Rg:Dg)(n,i.pos,i.inside,t)?t.preventDefault():ut(n,"pointer"))};class $g{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[_c],this.allowDefault=o.shiftKey;let r,i;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),i=t.inside;else{let d=e.state.doc.resolve(t.pos);r=d.parent,i=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&&r.type.spec.draggable&&r.type.spec.selectable!==!1||c instanceof R&&c.from<=i&&c.to>i)&&(this.mightDrag={node:r,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Me&&!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)),ut(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(()=>Ke(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(Xo(e))),this.updateAllowDefault(e),this.allowDefault||!t?ut(this.view,"pointer"):Ig(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||de&&this.mightDrag&&!this.mightDrag.node.isAtom||ie&&!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)?(Sn(this.view,D.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ut(this.view,"pointer")}move(e){this.updateAllowDefault(e),ut(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)}}ue.touchstart=n=>{n.input.lastTouch=Date.now(),Vr(n),ut(n,"pointer")},ue.touchmove=n=>{n.input.lastTouch=Date.now(),ut(n,"pointer")},ue.contextmenu=n=>Vr(n);function Gc(n,e){return n.composing?!0:de&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const zg=Ae?5e3:-1;pe.compositionstart=pe.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof z&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Qo(n,!0),n.markCursor=null;else if(Qo(n,!e.selection.empty),Me&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let o=n.domSelectionRange();for(let s=o.focusNode,r=o.focusOffset;s&&s.nodeType==1&&r!=0;){let i=r<0?s.lastChild:s.childNodes[r-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else s=i,r=-1}}n.input.composing=!0}Wc(n,zg)},pe.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++,Wc(n,20))};function Wc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Qo(n),e))}function jc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Vg());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Bg(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Nm(e.focusNode,e.focusOffset),o=Om(e.focusNode,e.focusOffset);if(t&&o&&t!=o){let s=o.pmViewDesc,r=n.domObserver.lastChangedTextNode;if(t==r||o==r)return r;if(!s||!s.isText(o.nodeValue))return o;if(n.input.compositionNode==o){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return o}}return t||o}function Vg(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Qo(n,e=!1){if(!(Ae&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),jc(n),e||n.docView&&n.docView.dirty){let t=Pr(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 Hg(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 Kn=me&&lt<15||gn&&$m<604;ue.copy=pe.cut=(n,e)=>{let t=e,o=n.state.selection,s=t.type=="cut";if(o.empty)return;let r=Kn?null:t.clipboardData,i=o.content(),{dom:l,text:a}=Rc(n,i);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",a)):Hg(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Fg(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function _g(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?Jn(n,o.value,null,s,e):Jn(n,o.textContent,o.innerHTML,s,e)},50)}function Jn(n,e,t,o,s){let r=Dc(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,r||A.empty)))return!0;if(!r)return!1;let i=Fg(r),l=i?n.state.tr.replaceSelectionWith(i,o):n.state.tr.replaceSelection(r);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function qc(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," "):""}pe.paste=(n,e)=>{let t=e;if(n.composing&&!Ae)return;let o=Kn?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&Jn(n,qc(o),o.getData("text/html"),s,t)?t.preventDefault():_g(n,t)};class Uc{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const Kc=we?"altKey":"ctrlKey";ue.dragstart=(n,e)=>{let t=e,o=n.input.mouseDown;if(o&&o.done(),!t.dataTransfer)return;let s=n.state.selection,r=s.empty?null:n.posAtCoords(Xo(t)),i;if(!(r&&r.pos>=s.from&&r.pos<=(s instanceof R?s.to-1:s.to))){if(o&&o.mightDrag)i=R.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&&(i=R.create(n.state.doc,u.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:d}=Rc(n,l);(!t.dataTransfer.files.length||!ie||Qa>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Kn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Kn||t.dataTransfer.setData("text/plain",c),n.dragging=new Uc(d,!t[Kc],i)},ue.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},pe.dragover=pe.dragenter=(n,e)=>e.preventDefault(),pe.drop=(n,e)=>{let t=e,o=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(Xo(t));if(!s)return;let r=n.state.doc.resolve(s.pos),i=o&&o.slice;i?n.someProp("transformPasted",f=>{i=f(i,n)}):i=Dc(n,qc(t.dataTransfer),Kn?null:t.dataTransfer.getData("text/html"),!1,r);let l=!!(o&&!t[Kc]);if(n.someProp("handleDrop",f=>f(n,t,i||A.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?zf(n.state.doc,r.pos,i):r.pos;a==null&&(a=r.pos);let c=n.state.tr;if(l){let{node:f}=o;f?f.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,p=c.doc;if(u?c.replaceRangeWith(d,d,i.content.firstChild):c.replaceRange(d,d,i),c.doc.eq(p))return;let h=c.doc.resolve(d);if(u&&R.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new R(h));else{let f=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,C)=>f=C),c.setSelection(Or(n,h,c.doc.resolve(f)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},ue.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Ke(n)},20))},ue.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},ue.beforeinput=(n,e)=>{if(ie&&Ae&&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",r=>r(n,Lt(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 pe)ue[n]=pe[n];function Zn(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 es{constructor(e,t){this.toDOM=e,this.spec=t||Vt,this.side=this.spec.side||0}map(e,t,o,s){let{pos:r,deleted:i}=e.mapResult(t.from+s,this.side<0?-1:1);return i?null:new ge(r-o,r-o,this)}valid(){return!0}eq(e){return this==e||e instanceof es&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Zn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class pt{constructor(e,t){this.attrs=e,this.spec=t||Vt}map(e,t,o,s){let r=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-o,i=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-o;return r>=i?null:new ge(r,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof pt&&Zn(this.attrs,e.attrs)&&Zn(this.spec,e.spec)}static is(e){return e.type instanceof pt}destroy(){}}class Hr{constructor(e,t){this.attrs=e,this.spec=t||Vt}map(e,t,o,s){let r=e.mapResult(t.from+s,1);if(r.deleted)return null;let i=e.mapResult(t.to+s,-1);return i.deleted||i.pos<=r.pos?null:new ge(r.pos-o,i.pos-o,this)}valid(e,t){let{index:o,offset:s}=e.content.findIndex(t.from),r;return s==t.from&&!(r=e.child(o)).isText&&s+r.nodeSize==t.to}eq(e){return this==e||e instanceof Hr&&Zn(this.attrs,e.attrs)&&Zn(this.spec,e.spec)}destroy(){}}class ge{constructor(e,t,o){this.from=e,this.to=t,this.type=o}copy(e,t){return new ge(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 ge(e,e,new es(t,o))}static inline(e,t,o,s){return new ge(e,t,new pt(o,s))}static node(e,t,o,s){return new ge(e,t,new Hr(o,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof pt}get widget(){return this.type instanceof es}}const vn=[],Vt={};class K{constructor(e,t){this.local=e.length?e:vn,this.children=t.length?t:vn}static create(e,t){return t.length?ts(t,e,0,Vt):le}find(e,t,o){let s=[];return this.findInner(e??0,t??1e9,s,0,o),s}findInner(e,t,o,s,r){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!r||r(l.spec))&&o.push(l.copy(l.from+s,l.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,o,s+l,r)}}map(e,t,o){return this==le||e.maps.length==0?this:this.mapInner(e,t,0,0,o||Vt)}mapInner(e,t,o,s,r){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,o,s);a&&a.type.valid(t,a)?(i||(i=[])).push(a):r.onRemove&&r.onRemove(this.local[l].spec)}return this.children.length?Gg(this.children,i||[],e,t,o,s,r):i?new K(i.sort(Ht),vn):le}add(e,t){return t.length?this==le?K.create(e,t):this.addInner(e,t,0):this}addInner(e,t,o){let s,r=0;e.forEach((l,a)=>{let c=a+o,d;if(d=Zc(t,l,c)){for(s||(s=this.children.slice());r<s.length&&s[r]<a;)r+=3;s[r]==a?s[r+2]=s[r+2].addInner(l,d,c+1):s.splice(r,0,a,a+l.nodeSize,ts(d,l,c+1,Vt)),r+=3}});let i=Jc(r?Yc(t):t,-o);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new K(i.length?this.local.concat(i).sort(Ht):this.local,s||this.children)}remove(e){return e.length==0||this==le?this:this.removeInner(e,0)}removeInner(e,t){let o=this.children,s=this.local;for(let r=0;r<o.length;r+=3){let i,l=o[r]+t,a=o[r+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(i||(i=[])).push(u));if(!i)continue;o==this.children&&(o=this.children.slice());let c=o[r+2].removeInner(i,l+1);c!=le?o[r+2]=c:(o.splice(r,3),r-=3)}if(s.length){for(let r=0,i;r<e.length;r++)if(i=e[r])for(let l=0;l<s.length;l++)s[l].eq(i,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 K(s,o):le}forChild(e,t){if(this==le)return this;if(t.isLeaf)return K.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 r=e+1,i=r+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>r&&a.type instanceof pt){let c=Math.max(r,a.from)-r,d=Math.min(i,a.to)-r;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new K(s.sort(Ht),vn);return o?new ht([l,o]):l}return o||le}eq(e){if(this==e)return!0;if(!(e instanceof K)||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 Fr(this.localsInner(e))}localsInner(e){if(this==le)return vn;if(e.inlineContent||!this.local.some(pt.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof pt||t.push(this.local[o]);return t}forEachSet(e){e(this)}}K.empty=new K([],[]),K.removeOverlap=Fr;const le=K.empty;class ht{constructor(e){this.members=e}map(e,t){const o=this.members.map(s=>s.map(e,t,Vt));return ht.from(o)}forChild(e,t){if(t.isLeaf)return K.empty;let o=[];for(let s=0;s<this.members.length;s++){let r=this.members[s].forChild(e,t);r!=le&&(r instanceof ht?o=o.concat(r.members):o.push(r))}return ht.from(o)}eq(e){if(!(e instanceof ht)||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 r=this.members[s].localsInner(e);if(r.length)if(!t)t=r;else{o&&(t=t.slice(),o=!1);for(let i=0;i<r.length;i++)t.push(r[i])}}return t?Fr(o?t:t.sort(Ht)):vn}static from(e){switch(e.length){case 0:return le;case 1:return e[0];default:return new ht(e.every(t=>t instanceof K)?e:e.reduce((t,o)=>t.concat(o instanceof K?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Gg(n,e,t,o,s,r,i){let l=n.slice();for(let c=0,d=r;c<t.maps.length;c++){let u=0;t.maps[c].forEach((p,h,f,m)=>{let g=m-f-(h-p);for(let b=0;b<l.length;b+=3){let C=l[b+1];if(C<0||p>C+d-u)continue;let y=l[b]+d-u;h>=y?l[b+1]=p<=y?-2:-1:p>=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]+r),u=d-s;if(u<0||u>=o.content.size){a=!0;continue}let p=t.map(n[c+1]+r,-1),h=p-s,{index:f,offset:m}=o.content.findIndex(u),g=o.maybeChild(f);if(g&&m==u&&m+g.nodeSize==h){let b=l[c+2].mapInner(t,g,d+1,n[c]+r+1,i);b!=le?(l[c]=u,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Wg(l,n,e,t,s,r,i),d=ts(c,o,0,i);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,p=0;u<d.children.length;u+=3){let h=d.children[u];for(;p<l.length&&l[p]<h;)p+=3;l.splice(p,0,d.children[u],d.children[u+1],d.children[u+2])}}return new K(e.sort(Ht),l)}function Jc(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 ge(s.from+e,s.to+e,s.type))}return t}function Wg(n,e,t,o,s,r,i){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):i.onRemove&&i.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+r+1);return t}function Zc(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,s=null;for(let r=0,i;r<n.length;r++)(i=n[r])&&i.from>t&&i.to<o&&((s||(s=[])).push(i),n[r]=null);return s}function Yc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function ts(n,e,t,o){let s=[],r=!1;e.forEach((l,a)=>{let c=Zc(n,l,a+t);if(c){r=!0;let d=ts(c,l,t+a+1,o);d!=le&&s.push(a,a+l.nodeSize,d)}});let i=Jc(r?Yc(n):n,-t).sort(Ht);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(o.onRemove&&o.onRemove(i[l].spec),i.splice(l--,1));return i.length||s.length?new K(i,s):le}function Ht(n,e){return n.from-e.from||n.to-e.to}function Fr(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 r=e[s];if(r.from==o.from){r.to!=o.to&&(e==n&&(e=n.slice()),e[s]=r.copy(r.from,o.to),Xc(e,s+1,r.copy(o.to,r.to)));continue}else{r.from<o.to&&(e==n&&(e=n.slice()),e[t]=o.copy(o.from,r.from),Xc(e,s,o.copy(r.from,o.to)));break}}}return e}function Xc(n,e,t){for(;e<n.length&&Ht(t,n[e])>0;)e++;n.splice(e,0,t)}function _r(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=le&&e.push(o)}),n.cursorWrapper&&e.push(K.create(n.state.doc,[n.cursorWrapper.deco])),ht.from(e)}const jg={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},qg=me&&lt<=11;class Ug{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 Kg{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Ug,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]);me&&lt<=11&&o.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),qg&&(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,jg)),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(Tc(this.view)){if(this.suppressingSelectionUpdates)return Ke(this.view);if(me&&lt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Dt(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 r=e.focusNode;r;r=Fn(r))t.add(r);for(let r=e.anchorNode;r;r=Fn(r))if(t.has(r)){o=r;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)&&Tc(e)&&!this.ignoreSelectionChange(o),r=-1,i=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(r=r<0?u.from:Math.min(u.from,r),i=i<0?u.to:Math.max(u.to,i),u.typeOver&&(l=!0))}if(Me&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,p]=d;u.parentNode&&u.parentNode.parentNode==p.parentNode?p.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let p of d){let h=p.parentNode;h&&h.nodeName=="LI"&&(!u||Yg(e,u)!=h)&&p.remove()}}}let c=null;r<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ko(o)&&(c=Pr(e))&&c.eq(D.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ke(e),this.currentSelection.set(o),e.scrollToSelection()):(r>-1||s)&&(r>-1&&(e.docView.markDirty(r,i),Jg(e)),this.handleDOMChange(r,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(o)||Ke(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,r=e.nextSibling;if(me&&lt<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:p}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(r=p)}let i=s&&s.parentNode==e.target?oe(s)+1:0,l=o.localPosFromDOM(e.target,i,-1),a=r&&r.parentNode==e.target?oe(r):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 Qc=new WeakMap,ed=!1;function Jg(n){if(!Qc.has(n)&&(Qc.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Me,ed)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."),ed=!0}}function td(n,e){let t=e.startContainer,o=e.startOffset,s=e.endContainer,r=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Dt(i.node,i.offset,s,r)&&([t,o,s,r]=[s,r,t,o]),{anchorNode:t,anchorOffset:o,focusNode:s,focusOffset:r}}function Zg(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return td(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?td(n,t):null}function Yg(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 Xg(n,e,t){let{node:o,fromOffset:s,toOffset:r,from:i,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}],Ko(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ie&&n.input.lastKeyCode===8)for(let g=r;g>s;g--){let b=o.childNodes[g-1],C=b.pmViewDesc;if(b.nodeName=="BR"&&!C){r=g;break}if(!C||C.size)break}let u=n.state.doc,p=n.someProp("domParser")||rn.fromSchema(n.state.schema),h=u.resolve(i),f=null,m=p.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:r,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Qg,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),f={anchor:g+i,head:b+i}}return{doc:m,sel:f,from:i,to:l}}function Qg(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(de&&/^(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||de&&/^(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 e1=/^(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 t1(n,e,t,o,s){let r=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let k=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,M=Pr(n,k);if(M&&!n.state.selection.eq(M)){if(ie&&Ae&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",N=>N(n,Lt(13,"Enter"))))return;let P=n.state.tr.setSelection(M);k=="pointer"?P.setMeta("pointer",!0):k=="key"&&P.scrollIntoView(),r&&P.setMeta("composition",r),n.dispatch(P)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Xg(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),p,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(p=n.state.selection.to,h="end"):(p=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let f=s1(u.content,c.doc.content,c.from,p,h);if(f&&n.input.domChangeCount++,(gn&&n.input.lastIOSEnter>Date.now()-225||Ae)&&s.some(k=>k.nodeType==1&&!e1.test(k.nodeName))&&(!f||f.endA>=f.endB)&&n.someProp("handleKeyDown",k=>k(n,Lt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!f)if(o&&a instanceof z&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))f={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let k=nd(n,n.state.doc,c.sel);if(k&&!k.eq(n.state.selection)){let M=n.state.tr.setSelection(k);r&&M.setMeta("composition",r),n.dispatch(M)}}return}n.state.selection.from<n.state.selection.to&&f.start==f.endB&&n.state.selection instanceof z&&(f.start>n.state.selection.from&&f.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?f.start=n.state.selection.from:f.endA<n.state.selection.to&&f.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(f.endB+=n.state.selection.to-f.endA,f.endA=n.state.selection.to)),me&&lt<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>c.from&&c.doc.textBetween(f.start-c.from-1,f.start-c.from+1)=="  "&&(f.start--,f.endA--,f.endB--);let m=c.doc.resolveNoCache(f.start-c.from),g=c.doc.resolveNoCache(f.endB-c.from),b=d.resolve(f.start),C=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=f.endA,y;if((gn&&n.input.lastIOSEnter>Date.now()-225&&(!C||s.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!C&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(y=D.findFrom(c.doc.resolve(m.pos+1),1,!0))&&y.head==g.pos)&&n.someProp("handleKeyDown",k=>k(n,Lt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>f.start&&o1(d,f.start,f.endA,m,g)&&n.someProp("handleKeyDown",k=>k(n,Lt(8,"Backspace")))){Ae&&ie&&n.domObserver.suppressSelectionUpdates();return}ie&&Ae&&f.endB==f.start&&(n.input.lastAndroidDelete=Date.now()),Ae&&!C&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==f.endA&&(f.endB-=2,g=c.doc.resolveNoCache(f.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(k){return k(n,Lt(13,"Enter"))})},20));let S=f.start,x=f.endA,w,v,E;if(C){if(m.pos==g.pos)me&&lt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ke(n),20)),w=n.state.tr.delete(S,x),v=d.resolve(f.start).marksAcross(d.resolve(f.endA));else if(f.endA==f.endB&&(E=n1(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start()))))w=n.state.tr,E.type=="add"?w.addMark(S,x,E.mark):w.removeMark(S,x,E.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let k=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",M=>M(n,S,x,k)))return;w=n.state.tr.insertText(k,S,x)}}if(w||(w=n.state.tr.replace(S,x,c.doc.slice(f.start-c.from,f.endB-c.from))),c.sel){let k=nd(n,w.doc,c.sel);k&&!(ie&&Ae&&n.composing&&k.empty&&(f.start!=f.endB||n.input.lastAndroidDelete<Date.now()-100)&&(k.head==S||k.head==w.mapping.map(x)-1)||me&&k.empty&&k.head==S)&&w.setSelection(k)}v&&w.ensureMarks(v),r&&w.setMeta("composition",r),n.dispatch(w.scrollIntoView())}function nd(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Or(n,e.resolve(t.anchor),e.resolve(t.head))}function n1(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,s=t,r=o,i,l,a;for(let d=0;d<o.length;d++)s=o[d].removeFromSet(s);for(let d=0;d<t.length;d++)r=t[d].removeFromSet(r);if(s.length==1&&r.length==0)l=s[0],i="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&r.length==1)l=r[0],i="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(T.from(c).eq(n))return{mark:l,type:i}}function o1(n,e,t,o,s){if(t-e<=s.pos-o.pos||Gr(o,!0,!1)<s.pos)return!1;let r=n.resolve(e);if(!o.parent.isTextblock){let l=r.nodeAfter;return l!=null&&t==e+l.nodeSize}if(r.parentOffset<r.parent.content.size||!r.parent.isTextblock)return!1;let i=n.resolve(Gr(r,!0,!0));return!i.parent.isTextblock||i.pos>t||Gr(i,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(i.parent.content)}function Gr(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 r=n.node(o).maybeChild(n.indexAfter(o));for(;r&&!r.isLeaf;)r=r.firstChild,s++}return s}function s1(n,e,t,o,s){let r=n.findDiffStart(e,t);if(r==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,r-Math.min(i,l));o-=i+a-r}if(i<r&&n.size<e.size){let a=o<=r&&o>=i?r-o:0;r-=a,r&&r<e.size&&od(e.textBetween(r-1,r+1))&&(r+=a?1:-1),l=r+(l-i),i=r}else if(l<r){let a=o<=r&&o>=l?r-o:0;r-=a,r&&r<n.size&&od(n.textBetween(r-1,r+1))&&(r+=a?1:-1),i=r+(i-l),l=r}return{start:r,endA:i,endB:l}}function od(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 r1{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 kg,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ad),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=id(this),rd(this),this.nodeViews=ld(this),this.docView=hc(this.state.doc,sd(this),_r(this),this.dom,this),this.domObserver=new Kg(this,(o,s,r,i)=>t1(this,o,s,r,i)),this.domObserver.start(),Tg(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&&$r(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ad),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,r=!1,i=!1;e.storedMarks&&this.composing&&(jc(this),i=!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 h=ld(this);l1(h,this.nodeViews)&&(this.nodeViews=h,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&$r(this),this.editable=id(this),rd(this);let a=_r(this),c=sd(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=r||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(i=!0);let p=d=="preserve"&&i&&this.dom.style.overflowAnchor==null&&Vm(this);if(i){this.domObserver.stop();let h=u&&(me||ie)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&i1(s.selection,e.selection);if(u){let f=ie?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Bg(this)),(r||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=hc(e.doc,c,a,this.dom,this)),f&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&cg(this))?Ke(this,h):(Cc(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():p&&Hm(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof R){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ec(this,t.getBoundingClientRect(),e)}else ec(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 r=o.from+(this.state.doc.content.size-t.doc.content.size);(r>0&&this.state.doc.nodeAt(r))==o.node&&(s=r)}this.dragging=new Uc(e.slice,e.move,s<0?void 0:R.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 i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(s=t?t(l):l))return s}let r=this.state.plugins;if(r)for(let i=0;i<r.length;i++){let l=r[i].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(me){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&&Fm(this.dom),Ke(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 qm(this,e)}coordsAtPos(e,t=1){return ic(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 Ym(this,t||this.state,e)}pasteHTML(e,t){return Jn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Jn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Eg(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],_r(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Am())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ag(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?de&&this.root.nodeType===11&&Rm(this.dom.ownerDocument)==this.dom&&Zg(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function sd(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"),[ge.node(0,n.state.doc.content.size,e)]}function rd(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:ge.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function id(n){return!n.someProp("editable",e=>e(n.state)===!1)}function i1(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 ld(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 l1(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 ad(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 Wr,jr;if(typeof WeakMap<"u"){let n=new WeakMap;Wr=e=>n.get(e),jr=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Wr=o=>{for(let s=0;s<n.length;s+=2)if(n[s]==o)return n[s+1]},jr=(o,s)=>(t==10&&(t=0),n[t++]=o,n[t++]=s)}var Z=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 r=o+1,i=s+1;for(let l=1;r<this.width&&this.map[e+l]==t;l++)r++;for(let l=1;i<this.height&&this.map[e+this.width*l]==t;l++)i++;return{left:o,top:s,right:r,bottom:i}}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:r,bottom:i}=this.findCell(n);return e=="horiz"?(t<0?o==0:s==this.width)?null:this.map[r*this.width+(t<0?o-1:s)]:(t<0?r==0:i==this.height)?null:this.map[o+this.width*(t<0?r-1:i)]}rectBetween(n,e){const{left:t,right:o,top:s,bottom:r}=this.findCell(n),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(s,a),right:Math.max(o,l),bottom:Math.max(r,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 r=o*this.width+s,i=this.map[r];t[i]||(t[i]=!0,!(s==n.left&&s&&this.map[r-1]==i||o==n.top&&o&&this.map[r-this.width]==i)&&e.push(i))}return e}positionAt(n,e,t){for(let o=0,s=0;;o++){const r=s+t.child(o).nodeSize;if(o==n){let i=e+n*this.width;const l=(n+1)*this.width;for(;i<l&&this.map[i]<s;)i++;return i==l?r-1:this.map[i]}s=r}}static get(n){return Wr(n)||jr(n,a1(n))}};function a1(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=c1(n),t=n.childCount,o=[];let s=0,r=null;const i=[];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 f=0;;f++){for(;s<o.length&&o[s]!=0;)s++;if(f==u.childCount)break;const m=u.child(f),{colspan:g,rowspan:b,colwidth:C}=m.attrs;for(let y=0;y<b;y++){if(y+c>=t){(r||(r=[])).push({type:"overlong_rowspan",pos:d,n:b-y});break}const S=s+y*e;for(let x=0;x<g;x++){o[S+x]==0?o[S+x]=d:(r||(r=[])).push({type:"collision",row:c,pos:d,n:g-x});const w=C&&C[x];if(w){const v=(S+x)%e*2,E=i[v];E==null||E!=w&&i[v+1]==1?(i[v]=w,i[v+1]=1):E==w&&i[v+1]++}}}s+=g,d+=m.nodeSize}const p=(c+1)*e;let h=0;for(;s<p;)o[s++]==0&&h++;h&&(r||(r=[])).push({type:"missing",row:c,n:h}),d++}const l=new Z(e,t,o,r);let a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(a=!0);return a&&d1(l,i,n),l}function c1(n){let e=-1,t=!1;for(let o=0;o<n.childCount;o++){const s=n.child(o);let r=0;if(t)for(let i=0;i<o;i++){const l=n.child(i);for(let a=0;a<l.childCount;a++){const c=l.child(a);i+c.attrs.rowspan>o&&(r+=c.attrs.colspan)}}for(let i=0;i<s.childCount;i++){const l=s.child(i);r+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=r:e!=r&&(e=Math.max(e,r))}return e}function d1(n,e,t){n.problems||(n.problems=[]);const o={};for(let s=0;s<n.map.length;s++){const r=n.map[s];if(o[r])continue;o[r]=!0;const i=t.nodeAt(r);if(!i)throw new RangeError(`No cell with offset ${r} found`);let l=null;const a=i.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=u1(a)))[c]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:l})}}function u1(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function cd(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),o=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(i=>Number(i)):null,s=Number(n.getAttribute("colspan")||1),r={colspan:s,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:o&&o.length==s?o:null};for(const i in e){const l=e[i].getFromDOM,a=l&&l(n);a!=null&&(r[i]=a)}return r}function dd(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 p1(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=>cd(o,e)}],toDOM(o){return["td",dd(o,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:o=>cd(o,e)}],toDOM(o){return["th",dd(o,e),0]}}}}function Ve(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 ft=new Vn("selectingCells");function Yn(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 ns(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 qr(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=Yn(e.$head)||h1(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function h1(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 Ur(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function f1(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Kr(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function ud(n,e,t){const o=n.node(-1),s=Z.get(o),r=n.start(-1),i=s.nextCell(n.pos-r,e,t);return i==null?null:n.node(0).resolve(r+i)}function xn(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 X=class Xe extends D{constructor(e,t=e){const o=e.node(-1),s=Z.get(o),r=e.start(-1),i=s.rectBetween(e.pos-r,t.pos-r),l=e.node(0),a=s.cellsInRect(i).filter(d=>d!=t.pos-r);a.unshift(t.pos-r);const c=a.map(d=>{const u=o.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const p=r+d+1;return new Ca(l.resolve(p),l.resolve(p+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(Ur(o)&&Ur(s)&&Kr(o,s)){const r=this.$anchorCell.node(-1)!=o.node(-1);return r&&this.isRowSelection()?Xe.rowSelection(o,s):r&&this.isColSelection()?Xe.colSelection(o,s):new Xe(o,s)}return z.between(o,s)}content(){const e=this.$anchorCell.node(-1),t=Z.get(e),o=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),r={},i=[];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 p=t.map[d];if(r[p])continue;r[p]=!0;const h=t.findCell(p);let f=e.nodeAt(p);if(!f)throw RangeError(`No cell with offset ${p} found`);const m=s.left-h.left,g=h.right-s.right;if(m>0||g>0){let b=f.attrs;if(m>0&&(b=xn(b,0,m)),g>0&&(b=xn(b,b.colspan-g,g)),h.left<s.left){if(f=f.type.createAndFill(b),!f)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else f=f.type.create(b,f.content)}if(h.top<s.top||h.bottom>s.bottom){const b={...f.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?f=f.type.createAndFill(b):f=f.type.create(b,f.content)}c.push(f)}i.push(e.child(a).copy(T.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new A(T.from(l),1,1)}replace(e,t=A.empty){const o=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){const{$from:l,$to:a}=s[i],c=e.mapping.slice(o);e.replace(c.map(l.pos),c.map(a.pos),i?A.empty:t)}const r=D.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,t){this.replace(e,new A(T.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),o=Z.get(t),s=this.$anchorCell.start(-1),r=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let i=0;i<r.length;i++)e(t.nodeAt(r[i]),s+r[i])}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=Z.get(o),r=e.start(-1),i=s.findCell(e.pos-r),l=s.findCell(t.pos-r),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(r+s.map[i.left])),l.bottom<s.height&&(t=a.resolve(r+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(r+s.map[l.left])),i.bottom<s.height&&(e=a.resolve(r+s.map[s.width*(s.height-1)+i.right-1]))),new Xe(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=Z.get(e),o=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-o),r=t.colCount(this.$headCell.pos-o);if(Math.min(s,r)>0)return!1;const i=s+this.$anchorCell.nodeAfter.attrs.colspan,l=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==t.width}eq(e){return e instanceof Xe&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const o=e.node(-1),s=Z.get(o),r=e.start(-1),i=s.findCell(e.pos-r),l=s.findCell(t.pos-r),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(r+s.map[i.top*s.width])),l.right<s.width&&(t=a.resolve(r+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(r+s.map[l.top*s.width])),i.right<s.width&&(e=a.resolve(r+s.map[s.width*(i.top+1)-1]))),new Xe(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Xe(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){return new Xe(e.resolve(t),e.resolve(o))}getBookmark(){return new m1(this.$anchorCell.pos,this.$headCell.pos)}};X.prototype.visible=!1,D.jsonID("cell",X);var m1=class mu{constructor(e,t){this.anchor=e,this.head=t}map(e){return new mu(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&&Kr(t,o)?new X(t,o):D.near(o,1)}};function g1(n){if(!(n.selection instanceof X))return null;const e=[];return n.selection.forEachCell((t,o)=>{e.push(ge.node(o,o+t.nodeSize,{class:"selectedCell"}))}),K.create(n.doc,e)}function y1({$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 r=e.depth;r>=0&&!(e.before(r+1)>e.start(r));r--,o--);return t==o&&/row|table/.test(n.node(s).type.spec.tableRole)}function b1({$from:n,$to:e}){let t,o;for(let s=n.depth;s>0;s--){const r=n.node(s);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){t=r;break}}for(let s=e.depth;s>0;s--){const r=e.node(s);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){o=r;break}}return t!==o&&e.parentOffset===0}function S1(n,e,t){const o=(e||n).selection,s=(e||n).doc;let r,i;if(o instanceof R&&(i=o.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")r=X.create(s,o.from);else if(i=="row"){const l=s.resolve(o.from+1);r=X.rowSelection(l,l)}else if(!t){const l=Z.get(o.node),a=o.from+1,c=a+l.map[l.width*l.height-1];r=X.create(s,a+1,c)}}else o instanceof z&&y1(o)?r=z.create(s,o.from):o instanceof z&&b1(o)&&(r=z.create(s,o.$from.start(),o.$from.end()));return r&&(e||(e=n.tr)).setSelection(r),e}var v1=new Vn("fix-tables");function pd(n,e,t,o){const s=n.childCount,r=e.childCount;e:for(let i=0,l=0;i<r;i++){const a=e.child(i);for(let c=l,d=Math.min(s,i+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)?pd(n.child(l),a,t+1,o):a.nodesBetween(0,a.content.size,o,t+1),t+=a.nodeSize}}function x1(n,e){let t;const o=(s,r)=>{s.type.spec.tableRole=="table"&&(t=w1(n,s,r,t))};return e?e.doc!=n.doc&&pd(e.doc,n.doc,0,o):n.doc.descendants(o),t}function w1(n,e,t,o){const s=Z.get(e);if(!s.problems)return o;o||(o=n.tr);const r=[];for(let a=0;a<s.height;a++)r.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 p=0;p<u.rowspan;p++)r[c.row+p]+=c.n;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,xn(u,u.colspan-c.n,c.n))}else if(c.type=="missing")r[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;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 i,l;for(let a=0;a<r.length;a++)r[a]&&(i==null&&(i=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const d=e.child(a),u=c+d.nodeSize,p=r[a];if(p>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const f=[];for(let g=0;g<p;g++){const b=Ve(n.schema)[h].createAndFill();b&&f.push(b)}const m=(a==0||i==a-1)&&l==a?c+1:u-1;o.insert(o.mapping.map(m),f)}c=u}return o.setMeta(v1,{fixTables:!0})}function hd(n){const e=n.selection,t=qr(n),o=t.node(-1),s=t.start(-1),r=Z.get(o);return{...e instanceof X?r.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):r.findCell(t.pos-s),tableStart:s,map:r,table:o}}function C1(n){return function(e,t){if(!ns(e))return!1;if(t){const o=Ve(e.schema),s=hd(e),r=e.tr,i=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=i.map(a=>s.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==o.header_cell&&r.setNodeMarkup(s.tableStart+i[a],o.cell,l[a].attrs);if(r.steps.length==0)for(let a=0;a<i.length;a++)r.setNodeMarkup(s.tableStart+i[a],o.header_cell,l[a].attrs);t(r)}return!0}}function fd(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 r=e.table.nodeAt(o[s]);if(r&&r.type!==t.header_cell)return!1}return!0}function Jr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?C1(n):function(t,o){if(!ns(t))return!1;if(o){const s=Ve(t.schema),r=hd(t),i=t.tr,l=fd("row",r,s),a=fd("column",r,s),d=(n==="column"?l:n==="row"?a:!1)?1:0,u=n=="column"?{left:0,top:d,right:1,bottom:r.map.height}:n=="row"?{left:d,top:0,right:r.map.width,bottom:1}:r,p=n=="column"?a?s.cell:s.header_cell:n=="row"?l?s.cell:s.header_cell:s.cell;r.map.cellsInRect(u).forEach(h=>{const f=h+r.tableStart,m=i.doc.nodeAt(f);m&&i.setNodeMarkup(f,p,m.attrs)}),o(i)}return!0}}Jr("row",{useDeprecatedLogic:!0}),Jr("column",{useDeprecatedLogic:!0}),Jr("cell",{useDeprecatedLogic:!0});function k1(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 r=n.node(-1).child(o),i=r.lastChild;if(i)return s-1-i.nodeSize;s-=r.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 r=t.child(o);if(r.childCount)return s+1;s+=r.nodeSize}}return null}function md(n){return function(e,t){if(!ns(e))return!1;const o=k1(qr(e),n);if(o==null)return!1;if(t){const s=e.doc.resolve(o);t(e.tr.setSelection(z.between(s,f1(s))).scrollIntoView())}return!0}}function ss(n,e){const t=n.selection;if(!(t instanceof X))return!1;if(e){const o=n.tr,s=Ve(n.schema).cell.createAndFill().content;t.forEachCell((r,i)=>{r.content.eq(s)||o.replace(o.mapping.map(i+1),o.mapping.map(i+r.nodeSize-1),new A(s,0,0))}),o.docChanged&&e(o)}return!0}function T1(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),r=s.type.spec.tableRole,i=s.type.schema,l=[];if(r=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),u=a<e.childCount-1?0:Math.max(0,o-1);(d||u)&&(c=Zr(Ve(i).row,new A(c,d,u)).content),l.push(c)}else if(r=="cell"||r=="header_cell")l.push(t||o?Zr(Ve(i).row,new A(e,t,o)).content:e);else return null;return E1(i,l)}function E1(n,e){const t=[];for(let s=0;s<e.length;s++){const r=e[s];for(let i=r.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=r.child(i).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(T.empty),t[s]<o){const r=Ve(n).cell.createAndFill(),i=[];for(let l=t[s];l<o;l++)i.push(r);e[s]=e[s].append(T.from(i))}return{height:e.length,width:o,rows:e}}function Zr(n,e){const t=n.createAndFill();return new wa(t).replace(0,t.content.size,e).doc}function M1({width:n,height:e,rows:t},o,s){if(n!=o){const r=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=r[l]||0,u=0;d<o;u++){let p=a.child(u%a.childCount);d+p.attrs.colspan>o&&(p=p.type.createChecked(xn(p.attrs,p.attrs.colspan,d+p.attrs.colspan-o),p.content)),c.push(p),d+=p.attrs.colspan;for(let h=1;h<p.attrs.rowspan;h++)r[l+h]=(r[l+h]||0)+p.attrs.colspan}i.push(T.from(c))}t=i,n=o}if(e!=s){const r=[];for(let i=0,l=0;i<s;i++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);i+u.attrs.rowspan>s&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,s-u.attrs.rowspan)},u.content)),a.push(u)}r.push(T.from(a))}t=r,e=s}return{width:n,height:e,rows:t}}function A1(n,e,t,o,s,r,i){const l=n.doc.type.schema,a=Ve(l);let c,d;if(s>e.width)for(let u=0,p=0;u<e.height;u++){const h=t.child(u);p+=h.nodeSize;const f=[];let m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<s;g++)f.push(m);n.insert(n.mapping.slice(i).map(p-1+o),f)}if(r>e.height){const u=[];for(let f=0,m=(e.height-1)*e.width;f<Math.max(e.width,s);f++){const g=f>=e.width?!1:t.nodeAt(e.map[m+f]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const p=a.row.create(null,T.from(u)),h=[];for(let f=e.height;f<r;f++)h.push(p);n.insert(n.mapping.slice(i).map(o+t.nodeSize-2),h)}return!!(c||d)}function gd(n,e,t,o,s,r,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=s;c<r;c++){const d=i*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const p=t.nodeAt(u),{top:h,left:f}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(l).map(u+o),null,{...p.attrs,rowspan:i-h}),n.insert(n.mapping.slice(l).map(e.positionAt(i,f,t)),p.type.createAndFill({...p.attrs,rowspan:h+p.attrs.rowspan-i})),c+=p.attrs.colspan-1}}return a}function yd(n,e,t,o,s,r,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=s;c<r;c++){const d=c*e.width+i,u=e.map[d];if(e.map[d-1]==u){a=!0;const p=t.nodeAt(u),h=e.colCount(u),f=n.mapping.slice(l).map(u+o);n.setNodeMarkup(f,null,xn(p.attrs,i-h,p.attrs.colspan-(i-h))),n.insert(f+p.nodeSize,p.type.createAndFill(xn(p.attrs,0,i-h))),c+=p.attrs.rowspan-1}}return a}function bd(n,e,t,o,s){let r=t?n.doc.nodeAt(t-1):n.doc;if(!r)throw new Error("No table found");let i=Z.get(r);const{top:l,left:a}=o,c=a+s.width,d=l+s.height,u=n.tr;let p=0;function h(){if(r=t?u.doc.nodeAt(t-1):u.doc,!r)throw new Error("No table found");i=Z.get(r),p=u.mapping.maps.length}A1(u,i,r,t,c,d,p)&&h(),gd(u,i,r,t,a,c,l,p)&&h(),gd(u,i,r,t,a,c,d,p)&&h(),yd(u,i,r,t,l,d,a,p)&&h(),yd(u,i,r,t,l,d,c,p)&&h();for(let f=l;f<d;f++){const m=i.positionAt(f,a,r),g=i.positionAt(f,c,r);u.replace(u.mapping.slice(p).map(m+t),u.mapping.slice(p).map(g+t),new A(s.rows[f-l],0,0))}h(),u.setSelection(new X(u.doc.resolve(t+i.positionAt(l,a,r)),u.doc.resolve(t+i.positionAt(d-1,c-1,r)))),e(u)}var P1=Ka({ArrowLeft:is("horiz",-1),ArrowRight:is("horiz",1),ArrowUp:is("vert",-1),ArrowDown:is("vert",1),"Shift-ArrowLeft":ls("horiz",-1),"Shift-ArrowRight":ls("horiz",1),"Shift-ArrowUp":ls("vert",-1),"Shift-ArrowDown":ls("vert",1),Backspace:ss,"Mod-Backspace":ss,Delete:ss,"Mod-Delete":ss});function rs(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function is(n,e){return(t,o,s)=>{if(!s)return!1;const r=t.selection;if(r instanceof X)return rs(t,o,D.near(r.$headCell,e));if(n!="horiz"&&!r.empty)return!1;const i=Sd(s,n,e);if(i==null)return!1;if(n=="horiz")return rs(t,o,D.near(t.doc.resolve(r.head+e),e));{const l=t.doc.resolve(i),a=ud(l,n,e);let c;return a?c=D.near(a,1):e<0?c=D.near(t.doc.resolve(l.before(-1)),-1):c=D.near(t.doc.resolve(l.after(-1)),1),rs(t,o,c)}}}function ls(n,e){return(t,o,s)=>{if(!s)return!1;const r=t.selection;let i;if(r instanceof X)i=r;else{const a=Sd(s,n,e);if(a==null)return!1;i=new X(t.doc.resolve(a))}const l=ud(i.$headCell,n,e);return l?rs(t,o,new X(i.$anchorCell,l)):!1}}function N1(n,e){const t=n.state.doc,o=Yn(t.resolve(e));return o?(n.dispatch(n.state.tr.setSelection(new X(o))),!0):!1}function O1(n,e,t){if(!ns(n.state))return!1;let o=T1(t);const s=n.state.selection;if(s instanceof X){o||(o={width:1,height:1,rows:[T.from(Zr(Ve(n.state.schema).cell,t))]});const r=s.$anchorCell.node(-1),i=s.$anchorCell.start(-1),l=Z.get(r).rectBetween(s.$anchorCell.pos-i,s.$headCell.pos-i);return o=M1(o,l.right-l.left,l.bottom-l.top),bd(n.state,n.dispatch,i,l,o),!0}else if(o){const r=qr(n.state),i=r.start(-1);return bd(n.state,n.dispatch,i,Z.get(r.node(-1)).findCell(r.pos-i),o),!0}else return!1}function I1(n,e){var t;if(e.ctrlKey||e.metaKey)return;const o=vd(n,e.target);let s;if(e.shiftKey&&n.state.selection instanceof X)r(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(s=Yn(n.state.selection.$anchor))!=null&&((t=Yr(n,e))==null?void 0:t.pos)!=s.pos)r(s,e),e.preventDefault();else if(!o)return;function r(a,c){let d=Yr(n,c);const u=ft.getState(n.state)==null;if(!d||!Kr(a,d))if(u)d=a;else return;const p=new X(a,d);if(u||!n.state.selection.eq(p)){const h=n.state.tr.setSelection(p);u&&h.setMeta(ft,a.pos),n.dispatch(h)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",l),ft.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(ft,-1))}function l(a){const c=a,d=ft.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(vd(n,c.target)!=o&&(u=Yr(n,e),!u))return i();u&&r(u,c)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",l)}function Sd(n,e,t){if(!(n.state.selection instanceof z))return null;const{$head:o}=n.state.selection;for(let s=o.depth-1;s>=0;s--){const r=o.node(s);if((t<0?o.index(s):o.indexAfter(s))!=(t<0?0:r.childCount))return null;if(r.type.spec.tableRole=="cell"||r.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 vd(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Yr(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Yn(n.state.doc.resolve(t.pos)):null}var R1=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")),Xr(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,Xr(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Xr(n,e,t,o,s,r){var i;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let u=0,p=0;u<d.childCount;u++){const{colspan:h,colwidth:f}=d.child(u).attrs;for(let m=0;m<h;m++,p++){const g=s==p?r:f&&f[m],b=g?g+"px":"";if(l+=g||o,g||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const C=document.createElement("col");C.style.width=b,e.appendChild(C)}}}for(;c;){const u=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=u}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var Se=new Vn("tableColumnResizing");function D1({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:o=R1,lastColumnResizable:s=!0}={}){const r=new fn({key:Se,state:{init(i,l){var a,c;const d=(c=(a=r.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,u=Ve(l.schema).table.name;return o&&d&&(d[u]=(p,h)=>new o(p,t,h)),new L1(-1,!1)},apply(i,l){return l.apply(i)}},props:{attributes:i=>{const l=Se.getState(i);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(i,l)=>{$1(i,l,n,s)},mouseleave:i=>{z1(i)},mousedown:(i,l)=>{B1(i,l,e,t)}},decorations:i=>{const l=Se.getState(i);if(l&&l.activeHandle>-1)return G1(i,l.activeHandle)},nodeViews:{}}});return r}var L1=class ys{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,o=e.getMeta(Se);if(o&&o.setHandle!=null)return new ys(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new ys(t.activeHandle,o.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);return Ur(e.doc.resolve(s))||(s=-1),new ys(s,t.dragging)}return t}};function $1(n,e,t,o){const s=Se.getState(n.state);if(s&&!s.dragging){const r=H1(e.target);let i=-1;if(r){const{left:l,right:a}=r.getBoundingClientRect();e.clientX-l<=t?i=xd(n,e,"left",t):a-e.clientX<=t&&(i=xd(n,e,"right",t))}if(i!=s.activeHandle){if(!o&&i!==-1){const l=n.state.doc.resolve(i),a=l.node(-1),c=Z.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Cd(n,i)}}}function z1(n){const e=Se.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Cd(n,-1)}function B1(n,e,t,o){var s;const r=(s=n.dom.ownerDocument.defaultView)!=null?s:window,i=Se.getState(n.state);if(!i||i.activeHandle==-1||i.dragging)return!1;const l=n.state.doc.nodeAt(i.activeHandle),a=V1(n,i.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(Se,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){r.removeEventListener("mouseup",c),r.removeEventListener("mousemove",d);const p=Se.getState(n.state);p!=null&&p.dragging&&(F1(n,p.activeHandle,wd(p.dragging,u,t)),n.dispatch(n.state.tr.setMeta(Se,{setDragging:null})))}function d(u){if(!u.which)return c(u);const p=Se.getState(n.state);if(p&&p.dragging){const h=wd(p.dragging,u,t);kd(n,p.activeHandle,h,o)}}return kd(n,i.activeHandle,a,o),r.addEventListener("mouseup",c),r.addEventListener("mousemove",d),e.preventDefault(),!0}function V1(n,e,{colspan:t,colwidth:o}){const s=o&&o[o.length-1];if(s)return s;const r=n.domAtPos(e);let l=r.node.childNodes[r.offset].offsetWidth,a=t;if(o)for(let c=0;c<t;c++)o[c]&&(l-=o[c],a--);return l/a}function H1(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function xd(n,e,t,o){const s=t=="right"?-o:o,r=n.posAtCoords({left:e.clientX+s,top:e.clientY});if(!r)return-1;const{pos:i}=r,l=Yn(n.state.doc.resolve(i));if(!l)return-1;if(t=="right")return l.pos;const a=Z.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 wd(n,e,t){const o=e.clientX-n.startX;return Math.max(t,n.startWidth+o)}function Cd(n,e){n.dispatch(n.state.tr.setMeta(Se,{setHandle:e}))}function F1(n,e,t){const o=n.state.doc.resolve(e),s=o.node(-1),r=Z.get(s),i=o.start(-1),l=r.colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<r.height;c++){const d=c*r.width+l;if(c&&r.map[d]==r.map[d-r.width])continue;const u=r.map[d],p=s.nodeAt(u).attrs,h=p.colspan==1?0:l-r.colCount(u);if(p.colwidth&&p.colwidth[h]==t)continue;const f=p.colwidth?p.colwidth.slice():_1(p.colspan);f[h]=t,a.setNodeMarkup(i+u,null,{...p,colwidth:f})}a.docChanged&&n.dispatch(a)}function kd(n,e,t,o){const s=n.state.doc.resolve(e),r=s.node(-1),i=s.start(-1),l=Z.get(r).colCount(s.pos-i)+s.nodeAfter.attrs.colspan-1;let a=n.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Xr(r,a.firstChild,a,o,l,t)}function _1(n){return Array(n).fill(0)}function G1(n,e){var t;const o=[],s=n.doc.resolve(e),r=s.node(-1);if(!r)return K.empty;const i=Z.get(r),l=s.start(-1),a=i.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){const d=a+c*i.width;if((a==i.width-1||i.map[d]!=i.map[d+1])&&(c==0||i.map[d]!=i.map[d-i.width])){const u=i.map[d],p=l+u+r.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(t=Se.getState(n))!=null&&t.dragging&&o.push(ge.node(l+u,l+u+r.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),o.push(ge.widget(p,h))}}return K.create(n.doc,o)}function W1({allowTableNodeSelection:n=!1}={}){return new fn({key:ft,state:{init(){return null},apply(e,t){const o=e.getMeta(ft);if(o!=null)return o==-1?null:o;if(t==null||!e.docChanged)return t;const{deleted:s,pos:r}=e.mapping.mapResult(t);return s?null:r}},props:{decorations:g1,handleDOMEvents:{mousedown:I1},createSelectionBetween(e){return ft.getState(e.state)!=null?e.state.selection:null},handleTripleClick:N1,handleKeyDown:P1,handlePaste:O1},appendTransaction(e,t,o){return S1(o,x1(o,t),n)}})}const Xn=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},Td="data-gs-mrk-fs",Ed="data-gs-ib",as="data-gs-ifrg",Je="attrs",Md={[Je]:{default:"{}"}},Ze={[Je]:{default:{}}},Ad=n=>({[Je]:JSON.stringify(Xn(n))}),Ye=n=>({attrs:Xn(n)}),Qn=n=>e=>[n,e.attrs.attrs,0],mt=n=>n.attrs[Je]?JSON.parse(n.attrs[Je]):{},j1={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${as}]`,getAttrs:Ye}],toDOM:()=>["span",{[as]:""},0]},div:{group:"block",content:"inline*",attrs:Ze,parseDOM:[{tag:"div",getAttrs:Ye}],toDOM:Qn("div")},paragraph:{group:"block",content:"inline*",attrs:Ze,parseDOM:[{tag:"p",getAttrs:Ye}],toDOM:Qn("p")},orderedList:{group:"block",content:"listItem+",attrs:Ze,parseDOM:[{tag:"ol",getAttrs:Ye}],toDOM:Qn("ol")},bulletList:{group:"block",content:"listItem+",attrs:Ze,parseDOM:[{tag:"ul",getAttrs:Ye}],toDOM:Qn("ul")},listItem:{content:"block*",group:"block",attrs:Ze,parseDOM:[{tag:"li",getAttrs:Ye}],toDOM:Qn("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:Ze,parseDOM:[{tag:"pre",getAttrs:Ye}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:Ze,parseDOM:[{tag:"img[src]",getAttrs:Ye}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${Ed}]`}],toDOM(){return["br",{[Ed]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:Ze,parseDOM:[{tag:"br",getAttrs:Ye}],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:Xn(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...p1({tableGroup:"block",cellContent:"block+",cellAttributes:{[Je]:{default:Ze[Je].default,getFromDOM:Xn,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:Xn(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},eo=(n,e)=>({attrs:Md,parseDOM:n.map(t=>({tag:t,getAttrs:Ad})),toDOM:e}),q1={strong:eo(["strong","b"],n=>["b",mt(n)]),link:eo(["a"],n=>["a",mt(n),0]),em:eo(["em","i"],n=>["em",mt(n)]),underline:eo(["u"],n=>["u",mt(n),0]),strikethrough:eo(["s"],n=>["s",mt(n),0]),font_size:{attrs:{...Md,size:{default:null}},parseDOM:[{tag:`span[${Td}]`,getAttrs:n=>({...Ad(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...mt(n),[Td]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},Pd=new pf({nodes:j1,marks:q1}),cs=new WeakMap,Qr=new WeakMap,U1=(n,e)=>{cs.set(n,e),Qr.set(e,n)},K1=(n,e)=>{cs.delete(n),Qr.delete(e)},ei=n=>cs.get(n),J1=n=>Qr.get(n),Nd=n=>{var t;const e=J1(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},Z1=n=>n.dispatchEvent(new CustomEvent("input"));function Y1(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(as)){if(t.getAttribute("style")){t.removeAttribute(as);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 X1(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"),r=d=>d.isChildOf("text"),i=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{o(d)&&s(d)&&!i(d)&&l(d,u)},c=(d,u)=>{if(o(d)&&!s(d)&&r(d)){const p=d.parents().find(h=>h.isInstanceOf("text"));p&&(l(p,u),setTimeout(()=>n.select(p),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Q1=(n,e)=>{const t=e0(n);return t&&c0(t)?t0(n,e):t?za(()=>({type:n.schema.nodes.div}))(n,e):!1};function e0(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 t0(n,e){const{selection:t,schema:o,tr:s}=n;s.split(t.from,1);const r=t.from+1,i=s.doc.nodeAt(r),l={...i.attrs.attrs,id:void 0},a=i.textContent.length>0,c=i.textContent.length||0,d=i.textContent||" ",u=o.text(d),p=o.nodes.div.create(l,a?u:[],[]);return s.replaceRangeWith(r,r+c+2,p),s.setSelection(z.create(s.doc,r+1)),e==null||e(s.scrollIntoView()),!0}function n0(n,e,t){const{state:o,dispatch:s}=n,{selection:r,tr:i}=o,l=(a,c,d)=>{const u={};return a.split(";").forEach(p=>{const[h,f]=p.split(":").map(m=>m.trim());h&&(u[h]=f)}),u[c]=d,Object.entries(u).map(([p,h])=>`${p}: ${h}`).join("; ")};if(!r.empty||t)i.doc.nodesBetween(r.from,r.to,(a,c)=>{var d,u;if(a.type===o.schema.nodes.image){const p=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);i.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:p}})}else if(a.type.isBlock){const p=l(((u=a.attrs.attrs)==null?void 0:u.style)||"","text-align",e);Od(a)?i.setBlockType(r.from,void 0,o.schema.nodes.div,{attrs:{style:p}}):i.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:p}})}});else{const a=o.doc.resolve(r.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);i.setNodeMarkup(c,void 0,{...d.attrs,style:u})}}i.docChanged&&s(i.scrollIntoView())}const to=(n,e)=>{const{from:t,to:o}=n.selection;let s=!1;return n.doc.nodesBetween(t,o,r=>{if(s)return!1;r.marks.some(i=>i.type===e)&&(s=!0)}),s};function o0(n,e,t="_blank"){const{state:o,dispatch:s}=n,{schema:r,selection:i,tr:l}=o,a=r.marks.link;try{const c=a.create({[Je]:JSON.stringify({href:e,target:t})});l.addMark(i.from,i.to,c),s(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function s0(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:r}=t;if(s.empty)return;const i=t.schema.marks.font_size;if(!i){console.error("Font size mark is not defined in the schema.");return}r.addMark(s.from,s.to,i.create({size:e})),o(r.scrollIntoView())}const Ft=(n,e)=>{const{doc:t,selection:o}=n.state,s=t.resolve(o.from);for(let r=s.depth;r>0;r--){const i=s.node(r);if(e(i))return{pos:r>0?s.before(r):0,start:s.start(r),depth:r,node:i}}},r0=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 i0(...n){return(e,t)=>{const o=i=>{e=e.apply(i),t==null||t(i)},s=n.pop();return n.reduce((i,l)=>i||l(e,o),!1)&&s!==void 0&&s(e,t)}}const l0=(n,e)=>{const{state:t,dispatch:o}=n;if(e!=null&&e.event){const{event:s}=e,r=n.posAtCoords({left:s.clientX,top:s.clientY});r!=null&&r.pos&&o(t.tr.setSelection(z.create(t.doc,r.pos)))}else Ba(t,o);setTimeout(()=>setTimeout(()=>n.focus()))},ti=n=>n.isBlock,Od=n=>n.type.name==="inlineFragment",a0=n=>ti(n)&&!Od(n),Id=n=>n.type.name==="bulletList",Rd=n=>n.type.name==="orderedList",c0=n=>n.type.name==="heading",d0=n=>Id(n)||Rd(n),Dd=(n,e)=>{var r,i;const t=(r=Ft(n,l=>l.type===e))==null?void 0:r.node,o=n.state.schema.nodes.listItem;let s;return t?s=vr(o):(i=Ft(n,d0))!=null&&i.node?s=i0(vr(o),Ja(e)):s=Ja(e),s(n.state,n.dispatch)},Ld=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(o=>o.type.name===e)},u0=n=>{var i;const{view:e,prop:t,editor:o,propCSS:s}=n,r=(i=Ft(e,a0))==null?void 0:i.node;if(r){const l=r.attrs.attrs||{},a=r0(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""},p0=n=>{const{view:e,prop:t,markName:o,editor:s,propCSS:r}=n,i=Ld(e,o);if(i){const l=i.attrs;if(l[t])return l[t];if(l[Je]){const a=mt(i).id;if(a){const c=s.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[r]||""}}}return""},$d=(n,e)=>{const{dispatch:t}=n,{nodes:o,marks:s}=n.state.schema;return{text:{selected:()=>{const{selection:r,doc:i}=n.state;return i.textBetween(r.from,r.to," ")},replace:(r,i={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(r));i.select&&(c=c.setSelection(z.create(c.doc,a,a+r.length))),t==null||t(c)}},bold:{toggle:()=>It(s.strong)(n.state,t),isActive:()=>to(n.state,s.strong)},italic:{toggle:()=>It(s.em)(n.state,t),isActive:()=>to(n.state,s.em)},underline:{toggle:()=>It(s.underline)(n.state,t),isActive:()=>to(n.state,s.underline)},strikethrough:{toggle:()=>It(s.strikethrough)(n.state,t),isActive:()=>to(n.state,s.strikethrough)},link:{get:()=>{const r=Nd(n);if(r!=null&&r.is("link"))return r.getAttributes();{const i=Ld(n,"link");return i?mt(i):{}}},toggle:()=>It(s.link)(n.state,t),isActive:()=>to(n.state,s.link),create:r=>{const i=Nd(n);i!=null&&i.is("link")?(i.addAttributes({href:r.url,target:r.target}),n.focus()):o0(n,r.url,r.target)}},alignText:{get:()=>u0({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:r=>n0(n,r.value,!0)},fontSize:{get:()=>p0({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:r=>s0(n,r.value)},image:{open(){const r="assetLayout",{state:i,dispatch:l}=n,{selection:a,doc:c}=i,d=c.textBetween(a.from,a.to," "),u={id:r,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:p=>{const h={alt:d,src:p.asset.getSrc()};l(i.tr.replaceSelectionWith(o.image.createAndFill({attrs:h})))}}};e.runCommand(G.layoutToggle,u)}},heading:{get:()=>{var i;const r=(i=Ft(n,ti))==null?void 0:i.node;return`${(r==null?void 0:r.attrs.level)||""}`},set:({value:r})=>{var a;const{state:i}=n,l=(a=Ft(n,ti))==null?void 0:a.node;rm(i.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:r?parseInt(r,10):0})(i,t)}},listBullet:{isActive:()=>{var r;return!!((r=Ft(n,Id))!=null&&r.node)},toggle:()=>Dd(n,o.bulletList)},listOrdered:{isActive:()=>{var r;return!!((r=Ft(n,Rd))!=null&&r.node)},toggle:()=>Dd(n,o.orderedList)}}};class gt{constructor(e,t,o={}){this.match=e,this.match=e,this.handler=typeof t=="string"?h0(t):t,this.undoable=o.undoable!==!1,this.inCode=o.inCode||!1}}function h0(n){return function(e,t,o,s){let r=n;if(t[1]){let i=t[0].lastIndexOf(t[1]);r+=t[0].slice(i+t[1].length),o+=i;let l=o-s;l>0&&(r=t[0].slice(i-l,i)+r,o=s)}return e.tr.insertText(r,o,s)}}const f0=500;function m0({rules:n}){let e=new fn({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,r){return zd(t,o,s,r,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:o}=t.state.selection;o&&zd(t,o.pos,o.pos,"",n,e)})}}},isInputRules:!0});return e}function zd(n,e,t,o,s,r){if(n.composing)return!1;let i=n.state,l=i.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-f0),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),p=u&&d.handler(i,u,e-(u[0].length-o.length),t);if(p)return d.undoable&&p.setMeta(r,{transform:p,from:e,to:t,text:o}),n.dispatch(p),!0}return!1}const g0=new gt(/--$/,"—"),y0=new gt(/\.\.\.$/,"…"),b0=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),S0=new gt(/"$/,"”"),v0=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),x0=new gt(/'$/,"’"),w0=[b0,S0,v0,x0];function ni(n,e,t=null,o){return new gt(n,(s,r,i,l)=>{let a=t instanceof Function?t(r):t,c=s.tr.delete(i,l),d=c.doc.resolve(i),u=d.blockRange(),p=u&&fa(u,e,a);if(!p)return null;c.wrap(u,p);let h=c.doc.resolve(i-1).nodeBefore;return h&&h.type==e&&_o(c.doc,i-1)&&(!o||o(r,h))&&c.join(i-1),c})}function Bd(n,e,t=null){return new gt(n,(o,s,r,i)=>{let l=o.doc.resolve(r),a=t instanceof Function?t(s):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?o.tr.delete(r,i).setBlockType(r,r,e,a):null})}function C0(n){return ni(/^\s*>\s$/,n)}function k0(n){return ni(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function T0(n){return ni(/^\s*([-+*])\s$/,n)}function E0(n){return Bd(/^```$/,n)}function M0(n,e){return Bd(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function A0(n){const e=w0.concat(y0,g0);let t;return(t=n.nodes.blockquote)&&e.push(C0(t)),(t=n.nodes.orderedList)&&e.push(k0(t)),(t=n.nodes.bulletList)&&e.push(T0(t)),(t=n.nodes.codeBlock)&&e.push(E0(t)),(t=n.nodes.heading)&&e.push(M0(t,6)),m0({rules:e})}const P0="rteProseMirror",N0=_.free,Pe="rte:selectionchange",ke={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>'},O0=(n,e)=>{var a;const{editor:t,el:o}=n,s=cs.get(o),r=$d(s,t),i={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:ke.bold,size:"s",type:"button",editorEvents:{[Pe]:({setState:c})=>{c({active:r.bold.isActive()})}},onClick:({setState:c})=>{r.bold.toggle(),c({active:r.bold.isActive()})}},italic:{id:"italic",icon:ke.italic,size:"s",type:"button",editorEvents:{[Pe]:({setState:c})=>{c({active:r.italic.isActive()})}},onClick:({setState:c})=>{r.italic.toggle(),c({active:r.italic.isActive()})}},underline:{id:"underline",icon:ke.underline,size:"s",type:"button",editorEvents:{[Pe]:({setState:c})=>{c({active:r.underline.isActive()})}},onClick:({setState:c})=>{r.underline.toggle(),c({active:r.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:ke.strikethrough,size:"s",type:"button",editorEvents:{[Pe]:({setState:c})=>{c({active:r.strikethrough.isActive()})}},onClick:({setState:c})=>{r.strikethrough.toggle(),c({active:r.strikethrough.isActive()})}},image:{id:"image",icon:ke.image,size:"s",type:"button",onClick:()=>r.image.open()},link:{id:"link",icon:ke.link,size:"s",type:"button",editorEvents:{[Pe]:({setState:c})=>{c({active:r.link.isActive(),disabled:s.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:u,y:p,width:h,height:f}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(G.layoutRemove,{id:m}),b=r.link.get(),C={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:u,y:p,w:h,h:f},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:y=>{y.preventDefault();const S=new FormData(y.currentTarget);r.link.create({url:S.get("url"),target:S.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(b==null?void 0:b.href)||"",onChange:({value:y,setState:S})=>S({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:S})=>S({value:y})},{type:"row",style:{gap:10,justifyContent:"end"},children:[r.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{r.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(G.layoutToggle,C)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:ke.alignTextLeft},{id:"center",icon:ke.alignTextCenter},{id:"right",icon:ke.alignTextRight},{id:"justify",icon:ke.alignTextJustify}],editorEvents:{[Pe]:({setState:c})=>{c({value:r.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:ke.listBullet,size:"s",type:"button",editorEvents:{[Pe]:({setState:c})=>{c({active:r.listBullet.isActive()})}},onClick:({setState:c})=>{r.listBullet.toggle(),c({active:r.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:ke.listOrdered,size:"s",type:"button",editorEvents:{[Pe]:({setState:c})=>{c({active:r.listOrdered.isActive()})}},onClick:({setState:c})=>{r.listOrdered.toggle(),c({active:r.listOrdered.isActive()})}},heading:{id:"heading",type:"selectField",size:"s",value:"",emptyState:"Heading",options:[{id:"",label:"Normal"},{id:"1",label:"Heading 1"},{id:"2",label:"Heading 2"},{id:"3",label:"Heading 3"},{id:"4",label:"Heading 4"},{id:"5",label:"Heading 5"},{id:"6",label:"Heading 6"}],editorEvents:{[Pe]:({setState:c})=>{c({value:r.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.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:{[Pe]:({setState:c})=>{c({value:r.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.fontSize.set({value:c}),s.focus()}}},l=[i.bold,i.italic,i.underline,i.strikethrough,i.image,i.link,i.listBullet,i.listOrdered,i.alignText,i.heading,i.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:r,layouts:i,proseMirror:{view:s},items:l}))||l};class I0{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;$d(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=""}}const R0=j(function(n,e={}){const t={plugins:i=>i.plugins,...e},o=(i,l)=>{var f,m;const a=((f=t.schema)==null?void 0:f.call(t,{editor:n,schema:Pd}))||Pd,{nodes:c,marks:d}=a,u=rn.fromSchema(a).parse(i),p=hn.create({doc:u,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,Plugin:fn,plugins:[D1(),W1(),A0(a),gm(),Sr({Tab:md(1),"Shift-Tab":md(-1)}),Sr({Enter:Hn($a,km(c.listItem),Q1),"Shift-Enter":Hn(La,(g,b)=>(b&&b(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":Ua,"Mod-y":gr,"Mod-Shift-z":gr,"Mod-b":It(d.strong),"Mod-i":It(d.em),"Shift-Tab":vr(c.listItem),Tab:Mm(c.listItem)}),Sr(lm)]})}),h=new r1({mount:i},{state:p,dispatchTransaction(g){var x;const{state:b}=h,C=b.apply(g),y=!b.doc.eq(C.doc);h.updateState(C);const S=!b.selection.eq(C.selection);y&&(Z1(((x=l==null?void 0:l.view)==null?void 0:x.el)||i),h.focus()),(S||y)&&n.trigger(Pe)}});return i.__rteView=h,h.setProps({nodeViews:{image(g){return new I0(g,h,n)}}}),h},s=i=>O0(i,t);n.setCustomRte({toolbar:s,parseContent:!0,async enable(i,l,a){const c=ei(i);if(c)return c;const d=o(i,a);return U1(i,d),l0(d,a),d},disable(i){const l=ei(i);if(l)return K1(i,l),l.destroy(),{forceSync:!0}},getContent(i){const l=ei(i);if(l){const{schema:a,doc:c}=l.state,d=document.createElement("div"),u=Ot.fromSchema(a).serializeFragment(c.content);return u.childNodes.forEach(p=>{p.nodeType===Node.ELEMENT_NODE&&p.innerHTML===""&&(p.innerHTML="<br/>")}),d.appendChild(u),Y1(d),i.classList.remove("ProseMirror-focused"),d.innerHTML}return i.innerHTML}});const r=X1(n,t);q({editor:n,licenseKey:t.licenseKey,plan:N0,pluginName:P0,cleanup:()=>{n.RichTextEditor.customRte=void 0,r()}})}),D0="canvasEmptyState",L0=_.startup,$0=j(function(n,e={}){const t=new WeakMap,o=new WeakMap,s=new WeakMap,r=new Set,i=new WeakMap,l={emptyStates:[],...e},a=(y,S)=>{let x=!1;const{isValid:w}=S;return Array.isArray(w)?x=w.some(v=>y.is(v)):bt(w)?x=w({component:y,editor:n}):x=y.is(w),x},c=y=>{const S=t.get(y);t.delete(y),S==null||S()},d=y=>{y.views.forEach(S=>c(S)),s.delete(y)},u=y=>{if(!(!y||r.has(y)))try{r.add(y);const S=y.components().length>0,x=s.get(y);if(S&&x)d(y);else if(!S&&!x){const w=i.has(y)?i.get(y):l.emptyStates.find(v=>a(y,v));if(i.set(y,w),!w)return;y.views.forEach(v=>{const E=w.render({editor:n,component:y,componentView:v,mount:k=>{o.set(v,k),s.set(y,!0);const M=v.getChildrenContainer();M==null||M.appendChild(k)},unmount:()=>c(v)});t.set(v,()=>{E==null||E();const k=o.get(v);k==null||k.remove()})})}}finally{r.delete(y)}},p=y=>{s.has(y)&&d(y)},h=({model:y})=>{u(y.getComponent())},f=n.Components.events,m=`${f.update}:components`,g="component:mount",b=n.Canvas.events.frameLoadBody,C=f.removed;n.on(m,u),n.on(g,u),n.on(C,p),n.on(b,h),q({editor:n,licenseKey:l.licenseKey,plan:L0,pluginName:D0,cleanup:()=>{n.off(m,u),n.off(g,u),n.off(C,p),n.off(b,h)}})}),Vd="canvasFullSize",z0=_.startup,B0=(n,e)=>{var r;const{rule:t,ruleView:o}=e,{style:s}=t.attributes;if(s&&s[n]){const i=s[n],l=(r=i==null?void 0:i.endsWith)==null?void 0:r.call(i,"vh"),a=o.frameView.model;if(l&&a.hasAutoHeight()){const c=parseFloat(i),d=t.toCSS({style:{...s,[n]:`${window.outerHeight*(c/100)}px`}});e.css=d}}},V0=n=>{["height","min-height","max-height"].forEach(e=>B0(e,n))},H0=j(function(n,e={}){const{Canvas:t,Commands:o,Devices:s,Css:r}=n,i={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:l,canvasOffsetX:a,canvasTransition:c,deviceMaxWidth:d,deviceMinHeigth:u,frameBorderRadius:p,frameTransition:h}=i,f=`${u}px`,m=t.events,g="core:preview",b=`${o.events.stopCommand}${g}`,C=t.getConfig(),y=`${Vd}:disable`,S=s.getAll().map(L=>({...L.attributes})),x=c*1e3,w={x:a,y:l};let v={},E,k;C.scrollableCanvas=!0,s.getAll().map(L=>{!L.get("width")&&L.set("width",`${d}px`),!L.get("height")&&L.set("height","auto"),!L.get("minHeight")&&L.set("minHeight",f)});const M=L=>{const W="data-gs-plg-full-size",_e=document.querySelector(`style[${W}]`);if(L&&_e)return _e.remove();const Gt=_e||document.createElement("style"),ms=t.getZoomMultiplier();Gt.setAttribute(W,"true"),Gt.innerHTML=`
809
+ .gjs-frame-wrapper { transition: width ${h}s !important; }
810
+ .gjs-frame-wrapper__bottom { height: ${l*ms}px }
811
+ .gjs-frame { border-radius: ${p}px }
812
+ `,!_e&&document.body.appendChild(Gt)};n.on(m.frameLoadHead,L=>{if(!C.scrollableCanvas)return;const{window:W}=L,_e=W.document,Gt=_e.head,ms="data-gs-plg-wrapper-style",gs=Gt.querySelector(`style[${ms}]`)||_e.createElement("style");gs.setAttribute(ms,"true"),gs.innerHTML=`
813
+ [data-gjs-type="wrapper"] { min-height: ${f}; }
814
+ [data-gjs-type="mjml"] { min-height: ${f} !important; }
815
+ [data-gjs-type="mj-body"] { min-height: ${f} !important; }
816
+ `,!Gt.contains(gs)&&Gt.appendChild(gs)});const P=()=>E.style.display="none",N=()=>E.style.display="",O=Cn(()=>{t.fitViewport({zoom:L=>L>100?100:L,ignoreHeight:!0,gap:w}),M(),setTimeout(()=>{var W,_e;const{em:L}=n;L.destroyed||((_e=(W=n.getSelected())==null?void 0:W.getEl())==null||_e.scrollIntoView({block:"nearest"}),n.refresh({tools:!0}),N(),o.isActive(g)?L.stopDefault():L.runDefault())},x)},100),$=(L={})=>{L.options&&L.options.from!=="fitViewport"&&t.fitViewport({zoom:t.getZoom(),ignoreHeight:!0,gap:w})},B=()=>{P(),O()},Q=()=>{v.overflowX="hidden",v.overflowY="auto"},ae=()=>{k==null||k.disconnect(),O.clear()},Fe=[[s.events.select,B],[m.zoom,$],[b,Q],[n.events.destroy,ae],[r.events.mountBefore,V0]];o.add(y,()=>{s.devices.reset(S),C.scrollableCanvas=!1,t.getModel().updateDevice(),t.setZoom(100),t.setCoords(0,0),v.overflowY="hidden",M(!0),Fe.forEach(([L,W])=>n.off(L,W)),ae(),o.run("studio:canvasReload")}),Fe.forEach(([L,W])=>n.on(L,W)),n.onReady(()=>{const L=t.getElement(),W=t.getFramesEl();E=t.getSpotsEl(),v=L.style,v.overflowX="hidden",W.style.transition=`transform ${c}s`,M(),k=new ResizeObserver(()=>{P(),O()}),k.observe(L.parentElement),O()}),q({editor:n,licenseKey:i.licenseKey,plan:z0,pluginName:Vd,cleanup:()=>{n.runCommand(y)}})}),oi="canvasGridMode",F0=_.startup,si="component-grid-mode",no="grid-mode",oo="gjs-drag-grid-spot",Hd=`${oo}__grid-item`,Fd=`${oo}__grid-target`,_d=`${oo}__snapped`,_0=`${oo}__container`,G0=()=>{const n="data-gjs-drag-grid-style",e=document,t="var(--gs-theme-cl-cmp-bg1, var(--gjs-color-highlight))",o="var(--gs-theme-cl-cmp-bg2, var(--gjs-color-blue))",s=e.querySelector(`style[${n}]`)||e.createElement("style");s.setAttribute(n,"true"),s.innerHTML=`
817
+ .${Hd} {
818
818
  outline: 2px solid ${o};
819
819
  background: ${t};
820
820
  outline-offset: -2px;
@@ -823,14 +823,14 @@
823
823
  height: 100%;
824
824
  opacity: 0.1;
825
825
  }
826
- .${Fd} {
826
+ .${_d} {
827
827
  width: 100%;
828
828
  height: 100%;
829
829
  outline: 2px solid ${o};
830
830
  outline-offset: -2px;
831
831
  position: absolute;
832
832
  }
833
- .${Hd} {
833
+ .${Fd} {
834
834
  position: absolute;
835
835
  z-index: -1;
836
836
  background: ${t};
@@ -838,14 +838,14 @@
838
838
  outline-offset: -1px;
839
839
  opacity: 0.35;
840
840
  }
841
- `,e.head.appendChild(s)};function _d(n){const{editor:e,type:t}=n,o=q0(e,n.component),s=oi(e,o.component);if(!U0(e,o,s,t))return{target:o,container:s,startScroll:si(e).scroll,shadowContainerEl:document.createElement("div"),shadowSnappedEl:document.createElement("div"),shadowTargetEl:document.createElement("div"),spot:e.Canvas.addSpot({type:eo,component:s.component})}}function Gd(n){const{editor:e,shadowTargetEl:t,shadowSnappedEl:o,shadowContainerEl:s,spotEl:r,target:i,container:l}=n,{Canvas:a}=e,c=e.config.stylePrefix;r==null||r.appendChild(s),s==null||s.appendChild(t),s==null||s.appendChild(o),_0(s,l),G0(t,i,l),W0(o,i),j0(s,l.el),i.el.style.opacity="0";const d=a.getSpots().filter(u=>u.type!==eo);e.em.stopDefault({preserveSelected:!0}),a.removeSpots(d),a.startAutoscroll(),a.getBody().classList.add(`${c}is__grabbing`)}function Wd(n){const{editor:e,shadowSnappedEl:t,shadowContainerEl:o,target:s,cancelled:r}=n,{Canvas:i}=e,l=e.config.stylePrefix,{component:a}=s;if(!r){const c=window.getComputedStyle(t);a.addStyle({"grid-area":c.gridArea,width:"",height:""})}s.el.style.opacity="",o.contains(t)&&(o==null||o.removeChild(t)),e.getModel().runDefault({preserveSelected:1}),i.stopAutoscroll(),i.getBody().classList.remove(`${l}is__grabbing`),i.removeSpots({type:eo}),e.select(a)}function _0(n,{rows:e,columns:t}){const o=[];for(let s=0;s<t.length;s++){o[s]=[];for(let r=0;r<e.length;r++){const i=document.createElement("div");i.className=Vd,i.style.gridArea=`${r+1} / ${s+1}`,o[s][r]=i,n.appendChild(i)}}return o}function G0(n,e,t){return n.className=Hd,n.style.top=`${e.offset.top-t.offset.top}px`,n.style.left=`${e.offset.left-t.offset.left}px`,n.style.width=`${e.offset.width+e.margin.left+e.margin.right}px`,n.style.height=`${e.offset.height+e.margin.top+e.margin.bottom}px`,n}function W0(n,e){const t=Ud(e.el,e.computedStyles);return n.className=Fd,n.style.gridArea=`${t.row.start} / ${t.column.start} / ${t.row.end} / ${t.column.end}`,n}function j0(n,e){const t=window.getComputedStyle(e);n.className=H0,n.style.position="relative",n.style.display=t.display,n.style.gap=t.gap,n.style.padding=t.padding,n.style.border=t.border,n.style.gridTemplateColumns=t.gridTemplateColumns,n.style.gridTemplateRows=t.gridTemplateRows}function jd(n,e){if(e){if(Array.isArray(e))return[...e].pop()}else return[...n.getSelectedAll()].pop();return e}function q0(n,e){const t=jd(n,e),o=t.getEl(),s=window.getComputedStyle(o);return{component:t,el:o,offset:n.Canvas.offset(o),margin:{top:parseFloat(s.marginTop),right:parseFloat(s.marginRight),bottom:parseFloat(s.marginBottom),left:parseFloat(s.marginLeft)},computedStyles:s}}function oi(n,e){const t=e.parent(),o=t.getEl(),s=window.getComputedStyle(o);return{component:t,el:o,offset:n.Canvas.offset(o),computedStyles:s,padding:{top:parseFloat(s.paddingTop),right:parseFloat(s.paddingRight),bottom:parseFloat(s.paddingBottom),left:parseFloat(s.paddingLeft)},columns:s.gridTemplateColumns.split(" ").map(i=>parseFloat(i)),rows:s.gridTemplateRows.split(" ").map(i=>parseFloat(i)),gap:{column:parseInt(s.columnGap),row:parseInt(s.rowGap)}}}function gt(n,e,t,o,s=1){let r=0;for(let i=e;i<=n.length;i++){if(r+(n[i-1]+o)*s>t)return i;r+=o+n[i-1]}return n.length+1}function si(n){const{scrollY:e,scrollX:t}=n.Canvas.getWindow();return{scroll:{top:e,left:t}}}function U0(n,e,t,o){const s=r=>n.em.logWarning(r);return o==="draggable"&&e.component.get(o)===!1?(s(`[${ti}] The element is not ${o}`),!0):t.computedStyles.display!=="grid"?(s(`[${ti}] The container does not have style display:grid`),!0):!1}function ri(n,e,t={}){const o=jd(n,e),s=o==null?void 0:o.parent(),r=s==null?void 0:s.getEl();if(!s||!r)return!1;const{enableGrid:i}=t,l=window.getComputedStyle(r).display==="grid";return yt(i)?i({component:o,parent:s,isParentGrid:l}):l}const qd=n=>n.split(" ").map(e=>parseFloat(e));function Ud(n,e){const t=n.ownerDocument.defaultView,o=e||t.getComputedStyle(n),s=o.gridArea.split("/").some(v=>isNaN(parseInt(v.trim()))),r={isComputed:s,raw:o.gridArea};if(!s)return{...r,row:{start:parseInt(o.gridRowStart),end:parseInt(o.gridRowEnd)},column:{start:parseInt(o.gridColumnStart),end:parseInt(o.gridColumnEnd)}};const i=n.parentElement,l=t.getComputedStyle(i),a=parseFloat(l.columnGap)||0,c=parseFloat(l.rowGap)||0,d=qd(l.gridTemplateColumns),u=qd(l.gridTemplateRows),p=parseFloat(l.paddingLeft)||0,h=parseFloat(l.paddingTop)||0,f=i.getBoundingClientRect(),m=n.getBoundingClientRect(),g=(v,w,x,T,k)=>{let M=1,P=T+k;for(let O=0;O<w.length;O++){const N=w[O],L=P+N;if(v>=P&&v<L)return M;P=L+x,M++}return-1},b=g(m.left,d,a,f.left,p),C=g(m.right-1,d,a,f.left,p)+1,y=g(m.top,u,c,f.top,h),S=g(m.bottom-1,u,c,f.top,h)+1;return{...r,row:{start:y,end:S},column:{start:b,end:C}}}function K0(n){n.Commands.add(ni,{stop(){},run(e,t,o={}){const s=_d({editor:e,component:o.target,type:"draggable"});if(!s){this.stopCommand();return}const{spot:r,target:i,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c,startScroll:d}=s;let{container:u}=s,p;new e.Utils.Dragger({doc:i.el.ownerDocument,onStart:()=>{p=setTimeout(()=>{Gd({editor:e,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:r.attributes.spotEl,target:i,container:u}),u=oi(e,i.component)},10)},onEnd:(f,m,{cancelled:g})=>{clearTimeout(p),Wd({editor:e,shadowSnappedEl:a,shadowContainerEl:l,target:i,cancelled:g}),this.stopCommand(),e.em.set("_cmpDrag",1)},setPosition:({x:f,y:m})=>{const{scroll:g}=si(e),{columns:b,rows:C,gap:y,offset:S,padding:v}=u,{offset:w,margin:x}=i,T=w.top-S.top-v.top-x.top+m-d.top+g.top,k=w.left-S.left-v.left-x.left+f-d.left+g.left,M=Math.min(gt(b,1,k,y.column,.5),b.length),P=Math.min(gt(C,1,T,y.row,.5),C.length),O=Math.min(gt(b,M,w.width,y.column)+1,b.length+1),N=Math.min(gt(C,P,w.height,y.row)+1,C.length+1);a.style.gridArea=`${P} / ${M} / ${N} / ${O}`,c.style.top=`${T+v.top}px`,c.style.left=`${k+v.left}px`}}).start(o.event)}})}function J0(n,e){const t=_d({editor:n,component:e.target,type:"resizable"});if(!t)return;const{onMove:o,onEnd:s}=e.options||{},{spot:r,target:i,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c}=t;let{container:d}=t,u="",p;return{onStart:h=>{u=h.target.dataset.gjsHandler||"",p=setTimeout(()=>{Gd({editor:n,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:r.attributes.spotEl,target:i,container:d}),d=oi(n,i.component)},10),n.trigger("component:resize",{...i,type:"start"})},onEnd:(h,f)=>{const{startDim:m,rectDim:g}=f.resizer,b=JSON.stringify(m)===JSON.stringify(g);clearTimeout(p),Wd({editor:n,shadowSnappedEl:a,shadowContainerEl:l,target:i,cancelled:b}),s==null||s(h,f)},onMove:h=>{var Z;const f=h;if(((Z=f.target)==null?void 0:Z.nodeName)==="I")return;const{scroll:m}=si(n),g=Ud(a);let b=0,C=0,y=0,S=0;const v=i.margin.left,w=i.margin.top,x=i.margin.bottom,T=i.margin.right,{width:k,top:M,left:P,height:O}=i.offset,N=f.clientX,L=f.clientY,z={t:M-w,l:P-v,h:O+w+x,w:k+v+T};u.startsWith("t")?(z.t=L-w,z.h=M+O+w+x-L):u.startsWith("b")&&(z.h=L-M+w+x),u.endsWith("l")?(z.l=N-v,z.w=P+k+v+T-N):u.endsWith("r")&&(z.w=N-P+v+T),u.endsWith("l")&&(y=m.left,g.column.start=gt(d.columns,1,z.l-d.offset.left-y-d.padding.left,d.gap.column,.5)),u.startsWith("t")&&(b=m.top,g.row.start=gt(d.rows,1,z.t-d.offset.top+b-d.padding.top,d.gap.row,.5)),u.endsWith("r")&&(S=m.left,g.column.end=Math.max(gt(d.columns,g.column.start,z.w-S,d.gap.column,.5),g.column.start+1)),u.startsWith("b")&&(C=m.top,g.row.end=Math.max(gt(d.rows,g.row.start,z.h+C,d.gap.row,.5),g.row.start+1)),a.style.gridArea=`${g.row.start} / ${g.column.start} / ${g.row.end} / ${g.column.end}`,c.style.width=`${z.w+S+y}px`,c.style.height=`${z.h+C-b}px`,c.style.left=`${z.l-d.offset.left-y}px`,c.style.top=`${z.t-d.offset.top+b}px`,o==null||o(h)}}}const Kd=["px","%","em","rem","vw","vh"],Z0=(n,e)=>{const t=n.Styles.getSectors().find(o=>!!o.getProperty(e));return{sector:t,property:t?t.getProperty(e):void 0}},Y0=(n,e)=>Z0(n,e),X0=(n,{x:e,y:t,mergable:o}={})=>{const s={property:`${n}-x`,type:"integer",units:Kd,...e},r={property:`${n}-y`,type:"integer",units:Kd,...t};return{property:n,type:"composite",properties:[s,r],...o&&{fromStyle(i,{name:l,separator:a,property:c}){const[d,u]=c.getProperties(),[p,h]=(i[l]||"").split(a);return{[d.getId()]:i[d.getName()]||p||"",[u.getId()]:i[u.getName()]||h||p||""}},toStyle(i,{name:l,property:a}){const[c,d]=a.getProperties(),u=i[c.getId()],p=i[d.getId()];return{[l]:u===p?u:`${u} ${p}`}}}}},ii={display:["grid"]};function Q0(n=""){const e=/^repeat\(\s*(\d+)\s*,\s*(.+)\s*\)$/i,t=/^minmax\(\s*(.+?)\s*,\s*(.+?)\s*\)$/i,o=n.match(e);if(!o)return null;const s=parseInt(o[1],10),r=o[2];let i=r,l=r;const a=r.match(t);return a&&(i=a[1],l=a[2]),{total:s,min:i===l?"":i,max:l}}function ey(n={}){let e="",t="",o="",s="";const r=m=>m.split("/").map(g=>g.trim()).filter(Boolean),i=n["grid-area"]||"",l=n["grid-column"]||"",a=n["grid-row"]||"",c=r(i),d=r(l),u=r(a),p=c.length,h=d.length,f=u.length;return p===4?(o=c[0],e=c[1],s=c[2],t=c[3]):p===3?(o=c[0],e=c[1],s=c[2]):p===2?(o=c[0],e=c[1]):p===1&&(o=c[0]),h===2?(e=d[0],t=d[1]):h===1&&(e=d[0]),f===2?(o=u[0],s=u[1]):f===1&&(o=u[0]),{columnStart:e,columnEnd:t,rowStart:o,rowEnd:s}}function Jd(n){const{property:e,label:t}=n,o="1",s="1fr";return{property:e,label:t,type:"composite",requires:ii,generic:!0,properties:[{name:" ",property:`${e}-repeat`,type:"number",full:!0,min:1,default:"1"},{label:"Min size",property:`${e}-min`,type:"number",min:0,units:["px","%"],default:"0"},{label:"Max size",property:`${e}-max`,type:"number",min:1,units:["fr","px","%"],default:"1"}],fromStyle(r,i){const{name:l,property:a}=i,[c,d,u]=a.getProperties(),p=r[l],h=Q0(p),f=(h==null?void 0:h.max)??s;return{[c.id]:(h==null?void 0:h.total)??o,[d.id]:(h==null?void 0:h.min)??"",[u.id]:f===s?"":f}},toStyle(r,{name:i,property:l}){const[a,c,d]=l.getProperties(),u=r[a.id],p=r[c.id],h=r[d.id]||s,f=p&&h?`minmax(${p}, ${h})`:h;return{[i]:`repeat(${u||o}, ${f})`}}}}function ty(n,e){if(!e.styleableGrid)return;const{property:t,...o}=Y0(n,"display");if(!t)return;const s=t.getOption("grid"),r=o.sector;s||t.addOption({id:"grid",label:"Grid"}),r.addProperty(Jd({label:"Columns",property:"grid-template-columns"}),{}),r.addProperty(Jd({label:"Rows",property:"grid-template-rows"}),{}),r.addProperty({id:"grid-gap",requires:ii,...X0("gap",{x:{id:"grid-row-gap",label:"Row",property:"row-gap",min:0,default:"0"},y:{id:"grid-column-gap",label:"Column",property:"column-gap",min:0,default:"0"},mergable:!0})},{}),r.addProperty({type:"composite",property:"grid-area",label:"Grid area",requiresParent:ii,generic:!0,properties:[{label:"Row start",property:"grid-row-start",type:"integer",default:"auto"},{label:"Row end",property:"grid-row-end",type:"integer",default:"auto"},{label:"Column start",property:"grid-column-start",type:"integer",default:"auto"},{label:"Column end",property:"grid-column-end",type:"integer",default:"auto"}],fromStyle(i){const l=ey(i);return{"grid-column-start":i["grid-column-start"]||l.columnStart,"grid-column-end":i["grid-column-end"]||l.columnEnd,"grid-row-start":i["grid-row-start"]||l.rowStart,"grid-row-end":i["grid-row-end"]||l.rowEnd}},toStyle(i,{name:l}){const a=i["grid-row-start"]||"auto",c=i["grid-row-end"]||"auto",d=i["grid-column-start"]||"auto",u=i["grid-column-end"]||"auto";return{[l]:`${a} / ${d} / ${c} / ${u}`}}},{})}const ny=G(function(n,e={}){const t={itemResizable:!0,...e},{Canvas:o,Commands:s,Components:r}=n,{itemResizable:i}=t,l=o.events,a=s.events,c=r.events,d=`${a.runBeforeCommand}tlb-move`,u=`${a.runBeforeCommand}resize`;let p;K0(n);const h=({options:y})=>{ri(n,y.target,t)&&(n.runCommand(ni,{...y}),y.abort=!0)},f=({options:y})=>{ri(n,y.target,t)&&Object.assign(y.options,J0(n,y))},m=()=>{const y=o.getSpots({type:eo}).pop();if(!y)return;let S=y.attributes.spotEl;S||(S=document.createElement("div"),S.className=to,y.set({spotEl:S})),Object.entries(y.getStyle()).forEach(([v,w])=>S.style.setProperty(v,w)),p==null||p.appendChild(S)},g=({spot:y})=>{const S=y.attributes.spotEl;y.type!==eo||!S||p==null||p.removeChild(S)};if(i){const y=S=>{const v=yt(i)?i({component:S}):i;return typeof v=="boolean"?v:{tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1,...v}};n.on(c.resizeInit,S=>{const{component:v}=S;if(ri(n,v,t)){const w=y(v);S.resizable=w}})}const b=[[d,h],[u,f],[l.spot,m],[l.spotRemove,g]];b.forEach(([y,S])=>{n.on(y,S)}),n.onReady(()=>{p=o.getSpotsEl(),F0(),ty(n,t)});const C=()=>{delete n.Commands.commands[ni],b.forEach(([y,S])=>{n.off(y,S)})};W({editor:n,licenseKey:t.licenseKey,plan:V0,pluginName:ti,cleanup:C})});var He=(n=>(n.panelBlocks="panelBlocks",n.panelPagesLayers="panelPagesLayers",n.panelGlobalStyles="panelGlobalStyles",n.panelSidebarTabs="panelSidebarTabs",n.panelAssets="panelAssets",n))(He||{});const Zd="sidebarButtonsTarget",cs=n=>{const{id:e,icon:t,label:o,tooltip:s,className:r,skipSelfClose:i,removeLayouts:l,layoutComponent:a,layoutCommand:c}=n,d=e;return{id:Yd(e),type:"button",icon:t,tooltip:o||s,className:r,editorEvents:{[`${xi.layoutToggleId}${d}`]:({fromEvent:u,setState:p,editor:h})=>{p({active:u.isOpen}),setTimeout(()=>h.refresh({tools:!0}),20)}},onClick:({editor:u,state:p})=>{if(p.active&&i)return;const h=(c==null?void 0:c.placer)||{type:"static",layoutId:Zd},f={...h,skipCleanup:h.type==="static"},m=l||Object.keys(He).filter(b=>b!==d);Xd(u,{removeLayouts:m,layout:{placer:f}});const g={id:d,placer:h,header:(c==null?void 0:c.header)??{label:o,close:!i},layout:a,style:{width:280,height:"100%",borderRightWidth:1,...c==null?void 0:c.style}};u.runCommand(_.layoutToggle,g)}}},Yd=n=>`button__${n}`,Xd=(n,e={})=>{(e.removeLayouts||Object.keys(He)).forEach(o=>n.runCommand(_.layoutRemove,{id:o,layout:e.layout}))},Qd=n=>{const e=(n==null?void 0:n.breakpointTablet)??1024,t=(n==null?void 0:n.breakpointMobile)??768,o={breakpointTablet:e,breakpointMobile:t},s={},r=[{id:He.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:He.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:He.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:He.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:h,editor:f})=>{var b;const m=f.getSelected(),g={type:"image",src:h.src};if(m!=null&&m.is("image"))return m.set("src",h.src);if(m&&f.Components.canMove(m,g)){const C=m.append(g)[0];C&&f.select(C)}else if(!m){const C=(b=f.getWrapper())==null?void 0:b.append(g)[0];C&&f.select(C)}}}}],i=[...r,{id:He.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:Zd,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=(h,f)=>{const m=h.map(b=>{const C=cs(b);return n!=null&&n.sidebarButton?n.sidebarButton({id:b.id,buttonIds:He,breakpoint:f,buttonProps:C,sidebarButtonProps:b,...o,createSidebarButton:y=>cs({...b,...y})}):C}).filter(Boolean);return(n!=null&&n.sidebarButtons?n==null?void 0:n.sidebarButtons({buttonIds:He,breakpoint:f,sidebarButtons:m,...o,createSidebarButton:b=>cs({...b})}):m).filter(Boolean)},u=(h,f,m)=>{var g;return((g=n==null?void 0:n.rootLayout)==null?void 0:g.call(n,{breakpoint:m,sidebarButtons:f,rootLayout:h,layoutSidebarLeft:a,layoutSidebarTarget:l,...o,createSidebarButton:b=>cs({...b})}))??h};if(e){const h=d(i,e);s[e]=u({type:"row",style:{height:"100%"},children:[{...a,children:h},l,c]},h,e)}if(t){const h=i.map(m=>({...m,layoutCommand:{placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}}})),f=d(h,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:f}]},f,t)}const p=d(r,0);return{default:u({type:"row",style:{height:"100%"},children:[{...a,children:p},l,c,{type:"sidebarRight"}]},p,0),responsive:s}},eu="layoutSidebarButtons",oy=F.free,tu=G(function(n,e={}){const{Commands:t}=n,o=t.events,s={...e};(()=>{if(n.runCommand(_.layoutConfigGet)||s.skipLayoutConfig===!0)return;const l=Qd(s);n.runCommand(_.layoutConfigSet,{...l})})(),t.add(`${eu}:toggleButton`,(i,l,a)=>{const c=document.getElementById(Yd(a==null?void 0:a.id));c==null||c.click()}),n.on(`${o.runCommand}core:preview`,()=>{Xd(n)}),W({editor:n,licenseKey:s.licenseKey,plan:oy,pluginName:eu,cleanup:()=>{n.runCommand(_.layoutConfigSet)}})});tu.createLayoutConfig=n=>Qd(n);const Ft="page-break";var Oe=(n=>(n.A5="a5",n.A5Portrait="a5-portrait",n.A4="a4",n.A3="a3",n.B5="b5",n.B4="b4",n.letter="letter",n.legal="legal",n.ledger="ledger",n))(Oe||{});function li(n,e){const o={mm:3.7795275590551185,cm:37.79527559055118,in:96,pt:1.3333333333333333,pc:16};return o[e]?n*o[e]:null}const sy=(n,e)=>{const{name:t,id:o,width:s,height:r,unit:i}=n,{fixedHeight:l}=e,a=`${s}${i}`,c=`${r}${i}`;return{id:o||t.toLowerCase().replace(/\s/g,"-"),name:`${t} (${a} x ${c})`,sizeH:r,sizeW:s,sizeUnit:i,widthMedia:"",width:a,minHeight:l?"0":`${li(r,i)}px`,height:l?c:void 0}},ai="page-breaks",ds="gjs-page-breaks-spot",ci=n=>n.type===ai;function ry(n){const{Devices:e}=n,{height:t,minHeight:o}=e.getSelected().attributes,r=parseFloat(`${t&&t!=="auto"?t:o}`),i=n.getWrapper(),l=i==null?void 0:i.getEl(),a=[];if(!i||!l)return a;const c=l.getBoundingClientRect().height,u=i.findType(Ft).map(h=>h.getEl()).filter(Boolean).map(h=>({top:h.offsetTop,height:h.offsetHeight}));let p=0;for(;p<c;){const h=u.find(f=>f.top>p&&f.top<p+r);h?(p=h.top+h.height,a.push(h.top)):(p+=r,p<c&&a.push(p))}return a}function iy(n,e){const{Canvas:t}=n,o=t.events,s=n.events;let r;const i=()=>{ys(`${Ei}preset-printable-spots`,`.${ds} {
841
+ `,e.head.appendChild(s)};function Gd(n){const{editor:e,type:t}=n,o=K0(e,n.component),s=ri(e,o.component);if(!J0(e,o,s,t))return{target:o,container:s,startScroll:ii(e).scroll,shadowContainerEl:document.createElement("div"),shadowSnappedEl:document.createElement("div"),shadowTargetEl:document.createElement("div"),spot:e.Canvas.addSpot({type:no,component:s.component})}}function Wd(n){const{editor:e,shadowTargetEl:t,shadowSnappedEl:o,shadowContainerEl:s,spotEl:r,target:i,container:l}=n,{Canvas:a}=e,c=e.config.stylePrefix;r==null||r.appendChild(s),s==null||s.appendChild(t),s==null||s.appendChild(o),W0(s,l),j0(t,i,l),q0(o,i),U0(s,l.el),i.el.style.opacity="0";const d=a.getSpots().filter(u=>u.type!==no);e.em.stopDefault({preserveSelected:!0}),a.removeSpots(d),a.startAutoscroll(),a.getBody().classList.add(`${c}is__grabbing`)}function jd(n){const{editor:e,shadowSnappedEl:t,shadowContainerEl:o,target:s,cancelled:r}=n,{Canvas:i}=e,l=e.config.stylePrefix,{component:a}=s;if(!r){const c=window.getComputedStyle(t);a.addStyle({"grid-area":c.gridArea,width:"",height:""})}s.el.style.opacity="",o.contains(t)&&(o==null||o.removeChild(t)),e.getModel().runDefault({preserveSelected:1}),i.stopAutoscroll(),i.getBody().classList.remove(`${l}is__grabbing`),i.removeSpots({type:no}),e.select(a)}function W0(n,{rows:e,columns:t}){const o=[];for(let s=0;s<t.length;s++){o[s]=[];for(let r=0;r<e.length;r++){const i=document.createElement("div");i.className=Hd,i.style.gridArea=`${r+1} / ${s+1}`,o[s][r]=i,n.appendChild(i)}}return o}function j0(n,e,t){return n.className=Fd,n.style.top=`${e.offset.top-t.offset.top}px`,n.style.left=`${e.offset.left-t.offset.left}px`,n.style.width=`${e.offset.width+e.margin.left+e.margin.right}px`,n.style.height=`${e.offset.height+e.margin.top+e.margin.bottom}px`,n}function q0(n,e){const t=Kd(e.el,e.computedStyles);return n.className=_d,n.style.gridArea=`${t.row.start} / ${t.column.start} / ${t.row.end} / ${t.column.end}`,n}function U0(n,e){const t=window.getComputedStyle(e);n.className=_0,n.style.position="relative",n.style.display=t.display,n.style.gap=t.gap,n.style.padding=t.padding,n.style.border=t.border,n.style.gridTemplateColumns=t.gridTemplateColumns,n.style.gridTemplateRows=t.gridTemplateRows}function qd(n,e){if(e){if(Array.isArray(e))return[...e].pop()}else return[...n.getSelectedAll()].pop();return e}function K0(n,e){const t=qd(n,e),o=t.getEl(),s=window.getComputedStyle(o);return{component:t,el:o,offset:n.Canvas.offset(o),margin:{top:parseFloat(s.marginTop),right:parseFloat(s.marginRight),bottom:parseFloat(s.marginBottom),left:parseFloat(s.marginLeft)},computedStyles:s}}function ri(n,e){const t=e.parent(),o=t.getEl(),s=window.getComputedStyle(o);return{component:t,el:o,offset:n.Canvas.offset(o),computedStyles:s,padding:{top:parseFloat(s.paddingTop),right:parseFloat(s.paddingRight),bottom:parseFloat(s.paddingBottom),left:parseFloat(s.paddingLeft)},columns:s.gridTemplateColumns.split(" ").map(i=>parseFloat(i)),rows:s.gridTemplateRows.split(" ").map(i=>parseFloat(i)),gap:{column:parseInt(s.columnGap),row:parseInt(s.rowGap)}}}function yt(n,e,t,o,s=1){let r=0;for(let i=e;i<=n.length;i++){if(r+(n[i-1]+o)*s>t)return i;r+=o+n[i-1]}return n.length+1}function ii(n){const{scrollY:e,scrollX:t}=n.Canvas.getWindow();return{scroll:{top:e,left:t}}}function J0(n,e,t,o){const s=r=>n.em.logWarning(r);return o==="draggable"&&e.component.get(o)===!1?(s(`[${oi}] The element is not ${o}`),!0):t.computedStyles.display!=="grid"?(s(`[${oi}] The container does not have style display:grid`),!0):!1}function li(n,e,t={}){const o=qd(n,e),s=o==null?void 0:o.parent(),r=s==null?void 0:s.getEl();if(!s||!r)return!1;const{enableGrid:i}=t,l=window.getComputedStyle(r).display==="grid";return bt(i)?i({component:o,parent:s,isParentGrid:l}):l}const Ud=n=>n.split(" ").map(e=>parseFloat(e));function Kd(n,e){const t=n.ownerDocument.defaultView,o=e||t.getComputedStyle(n),s=o.gridArea.split("/").some(x=>isNaN(parseInt(x.trim()))),r={isComputed:s,raw:o.gridArea};if(!s)return{...r,row:{start:parseInt(o.gridRowStart),end:parseInt(o.gridRowEnd)},column:{start:parseInt(o.gridColumnStart),end:parseInt(o.gridColumnEnd)}};const i=n.parentElement,l=t.getComputedStyle(i),a=parseFloat(l.columnGap)||0,c=parseFloat(l.rowGap)||0,d=Ud(l.gridTemplateColumns),u=Ud(l.gridTemplateRows),p=parseFloat(l.paddingLeft)||0,h=parseFloat(l.paddingTop)||0,f=i.getBoundingClientRect(),m=n.getBoundingClientRect(),g=(x,w,v,E,k)=>{let M=1,P=E+k;for(let N=0;N<w.length;N++){const O=w[N],$=P+O;if(x>=P&&x<$)return M;P=$+v,M++}return-1},b=g(m.left,d,a,f.left,p),C=g(m.right-1,d,a,f.left,p)+1,y=g(m.top,u,c,f.top,h),S=g(m.bottom-1,u,c,f.top,h)+1;return{...r,row:{start:y,end:S},column:{start:b,end:C}}}function Z0(n){n.Commands.add(si,{stop(){},run(e,t,o={}){const s=Gd({editor:e,component:o.target,type:"draggable"});if(!s){this.stopCommand();return}const{spot:r,target:i,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c,startScroll:d}=s;let{container:u}=s,p;new e.Utils.Dragger({doc:i.el.ownerDocument,onStart:()=>{p=setTimeout(()=>{Wd({editor:e,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:r.attributes.spotEl,target:i,container:u}),u=ri(e,i.component)},10)},onEnd:(f,m,{cancelled:g})=>{clearTimeout(p),jd({editor:e,shadowSnappedEl:a,shadowContainerEl:l,target:i,cancelled:g}),this.stopCommand(),e.em.set("_cmpDrag",1)},setPosition:({x:f,y:m})=>{const{scroll:g}=ii(e),{columns:b,rows:C,gap:y,offset:S,padding:x}=u,{offset:w,margin:v}=i,E=w.top-S.top-x.top-v.top+m-d.top+g.top,k=w.left-S.left-x.left-v.left+f-d.left+g.left,M=Math.min(yt(b,1,k,y.column,.5),b.length),P=Math.min(yt(C,1,E,y.row,.5),C.length),N=Math.min(yt(b,M,w.width,y.column)+1,b.length+1),O=Math.min(yt(C,P,w.height,y.row)+1,C.length+1);a.style.gridArea=`${P} / ${M} / ${O} / ${N}`,c.style.top=`${E+x.top}px`,c.style.left=`${k+x.left}px`}}).start(o.event)}})}function Y0(n,e){const t=Gd({editor:n,component:e.target,type:"resizable"});if(!t)return;const{onMove:o,onEnd:s}=e.options||{},{spot:r,target:i,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c}=t;let{container:d}=t,u="",p;return{onStart:h=>{u=h.target.dataset.gjsHandler||"",p=setTimeout(()=>{Wd({editor:n,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:r.attributes.spotEl,target:i,container:d}),d=ri(n,i.component)},10),n.trigger("component:resize",{...i,type:"start"})},onEnd:(h,f)=>{const{startDim:m,rectDim:g}=f.resizer,b=JSON.stringify(m)===JSON.stringify(g);clearTimeout(p),jd({editor:n,shadowSnappedEl:a,shadowContainerEl:l,target:i,cancelled:b}),s==null||s(h,f)},onMove:h=>{var Q;const f=h;if(((Q=f.target)==null?void 0:Q.nodeName)==="I")return;const{scroll:m}=ii(n),g=Kd(a);let b=0,C=0,y=0,S=0;const x=i.margin.left,w=i.margin.top,v=i.margin.bottom,E=i.margin.right,{width:k,top:M,left:P,height:N}=i.offset,O=f.clientX,$=f.clientY,B={t:M-w,l:P-x,h:N+w+v,w:k+x+E};u.startsWith("t")?(B.t=$-w,B.h=M+N+w+v-$):u.startsWith("b")&&(B.h=$-M+w+v),u.endsWith("l")?(B.l=O-x,B.w=P+k+x+E-O):u.endsWith("r")&&(B.w=O-P+x+E),u.endsWith("l")&&(y=m.left,g.column.start=yt(d.columns,1,B.l-d.offset.left-y-d.padding.left,d.gap.column,.5)),u.startsWith("t")&&(b=m.top,g.row.start=yt(d.rows,1,B.t-d.offset.top+b-d.padding.top,d.gap.row,.5)),u.endsWith("r")&&(S=m.left,g.column.end=Math.max(yt(d.columns,g.column.start,B.w-S,d.gap.column,.5),g.column.start+1)),u.startsWith("b")&&(C=m.top,g.row.end=Math.max(yt(d.rows,g.row.start,B.h+C,d.gap.row,.5),g.row.start+1)),a.style.gridArea=`${g.row.start} / ${g.column.start} / ${g.row.end} / ${g.column.end}`,c.style.width=`${B.w+S+y}px`,c.style.height=`${B.h+C-b}px`,c.style.left=`${B.l-d.offset.left-y}px`,c.style.top=`${B.t-d.offset.top+b}px`,o==null||o(h)}}}const Jd=["px","%","em","rem","vw","vh"],X0=(n,e)=>{const t=n.Styles.getSectors().find(o=>!!o.getProperty(e));return{sector:t,property:t?t.getProperty(e):void 0}},Q0=(n,e)=>X0(n,e),ey=(n,{x:e,y:t,mergable:o}={})=>{const s={property:`${n}-x`,type:"integer",units:Jd,...e},r={property:`${n}-y`,type:"integer",units:Jd,...t};return{property:n,type:"composite",properties:[s,r],...o&&{fromStyle(i,{name:l,separator:a,property:c}){const[d,u]=c.getProperties(),[p,h]=(i[l]||"").split(a);return{[d.getId()]:i[d.getName()]||p||"",[u.getId()]:i[u.getName()]||h||p||""}},toStyle(i,{name:l,property:a}){const[c,d]=a.getProperties(),u=i[c.getId()],p=i[d.getId()];return{[l]:u===p?u:`${u} ${p}`}}}}},ai={display:["grid"]};function ty(n=""){const e=/^repeat\(\s*(\d+)\s*,\s*(.+)\s*\)$/i,t=/^minmax\(\s*(.+?)\s*,\s*(.+?)\s*\)$/i,o=n.match(e);if(!o)return null;const s=parseInt(o[1],10),r=o[2];let i=r,l=r;const a=r.match(t);return a&&(i=a[1],l=a[2]),{total:s,min:i===l?"":i,max:l}}function ny(n={}){let e="",t="",o="",s="";const r=m=>m.split("/").map(g=>g.trim()).filter(Boolean),i=n["grid-area"]||"",l=n["grid-column"]||"",a=n["grid-row"]||"",c=r(i),d=r(l),u=r(a),p=c.length,h=d.length,f=u.length;return p===4?(o=c[0],e=c[1],s=c[2],t=c[3]):p===3?(o=c[0],e=c[1],s=c[2]):p===2?(o=c[0],e=c[1]):p===1&&(o=c[0]),h===2?(e=d[0],t=d[1]):h===1&&(e=d[0]),f===2?(o=u[0],s=u[1]):f===1&&(o=u[0]),{columnStart:e,columnEnd:t,rowStart:o,rowEnd:s}}function Zd(n){const{property:e,label:t}=n,o="1",s="1fr";return{property:e,label:t,type:"composite",requires:ai,generic:!0,properties:[{name:" ",property:`${e}-repeat`,type:"number",full:!0,min:1,default:"1"},{label:"Min size",property:`${e}-min`,type:"number",min:0,units:["px","%"],default:"0"},{label:"Max size",property:`${e}-max`,type:"number",min:1,units:["fr","px","%"],default:"1"}],fromStyle(r,i){const{name:l,property:a}=i,[c,d,u]=a.getProperties(),p=r[l],h=ty(p),f=(h==null?void 0:h.max)??s;return{[c.id]:(h==null?void 0:h.total)??o,[d.id]:(h==null?void 0:h.min)??"",[u.id]:f===s?"":f}},toStyle(r,{name:i,property:l}){const[a,c,d]=l.getProperties(),u=r[a.id],p=r[c.id],h=r[d.id]||s,f=p&&h?`minmax(${p}, ${h})`:h;return{[i]:`repeat(${u||o}, ${f})`}}}}function oy(n,e){if(!e.styleableGrid)return;const{property:t,...o}=Q0(n,"display");if(!t)return;const s=t.getOption("grid"),r=o.sector;s||t.addOption({id:"grid",label:"Grid"}),r.addProperty(Zd({label:"Columns",property:"grid-template-columns"}),{}),r.addProperty(Zd({label:"Rows",property:"grid-template-rows"}),{}),r.addProperty({id:"grid-gap",requires:ai,...ey("gap",{x:{id:"grid-row-gap",label:"Row",property:"row-gap",min:0,default:"0"},y:{id:"grid-column-gap",label:"Column",property:"column-gap",min:0,default:"0"},mergable:!0})},{}),r.addProperty({type:"composite",property:"grid-area",label:"Grid area",requiresParent:ai,generic:!0,properties:[{label:"Row start",property:"grid-row-start",type:"integer",default:"auto"},{label:"Row end",property:"grid-row-end",type:"integer",default:"auto"},{label:"Column start",property:"grid-column-start",type:"integer",default:"auto"},{label:"Column end",property:"grid-column-end",type:"integer",default:"auto"}],fromStyle(i){const l=ny(i);return{"grid-column-start":i["grid-column-start"]||l.columnStart,"grid-column-end":i["grid-column-end"]||l.columnEnd,"grid-row-start":i["grid-row-start"]||l.rowStart,"grid-row-end":i["grid-row-end"]||l.rowEnd}},toStyle(i,{name:l}){const a=i["grid-row-start"]||"auto",c=i["grid-row-end"]||"auto",d=i["grid-column-start"]||"auto",u=i["grid-column-end"]||"auto";return{[l]:`${a} / ${d} / ${c} / ${u}`}}},{})}const sy=j(function(n,e={}){const t={itemResizable:!0,...e},{Canvas:o,Commands:s,Components:r}=n,{itemResizable:i}=t,l=o.events,a=s.events,c=r.events,d=`${a.runBeforeCommand}tlb-move`,u=`${a.runBeforeCommand}resize`;let p;Z0(n);const h=({options:y})=>{li(n,y.target,t)&&(n.runCommand(si,{...y}),y.abort=!0)},f=({options:y})=>{li(n,y.target,t)&&Object.assign(y.options,Y0(n,y))},m=()=>{const y=o.getSpots({type:no}).pop();if(!y)return;let S=y.attributes.spotEl;S||(S=document.createElement("div"),S.className=oo,y.set({spotEl:S})),Object.entries(y.getStyle()).forEach(([x,w])=>S.style.setProperty(x,w)),p==null||p.appendChild(S)},g=({spot:y})=>{const S=y.attributes.spotEl;y.type!==no||!S||p==null||p.removeChild(S)};if(i){const y=S=>{const x=bt(i)?i({component:S}):i;return typeof x=="boolean"?x:{tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1,...x}};n.on(c.resizeInit,S=>{const{component:x}=S;if(li(n,x,t)){const w=y(x);S.resizable=w}})}const b=[[d,h],[u,f],[l.spot,m],[l.spotRemove,g]];b.forEach(([y,S])=>{n.on(y,S)}),n.onReady(()=>{p=o.getSpotsEl(),G0(),oy(n,t)});const C=()=>{delete n.Commands.commands[si],b.forEach(([y,S])=>{n.off(y,S)})};q({editor:n,licenseKey:t.licenseKey,plan:F0,pluginName:oi,cleanup:C})});var He=(n=>(n.panelBlocks="panelBlocks",n.panelPagesLayers="panelPagesLayers",n.panelGlobalStyles="panelGlobalStyles",n.panelSidebarTabs="panelSidebarTabs",n.panelAssets="panelAssets",n))(He||{});const Yd="sidebarButtonsTarget",ds=n=>{const{id:e,icon:t,label:o,tooltip:s,className:r,skipSelfClose:i,removeLayouts:l,layoutComponent:a,layoutCommand:c}=n,d=e;return{id:Xd(e),type:"button",icon:t,tooltip:o||s,className:r,editorEvents:{[`${wi.layoutToggleId}${d}`]:({fromEvent:u,setState:p,editor:h})=>{p({active:u.isOpen}),setTimeout(()=>h.refresh({tools:!0}),20)}},onClick:({editor:u,state:p})=>{if(p.active&&i)return;const h=(c==null?void 0:c.placer)||{type:"static",layoutId:Yd},f={...h,skipCleanup:h.type==="static"},m=l||Object.keys(He).filter(b=>b!==d);Qd(u,{removeLayouts:m,layout:{placer:f}});const g={id:d,placer:h,header:(c==null?void 0:c.header)??{label:o,close:!i},layout:a,style:{width:280,height:"100%",borderRightWidth:1,...c==null?void 0:c.style}};u.runCommand(G.layoutToggle,g)}}},Xd=n=>`button__${n}`,Qd=(n,e={})=>{(e.removeLayouts||Object.keys(He)).forEach(o=>n.runCommand(G.layoutRemove,{id:o,layout:e.layout}))},eu=n=>{const e=(n==null?void 0:n.breakpointTablet)??1024,t=(n==null?void 0:n.breakpointMobile)??768,o={breakpointTablet:e,breakpointMobile:t},s={},r=[{id:He.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:He.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:He.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:He.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:h,editor:f})=>{var b;const m=f.getSelected(),g={type:"image",src:h.src};if(m!=null&&m.is("image"))return m.set("src",h.src);if(m&&f.Components.canMove(m,g)){const C=m.append(g)[0];C&&f.select(C)}else if(!m){const C=(b=f.getWrapper())==null?void 0:b.append(g)[0];C&&f.select(C)}}}}],i=[...r,{id:He.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:Yd,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=(h,f)=>{const m=h.map(b=>{const C=ds(b);return n!=null&&n.sidebarButton?n.sidebarButton({id:b.id,buttonIds:He,breakpoint:f,buttonProps:C,sidebarButtonProps:b,...o,createSidebarButton:y=>ds({...b,...y})}):C}).filter(Boolean);return(n!=null&&n.sidebarButtons?n==null?void 0:n.sidebarButtons({buttonIds:He,breakpoint:f,sidebarButtons:m,...o,createSidebarButton:b=>ds({...b})}):m).filter(Boolean)},u=(h,f,m)=>{var g;return((g=n==null?void 0:n.rootLayout)==null?void 0:g.call(n,{breakpoint:m,sidebarButtons:f,rootLayout:h,layoutSidebarLeft:a,layoutSidebarTarget:l,...o,createSidebarButton:b=>ds({...b})}))??h};if(e){const h=d(i,e);s[e]=u({type:"row",style:{height:"100%"},children:[{...a,children:h},l,c]},h,e)}if(t){const h=i.map(m=>({...m,layoutCommand:{placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}}})),f=d(h,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:f}]},f,t)}const p=d(r,0);return{default:u({type:"row",style:{height:"100%"},children:[{...a,children:p},l,c,{type:"sidebarRight"}]},p,0),responsive:s}},tu="layoutSidebarButtons",ry=_.free,nu=j(function(n,e={}){const{Commands:t}=n,o=t.events,s={...e};(()=>{if(n.runCommand(G.layoutConfigGet)||s.skipLayoutConfig===!0)return;const l=eu(s);n.runCommand(G.layoutConfigSet,{...l})})(),t.add(`${tu}:toggleButton`,(i,l,a)=>{const c=document.getElementById(Xd(a==null?void 0:a.id));c==null||c.click()}),n.on(`${o.runCommand}core:preview`,()=>{Qd(n)}),q({editor:n,licenseKey:s.licenseKey,plan:ry,pluginName:tu,cleanup:()=>{n.runCommand(G.layoutConfigSet)}})});nu.createLayoutConfig=n=>eu(n);const _t="page-break";var Ne=(n=>(n.A5="a5",n.A5Portrait="a5-portrait",n.A4="a4",n.A3="a3",n.B5="b5",n.B4="b4",n.letter="letter",n.legal="legal",n.ledger="ledger",n))(Ne||{});function ci(n,e){const o={mm:3.7795275590551185,cm:37.79527559055118,in:96,pt:1.3333333333333333,pc:16};return o[e]?n*o[e]:null}const iy=(n,e)=>{const{name:t,id:o,width:s,height:r,unit:i}=n,{fixedHeight:l}=e,a=`${s}${i}`,c=`${r}${i}`;return{id:o||t.toLowerCase().replace(/\s/g,"-"),name:`${t} (${a} x ${c})`,sizeH:r,sizeW:s,sizeUnit:i,widthMedia:"",width:a,minHeight:l?"0":`${ci(r,i)}px`,height:l?c:void 0}},di="page-breaks",us="gjs-page-breaks-spot",ui=n=>n.type===di;function ly(n){const{Devices:e}=n,{height:t,minHeight:o}=e.getSelected().attributes,r=parseFloat(`${t&&t!=="auto"?t:o}`),i=n.getWrapper(),l=i==null?void 0:i.getEl(),a=[];if(!i||!l)return a;const c=l.getBoundingClientRect().height,u=i.findType(_t).map(h=>h.getEl()).filter(Boolean).map(h=>({top:h.offsetTop,height:h.offsetHeight}));let p=0;for(;p<c;){const h=u.find(f=>f.top>p&&f.top<p+r);h?(p=h.top+h.height,a.push(h.top)):(p+=r,p<c&&a.push(p))}return a}function ay(n,e){const{Canvas:t}=n,o=t.events,s=n.events;let r;const i=()=>{Ss(`${Mi}preset-printable-spots`,`.${us} {
842
842
  position: absolute;
843
843
  left: 0;
844
844
  width: 100%;
845
845
  border-top: 1px dashed var(--gs-theme-cl-cmp-bg2, var(--gjs-color-blue));
846
846
  color: var(--gs-theme-cl-prm-txt, var(--gjs-font-color));
847
847
  }
848
- .${ds}::after {
848
+ .${us}::after {
849
849
  background-color: var(--gs-theme-cl-cmp-bg1, var(--gjs-color-highlight));
850
850
  content: attr(data-page-number);
851
851
  display: block;
@@ -856,7 +856,7 @@
856
856
  right: 0;
857
857
  transform: translate(100%, -50%);
858
858
  }
859
- `,{target:window.document.head})},l=()=>{if(e.enablePageBreaksSpot===!1)return;const g={id:ai,type:ai,component:n.getWrapper()};return t.getSpots(g).pop()||t.addSpot(g)},a=({spot:g})=>{const{spotEl:b}=g.attributes;!ci(g)||!b||!r||r.removeChild(b)},c=({spot:g})=>{if(!ci(g)||!r)return;let{spotEl:b}=g.attributes;b||(b=document.createElement("div"),b.className=`${ds}__items`,g.set({spotEl:b})),r.appendChild(b)},d=({spot:g})=>{const{spotEl:b,pageBreaks:C=[]}=g.attributes;!ci(g)||!b||!r||(Object.entries(g.getStyle()).forEach(([y,S])=>b.style.setProperty(y,S)),b.innerHTML="",C.forEach((y,S)=>{const v=document.createElement("div");v.setAttribute("data-page-number",`${S+2}`),v.className=ds,v.style.top=`${y}px`,b.appendChild(v)}))},u=xn(()=>{if(n.em.destroyed)return;const g=l();g&&g.set({pageBreaks:ry(n),up:(g.attributes.up||0)+1})},150),p=xn(u,200),h=()=>{r=t.getSpotsEl(),l()},f=()=>{const g=l();g&&g.set({up:(g.attributes.up||0)+1})},m=[["component:input",u],["frame:scroll",f],[s.update,u],[o.spotAdd,c],[o.spotUpdate,d],[o.spotRemove,a],[o.frameLoadBody,h]];return m.forEach(([g,b])=>n.on(g,b)),n.onReady(()=>{i(),new ResizeObserver(f).observe(t.getElement().parentElement)}),()=>{m.forEach(([g,b])=>n.off(g,b)),u.clear(),p.clear()}}var di=(n=>(n.print="presetPrintable:print",n))(di||{});const nu=n=>new Promise(e=>{const t=document.createElement("iframe");t.style.cssText="position: absolute; width: 0; height: 0; border: 0; opacity: 0; pointer-events: none;",t.srcdoc=n.content,t.onload=()=>e(t),document.body.appendChild(t)});function ly(n,e){const{Commands:t,Pages:o}=n;return t.add(di.print,async(s,r,i={})=>{const l={page:i.allPages?void 0:o.getSelected(),styles:"inline",optionsHtml:{exporter:null}},c=(await t.run(_.projectFiles,l)).filter(p=>p.filename.endsWith(".html")),d=c.map(p=>p.content).join('<div style="break-before: page;"></div>'),u=[];if(i.separatePrints)for(const p of c)u.push(await nu(p));else u.push(await nu({content:d,filename:"",mimeType:""}));for(const p of u){const h=p.contentWindow;h.focus(),h.print()}setTimeout(()=>u.forEach(p=>p.remove()),1e3)}),t.add("presetPrintable:exp",async s=>{await Si("https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"),await Si("https://cdn.jsdelivr.net/npm/jspdf@3.0.0/dist/jspdf.umd.min.js");const{Devices:r,Canvas:i}=s,{sizeW:l,sizeH:a,sizeUnit:c}=r.getSelected().attributes,d=i.getFrameEl().contentDocument,u="px",p=[li(l,c),li(a,c)],h=new window.jspdf.jsPDF({unit:u,format:p}),f=d.body;h.html(f,{callback:m=>m.save()})}),()=>{delete n.Commands.commands[di.print]}}function ay(n,e){const{blockPageBreak:t={}}=e,{Components:o,Blocks:s}=n,r="Page Break",i=`${Ne}${Ft}`;return o.addType(Ft,{block:t&&{label:r,media:'<svg viewBox="0 0 24 24"><path d="M18 20H6v-2H4v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2h-2v2M14 2H6a2 2 0 0 0-2 2v8h2V4h8v4h4v4h2V8l-6-6m-3 14H8v-2h3v2m5 0h-3v-2h3v2M3 14h3v2H3v-2m18 2h-3v-2h3v2Z"/></svg>',category:"Extra",select:!0,...t},isComponent:Xe(Ft),model:{defaults:{name:r,classes:i,attributes:{[_e]:Ft},emptyState:!0,stylable:!1,droppable:!1,draggable:gs("wrapper"),styles:`.${i} { break-before: page; }`,traits:[]}}}),()=>{o.removeType(Ft),s.remove(Ft)}}const cy="presetPrintable",dy=F.free,uy=G(function(n,e={}){var w;const t={selectedDevice:Oe.A4,...e},{Canvas:o,Devices:s,Blocks:r}=n,i=o.events,l=n.events,a=t.selectedDevice||s.getConfig().default,c=[{id:Oe.A5,name:"A5",width:148,height:210,unit:"mm"},{id:Oe.A5Portrait,name:"A5 Portrait",width:210,height:148,unit:"mm"},{id:Oe.A4,name:"A4",width:210,height:297,unit:"mm"},{id:Oe.A3,name:"A3",width:297,height:420,unit:"mm"},{id:Oe.B5,name:"B5",width:176,height:250,unit:"mm"},{id:Oe.B4,name:"B4",width:250,height:353,unit:"mm"},{id:Oe.letter,name:"Letter",width:8.5,height:11,unit:"in"},{id:Oe.legal,name:"Legal",width:8.5,height:14,unit:"in"},{id:Oe.ledger,name:"Ledger",width:11,height:17,unit:"in"}],u=(((w=t.devices)==null?void 0:w.call(t,{items:c}))||c).map(x=>sy(x,t));s.devices.reset(u);const p=a&&s.get(a)||s.getAll().at(0);s.select(p),["map","video"].forEach(x=>r.remove(x));const f=()=>{const x="page-rule",{rules:T}=n.Css,{width:k,height:M,minHeight:P}=s.getSelected().attributes,O=M&&M!=="auto"?M:P;(T.where({id:x}).pop()||T.add({id:x,selectors:[],selectorsAdd:"@page"},{at:0})).setStyle({size:`${k} ${O}`,margin:"0"})},m=x=>{const T=x.document,{minHeight:k}=s.getSelected().attributes,P=`
859
+ `,{target:window.document.head})},l=()=>{if(e.enablePageBreaksSpot===!1)return;const g={id:di,type:di,component:n.getWrapper()};return t.getSpots(g).pop()||t.addSpot(g)},a=({spot:g})=>{const{spotEl:b}=g.attributes;!ui(g)||!b||!r||r.removeChild(b)},c=({spot:g})=>{if(!ui(g)||!r)return;let{spotEl:b}=g.attributes;b||(b=document.createElement("div"),b.className=`${us}__items`,g.set({spotEl:b})),r.appendChild(b)},d=({spot:g})=>{const{spotEl:b,pageBreaks:C=[]}=g.attributes;!ui(g)||!b||!r||(Object.entries(g.getStyle()).forEach(([y,S])=>b.style.setProperty(y,S)),b.innerHTML="",C.forEach((y,S)=>{const x=document.createElement("div");x.setAttribute("data-page-number",`${S+2}`),x.className=us,x.style.top=`${y}px`,b.appendChild(x)}))},u=Cn(()=>{if(n.em.destroyed)return;const g=l();g&&g.set({pageBreaks:ly(n),up:(g.attributes.up||0)+1})},150),p=Cn(u,200),h=()=>{r=t.getSpotsEl(),l()},f=()=>{const g=l();g&&g.set({up:(g.attributes.up||0)+1})},m=[["component:input",u],["frame:scroll",f],[s.update,u],[o.spotAdd,c],[o.spotUpdate,d],[o.spotRemove,a],[o.frameLoadBody,h]];return m.forEach(([g,b])=>n.on(g,b)),n.onReady(()=>{i(),new ResizeObserver(f).observe(t.getElement().parentElement)}),()=>{m.forEach(([g,b])=>n.off(g,b)),u.clear(),p.clear()}}var pi=(n=>(n.print="presetPrintable:print",n))(pi||{});const ou=n=>new Promise(e=>{const t=document.createElement("iframe");t.style.cssText="position: absolute; width: 0; height: 0; border: 0; opacity: 0; pointer-events: none;",t.srcdoc=n.content,t.onload=()=>e(t),document.body.appendChild(t)});function cy(n,e){const{Commands:t,Pages:o}=n;return t.add(pi.print,async(s,r,i={})=>{const l={page:i.allPages?void 0:o.getSelected(),styles:"inline",optionsHtml:{exporter:null}},c=(await t.run(G.projectFiles,l)).filter(p=>p.filename.endsWith(".html")),d=c.map(p=>p.content).join('<div style="break-before: page;"></div>'),u=[];if(i.separatePrints)for(const p of c)u.push(await ou(p));else u.push(await ou({content:d,filename:"",mimeType:""}));for(const p of u){const h=p.contentWindow;h.focus(),h.print()}setTimeout(()=>u.forEach(p=>p.remove()),1e3)}),t.add("presetPrintable:exp",async s=>{await vi("https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"),await vi("https://cdn.jsdelivr.net/npm/jspdf@3.0.0/dist/jspdf.umd.min.js");const{Devices:r,Canvas:i}=s,{sizeW:l,sizeH:a,sizeUnit:c}=r.getSelected().attributes,d=i.getFrameEl().contentDocument,u="px",p=[ci(l,c),ci(a,c)],h=new window.jspdf.jsPDF({unit:u,format:p}),f=d.body;h.html(f,{callback:m=>m.save()})}),()=>{delete n.Commands.commands[pi.print]}}function dy(n,e){const{blockPageBreak:t={}}=e,{Components:o,Blocks:s}=n,r="Page Break",i=`${Oe}${_t}`;return o.addType(_t,{block:t&&{label:r,media:'<svg viewBox="0 0 24 24"><path d="M18 20H6v-2H4v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2h-2v2M14 2H6a2 2 0 0 0-2 2v8h2V4h8v4h4v4h2V8l-6-6m-3 14H8v-2h3v2m5 0h-3v-2h3v2M3 14h3v2H3v-2m18 2h-3v-2h3v2Z"/></svg>',category:"Extra",select:!0,...t},isComponent:Qe(_t),model:{defaults:{name:r,classes:i,attributes:{[Ge]:_t},emptyState:!0,stylable:!1,droppable:!1,draggable:bs("wrapper"),styles:`.${i} { break-before: page; }`,traits:[]}}}),()=>{o.removeType(_t),s.remove(_t)}}const uy="presetPrintable",py=_.free,hy=j(function(n,e={}){var w;const t={selectedDevice:Ne.A4,...e},{Canvas:o,Devices:s,Blocks:r}=n,i=o.events,l=n.events,a=t.selectedDevice||s.getConfig().default,c=[{id:Ne.A5,name:"A5",width:148,height:210,unit:"mm"},{id:Ne.A5Portrait,name:"A5 Portrait",width:210,height:148,unit:"mm"},{id:Ne.A4,name:"A4",width:210,height:297,unit:"mm"},{id:Ne.A3,name:"A3",width:297,height:420,unit:"mm"},{id:Ne.B5,name:"B5",width:176,height:250,unit:"mm"},{id:Ne.B4,name:"B4",width:250,height:353,unit:"mm"},{id:Ne.letter,name:"Letter",width:8.5,height:11,unit:"in"},{id:Ne.legal,name:"Legal",width:8.5,height:14,unit:"in"},{id:Ne.ledger,name:"Ledger",width:11,height:17,unit:"in"}],u=(((w=t.devices)==null?void 0:w.call(t,{items:c}))||c).map(v=>iy(v,t));s.devices.reset(u);const p=a&&s.get(a)||s.getAll().at(0);s.select(p),["map","video"].forEach(v=>r.remove(v));const f=()=>{const v="page-rule",{rules:E}=n.Css,{width:k,height:M,minHeight:P}=s.getSelected().attributes,N=M&&M!=="auto"?M:P;(E.where({id:v}).pop()||E.add({id:v,selectors:[],selectorsAdd:"@page"},{at:0})).setStyle({size:`${k} ${N}`,margin:"0"})},m=v=>{const E=v.document,{minHeight:k}=s.getSelected().attributes,P=`
860
860
  ${!!parseFloat(`${k}`)?`
861
861
  [data-gjs-type="wrapper"] { min-height: ${k}; }
862
862
  `:`
@@ -869,20 +869,10 @@
869
869
  height: 100dvh;
870
870
  }
871
871
  `}
872
- `;ys(`${Ei}preset-printable`,P,{doc:T,target:T.head}),f()};n.on(i.frameLoadBody,x=>{const T=x.window;if(m(T),t.fixedHeight){const M=x.model.getComponent().getEl();M==null||M.addEventListener("scroll",P=>{const O=P.target;O.scrollTop>0&&O.scrollTo(0,0)})}}),n.on(s.events.select,()=>{var T;const x=(T=o.getFrameEl().contentDocument)==null?void 0:T.defaultView;x&&m(x)});const g=()=>{const T=n.Css.getRules().filter(k=>k.selectorsToString()==="body").pop();T==null||T.addStyle({"margin-top":"","margin-right":"","margin-bottom":"","margin-left":"",margin:"0"})},b=[[l.projectLoad,g]];b.forEach(([x,T])=>n.on(x,T));const C=iy(n,t),y=ly(n),S=ay(n,t);n.onReady(()=>{n.UndoManager.clear()});const v=()=>{b.forEach(([x,T])=>n.off(x,T)),C(),y(),S()};n.on(l.destroy,v),W({editor:n,licenseKey:t.licenseKey,plan:dy,pluginName:cy,cleanup:v})});var no=(n=>(n.variable="data-variable",n.condition="data-condition",n.conditionTrue="data-condition-true-content",n.conditionFalse="data-condition-false-content",n.collection="data-collection",n.collectionItem="data-collection-item",n))(no||{});class py{constructor(e){this.strategy=e,this.requiredHelpers=new Set,this.helperLibrary={}}registerHelper(e){this.helperLibrary[e]&&this.requiredHelpers.add(e)}generateVariable(e){return this.strategy.getVariableSyntax(e)}generateCollectionStart(e){return this.registerHelper("slice"),this.strategy.getCollectionStartSyntax(e)}generateCollectionEnd(){return this.strategy.getCollectionEndSyntax()}generateConditionalStart(e){return this.strategy.getConditionalStartSyntax(e)}generateConditionElse(){return this.strategy.getConditionElseSyntax()}generateConditionalEnd(){return this.strategy.getConditionalEndSyntax()}reset(){this.requiredHelpers.clear()}}function hy(n){return typeof n=="object"&&n.type===no.variable}function us({component:n,value:e,getCustomPath:t}){if(hy(e)&&!e.collectionId&&t){const o=e.path??"",s=o.split(".");return{...e,path:t({component:n,path:o,paths:s})}}return e}const fy=n=>{ui(n,no.variable,{toHTML(e){var i;const t=this.tagName,o=this.__attrToString(e),s=(i=this.getDataResolver)==null?void 0:i.call(this),r=us({component:this,value:s,getCustomPath:e==null?void 0:e.getCustomPath});return`<${t}${o?` ${o}`:""}>${e.exporter.generateVariable(r)}</${t}>`}}),ui(n,no.condition,{toHTML(e){var d,u;const t=e.exporter,o=e==null?void 0:e.getCustomPath,s=this.components(),[r,i]=(s==null?void 0:s.models)??[],l=(d=this.getDataResolver)==null?void 0:d.call(this),a=((u=this.resolveCondition)==null?void 0:u.call(this,l==null?void 0:l.condition,o))??{};let c="";return i&&(c=`
873
- ${t.generateConditionElse()}
874
- ${i.toHTML(e)??""}`),`
875
- ${t.generateConditionalStart(a)}
876
- ${(r==null?void 0:r.toHTML(e))??""}${c}
877
- ${t.generateConditionalEnd()}
878
- `},resolveCondition(e,t){var s,r;if(!e)return{};if(e.operator==="and"||e.operator==="or")return{operator:e.operator,statements:((r=(s=e.statements)==null?void 0:s.map)==null?void 0:r.call(s,i=>{var l;return((l=this.resolveCondition)==null?void 0:l.call(this,i,t))??{}}))??[]};const o={component:this,getCustomPath:t};return{...e,left:us({...o,value:e.left}),right:us({...o,value:e.right})}}}),ui(n,no.collection,{toHTML(e){const t=e.exporter,o=this.tagName,s=this.__attrToString(e),r=this.getDataResolver(),i={...r,dataSource:us({component:this,value:r==null?void 0:r.dataSource,getCustomPath:e==null?void 0:e.getCustomPath})},l=this.components().at(0);return`
879
- <${o}${s?` ${s}`:""}>${t.generateCollectionStart(i)}
880
- ${(l==null?void 0:l.toHTML(e))??""}
881
- ${t.generateCollectionEnd()}</${o}>
882
- `}})},ui=(n,e,t)=>{const o=n.Components.getType(e);if(!o){console.warn(`Component type ${e} not found`);return}const{model:s}=o;n.Components.addType(e,{model:{...t,toHTML(r={}){var l;const{exporter:i}=r;return i?i.export?i.export({component:this}):((l=t.toHTML)==null?void 0:l.call(this,r))??"":s.prototype.toHTML.call(this,r)??""}}})},my=n=>{const e=n;return e.logicalOperator==="and"||e.logicalOperator==="or"},ou=(n,e)=>(n.config.optsHtml={...n.config.optsHtml,exporter:new py(e)},fy(n),()=>{n.config.optsHtml.exporter=void 0}),su=(n,e)=>{const t=s=>{const{input:r}=s,{contains:i}=e;(!i||r.includes(i))&&(s.input=e.importer.import(r))},o=n.Parser.events.htmlBefore;return n.on(o,t),()=>{n.off(o,t)}};class gy{getVariableSyntax(e){const{defaultValue:t}=e,o=this.getFullPath(e),s=t?` || \`${t}\``:"";return`<%= ${o}${s} %>`}getCollectionStartSyntax(e){const{collectionId:t,dataSource:o,startIndex:s,endIndex:r}=e,i=(o==null?void 0:o.path)||t||"",l=this._sanitizeVariableName(t);let a="";if(s!==void 0||r!==void 0){const c=s??0,d=r!==void 0?r:"";a=`.slice(${c}${d!==""?`, ${d}`:""})`}return`<% ${i}${a}.forEach(function(currentItem, index, arr) {
872
+ `;Ss(`${Mi}preset-printable`,P,{doc:E,target:E.head}),f()};n.on(i.frameLoadBody,v=>{const E=v.window;if(m(E),t.fixedHeight){const M=v.model.getComponent().getEl();M==null||M.addEventListener("scroll",P=>{const N=P.target;N.scrollTop>0&&N.scrollTo(0,0)})}}),n.on(s.events.select,()=>{var E;const v=(E=o.getFrameEl().contentDocument)==null?void 0:E.defaultView;v&&m(v)});const g=()=>{const E=n.Css.getRules().filter(k=>k.selectorsToString()==="body").pop();E==null||E.addStyle({"margin-top":"","margin-right":"","margin-bottom":"","margin-left":"",margin:"0"})},b=[[l.projectLoad,g]];b.forEach(([v,E])=>n.on(v,E));const C=ay(n,t),y=cy(n),S=dy(n,t);n.onReady(()=>{n.UndoManager.clear()});const x=()=>{b.forEach(([v,E])=>n.off(v,E)),C(),y(),S()};n.on(l.destroy,x),q({editor:n,licenseKey:t.licenseKey,plan:py,pluginName:uy,cleanup:x})}),fy=n=>{const e=n;return e.logicalOperator==="and"||e.logicalOperator==="or"},su=(n,e)=>(n.config.optsHtml={...n.config.optsHtml,exporter:e},()=>{n.config.optsHtml.exporter=void 0}),ru=(n,e)=>{const t=s=>{const{input:r}=s,{contains:i}=e;(!i||r.includes(i))&&(s.input=e.importer.import(r))},o=n.Parser.events.htmlBefore;return n.on(o,t),()=>{n.off(o,t)}};class my{getVariableSyntax({dataResolver:e}){const{defaultValue:t}=e,o=this.getFullPath(e),s=t?` || \`${t}\``:"";return`<%= ${o}${s} %>`}getCollectionStartSyntax({dataResolver:e}){const{collectionId:t,dataSource:o,startIndex:s,endIndex:r}=e,i=(o==null?void 0:o.path)||t||"",l=this._sanitizeVariableName(t);let a="";if(s!==void 0||r!==void 0){const c=s??0,d=r!==void 0?r:"";a=`.slice(${c}${d!==""?`, ${d}`:""})`}return`<% ${i}${a}.forEach(function(currentItem, index, arr) {
883
873
  const startIndex = parseInt(${s??0}, 10);
884
874
  const endIndex = startIndex + arr.length;
885
- const ${l}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getCollectionEndSyntax(){return"<% }) %>"}getConditionalStartSyntax(e){return`<% if (${this._parseCondition(e)}) { %>`}getConditionElseSyntax(){return"<% } else { %>"}getConditionalEndSyntax(){return"<% } %>"}getFullPath({collectionId:e,path:t,variableType:o}){return(e?[this._sanitizeVariableName(e),o,t].filter(Boolean).join("."):t)||""}_parseCondition(e){if(!e)return"";if(my(e)){const t=e.statements.map(r=>this._parseCondition(r)),o=yy[e.logicalOperator];let s=t.length>1?`(${t.join(`)${o}(`)})`:t[0];return e.logicalOperator==="xor"&&(s=`!!(${s})`),s}else{const t=this._parseValue(e.left),o=this._parseValue(e.right);switch(e.operator){case"equals":return`${t} === ${o}`;case">":case"<":case">=":case"<=":case"=":case"!=":return`${t} ${e.operator} ${o}`;case"contains":return`${t}?.includes(${o})`;case"startsWith":return`${t}?.startsWith(${o})`;case"endsWith":return`${t}?.endsWith(${o})`;case"equalsIgnoreCase":return`${t}?.toLowerCase() === ${o}?.toLowerCase()`;case"trimEquals":return`${t}?.trim() === ${o}?.trim()`;case"isTruthy":return`!!${t}`;case"isFalsy":return`!${t}`;case"isDefined":return`${t} !== undefined`;case"isNull":return`${t} === null`;case"isUndefined":return`${t} === undefined`;case"isArray":return`Array.isArray(${t})`;case"isObject":return`typeof ${t} === 'object' && ${t} !== null && !Array.isArray(${t})`;case"isString":return`typeof ${t} === 'string'`;case"isNumber":return`typeof ${t} === 'number' && !isNaN(${t})`;case"isBoolean":return`typeof ${t} === 'boolean'`;default:return`${t} ${e.operator} ${o}`}}}_parseValue(e){return typeof e=="object"?this.getFullPath(e):typeof e=="string"?`'${e.replace(/'/g,"\\'")}'`:String(e)}}const yy={and:"&&",or:"||",xor:"^"},by=["===","==","!==","!=","<=",">=","<",">","&&","||"],Sy={"===":"=","==":"=","!==":"!=","!=":"!=","<=":"<=",">=":">=","<":"<",">":">","&&":"&&","||":"||"};class vy{constructor(){this.messages=[],this.collectionStack=[]}import(e){this.messages=[],this.collectionStack=[];try{const t=this.parseEjsTemplate(e);return this.astToGrapesJS(t)}catch(t){return console.error("Error during import:",t),this.addMessage("error",`Error during import: ${t instanceof Error?t.message:String(t)}`),""}}parseEjsTemplate(e){const t=[];let o=0;for(;o<e.length;){const s=e.indexOf("<%",o);if(s===-1){o<e.length&&t.push(this.createAppendLiteral(e.slice(o)));break}s>o&&t.push(this.createAppendLiteral(e.slice(o,s)));const r=e.indexOf("%>",s);if(r===-1)throw new Error("Unclosed EJS tag");const i=e.slice(s+2,r).trim();if(o=r+2,i.startsWith("=")||i.startsWith("-")){const l=i.slice(1).trim();t.push(this.createAppendExpression(l))}else{if(i.startsWith("#"))continue;if(i.startsWith("if")){const l=this.parseIfStatement(i,e,o);t.push(l),o=l.endPos||o}else if(i.startsWith("for")){const l=this.parseForStatement(i,e,o);t.push(l),o=l.endPos||o}else{const l=i.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);if(l){const a=l[1],c=l[2],d=this.parseForEachStatement(a,c,e,o);t.push(d),o=d.endPos||o}else this.addMessage("info",`Unsupported scriptlet content: ${i}`)}}}return{type:"Program",body:t}}createAppendLiteral(e){return{type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:"__append"},arguments:[{type:"Literal",value:e}]}}}createAppendExpression(e){return{type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:"__append"},arguments:[this.parseJsExpression(e)]}}}parseIfStatement(e,t,o){const s=e.match(/if\s*\((.*)\)\s*\{?/);if(!s)throw new Error("Invalid if statement syntax");const r=this.parseJsExpression(s[1]),{body:i,endPos:l}=this.parseTemplateBlock(t,o);let a=null,c=l;const d=t.indexOf("<%",c);if(d===c){const u=t.indexOf("%>",d);if(u!==-1){const p=t.slice(d+2,u).trim(),h=u+2-d;if(p.startsWith("} else if")){c=d+h;const f=p.substring(p.indexOf("if")).trim(),m=this.parseIfStatement(f,t,c);a={type:"IfStatement",test:m.test,consequent:m.consequent,alternate:m.alternate},c=m.endPos}else if(p.startsWith("} else")){c=d+h;const{body:f,endPos:m}=this.parseTemplateBlock(t,c);a={type:"BlockStatement",body:f},c=m;const g=t.indexOf("<%",c),b=t.indexOf("%>",g);g===c&&t.slice(g+2,b).trim()==="}"&&(c=b+2)}else p==="}"&&(c=d+h)}}return{type:"IfStatement",test:r,consequent:{type:"BlockStatement",body:i},alternate:a,endPos:c}}parseForStatement(e,t,o){const s=e.match(/for\s*\((.*)\)\s*\{?/);if(!s)throw new Error("Invalid for statement syntax");const r=s[1].split("of");if(r.length!==2)throw new Error("Only for...of loops are supported");const i=r[0].trim().replace(/^let\s+|^const\s+|^var\s+/,""),l=r[1].trim(),{body:a,endPos:c}=this.parseTemplateBlock(t,o);return{type:"ForStatement",init:{type:"VariableDeclaration",kind:"let",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:i},init:this.parseJsExpression(l)}]},test:null,update:null,body:{type:"BlockStatement",body:a},endPos:(()=>{const d=t.indexOf("<%",c),u=t.indexOf("%>",d);return d===c&&t.slice(d+2,u).trim()==="}"?u+2:c})()}}parseForEachStatement(e,t,o,s){const{body:r,endPos:i}=this.parseTemplateBlock(o,s);return{type:"ForEachStatement",collection:this.parseJsExpression(e),itemIdentifier:{type:"Identifier",name:t},body:{type:"BlockStatement",body:r},endPos:(()=>{const l=o.indexOf("<%",i),a=o.indexOf("%>",l);return l===i&&o.slice(l+2,a).trim()==="}"?a+2:i})()}}parseTemplateBlock(e,t){const o=[];let s=t;for(;s<e.length;){const r=e.indexOf("<%",s);if(r===-1){s<e.length&&o.push(this.createAppendLiteral(e.slice(s))),s=e.length;break}r>s&&o.push(this.createAppendLiteral(e.slice(s,r)));const i=e.indexOf("%>",r);if(i===-1)throw new Error("Unclosed EJS tag within block");const l=e.slice(r+2,i).trim();if(l==="}"||l.startsWith("} else")){s=r;break}if(s=i+2,l.startsWith("=")||l.startsWith("-")){const a=l.slice(1).trim();o.push(this.createAppendExpression(a))}else{if(l.startsWith("#"))continue;if(l.startsWith("if")){const a=this.parseIfStatement(l,e,s);o.push(a),s=a.endPos||s}else if(l.startsWith("for")){const a=this.parseForStatement(l,e,s);o.push(a),s=a.endPos||s}else{const a=l.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);if(a){const c=a[1],d=a[2],u=this.parseForEachStatement(c,d,e,s);o.push(u),s=u.endPos||s}else this.addMessage("info",`Unsupported scriptlet content within block: ${l}`)}}}return{body:o,endPos:s}}parseJsExpression(e){if(/^(['"]).*\1$/.test(e))return{type:"Literal",value:e.slice(1,-1)};if(/^-?\d+$/.test(e))return{type:"Literal",value:parseInt(e,10)};if(/^-?\d+\.\d+$/.test(e))return{type:"Literal",value:parseFloat(e)};if(e==="true"||e==="false")return{type:"Literal",value:e==="true"};for(const s of by){const r=e.lastIndexOf(s);if(r>0&&e[r-1]!=="!"&&e[r-1]!=="="&&e[r-1]!=="<"&&e[r-1]!==">")return{type:s==="&&"||s==="||"?"LogicalExpression":"BinaryExpression",operator:Sy[s],left:this.parseJsExpression(e.slice(0,r).trim()),right:this.parseJsExpression(e.slice(r+s.length).trim())}}const t=e.indexOf("."),o=e.indexOf("[");if(t>0&&(o===-1||t<o)||o>0&&(t===-1||o<t)){const s=t>0&&(o===-1||t<o)?t:o;let r,i,l=!1;if(s===t)r=e.slice(0,t),i={type:"Identifier",name:e.slice(t+1)},l=!1;else{r=e.slice(0,o);const a=e.indexOf("]",o);if(a===-1)throw new Error("Unclosed bracket in expression");const c=e.slice(o+1,a);i=/^(['"]).*\1$/.test(c)||/^-?\d+(\.\d+)?$/.test(c)?this.parseJsExpression(c):{type:"Identifier",name:c},l=!0}return{type:"MemberExpression",object:this.parseJsExpression(r),property:i,computed:l}}return{type:"Identifier",name:e}}astToGrapesJS(e){switch(e.type){case"Program":return this.handleProgram(e);case"VariableDeclaration":return this.handleVariableDeclaration(e);case"ExpressionStatement":return this.handleExpressionStatement(e);case"IfStatement":return this.handleIfStatement(e);case"ForStatement":return this.handleForStatement(e);case"ForEachStatement":return this.handleForEachStatement(e);case"BlockStatement":return this.handleBlockStatement(e);case"Literal":return this.handleLiteral(e);case"Identifier":return this.handleIdentifier(e);case"MemberExpression":return this.handleMemberExpression(e);case"BinaryExpression":return this.handleBinaryExpression(e);case"LogicalExpression":return this.handleLogicalExpression(e);case"CallExpression":return this.handleCallExpression(e);default:return this.addMessage("warning",`Unsupported node type: ${e.type}`),""}}handleProgram(e){let t="";for(const o of e.body)t+=this.astToGrapesJS(o);return t}handleVariableDeclaration(e){return""}handleExpressionStatement(e){return e.expression.type==="CallExpression"&&e.expression.callee.type==="Identifier"&&e.expression.callee.name==="__append"&&e.expression.arguments.length>0?this.astToGrapesJS(e.expression.arguments[0]):""}handleIfStatement(e){const t=this.getConditionExpression(e.test),o=this.astToGrapesJS(e.consequent);let s="";return e.alternate&&(s=this.astToGrapesJS(e.alternate)),`
875
+ const ${l}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getCollectionEndSyntax(){return"<% }) %>"}getConditionalStartSyntax({dataResolver:e}){return`<% if (${this._parseCondition(e.condition)}) { %>`}getConditionElseSyntax(){return"<% } else { %>"}getConditionalEndSyntax(){return"<% } %>"}getFullPath({collectionId:e,path:t,variableType:o}){return(e?[this._sanitizeVariableName(e),o,t].filter(Boolean).join("."):t)||""}_parseCondition(e){if(!e)return"";if(fy(e)){const t=e.statements.map(r=>this._parseCondition(r)),o=gy[e.logicalOperator];let s=t.length>1?`(${t.join(`)${o}(`)})`:t[0];return e.logicalOperator==="xor"&&(s=`!!(${s})`),s}else{const t=this._parseValue(e.left),o=this._parseValue(e.right);switch(e.operator){case"equals":return`${t} === ${o}`;case">":case"<":case">=":case"<=":case"=":case"!=":return`${t} ${e.operator} ${o}`;case"contains":return`${t}?.includes(${o})`;case"startsWith":return`${t}?.startsWith(${o})`;case"endsWith":return`${t}?.endsWith(${o})`;case"equalsIgnoreCase":return`${t}?.toLowerCase() === ${o}?.toLowerCase()`;case"trimEquals":return`${t}?.trim() === ${o}?.trim()`;case"isTruthy":return`!!${t}`;case"isFalsy":return`!${t}`;case"isDefined":return`${t} !== undefined`;case"isNull":return`${t} === null`;case"isUndefined":return`${t} === undefined`;case"isArray":return`Array.isArray(${t})`;case"isObject":return`typeof ${t} === 'object' && ${t} !== null && !Array.isArray(${t})`;case"isString":return`typeof ${t} === 'string'`;case"isNumber":return`typeof ${t} === 'number' && !isNaN(${t})`;case"isBoolean":return`typeof ${t} === 'boolean'`;default:return`${t} ${e.operator} ${o}`}}}_parseValue(e){return typeof e=="object"?this.getFullPath(e):typeof e=="string"?`'${e.replace(/'/g,"\\'")}'`:String(e)}}const gy={and:"&&",or:"||",xor:"^"},yy=["===","==","!==","!=","<=",">=","<",">","&&","||"],by={"===":"=","==":"=","!==":"!=","!=":"!=","<=":"<=",">=":">=","<":"<",">":">","&&":"&&","||":"||"};class Sy{constructor(){this.messages=[],this.collectionStack=[]}import(e){this.messages=[],this.collectionStack=[];try{const t=this.parseEjsTemplate(e);return this.astToGrapesJS(t)}catch(t){return console.error("Error during import:",t),this.addMessage("error",`Error during import: ${t instanceof Error?t.message:String(t)}`),""}}parseEjsTemplate(e){const t=[];let o=0;for(;o<e.length;){const s=e.indexOf("<%",o);if(s===-1){o<e.length&&t.push(this.createAppendLiteral(e.slice(o)));break}s>o&&t.push(this.createAppendLiteral(e.slice(o,s)));const r=e.indexOf("%>",s);if(r===-1)throw new Error("Unclosed EJS tag");const i=e.slice(s+2,r).trim();if(o=r+2,i.startsWith("=")||i.startsWith("-")){const l=i.slice(1).trim();t.push(this.createAppendExpression(l))}else{if(i.startsWith("#"))continue;if(i.startsWith("if")){const l=this.parseIfStatement(i,e,o);t.push(l),o=l.endPos||o}else if(i.startsWith("for")){const l=this.parseForStatement(i,e,o);t.push(l),o=l.endPos||o}else{const l=i.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);if(l){const a=l[1],c=l[2],d=this.parseForEachStatement(a,c,e,o);t.push(d),o=d.endPos||o}else this.addMessage("info",`Unsupported scriptlet content: ${i}`)}}}return{type:"Program",body:t}}createAppendLiteral(e){return{type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:"__append"},arguments:[{type:"Literal",value:e}]}}}createAppendExpression(e){return{type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:"__append"},arguments:[this.parseJsExpression(e)]}}}parseIfStatement(e,t,o){const s=e.match(/if\s*\((.*)\)\s*\{?/);if(!s)throw new Error("Invalid if statement syntax");const r=this.parseJsExpression(s[1]),{body:i,endPos:l}=this.parseTemplateBlock(t,o);let a=null,c=l;const d=t.indexOf("<%",c);if(d===c){const u=t.indexOf("%>",d);if(u!==-1){const p=t.slice(d+2,u).trim(),h=u+2-d;if(p.startsWith("} else if")){c=d+h;const f=p.substring(p.indexOf("if")).trim(),m=this.parseIfStatement(f,t,c);a={type:"IfStatement",test:m.test,consequent:m.consequent,alternate:m.alternate},c=m.endPos}else if(p.startsWith("} else")){c=d+h;const{body:f,endPos:m}=this.parseTemplateBlock(t,c);a={type:"BlockStatement",body:f},c=m;const g=t.indexOf("<%",c),b=t.indexOf("%>",g);g===c&&t.slice(g+2,b).trim()==="}"&&(c=b+2)}else p==="}"&&(c=d+h)}}return{type:"IfStatement",test:r,consequent:{type:"BlockStatement",body:i},alternate:a,endPos:c}}parseForStatement(e,t,o){const s=e.match(/for\s*\((.*)\)\s*\{?/);if(!s)throw new Error("Invalid for statement syntax");const r=s[1].split("of");if(r.length!==2)throw new Error("Only for...of loops are supported");const i=r[0].trim().replace(/^let\s+|^const\s+|^var\s+/,""),l=r[1].trim(),{body:a,endPos:c}=this.parseTemplateBlock(t,o);return{type:"ForStatement",init:{type:"VariableDeclaration",kind:"let",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:i},init:this.parseJsExpression(l)}]},test:null,update:null,body:{type:"BlockStatement",body:a},endPos:(()=>{const d=t.indexOf("<%",c),u=t.indexOf("%>",d);return d===c&&t.slice(d+2,u).trim()==="}"?u+2:c})()}}parseForEachStatement(e,t,o,s){const{body:r,endPos:i}=this.parseTemplateBlock(o,s);return{type:"ForEachStatement",collection:this.parseJsExpression(e),itemIdentifier:{type:"Identifier",name:t},body:{type:"BlockStatement",body:r},endPos:(()=>{const l=o.indexOf("<%",i),a=o.indexOf("%>",l);return l===i&&o.slice(l+2,a).trim()==="}"?a+2:i})()}}parseTemplateBlock(e,t){const o=[];let s=t;for(;s<e.length;){const r=e.indexOf("<%",s);if(r===-1){s<e.length&&o.push(this.createAppendLiteral(e.slice(s))),s=e.length;break}r>s&&o.push(this.createAppendLiteral(e.slice(s,r)));const i=e.indexOf("%>",r);if(i===-1)throw new Error("Unclosed EJS tag within block");const l=e.slice(r+2,i).trim();if(l==="}"||l.startsWith("} else")){s=r;break}if(s=i+2,l.startsWith("=")||l.startsWith("-")){const a=l.slice(1).trim();o.push(this.createAppendExpression(a))}else{if(l.startsWith("#"))continue;if(l.startsWith("if")){const a=this.parseIfStatement(l,e,s);o.push(a),s=a.endPos||s}else if(l.startsWith("for")){const a=this.parseForStatement(l,e,s);o.push(a),s=a.endPos||s}else{const a=l.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);if(a){const c=a[1],d=a[2],u=this.parseForEachStatement(c,d,e,s);o.push(u),s=u.endPos||s}else this.addMessage("info",`Unsupported scriptlet content within block: ${l}`)}}}return{body:o,endPos:s}}parseJsExpression(e){if(/^(['"]).*\1$/.test(e))return{type:"Literal",value:e.slice(1,-1)};if(/^-?\d+$/.test(e))return{type:"Literal",value:parseInt(e,10)};if(/^-?\d+\.\d+$/.test(e))return{type:"Literal",value:parseFloat(e)};if(e==="true"||e==="false")return{type:"Literal",value:e==="true"};for(const s of yy){const r=e.lastIndexOf(s);if(r>0&&e[r-1]!=="!"&&e[r-1]!=="="&&e[r-1]!=="<"&&e[r-1]!==">")return{type:s==="&&"||s==="||"?"LogicalExpression":"BinaryExpression",operator:by[s],left:this.parseJsExpression(e.slice(0,r).trim()),right:this.parseJsExpression(e.slice(r+s.length).trim())}}const t=e.indexOf("."),o=e.indexOf("[");if(t>0&&(o===-1||t<o)||o>0&&(t===-1||o<t)){const s=t>0&&(o===-1||t<o)?t:o;let r,i,l=!1;if(s===t)r=e.slice(0,t),i={type:"Identifier",name:e.slice(t+1)},l=!1;else{r=e.slice(0,o);const a=e.indexOf("]",o);if(a===-1)throw new Error("Unclosed bracket in expression");const c=e.slice(o+1,a);i=/^(['"]).*\1$/.test(c)||/^-?\d+(\.\d+)?$/.test(c)?this.parseJsExpression(c):{type:"Identifier",name:c},l=!0}return{type:"MemberExpression",object:this.parseJsExpression(r),property:i,computed:l}}return{type:"Identifier",name:e}}astToGrapesJS(e){switch(e.type){case"Program":return this.handleProgram(e);case"VariableDeclaration":return this.handleVariableDeclaration(e);case"ExpressionStatement":return this.handleExpressionStatement(e);case"IfStatement":return this.handleIfStatement(e);case"ForStatement":return this.handleForStatement(e);case"ForEachStatement":return this.handleForEachStatement(e);case"BlockStatement":return this.handleBlockStatement(e);case"Literal":return this.handleLiteral(e);case"Identifier":return this.handleIdentifier(e);case"MemberExpression":return this.handleMemberExpression(e);case"BinaryExpression":return this.handleBinaryExpression(e);case"LogicalExpression":return this.handleLogicalExpression(e);case"CallExpression":return this.handleCallExpression(e);default:return this.addMessage("warning",`Unsupported node type: ${e.type}`),""}}handleProgram(e){let t="";for(const o of e.body)t+=this.astToGrapesJS(o);return t}handleVariableDeclaration(e){return""}handleExpressionStatement(e){return e.expression.type==="CallExpression"&&e.expression.callee.type==="Identifier"&&e.expression.callee.name==="__append"&&e.expression.arguments.length>0?this.astToGrapesJS(e.expression.arguments[0]):""}handleIfStatement(e){const t=this.getConditionExpression(e.test),o=this.astToGrapesJS(e.consequent);let s="";return e.alternate&&(s=this.astToGrapesJS(e.alternate)),`
886
876
  <data-condition data-gjs-data-resolver='${JSON.stringify({condition:t})}'>
887
877
  <data-condition-true-content>${o}</data-condition-true-content>
888
878
  <data-condition-false-content>${s}</data-condition-false-content>
@@ -899,7 +889,7 @@ const ${l}={ currentItem, currentIndex: startIndex + index, remainingItems: endI
899
889
  ${r}
900
890
  </data-collection-item>
901
891
  </data-collection>
902
- `}handleBlockStatement(e){let t="";for(const o of e.body)t+=this.astToGrapesJS(o);return t}handleLiteral(e){return String(e.value??"")}handleIdentifier(e){let t={path:e.name};if(this.collectionStack.length>0){const o=this.collectionStack[this.collectionStack.length-1];e.name===o&&(t={collectionId:o,variableType:"currentItem"})}return`<data-variable data-gjs-data-resolver='${JSON.stringify(t)}'></data-variable>`}handleMemberExpression(e,t={}){let s={path:this.getExpressionString(e),...t};if(this.collectionStack.length>0){const r=this.collectionStack[this.collectionStack.length-1];let i=e;const l=[];for(;i.type==="MemberExpression";)i.property.type==="Identifier"&&!i.computed?l.unshift(i.property.name):i.property.type==="Literal"&&i.computed?l.unshift(String(i.property.value)):l.unshift(this.getExpressionString(i.property)),i=i.object;if(i.type==="Identifier"&&i.name===r){const a=l.join(".");s={...t,collectionId:r,variableType:"currentItem",path:a}}}return`<data-variable data-gjs-data-resolver='${JSON.stringify(s)}'></data-variable>`}handleBinaryExpression(e){return`${this.getExpressionString(e.left)} ${e.operator} ${this.getExpressionString(e.right)}`}handleLogicalExpression(e){return e.operator==="||"&&e.right.type==="Literal"?this.handleMemberExpression(e.left,{defaultValue:e.right.value}):`${this.getExpressionString(e.left)} ${e.operator} ${this.getExpressionString(e.right)}`}handleCallExpression(e){var t;if(e.callee.type==="Identifier"&&e.callee.name==="include"){const o=((t=e.arguments[0])==null?void 0:t.type)==="Literal"?String(e.arguments[0].value):"";return this.addMessage("info",`Partial includes are not fully supported: ${o}`),""}return""}getConditionExpression(e){if(e.type==="Identifier")return{logicalOperator:"and",statements:[{left:{type:"data-variable",path:e.name},operator:"isTruthy"}]};if(e.type==="MemberExpression"){let t=this.getExpressionString(e),o="isTruthy";return t.startsWith("!!")?(o="isTruthy",t=t.slice(2)):t.startsWith("!")&&(o="isFalsy",t=t.slice(1)),{logicalOperator:"and",statements:[{left:{type:"data-variable",path:t},operator:o}]}}if(e.type==="BinaryExpression"||e.type==="LogicalExpression"){const t=this.getConditionExpression(e.left),o=this.getConditionExpression(e.right);return`${t} ${e.operator} ${o}`}return e.type==="Literal"?typeof e.value=="string"?`'${e.value}'`:String(e.value??""):this.getExpressionString(e)}getExpressionString(e){switch(e.type){case"Identifier":return e.name;case"Literal":return String(e.value??"");case"MemberExpression":{const t=this.getExpressionString(e.object),o=this.getExpressionString(e.property);return e.computed?`${t}[${o}]`:`${t}.${o}`}case"BinaryExpression":{const t=this.getExpressionString(e.left),o=this.getExpressionString(e.right);return`${t} ${e.operator} ${o}`}case"LogicalExpression":{const t=this.getExpressionString(e.left),o=this.getExpressionString(e.right);return`${t} ${e.operator} ${o}`}default:return this.addMessage("warning",`Unsupported expression type for getExpressionString: ${e.type}`),""}}addMessage(e,t){this.messages.push({type:e,message:t})}}const xy="dataSourceEjs",wy=F.startup,Cy=G(function(n,e={}){const t=ou(n,new gy),o=su(n,{contains:"<%",importer:new vy});W({editor:n,licenseKey:e.licenseKey,plan:wy,pluginName:xy,cleanup:()=>{t(),o()}})}),ru={equals:"equals",isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue"},ky={...ru,...{">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq"},...{contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"}};class Ty{getHelperId(e){return ky[e]||e}getFullPath({collectionId:e,path:t}){let o=t;return e&&(o=[this._sanitizeVariableName(e),t].filter(Boolean).join(".")),o||""}getVariableSyntax(e){const{defaultValue:t}=e,o=this.getFullPath(e);return t?`{{#if ${o}}}{{{${o}}}}{{else}}${t}{{/if}}`:`{{{${o}}}}`}getCollectionStartSyntax(e){const{collectionId:t,dataSource:o}=e,s=o==null?void 0:o.path;let r="";if(e.startIndex!==void 0||e.endIndex!==void 0){const c=e.startIndex??0,d=e.endIndex!==void 0?e.endIndex:"";d!==""?r=` (slice ${s} ${c} ${d})`:r=` (slice ${s} ${c})`}const l=` as |${this._sanitizeVariableName(t)}|`;return`{{#each ${r||s}${l}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax(e){if(!e)return"";const t=e,o=e;if(o.statements&&o.logicalOperator==="and"||o.logicalOperator==="or"){const{statements:s}=o,r=o.logicalOperator,i=s.map(a=>this._parseCondition(a)).join(" ");return`{{#if ${s.length>1?`(${r} ${i})`:i}}}`}else return`{{#if ${this._parseCondition(t)}}}`}_parseCondition(e){if(!e)return"";const t=e,o=e;if(o.statements&&o.logicalOperator==="and"||o.logicalOperator==="or"){const{statements:s}=o,r=o.logicalOperator,i=o.statements.map(l=>this._parseCondition(l)).join(" ");return s.length>1?`(${r} ${i})`:i}else{const s=t.operator,r=this.getHelperId(s),i=this._parseValue(t.left),l=this._parseValue(t.right);return this.getExpressionStr(r,i,l)}}getExpressionStr(e,t,o){return ru[e]?e==="isTruthy"?t:e==="isFalsy"?`!${t}`:`${e} ${t}`:`(${e} ${t} ${o})`}_parseValue(e){return typeof e=="object"?this.getFullPath(e):typeof e=="string"?`'${e.replace(/'/g,"\\'")}'`:String(e)}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getConditionElseSyntax(){return"{{else}}"}getConditionalEndSyntax(){return"{{/if}}"}}class Ey{constructor(){this.messages=[],this.collectionStack=[]}import(e){this.messages=[],this.collectionStack=[];const t=this.parse(e);return this.astToGrapesJS(t)}parse(e){try{return vn.parse(e)}catch(t){if(t instanceof Error&&t.message.includes("Parse error")){const o=t.message.match(/line (\d+)/),s=o?parseInt(o[1]):0,r=t.message.match(/column (\d+)/),i=r?parseInt(r[1]):0;throw new Error(`Handlebars syntax error at line ${s}, column ${i}: ${t.message}`)}throw t}}astToGrapesJS(e){switch(e.type){case"Program":return this.handleProgram(e);case"ContentStatement":return this.handleContentStatement(e);case"MustacheStatement":return this.handleMustacheStatement(e);case"BlockStatement":return this.handleBlockStatement(e);case"PartialStatement":return this.handlePartialStatement(e);case"CommentStatement":return this.handleCommentStatement(e);case"ElementNode":return this.handleElementNode(e);case"TextNode":return this.handleTextNode(e);default:return this.addMessage("warning",`Unsupported node type: ${e.type}`,e.loc),""}}handleProgram(e){let t="";if(e.body)for(const o of e.body)t+=this.astToGrapesJS(o);return t}handleContentStatement(e){return e.value||""}handleMustacheStatement(e,t={}){const o=this.getExpressionString(e.path),s={...t};return this.collectionStack.length>0?this.processPathWithCollectionContext(o,s):s.path=o,`<data-variable data-gjs-data-resolver='${JSON.stringify(s)}'></data-variable>`}processPathWithCollectionContext(e,t){e.startsWith("@")?this.handleDirectCollectionReference(e,t):this.handleRelativePathReference(e,t)}handleDirectCollectionReference(e,t){if(this.isSpecialIterationVariable(e)){this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length-1],e,t);return}const[o,...s]=e.substring(1).split("/"),r=s.join(".");this.collectionStack.includes(o)?this.setCurrentItemResolver(o,r,t):this.handleParentReferenceFallback(e,t)}isSpecialIterationVariable(e){return["index","@index","key","@key"].includes(e)}setSpecialVariableResolver(e,t,o){o.collectionId=e;const s={index:"currentIndex","@index":"currentIndex",key:"currentKey","@key":"currentKey"};o.variableType=s[t]}setCurrentItemResolver(e,t,o){o.collectionId=e,o.variableType="currentItem",t&&(o.path=t)}handleRelativePathReference(e,t){const o=pi(e),{parentLevel:s,remainingPathParts:r}=this.calculateParentLevel(o),i=r.join("."),l=this.collectionStack.length-1-s;l>=0&&l<this.collectionStack.length?this.resolveRelativePath(i,l,t):t.path=r.join(".")}calculateParentLevel(e){const t=this.collectionStack.findLastIndex(r=>r===e[0]);if(t!==-1)return{parentLevel:this.collectionStack.length-1-t,remainingPathParts:e.slice(1)};let o=0;const s=[...e];for(;s[0]==="..";)o++,s.shift();return{parentLevel:o,remainingPathParts:s}}resolveRelativePath(e,t,o){const s=this.collectionStack[t];o.collectionId=s,o.variableType="currentItem",e!=="this"&&(o.path=e.startsWith("this.")?e.split(".").slice(1).join("."):e)}handleParentReferenceFallback(e,t){const o=pi(e),{parentLevel:s,remainingPathParts:r}=this.calculateParentLevel(o),i=r.join("."),l=this.collectionStack.length-1-s;l>=0&&l<this.collectionStack.length?this.resolveRelativePath(i,l,t):t.path=r.join(".")}handleBlockStatement(e){const t=e.path.original;switch(t){case"if":case"unless":return this.handleConditionalBlock(e,t);case"each":return this.handleEachBlock(e);default:return this.addMessage("warning",`Unsupported block helper: ${t}`,e.loc),this.handleGenericBlock(e)}}handleConditionalBlock(e,t){const r={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(e.params[0])},operator:t==="unless"?"isFalsy":"isTruthy"}]},i=this.handleProgram(e.program),l=e.inverse?this.handleProgram(e.inverse):"";return`
892
+ `}handleBlockStatement(e){let t="";for(const o of e.body)t+=this.astToGrapesJS(o);return t}handleLiteral(e){return String(e.value??"")}handleIdentifier(e){let t={path:e.name};if(this.collectionStack.length>0){const o=this.collectionStack[this.collectionStack.length-1];e.name===o&&(t={collectionId:o,variableType:"currentItem"})}return`<data-variable data-gjs-data-resolver='${JSON.stringify(t)}'></data-variable>`}handleMemberExpression(e,t={}){let s={path:this.getExpressionString(e),...t};if(this.collectionStack.length>0){const r=this.collectionStack[this.collectionStack.length-1];let i=e;const l=[];for(;i.type==="MemberExpression";)i.property.type==="Identifier"&&!i.computed?l.unshift(i.property.name):i.property.type==="Literal"&&i.computed?l.unshift(String(i.property.value)):l.unshift(this.getExpressionString(i.property)),i=i.object;if(i.type==="Identifier"&&i.name===r){const a=l.join(".");s={...t,collectionId:r,variableType:"currentItem",path:a}}}return`<data-variable data-gjs-data-resolver='${JSON.stringify(s)}'></data-variable>`}handleBinaryExpression(e){return`${this.getExpressionString(e.left)} ${e.operator} ${this.getExpressionString(e.right)}`}handleLogicalExpression(e){return e.operator==="||"&&e.right.type==="Literal"?this.handleMemberExpression(e.left,{defaultValue:e.right.value}):`${this.getExpressionString(e.left)} ${e.operator} ${this.getExpressionString(e.right)}`}handleCallExpression(e){var t;if(e.callee.type==="Identifier"&&e.callee.name==="include"){const o=((t=e.arguments[0])==null?void 0:t.type)==="Literal"?String(e.arguments[0].value):"";return this.addMessage("info",`Partial includes are not fully supported: ${o}`),""}return""}getConditionExpression(e){if(e.type==="Identifier")return{logicalOperator:"and",statements:[{left:{type:"data-variable",path:e.name},operator:"isTruthy"}]};if(e.type==="MemberExpression"){let t=this.getExpressionString(e),o="isTruthy";return t.startsWith("!!")?(o="isTruthy",t=t.slice(2)):t.startsWith("!")&&(o="isFalsy",t=t.slice(1)),{logicalOperator:"and",statements:[{left:{type:"data-variable",path:t},operator:o}]}}if(e.type==="BinaryExpression"||e.type==="LogicalExpression"){const t=this.getConditionExpression(e.left),o=this.getConditionExpression(e.right);return`${t} ${e.operator} ${o}`}return e.type==="Literal"?typeof e.value=="string"?`'${e.value}'`:String(e.value??""):this.getExpressionString(e)}getExpressionString(e){switch(e.type){case"Identifier":return e.name;case"Literal":return String(e.value??"");case"MemberExpression":{const t=this.getExpressionString(e.object),o=this.getExpressionString(e.property);return e.computed?`${t}[${o}]`:`${t}.${o}`}case"BinaryExpression":{const t=this.getExpressionString(e.left),o=this.getExpressionString(e.right);return`${t} ${e.operator} ${o}`}case"LogicalExpression":{const t=this.getExpressionString(e.left),o=this.getExpressionString(e.right);return`${t} ${e.operator} ${o}`}default:return this.addMessage("warning",`Unsupported expression type for getExpressionString: ${e.type}`),""}}addMessage(e,t){this.messages.push({type:e,message:t})}}const vy="dataSourceEjs",xy=_.startup,wy=j(function(n,e={}){const t=su(n,new my),o=ru(n,{contains:"<%",importer:new Sy});q({editor:n,licenseKey:e.licenseKey,plan:xy,pluginName:vy,cleanup:()=>{t(),o()}})}),iu={equals:"equals",isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue"},Cy={...iu,...{">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq"},...{contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"}};class ky{getHelperId(e){return Cy[e]||e}getFullPath({collectionId:e,path:t}){let o=t;return e&&(o=[this._sanitizeVariableName(e),t].filter(Boolean).join(".")),o||""}getVariableSyntax({dataResolver:e}){const{defaultValue:t}=e,o=this.getFullPath(e);return t?`{{#if ${o}}}{{{${o}}}}{{else}}${t}{{/if}}`:`{{{${o}}}}`}getCollectionStartSyntax({dataResolver:e}){const{collectionId:t,dataSource:o}=e,s=o==null?void 0:o.path;let r="";if(e.startIndex!==void 0||e.endIndex!==void 0){const c=e.startIndex??0,d=e.endIndex!==void 0?e.endIndex:"";d!==""?r=` (slice ${s} ${c} ${d})`:r=` (slice ${s} ${c})`}const l=` as |${this._sanitizeVariableName(t)}|`;return`{{#each ${r||s}${l}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax({dataResolver:e}){const t=e.condition;if(!t)return"";const o=t,s=t;if(s.statements&&s.logicalOperator==="and"||s.logicalOperator==="or"){const{statements:r}=s,i=s.logicalOperator,l=r.map(c=>this._parseCondition(c)).join(" ");return`{{#if ${r.length>1?`(${i} ${l})`:l}}}`}else return`{{#if ${this._parseCondition(o)}}}`}_parseCondition(e){if(!e)return"";const t=e,o=e;if(o.statements&&o.logicalOperator==="and"||o.logicalOperator==="or"){const{statements:s}=o,r=o.logicalOperator,i=o.statements.map(l=>this._parseCondition(l)).join(" ");return s.length>1?`(${r} ${i})`:i}else{const s=t.operator,r=this.getHelperId(s),i=this._parseValue(t.left),l=this._parseValue(t.right);return this.getExpressionStr(r,i,l)}}getExpressionStr(e,t,o){return iu[e]?e==="isTruthy"?t:e==="isFalsy"?`!${t}`:`${e} ${t}`:`(${e} ${t} ${o})`}_parseValue(e){return typeof e=="object"?this.getFullPath(e):typeof e=="string"?`'${e.replace(/'/g,"\\'")}'`:String(e)}_sanitizeVariableName(e){return e.replace(/[^a-zA-Z0-9_$]/g,"_")}getConditionElseSyntax(){return"{{else}}"}getConditionalEndSyntax(){return"{{/if}}"}}class Ty{constructor(){this.messages=[],this.collectionStack=[]}import(e){this.messages=[],this.collectionStack=[];const t=this.parse(e);return this.astToGrapesJS(t)}parse(e){try{return wn.parse(e)}catch(t){if(t instanceof Error&&t.message.includes("Parse error")){const o=t.message.match(/line (\d+)/),s=o?parseInt(o[1]):0,r=t.message.match(/column (\d+)/),i=r?parseInt(r[1]):0;throw new Error(`Handlebars syntax error at line ${s}, column ${i}: ${t.message}`)}throw t}}astToGrapesJS(e){switch(e.type){case"Program":return this.handleProgram(e);case"ContentStatement":return this.handleContentStatement(e);case"MustacheStatement":return this.handleMustacheStatement(e);case"BlockStatement":return this.handleBlockStatement(e);case"PartialStatement":return this.handlePartialStatement(e);case"CommentStatement":return this.handleCommentStatement(e);case"ElementNode":return this.handleElementNode(e);case"TextNode":return this.handleTextNode(e);default:return this.addMessage("warning",`Unsupported node type: ${e.type}`,e.loc),""}}handleProgram(e){let t="";if(e.body)for(const o of e.body)t+=this.astToGrapesJS(o);return t}handleContentStatement(e){return e.value||""}handleMustacheStatement(e,t={}){const o=this.getExpressionString(e.path),s={...t};return this.collectionStack.length>0?this.processPathWithCollectionContext(o,s):s.path=o,`<data-variable data-gjs-data-resolver='${JSON.stringify(s)}'></data-variable>`}processPathWithCollectionContext(e,t){e.startsWith("@")?this.handleDirectCollectionReference(e,t):this.handleRelativePathReference(e,t)}handleDirectCollectionReference(e,t){if(this.isSpecialIterationVariable(e)){this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length-1],e,t);return}const[o,...s]=e.substring(1).split("/"),r=s.join(".");this.collectionStack.includes(o)?this.setCurrentItemResolver(o,r,t):this.handleParentReferenceFallback(e,t)}isSpecialIterationVariable(e){return["index","@index","key","@key"].includes(e)}setSpecialVariableResolver(e,t,o){o.collectionId=e;const s={index:"currentIndex","@index":"currentIndex",key:"currentKey","@key":"currentKey"};o.variableType=s[t]}setCurrentItemResolver(e,t,o){o.collectionId=e,o.variableType="currentItem",t&&(o.path=t)}handleRelativePathReference(e,t){const o=hi(e),{parentLevel:s,remainingPathParts:r}=this.calculateParentLevel(o),i=r.join("."),l=this.collectionStack.length-1-s;l>=0&&l<this.collectionStack.length?this.resolveRelativePath(i,l,t):t.path=r.join(".")}calculateParentLevel(e){const t=this.collectionStack.findLastIndex(r=>r===e[0]);if(t!==-1)return{parentLevel:this.collectionStack.length-1-t,remainingPathParts:e.slice(1)};let o=0;const s=[...e];for(;s[0]==="..";)o++,s.shift();return{parentLevel:o,remainingPathParts:s}}resolveRelativePath(e,t,o){const s=this.collectionStack[t];o.collectionId=s,o.variableType="currentItem",e!=="this"&&(o.path=e.startsWith("this.")?e.split(".").slice(1).join("."):e)}handleParentReferenceFallback(e,t){const o=hi(e),{parentLevel:s,remainingPathParts:r}=this.calculateParentLevel(o),i=r.join("."),l=this.collectionStack.length-1-s;l>=0&&l<this.collectionStack.length?this.resolveRelativePath(i,l,t):t.path=r.join(".")}handleBlockStatement(e){const t=e.path.original;switch(t){case"if":case"unless":return this.handleConditionalBlock(e,t);case"each":return this.handleEachBlock(e);default:return this.addMessage("warning",`Unsupported block helper: ${t}`,e.loc),this.handleGenericBlock(e)}}handleConditionalBlock(e,t){const r={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(e.params[0])},operator:t==="unless"?"isFalsy":"isTruthy"}]},i=this.handleProgram(e.program),l=e.inverse?this.handleProgram(e.inverse):"";return`
903
893
  <data-condition data-gjs-data-resolver='${JSON.stringify({condition:r})}'>
904
894
  <data-condition-true-content>${i}</data-condition-true-content>
905
895
  <data-condition-false-content>${l}</data-condition-false-content>
@@ -908,4 +898,4 @@ const ${l}={ currentItem, currentIndex: startIndex + index, remainingItems: endI
908
898
  <data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:t},collectionId:o})}'>
909
899
  <data-collection-item>${s}</data-collection-item>
910
900
  </data-collection>
911
- `}handleCommentStatement(e){return`<!--${e.value}-->`}handleElementNode(e){let t="";if(e.attributes)for(const s of e.attributes)s.value.type==="TextNode"?t+=` ${s.name}="${s.value.chars}"`:(this.addMessage("warning",`Complex attribute values not fully supported: ${s.name}`,e.loc),t+=` ${s.name}="${this.getExpressionString(s.value)}"`);let o="";if(e.children)for(const s of e.children)o+=this.astToGrapesJS(s);return`<${e.tag}${t}>${o}</${e.tag}>`}handleTextNode(e){return e.chars||""}handlePartialStatement(e){return this.addMessage("warning",`Partials are not fully supported: ${e.name.original}`,e.loc),`{{> ${e.name.original}}}`}handleGenericBlock(e){const t=this.handleProgram(e.program);return`<!-- Unsupported block: ${e.path.original} -->${t}`}getExpressionString(e){return e.type==="PathExpression"?e.original:e.type==="StringLiteral"?e.value:e.type==="NumberLiteral"?e.value.toString():e.type==="BooleanLiteral"?e.value?"true":"false":e.type==="SubExpression"?this.getExpressionString(e.params[0]):e.type==="Hash"?`{${e.pairs.map(o=>`${o.key}=${this.getExpressionString(o.value)}`).join(", ")}}`:(this.addMessage("warning",`Complex expression type not fully supported: ${e.type}`,e.loc),"")}addMessage(e,t,o){this.messages.push({type:e,message:t,location:o?{line:o.start.line,column:o.start.column}:void 0})}}const pi=n=>{if(n==null||n==="")return[];if(n===".")return["this"];if(n===".."||n==="../")return[".."];if(n.startsWith("../")){const i=n.substring(3);return["..",...pi(i)]}const e=[];let t=0,o=n.replace(/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,(i,l,a,c)=>{const d=a!==void 0?a:c||"";return e[t]=d,`__HANDLEBARS_PLACEHOLDER_${t++}__`});o=o.replace(/\//g,".");const s=o.split("."),r=[];for(const i of s){const l=/^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(i);if(l){const a=parseInt(l[1],10);r.push(e[a])}else i!==""&&r.push(i)}return r},My="dataSourceHandlebars",Ay=F.startup,Py=G(function(n,e={}){const t=ou(n,new Ty),o=su(n,{contains:"{{",importer:new Ey});W({editor:n,licenseKey:e.licenseKey,plan:Ay,pluginName:My,cleanup:()=>{t(),o()}})}),Oy=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)},iu="youtube-video",Ny=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:o="high"}=n,s=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=Oy(l);return`${c}?${d}`},r=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},i=l=>{const a=r(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,type:iu,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:[iu],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 h=await(await fetch(s(u))).json();return(m=h.items)!=null&&m.length?{items:h.items.map(i),nextPageCustomData:{token:h.nextPageToken},isLastPage:!h.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}}]})}},Iy={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},Ry="youtubeAssetProvider",Dy=F.startup,Ly=G(function(n,e){var c;const{skipVideoComponent:t,i18n:o={}}=e,s=Ny(e);n.runCommand(_.assetProviderAdd,{provider:s});const r="search-on-youtube",i="video",l=(c=n.Components.getType(i))==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(i,{model:{getYoutubeTraits(){const[d,...u]=l.getYoutubeTraits.apply(this);return[d,{id:r,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:Iy,...o}),W({editor:n,licenseKey:e.licenseKey,plan:Dy,pluginName:Ry,cleanup:()=>{n.runCommand(_.assetProviderRemove,{id:s.id}),!t&&l&&n.Components.addType(i,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==r)}}})}})}),oo=n=>n.replaceAll('"',"").replaceAll("'",""),hi=n=>n.includes(",")?n:/\s/.test(n)?`"${oo(n)}"`:oo(n),lu=(n,e,t)=>({family:n,variant:e,...t}),au=(n,e)=>{n=hi(n);const{menuVariant:t,variants:o}=e;return{family:n,familyLabel:oo(n),menuVariant:t&&lu(hi(`menuFont-${oo(n)}`),"regular",t),variants:Object.assign({},...Object.entries(o).map(([s,r])=>({[s]:lu(n,s,r)})))}},cu=(n,e)=>{var l;const t=au(n.family,n),o=t.menuVariant??((l=Object.values(t.variants))==null?void 0:l[0]);if(!o)return"Arial, Helvetica, sans-serif";const{source:s,descriptors:r}=o,i=oo(o.family);if(!e){const a=new FontFace(i,`url("${s}")`,r),c=Array.from(document.fonts.values()).filter(d=>d.family===i);for(const d of c)document.fonts.delete(d);document.fonts.add(a),a.load().catch(()=>{})}return hi(i)},$y=n=>{const{family:e,menu:t,axes:o}=n,s=!!o,r=Object.assign({},...n.variants.map(i=>{var d,u;let l,a;if(s){const p=o.find(h=>h.tag==="wght");if(p){const{start:h,end:f}=p;l=`${h} ${f}`}}return l||(l=((d=i.match(/\d+/))==null?void 0:d[0])??"400"),a=((u=i.match(/[a-zA-Z]+/))==null?void 0:u[0])==="italic"?"italic":void 0,{[i]:{source:n.files[i],descriptors:{style:a,weight:l}}}}));return au(e,{menuVariant:{source:t},variants:r})},zy=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:$y(n),needsLoading:!0}}),By=n=>{const{font:e}=n.customData;return n.customData.needsLoading?(n.customData.needsLoading=!1,cu(e)):cu(e,!0)};let so;const Vy=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)},Hy=n=>{const{apiKey:e,searchParams:t}=n,o=(s={})=>{const r="https://www.googleapis.com/webfonts/v1/webfonts",i=Vy(s);return`${r}?${i}`};return{id:"google-fonts",types:["font"],label:({editor:s})=>s.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var c;if(so)return so;const s={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},r=t==null?void 0:t(),i={...s,...r},a=await(await fetch(o(i))).json();return(c=a.items)!=null&&c.length?(so=a.items.map(zy),so):[]},itemLayout:s=>{const r=so.find(l=>l.id===s.assetProps.id),i=By(r);return{type:"column",onClick:()=>s.onSelect(r),htmlAttrs:{title:r.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}},{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"16px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},Fy={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},_y="googleFontsAssetProvider",Gy=F.startup,Wy=G(function(n,e){const{i18n:t={}}=e,o=Hy(e);n.runCommand(_.assetProviderAdd,{provider:o}),n.I18n.addMessages({en:Fy,...t}),W({editor:n,licenseKey:e.licenseKey,plan:Gy,pluginName:_y,cleanup:()=>{n.runCommand(_.assetProviderRemove,{id:o.id})}})}),jy="canvasAbsoluteMode",qy=F.startup,Uy=(n,e,t)=>{const o=t.enableAbsolute??(a=>a.hasAbsolute),r=(Array.isArray(e)?e:e?[e]:[...n.getSelectedAll()])[0];if(!r)return;const i=r.getEl();return{result:yt(o)?o({component:r,hasAbsolute:!!i&&getComputedStyle(i).position==="absolute"}):!1,component:r,dmode:r.get("dmode")}};function ps({guideMatched:n,canvasView:e}){var M;const t=n.guide.x===void 0?"y":"x";let o=0,s=0,r=0,i=0;const{guide:l,matched:a}=n,c=e.getElBoxRect(l.componentView.el),d=e.getElBoxRect(((M=a.componentView)==null?void 0:M.el)||a.componentEl),u=c.y,p=c.y+c.height,h=c.x,f=c.x+c.width,m=d.y,g=d.y+d.height,b=d.x,C=d.x+d.width,y=Math.max(0,u-g),S=Math.max(0,m-p),v=Math.max(0,h-C),w=Math.max(0,b-f),x=y>S,T=v>w,k=l.type;return t==="x"&&(k==="l"?(o=h,x?(s=g,r=y):(s=p,r=S)):k==="r"?(o=f,x?(s=g,r=y):(s=p,r=S)):k==="x"&&(o=h-(h-f)/2,x?(s=g,r=y):(s=p,r=S))),t==="y"&&(k==="t"?(s=u,T?(o=C,i=v):(o=f,i=w)):k==="b"?(s=p,T?(o=C,i=v):(o=f,i=w)):k==="y"&&(s=u-(u-p)/2,T?(o=C,i=v):(o=f,i=w))),{axis:t,x:o,y:s,width:i,height:r}}function Ky({guideMatched:n,component:e,canvasView:t}){const o=n.guide.x===void 0?"x":"y",{guide:s,matched:r}=n,i=s.type,l=r.type,a=t.getElementPos(s.componentView.el).rect,c=t.getElementPos(r.componentView.el).rect;if(o==="x"){const d=a.height,u=c.top,p=c.top+c.height;let h=0;i==="t"?l==="t"?h=u-d:l==="b"?h=p-d:l==="y"&&(h=u-d-(u-p)/2):i==="b"?l==="t"?h=u-d*2:l==="b"?h=p-d*2:l==="y"&&(h=u-d*2-(u-p)/2):i==="y"&&(l==="t"?h=u-d*1.5:l==="b"?h=p-d*1.5:l==="y"&&(h=u-d*1.5-(u-p)/2)),e.addStyle({top:`${h-5}px`},{partial:!0})}if(o==="y"){const d=a.width,u=c.left,p=c.left+c.width;let h=0;i==="l"?l==="l"?h=u:l==="r"?h=p:l==="x"&&(h=u-(u-p)/2):i==="r"?l==="l"?h=u-d:l==="r"?h=p-d:l==="x"&&(h=u-d-(u-p)/2):i==="x"&&(l==="l"?h=u-d/2:l==="r"&&(h=p-d/2)),e.addStyle({left:`${h}px`},{partial:!0})}}function du({snapping:n,editor:e,props:t}){var P,O;const{command:o,guidesMatched:s}=t,r=t.component,i=r.getEl(),l=e.Canvas.getCanvasView(),{x:a,y:c}=n??{x:10,y:10},d=o.opts.event,u=d.clientX,p=d.clientY;if(!r.__lastSnappedPosition){const N=l.getElBoxRect(i),L=u-N.x,z=p-N.y;r.__lastSnappedPosition={left:N.x,top:N.y},r.__dragOffset={x:L,y:z}}const h=((P=r.__dragOffset)==null?void 0:P.x)||0,f=((O=r.__dragOffset)==null?void 0:O.y)||0,m=r.__lastSnappedPosition,g=u-m.left-h,b=p-m.top-f;let C=m.left,y=m.top;const S=s==null?void 0:s[0],v=(S==null?void 0:S.guide.type)==="l",w=(S==null?void 0:S.guide.type)==="x",x=(S==null?void 0:S.guide.type)==="r",T=(S==null?void 0:S.guide.type)==="t",k=(S==null?void 0:S.guide.type)==="b",M=(S==null?void 0:S.guide.type)==="y";if(S){const{x:N,y:L}=ps({guideMatched:S,canvasView:l}),z=i.offsetWidth,Z=i.offsetHeight;v?C=N:x?C=N-z:w?C=N-z/2:T?y=L:k?y=L-Z:M&&(y=L-Z/2),r.__lastSnappedGuideMatched=S}else Math.abs(g)>=a&&(C=Math.round((m.left+g)/a)*a,r.__lastSnappedGuideMatched=null),Math.abs(b)>=c&&(y=Math.round((m.top+b)/c)*c,r.__lastSnappedGuideMatched=null);return r.addStyle({left:`${C}px`,top:`${y}px`},{partial:!0}),r.__lastSnappedPosition={left:C,top:y},{x:C,y,guideMatched:r.__lastSnappedGuideMatched}}function Jy({snapping:n,props:e,editor:t}){const{x:o,y:s}=du({snapping:n,props:e,editor:t}),r=e.component;r.addStyle({left:`${o}px`,top:`${s}px`}),delete r.__lastSnappedPosition,delete r.__lastSnappedGuideMatched}const Zy="core:component-drag",Yy="studio:setDragAbsolute",Xy="dmode:start",uu="dmode:move",pu="dmode:end",fi="dragAbsolute",Qy="select",eb="hover",tb="spacing",nb=G(function(n,e={}){const{Commands:t}=n,o=t.events,s=t.getConfig().defaultOptions??{},r=`${o.runBeforeCommand}tlb-move`;s[Zy]={run:x=>({...x,skipGuidesRender:!0})};const{snapping:i,locking:l,globalAbsolute:a=!0}=e;a&&n.setDragMode("absolute");const c=!!(i!=null&&i.x||i!=null&&i.y),d=!!(l!=null&&l.x||l!=null&&l.y),{Canvas:u}=n;let p=null;const h=x=>{const{component:T,guidesMatched:k,command:M}=x,P=T.view,O=n.Canvas.getCanvasView(),N=T.getEl();let L=k.map(le=>le.matched.componentEl),z=k.map(le=>ps({guideMatched:le,canvasView:O}));if(c){const{guideMatched:le}=du({snapping:i,props:x,editor:n});le?(L=[le.matched.componentEl],z=[ps({guideMatched:le,canvasView:O})]):(L=[],z=[])}if(d)if(M.opts.event.shiftKey)if(!p)p=k[0];else{const Fe=p,J=Fe.guide.x===void 0?"x":"y";(J==="x"&&(l==null?void 0:l.x)||J==="y"&&(l==null?void 0:l.y))&&(Ky({guideMatched:Fe,component:T,canvasView:O}),L=[Fe.matched.componentEl],z=[ps({guideMatched:Fe,canvasView:O})])}else p=null;const Z={id:fi,type:fi,component:T,componentView:P,originComponent:N,matchedComponents:L,originMatchedDistances:z};u.addSpot(Z)},f=({enabled:x})=>{n.runCommand(Yy,{enabled:x})},m=({type:x})=>{u.removeSpots({type:x})},g=()=>{m({type:Qy}),m({type:eb}),m({type:tb})},b=x=>{f({enabled:!0}),h(x),g()},C=x=>{h(x),g()},y=x=>{m({type:fi}),c&&Jy({snapping:i,props:x,editor:n}),f({enabled:!1})},w=[[Xy,x=>{b(x),n.on(uu,C);const T=()=>{y(x),n.off(uu,C),n.off(pu,T)};n.on(pu,T)}],[r,x=>{if(a)return;const T=x.options.target,k=Uy(n,T,e);k!=null&&k.result&&!k.dmode&&(k.component.set({dmode:"absolute"}),x.options.mode="absolute")}]];w.forEach(([x,T])=>n.on(x,T)),W({editor:n,licenseKey:e.licenseKey,plan:qy,pluginName:jy,cleanup:()=>{f({enabled:!1}),w.forEach(([x,T])=>n.off(x,T))}})});H.accordionComponent=ah,H.animationComponent=Bh,H.canvasAbsoluteMode=nb,H.canvasEmptyState=$0,H.canvasFullSize=B0,H.canvasGridMode=ny,H.dataSourceEjs=Cy,H.dataSourceHandlebars=Py,H.dialogComponent=Nu,H.flexComponent=Ph,H.fsLightboxComponent=Ap,H.googleFontsAssetProvider=Wy,H.iconifyComponent=qu,H.layoutSidebarButtons=tu,H.lightGalleryComponent=Bp,H.listPagesComponent=kp,H.presetPrintable=uy,H.rteProseMirror=R0,H.rteTinyMce=Kh,H.swiperComponent=Qp,H.tableComponent=yp,H.youtubeAssetProvider=Ly,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
901
+ `}handleCommentStatement(e){return`<!--${e.value}-->`}handleElementNode(e){let t="";if(e.attributes)for(const s of e.attributes)s.value.type==="TextNode"?t+=` ${s.name}="${s.value.chars}"`:(this.addMessage("warning",`Complex attribute values not fully supported: ${s.name}`,e.loc),t+=` ${s.name}="${this.getExpressionString(s.value)}"`);let o="";if(e.children)for(const s of e.children)o+=this.astToGrapesJS(s);return`<${e.tag}${t}>${o}</${e.tag}>`}handleTextNode(e){return e.chars||""}handlePartialStatement(e){return this.addMessage("warning",`Partials are not fully supported: ${e.name.original}`,e.loc),`{{> ${e.name.original}}}`}handleGenericBlock(e){const t=this.handleProgram(e.program);return`<!-- Unsupported block: ${e.path.original} -->${t}`}getExpressionString(e){return e.type==="PathExpression"?e.original:e.type==="StringLiteral"?e.value:e.type==="NumberLiteral"?e.value.toString():e.type==="BooleanLiteral"?e.value?"true":"false":e.type==="SubExpression"?this.getExpressionString(e.params[0]):e.type==="Hash"?`{${e.pairs.map(o=>`${o.key}=${this.getExpressionString(o.value)}`).join(", ")}}`:(this.addMessage("warning",`Complex expression type not fully supported: ${e.type}`,e.loc),"")}addMessage(e,t,o){this.messages.push({type:e,message:t,location:o?{line:o.start.line,column:o.start.column}:void 0})}}const hi=n=>{if(n==null||n==="")return[];if(n===".")return["this"];if(n===".."||n==="../")return[".."];if(n.startsWith("../")){const i=n.substring(3);return["..",...hi(i)]}const e=[];let t=0,o=n.replace(/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,(i,l,a,c)=>{const d=a!==void 0?a:c||"";return e[t]=d,`__HANDLEBARS_PLACEHOLDER_${t++}__`});o=o.replace(/\//g,".");const s=o.split("."),r=[];for(const i of s){const l=/^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(i);if(l){const a=parseInt(l[1],10);r.push(e[a])}else i!==""&&r.push(i)}return r},Ey="dataSourceHandlebars",My=_.startup,Ay=j(function(n,e={}){const t=su(n,new ky),o=ru(n,{contains:"{{",importer:new Ty});q({editor:n,licenseKey:e.licenseKey,plan:My,pluginName:Ey,cleanup:()=>{t(),o()}})}),Py=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)},lu="youtube-video",Ny=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:o="high"}=n,s=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=Py(l);return`${c}?${d}`},r=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},i=l=>{const a=r(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,type:lu,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:[lu],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 h=await(await fetch(s(u))).json();return(m=h.items)!=null&&m.length?{items:h.items.map(i),nextPageCustomData:{token:h.nextPageToken},isLastPage:!h.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}}]})}},Oy={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},Iy="youtubeAssetProvider",Ry=_.startup,Dy=j(function(n,e){var c;const{skipVideoComponent:t,i18n:o={}}=e,s=Ny(e);n.runCommand(G.assetProviderAdd,{provider:s});const r="search-on-youtube",i="video",l=(c=n.Components.getType(i))==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(i,{model:{getYoutubeTraits(){const[d,...u]=l.getYoutubeTraits.apply(this);return[d,{id:r,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:Oy,...o}),q({editor:n,licenseKey:e.licenseKey,plan:Ry,pluginName:Iy,cleanup:()=>{n.runCommand(G.assetProviderRemove,{id:s.id}),!t&&l&&n.Components.addType(i,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==r)}}})}})}),so=n=>n.replaceAll('"',"").replaceAll("'",""),fi=n=>n.includes(",")?n:/\s/.test(n)?`'${so(n)}'`:so(n),au=(n,e,t)=>({family:n,variant:e,...t}),cu=(n,e)=>{n=fi(n);const{menuVariant:t,variants:o}=e;return{family:n,familyLabel:so(n),menuVariant:t&&au(fi(`menuFont-${so(n)}`),"regular",t),variants:Object.assign({},...Object.entries(o).map(([s,r])=>({[s]:au(n,s,r)})))}},du=(n,e)=>{var l;const t=cu(n.family,n),o=t.menuVariant??((l=Object.values(t.variants))==null?void 0:l[0]);if(!o)return"Arial, Helvetica, sans-serif";const{source:s,descriptors:r}=o,i=so(o.family);if(!e){const a=new FontFace(i,`url("${s}")`,r),c=Array.from(document.fonts.values()).filter(d=>d.family===i);for(const d of c)document.fonts.delete(d);document.fonts.add(a),a.load().catch(()=>{})}return fi(i)},Ly=n=>{const{family:e,menu:t,axes:o}=n,s=!!o,r=Object.assign({},...n.variants.map(i=>{var d,u;let l,a;if(s){const p=o.find(h=>h.tag==="wght");if(p){const{start:h,end:f}=p;l=`${h} ${f}`}}return l||(l=((d=i.match(/\d+/))==null?void 0:d[0])??"400"),a=((u=i.match(/[a-zA-Z]+/))==null?void 0:u[0])==="italic"?"italic":void 0,{[i]:{source:n.files[i],descriptors:{style:a,weight:l}}}}));return cu(e,{menuVariant:{source:t},variants:r})},$y=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:Ly(n),needsLoading:!0}}),zy=n=>{const{font:e}=n.customData;return n.customData.needsLoading?(n.customData.needsLoading=!1,du(e)):du(e,!0)};let ro;const By=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)},Vy=n=>{const{apiKey:e,searchParams:t}=n,o=(s={})=>{const r="https://www.googleapis.com/webfonts/v1/webfonts",i=By(s);return`${r}?${i}`};return{id:"google-fonts",types:["font"],label:({editor:s})=>s.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var c;if(ro)return ro;const s={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},r=t==null?void 0:t(),i={...s,...r},a=await(await fetch(o(i))).json();return(c=a.items)!=null&&c.length?(ro=a.items.map($y),ro):[]},itemLayout:s=>{const r=ro.find(l=>l.id===s.assetProps.id),i=zy(r);return{type:"column",onClick:()=>s.onSelect(r),htmlAttrs:{title:r.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}},{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"16px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},Hy={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},Fy="googleFontsAssetProvider",_y=_.startup,Gy=j(function(n,e){const{i18n:t={}}=e,o=Vy(e);n.runCommand(G.assetProviderAdd,{provider:o}),n.I18n.addMessages({en:Hy,...t}),q({editor:n,licenseKey:e.licenseKey,plan:_y,pluginName:Fy,cleanup:()=>{n.runCommand(G.assetProviderRemove,{id:o.id})}})}),Wy="canvasAbsoluteMode",jy=_.startup,qy=(n,e,t)=>{const o=t.enableAbsolute??(a=>a.hasAbsolute),r=(Array.isArray(e)?e:e?[e]:[...n.getSelectedAll()])[0];if(!r)return;const i=r.getEl();return{result:bt(o)?o({component:r,hasAbsolute:!!i&&getComputedStyle(i).position==="absolute"}):!1,component:r,dmode:r.get("dmode")}};function ps({guideMatched:n,canvasView:e}){var M;const t=n.guide.x===void 0?"y":"x";let o=0,s=0,r=0,i=0;const{guide:l,matched:a}=n,c=e.getElBoxRect(l.componentView.el),d=e.getElBoxRect(((M=a.componentView)==null?void 0:M.el)||a.componentEl),u=c.y,p=c.y+c.height,h=c.x,f=c.x+c.width,m=d.y,g=d.y+d.height,b=d.x,C=d.x+d.width,y=Math.max(0,u-g),S=Math.max(0,m-p),x=Math.max(0,h-C),w=Math.max(0,b-f),v=y>S,E=x>w,k=l.type;return t==="x"&&(k==="l"?(o=h,v?(s=g,r=y):(s=p,r=S)):k==="r"?(o=f,v?(s=g,r=y):(s=p,r=S)):k==="x"&&(o=h-(h-f)/2,v?(s=g,r=y):(s=p,r=S))),t==="y"&&(k==="t"?(s=u,E?(o=C,i=x):(o=f,i=w)):k==="b"?(s=p,E?(o=C,i=x):(o=f,i=w)):k==="y"&&(s=u-(u-p)/2,E?(o=C,i=x):(o=f,i=w))),{axis:t,x:o,y:s,width:i,height:r}}function Uy({guideMatched:n,component:e,canvasView:t}){const o=n.guide.x===void 0?"x":"y",{guide:s,matched:r}=n,i=s.type,l=r.type,a=t.getElementPos(s.componentView.el).rect,c=t.getElementPos(r.componentView.el).rect;if(o==="x"){const d=a.height,u=c.top,p=c.top+c.height;let h=0;i==="t"?l==="t"?h=u-d:l==="b"?h=p-d:l==="y"&&(h=u-d-(u-p)/2):i==="b"?l==="t"?h=u-d*2:l==="b"?h=p-d*2:l==="y"&&(h=u-d*2-(u-p)/2):i==="y"&&(l==="t"?h=u-d*1.5:l==="b"?h=p-d*1.5:l==="y"&&(h=u-d*1.5-(u-p)/2)),e.addStyle({top:`${h-5}px`},{partial:!0})}if(o==="y"){const d=a.width,u=c.left,p=c.left+c.width;let h=0;i==="l"?l==="l"?h=u:l==="r"?h=p:l==="x"&&(h=u-(u-p)/2):i==="r"?l==="l"?h=u-d:l==="r"?h=p-d:l==="x"&&(h=u-d-(u-p)/2):i==="x"&&(l==="l"?h=u-d/2:l==="r"&&(h=p-d/2)),e.addStyle({left:`${h}px`},{partial:!0})}}function uu({snapping:n,editor:e,props:t}){var P,N;const{command:o,guidesMatched:s}=t,r=t.component,i=r.getEl(),l=e.Canvas.getCanvasView(),{x:a,y:c}=n??{x:10,y:10},d=o.opts.event,u=d.clientX,p=d.clientY;if(!r.__lastSnappedPosition){const O=l.getElBoxRect(i),$=u-O.x,B=p-O.y;r.__lastSnappedPosition={left:O.x,top:O.y},r.__dragOffset={x:$,y:B}}const h=((P=r.__dragOffset)==null?void 0:P.x)||0,f=((N=r.__dragOffset)==null?void 0:N.y)||0,m=r.__lastSnappedPosition,g=u-m.left-h,b=p-m.top-f;let C=m.left,y=m.top;const S=s==null?void 0:s[0],x=(S==null?void 0:S.guide.type)==="l",w=(S==null?void 0:S.guide.type)==="x",v=(S==null?void 0:S.guide.type)==="r",E=(S==null?void 0:S.guide.type)==="t",k=(S==null?void 0:S.guide.type)==="b",M=(S==null?void 0:S.guide.type)==="y";if(S){const{x:O,y:$}=ps({guideMatched:S,canvasView:l}),B=i.offsetWidth,Q=i.offsetHeight;x?C=O:v?C=O-B:w?C=O-B/2:E?y=$:k?y=$-Q:M&&(y=$-Q/2),r.__lastSnappedGuideMatched=S}else Math.abs(g)>=a&&(C=Math.round((m.left+g)/a)*a,r.__lastSnappedGuideMatched=null),Math.abs(b)>=c&&(y=Math.round((m.top+b)/c)*c,r.__lastSnappedGuideMatched=null);return r.addStyle({left:`${C}px`,top:`${y}px`},{partial:!0}),r.__lastSnappedPosition={left:C,top:y},{x:C,y,guideMatched:r.__lastSnappedGuideMatched}}function Ky({snapping:n,props:e,editor:t}){const{x:o,y:s}=uu({snapping:n,props:e,editor:t}),r=e.component;r.addStyle({left:`${o}px`,top:`${s}px`}),delete r.__lastSnappedPosition,delete r.__lastSnappedGuideMatched}const Jy="core:component-drag",Zy="studio:setDragAbsolute",Yy="dmode:start",pu="dmode:move",hu="dmode:end",mi="dragAbsolute",Xy="select",Qy="hover",eb="spacing",tb=j(function(n,e={}){const{Commands:t}=n,o=t.events,s=t.getConfig().defaultOptions??{},r=`${o.runBeforeCommand}tlb-move`;s[Jy]={run:v=>({...v,skipGuidesRender:!0})};const{snapping:i,locking:l,globalAbsolute:a=!0}=e;a&&n.setDragMode("absolute");const c=!!(i!=null&&i.x||i!=null&&i.y),d=!!(l!=null&&l.x||l!=null&&l.y),{Canvas:u}=n;let p=null;const h=v=>{const{component:E,guidesMatched:k,command:M}=v,P=E.view,N=n.Canvas.getCanvasView(),O=E.getEl();let $=k.map(ae=>ae.matched.componentEl),B=k.map(ae=>ps({guideMatched:ae,canvasView:N}));if(c){const{guideMatched:ae}=uu({snapping:i,props:v,editor:n});ae?($=[ae.matched.componentEl],B=[ps({guideMatched:ae,canvasView:N})]):($=[],B=[])}if(d)if(M.opts.event.shiftKey)if(!p)p=k[0];else{const Fe=p,L=Fe.guide.x===void 0?"x":"y";(L==="x"&&(l==null?void 0:l.x)||L==="y"&&(l==null?void 0:l.y))&&(Uy({guideMatched:Fe,component:E,canvasView:N}),$=[Fe.matched.componentEl],B=[ps({guideMatched:Fe,canvasView:N})])}else p=null;const Q={id:mi,type:mi,component:E,componentView:P,originComponent:O,matchedComponents:$,originMatchedDistances:B};u.addSpot(Q)},f=({enabled:v})=>{n.runCommand(Zy,{enabled:v})},m=({type:v})=>{u.removeSpots({type:v})},g=()=>{m({type:Xy}),m({type:Qy}),m({type:eb})},b=v=>{f({enabled:!0}),h(v),g()},C=v=>{h(v),g()},y=v=>{m({type:mi}),c&&Ky({snapping:i,props:v,editor:n}),f({enabled:!1})},w=[[Yy,v=>{b(v),n.on(pu,C);const E=()=>{y(v),n.off(pu,C),n.off(hu,E)};n.on(hu,E)}],[r,v=>{if(a)return;const E=v.options.target,k=qy(n,E,e);k!=null&&k.result&&!k.dmode&&(k.component.set({dmode:"absolute"}),v.options.mode="absolute")}]];w.forEach(([v,E])=>n.on(v,E)),q({editor:n,licenseKey:e.licenseKey,plan:jy,pluginName:Wy,cleanup:()=>{f({enabled:!1}),w.forEach(([v,E])=>n.off(v,E))}})});F.accordionComponent=ah,F.animationComponent=Bh,F.canvasAbsoluteMode=tb,F.canvasEmptyState=$0,F.canvasFullSize=H0,F.canvasGridMode=sy,F.dataSourceEjs=wy,F.dataSourceHandlebars=Ay,F.dialogComponent=Ou,F.flexComponent=Ph,F.fsLightboxComponent=Ap,F.googleFontsAssetProvider=Gy,F.iconifyComponent=qu,F.layoutSidebarButtons=nu,F.lightGalleryComponent=Bp,F.listPagesComponent=kp,F.presetPrintable=hy,F.rteProseMirror=R0,F.rteTinyMce=Kh,F.swiperComponent=Qp,F.tableComponent=yp,F.youtubeAssetProvider=Dy,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});