@grapesjs/studio-sdk-plugins 1.0.38-rc.0 → 1.0.39-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/dist/accordionComponent/index.cjs.js +5 -5
  2. package/dist/accordionComponent/index.es.js +70 -67
  3. package/dist/accordionComponent/index.js +39 -0
  4. package/dist/accordionComponent/index.umd.js +4 -4
  5. package/dist/aiChat/components/AiChatHeader.d.ts +4 -5
  6. package/dist/aiChat/components/AiChatInput/index.d.ts +4 -5
  7. package/dist/aiChat/components/AiChatMessage.d.ts +7 -8
  8. package/dist/aiChat/components/index.d.ts +1 -1
  9. package/dist/aiChat/components/utils.d.ts +1 -1
  10. package/dist/aiChat/index.cjs.js +10 -376
  11. package/dist/aiChat/index.es.js +4569 -28851
  12. package/dist/aiChat/index.js +10 -376
  13. package/dist/aiChat/index.umd.js +11 -377
  14. package/dist/aiChat/server/index.cjs.d.ts +0 -1
  15. package/dist/aiChat/server/index.cjs.js +45 -45
  16. package/dist/aiChat/server/index.d.ts +0 -1
  17. package/dist/aiChat/server/index.es.d.ts +0 -1
  18. package/dist/aiChat/server/index.es.js +371 -427
  19. package/dist/aiChat/server/index.js +45 -45
  20. package/dist/aiChat/server/index.umd.js +41 -41
  21. package/dist/aiChat/server/stream.test.d.ts +1 -0
  22. package/dist/aiChat/types.d.ts +18 -4
  23. package/dist/aiChat/typesSchema.d.ts +13 -0
  24. package/dist/animationComponent/index.cjs.js +3 -3
  25. package/dist/animationComponent/index.es.js +49 -46
  26. package/dist/animationComponent/index.js +519 -0
  27. package/dist/animationComponent/index.umd.js +3 -3
  28. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  29. package/dist/canvasAbsoluteMode/index.es.js +115 -112
  30. package/dist/canvasAbsoluteMode/index.js +1 -0
  31. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  32. package/dist/canvasEmptyState/index.cjs.js +1 -1
  33. package/dist/canvasEmptyState/index.es.js +71 -68
  34. package/dist/canvasEmptyState/index.js +1 -0
  35. package/dist/canvasEmptyState/index.umd.js +1 -1
  36. package/dist/canvasFullSize/index.cjs.js +3 -3
  37. package/dist/canvasFullSize/index.es.js +69 -66
  38. package/dist/canvasFullSize/index.js +10 -0
  39. package/dist/canvasFullSize/index.umd.js +4 -4
  40. package/dist/canvasGridMode/index.cjs.js +7 -7
  41. package/dist/canvasGridMode/index.es.js +142 -139
  42. package/dist/canvasGridMode/index.js +26 -0
  43. package/dist/canvasGridMode/index.umd.js +7 -7
  44. package/dist/canvasScreenshot/index.cjs.js +1 -1
  45. package/dist/canvasScreenshot/index.es.js +78 -75
  46. package/dist/canvasScreenshot/index.js +1 -0
  47. package/dist/canvasScreenshot/index.umd.js +1 -1
  48. package/dist/dataSourceEjs/EjsExporter.d.ts +1 -1
  49. package/dist/dataSourceEjs/index.cjs.js +3 -3
  50. package/dist/dataSourceEjs/index.es.js +40 -37
  51. package/dist/dataSourceEjs/index.js +21 -0
  52. package/dist/dataSourceEjs/index.umd.js +3 -3
  53. package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +2 -2
  54. package/dist/dataSourceHandlebars/constants.d.ts +1 -1
  55. package/dist/dataSourceHandlebars/index.cjs.js +4 -4
  56. package/dist/dataSourceHandlebars/index.es.js +58 -55
  57. package/dist/dataSourceHandlebars/index.js +10 -0
  58. package/dist/dataSourceHandlebars/index.umd.js +2 -2
  59. package/dist/dialogComponent/index.cjs.js +11 -11
  60. package/dist/dialogComponent/index.es.js +72 -69
  61. package/dist/dialogComponent/index.js +59 -0
  62. package/dist/dialogComponent/index.umd.js +11 -11
  63. package/dist/flexComponent/index.cjs.js +6 -6
  64. package/dist/flexComponent/index.es.js +151 -142
  65. package/dist/flexComponent/index.js +33 -0
  66. package/dist/flexComponent/index.umd.js +8 -8
  67. package/dist/flexComponent/typesSchema.d.ts +1 -1
  68. package/dist/fsLightboxComponent/index.cjs.js +3 -3
  69. package/dist/fsLightboxComponent/index.es.js +93 -90
  70. package/dist/fsLightboxComponent/index.js +6 -0
  71. package/dist/fsLightboxComponent/index.umd.js +3 -3
  72. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  73. package/dist/googleFontsAssetProvider/index.es.js +112 -109
  74. package/dist/googleFontsAssetProvider/index.js +1 -0
  75. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  76. package/dist/googleFontsAssetProvider/utils.d.ts +1 -1
  77. package/dist/iconifyComponent/index.cjs.js +2 -2
  78. package/dist/iconifyComponent/index.es.js +80 -77
  79. package/dist/iconifyComponent/index.js +3 -0
  80. package/dist/iconifyComponent/index.umd.js +2 -2
  81. package/dist/index.cjs.d.ts +1 -0
  82. package/dist/index.cjs.js +970 -82
  83. package/dist/index.d.ts +1 -0
  84. package/dist/index.es.d.ts +1 -0
  85. package/dist/index.es.js +7422 -6145
  86. package/dist/index.umd.js +975 -87
  87. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  88. package/dist/layoutSidebarButtons/index.es.js +95 -92
  89. package/dist/layoutSidebarButtons/index.js +1 -0
  90. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  91. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  92. package/dist/lightGalleryComponent/index.es.js +164 -161
  93. package/dist/lightGalleryComponent/index.js +1 -0
  94. package/dist/lightGalleryComponent/index.umd.js +1 -1
  95. package/dist/lightGalleryComponent/utils.d.ts +1 -1
  96. package/dist/linkImageComponent/index.cjs.js +2 -2
  97. package/dist/linkImageComponent/index.es.js +60 -57
  98. package/dist/linkImageComponent/index.js +12 -0
  99. package/dist/linkImageComponent/index.umd.js +2 -2
  100. package/dist/listPagesComponent/index.cjs.js +4 -4
  101. package/dist/listPagesComponent/index.es.js +57 -54
  102. package/dist/listPagesComponent/index.js +11 -0
  103. package/dist/listPagesComponent/index.umd.js +4 -4
  104. package/dist/listPagesComponent/utils.d.ts +1 -1
  105. package/dist/presetBlockLibrary/blocks.d.ts +6 -0
  106. package/dist/presetBlockLibrary/blocks.test.d.ts +2 -0
  107. package/dist/presetBlockLibrary/emailBlocks.d.ts +53 -0
  108. package/dist/presetBlockLibrary/index.cjs.d.ts +3 -0
  109. package/dist/presetBlockLibrary/index.cjs.js +889 -0
  110. package/dist/presetBlockLibrary/index.d.ts +3 -0
  111. package/dist/presetBlockLibrary/index.es.d.ts +3 -0
  112. package/dist/presetBlockLibrary/index.es.js +1408 -0
  113. package/dist/presetBlockLibrary/index.js +889 -0
  114. package/dist/presetBlockLibrary/index.test.d.ts +1 -0
  115. package/dist/presetBlockLibrary/index.umd.js +889 -0
  116. package/dist/presetBlockLibrary/shared.d.ts +3 -0
  117. package/dist/presetBlockLibrary/types.d.ts +24 -0
  118. package/dist/presetBlockLibrary/typesSchema.d.ts +47 -0
  119. package/dist/presetPrintable/index.cjs.js +3 -3
  120. package/dist/presetPrintable/index.es.js +133 -130
  121. package/dist/presetPrintable/index.js +32 -0
  122. package/dist/presetPrintable/index.umd.js +4 -4
  123. package/dist/prosemirror/index.cjs.js +8 -8
  124. package/dist/prosemirror/index.es.js +552 -549
  125. package/dist/prosemirror/index.js +10 -0
  126. package/dist/prosemirror/index.umd.js +9 -9
  127. package/dist/prosemirror/toolbar.d.ts +2 -2
  128. package/dist/prosemirror/types.d.ts +5 -5
  129. package/dist/rendererReact/index.cjs.js +1 -1
  130. package/dist/rendererReact/index.es.js +137 -134
  131. package/dist/rendererReact/index.js +1 -1
  132. package/dist/rendererReact/index.umd.js +1 -1
  133. package/dist/rteTinyMce/index.cjs.js +2 -2
  134. package/dist/rteTinyMce/index.es.js +74 -71
  135. package/dist/rteTinyMce/index.js +104 -0
  136. package/dist/rteTinyMce/index.umd.js +2 -2
  137. package/dist/shapeDividerComponent/index.cjs.js +4 -4
  138. package/dist/shapeDividerComponent/index.es.js +91 -88
  139. package/dist/shapeDividerComponent/index.js +97 -0
  140. package/dist/shapeDividerComponent/index.umd.js +4 -4
  141. package/dist/swiperComponent/index.cjs.js +7 -7
  142. package/dist/swiperComponent/index.es.js +95 -92
  143. package/dist/swiperComponent/index.js +45 -0
  144. package/dist/swiperComponent/index.umd.js +5 -5
  145. package/dist/tableComponent/index.cjs.js +1 -1
  146. package/dist/tableComponent/index.es.js +181 -178
  147. package/dist/tableComponent/index.js +1 -0
  148. package/dist/tableComponent/index.umd.js +1 -1
  149. package/dist/tableComponent/types.d.ts +3 -3
  150. package/dist/types.d.ts +14 -14
  151. package/dist/utils.d.ts +3 -2
  152. package/dist/utilsDataSources.d.ts +1 -1
  153. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  154. package/dist/youtubeAssetProvider/index.es.js +90 -87
  155. package/dist/youtubeAssetProvider/index.js +1 -0
  156. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  157. package/package.json +182 -34
  158. package/dist/aiChat/server/models.d.ts +0 -15
package/dist/index.umd.js CHANGED
@@ -1,14 +1,14 @@
1
- (function(V,kn){typeof exports=="object"&&typeof module<"u"?kn(exports,require("handlebars/dist/cjs/handlebars")):typeof define=="function"&&define.amd?define(["exports","handlebars/dist/cjs/handlebars"],kn):(V=typeof globalThis<"u"?globalThis:V||self,kn(V.StudioSdkPlugins={},V.Handlebars))})(this,function(V,kn){"use strict";const Tr="app.grapesjs.com",Mr="app-stage.grapesjs.com",Ar=[Tr,"app2.grapesjs.com",Mr,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],Mp="license:check:end",Ap=()=>typeof window<"u",Ts=(n,e={})=>{const t=$p(n)?{id:n,src:n}:n;return new Promise((o,s)=>{var u,h;const{loadedScripts:i}=e,{id:r,src:l}=t,a=document.querySelector(`script[src="${l}"]`);if(a){if((u=e.onScript)==null||u.call(e,a),i&&!i.get(l)){a.addEventListener("load",()=>o(r)),a.addEventListener("error",()=>s(r));return}return o(r)}const c=window.define;window.define=void 0;const d=()=>{i==null||i.set(l,!0),window.define=c},p=document.createElement("script");p.src=l,p.onload=()=>{o(r),d()},p.onerror=()=>{s(r),d()},document.head.appendChild(p),(h=e.onScript)==null||h.call(e,p)})},Pp=n=>{const e=n.map(t=>Ts(t));return Promise.allSettled(e)},Np=async n=>{const e=window.define;window.define=void 0;const t=await Pp(n);return window.define=e,t},Op=({isDev:n,isStage:e,isPlatform:t})=>`${n?"":`https://${e?Mr:Tr}`}/${t?"platform-api":"api"}`,Ip=()=>{if(!Ap())return"";const{hostname:n}=window.location;if(n)return n;try{return window.parent.location.hostname||""}catch{return""}},Rp=()=>{const n=Ip();return!!n&&(Ar.includes(n)||Ar.some(e=>n.endsWith(e)))},Dp=n=>n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?"-":"")+e.toLowerCase()),Lp=n=>typeof n<"u",$p=n=>typeof n=="string";function xt(n){return typeof n=="function"}async function zp({path:n,baseApiUrl:e,method:t="GET",headers:o={},params:s,body:i}){const l=`${e||Op({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...o}};i&&(a.body=JSON.stringify(i));const c=s?new URLSearchParams(s).toString():"",d=c?`?${c}`:"",p=await fetch(`${l}${d}`,a);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var F=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(F||{}),Pr=(n=>(n.Info="info",n.Error="error",n.Success="success",n.Warning="warning",n))(Pr||{}),G=(n=>(n.toastAdd="studio:toastAdd",n.toastRemove="studio:toastRemove",n.dialogOpen="studio:dialogOpen",n.dialogClose="studio:dialogClose",n.dialogExportCode="studio:dialogExportCode",n.dialogImportCode="studio:dialogImportCode",n.openEditCode="studio:openEditCode",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.clearPage="studio:clearPage",n.projectFiles="studio:projectFiles",n.validateCode="studio:validateCode",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.layoutComponentAdd="studio:layoutComponentAdd",n.layoutComponentGet="studio:layoutComponentGet",n.layoutComponentRemove="studio:layoutComponentRemove",n.layoutComponentRender="studio:layoutComponentRender",n.getStateTheme="studio:getStateTheme",n.setStateTheme="studio:setStateTheme",n.settings="studio:settings",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||{}),Nr=(n=>(n.layoutToggleId="studio:layoutToggle:",n.toggleBlocksPanel="studio:toggleBlocksPanel",n.pageSettingsUpdate="studio:pageSettingsUpdate",n.toggleDataSourcesPreview="studio:toggleDataSourcesPreview",n))(Nr||{}),Or=(n=>(n.dark="dark",n.light="light",n.auto="auto",n))(Or||{}),Ir=(n=>(n.web="web",n.email="email",n.document="document",n.react="react",n))(Ir||{});const Rr={[F.free]:0,[F.startup]:10,[F.business]:20,[F.enterprise]:30};function Bp(n){const e=n;return e.init=t=>o=>n(o,t),e}const W=n=>Bp(n);async function j({editor:n,plan:e,pluginName:t,licenseKey:o,onLicenseCheckResponse:s,cleanup:i}){let r="",l;const a=p=>{console.warn("Cleanup plugin:",t,"Reason:",p),i()},c=(p={})=>{var g;const{error:u,sdkLicense:h}=p,f=(g=p.plan)==null?void 0:g.category;if(!(h||p.license)||u)a(u||"Invalid license");else if(f){const b=Rr[e],w=Rr[f];b>w&&a({pluginRequiredPlan:e,licensePlan:f})}};n.Commands.has(G.settings)&&(l=n.runCommand(G.settings),r=(l==null?void 0:l.baseUrl)||"");const d=p=>{s==null||s(p),p&&c(p)};if(!l){n.onReady(async()=>{if(!Rp())if(o){const p=await Hp({licenseKey:o,pluginName:t,baseApiUrl:r});d(p)}else a("The `licenseKey` option not provided")});return}if(l.licensePlan||l.licenseError){const p=Vp(l);d(p);return}n.on(Mp,p=>d(p))}const Vp=n=>({sdkLicense:n.license,license:n.license,error:n.licenseError,plan:n.licensePlan});async function Hp(n){const{licenseKey:e,pluginName:t,baseApiUrl:o}=n;try{return(await zp({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 fo=(n,e)=>{var t;return!!((t=n==null?void 0:n.hasAttribute)!=null&&t.call(n,e))},ot=(n,e)=>{var t;return!!((t=n==null?void 0:n.classList)!=null&&t.contains(e))},$e=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,Pe))===n},mo=(...n)=>e=>n.some(t=>e.is(t)),Ms=(...n)=>(e,t)=>n.some(o=>t.is(o)),Fp=(n,e={})=>{var i;const t={},o=[],s=[];for(const r in n){const{value:l,...a}=n[r];o.push({id:r,name:r,changeProp:!0,category:e.category,...a}),t[r]=l,!Lp(l)&&s.push(r);const{subTraits:c={}}=a;for(const d in a.subTraits)(i=c[d])==null||i.forEach(p=>{const u=p.id||p.name;t[u]=p.value})}return{propKeys:Object.keys(t),propsNoValues:s,props:t,traits:o}},_p=(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,()=>Dr(n,o)),Dr(n,o)}})},Dr=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},r=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(r);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},As=(n,e,t)=>{const{doc:o=document}=t,s=t.target||o.head,i=s.querySelector(`style[${n}]`)||o.createElement("style");i.setAttribute(n,"true"),i.innerHTML=e,!s.contains(i)&&s.appendChild(i)},Gp=(n,e)=>{e.forEach(t=>{const o=Dp(t);o!==t&&n.has(o)&&n.set({[t]:n.get(o),[o]:void 0})})},ke="gjs-plg-",go="data-gs-plg-",Pe="data-type-role",Lr=(...n)=>n.map(e=>`[data-gjs-type="${e}"]`).join(","),Wp="dialogComponent",jp=W(function(n,e={}){const{Blocks:t,Components:o}=n,{licenseKey:s}=e,i="gjs-plg-dialog",r="gjs-plg-dialog-overlay",l="gjs-plg-dialog-content",a="gjs-plg-dialog-close",c="gjs-plg-dialog-title",d="gjs-plg-dialog-body",p="gjs-plg-dialog-description",u="gjs-plg-dialog-placeholder";t.add(i,{label:"Dialog",media:`
1
+ (function(B,Mn){typeof exports=="object"&&typeof module<"u"?Mn(exports,require("handlebars/dist/cjs/handlebars.js")):typeof define=="function"&&define.amd?define(["exports","handlebars/dist/cjs/handlebars.js"],Mn):(B=typeof globalThis<"u"?globalThis:B||self,Mn(B.StudioSdkPlugins={},B.Handlebars))})(this,function(B,Mn){"use strict";const zs="app.grapesjs.com",Rs="app-stage.grapesjs.com",Ls=[zs,"app2.grapesjs.com",Rs,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],mu="license:check:end",gu=()=>typeof window<"u",$i=(n,e={})=>{const t=Tu(n)?{id:n,src:n}:n;return new Promise((o,i)=>{var u,f;const{loadedScripts:r}=e,{id:s,src:l}=t,a=document.querySelector(`script[src="${l}"]`);if(a){if((u=e.onScript)==null||u.call(e,a),r&&!r.get(l)){a.addEventListener("load",()=>o(s)),a.addEventListener("error",()=>i(s));return}return o(s)}const c=window.define;window.define=void 0;const d=()=>{r==null||r.set(l,!0),window.define=c},p=document.createElement("script");p.src=l,p.onload=()=>{o(s),d()},p.onerror=()=>{i(s),d()},document.head.appendChild(p),(f=e.onScript)==null||f.call(e,p)})},bu=(n,e={})=>{const t=n.map(o=>$i(o,e));return Promise.allSettled(t)},yu=async(n,e={})=>{const t=window.define;window.define=void 0;const o=await bu(n,e);return window.define=t,o},xu=({isDev:n,isStage:e,isPlatform:t})=>`${n?"":`https://${e?Rs:zs}`}/${t?"platform-api":"api"}`,vu=(n={})=>{const{width:e=300,height:t,text:o="IMAGE",bg:i="777",fg:r="white"}=n,s=t?`x${t}`:"";return`https://placehold.co/${e}${s}/${i}/${r}.png?text=${o}`},wu=()=>{if(!gu())return"";const{hostname:n}=window.location;if(n)return n;try{return window.parent.location.hostname||""}catch{return""}},Su=()=>{const n=wu();return!!n&&(Ls.includes(n)||Ls.some(e=>n.endsWith(e)))},Cu=n=>n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?"-":"")+e.toLowerCase()),ku=n=>typeof n<"u",Tu=n=>typeof n=="string";function Le(n){return typeof n=="function"}const Bs=n=>!!n.Components.getType("mjml");async function Eu({path:n,baseApiUrl:e,method:t="GET",headers:o={},params:i,body:r}){const l=`${e||xu({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...o}};r&&(a.body=JSON.stringify(r));const c=i?new URLSearchParams(i).toString():"",d=c?`?${c}`:"",p=await fetch(`${l}${d}`,a);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var F=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(F||{}),Vs=(n=>(n.Info="info",n.Error="error",n.Success="success",n.Warning="warning",n))(Vs||{}),W=(n=>(n.toastAdd="studio:toastAdd",n.toastRemove="studio:toastRemove",n.dialogOpen="studio:dialogOpen",n.dialogClose="studio:dialogClose",n.dialogExportCode="studio:dialogExportCode",n.dialogImportCode="studio:dialogImportCode",n.openEditCode="studio:openEditCode",n.openBlocks="studio:openBlocks",n.appendComponent="studio:appendComponent",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.clearPage="studio:clearPage",n.projectFiles="studio:projectFiles",n.validateCode="studio:validateCode",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.layoutComponentAdd="studio:layoutComponentAdd",n.layoutComponentGet="studio:layoutComponentGet",n.layoutComponentRemove="studio:layoutComponentRemove",n.layoutComponentRender="studio:layoutComponentRender",n.getStateTheme="studio:getStateTheme",n.setStateTheme="studio:setStateTheme",n.settings="studio:settings",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))(W||{}),Hs=(n=>(n.layoutToggleId="studio:layoutToggle:",n.toggleBlocksPanel="studio:toggleBlocksPanel",n.pageSettingsUpdate="studio:pageSettingsUpdate",n.toggleDataSourcesPreview="studio:toggleDataSourcesPreview",n))(Hs||{}),Fs=(n=>(n.dark="dark",n.light="light",n.auto="auto",n))(Fs||{}),_s=(n=>(n.web="web",n.email="email",n.document="document",n.react="react",n))(_s||{});const Gs={[F.free]:0,[F.startup]:10,[F.business]:20,[F.enterprise]:30};function Mu(n,e){const t=n;return t.init=o=>{const i=r=>n(r,o);return e&&(i.__gjsPluginId=e),i},t}const q=(n,e)=>Mu(n,e);async function U({editor:n,plan:e,pluginName:t,licenseKey:o,onLicenseCheckResponse:i,cleanup:r}){let s="",l;const a=p=>{console.warn("Cleanup plugin:",t,"Reason:",p),r(n,t)},c=(p={})=>{var b;const{error:u,sdkLicense:f}=p,h=(b=p.plan)==null?void 0:b.category;if(!(f||p.license)||u)a(u||"Invalid license");else if(h){const x=Gs[e],C=Gs[h];x>C&&a({pluginRequiredPlan:e,licensePlan:h})}};n.Commands.has(W.settings)&&(l=n.runCommand(W.settings),s=(l==null?void 0:l.baseUrl)||"");const d=p=>{i==null||i(p),p&&c(p)};if(!l){n.onReady(async()=>{if(!Su())if(o){const p=await ju({licenseKey:o,pluginName:t,baseApiUrl:s});d(p)}else a("The `licenseKey` option not provided")});return}if(l.licensePlan||l.licenseError){const p=Au(l);d(p);return}n.on(mu,p=>d(p))}const Au=n=>({sdkLicense:n.license,license:n.license,error:n.licenseError,plan:n.licensePlan});async function ju(n){const{licenseKey:e,pluginName:t,baseApiUrl:o}=n;try{return(await Eu({baseApiUrl:o,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const yo=(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))},Be=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,Pe))===n},xo=(...n)=>e=>n.some(t=>e.is(t)),Pi=(...n)=>(e,t)=>n.some(o=>t.is(o)),$u=(n,e)=>n.onReady(()=>n.Plugins.remove(e)),Pu=(n,e={})=>{var r;const t={},o=[],i=[];for(const s in n){const{value:l,...a}=n[s];o.push({id:s,name:s,changeProp:!0,category:e.category,...a}),t[s]=l,!ku(l)&&i.push(s);const{subTraits:c={}}=a;for(const d in a.subTraits)(r=c[d])==null||r.forEach(p=>{const u=p.id||p.name;t[u]=p.value})}return{propKeys:Object.keys(t),propsNoValues:i,props:t,traits:o}},Nu=(n,e)=>{e.forEach(t=>{if(t.subTraits){const o=`${t.id||t.name}`,i=t.changeProp?`change:${o}`:`change:attributes:${o}`;n.on(i,()=>Ws(n,o)),Ws(n,o)}})},Ws=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),i=t.get("subTraits")||{},s=(Object.values(i).flat()||[]).map(c=>c.id||c.name);n.removeTrait(s);const l=i[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},Ni=(n,e,t)=>{const{doc:o=document}=t,i=t.target||o.head,r=i.querySelector(`style[${n}]`)||o.createElement("style");r.setAttribute(n,"true"),r.innerHTML=e,!i.contains(r)&&i.appendChild(r)},Ou=(n,e)=>{e.forEach(t=>{const o=Cu(t);o!==t&&n.has(o)&&n.set({[t]:n.get(o),[o]:void 0})})},Ee="gjs-plg-",vo="data-gs-plg-",Pe="data-type-role",qs=(...n)=>n.map(e=>`[data-gjs-type="${e}"]`).join(","),Us="dialogComponent",Iu=q(function(n,e={}){const{Blocks:t,Components:o}=n,{licenseKey:i}=e,r="gjs-plg-dialog",s="gjs-plg-dialog-overlay",l="gjs-plg-dialog-content",a="gjs-plg-dialog-close",c="gjs-plg-dialog-title",d="gjs-plg-dialog-body",p="gjs-plg-dialog-description",u="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:i},activate:!0,...e.block}),o.addType(i,{model:{defaults:{tagName:"div",attributes:{class:i,"data-type-role":i},components:[{type:r},{type:u}],draggable:Lr("wrapper"),droppable:Lr(i),styles:`
6
- .${i} {
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:s},{type:u}],draggable:qs("wrapper"),droppable:qs(r),styles:`
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(v){const C=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),S=m.querySelector('[data-type-role="gjs-plg-dialog-close"]');function x(){C.style.display="none"}v?(m._onCloseWhenPressingX=x,S.addEventListener("click",m._onCloseWhenPressingX)):(S.removeEventListener("click",m._onCloseWhenPressingX),m._onCloseWhenPressingX=null)}function b(v){const C=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function S(x){x.key==="Escape"&&(C.style.display="none")}v?(m._onCloseWhenPressingEsc=S,m.addEventListener("keydown",m._onCloseWhenPressingEsc)):(m.removeEventListener("keydown",m._onCloseWhenPressingEsc),m._onCloseWhenPressingEsc=null)}function w(v){const C=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function S(){C.style.display="flex"}v?(m._onOpenWhenLeavingWindow=S,document.addEventListener("mouseleave",m._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",m._onOpenWhenLeavingWindow),m._onOpenWhenLeavingWindow=null)}function y(v){const C=m.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function S(){const x=document.documentElement.scrollTop;v&&x>=Number(v)&&(C.style.display="flex")}v?(m._onOpenWhenScrollingToLevel=S,document.addEventListener("scroll",m._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",m._onOpenWhenScrollingToLevel),m._onOpenWhenScrollingToLevel=null)}g(f.closeWhenPressingX),b(f.closeWhenPressingEsc),w(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(r,{model:{defaults:{tagName:"div",attributes:{class:r,"data-type-role":r},components:{type:l},droppable:!1,draggable:!1,styles:`
11
- .${r} {
10
+ `,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(h){var g;(g=h.getSelected())==null||g.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(h){const g=this;function b(v){const k=g.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),w=g.querySelector('[data-type-role="gjs-plg-dialog-close"]');function S(){k.style.display="none"}v?(g._onCloseWhenPressingX=S,w.addEventListener("click",g._onCloseWhenPressingX)):(w.removeEventListener("click",g._onCloseWhenPressingX),g._onCloseWhenPressingX=null)}function x(v){const k=g.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function w(S){S.key==="Escape"&&(k.style.display="none")}v?(g._onCloseWhenPressingEsc=w,g.addEventListener("keydown",g._onCloseWhenPressingEsc)):(g.removeEventListener("keydown",g._onCloseWhenPressingEsc),g._onCloseWhenPressingEsc=null)}function C(v){const k=g.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function w(){k.style.display="flex"}v?(g._onOpenWhenLeavingWindow=w,document.addEventListener("mouseleave",g._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",g._onOpenWhenLeavingWindow),g._onOpenWhenLeavingWindow=null)}function y(v){const k=g.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function w(){const S=document.documentElement.scrollTop;v&&S>=Number(v)&&(k.style.display="flex")}v?(g._onOpenWhenScrollingToLevel=w,document.addEventListener("scroll",g._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",g._onOpenWhenScrollingToLevel),g._onOpenWhenScrollingToLevel=null)}b(h.closeWhenPressingX),x(h.closeWhenPressingEsc),C(h.openWhenLeavingWindow),y(h.openWhenScrollingToLevel)}},init(){this.on("active",this.handleOpenWhenClickPlaceholder)},handleOpenWhenClickPlaceholder(){this.view.el.querySelector('[data-type-role="gjs-plg-dialog-placeholder"]').addEventListener("click",()=>{const g=this.view.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');g.style.display="flex"})}},view:{onActive(){const h=this.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');h.style.display="flex"}}}),o.addType(s,{model:{defaults:{tagName:"div",attributes:{class:s,"data-type-role":s},components:{type:l},droppable:!1,draggable:!1,styles:`
11
+ .${s} {
12
12
  position: fixed;
13
13
  top: 0;
14
14
  left: 0;
@@ -56,24 +56,24 @@
56
56
  .${p} {
57
57
  margin: 0;
58
58
  }
59
- `}}}),o.addType(u,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:u,"data-type-role":u},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){const{em: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=""})}}}),j({editor:n,licenseKey:s,plan:F.startup,pluginName:Wp,cleanup:()=>{t.remove(i),o.removeType(i)}})}),qp="iconifyComponent",Up=F.startup,Kp={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},Ps=`<svg viewBox="0 0 24 24">
59
+ `}}}),o.addType(u,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:u,"data-type-role":u},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){const{em:h,el:g}=this,b="core:preview",x=h.Commands.events;this.listenTo(h,`${x.runCommand}${b}`,()=>{g.style.display="none"}),this.listenTo(h,`${x.stopCommand}${b}`,()=>{g.style.display=""})}}}),U({editor:n,licenseKey:i,plan:F.startup,pluginName:Us,cleanup:()=>{t.remove(r),o.removeType(r)}})},Us),Ks="iconifyComponent",Du=F.startup,zu={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},Oi=`<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>`,$r="layout-icon-picker",Jp="icons-layout-",zr="icons-list-layout",Br="gs-iconify-picker",Ns="__iconify_collection",Zp="https://api.iconify.design",Os=new Map;let yo;const Yp=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function Vr({collectionId:n,editor:e}){try{if(Os.has(n))return Os.get(n);const t=await fetch(Yp({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const o=await t.json();return Os.set(n,o),o}catch(t){console.error("Error fetching collection",t),e.runCommand(G.toastAdd,ou());return}}async function Xp({collectionIds:n,editor:e}){try{if(yo)return yo;const t=n?`?prefixes=${n.join(",")}`:"",o=await fetch(`${Zp}/collections${t}`);if(!o.ok)throw new Error(`Failed to fetch collections: ${o.statusText}`);return yo=await o.json(),yo}catch(t){console.error("Error fetching collections",t),e.runCommand(G.toastAdd,_r());return}}function Hr(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function Qp({collectionIds:n,editor:e,component:t}){const o=await Xp({collectionIds:n,editor:e});if(!o)return;const s=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},i=Object.entries(o).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),r=t.get("collectionId")??i[0].id;e.runCommand(G.layoutToggle,{id:$r,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[tu({collectionsList:i,collectionId:r,editor:e,handleClick:s}),{id:zr,type:"column",grow:!0}]}});const l=await Vr({collectionId:r,editor:e});l&&(Fr({editor:e,collection:l}),Is({editor:e,collection:l,handleClick:s,collectionId:r}))}function Fr({editor:n,collection:e}){n.em.set(Ns,e)}function eu(n){return n.em.get(Ns)}function Is(n){const{editor:e}=n;e.runCommand(G.layoutUpdate,{id:Jp,layout:nu(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:zr}})}function tu(n){const{collectionsList:e,collectionId:t,editor:o,handleClick:s}=n,i=e.map(({id:r,name:l,total:a})=>({id:r,label:`${l} (${a})`})).sort((r,l)=>r.label.localeCompare(l.label));return{type:"column",style:{gap:10},className:`${Br}__header`,children:[{type:"selectField",value:t,options:i,emptyState:"Select an icon collection",onChange:async({setState:r,value:l})=>{const a=await Vr({collectionId:l,editor:o});a&&(r({value:l}),Fr({editor:o,collection:a}),Is({editor:o,collection:a,handleClick:s,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${Ns}`]:({setState:r})=>r({value:""})},onInput:({setState:r,value:l,editor:a})=>{const c=eu(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([p])=>p.includes(l)));r({value:l}),Is({editor:a,collection:c,handleClick:s,collectionId:t,collectionFiltered:{...c,icons:d}})}}]}}function nu({collection:n,collectionFiltered:e,handleClick:t}){const{height:o=24,width:s=24,icons:i,prefix:r}=e||n,l=Object.entries(i).map(([a,c])=>({name:a,...c}),{});return{type:"column",className:`${Br}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>({type:"custom",render:c=>{const{editor:d,addEl:p,removeEl:u}=c,h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.setAttribute("xmlns","http://www.w3.org/2000/svg"),h.innerHTML=a.body;const f=a.width||s,m=a.height||o;h.setAttribute("viewBox",`0 0 ${f} ${m}`),h.style.cssText="width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";const g=[["click",()=>{const b=h.cloneNode(!0);b.removeAttribute("style");const w=b.outerHTML;t({icon:w,collectionId:r,iconId:a.name}),d==null||d.runCommand(G.layoutRemove,{id:$r})}],["pointerover",()=>{h.style.border="2px solid currentColor",h.style.padding="4px"}],["pointerout",()=>{h.style.border="",h.style.padding=""}]];return g.forEach(([b,w])=>h.addEventListener(b,w)),p(h),()=>{g.forEach(([b,w])=>h.removeEventListener(b,w)),u(h)}}})}}}function _r(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:Pr.Error}}function ou(){return{..._r(),id:"toast-error-getCollection",content:"Error fetching collection"}}const su=W(function(n,e={}){var h;const{Components:t,Blocks:o}=n,{collections:s,extendIconComponent:i=!0,licenseKey:r,block:l={}}=e,a="icon",c="iconify",d="Iconify",p="data-type-iconify",u={events:()=>({dblclick:"onActive"}),onActive(){Qp({collectionIds:s,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:Ps,content:{type:c},category:"Extra",activate:!0,...l},isComponent:f=>fo(f,p),model:{defaults:{name:d,icon:Ps,droppable:!1,attributes:{[p]:!0},resizable:Kp,components:Ps,style:{width:"50px",height:"50px"},traits:[Hr()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:u}),i){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,Hr(),...b]}},view:u})}j({editor:n,licenseKey:r,plan:Up,pluginName:qp,cleanup:()=>{o.remove(c),t.removeType(c)}})});function En(n,e,t){let o,s,i,r,l;const a=e===void 0?100:e;function c(){const p=Date.now()-r;p<a&&p>=0?o=setTimeout(c,a-p):(o=null,l=n.apply(i,s),i=s=null)}const d=function(){return i=this,s=arguments,r=Date.now(),o||(o=setTimeout(c,a)),l};return d.clear=function(){o&&(clearTimeout(o),o=null)},d.flush=function(){o&&(l=n.apply(i,s),i=s=null,clearTimeout(o),o=null)},d}const iu="tableComponent",ru=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 z={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>'},ze="table",Gr="thead",Wr="tfoot",Rs="tbody",fe="row",q="cell",Ds="clipboardTable",lu=[ze,Gr,Wr,Rs,fe,q],bo=n=>n.em.get(Ds)||[],au=n=>n.every(e=>e.is(q)),Ls=(n,e)=>{const{editor:t,event:o,opts:s}=n,i=o.currentTarget||o.target,{x:r,y:l,width:a,height:c}=i.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:r,y:l,w:a,h:c},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...e};xt(s.openSettings)?s.openSettings({...n,layoutProps:d}):t.runCommand(G.layoutToggle,d)},cu=(n,{rows:e=1,cells:t=5,text:o}={})=>({type:n,components:Array.from(Array(e).keys()).map(s=>({type:fe,components:Array.from(Array(t).keys()).map(i=>({type:q,components:o?{type:"text",content:xt(o)?o({y:s,x:i}):o}:void 0}))}))}),jr="Table settings",qr=n=>{const{component:e}=n;return e.is(ze)?e:e.closestType(ze)},du=n=>{var e;(e=qr(n))==null||e.remove(n.opts)},pu=n=>{const e=qr(n);e&&(n.editor.select(e),Ls(n,{id:"tableSettings",header:{label:jr}}))},Ur=n=>[{id:I.table,icon:z[I.table],label:"Table",items:[{id:I.tableSettings,label:jr,icon:z[I.tableSettings],onClick:({event:t})=>pu({...n,event:t})},{id:I.tableDelete,label:"Delete table",icon:z[I.tableDelete],onClick:()=>du(n)}]}],Kr=({editor:n})=>{const e=bo(n);return e.length&&au(e)},Jr=({component:n,editor:e,after:t})=>{if(!n.is(q))return;const o=n.closestType(ze),s=n.closestType(fe),i=n.index()+(t?1:0);o==null||o.findType(fe).forEach(l=>l.append({type:q},{at:i}));const r=s==null?void 0:s.components().at(i);r&&e.select(r)},Zr=({component:n,opts:e})=>{if(!n.is(q))return;const t=n.closestType(ze),o=n.index();t==null||t.findType(fe).forEach(s=>{var i;return(i=s.components().at(o))==null?void 0:i.remove(e)})},Yr=({component:n,editor:e})=>{if(!n.is(q))return;const t=n.closestType(ze),o=n.index(),s=(t==null?void 0:t.findType(fe).map(i=>i.components().at(o)))||[];s.length&&e.em.set(Ds,s)},Xr=n=>{const{component:e,editor:t,after:o}=n;if(!e.is(q)||!Kr(n))return;const s=bo(t),i=e.closestType(ze),r=e.index()+(o?1:0);i==null||i.findType(fe).forEach((l,a)=>{const c=s[a],d=(c==null?void 0:c.clone())||{type:q};l.append(d,{at:r})})},uu=n=>{const{component:e}=n;e.is(q)&&(Yr(n),Zr({...n,opts:{temporary:!0}}))},hu=n=>{const e=Kr(n);return[{id:I.tableColumnItems,icon:z[I.tableColumn],label:"Column",items:[{id:I.tableColumnInsertBefore,label:"Insert column before",icon:z[I.tableColumnInsertBefore],onClick:()=>Jr(n)},{id:I.tableColumnInsertAfter,label:"Insert column after",icon:z[I.tableColumnInsertAfter],onClick:()=>Jr({...n,after:!0})},{id:I.tableColumnDelete,label:"Delete column",icon:z[I.tableColumnDelete],onClick:()=>Zr(n)},{id:I.tableColumnCut,label:"Cut column",icon:z[I.tableColumnCut],onClick:()=>uu(n)},{id:I.tableColumnCopy,label:"Copy column",icon:z[I.tableColumnCopy],onClick:()=>Yr(n)},{id:I.tableColumnPasteBefore,label:"Paste column before",icon:z[I.tableColumnPasteBefore],disabled:!e,onClick:()=>Xr(n)},{id:I.tableColumnPasteAfter,label:"Paste column after",icon:z[I.tableColumnPasteAfter],disabled:!e,onClick:()=>Xr({...n,after:!0})}]}]},Qr="Row settings",fu=n=>n.every(e=>e.is(fe)),qt=n=>{const{component:e}=n,t=e.is(q),o=e.is(fe);if(!(!t&&!o))return o?e:e.closestType(fe)},el=n=>{const{component:e,editor:t,after:o}=n,s=qt(n);if(!s)return;const i=s.index()+(o?1:0),r=s.components().length,l=Array.from(Array(r).keys()).map(()=>({type:q})),a=s.parent();if(a){const c=a.append({type:fe,components:l},{at:i})[0];if(e.is(q)&&c){const d=e.index(),p=c.components().at(d);p&&t.select(p)}}},tl=n=>{var e;(e=qt(n))==null||e.remove(n.opts)},nl=n=>{const e=qt(n);e&&n.editor.em.set(Ds,[e])},ol=n=>{var l;const{editor:e,after:t}=n,o=qt(n);if(!o||!sl(n))return;const i=bo(e)[0],r=o.index()+(t?1:0);i&&((l=o.parent())==null||l.append(i.clone(),{at:r}))},mu=n=>{qt(n)&&(nl(n),tl({...n,opts:{temporary:!0}}))},sl=({editor:n})=>{const e=bo(n);return e.length&&fu(e)},gu=n=>{const e=qt(n);e&&(n.editor.select(e),Ls(n,{id:"tableRowSettings",header:{label:Qr}}))},il=n=>{const e=sl(n);return[{id:I.tableRowItems,icon:z[I.tableRowProperties],label:"Row",items:[{id:I.tableRowInsertBefore,label:"Insert row before",icon:z[I.tableRowInsertBefore],onClick:()=>el(n)},{id:I.tableRowInsertAfter,label:"Insert row after",icon:z[I.tableRowInsertAfter],onClick:()=>el({...n,after:!0})},{id:I.tableRowDelete,label:"Delete row",icon:z[I.tableRowDelete],onClick:()=>tl(n)},{id:I.tableRowProperties,label:Qr,icon:z[I.tableRowProperties],onClick:({event:o})=>gu({...n,event:o})},{id:I.tableRowCut,label:"Cut row",icon:z[I.tableRowCut],onClick:()=>mu(n)},{id:I.tableRowCopy,label:"Copy row",icon:z[I.tableRowCopy],onClick:()=>nl(n)},{id:I.tableRowPasteBefore,label:"Paste row before",icon:z[I.tableRowPasteBefore],disabled:!e,onClick:()=>ol(n)},{id:I.tableRowPasteAfter,label:"Paste row after",icon:z[I.tableRowPasteAfter],disabled:!e,onClick:()=>ol({...n,after:!0})}]},...Ur(n)]},$s=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),o=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:o}};function rl(n){const e=[];return n.components().forEach((t,o)=>{t.components().each((s,i)=>{const{rowspan:r,colspan:l}=$s(s);if(e[o])for(;e[o][i];)i++;for(let a=o;a<o+r;a++){e[a]||(e[a]=[]);for(let c=i;c<i+l;c++)e[a][c]={real:a===o&&c===i,cell:s,rowspan:r,colspan:l}}})}),e}function Ut(n,e,t){var o;return(o=n[t])==null?void 0:o[e]}const zs=n=>n.closestType(fe);function yu(n,{x:e,y:t,rows:o,cols:s}){var l;let i=zs(n[t][e].cell),r;for(let a=1;a<=o;a++)if(i=(l=i==null?void 0:i.parent())==null?void 0:l.components().at(i.index()+1),i){for(r=e;r>=0;r--){const{cell:c}=n[t+a][r],d=zs(c);if(d===i){for(let p=1;p<=s;p++){const u=c.index();d.append({type:q},{at:u+1})}break}}if(r===-1){const d=i.components().at(0).index();for(let p=1;p<=s;p++)i.append({type:q},{at:d})}}}function ll(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const s=n[e][t].cell;if(s.em.selected.hasComponent(s)){const{rowspan:i,colspan:r}=$s(s);if(r>1||i>1){s.addAttributes({colspan:1,rowspan:1});for(let l=0;l<r-1;l++){const a=s.index();zs(s).append({type:q},{at:a+1})}yu(n,{x:t,y:e,rows:i-1,cols:r})}}}}function bu(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const vo=(n,e={})=>{var r;const t=rl(n),{em:o}=n;let s,i;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((r=e.selected)!=null&&r.includes(c.cell)||o.selected.hasComponent(c.cell)){const d={x:a,y:l};s||(s=d),i=d}}return{grid:t,startPos:s,endPos:i}};function vu(n,e={}){const t=vo(n),{startPos:o,endPos:s}=t;let{grid:i}=t;const{em:r}=n;if(!o||!s)return;const l=o.x,a=o.y,c=s.x,d=s.y,p=Ut(i,l,a),u=Ut(i,c,d);if(p&&u){ll(i),i=rl(n);const h=[],f=Ut(i,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=Ut(i,g,m);if(!b)continue;const{cell:w}=b;w!==f&&h.push(w)}h.forEach(m=>{e.mergeContent&&f.append(m.components().models),m.remove()}),r.setSelected(f),bu(n)}}const al="Cell settings",Su="Merge cells",xu="Split cell",wu=n=>n.closestType(fe),Kt=n=>{var e;return(e=wu(n))==null?void 0:e.parent()},Cu=n=>{const e=n.editor.getSelectedAll(),t=Kt(e[0]),o=e[0];if(!t||!(o!=null&&o.is(q))||e.length>1)return!1;const{rowspan:s,colspan:i}=$s(o);return!(i<2&&s<2)},ku=n=>{const t=n.editor.getSelectedAll()[0],o=Kt(t),{grid:s}=vo(o);ll(s)},cl=n=>{const e=n.editor.getSelectedAll(),t=Kt(e[0]);if(!t||e.length<2||e.some(l=>!l.is(q)||Kt(l)!==t))return!1;const{grid:o,startPos:s,endPos:i}=vo(t),{em:r}=t;if(!s||!i)return!1;for(let l=s.y;l<=i.y;l++)for(let a=s.x;a<=i.x;a++){const c=Ut(o,a,l);if(!c||!r.selected.hasComponent(c.cell))return!1}return!0},Eu=n=>{const{editor:e}=n;if(!cl(n))return;const t=e.getSelectedAll(),o=Kt(t[0]);vu(o,{mergeContent:!0})},Tu=n=>{Ls(n,{id:"tableCellSettings",header:{label:al}})},Mu=n=>[{id:I.tableCellItems,icon:z[I.tableCellProperties],label:"Cell",items:[{id:I.tableCellProperties,label:al,icon:z[I.tableCellProperties],onClick:({event:t})=>Tu({...n,event:t})},{id:I.tableCellMerge,label:Su,icon:z[I.tableCellMerge],onClick:()=>Eu(n),disabled:!cl(n)},{id:I.tableCellSplit,label:xu,icon:z[I.tableCellSplit],onClick:()=>ku(n),disabled:!Cu(n)}]},...hu(n),...il(n)],Au=n=>{const e=n[0]&&Kt(n[0]);if(!e)return;const{grid:t,startPos:o,endPos:s}=vo(e,{selected:n});if(!o||!s)return;const i=[];for(let r=o.y;r<=s.y;r++)for(let l=o.x;l<=s.x;l++){const a=Ut(t,l,r);a&&i.push(a.cell)}i.length&&e.em.setSelected(i,{fromCell:!0})},Pu=W(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(ze,{block:t.block&&{label:"Table",media:z.table,category:"Extra",content:{type:ze,style:{width:"100%"}},select:!0,...t.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:z.table,stylable:["width","height","margin","font-family","font-size","font-weight","line-height","text-align","background","background-color","border-width","border-style","border-color"],traits:[{type:"number",min:0,name:"cellspacing",label:"Cell spacing"},{type:"number",min:0,name:"cellpadding",label:"Cell padding"},{id:"tableCaption",type:"checkbox",label:"Caption",setValue({component:r,value:l,emitUpdate:a}){const c=r.find("caption")[0];l?!c&&r.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):c==null||c.remove(),a(),n.refresh({tools:!0})},getValue(r){return!!r.component.find("caption")[0]}}],components:cu(Rs,{rows:5}),contextMenu:({items:r,editor:l,component:a})=>[...Ur({editor:l,component:a,opts:t}),...r]}}}),o.addType(Gr,{model:{defaults:{icon:z.tableHead,...s}}}),o.addType(Wr,{model:{defaults:{icon:z.tableFoot,...s}}}),o.addType(Rs,{model:{defaults:{icon:z.tableRowProperties,...s}}}),o.addType(fe,{model:{defaults:{icon:z.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:r,editor:l,component:a})=>[...il({editor:l,component:a,opts:t}),...r]}}}),o.addType(q,{model:{defaults:{icon:z.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background","background-color","text-align","vertical-align","border-width","border-style","border-color"],traits:[{id:"tableCellType",type:"select",options:[{value:"td",name:"Cell"},{value:"th",name:"Header Cell"}],label:"Cell type",name:"tagName",changeProp:!0},{id:"tableCellScope",type:"select",options:[{value:!1,name:"None"},{value:"row",name:"Row"},{value:"col",name:"Column"},{value:"rowgroup",name:"Row group"},{value:"colgroup",name:"Column group"}],label:"Scope",name:"scope"}],contextMenu:({items:r,editor:l,component:a})=>[...Mu({editor:l,component:a,opts:t}),...r]}}});const i=En((r,l)=>{var p;const a=n.getSelectedAll(),c=!!((p=l==null?void 0:l.event)!=null&&p.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(u=>u.is(q)?u:u.closestType(q)).filter(Boolean);d.length===a.length&&Au(d)},0);n.on("component:select",i),j({editor:n,plan:ru,pluginName:iu,licenseKey:t.licenseKey,cleanup:()=>{n.off("component:select",i),n.Blocks.remove(ze),lu.forEach(r=>o.removeType(r))}})}),Nu="listPagesComponent",Ou=F.startup,dl="page://",wt="list-pages",Jt="list-pages-item",Ct="list-pages-link",Iu=n=>n.components().reduce((e,t)=>{var r;const o=t.findFirstType(Ct),s=(r=o==null?void 0:o.attributes.attributes)==null?void 0:r.href,i=s!=null&&s.startsWith(dl)?s.replace(dl,""):"";if(i&&o){const l=e[i];l?l.push(o):e[i]=[o]}return e},{}),So="data-type-role",Ru="page_root",Du=n=>e=>e.is(n),Lu=n=>(e,t)=>t.is(n),Bs=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,So))===n},$u=W(function(n,e={}){const{Blocks:t,Components:o,Pages:s}=n,{licenseKey:i,block:r={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${ke}${wt}`,p=`${ke}${Ct}`,u='<svg viewBox="0 0 24 24"><path d="M11 15H17V17H11V15M9 7H7V9H9V7M11 13H17V11H11V13M11 9H17V7H11V9M9 11H7V13H9V11M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H5V19H19V5M9 15H7V17H9V15Z"/></svg>',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(wt,{block:r&&{label:l,media:u,category:"Extra",select:!0,...e.block},isComponent:Bs(wt),model:{defaults:{tagName:"ul",name:l,[Ru]:"",classes:d,attributes:{[So]:wt,role:"navigation"},droppable:Du(Jt),styles:`
61
+ </svg>`,Js="layout-icon-picker",Ru="icons-layout-",Ys="icons-list-layout",Zs="gs-iconify-picker",Ii="__iconify_collection",Lu="https://api.iconify.design",Di=new Map;let wo;const Bu=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function Xs({collectionId:n,editor:e}){try{if(Di.has(n))return Di.get(n);const t=await fetch(Bu({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const o=await t.json();return Di.set(n,o),o}catch(t){console.error("Error fetching collection",t),e.runCommand(W.toastAdd,Wu());return}}async function Vu({collectionIds:n,editor:e}){try{if(wo)return wo;const t=n?`?prefixes=${n.join(",")}`:"",o=await fetch(`${Lu}/collections${t}`);if(!o.ok)throw new Error(`Failed to fetch collections: ${o.statusText}`);return wo=await o.json(),wo}catch(t){console.error("Error fetching collections",t),e.runCommand(W.toastAdd,tl());return}}function Qs(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function Hu({collectionIds:n,editor:e,component:t}){const o=await Vu({collectionIds:n,editor:e});if(!o)return;const i=({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)),s=t.get("collectionId")??r[0].id;e.runCommand(W.layoutToggle,{id:Js,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[_u({collectionsList:r,collectionId:s,editor:e,handleClick:i}),{id:Ys,type:"column",grow:!0}]}});const l=await Xs({collectionId:s,editor:e});l&&(el({editor:e,collection:l}),zi({editor:e,collection:l,handleClick:i,collectionId:s}))}function el({editor:n,collection:e}){n.em.set(Ii,e)}function Fu(n){return n.em.get(Ii)}function zi(n){const{editor:e}=n;e.runCommand(W.layoutUpdate,{id:Ru,layout:Gu(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:Ys}})}function _u(n){const{collectionsList:e,collectionId:t,editor:o,handleClick:i}=n,r=e.map(({id:s,name:l,total:a})=>({id:s,label:`${l} (${a})`})).sort((s,l)=>s.label.localeCompare(l.label));return{type:"column",style:{gap:10},className:`${Zs}__header`,children:[{type:"selectField",value:t,options:r,emptyState:"Select an icon collection",onChange:async({setState:s,value:l})=>{const a=await Xs({collectionId:l,editor:o});a&&(s({value:l}),el({editor:o,collection:a}),zi({editor:o,collection:a,handleClick:i,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${Ii}`]:({setState:s})=>s({value:""})},onInput:({setState:s,value:l,editor:a})=>{const c=Fu(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([p])=>p.includes(l)));s({value:l}),zi({editor:a,collection:c,handleClick:i,collectionId:t,collectionFiltered:{...c,icons:d}})}}]}}function Gu({collection:n,collectionFiltered:e,handleClick:t}){const{height:o=24,width:i=24,icons:r,prefix:s}=e||n,l=Object.entries(r).map(([a,c])=>({name:a,...c}),{});return{type:"column",className:`${Zs}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>({type:"custom",render:c=>{const{editor:d,addEl:p,removeEl:u}=c,f=document.createElementNS("http://www.w3.org/2000/svg","svg");f.setAttribute("xmlns","http://www.w3.org/2000/svg"),f.innerHTML=a.body;const h=a.width||i,g=a.height||o;f.setAttribute("viewBox",`0 0 ${h} ${g}`),f.style.cssText="width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";const b=[["click",()=>{const x=f.cloneNode(!0);x.removeAttribute("style");const C=x.outerHTML;t({icon:C,collectionId:s,iconId:a.name}),d==null||d.runCommand(W.layoutRemove,{id:Js})}],["pointerover",()=>{f.style.border="2px solid currentColor",f.style.padding="4px"}],["pointerout",()=>{f.style.border="",f.style.padding=""}]];return b.forEach(([x,C])=>f.addEventListener(x,C)),p(f),()=>{b.forEach(([x,C])=>f.removeEventListener(x,C)),u(f)}}})}}}function tl(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:Vs.Error}}function Wu(){return{...tl(),id:"toast-error-getCollection",content:"Error fetching collection"}}const qu=q(function(n,e={}){var f;const{Components:t,Blocks:o}=n,{collections:i,extendIconComponent:r=!0,licenseKey:s,block:l={}}=e,a="icon",c="iconify",d="Iconify",p="data-type-iconify",u={events:()=>({dblclick:"onActive"}),onActive(){Hu({collectionIds:i,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:Oi,content:{type:c},category:"Extra",activate:!0,...l},isComponent:h=>yo(h,p),model:{defaults:{name:d,icon:Oi,droppable:!1,attributes:{[p]:!0},resizable:zu,components:Oi,style:{width:"50px",height:"50px"},traits:[Qs()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(h=>h.set({layerable:!1,locked:!0}))}},view:u}),r){const h=(f=t.getType(a))==null?void 0:f.model,[g,b,...x]=h.getDefaults().traits;t.addType(a,{model:{defaults:{traits:[g,b,Qs(),...x]}},view:u})}U({editor:n,licenseKey:s,plan:Du,pluginName:Ks,cleanup:()=>{o.remove(c),t.removeType(c)}})},Ks);function An(n,e,t){let o,i,r,s,l;const a=e===void 0?100:e;function c(){const p=Date.now()-s;p<a&&p>=0?o=setTimeout(c,a-p):(o=null,l=n.apply(r,i),r=i=null)}const d=function(){return r=this,i=arguments,s=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,i),r=i=null,clearTimeout(o),o=null)},d}const nl="tableComponent",Uu=F.startup;var O=(n=>(n.table="table",n.tableSettings="tableSettings",n.tableDelete="tableDelete",n.tableHead="tableHead",n.tableFoot="tableFoot",n.tableCellItems="tableCellItems",n.tableCellProperties="tableCellProperties",n.tableCellMerge="tableCellMerge",n.tableCellSplit="tableCellSplit",n.tableRowItems="tableRowItems",n.tableRowInsertBefore="tableRowInsertBefore",n.tableRowInsertAfter="tableRowInsertAfter",n.tableRowDelete="tableRowDelete",n.tableRowProperties="tableRowProperties",n.tableRowCut="tableRowCut",n.tableRowCopy="tableRowCopy",n.tableRowPasteBefore="tableRowPasteBefore",n.tableRowPasteAfter="tableRowPasteAfter",n.tableColumn="tableColumn",n.tableColumnItems="tableColumnItems",n.tableColumnInsertBefore="tableColumnInsertBefore",n.tableColumnInsertAfter="tableColumnInsertAfter",n.tableColumnDelete="tableColumnDelete",n.tableColumnCut="tableColumnCut",n.tableColumnCopy="tableColumnCopy",n.tableColumnPasteBefore="tableColumnPasteBefore",n.tableColumnPasteAfter="tableColumnPasteAfter",n))(O||{});const 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>'},Ve="table",ol="thead",il="tfoot",Ri="tbody",ge="row",K="cell",Li="clipboardTable",Ku=[Ve,ol,il,Ri,ge,K],So=n=>n.em.get(Li)||[],Ju=n=>n.every(e=>e.is(K)),Bi=(n,e)=>{const{editor:t,event:o,opts:i}=n,r=o.currentTarget||o.target,{x:s,y:l,width:a,height:c}=r.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:s,y:l,w:a,h:c},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...e};Le(i.openSettings)?i.openSettings({...n,layoutProps:d}):t.runCommand(W.layoutToggle,d)},Yu=(n,{rows:e=1,cells:t=5,text:o}={})=>({type:n,components:Array.from(Array(e).keys()).map(i=>({type:ge,components:Array.from(Array(t).keys()).map(r=>({type:K,components:o?{type:"text",content:Le(o)?o({y:i,x:r}):o}:void 0}))}))}),rl="Table settings",sl=n=>{const{component:e}=n;return e.is(Ve)?e:e.closestType(Ve)},Zu=n=>{var e;(e=sl(n))==null||e.remove(n.opts)},Xu=n=>{const e=sl(n);e&&(n.editor.select(e),Bi(n,{id:"tableSettings",header:{label:rl}}))},ll=n=>[{id:O.table,icon:V[O.table],label:"Table",items:[{id:O.tableSettings,label:rl,icon:V[O.tableSettings],onClick:({event:t})=>Xu({...n,event:t})},{id:O.tableDelete,label:"Delete table",icon:V[O.tableDelete],onClick:()=>Zu(n)}]}],al=({editor:n})=>{const e=So(n);return e.length&&Ju(e)},cl=({component:n,editor:e,after:t})=>{if(!n.is(K))return;const o=n.closestType(Ve),i=n.closestType(ge),r=n.index()+(t?1:0);o==null||o.findType(ge).forEach(l=>l.append({type:K},{at:r}));const s=i==null?void 0:i.components().at(r);s&&e.select(s)},dl=({component:n,opts:e})=>{if(!n.is(K))return;const t=n.closestType(Ve),o=n.index();t==null||t.findType(ge).forEach(i=>{var r;return(r=i.components().at(o))==null?void 0:r.remove(e)})},pl=({component:n,editor:e})=>{if(!n.is(K))return;const t=n.closestType(Ve),o=n.index(),i=(t==null?void 0:t.findType(ge).map(r=>r.components().at(o)))||[];i.length&&e.em.set(Li,i)},ul=n=>{const{component:e,editor:t,after:o}=n;if(!e.is(K)||!al(n))return;const i=So(t),r=e.closestType(Ve),s=e.index()+(o?1:0);r==null||r.findType(ge).forEach((l,a)=>{const c=i[a],d=(c==null?void 0:c.clone())||{type:K};l.append(d,{at:s})})},Qu=n=>{const{component:e}=n;e.is(K)&&(pl(n),dl({...n,opts:{temporary:!0}}))},ef=n=>{const e=al(n);return[{id:O.tableColumnItems,icon:V[O.tableColumn],label:"Column",items:[{id:O.tableColumnInsertBefore,label:"Insert column before",icon:V[O.tableColumnInsertBefore],onClick:()=>cl(n)},{id:O.tableColumnInsertAfter,label:"Insert column after",icon:V[O.tableColumnInsertAfter],onClick:()=>cl({...n,after:!0})},{id:O.tableColumnDelete,label:"Delete column",icon:V[O.tableColumnDelete],onClick:()=>dl(n)},{id:O.tableColumnCut,label:"Cut column",icon:V[O.tableColumnCut],onClick:()=>Qu(n)},{id:O.tableColumnCopy,label:"Copy column",icon:V[O.tableColumnCopy],onClick:()=>pl(n)},{id:O.tableColumnPasteBefore,label:"Paste column before",icon:V[O.tableColumnPasteBefore],disabled:!e,onClick:()=>ul(n)},{id:O.tableColumnPasteAfter,label:"Paste column after",icon:V[O.tableColumnPasteAfter],disabled:!e,onClick:()=>ul({...n,after:!0})}]}]},fl="Row settings",tf=n=>n.every(e=>e.is(ge)),Jt=n=>{const{component:e}=n,t=e.is(K),o=e.is(ge);if(!(!t&&!o))return o?e:e.closestType(ge)},hl=n=>{const{component:e,editor:t,after:o}=n,i=Jt(n);if(!i)return;const r=i.index()+(o?1:0),s=i.components().length,l=Array.from(Array(s).keys()).map(()=>({type:K})),a=i.parent();if(a){const c=a.append({type:ge,components:l},{at:r})[0];if(e.is(K)&&c){const d=e.index(),p=c.components().at(d);p&&t.select(p)}}},ml=n=>{var e;(e=Jt(n))==null||e.remove(n.opts)},gl=n=>{const e=Jt(n);e&&n.editor.em.set(Li,[e])},bl=n=>{var l;const{editor:e,after:t}=n,o=Jt(n);if(!o||!yl(n))return;const r=So(e)[0],s=o.index()+(t?1:0);r&&((l=o.parent())==null||l.append(r.clone(),{at:s}))},nf=n=>{Jt(n)&&(gl(n),ml({...n,opts:{temporary:!0}}))},yl=({editor:n})=>{const e=So(n);return e.length&&tf(e)},of=n=>{const e=Jt(n);e&&(n.editor.select(e),Bi(n,{id:"tableRowSettings",header:{label:fl}}))},xl=n=>{const e=yl(n);return[{id:O.tableRowItems,icon:V[O.tableRowProperties],label:"Row",items:[{id:O.tableRowInsertBefore,label:"Insert row before",icon:V[O.tableRowInsertBefore],onClick:()=>hl(n)},{id:O.tableRowInsertAfter,label:"Insert row after",icon:V[O.tableRowInsertAfter],onClick:()=>hl({...n,after:!0})},{id:O.tableRowDelete,label:"Delete row",icon:V[O.tableRowDelete],onClick:()=>ml(n)},{id:O.tableRowProperties,label:fl,icon:V[O.tableRowProperties],onClick:({event:o})=>of({...n,event:o})},{id:O.tableRowCut,label:"Cut row",icon:V[O.tableRowCut],onClick:()=>nf(n)},{id:O.tableRowCopy,label:"Copy row",icon:V[O.tableRowCopy],onClick:()=>gl(n)},{id:O.tableRowPasteBefore,label:"Paste row before",icon:V[O.tableRowPasteBefore],disabled:!e,onClick:()=>bl(n)},{id:O.tableRowPasteAfter,label:"Paste row after",icon:V[O.tableRowPasteAfter],disabled:!e,onClick:()=>bl({...n,after:!0})}]},...ll(n)]},Vi=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),o=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:o}};function vl(n){const e=[];return n.components().forEach((t,o)=>{t.components().each((i,r)=>{const{rowspan:s,colspan:l}=Vi(i);if(e[o])for(;e[o][r];)r++;for(let a=o;a<o+s;a++){e[a]||(e[a]=[]);for(let c=r;c<r+l;c++)e[a][c]={real:a===o&&c===r,cell:i,rowspan:s,colspan:l}}})}),e}function Yt(n,e,t){var o;return(o=n[t])==null?void 0:o[e]}const Hi=n=>n.closestType(ge);function rf(n,{x:e,y:t,rows:o,cols:i}){var l;let r=Hi(n[t][e].cell),s;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(s=e;s>=0;s--){const{cell:c}=n[t+a][s],d=Hi(c);if(d===r){for(let p=1;p<=i;p++){const u=c.index();d.append({type:K},{at:u+1})}break}}if(s===-1){const d=r.components().at(0).index();for(let p=1;p<=i;p++)r.append({type:K},{at:d})}}}function wl(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const i=n[e][t].cell;if(i.em.selected.hasComponent(i)){const{rowspan:r,colspan:s}=Vi(i);if(s>1||r>1){i.addAttributes({colspan:1,rowspan:1});for(let l=0;l<s-1;l++){const a=i.index();Hi(i).append({type:K},{at:a+1})}rf(n,{x:t,y:e,rows:r-1,cols:s})}}}}function sf(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const Co=(n,e={})=>{var s;const t=vl(n),{em:o}=n;let i,r;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((s=e.selected)!=null&&s.includes(c.cell)||o.selected.hasComponent(c.cell)){const d={x:a,y:l};i||(i=d),r=d}}return{grid:t,startPos:i,endPos:r}};function lf(n,e={}){const t=Co(n),{startPos:o,endPos:i}=t;let{grid:r}=t;const{em:s}=n;if(!o||!i)return;const l=o.x,a=o.y,c=i.x,d=i.y,p=Yt(r,l,a),u=Yt(r,c,d);if(p&&u){wl(r),r=vl(n);const f=[],h=Yt(r,l,a).cell;h.addAttributes({colspan:c-l+1,rowspan:d-a+1});for(let g=a;g<=d;g++)for(let b=l;b<=c;b++){const x=Yt(r,b,g);if(!x)continue;const{cell:C}=x;C!==h&&f.push(C)}f.forEach(g=>{e.mergeContent&&h.append(g.components().models),g.remove()}),s.setSelected(h),sf(n)}}const Sl="Cell settings",af="Merge cells",cf="Split cell",df=n=>n.closestType(ge),Zt=n=>{var e;return(e=df(n))==null?void 0:e.parent()},pf=n=>{const e=n.editor.getSelectedAll(),t=Zt(e[0]),o=e[0];if(!t||!(o!=null&&o.is(K))||e.length>1)return!1;const{rowspan:i,colspan:r}=Vi(o);return!(r<2&&i<2)},uf=n=>{const t=n.editor.getSelectedAll()[0],o=Zt(t),{grid:i}=Co(o);wl(i)},Cl=n=>{const e=n.editor.getSelectedAll(),t=Zt(e[0]);if(!t||e.length<2||e.some(l=>!l.is(K)||Zt(l)!==t))return!1;const{grid:o,startPos:i,endPos:r}=Co(t),{em:s}=t;if(!i||!r)return!1;for(let l=i.y;l<=r.y;l++)for(let a=i.x;a<=r.x;a++){const c=Yt(o,a,l);if(!c||!s.selected.hasComponent(c.cell))return!1}return!0},ff=n=>{const{editor:e}=n;if(!Cl(n))return;const t=e.getSelectedAll(),o=Zt(t[0]);lf(o,{mergeContent:!0})},hf=n=>{Bi(n,{id:"tableCellSettings",header:{label:Sl}})},mf=n=>[{id:O.tableCellItems,icon:V[O.tableCellProperties],label:"Cell",items:[{id:O.tableCellProperties,label:Sl,icon:V[O.tableCellProperties],onClick:({event:t})=>hf({...n,event:t})},{id:O.tableCellMerge,label:af,icon:V[O.tableCellMerge],onClick:()=>ff(n),disabled:!Cl(n)},{id:O.tableCellSplit,label:cf,icon:V[O.tableCellSplit],onClick:()=>uf(n),disabled:!pf(n)}]},...ef(n),...xl(n)],gf=n=>{const e=n[0]&&Zt(n[0]);if(!e)return;const{grid:t,startPos:o,endPos:i}=Co(e,{selected:n});if(!o||!i)return;const r=[];for(let s=o.y;s<=i.y;s++)for(let l=o.x;l<=i.x;l++){const a=Yt(t,l,s);a&&r.push(a.cell)}r.length&&e.em.setSelected(r,{fromCell:!0})},bf=q(function(n,e={}){const t={block:{},...e},{Components:o}=n,i={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(Ve,{block:t.block&&{label:"Table",media:V.table,category:"Extra",content:{type:Ve,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:s,value:l,emitUpdate:a}){const c=s.find("caption")[0];l?!c&&s.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):c==null||c.remove(),a(),n.refresh({tools:!0})},getValue(s){return!!s.component.find("caption")[0]}}],components:Yu(Ri,{rows:5}),contextMenu:({items:s,editor:l,component:a})=>[...ll({editor:l,component:a,opts:t}),...s]}}}),o.addType(ol,{model:{defaults:{icon:V.tableHead,...i}}}),o.addType(il,{model:{defaults:{icon:V.tableFoot,...i}}}),o.addType(Ri,{model:{defaults:{icon:V.tableRowProperties,...i}}}),o.addType(ge,{model:{defaults:{icon:V.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:s,editor:l,component:a})=>[...xl({editor:l,component:a,opts:t}),...s]}}}),o.addType(K,{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:s,editor:l,component:a})=>[...mf({editor:l,component:a,opts:t}),...s]}}});const r=An((s,l)=>{var p;const a=n.getSelectedAll(),c=!!((p=l==null?void 0:l.event)!=null&&p.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(u=>u.is(K)?u:u.closestType(K)).filter(Boolean);d.length===a.length&&gf(d)},0);n.on("component:select",r),U({editor:n,plan:Uu,pluginName:nl,licenseKey:t.licenseKey,cleanup:()=>{n.off("component:select",r),n.Blocks.remove(Ve),Ku.forEach(s=>o.removeType(s))}})},nl),kl="listPagesComponent",yf=F.startup,Tl="page://",kt="list-pages",Xt="list-pages-item",Tt="list-pages-link",xf=n=>n.components().reduce((e,t)=>{var s;const o=t.findFirstType(Tt),i=(s=o==null?void 0:o.attributes.attributes)==null?void 0:s.href,r=i!=null&&i.startsWith(Tl)?i.replace(Tl,""):"";if(r&&o){const l=e[r];l?l.push(o):e[r]=[o]}return e},{}),ko="data-type-role",vf="page_root",wf=n=>e=>e.is(n),Sf=n=>(e,t)=>t.is(n),Fi=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,ko))===n},Cf=q(function(n,e={}){const{Blocks:t,Components:o,Pages:i}=n,{licenseKey:r,block:s={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${Ee}${kt}`,p=`${Ee}${Tt}`,u='<svg viewBox="0 0 24 24"><path d="M11 15H17V17H11V15M9 7H7V9H9V7M11 13H17V11H11V13M11 9H17V7H11V9M9 11H7V13H9V11M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H5V19H19V5M9 15H7V17H9V15Z"/></svg>',f='<svg viewBox="0 0 24 24"><path d="M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" /></svg>';o.addType(kt,{block:s&&{label:l,media:u,category:"Extra",select:!0,...e.block},isComponent:Fi(kt),model:{defaults:{tagName:"ul",name:l,[vf]:"",classes:d,attributes:{[ko]:kt,role:"navigation"},droppable:wf(Xt),styles:`
62
62
  .${d} {
63
63
  list-style: none;
64
64
  margin: 0;
65
65
  padding: 0;
66
66
  }
67
- `},init(){this.syncPageItems=En(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=Iu(this);f.forEach((b,w)=>{const y=b.id,v=b.getName(),C=g[y];C?C==null||C.forEach(S=>{S.getInnerHTML()!==v&&S.components(v)}):m.add({type:Jt,components:[{type:Ct,attributes:{href:`page://${y}`},components:{type:"textnode",content:v}}]},{at:w})})}}}),o.addType(Jt,{isComponent:Bs(Jt),model:{defaults:{name:a,tagName:"li",icon:h,attributes:{[So]:Jt},components:{type:Ct},draggable:Lu(wt)}}}),o.addType(Ct,{extend:"link",isComponent:Bs(Ct),model:{defaults:{removable:!1,copyable:!1,delegate:{move:f=>f.closestType(Jt)},name:c,classes:p,attributes:{[So]:Ct},components:{type:"textnode",content:"Item"},styles:`
67
+ `},init(){this.syncPageItems=An(this.syncPageItems.bind(this),0),this.listenTo(this.em,i.events.all,this.syncPageItems),this.syncPageItems()},syncPageItems(){if(n.Components.getSymbolInfo(this).isInstance)return;const h=this.em.Pages.getAll(),g=this.components(),b=xf(this);h.forEach((x,C)=>{const y=x.id,v=x.getName(),k=b[y];k?k==null||k.forEach(w=>{w.getInnerHTML()!==v&&w.components(v)}):g.add({type:Xt,components:[{type:Tt,attributes:{href:`page://${y}`},components:{type:"textnode",content:v}}]},{at:C})})}}}),o.addType(Xt,{isComponent:Fi(Xt),model:{defaults:{name:a,tagName:"li",icon:f,attributes:{[ko]:Xt},components:{type:Tt},draggable:Sf(kt)}}}),o.addType(Tt,{extend:"link",isComponent:Fi(Tt),model:{defaults:{removable:!1,copyable:!1,delegate:{move:h=>h.closestType(Xt)},name:c,classes:p,attributes:{[ko]:Tt},components:{type:"textnode",content:"Item"},styles:`
68
68
  .${p} {
69
69
  text-decoration: none;
70
70
  }
71
- `}}}),j({editor:n,licenseKey:i,plan:Ou,pluginName:Nu,cleanup:()=>{t.remove(wt),o.removeType(wt)}})}),zu="fsLightboxComponent",Bu=F.startup,xo="data-fslightbox",wo="data-type",Vu="fslightbox-open",Zt="fslightbox",Yt={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',imageLightbox:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},Hu=W(function(n,e={}){const{Blocks:t,Components:o}=n,s="Lightbox",i=`${ke}${Zt}`,r={toolbarIconOpen:Yt.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=r,d=function(w){const y=this,v="data-fslightbox",C=window,S=()=>{var M;const x=C.refreshFsLightbox;x==null||x();const E=y.getAttribute(v);if((M=C.fsLightboxInstances)==null||M[E],!C._isEditor)return;Array.from(document.querySelectorAll(`[${v}]`)).forEach(P=>{const N=P.onclick;P.onclick=function(O){O.preventDefault();const R=P;!R.__skipLb&&(N==null||N(O)),R.__skipLb=!0}})};if(C.refreshFsLightbox)S();else{const x=document.createElement("script");x.src=w.cdnScript,x.onload=S,document.head.appendChild(x)}},p=w=>({id:`${Zt}-open-lb`,label:a,command:()=>{const y=w.getView();y==null||y.toggleLightbox()}}),u="source-type",h={type:"radio",name:u,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:Yt.image},{id:"video",label:"Video",icon:Yt.video},{id:"el",label:"Custom Element",icon:Yt.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(Zt,{block:l&&{label:s,media:Yt.imageLightbox,category:"Extra",select:!0,...r.block},isComponent:w=>{var y;return(y=w.hasAttribute)==null?void 0:y.call(w,xo)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:s,icon:Yt.imageLightbox,classes:i,draggable:(w,y)=>!y.is(Zt),attributes:{[xo]:"lightbox",[wo]:"image",href:c},components:{type:"image",src:c},script:d,cdnScript:r.cdnScript,"script-props":["attributes","cdnScript"],[u]:"image",traits:[h,{name:xo,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(w,y){var C;const v=(C=y.target)==null?void 0:C.getView();v==null||v.toggleLightbox()}}],styles:`
72
- .${i} {
71
+ `}}}),U({editor:n,licenseKey:r,plan:yf,pluginName:kl,cleanup:()=>{t.remove(kt),o.removeType(kt)}})},kl),El="fsLightboxComponent",kf=F.startup,To="data-fslightbox",Eo="data-type",Tf="fslightbox-open",Qt="fslightbox",en={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>'},Ef=q(function(n,e={}){const{Blocks:t,Components:o}=n,i="Lightbox",r=`${Ee}${Qt}`,s={toolbarIconOpen:en.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=s,d=function(C){const y=this,v="data-fslightbox",k=window,w=()=>{var A;const S=k.refreshFsLightbox;S==null||S();const E=y.getAttribute(v);if((A=k.fsLightboxInstances)==null||A[E],!k._isEditor)return;Array.from(document.querySelectorAll(`[${v}]`)).forEach($=>{const P=$.onclick;$.onclick=function(N){N.preventDefault();const I=$;!I.__skipLb&&(P==null||P(N)),I.__skipLb=!0}})};if(k.refreshFsLightbox)w();else{const S=document.createElement("script");S.src=C.cdnScript,S.onload=w,document.head.appendChild(S)}},p=C=>({id:`${Qt}-open-lb`,label:a,command:()=>{const y=C.getView();y==null||y.toggleLightbox()}}),u="source-type",f={type:"radio",name:u,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:en.image},{id:"video",label:"Video",icon:en.video},{id:"el",label:"Custom Element",icon:en.external}],labelToTitle:!0},h={id:"href-image",name:"href",type:"file",label:"Source Image"},g={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},b={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},x={image:[h],video:[g],el:[b]};o.addType(Qt,{block:l&&{label:i,media:en.imageLightbox,category:"Extra",select:!0,...s.block},isComponent:C=>{var y;return(y=C.hasAttribute)==null?void 0:y.call(C,To)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:i,icon:en.imageLightbox,classes:r,draggable:(C,y)=>!y.is(Qt),attributes:{[To]:"lightbox",[Eo]:"image",href:c},components:{type:"image",src:c},script:d,cdnScript:s.cdnScript,"script-props":["attributes","cdnScript"],[u]:"image",traits:[f,{name:To,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(C,y){var k;const v=(k=y.target)==null?void 0:k.getView();v==null||v.toggleLightbox()}}],styles:`
72
+ .${r} {
73
73
  display: inline-block;
74
74
  padding: 10px;
75
75
  }
76
- `},init(){const w=[u].map(y=>`change:${y}`).join(" ");this.on(w,this.updateTraits),this.on(`change:${u}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(w,y,v){if(v.adjust)return;const S=this.get(u)==="video"?"video":"image";this.addAttributes({[wo]:S,href:""})},adjustSourceType(){const w=this.get(u),y=this.getAttributes().href||"",v={adjust:!0};if(w==="video"){const C=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[wo]:C},v)}else w!=="el"&&y.startsWith("#")?this.set(u,"el",v):w==="image"&&this.addAttributes({[wo]:"image"},v)},updateTraits(w={}){const{changed:y}=this,{init:v}=w;if(y[h.name]||v){this.removeTrait([f.name,m.name,g.name]);const C=this.get(u)||"image",S=this.getTraitIndex(u)+1;this.addTrait(b[C],{at:S})}},initToolbar(){if(!a)return;const{toolbar:w}=this,y=p(this);!w.find(C=>C.id===y.id)&&(w==null||w.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:w,el:y,model:v}=this,{Canvas:C}=w,S=v.getAttributes()[xo],{defaultView:x,documentElement:E}=y.ownerDocument,k=(P=x.fsLightboxInstances)==null?void 0:P[S];if(E.classList.contains(Vu))k.close();else{y.__skipLb=!1;let N;k.props.onOpen=()=>{N=C.getSpots(),setTimeout(()=>C.removeSpots())},k.props.onClose=()=>{N.forEach(O=>C.addSpot(O.attributes))},y.click()}}}}),j({editor:n,plan:Bu,licenseKey:r.licenseKey,pluginName:zu,cleanup:()=>{t.remove(Zt),o.removeType(Zt)}})}),Fu="lightGalleryComponent",_u=F.startup;var Xt=(n=>(n.image="image",n.video="video",n.external="external",n))(Xt||{});const kt="lightGallery",pl=`${kt}-item`,Co="data-lightgallery",ul=`${Co}-item`,ko="toggle",Et={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>'},Vs={propKeys:[],props:{},traits:[]},Tn=(n,e={})=>{var s;const t={},o=[];for(const i in n){const{value:r,...l}=n[i];o.push({id:i,name:i,changeProp:!0,category:e.category,...l}),t[i]=r;const{subTraits:a={}}=l;for(const c in l.subTraits)(s=a[c])==null||s.forEach(d=>{const p=d.id||d.name;t[p]=d.value})}return{propKeys:Object.keys(t),props:t,traits:o}},Hs=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),s=t.get("subTraits")||{},r=(Object.values(s).flat()||[]).map(c=>c.id||c.name);n.removeTrait(r);const l=s[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},Fs=(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,()=>Hs(n,t)),Hs(n,t)})},Gu=(n,e,t)=>{const s=n.getTrait(e).get("subTraits")||{},r=(Object.values(s).flat()||[]).map(a=>{const c=a.name||a.id;return a.changeProp?`change:${c}`:`change:attributes:${c}`}),l=Array.from(new Set(r));l.length&&n.on(l.join(" "),t)},Wu={[ko]:{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}},ju={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"}]}}},qu={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}]}}},Uu={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}]}}},st="sourceType",Eo="data-iframe",_s={name:"href",type:"file",label:"Image Source"},To={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},Gs={name:"data-poster",label:"Video Poster",type:"file"},hl={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},fl={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Ku={[ko]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var s,i;const t=e.target,o=(s=t==null?void 0:t.closestType(kt))==null?void 0:s.getView();if(o&&t){const r=((i=o.getLightGallery())==null?void 0:i.items)||[],l=Array.from(r).indexOf(t.getEl());l>=0&&o.toggleGallery(l)}}},[st]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[_s],video:[To,Gs],external:[hl]},options:[{id:"image",label:_s.label||"",icon:Et.image},{id:"video",label:To.label||"",icon:Et.video},{id:"external",label:hl.label||"",icon:Et.external}]},subHtml:fl},ml="lgThumbnail",Ju="lgVideo",gl="lgAutoplay",yl="lgZoom",Qt="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Zu=W(function(n,e={}){const{Blocks:t,Components:o}=n,s="LightGallery",i="LightGallery Item",r={toolbarIconOpen:Et.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[ml,Ju,gl,yl],cdnScript:[`${Qt}/lightgallery.min.js`,`${Qt}/plugins/thumbnail/lg-thumbnail.min.js`,`${Qt}/plugins/video/lg-video.min.js`,`${Qt}/plugins/autoplay/lg-autoplay.min.js`,`${Qt}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${Qt}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=r,d=function(y){const v=this,C=window,{plugins:S,cdnScript:x,cdnStyle:E,inline:k,lgLicenseKey:M,...P}=y||{},N=R=>isNaN(R)?void 0:parseInt(R,10),O=()=>{var ue;const R={...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:(S||[]).map(he=>C[he])};k&&(R.container=v,R.closable=!1);const _=(ue=C.lightGallery)==null?void 0:ue.call(C,v,R);k&&_.openGallery()};if(C.lightGallery)O();else{const{head:R}=document,_=Array.isArray(x)?[...x]:[x],ue=Array.isArray(E)?[...E]:[E],he=Ce=>{if(Ce.length){const Ae=document.createElement("link");Ae.href=Ce.shift(),Ae.rel="stylesheet",R.appendChild(Ae),he(Ce)}},tt=Ce=>{if(Ce.length){const Ae=document.createElement("script");Ae.src=Ce.shift(),Ae.onerror=Ae.onload=tt.bind(null,Ce),R.appendChild(Ae)}else O()};he(ue),tt(_)}},p=y=>{const v=y.getTrait(ko);if(!a||!v)return;const{toolbar:C}=y,S={id:ko,label:a,command:()=>setTimeout(()=>v.runCommand(),100)};!C.find(E=>E.id===S.id)&&(C==null||C.unshift(S))};let u=[];const h=r.plugins||[],f=Tn(Wu),m=h.includes(ml)?Tn(ju):Vs,g=h.includes(gl)?Tn(qu):Vs,b=h.includes(yl)?Tn(Uu):Vs;o.addType(kt,{block:l&&{label:s,media:Et.gallery,category:"Extra",select:!0,...r.block},isComponent:y=>fo(y,Co),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:Et.gallery,draggable:(y,v)=>!v.is(kt),attributes:{[Co]:!0},components:{type:pl},script:d,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.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(){Fs(this,["thumbnail"]),Fs(this,["autoplay"]),Fs(this,["zoom"])},initToolbar(){p(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 v;const y=this.getLightGallery();return((v=y==null?void 0:y.settings)==null?void 0:v.container)===this.el},onLgInit(y){this.el.__lg=y.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:y}=this,{Canvas:v}=y,C=this.getLightGallery();u=v.getSpots(),setTimeout(()=>v.removeSpots()),C.__lgOpened=!0},onLgClose(){const y=this.getLightGallery();u.forEach(v=>this.em.Canvas.addSpot(v.attributes)),u=[],y.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(y){const v=this.getLightGallery();if(v.__lgOpened)return v.closeGallery(!0);v.lgOpened=!1,v.openGallery(y)}}});const w=Tn(Ku);o.addType(pl,{isComponent:y=>fo(y,ul)||y.tagName==="A"&&fo(y.parentElement,Co),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:i,icon:Et.galleryItem,attributes:{[ul]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...w.props,traits:[...w.traits]},init(){const y=[st].map(v=>`change:${v}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Gu(this,st,this.triggerGalleryUpdate)},initToolbar(){p(this)},initScriptUpdate(){const y=[fl.name].map(v=>`change:attributes:${v}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var v;(v=this.closestType(kt))==null||v.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:v}=this,{init:C}=y;if(v[st]||C){Hs(this,st);const S=this.getTrait(st).getValue();if(S===Xt.image){this.removeAttributes([To.name,Gs.name,Eo]);const x=this.getTrait(_s.name);x.setValue(x.getValue()||c)}else S===Xt.video?this.removeAttributes([Eo]):S===Xt.external&&this.addAttributes({[Eo]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[Eo]?this.set(st,Xt.external):(y[To.name]||y[Gs.name])&&this.set(st,Xt.video)}}}),j({editor:n,plan:_u,licenseKey:r.licenseKey,pluginName:Fu,cleanup:()=>{t.remove(kt),o.removeType(kt)}})}),Ne="swiper",Mn=`${Ne}-slide`,en=`${Ne}-wrapper`,tn=`${Ne}-nav-prev`,Mo=`${Ne}-nav-next`,nn=`${Ne}-pagination`,An=`${Ne}-scrollbar`,le={slider:`<svg viewBox="0 0 24 24">
76
+ `},init(){const C=[u].map(y=>`change:${y}`).join(" ");this.on(C,this.updateTraits),this.on(`change:${u}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(C,y,v){if(v.adjust)return;const w=this.get(u)==="video"?"video":"image";this.addAttributes({[Eo]:w,href:""})},adjustSourceType(){const C=this.get(u),y=this.getAttributes().href||"",v={adjust:!0};if(C==="video"){const k=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[Eo]:k},v)}else C!=="el"&&y.startsWith("#")?this.set(u,"el",v):C==="image"&&this.addAttributes({[Eo]:"image"},v)},updateTraits(C={}){const{changed:y}=this,{init:v}=C;if(y[f.name]||v){this.removeTrait([h.name,g.name,b.name]);const k=this.get(u)||"image",w=this.getTraitIndex(u)+1;this.addTrait(x[k],{at:w})}},initToolbar(){if(!a)return;const{toolbar:C}=this,y=p(this);!C.find(k=>k.id===y.id)&&(C==null||C.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var $;const{em:C,el:y,model:v}=this,{Canvas:k}=C,w=v.getAttributes()[To],{defaultView:S,documentElement:E}=y.ownerDocument,T=($=S.fsLightboxInstances)==null?void 0:$[w];if(E.classList.contains(Tf))T.close();else{y.__skipLb=!1;let P;T.props.onOpen=()=>{P=k.getSpots(),setTimeout(()=>k.removeSpots())},T.props.onClose=()=>{P.forEach(N=>k.addSpot(N.attributes))},y.click()}}}}),U({editor:n,plan:kf,licenseKey:s.licenseKey,pluginName:El,cleanup:()=>{t.remove(Qt),o.removeType(Qt)}})},El),Ml="lightGalleryComponent",Mf=F.startup;var tn=(n=>(n.image="image",n.video="video",n.external="external",n))(tn||{});const Et="lightGallery",Al=`${Et}-item`,Mo="data-lightgallery",jl=`${Mo}-item`,Ao="toggle",Mt={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>'},_i={propKeys:[],props:{},traits:[]},jn=(n,e={})=>{var i;const t={},o=[];for(const r in n){const{value:s,...l}=n[r];o.push({id:r,name:r,changeProp:!0,category:e.category,...l}),t[r]=s;const{subTraits:a={}}=l;for(const c in l.subTraits)(i=a[c])==null||i.forEach(d=>{const p=d.id||d.name;t[p]=d.value})}return{propKeys:Object.keys(t),props:t,traits:o}},Gi=(n,e)=>{const t=n.getTrait(e),o=t.get("category"),i=t.get("subTraits")||{},s=(Object.values(i).flat()||[]).map(c=>c.id||c.name);n.removeTrait(s);const l=i[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:o,...c})),{at:a})},Wi=(n,e)=>{e.forEach(t=>{const o=n.getTrait(t);if(!o||!o.get("subTraits"))return;const i=o.changeProp?`change:${t}`:`change:attributes:${t}`;n.on(i,()=>Gi(n,t)),Gi(n,t)})},Af=(n,e,t)=>{const i=n.getTrait(e).get("subTraits")||{},s=(Object.values(i).flat()||[]).map(a=>{const c=a.name||a.id;return a.changeProp?`change:${c}`:`change:attributes:${c}`}),l=Array.from(new Set(s));l.length&&n.on(l.join(" "),t)},jf={[Ao]:{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}},$f={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"}]}}},Pf={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}]}}},Nf={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}]}}},lt="sourceType",jo="data-iframe",qi={name:"href",type:"file",label:"Image Source"},$o={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},Ui={name:"data-poster",label:"Video Poster",type:"file"},$l={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},Pl={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Of={[Ao]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var i,r;const t=e.target,o=(i=t==null?void 0:t.closestType(Et))==null?void 0:i.getView();if(o&&t){const s=((r=o.getLightGallery())==null?void 0:r.items)||[],l=Array.from(s).indexOf(t.getEl());l>=0&&o.toggleGallery(l)}}},[lt]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[qi],video:[$o,Ui],external:[$l]},options:[{id:"image",label:qi.label||"",icon:Mt.image},{id:"video",label:$o.label||"",icon:Mt.video},{id:"external",label:$l.label||"",icon:Mt.external}]},subHtml:Pl},Nl="lgThumbnail",If="lgVideo",Ol="lgAutoplay",Il="lgZoom",nn="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Df=q(function(n,e={}){const{Blocks:t,Components:o}=n,i="LightGallery",r="LightGallery Item",s={toolbarIconOpen:Mt.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[Nl,If,Ol,Il],cdnScript:[`${nn}/lightgallery.min.js`,`${nn}/plugins/thumbnail/lg-thumbnail.min.js`,`${nn}/plugins/video/lg-video.min.js`,`${nn}/plugins/autoplay/lg-autoplay.min.js`,`${nn}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${nn}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=s,d=function(y){const v=this,k=window,{plugins:w,cdnScript:S,cdnStyle:E,inline:T,lgLicenseKey:A,...$}=y||{},P=I=>isNaN(I)?void 0:parseInt(I,10),N=()=>{var he;const I={...$,licenseKey:A,speed:P($.speed),startAnimationDuration:P($.startAnimationDuration),thumbMargin:P($.thumbMargin),thumbWidth:P($.thumbWidth),slideShowInterval:P($.slideShowInterval),scale:P($.scale),enableZoomAfter:P($.enableZoomAfter),plugins:(w||[]).map(me=>k[me])};T&&(I.container=v,I.closable=!1);const G=(he=k.lightGallery)==null?void 0:he.call(k,v,I);T&&G.openGallery()};if(k.lightGallery)N();else{const{head:I}=document,G=Array.isArray(S)?[...S]:[S],he=Array.isArray(E)?[...E]:[E],me=Te=>{if(Te.length){const $e=document.createElement("link");$e.href=Te.shift(),$e.rel="stylesheet",I.appendChild($e),me(Te)}},it=Te=>{if(Te.length){const $e=document.createElement("script");$e.src=Te.shift(),$e.onerror=$e.onload=it.bind(null,Te),I.appendChild($e)}else N()};me(he),it(G)}},p=y=>{const v=y.getTrait(Ao);if(!a||!v)return;const{toolbar:k}=y,w={id:Ao,label:a,command:()=>setTimeout(()=>v.runCommand(),100)};!k.find(E=>E.id===w.id)&&(k==null||k.unshift(w))};let u=[];const f=s.plugins||[],h=jn(jf),g=f.includes(Nl)?jn($f):_i,b=f.includes(Ol)?jn(Pf):_i,x=f.includes(Il)?jn(Nf):_i;o.addType(Et,{block:l&&{label:i,media:Mt.gallery,category:"Extra",select:!0,...s.block},isComponent:y=>yo(y,Mo),extendFn:["init","initToolbar"],model:{defaults:{name:i,icon:Mt.gallery,draggable:(y,v)=>!v.is(Et),attributes:{[Mo]:!0},components:{type:Al},script:d,selector:"",exThumbImage:"",cdnScript:s.cdnScript,cdnStyle:s.cdnStyle,plugins:s.plugins,lgLicenseKey:s.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...h.propKeys,...g.propKeys,...b.propKeys,...x.propKeys],...h.props,...g.props,...b.props,...x.props,traits:[...h.traits,...g.traits,...b.traits,...x.traits]},init(){Wi(this,["thumbnail"]),Wi(this,["autoplay"]),Wi(this,["zoom"])},initToolbar(){p(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 v;const y=this.getLightGallery();return((v=y==null?void 0:y.settings)==null?void 0:v.container)===this.el},onLgInit(y){this.el.__lg=y.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:y}=this,{Canvas:v}=y,k=this.getLightGallery();u=v.getSpots(),setTimeout(()=>v.removeSpots()),k.__lgOpened=!0},onLgClose(){const y=this.getLightGallery();u.forEach(v=>this.em.Canvas.addSpot(v.attributes)),u=[],y.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(y){const v=this.getLightGallery();if(v.__lgOpened)return v.closeGallery(!0);v.lgOpened=!1,v.openGallery(y)}}});const C=jn(Of);o.addType(Al,{isComponent:y=>yo(y,jl)||y.tagName==="A"&&yo(y.parentElement,Mo),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:r,icon:Mt.galleryItem,attributes:{[jl]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...C.props,traits:[...C.traits]},init(){const y=[lt].map(v=>`change:${v}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Af(this,lt,this.triggerGalleryUpdate)},initToolbar(){p(this)},initScriptUpdate(){const y=[Pl.name].map(v=>`change:attributes:${v}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var v;(v=this.closestType(Et))==null||v.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:v}=this,{init:k}=y;if(v[lt]||k){Gi(this,lt);const w=this.getTrait(lt).getValue();if(w===tn.image){this.removeAttributes([$o.name,Ui.name,jo]);const S=this.getTrait(qi.name);S.setValue(S.getValue()||c)}else w===tn.video?this.removeAttributes([jo]):w===tn.external&&this.addAttributes({[jo]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[jo]?this.set(lt,tn.external):(y[$o.name]||y[Ui.name])&&this.set(lt,tn.video)}}}),U({editor:n,plan:Mf,licenseKey:s.licenseKey,pluginName:Ml,cleanup:()=>{t.remove(Et),o.removeType(Et)}})},Ml),Ne="swiper",$n=`${Ne}-slide`,on=`${Ne}-wrapper`,rn=`${Ne}-nav-prev`,Po=`${Ne}-nav-next`,sn=`${Ne}-pagination`,Pn=`${Ne}-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,29 +96,29 @@
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>`},bl={id:"swiper-responsive",label:"Responsive",icon:le.responsive},vl={id:"swiper-extra",label:"Extra",icon:le.extra},Yu={actions:{type:"radio",label:!1,labelToTitle:!0,options:[{id:"r",label:"Reload slider",icon:le.reload},{id:"p",label:"Previous slide",icon:le.prev},{id:"n",label:"Next slide",icon:le.next},{id:"a",label:"Add new slide",icon:le.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(tn),setValue:({component:n,value:e})=>{var t,o;e?n.append([{type:tn},{type:Mo}]):((t=n.findFirstType(tn))==null||t.remove(),(o=n.findFirstType(Mo))==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:le.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:le.autoplay},type:"checkbox",label:"Enable Autoplay",value:!1,subTraits:{true:[{type:"checkbox",name:"autoplayEditor",label:"Autoplay in editor",tip:"Allow autoplay to run while editing in the canvas. Note: this may make selecting and editing slides difficult as they will automatically change.",changeProp:!0,value:!1},{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:le.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(nn)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(nn);t==null||t.remove(),e!=="none"&&n.append({type:nn}),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:le.scrollbar},type:"checkbox",label:"Enable Scrollbar",getValue:({component:n})=>!!n.findFirstType(An),setValue:({component:n,value:e})=>{const t=n.findFirstType(An);t==null||t.remove(),e&&n.append({type:An}),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:le.parallax},type:"checkbox",label:"Enable Parallax",value:!1},mobile:{category:bl,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:bl,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:vl,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:vl,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},Sl="Slider",Ws="swiper",on=`${Ws}-`,Xu=(n,e)=>{const{Components:t,Blocks:o,Commands:s}=n,{block:i}=e,r=Fp(Yu),l="core:preview",a=s.events,c=function(u){const h=this,f=window,m=h.__onLoad,g=h.__activeSlide,b=h.__inPreview,w=f._isEditor&&!b?u.autoplayEditor:!0,{cdnScript:y,cdnStyle:v,slidesPerView:C}=u||{},S=E=>isNaN(E)?void 0:parseFloat(E),x=()=>{const E=h.parentElement;E&&(E.style.minWidth="0");const k={loop:u.loop,speed:u.speed,initialSlide:u.initialSlide,direction:u.vertical?"vertical":"horizontal",effect:u.effect,freeMode:u.freeMode,parallax:u.parallax,autoHeight:u.autoHeight,allowTouchMove:u.allowTouchMove,grabCursor:u.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(C)?C:S(C),slidesPerGroup:S(u.slidesPerGroup),spaceBetween:S(u.spaceBetween),slidesOffsetBefore:S(u.slidesOffsetBefore),slidesOffsetAfter:S(u.slidesOffsetAfter),centeredSlides:u.centeredSlides,fadeEffect:{crossFade:u.crossFade},cubeEffect:{shadow:u.cubeEffectShadow,slideShadows:u.cubeEffectSlideShadows,shadowOffset:S(u.cubeEffectShadowOffset),shadowScale:S(u.cubeEffectShadowScale)},coverflowEffect:{depth:S(u.coverflowEffectDepth),modifier:S(u.coverflowEffectModifier),rotate:S(u.coverflowEffectRotate),scale:S(u.coverflowEffectScale),stretch:S(u.coverflowEffectStretch),slideShadows:u.coverflowEffectSlideShadows},flipEffect:{limitRotation:u.flipEffectLimitRotation,slideShadows:u.flipEffectSlideShadows},cardsEffect:{perSlideOffset:S(u.cardsEffectPerSlideOffset),perSlideRotate:S(u.cardsEffectPerSlideRotate),rotate:u.cardsEffectRotate,slideShadows:u.cardsEffectSlideShadows},navigation:{nextEl:h.querySelector(".swiper-button-next"),prevEl:h.querySelector(".swiper-button-prev")},pagination:{type:u.pagination||"bullets",dynamicBullets:u.dynamicBullets,clickable:u.clickableBullets,progressbarOpposite:u.progressbarOpposite,el:h.querySelector(".swiper-pagination")},scrollbar:{el:h.querySelector(".swiper-scrollbar"),draggable:u.scrollbarDraggable,hide:u.scrollbarHide},autoplay:u.autoplay&&w&&{delay:u.autoplayDelay,disableOnInteraction:u.autoplayDisableOnInteraction,pauseOnMouseEnter:u.autoplayPauseOnMouseEnter,reverseDirection:u.autoplayReverseDirection,stopOnLastSlide:u.autoplayStopOnLastSlide,waitForTransition:u.autoplayWaitForTransition}};if(u.tablet){const{tabletBreakpoint:P,tabletSlidesPerView:N}=u,O=S(P);k.breakpoints[O]={slidesPerView:isNaN(N)?N:S(N),slidesPerGroup:S(u.tabletSlidesPerGroup),spaceBetween:S(u.tabletSpaceBetween)}}if(u.mobile){const{mobileBreakpoint:P,mobileSlidesPerView:N}=u,O=S(P);k.breakpoints[O]={slidesPerView:isNaN(N)?N:S(N),slidesPerGroup:S(u.mobileSlidesPerGroup),spaceBetween:S(u.mobileSpaceBetween)}}m&&!b&&(k.simulateTouch=!1),g&&(k.initialSlide=g);const M=new f.Swiper(h,k);m==null||m(M)};if(f.Swiper)x();else{const{head:E}=document,k=Array.isArray(y)?[...y]:[y],M=Array.isArray(v)?[...v]:[v],P=O=>{if(O.length){const R=document.createElement("link");R.href=O.shift(),R.rel="stylesheet",E.prepend(R),P(O)}},N=O=>{if(O.length){const R=document.createElement("script");R.src=O.shift(),R.onerror=R.onload=N.bind(null,O),E.appendChild(R)}else x()};P(M),N(k)}},d=(u=0)=>({type:Mn,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${u}`}}}),p=t.getType("default").model;return t.addType(Ne,{block:i&&{label:Sl,media:le.slider,category:"Extra",select:!0,...e.block},isComponent:u=>ot(u,Ws),model:{defaults:()=>({name:Sl,icon:le.slider,classes:Ws,draggable:(u,h)=>!h.is(Ne),components:[{type:en,components:[d(1),d(2),d(3)]},{type:nn}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...r.propKeys],...r.props,traits:[...r.traits]}),init(){const{em:u}=this;_p(this,r.traits),Gp(this,r.propKeys),this.listenTo(u,`${a.runCommand}${l}`,this.onPreviewOn),this.listenTo(u,`${a.stopCommand}${l}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const u=this.findFirstType(en);u==null||u.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var h;const u=((h=this.findFirstType(en))==null?void 0:h.components().length)||0;return{type:Mn,components:{type:"text",components:{type:"textnode",content:`Slide ${u+1}`}}}},toJSON(...u){const h=p.prototype.toJSON.apply(this,u);return r.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 u;(u=this.getSwiper())==null||u.destroy()},onRender(){const u=this.el;u.__onLoad=h=>h.on("slideChange",()=>this.__activeSlide=h.activeIndex),u.__activeSlide=this.__activeSlide,u.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(Ne),o.remove(Ne)}},Qu="Nav Prev",eh="Nav Next",Ao=`${on}button-prev`,Po=`${on}button-next`,th=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(tn,{isComponent:o=>ot(o,Ao),model:{defaults:{name:Qu,classes:Ao,copyable:!1,highlightable:!1,droppable:!1,draggable:!1,selectable:!1,hoverable:!1,layerable:!1,components:t("M0,22L22,0l2.1,2.1L4.2,22l19.9,19.9L22,44L0,22L0,22L0,22z"),styles:`
100
- .${Ao} {
99
+ </svg>`},Dl={id:"swiper-responsive",label:"Responsive",icon:ce.responsive},zl={id:"swiper-extra",label:"Extra",icon:ce.extra},zf={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(rn),setValue:({component:n,value:e})=>{var t,o;e?n.append([{type:rn},{type:Po}]):((t=n.findFirstType(rn))==null||t.remove(),(o=n.findFirstType(Po))==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:"checkbox",name:"autoplayEditor",label:"Autoplay in editor",tip:"Allow autoplay to run while editing in the canvas. Note: this may make selecting and editing slides difficult as they will automatically change.",changeProp:!0,value:!1},{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(sn)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(sn);t==null||t.remove(),e!=="none"&&n.append({type:sn}),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(Pn),setValue:({component:n,value:e})=>{const t=n.findFirstType(Pn);t==null||t.remove(),e&&n.append({type:Pn}),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:zl,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:zl,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},Rl="Slider",Ki="swiper",ln=`${Ki}-`,Rf=(n,e)=>{const{Components:t,Blocks:o,Commands:i}=n,{block:r}=e,s=Pu(zf),l="core:preview",a=i.events,c=function(u){const f=this,h=window,g=f.__onLoad,b=f.__activeSlide,x=f.__inPreview,C=h._isEditor&&!x?u.autoplayEditor:!0,{cdnScript:y,cdnStyle:v,slidesPerView:k}=u||{},w=E=>isNaN(E)?void 0:parseFloat(E),S=()=>{const E=f.parentElement;E&&(E.style.minWidth="0");const T={loop:u.loop,speed:u.speed,initialSlide:u.initialSlide,direction:u.vertical?"vertical":"horizontal",effect:u.effect,freeMode:u.freeMode,parallax:u.parallax,autoHeight:u.autoHeight,allowTouchMove:u.allowTouchMove,grabCursor:u.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(k)?k:w(k),slidesPerGroup:w(u.slidesPerGroup),spaceBetween:w(u.spaceBetween),slidesOffsetBefore:w(u.slidesOffsetBefore),slidesOffsetAfter:w(u.slidesOffsetAfter),centeredSlides:u.centeredSlides,fadeEffect:{crossFade:u.crossFade},cubeEffect:{shadow:u.cubeEffectShadow,slideShadows:u.cubeEffectSlideShadows,shadowOffset:w(u.cubeEffectShadowOffset),shadowScale:w(u.cubeEffectShadowScale)},coverflowEffect:{depth:w(u.coverflowEffectDepth),modifier:w(u.coverflowEffectModifier),rotate:w(u.coverflowEffectRotate),scale:w(u.coverflowEffectScale),stretch:w(u.coverflowEffectStretch),slideShadows:u.coverflowEffectSlideShadows},flipEffect:{limitRotation:u.flipEffectLimitRotation,slideShadows:u.flipEffectSlideShadows},cardsEffect:{perSlideOffset:w(u.cardsEffectPerSlideOffset),perSlideRotate:w(u.cardsEffectPerSlideRotate),rotate:u.cardsEffectRotate,slideShadows:u.cardsEffectSlideShadows},navigation:{nextEl:f.querySelector(".swiper-button-next"),prevEl:f.querySelector(".swiper-button-prev")},pagination:{type:u.pagination||"bullets",dynamicBullets:u.dynamicBullets,clickable:u.clickableBullets,progressbarOpposite:u.progressbarOpposite,el:f.querySelector(".swiper-pagination")},scrollbar:{el:f.querySelector(".swiper-scrollbar"),draggable:u.scrollbarDraggable,hide:u.scrollbarHide},autoplay:u.autoplay&&C&&{delay:u.autoplayDelay,disableOnInteraction:u.autoplayDisableOnInteraction,pauseOnMouseEnter:u.autoplayPauseOnMouseEnter,reverseDirection:u.autoplayReverseDirection,stopOnLastSlide:u.autoplayStopOnLastSlide,waitForTransition:u.autoplayWaitForTransition}};if(u.tablet){const{tabletBreakpoint:$,tabletSlidesPerView:P}=u,N=w($);T.breakpoints[N]={slidesPerView:isNaN(P)?P:w(P),slidesPerGroup:w(u.tabletSlidesPerGroup),spaceBetween:w(u.tabletSpaceBetween)}}if(u.mobile){const{mobileBreakpoint:$,mobileSlidesPerView:P}=u,N=w($);T.breakpoints[N]={slidesPerView:isNaN(P)?P:w(P),slidesPerGroup:w(u.mobileSlidesPerGroup),spaceBetween:w(u.mobileSpaceBetween)}}g&&!x&&(T.simulateTouch=!1),b&&(T.initialSlide=b);const A=new h.Swiper(f,T);g==null||g(A)};if(h.Swiper)S();else{const{head:E}=document,T=Array.isArray(y)?[...y]:[y],A=Array.isArray(v)?[...v]:[v],$=N=>{if(N.length){const I=document.createElement("link");I.href=N.shift(),I.rel="stylesheet",E.prepend(I),$(N)}},P=N=>{if(N.length){const I=document.createElement("script");I.src=N.shift(),I.onerror=I.onload=P.bind(null,N),E.appendChild(I)}else S()};$(A),P(T)}},d=(u=0)=>({type:$n,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${u}`}}}),p=t.getType("default").model;return t.addType(Ne,{block:r&&{label:Rl,media:ce.slider,category:"Extra",select:!0,...e.block},isComponent:u=>st(u,Ki),model:{defaults:()=>({name:Rl,icon:ce.slider,classes:Ki,draggable:(u,f)=>!f.is(Ne),components:[{type:on,components:[d(1),d(2),d(3)]},{type:sn}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...s.propKeys],...s.props,traits:[...s.traits]}),init(){const{em:u}=this;Nu(this,s.traits),Ou(this,s.propKeys),this.listenTo(u,`${a.runCommand}${l}`,this.onPreviewOn),this.listenTo(u,`${a.stopCommand}${l}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const u=this.findFirstType(on);u==null||u.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var f;const u=((f=this.findFirstType(on))==null?void 0:f.components().length)||0;return{type:$n,components:{type:"text",components:{type:"textnode",content:`Slide ${u+1}`}}}},toJSON(...u){const f=p.prototype.toJSON.apply(this,u);return s.propsNoValues.forEach(h=>delete f[h]),delete f["script-props"],f}},view:{init(){this.listenTo(this.model,t.events.scriptUnmount,this.destroySwiper)},getSwiper(){return this.el.swiper},destroySwiper(){var u;(u=this.getSwiper())==null||u.destroy()},onRender(){const u=this.el;u.__onLoad=f=>f.on("slideChange",()=>this.__activeSlide=f.activeIndex),u.__activeSlide=this.__activeSlide,u.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(Ne),o.remove(Ne)}},Lf="Nav Prev",Bf="Nav Next",No=`${ln}button-prev`,Oo=`${ln}button-next`,Vf=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(rn,{isComponent:o=>st(o,No),model:{defaults:{name:Lf,classes:No,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
+ .${No} {
101
101
  color: inherit;
102
102
  }
103
- .${Ao}:after {
103
+ .${No}:after {
104
104
  content: none;
105
105
  }
106
- `}}}),e.addType(Mo,{extend:tn,isComponent:o=>ot(o,Po),model:{defaults:{name:eh,classes:Po,components:t("M27,22L27,22L5,44l-2.1-2.1L22.8,22L2.9,2.1L5,0L27,22L27,22z"),styles:`
107
- .${Po} {
106
+ `}}}),e.addType(Po,{extend:rn,isComponent:o=>st(o,Oo),model:{defaults:{name:Bf,classes:Oo,components:t("M27,22L27,22L5,44l-2.1-2.1L22.8,22L2.9,2.1L5,0L27,22L27,22z"),styles:`
107
+ .${Oo} {
108
108
  color: inherit;
109
109
  }
110
- .${Po}:after {
110
+ .${Oo}:after {
111
111
  content: none;
112
112
  }
113
- `}}}),()=>{e.removeType(tn),e.removeType(Mo)}},nh=n=>{const{Components:e}=n,t=`${on}pagination`;return e.addType(nn,{isComponent:o=>ot(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(rn),e.removeType(Po)}},Hf=n=>{const{Components:e}=n,t=`${ln}pagination`;return e.addType(sn,{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(nn)}},oh="Scrollbar",xl=`${on}scrollbar`,sh=n=>{const{Components:e}=n;return e.addType(An,{isComponent:t=>ot(t,xl),model:{defaults:{name:oh,classes:xl,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{e.removeType(An)}},ih="Slide",wl=`${on}slide`,rh=n=>{const{Components:e}=n;return e.addType(Mn,{isComponent:t=>ot(t,wl),model:{defaults:{name:ih,classes:wl,icon:le.slider,draggable:(t,o)=>o.is(en)}}}),()=>{e.removeType(Mn)}},lh="Wrapper",Cl=`${on}wrapper`,ah=n=>{const{Components:e}=n,{events:t}=e;return e.addType(en,{isComponent:o=>ot(o,Cl),model:{defaults:{name:lh,icon:le.slider,classes:Cl,copyable:!1,removable:!1,draggable:!1,highlightable:!1,droppable:o=>o.is(Mn)},init(){const o=this.components();this.listenTo(o,"add remove",this.updateSlider)},updateSlider(o){const s=this.closestType(Ne);if(s){const i=s.getView();s.reloadSlider(),this.em.once(t.scriptMount,()=>{setTimeout(()=>{var r;return(r=i.getSwiper())==null?void 0:r.slideTo(o.index())},100)})}}}}),()=>{e.removeType(en)}},ch="swiperComponent",dh=F.startup,ph=W(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=[Xu(n,t),th(n),ah(n),rh(n),nh(n),sh(n)];j({editor:n,plan:dh,licenseKey:t.licenseKey,pluginName:ch,cleanup:()=>{o.forEach(s=>s())}})}),me="accordion",Pn=`${me}-group`,Je=`${me}-header`,it=`${me}-content`,Tt=`${me}-marker`,kl=`${ke}${Je}`,js=`${ke}${Tt}`,uh=`${ke}${it}`,El=`${js}-open`,Mt={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>'},Tl=(n,e)=>{const{toolbarIconOpen:t=Mt.eye}=e,o=n.is(me)?n:n.closestType(me);if(!t||!o)return;const{toolbar:s}=n,i={id:"accordion-toggle-open",label:t,command:()=>o.toggleOpen()};!s.find(l=>l.id===i.id)&&(s==null||s.unshift(i))},hh=(n,e)=>{const{Components:t,Blocks:o}=n,{block:s={}}=e,i="Accordion",r=`${ke}${me}`,l=function(a={}){const c=this,d=()=>{const{clsMarkerOpen:p}=a,u=c.querySelector('[data-type-role="accordion-marker"]');!u||!p||(c.open?u.classList.add(p):u.classList.remove(p))};c.addEventListener("toggle",()=>{d(),c.dispatchEvent(new CustomEvent("details-toggle",{bubbles:!0}))}),d()};return t.addType(me,{block:s&&{label:i,media:Mt.accordion,category:"Extra",select:!0,...s},isComponent:$e(me),extendFn:["initToolbar"],model:{defaults:{tagName:"details",name:i,classes:r,emptyState:!0,clsMarkerOpen:El,attributes:{[Pe]:me},droppable:mo(Je,it),components:[{type:Je},{type:it}],"script-props":["clsMarkerOpen"],script:l,traits:[{type:"checkbox",name:"open",label:"Open"}],styles:`
121
- .${r}::details-content {
120
+ `}}}),()=>{e.removeType(sn)}},Ff="Scrollbar",Ll=`${ln}scrollbar`,_f=n=>{const{Components:e}=n;return e.addType(Pn,{isComponent:t=>st(t,Ll),model:{defaults:{name:Ff,classes:Ll,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{e.removeType(Pn)}},Gf="Slide",Bl=`${ln}slide`,Wf=n=>{const{Components:e}=n;return e.addType($n,{isComponent:t=>st(t,Bl),model:{defaults:{name:Gf,classes:Bl,icon:ce.slider,draggable:(t,o)=>o.is(on)}}}),()=>{e.removeType($n)}},qf="Wrapper",Vl=`${ln}wrapper`,Uf=n=>{const{Components:e}=n,{events:t}=e;return e.addType(on,{isComponent:o=>st(o,Vl),model:{defaults:{name:qf,icon:ce.slider,classes:Vl,copyable:!1,removable:!1,draggable:!1,highlightable:!1,droppable:o=>o.is($n)},init(){const o=this.components();this.listenTo(o,"add remove",this.updateSlider)},updateSlider(o){const i=this.closestType(Ne);if(i){const r=i.getView();i.reloadSlider(),this.em.once(t.scriptMount,()=>{setTimeout(()=>{var s;return(s=r.getSwiper())==null?void 0:s.slideTo(o.index())},100)})}}}}),()=>{e.removeType(on)}},Hl="swiperComponent",Kf=F.startup,Jf=q(function(n,e={}){const t={block:{},cdnScript:"https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js",cdnStyle:"https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css",...e},o=[Rf(n,t),Vf(n),Uf(n),Wf(n),Hf(n),_f(n)];U({editor:n,plan:Kf,licenseKey:t.licenseKey,pluginName:Hl,cleanup:()=>{o.forEach(i=>i())}})},Hl),be="accordion",Nn=`${be}-group`,Xe=`${be}-header`,at=`${be}-content`,At=`${be}-marker`,Fl=`${Ee}${Xe}`,Ji=`${Ee}${At}`,Yf=`${Ee}${at}`,_l=`${Ji}-open`,jt={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>'},Gl=(n,e)=>{const{toolbarIconOpen:t=jt.eye}=e,o=n.is(be)?n:n.closestType(be);if(!t||!o)return;const{toolbar:i}=n,r={id:"accordion-toggle-open",label:t,command:()=>o.toggleOpen()};!i.find(l=>l.id===r.id)&&(i==null||i.unshift(r))},Zf=(n,e)=>{const{Components:t,Blocks:o}=n,{block:i={}}=e,r="Accordion",s=`${Ee}${be}`,l=function(a={}){const c=this,d=()=>{const{clsMarkerOpen:p}=a,u=c.querySelector('[data-type-role="accordion-marker"]');!u||!p||(c.open?u.classList.add(p):u.classList.remove(p))};c.addEventListener("toggle",()=>{d(),c.dispatchEvent(new CustomEvent("details-toggle",{bubbles:!0}))}),d()};return t.addType(be,{block:i&&{label:r,media:jt.accordion,category:"Extra",select:!0,...i},isComponent:Be(be),extendFn:["initToolbar"],model:{defaults:{tagName:"details",name:r,classes:s,emptyState:!0,clsMarkerOpen:_l,attributes:{[Pe]:be},droppable:xo(Xe,at),components:[{type:Xe},{type:at}],"script-props":["clsMarkerOpen"],script:l,traits:[{type:"checkbox",name:"open",label:"Open"}],styles:`
121
+ .${s}::details-content {
122
122
  opacity: 0;
123
123
  block-size: 0;
124
124
  overflow: hidden;
@@ -129,55 +129,55 @@
129
129
  transition-duration: 0.2s;
130
130
  }
131
131
 
132
- .${r}[open]::details-content {
132
+ .${s}[open]::details-content {
133
133
  opacity: 1;
134
134
  transform: translateY(0);
135
135
  block-size: auto;
136
136
  }
137
- `},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){Tl(this,e)}}}),()=>{o.remove(me),t.removeType(me)}},fh=n=>{const{Components:e}=n;return e.addType(it,{isComponent:$e(it),model:{defaults:{name:"Accordion Content",removable:!1,copyable:!1,draggable:!1,emptyState:!0,classes:uh,icon:Mt.accordionContent,attributes:{[Pe]:it},components:"<div>Accordion content</div>"}}}),()=>{e.removeType(it)}},mh=(n,e)=>{const{Components:t,Blocks:o}=n,{blockGroup:s={}}=e,i="Accordion Group",r=function(a={}){if(!a.single)return;const c=this;c.addEventListener("details-toggle",d=>{const p=d.target;if(!a.single||!p||!p.open)return;c.querySelectorAll('[data-type-role="accordion"]').forEach(h=>{p!==h&&h.open&&(h.open=!1)})})},l=(a={})=>({type:me,attributes:{open:a.open},components:[{type:Je,components:[`<div>${a.header}</div>`,{type:Tt}]},{type:it,components:`<div>${a.content}</div>`}]});return t.addType(Pn,{block:s&&{label:i,media:Mt.accordionGroup,category:"Extra",select:!0,...s},isComponent:$e(Pn),model:{defaults:{name:i,attributes:{[Pe]:Pn},droppable:mo(me),single:!0,emptyState:!0,components:Array(3).fill(0).map((a,c)=>l({open:c===0,header:`Accordion header ${c+1}`,content:`Accordion content ${c+1}`})),traits:[{type:"checkbox",name:"single",changeProp:!0,tip:"Only one accordion can be open at a time",label:"Single open"}],"script-props":["single"],script:r}}}),()=>{o.remove(Pn),t.removeType(Pn)}},gh=(n,e)=>{const{Components:t}=n;return t.addType(Je,{isComponent:$e(Je),extendFn:["initToolbar"],model:{defaults:{tagName:"summary",name:"Accordion Header",removable:!1,copyable:!1,draggable:!1,emptyState:!0,icon:Mt.accordionHeader,classes:kl,attributes:{[Pe]:Je},components:["<div>Accordion header</div>",{type:Tt}],styles:`
137
+ `},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){Gl(this,e)}}}),()=>{o.remove(be),t.removeType(be)}},Xf=n=>{const{Components:e}=n;return e.addType(at,{isComponent:Be(at),model:{defaults:{name:"Accordion Content",removable:!1,copyable:!1,draggable:!1,emptyState:!0,classes:Yf,icon:jt.accordionContent,attributes:{[Pe]:at},components:"<div>Accordion content</div>"}}}),()=>{e.removeType(at)}},Qf=(n,e)=>{const{Components:t,Blocks:o}=n,{blockGroup:i={}}=e,r="Accordion Group",s=function(a={}){if(!a.single)return;const c=this;c.addEventListener("details-toggle",d=>{const p=d.target;if(!a.single||!p||!p.open)return;c.querySelectorAll('[data-type-role="accordion"]').forEach(f=>{p!==f&&f.open&&(f.open=!1)})})},l=(a={})=>({type:be,attributes:{open:a.open},components:[{type:Xe,components:[`<div>${a.header}</div>`,{type:At}]},{type:at,components:`<div>${a.content}</div>`}]});return t.addType(Nn,{block:i&&{label:r,media:jt.accordionGroup,category:"Extra",select:!0,...i},isComponent:Be(Nn),model:{defaults:{name:r,attributes:{[Pe]:Nn},droppable:xo(be),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:s}}}),()=>{o.remove(Nn),t.removeType(Nn)}},eh=(n,e)=>{const{Components:t}=n;return t.addType(Xe,{isComponent:Be(Xe),extendFn:["initToolbar"],model:{defaults:{tagName:"summary",name:"Accordion Header",removable:!1,copyable:!1,draggable:!1,emptyState:!0,icon:jt.accordionHeader,classes:Fl,attributes:{[Pe]:Xe},components:["<div>Accordion header</div>",{type:At}],styles:`
138
138
  summary {
139
139
  list-style: none;
140
140
  }
141
- .${kl} {
141
+ .${Fl} {
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(){Tl(this,e)}}}),()=>{t.removeType(Je)}},yh=n=>{const{Components:e}=n;return e.addType(Tt,{extend:"icon",isComponent:$e(Tt),model:{defaults:{name:"Accordion Marker",icon:Mt.accordionMarker,classes:js,attributes:{[Pe]:Tt},components:Mt.caret,droppable:!1,draggable:Ms(Je),styles:`
149
- .${js} {
148
+ `},initToolbar(){Gl(this,e)}}}),()=>{t.removeType(Xe)}},th=n=>{const{Components:e}=n;return e.addType(At,{extend:"icon",isComponent:Be(At),model:{defaults:{name:"Accordion Marker",icon:jt.accordionMarker,classes:Ji,attributes:{[Pe]:At},components:jt.caret,droppable:!1,draggable:Pi(Xe),styles:`
149
+ .${Ji} {
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
- .${El} {
155
+ .${_l} {
156
156
  transform: rotateZ(180deg);
157
157
  }
158
- `}}}),()=>{e.removeType(Tt)}},bh="accordionComponent",vh=F.startup,Sh=W(function(n,e={}){const t=[hh(n,e),mh(n,e),gh(n,e),yh(n),fh(n)];j({editor:n,licenseKey:e.licenseKey,plan:vh,pluginName:bh,cleanup:()=>{t.forEach(o=>o())}})}),po=class po{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):Ys(e.componentColumn,po.CSS_FLEX_BASIS)}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:o,sizeValue:s,partial:i}=e;o.addStyle({[po.CSS_FLEX_BASIS]:s},{partial:i})}}};po.CSS_FLEX_BASIS="flex-basis";let qs=po;const uo=class uo{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):Ys(e.componentRow,uo.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:o,gapValue:s,partial:i}=e;o.addStyle({[uo.CSS_GAP]:s},{partial:i})}}};uo.CSS_GAP="gap";let Us=uo;const xs=class xs{constructor(e){this.config=e}getParentSize(e){var i;if((i=this.config)!=null&&i.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:o}=e,s=t.getEl();return s?o?s.clientHeight:s.clientWidth:0}isLayoutVertical(e){var o;if((o=this.config)!=null&&o.isParentVertical)return this.config.isParentVertical(e);const t=Ys(e.componentRow,xs.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};xs.CSS_FLEX_DIRECTION="flex-direction";let Ks=xs;const ho=class ho{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(ho.MJML_COLUMN_TYPE)){const i=t.getAttributes().width;if(i&&(i.includes("%")||!isNaN(parseFloat(i))))return parseFloat(i);const r=t.parent();return 100/(r?r.components().length:1)}return 0}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:o,sizeValue:s,partial:i}=e;o.is(ho.MJML_COLUMN_TYPE)&&o.addAttributes({width:`${parseFloat(s)}%`},{partial:i})}}};ho.MJML_COLUMN_TYPE="mj-column";let Js=ho;const ws=class ws{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(ws.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)}};ws.MJML_SECTION_TYPE="mj-section";let Zs=ws;class xh{constructor(e){this.config=e}getParentSize(e){var r;if((r=this.config)!=null&&r.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:o}=e,s=t.getEl();if(!s)return 0;let i=s;if(s.tagName!=="TABLE"){const l=s.querySelectorAll("table");l.length&&(i=l[0])}return o?i.clientHeight:i.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class sn{constructor(){this.handlerCache=new Map}static getInstance(){return sn.instance||(sn.instance=new sn),sn.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(rn(e)?this.handlerCache.set(t,{sizeHandler:new Js(e),gapHandler:new Zs(e),parentSizeHandler:new xh(e)}):this.handlerCache.set(t,{sizeHandler:new qs(e),gapHandler:new Us(e),parentSizeHandler:new Ks(e)})),this.handlerCache.get(t)}}function At(n){return sn.getInstance().getHandlers(n)}const Ml=n=>{n.style.display="none"},Al=n=>{n.style.display="block"},Nn=n=>+parseFloat(`${n}`).toFixed(2),rn=n=>n.projectType===Ir.email,wh=n=>n?["top","bottom"]:["left","right"],Ch=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},kh=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},Eh=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},Th=(n,e,t,o)=>{const i=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return i>=0&&i<o?i:-1},No=n=>n==="top"||n==="bottom",Mh=(n,e)=>!!(Ch(n)&&(e==="left"||e==="top")||kh(n)&&(e==="right"||e==="bottom")),Ah=n=>{const e=n.parent();return e?e.components().models.length>1:!1},Pl=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,Ys=(n,e,t=!1)=>{const o=!t,s=n.getEl();if(!s)return o?0:"";const r=window.getComputedStyle(s)[e]||"";if(o){let l;return typeof r=="string"?(l=parseFloat(r.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(r)||0,l}return r},Nl=(n,e,t)=>{const o=Xs({componentRow:n,isVertical:e},t),s=n.components().models;return o*(s.length-1)},On=(n,e)=>At(e).parentSizeHandler.isLayoutVertical({componentRow:n}),In=(n,e)=>At(e).sizeHandler.getSize(n),Xs=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:o}=At(e);if(!t.isGapSupported())return 0;const s=t.getGap(n),i=o.getParentSize(n);return s/100*i},Qs=(n,e)=>At(e).parentSizeHandler.getParentSize(n),Rn=(n,e)=>{At(e).sizeHandler.setSize(n)},Ol=(n,e)=>{const t=In(n,e);Rn({...n,sizeValue:`${t}%`,partial:!1},e)},Il=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=At(e);t.isGapSupported()&&t.setGap(n)},Ph=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const o=n.components().models,s={componentRow:n,isVertical:On(n,e)};o.map(i=>Ol({...s,componentColumn:i},e)),Il({...s,gapValue:String(t),partial:!1},e)};function Nh(n,e){const{Blocks:t}=n,{typeColumn:o,typeRow:s,blocks:i}=e;if(i===!1||rn(e))return;const r=p=>({type:s,components:p.map(u=>({type:o,style:{"flex-basis":`${u}%`}}))}),l=p=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
158
+ `}}}),()=>{e.removeType(At)}},Wl="accordionComponent",nh=F.startup,oh=q(function(n,e={}){const t=[Zf(n,e),Qf(n,e),eh(n,e),th(n),Xf(n)];U({editor:n,licenseKey:e.licenseKey,plan:nh,pluginName:Wl,cleanup:()=>{t.forEach(o=>o())}})},Wl),mo=class mo{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):tr(e.componentColumn,mo.CSS_FLEX_BASIS)}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:o,sizeValue:i,partial:r}=e;o.addStyle({[mo.CSS_FLEX_BASIS]:i},{partial:r})}}};mo.CSS_FLEX_BASIS="flex-basis";let Yi=mo;const go=class go{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):tr(e.componentRow,go.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:o,gapValue:i,partial:r}=e;o.addStyle({[go.CSS_GAP]:i},{partial:r})}}};go.CSS_GAP="gap";let Zi=go;const Ti=class Ti{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,i=t.getEl();return i?o?i.clientHeight:i.clientWidth:0}isLayoutVertical(e){var o;if((o=this.config)!=null&&o.isParentVertical)return this.config.isParentVertical(e);const t=tr(e.componentRow,Ti.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};Ti.CSS_FLEX_DIRECTION="flex-direction";let Xi=Ti;const bo=class bo{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(bo.MJML_COLUMN_TYPE)){const r=t.getAttributes().width;if(r&&(r.includes("%")||!isNaN(parseFloat(r))))return parseFloat(r);const s=t.parent();return 100/(s?s.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:i,partial:r}=e;o.is(bo.MJML_COLUMN_TYPE)&&o.addAttributes({width:`${parseFloat(i)}%`},{partial:r})}}};bo.MJML_COLUMN_TYPE="mj-column";let Qi=bo;const Ei=class Ei{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(Ei.MJML_SECTION_TYPE)){const i=t.getAttributes();if(i&&i.padding)return parseInt(i.padding,10)||0}return 0}setGap(e){var t,o;(o=(t=this.config)==null?void 0:t.setGap)==null||o.call(t,e)}};Ei.MJML_SECTION_TYPE="mj-section";let er=Ei;class ih{constructor(e){this.config=e}getParentSize(e){var s;if((s=this.config)!=null&&s.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:o}=e,i=t.getEl();if(!i)return 0;let r=i;if(i.tagName!=="TABLE"){const l=i.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 an{constructor(){this.handlerCache=new Map}static getInstance(){return an.instance||(an.instance=new an),an.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(cn(e)?this.handlerCache.set(t,{sizeHandler:new Qi(e),gapHandler:new er(e),parentSizeHandler:new ih(e)}):this.handlerCache.set(t,{sizeHandler:new Yi(e),gapHandler:new Zi(e),parentSizeHandler:new Xi(e)})),this.handlerCache.get(t)}}function $t(n){return an.getInstance().getHandlers(n)}const ql=n=>{n.style.display="none"},Ul=n=>{n.style.display="block"},On=n=>+parseFloat(`${n}`).toFixed(2),cn=n=>n.projectType===_s.email,rh=n=>n?["top","bottom"]:["left","right"],sh=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},lh=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},ah=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},ch=(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},Io=n=>n==="top"||n==="bottom",dh=(n,e)=>!!(sh(n)&&(e==="left"||e==="top")||lh(n)&&(e==="right"||e==="bottom")),ph=n=>{const e=n.parent();return e?e.components().models.length>1:!1},Kl=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,tr=(n,e,t=!1)=>{const o=!t,i=o?0:"",r=n.getEl();let s;try{s=r?window.getComputedStyle(r):void 0}catch{s=void 0}if(!s)return i;const l=s[e]||"";if(o){let a;return typeof l=="string"?(a=parseFloat(l.replace(/[^-\d.]/g,"")),isNaN(a)&&(a=0)):a=Number(l)||0,a}return l},Jl=(n,e,t)=>{const o=nr({componentRow:n,isVertical:e},t),i=n.components().models;return o*(i.length-1)},In=(n,e)=>$t(e).parentSizeHandler.isLayoutVertical({componentRow:n}),Dn=(n,e)=>$t(e).sizeHandler.getSize(n),nr=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:o}=$t(e);if(!t.isGapSupported())return 0;const i=t.getGap(n),r=o.getParentSize(n);return i/100*r},or=(n,e)=>$t(e).parentSizeHandler.getParentSize(n),zn=(n,e)=>{$t(e).sizeHandler.setSize(n)},Yl=(n,e)=>{const t=Dn(n,e);zn({...n,sizeValue:`${t}%`,partial:!1},e)},Zl=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=$t(e);t.isGapSupported()&&t.setGap(n)},uh=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const o=n.components().models,i={componentRow:n,isVertical:In(n,e)};o.map(r=>Yl({...i,componentColumn:r},e)),Zl({...i,gapValue:String(t),partial:!1},e)};function fh(n,e){const{Blocks:t}=n,{typeColumn:o,typeRow:i,blocks:r}=e;if(r===!1||cn(e))return;const s=p=>({type:i,components:p.map(u=>({type:o,style:{"flex-basis":`${u}%`}}))}),l=p=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
159
159
  ${p.map(u=>`<div style="flex-basis: ${u}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
160
- </div>`,a=(p,u)=>({id:`flex-row-${u.join("-")}`,label:p,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(u),content:r(u)}),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=xt(i)?i({blocks:c}):c;return d.forEach(p=>t.add(p.id,p)),()=>{d.forEach(p=>t.remove(p.id))}}const Oh=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:s,extendTypeColumn:i}=e,r=`${ke}${s}`,a=!!s&&!!t.getType(s)&&!i;if(!(!s||a||rn(e)))return t.addType(s,{isComponent:$e(s),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:r,icon:'<svg viewBox="0 0 24 24"><path d="M14.5 2.3A1.8 1.8 0 0 0 12.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8zm-8 0A1.8 1.8 0 0 0 4.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',draggable:Ms(o),attributes:{[Pe]:s},styles:`
161
- .${r} {
160
+ </div>`,a=(p,u)=>({id:`flex-row-${u.join("-")}`,label:p,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(u),content:s(u)}),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=Le(r)?r({blocks:c}):c;return d.forEach(p=>t.add(p.id,p)),()=>{d.forEach(p=>t.remove(p.id))}}const hh=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:i,extendTypeColumn:r}=e,s=`${Ee}${i}`,a=!!i&&!!t.getType(i)&&!r;if(!(!i||a||cn(e)))return t.addType(i,{isComponent:Be(i),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:s,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:Pi(o),attributes:{[Pe]:i},styles:`
161
+ .${s} {
162
162
  flex-grow: 1;
163
163
  }
164
- `}}}),()=>{t.removeType(s)}},Ih=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:s,extendTypeRow:i}=e,r=`${ke}${o}`,a=!!o&&!!t.getType(o)&&!i;if(!(!o||a||rn(e)))return t.addType(o,{isComponent:$e(o),model:{defaults:{name:"Row",classes:r,icon:'<svg viewBox="0 0 24 24"><path d="M4 4.8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3A1.8 1.8 0 0 0 20 4.7zm0 8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',emptyState:{styleIn:"width: 100%"},attributes:{[Pe]:o},droppable:mo(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
- .${r} {
164
+ `}}}),()=>{t.removeType(i)}},mh=(n,e)=>{const{Components:t}=n,{typeRow:o,typeColumn:i,extendTypeRow:r}=e,s=`${Ee}${o}`,a=!!o&&!!t.getType(o)&&!r;if(!(!o||a||cn(e)))return t.addType(o,{isComponent:Be(o),model:{defaults:{name:"Row",classes:s,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:{[Pe]:o},droppable:xo(i),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
+ .${s} {
166
166
  display: flex;
167
167
  align-items: stretch;
168
168
  flex-wrap: nowrap;
169
169
  }
170
- `}}}),()=>{t.removeType(o)}},Rh="flexComponent",Dh=F.startup;class Lh{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 $h{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o,this.resizeState=new WeakMap}getState(e){return this.resizeState.has(e)||this.resizeState.set(e,{}),this.resizeState.get(e)}clearState(e){return this.resizeState.delete(e)}startResize(e,t,o){const{opts:s}=this,i=this.getState(e);i.direction=t,i.startX=o.clientX,i.startY=o.clientY,i.resizing=!0,i.lastSnappedPercent=void 0;const r=e.parent();if(!r||!this.registry.isValidRelationship(r,e))return;i.snapEnabled=r.get("snap")??s.snapEnabled,i.snapDivisions=r.get("snap-divisions")??s.snapDivisions??12;const l=r.components().models,a=l.findIndex(u=>u.cid===e.cid),c=On(r,s),d=Th(a,t,c,l.length);d!==-1&&(i.adjacentIdx=d);const p={componentColumn:e,componentRow:r,isVertical:c};if(i.startPercent=In(p,s),typeof i.adjacentIdx<"u"){const u=l[i.adjacentIdx];i.neighborStartPercent=In({...p,componentColumn:u},s)}}updateResizeByDelta(e,t,o){const s=this.getState(e),i=e.parent();!s.resizing||!i||(s.snapEnabled?this.updateSnapResize(e,t,o):this.updateContinuesResize(e,t,o))}finishResize(e){const t=e.parent(),o=t==null?void 0:t.components().models,s={componentRow:t,isVertical:!!t&&On(t,this.opts)};o==null||o.forEach(i=>Ol({...s,componentColumn:i},this.opts)),this.clearState(e)}updateContinuesResize(e,t,o){const s=this.getState(e),i=e.parent(),{opts:r}=this;if(!i)return;const l=r.minItemPercent??0,a=No(t),c=Qs({componentRow:i,isVertical:a},r),d=Nl(i,a,this.opts),u=100-d/c*100,h=o/(c-d)*u,{startPercent:f=0,neighborStartPercent:m=0}=s,g={componentRow:i,isVertical:a,componentColumn:e,partial:!0},b=Pl(t,o)?f+Math.abs(h):f-Math.abs(h);if(typeof s.adjacentIdx<"u"){const w=i.components().models[s.adjacentIdx],y=f+m,v=y-l,S=Math.min(v,Math.max(l,b)),x=y-S;Rn({...g,sizeValue:`${Nn(S)}%`},r),Rn({...g,componentColumn:w,sizeValue:`${Nn(x)}%`},r)}else{const w=Math.max(l,Math.min(u,b));Rn({...g,sizeValue:`${Nn(w)}%`},r)}}updateSnapResize(e,t,o){const s=this.getState(e),i=e.parent(),r=No(t),l=Qs({componentRow:i,isVertical:r},this.opts),a=Nl(i,r,this.opts),c=l-a,d=o/c*100,p=Pl(t,o),{startPercent:u=0,snapDivisions:h=12}=s,f=p?u+Math.abs(d):u-Math.abs(d),m=100/h,g=Math.floor(f/m)*m,b=Math.ceil(f/m)*m,w=Math.abs(b-f),y=Math.abs(f-g),v=m*.2,C=w<y?b:g;if(C>0&&C<100&&(w<v||y<v)&&s.lastSnappedPercent!==C){s.lastSnappedPercent=C;let E=Math.abs(C-u)/100*c;(p&&(t==="left"||t==="top")||!p&&(t==="right"||t==="bottom"))&&(E=-E),this.updateContinuesResize(e,t,E)}else w>=v&&y>=v&&(s.lastSnappedPercent=void 0)}}class zh{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o}updateGapByDelta(e,t,o,s){if(!this.registry.isGapAdjustableParent(e))return;const{opts:i}=this,r=Math.max(0,o+t),l=Qs({componentRow:e,isVertical:s},i),a=r/l*100,c=e.components().models,d=c.length-1,p={componentRow:e,isVertical:s},u=c.reduce((v,C)=>v+In({...p,componentColumn:C},i),0),f=100-a*d,m=i.minItemPercent||5;if(f<m*c.length)return;const b=100-d*a,w=u-b,y={componentRow:e,isVertical:s,partial:!0};c.map(v=>{const C=In({...p,componentColumn:v},i),S=C-C/u*w;Rn({...y,componentColumn:v,sizeValue:`${Nn(S)}%`},i)}),Il({...y,gapValue:`${Nn(a)}%`},i)}finishGapAdjust(e){Ph(e,this.opts)}}class Bh{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o,this.resizeHandler=new $h(e,t,o),this.gapHandler=new zh(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 Oo="gs-flex-spots",Rl=`${Oo}__handle-size`,Vh=`${Oo}__handle-gap`;function Hh(n,e){const{Canvas:t}=n,o="flex-resize-spot";let s,i,r,l,a=null,c=null;const d=new Lh,p=new Bh(n,d,e),u=()=>{var S;s=document.createElement("div"),s.className=Oo,s.style.display="none",i=document.createElement("div"),i.className=`${Oo}__handles`,i.style.position="absolute",i.style.pointerEvents="none",i.style.zIndex="21",r={left:document.createElement("div"),right:document.createElement("div"),top:document.createElement("div"),bottom:document.createElement("div")},Object.entries(r).forEach(([x,E])=>{const k=x,M=No(k);E.className=`${Rl} ${Rl}-${k} gjs-resizer-h gjs-cv-unscale`,E.style.cssText=`
170
+ `}}}),()=>{t.removeType(o)}},Xl="flexComponent",gh=F.startup;class bh{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"),i=t.get("type");return this.typeRelationships.has(o)?this.typeRelationships.get(o).has(i):!1}}class yh{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:i}=this,r=this.getState(e);r.direction=t,r.startX=o.clientX,r.startY=o.clientY,r.resizing=!0,r.lastSnappedPercent=void 0;const s=e.parent();if(!s||!this.registry.isValidRelationship(s,e))return;r.snapEnabled=s.get("snap")??i.snapEnabled,r.snapDivisions=s.get("snap-divisions")??i.snapDivisions??12;const l=s.components().models,a=l.findIndex(u=>u.cid===e.cid),c=In(s,i),d=ch(a,t,c,l.length);d!==-1&&(r.adjacentIdx=d);const p={componentColumn:e,componentRow:s,isVertical:c};if(r.startPercent=Dn(p,i),typeof r.adjacentIdx<"u"){const u=l[r.adjacentIdx];r.neighborStartPercent=Dn({...p,componentColumn:u},i)}}updateResizeByDelta(e,t,o){const i=this.getState(e),r=e.parent();!i.resizing||!r||(i.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,i={componentRow:t,isVertical:!!t&&In(t,this.opts)};o==null||o.forEach(r=>Yl({...i,componentColumn:r},this.opts)),this.clearState(e)}updateContinuesResize(e,t,o){const i=this.getState(e),r=e.parent(),{opts:s}=this;if(!r)return;const l=s.minItemPercent??0,a=Io(t),c=or({componentRow:r,isVertical:a},s),d=Jl(r,a,this.opts),u=100-d/c*100,f=o/(c-d)*u,{startPercent:h=0,neighborStartPercent:g=0}=i,b={componentRow:r,isVertical:a,componentColumn:e,partial:!0},x=Kl(t,o)?h+Math.abs(f):h-Math.abs(f);if(typeof i.adjacentIdx<"u"){const C=r.components().models[i.adjacentIdx],y=h+g,v=y-l,w=Math.min(v,Math.max(l,x)),S=y-w;zn({...b,sizeValue:`${On(w)}%`},s),zn({...b,componentColumn:C,sizeValue:`${On(S)}%`},s)}else{const C=Math.max(l,Math.min(u,x));zn({...b,sizeValue:`${On(C)}%`},s)}}updateSnapResize(e,t,o){const i=this.getState(e),r=e.parent(),s=Io(t),l=or({componentRow:r,isVertical:s},this.opts),a=Jl(r,s,this.opts),c=l-a,d=o/c*100,p=Kl(t,o),{startPercent:u=0,snapDivisions:f=12}=i,h=p?u+Math.abs(d):u-Math.abs(d),g=100/f,b=Math.floor(h/g)*g,x=Math.ceil(h/g)*g,C=Math.abs(x-h),y=Math.abs(h-b),v=g*.2,k=C<y?x:b;if(k>0&&k<100&&(C<v||y<v)&&i.lastSnappedPercent!==k){i.lastSnappedPercent=k;let E=Math.abs(k-u)/100*c;(p&&(t==="left"||t==="top")||!p&&(t==="right"||t==="bottom"))&&(E=-E),this.updateContinuesResize(e,t,E)}else C>=v&&y>=v&&(i.lastSnappedPercent=void 0)}}class xh{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o}updateGapByDelta(e,t,o,i){if(!this.registry.isGapAdjustableParent(e))return;const{opts:r}=this,s=Math.max(0,o+t),l=or({componentRow:e,isVertical:i},r),a=s/l*100,c=e.components().models,d=c.length-1,p={componentRow:e,isVertical:i},u=c.reduce((v,k)=>v+Dn({...p,componentColumn:k},r),0),h=100-a*d,g=r.minItemPercent||5;if(h<g*c.length)return;const x=100-d*a,C=u-x,y={componentRow:e,isVertical:i,partial:!0};c.map(v=>{const k=Dn({...p,componentColumn:v},r),w=k-k/u*C;zn({...y,componentColumn:v,sizeValue:`${On(w)}%`},r)}),Zl({...y,gapValue:`${On(a)}%`},r)}finishGapAdjust(e){uh(e,this.opts)}}class vh{constructor(e,t,o){this.editor=e,this.registry=t,this.opts=o,this.resizeHandler=new yh(e,t,o),this.gapHandler=new xh(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,i){this.gapHandler.updateGapByDelta(e,t,o,i)}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 Do="gs-flex-spots",Ql=`${Do}__handle-size`,wh=`${Do}__handle-gap`;function Sh(n,e){const{Canvas:t}=n,o="flex-resize-spot";let i,r,s,l,a=null,c=null;const d=new bh,p=new vh(n,d,e),u=()=>{var w;i=document.createElement("div"),i.className=Do,i.style.display="none",r=document.createElement("div"),r.className=`${Do}__handles`,r.style.position="absolute",r.style.pointerEvents="none",r.style.zIndex="21",s={left:document.createElement("div"),right:document.createElement("div"),top:document.createElement("div"),bottom:document.createElement("div")},Object.entries(s).forEach(([S,E])=>{const T=S,A=Io(T);E.className=`${Ql} ${Ql}-${T} gjs-resizer-h gjs-cv-unscale`,E.style.cssText=`
171
171
  pointer-events: all;
172
172
  position: absolute;
173
173
  z-index: 1;
174
- cursor: ${M?"ns-resize":"ew-resize"};
175
- ${M?"left: 50%;":"top: 50%;"}
176
- ${k==="left"?"left: 0px;":""}
177
- ${k==="right"?"right: 0px;":""}
178
- ${k==="top"?"top: 0px;":""}
179
- ${k==="bottom"?"bottom: 0px;":""}
180
- `,E.addEventListener("pointerdown",h(k)),i.appendChild(E)}),!e.disableGapHandler&&!rn(e)&&(l=document.createElement("div"),l.className=Vh,l.style.cssText=`
174
+ cursor: ${A?"ns-resize":"ew-resize"};
175
+ ${A?"left: 50%;":"top: 50%;"}
176
+ ${T==="left"?"left: 0px;":""}
177
+ ${T==="right"?"right: 0px;":""}
178
+ ${T==="top"?"top: 0px;":""}
179
+ ${T==="bottom"?"bottom: 0px;":""}
180
+ `,E.addEventListener("pointerdown",f(T)),r.appendChild(E)}),!e.disableGapHandler&&!cn(e)&&(l=document.createElement("div"),l.className=wh,l.style.cssText=`
181
181
  position: absolute;
182
182
  background-color: var(--gs-theme-cl-cmp-bg1, #3b97e3);
183
183
  border-width: 2px;
@@ -187,8 +187,8 @@
187
187
  pointer-events: all;
188
188
  max-width: 3rem;
189
189
  max-height: 3rem;
190
- `,l.addEventListener("pointerdown",f()),i.appendChild(l)),s.append(i),(S=t.getSpotsEl())==null||S.appendChild(s)},h=S=>x=>{if(!a)return;x.stopPropagation(),x.preventDefault(),p.startResize(a,S,x);const E=x.clientX,k=x.clientY;x.target.setPointerCapture(x.pointerId);const M=N=>{const O=n.Canvas.getZoomMultiplier(),R=(N.clientX-E)*O,_=(N.clientY-k)*O,ue=No(S)?_:R;p.updateResizeByDelta(a,S,ue)},P=()=>{p.finishResize(a),x.target.releasePointerCapture(x.pointerId),document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",P)};document.addEventListener("pointermove",M),document.addEventListener("pointerup",P)},f=()=>S=>{if(!c)return;const x=c;S.stopPropagation(),S.preventDefault();const E=On(x,e),k=Xs({componentRow:x,isVertical:E},e),M=S.clientX,P=S.clientY;S.target.setPointerCapture(S.pointerId);const N=R=>{const _=n.Canvas.getZoomMultiplier(),ue=E?(R.clientY-P)*_:(R.clientX-M)*_;p.updateGapByDelta(x,ue,k,E)},O=()=>{p.finishGapAdjust(x),S.target.releasePointerCapture(S.pointerId),document.removeEventListener("pointermove",N),document.removeEventListener("pointerup",O)};document.addEventListener("pointermove",N),document.addEventListener("pointerup",O)},m=S=>{const x=S.component;if(!x||!s||(a=x,c=x.parent(),!c))return;const E=c;Al(s);const k=S.getStyle();i&&Object.assign(i.style,k);const M=On(E,e),P=wh(M);if(Object.values(r).forEach(Ml),P.forEach(O=>{if(Mh(x,O))return;const R=r[O];Al(R)}),At(e).gapHandler.isGapSupported()&&l&&Ah(x)){const O=Xs({componentRow:E,isVertical:M},e);g(O,M,Eh(x))}},g=(S,x,E=!1)=>{const k=e.gapHandleSize,M=l.style;if(x){M.height=`${k}px`;const P=l.offsetHeight;E?(M.top=`-${(S+P)/2}px`,M.bottom=""):(M.bottom=`-${(S+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=`-${(S+P)/2}px`,M.right=""):(M.right=`-${(S+P)/2}px`,M.left=""),M.height="50%",M.top="50%",M.transform="translateY(-50%)",M.cursor="col-resize"}},b=()=>{s&&(Ml(s),a=null,c=null)},w=()=>{t.removeSpots({type:o});const S=n.getSelected(),x=S==null?void 0:S.parent();S&&x&&d.isValidRelationship(x,S)?t.addSpot({type:o,component:S}):b()},y=()=>{const S=t.getSpots().filter(x=>x.type===o)[0];S&&m(S)},v=(S,x)=>{d.registerTypeRelationship(S,x)};n.onReady(()=>{u(),rn(e)?v("mj-section","mj-column"):v(e.typeRow,e.typeColumn)});const C="component:toggled";return n.on(t.events.spot,y),n.on(C,w),()=>{n.off(t.events.spot,y),n.off(C,w)}}const Fh=W(function(n,e={}){const t={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...e},o=[Ih(n,t),Oh(n,t)],s=Hh(n,t),i=Nh(n,t);j({editor:n,licenseKey:t.licenseKey,plan:Dh,pluginName:Rh,cleanup:()=>{o.forEach(r=>r==null?void 0:r()),s(),i==null||i()}})});var Oe=(n=>(n.name="animation-name",n.duration="animation-duration",n.delay="animation-delay",n.iterationCount="animation-iteration-count",n.timingFunction="animation-timing-function",n.fillMode="animation-fill-mode",n))(Oe||{}),ln=(n=>(n.onScroll="--animation-on-scroll",n.threshold="--animation-threshold",n.repeat="--animation-repeat",n))(ln||{});const Be="animation",an="animation-group",Dl="animation:update",ei="animation-group:update",Ll={category:{id:"animations",label:"Animations"},select:!0},Io=n=>(n==null?void 0:n.getType())===Be,Ro=n=>(n==null?void 0:n.getType())===an,$l=n=>Io(n)||Ro(n),Dn={isVisible:({component:n})=>Io(n)},_h={isVisible:({component:n})=>Ro(n)},Gh={isVisible:({component:n})=>Io(n)&&Ro(n==null?void 0:n.parent())?!1:$l(n)},zl={isVisible:({component:n,sector:e})=>{var t;return Io(n)&&Ro(n==null?void 0:n.parent())?!1:$l(n)&&((t=e.getProperty(ln.onScroll))==null?void 0:t.getValue())==="true"}},Bl={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>'},Wh=function(n){const e=this;let t=null;const o=()=>{t==null||t.disconnect(),t=null},s=()=>{o();const i=e.style;i.animationName="",requestAnimationFrame(()=>{const r=getComputedStyle(e),l=r.getPropertyValue("animation-name").trim(),a=r.getPropertyValue("--animation-on-scroll").trim()!=="false",c=parseFloat(r.getPropertyValue("--animation-threshold").trim())||.2,d=r.getPropertyValue("--animation-repeat").trim()==="true",p=()=>{i.animationName="none",e.offsetWidth,i.animationName=l,i.animationPlayState="running"};if(!l||l==="none"){i.animationName="none",i.animationPlayState="paused";return}if(!a){p();return}i.animationPlayState="paused",t=new IntersectionObserver(u=>{u.forEach(h=>{h.isIntersecting&&(p(),!d&&o())})},{threshold:c}),t.observe(e)})};e.addEventListener(n.animationUpdateEvent,s),s()},jh=(n,e)=>{const{Components:t,Blocks:o,Canvas:s}=n,{block:i={},animationList:r=[]}=e,l=n.Components.events,a="Animation",c=Object.values(ln),d=Object.values(Oe);return t.addType(Be,{block:i?{label:a,media:Bl.animation,content:{type:Be},...Ll,...i}:void 0,model:{defaults:{emptyState:!0,name:a,traits:[],script:Wh,animationUpdateEvent:Dl,"script-props":["animationUpdateEvent"],styles:r.map(p=>p.css).join(`
191
- `)},init(){const{em:p}=this;this.addStyle({[Oe.name]:"fadeIn",[Oe.duration]:"1s",[Oe.fillMode]:"both",...e.animationStyle,...this.getStyle()}),this.listenTo(p,l.mount,u=>{var f;if(u!==this)return;((f=this.parent())==null?void 0:f.get("type"))!==an||c.forEach(m=>this.removeStyle(m))})}},view:{events:()=>({animationstart:"onAnimationStart",animationend:"onAnimationEnd"}),init(){const{model:p}=this;this.listenTo(p,l.styleUpdate,this.handleStyleChange)},onAnimationStart(){var u;if((u=this.cmpSpots)!=null&&u.length)return;const p=s.getSpots({component:this.model});this.cmpSpots=p,s.removeSpots(p),this.el.ownerDocument.body.style.overflowX="hidden"},onAnimationEnd(){const p=this.cmpSpots||[];s.spots.add(p),this.cmpSpots=[],this.el.ownerDocument.body.style.overflowX=""},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(Dl))},handleStyleChange(p,u){Object.keys((u==null?void 0:u.style)||{}).some(m=>d.includes(m)||c.includes(m))&&this.triggerAnimation()},onRender(){this.triggerAnimation()}}}),()=>{o.remove(Be),t.removeType(Be)}},qh=function(n){const e=this,t="--animation-on-scroll",o="--animation-threshold",s="--animation-repeat";let i=null;const r=()=>{i==null||i.disconnect(),i=null},l=()=>{r();const a=getComputedStyle(e),c=a.getPropertyValue(t).trim()!=="false",d=parseFloat(a.getPropertyValue(o).trim())||.2,p=a.getPropertyValue(s).trim()==="true",u=()=>{Array.from(e.children).forEach(h=>{h instanceof HTMLElement&&typeof h.dispatchEvent=="function"&&h.dispatchEvent(new CustomEvent(ei,{bubbles:!1}))})};if(!c){u();return}i=new IntersectionObserver(h=>{h.forEach(f=>{f.isIntersecting?(u(),!p&&r()):p&&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}),i.observe(e)};e.addEventListener(n.animationGroupUpdateEvent,l),l()},Uh=(n,e)=>{const{Components:t,Blocks:o}=n,{blockGroup:s={}}=e,i="Animation Group";return t.addType(an,{block:s?{label:i,media:Bl.animationGroup,content:{type:an,components:[{type:Be},{type:Be},{type:Be}]},...Ll,...s}:void 0,model:{defaults:{name:i,emptyState:!0,traits:[],script:qh,animationGroupUpdateEvent:ei,"script-props":["animationGroupUpdateEvent"],droppable:mo(Be)},init(){this.addStyle({...e.animationGroupStyle,...this.getStyle()});const r=this.components();this.listenTo(r,"add remove",this.updateChildrenStaggerStyles),this.updateChildrenStaggerStyles()},updateChildrenStaggerStyles(){this.components().forEach((r,l)=>{r.is(Be)&&r.addStyle({"--stagger-index":l.toString(),[Oe.delay]:"calc(var(--stagger-index, 0) * var(--stagger-delay, 0.3s))"},{partial:!0})})}},view:{init(){const{model:r}=this;this.listenTo(r,"component:styleUpdate",this.handleStyleChange)},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(ei))},handleStyleChange(){this.triggerAnimation(),this.model.updateChildrenStaggerStyles()},onRender(){this.triggerAnimation()}}}),()=>{o.remove(an),t.removeType(an)}},Kh="animationComponent",Jh=F.startup,Vl=[{id:"flash",name:"Flash",css:`@keyframes flash {
190
+ `,l.addEventListener("pointerdown",h()),r.appendChild(l)),i.append(r),(w=t.getSpotsEl())==null||w.appendChild(i)},f=w=>S=>{if(!a)return;S.stopPropagation(),S.preventDefault(),p.startResize(a,w,S);const E=S.clientX,T=S.clientY;S.target.setPointerCapture(S.pointerId);const A=P=>{const N=n.Canvas.getZoomMultiplier(),I=(P.clientX-E)*N,G=(P.clientY-T)*N,he=Io(w)?G:I;p.updateResizeByDelta(a,w,he)},$=()=>{p.finishResize(a),S.target.releasePointerCapture(S.pointerId),document.removeEventListener("pointermove",A),document.removeEventListener("pointerup",$)};document.addEventListener("pointermove",A),document.addEventListener("pointerup",$)},h=()=>w=>{if(!c)return;const S=c;w.stopPropagation(),w.preventDefault();const E=In(S,e),T=nr({componentRow:S,isVertical:E},e),A=w.clientX,$=w.clientY;w.target.setPointerCapture(w.pointerId);const P=I=>{const G=n.Canvas.getZoomMultiplier(),he=E?(I.clientY-$)*G:(I.clientX-A)*G;p.updateGapByDelta(S,he,T,E)},N=()=>{p.finishGapAdjust(S),w.target.releasePointerCapture(w.pointerId),document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",N)};document.addEventListener("pointermove",P),document.addEventListener("pointerup",N)},g=w=>{const S=w.component;if(!S||!i||(a=S,c=S.parent(),!c))return;const E=c;Ul(i);const T=w.getStyle();r&&Object.assign(r.style,T);const A=In(E,e),$=rh(A);if(Object.values(s).forEach(ql),$.forEach(N=>{if(dh(S,N))return;const I=s[N];Ul(I)}),$t(e).gapHandler.isGapSupported()&&l&&ph(S)){const N=nr({componentRow:E,isVertical:A},e);b(N,A,ah(S))}},b=(w,S,E=!1)=>{const T=e.gapHandleSize,A=l.style;if(S){A.height=`${T}px`;const $=l.offsetHeight;E?(A.top=`-${(w+$)/2}px`,A.bottom=""):(A.bottom=`-${(w+$)/2}px`,A.top=""),A.width="50%",A.left="50%",A.transform="translateX(-50%)",A.cursor="row-resize"}else{A.width=`${T}px`;const $=l.offsetWidth;E?(A.left=`-${(w+$)/2}px`,A.right=""):(A.right=`-${(w+$)/2}px`,A.left=""),A.height="50%",A.top="50%",A.transform="translateY(-50%)",A.cursor="col-resize"}},x=()=>{i&&(ql(i),a=null,c=null)},C=()=>{t.removeSpots({type:o});const w=n.getSelected(),S=w==null?void 0:w.parent();w&&S&&d.isValidRelationship(S,w)?t.addSpot({type:o,component:w}):x()},y=()=>{const w=t.getSpots().filter(S=>S.type===o)[0];w&&g(w)},v=(w,S)=>{d.registerTypeRelationship(w,S)};n.onReady(()=>{u(),cn(e)?v("mj-section","mj-column"):v(e.typeRow,e.typeColumn)});const k="component:toggled";return n.on(t.events.spot,y),n.on(k,C),()=>{n.off(t.events.spot,y),n.off(k,C)}}const Ch=q(function(n,e={}){const t={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...e},o=[mh(n,t),hh(n,t)],i=Sh(n,t),r=fh(n,t);U({editor:n,licenseKey:t.licenseKey,plan:gh,pluginName:Xl,cleanup:()=>{o.forEach(s=>s==null?void 0:s()),i(),r==null||r()}})},Xl);var Oe=(n=>(n.name="animation-name",n.duration="animation-duration",n.delay="animation-delay",n.iterationCount="animation-iteration-count",n.timingFunction="animation-timing-function",n.fillMode="animation-fill-mode",n))(Oe||{}),dn=(n=>(n.onScroll="--animation-on-scroll",n.threshold="--animation-threshold",n.repeat="--animation-repeat",n))(dn||{});const He="animation",pn="animation-group",ea="animation:update",ir="animation-group:update",ta={category:{id:"animations",label:"Animations"},select:!0},zo=n=>(n==null?void 0:n.getType())===He,Ro=n=>(n==null?void 0:n.getType())===pn,na=n=>zo(n)||Ro(n),Rn={isVisible:({component:n})=>zo(n)},kh={isVisible:({component:n})=>Ro(n)},Th={isVisible:({component:n})=>zo(n)&&Ro(n==null?void 0:n.parent())?!1:na(n)},oa={isVisible:({component:n,sector:e})=>{var t;return zo(n)&&Ro(n==null?void 0:n.parent())?!1:na(n)&&((t=e.getProperty(dn.onScroll))==null?void 0:t.getValue())==="true"}},ia={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>'},Eh=function(n){const e=this;let t=null;const o=()=>{t==null||t.disconnect(),t=null},i=()=>{o();const r=e.style;r.animationName="",requestAnimationFrame(()=>{const s=getComputedStyle(e),l=s.getPropertyValue("animation-name").trim(),a=s.getPropertyValue("--animation-on-scroll").trim()!=="false",c=parseFloat(s.getPropertyValue("--animation-threshold").trim())||.2,d=s.getPropertyValue("--animation-repeat").trim()==="true",p=()=>{r.animationName="none",e.offsetWidth,r.animationName=l,r.animationPlayState="running"};if(!l||l==="none"){r.animationName="none",r.animationPlayState="paused";return}if(!a){p();return}r.animationPlayState="paused",t=new IntersectionObserver(u=>{u.forEach(f=>{f.isIntersecting&&(p(),!d&&o())})},{threshold:c}),t.observe(e)})};e.addEventListener(n.animationUpdateEvent,i),i()},Mh=(n,e)=>{const{Components:t,Blocks:o,Canvas:i}=n,{block:r={},animationList:s=[]}=e,l=n.Components.events,a="Animation",c=Object.values(dn),d=Object.values(Oe);return t.addType(He,{block:r?{label:a,media:ia.animation,content:{type:He},...ta,...r}:void 0,model:{defaults:{emptyState:!0,name:a,traits:[],script:Eh,animationUpdateEvent:ea,"script-props":["animationUpdateEvent"],styles:s.map(p=>p.css).join(`
191
+ `)},init(){const{em:p}=this;this.addStyle({[Oe.name]:"fadeIn",[Oe.duration]:"1s",[Oe.fillMode]:"both",...e.animationStyle,...this.getStyle()}),this.listenTo(p,l.mount,u=>{var h;if(u!==this)return;((h=this.parent())==null?void 0:h.get("type"))!==pn||c.forEach(g=>this.removeStyle(g))})}},view:{events:()=>({animationstart:"onAnimationStart",animationend:"onAnimationEnd"}),init(){const{model:p}=this;this.listenTo(p,l.styleUpdate,this.handleStyleChange)},onAnimationStart(){var u;if((u=this.cmpSpots)!=null&&u.length)return;const p=i.getSpots({component:this.model});this.cmpSpots=p,i.removeSpots(p),this.el.ownerDocument.body.style.overflowX="hidden"},onAnimationEnd(){const p=this.cmpSpots||[];i.spots.add(p),this.cmpSpots=[],this.el.ownerDocument.body.style.overflowX=""},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(ea))},handleStyleChange(p,u){Object.keys((u==null?void 0:u.style)||{}).some(g=>d.includes(g)||c.includes(g))&&this.triggerAnimation()},onRender(){this.triggerAnimation()}}}),()=>{o.remove(He),t.removeType(He)}},Ah=function(n){const e=this,t="--animation-on-scroll",o="--animation-threshold",i="--animation-repeat";let r=null;const s=()=>{r==null||r.disconnect(),r=null},l=()=>{s();const a=getComputedStyle(e),c=a.getPropertyValue(t).trim()!=="false",d=parseFloat(a.getPropertyValue(o).trim())||.2,p=a.getPropertyValue(i).trim()==="true",u=()=>{Array.from(e.children).forEach(f=>{f instanceof HTMLElement&&typeof f.dispatchEvent=="function"&&f.dispatchEvent(new CustomEvent(ir,{bubbles:!1}))})};if(!c){u();return}r=new IntersectionObserver(f=>{f.forEach(h=>{h.isIntersecting?(u(),!p&&s()):p&&Array.from(e.children).forEach(g=>{g instanceof HTMLElement&&getComputedStyle(g).getPropertyValue(t).trim()!=="false"&&(g.style.opacity="0",g.style.animationPlayState="paused")})})},{threshold:d}),r.observe(e)};e.addEventListener(n.animationGroupUpdateEvent,l),l()},jh=(n,e)=>{const{Components:t,Blocks:o}=n,{blockGroup:i={}}=e,r="Animation Group";return t.addType(pn,{block:i?{label:r,media:ia.animationGroup,content:{type:pn,components:[{type:He},{type:He},{type:He}]},...ta,...i}:void 0,model:{defaults:{name:r,emptyState:!0,traits:[],script:Ah,animationGroupUpdateEvent:ir,"script-props":["animationGroupUpdateEvent"],droppable:xo(He)},init(){this.addStyle({...e.animationGroupStyle,...this.getStyle()});const s=this.components();this.listenTo(s,"add remove",this.updateChildrenStaggerStyles),this.updateChildrenStaggerStyles()},updateChildrenStaggerStyles(){this.components().forEach((s,l)=>{s.is(He)&&s.addStyle({"--stagger-index":l.toString(),[Oe.delay]:"calc(var(--stagger-index, 0) * var(--stagger-delay, 0.3s))"},{partial:!0})})}},view:{init(){const{model:s}=this;this.listenTo(s,"component:styleUpdate",this.handleStyleChange)},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(ir))},handleStyleChange(){this.triggerAnimation(),this.model.updateChildrenStaggerStyles()},onRender(){this.triggerAnimation()}}}),()=>{o.remove(pn),t.removeType(pn)}},ra="animationComponent",$h=F.startup,sa=[{id:"flash",name:"Flash",css:`@keyframes flash {
192
192
  0%, 50%, to {
193
193
  opacity:1
194
194
  }
@@ -705,7 +705,7 @@
705
705
  transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0);
706
706
  animation-timing-function:cubic-bezier(.175, .885, .32, 1)
707
707
  }
708
- }`}],Zh=W(function(n,e={}){var s;const t=((s=e.animations)==null?void 0:s.call(e,{items:Vl}))||Vl,o=[jh(n,{...e,animationList:t}),Uh(n,e)];n.Styles.addSector("animation",{name:"Animation",properties:[{...Dn,name:"Type",property:Oe.name,type:"select",full:!0,default:"fadeIn",options:t},{...Dn,name:"Duration",property:Oe.duration,type:"number",units:["s"],min:.1,max:10,step:.1,default:"1s"},{...Dn,name:"Delay",property:Oe.delay,type:"number",units:["s"],min:0,max:10,step:.1,default:"1s"},{...Dn,name:"Iteration Count",property:Oe.iterationCount,type:"select",default:"1",options:[{id:"1",name:"One time"},{id:"infinite",name:"Infinite"}]},{...Dn,name:"Timing",property:Oe.timingFunction,type:"select",default:"ease",options:[{id:"ease",name:"Ease"},{id:"ease-in",name:"Ease in"},{id:"ease-out",name:"Ease out"},{id:"ease-in-out",name:"Ease in out"},{id:"linear",name:"Linear"}]},{..._h,name:"Stagger Delay",property:"--stagger-delay",type:"slider",units:["s"],min:.1,max:5,step:.1,default:"0.3s"},{...Gh,name:"Animate on Scroll",property:ln.onScroll,type:"radio",default:"true",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]},{...zl,name:"Scroll Threshold",property:ln.threshold,type:"number",full:!0,min:.1,max:1,step:.01,default:"0.2"},{...zl,name:"Repeat on Scroll",property:ln.repeat,type:"radio",default:"false",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]}]}),j({editor:n,licenseKey:e.licenseKey,plan:Jh,pluginName:Kh,cleanup:()=>{o.forEach(i=>i())}})}),Yh="shapeDividerComponent",Xh=F.startup,Qh=W(function(n,e={}){const{Components:t,Blocks:o,Selectors:s}=n,i="shape-divider",r=`${i}-cnt`,l=`${ke}${i}`,a=`${ke}${r}`,c=[{id:"tilt",label:"Tilt",value:`<svg preserveAspectRatio="none" viewBox="0 0 240 24">
708
+ }`}],Ph=q(function(n,e={}){var i;const t=((i=e.animations)==null?void 0:i.call(e,{items:sa}))||sa,o=[Mh(n,{...e,animationList:t}),jh(n,e)];n.Styles.addSector("animation",{name:"Animation",properties:[{...Rn,name:"Type",property:Oe.name,type:"select",full:!0,default:"fadeIn",options:t},{...Rn,name:"Duration",property:Oe.duration,type:"number",units:["s"],min:.1,max:10,step:.1,default:"1s"},{...Rn,name:"Delay",property:Oe.delay,type:"number",units:["s"],min:0,max:10,step:.1,default:"1s"},{...Rn,name:"Iteration Count",property:Oe.iterationCount,type:"select",default:"1",options:[{id:"1",name:"One time"},{id:"infinite",name:"Infinite"}]},{...Rn,name:"Timing",property:Oe.timingFunction,type:"select",default:"ease",options:[{id:"ease",name:"Ease"},{id:"ease-in",name:"Ease in"},{id:"ease-out",name:"Ease out"},{id:"ease-in-out",name:"Ease in out"},{id:"linear",name:"Linear"}]},{...kh,name:"Stagger Delay",property:"--stagger-delay",type:"slider",units:["s"],min:.1,max:5,step:.1,default:"0.3s"},{...Th,name:"Animate on Scroll",property:dn.onScroll,type:"radio",default:"true",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]},{...oa,name:"Scroll Threshold",property:dn.threshold,type:"number",full:!0,min:.1,max:1,step:.01,default:"0.2"},{...oa,name:"Repeat on Scroll",property:dn.repeat,type:"radio",default:"false",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]}]}),U({editor:n,licenseKey:e.licenseKey,plan:$h,pluginName:ra,cleanup:()=>{o.forEach(r=>r())}})},ra),la="shapeDividerComponent",Nh=F.startup,Oh=q(function(n,e={}){const{Components:t,Blocks:o,Selectors:i}=n,r="shape-divider",s=`${r}-cnt`,l=`${Ee}${r}`,a=`${Ee}${s}`,c=[{id:"tilt",label:"Tilt",value:`<svg preserveAspectRatio="none" viewBox="0 0 240 24">
709
709
  <path d="M240 24V0L0 24h240z"/>
710
710
  </svg>`},{id:"tilt-split",label:"Tilt split",value:`<svg preserveAspectRatio="none" viewBox="0 0 240 24">
711
711
  <path fill-opacity=".3" d="M240 24V0L0 24h240z"/>
@@ -765,9 +765,9 @@
765
765
  <path fill-opacity=".3" d="M0 0v18C21.5 7 49.6 2.2 64.8 6.4 82 11.2 75.4 25.2 91.7 23.9c14.2-1.1 25.8-12.3 40-12.3 10.4 0 7.8 6 18.8 6.9 11.5.8 21.6-5 37.2-9 19.9-5 42.1-5.3 52.3 0V0H0z"/>
766
766
  </svg>`},{id:"zigzag",label:"Zigzag",value:`<svg class="${a}-inv" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 1000 38">
767
767
  <path d="M75 38l25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25 25 25 25-25V.0H0V13l25 25 25-25z"/>
768
- </svg>`}],d={tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1},p={...d,bc:!0},u={...d,tc:!0},h="shape",f="flip-y",m="flip-x",g="Shape Divider",b=`<svg viewBox="0 0 22 22">
768
+ </svg>`}],d={tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1},p={...d,bc:!0},u={...d,tc:!0},f="shape",h="flip-y",g="flip-x",b="Shape Divider",x=`<svg viewBox="0 0 22 22">
769
769
  <path fill="currentColor" d="M2 2v18h18V2H2zm0-2h18a2 2 0 012 2v18a2 2 0 01-2 2H2a2 2 0 01-2-2V2C0 .9.9 0 2 0zM1 13L2 0h18l1 9-20 4z"/>
770
- </svg>`,{block:w={}}=e;n.on(s.events.add,y=>{y.getFullName().startsWith(`.${l}`)&&y.set({private:!0})}),t.addType(i,{isComponent:y=>$e(i)(y)||ot(y,l),block:w&&{label:g,media:b,category:"Extra",select:!0,...w},model:{defaults:{droppable:!1,highlightable:!1,classes:l,attributes:{[Pe]:i},components:{type:r},styles:`.${l} { position: relative; }`,delegate:{select:y=>y.findFirstType(r),layer:y=>y.findFirstType(r)}}},view:{onRender(){this.el.style.height="1px"}}}),t.addType(r,{isComponent:$e(r),model:{defaults:{droppable:!1,highlightable:!1,classes:a,emptyState:!0,icon:b,name:g,delegate:{remove:y=>y.parent(),move:y=>y.parent(),copy:y=>y.parent()},attributes:{[Pe]:r},[h]:c[0].id,resizable:p,stylable:["height","width","color"],styles:`
770
+ </svg>`,{block:C={}}=e;n.on(i.events.add,y=>{y.getFullName().startsWith(`.${l}`)&&y.set({private:!0})}),t.addType(r,{isComponent:y=>Be(r)(y)||st(y,l),block:C&&{label:b,media:x,category:"Extra",select:!0,...C},model:{defaults:{droppable:!1,highlightable:!1,classes:l,attributes:{[Pe]:r},components:{type:s},styles:`.${l} { position: relative; }`,delegate:{select:y=>y.findFirstType(s),layer:y=>y.findFirstType(s)}}},view:{onRender(){this.el.style.height="1px"}}}),t.addType(s,{isComponent:Be(s),model:{defaults:{droppable:!1,highlightable:!1,classes:a,emptyState:!0,icon:x,name:b,delegate:{remove:y=>y.parent(),move:y=>y.parent(),copy:y=>y.parent()},attributes:{[Pe]:s},[f]:c[0].id,resizable:p,stylable:["height","width","color"],styles:`
771
771
  .${a} {
772
772
  position: absolute;
773
773
  width: 100%;
@@ -801,7 +801,7 @@
801
801
  .${a}-inv > path {
802
802
  transform: scale(-1, -1) translate(-100%, -100%);
803
803
  }
804
- `,traits:[{type:"select",name:h,label:"Shape",changeProp:!0,options:c.map(({id:y,label:v,value:C})=>({id:y,label:v,icon:{icon:C.replace("<svg ",'<svg style="width: 35px; height: 7px; fill: currentColor;"')}}))},{type:"checkbox",name:f,label:"Flip vertically",changeProp:!0},{type:"checkbox",name:m,label:"flip horizontally",changeProp:!0}]},init(){this.on(`change:${h}`,this.onShapeChange),this.on(`change:${m} change:${f}`,this.onFlip),this.onShapeChange()},onShapeChange(){const y=this.get(h),v=c.find(S=>S.id===y),C=(v==null?void 0:v.value)||this.getInnerHTML().trim();this.components(""),C&&this.set("content",C)},onFlip(){const y=this.get(f),v=this.get(m),C=["fl-v","fl-h","fl-v-h"].map(x=>`${a}--${x}`);let S;y&&v?S=C[2]:v?S=C[1]:y&&(S=C[0]),this.removeClass(C),S&&this.addClass(S),this.set("resizable",y?u:p)}}}),j({editor:n,licenseKey:e.licenseKey,plan:Xh,pluginName:Yh,cleanup:()=>{t.removeType(i),o.remove(i)}})}),ef=n=>n.dispatchEvent(new CustomEvent("input")),tf=(n,e)=>{if(!e)return()=>{};const t="keydown",o=i=>{var r;i.key==="Escape"&&((r=n.getEditing())==null||r.trigger("disable"))},s=()=>document.removeEventListener(t,o);return n.onReady(()=>{document.addEventListener(t,o),n.on(n.events.destroy,s)}),s};function Hl(n,e){if(!e)return()=>{};const t=n.Components.events,o=d=>n.getSelectedAll().includes(d),s=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),i=d=>d.isChildOf("text"),r=d=>n.getEditing()===d,l=(d,p={})=>{d.trigger("focus",p.event)},a=(d,p)=>{o(d)&&s(d)&&!r(d)&&l(d,p)},c=(d,p)=>{if(o(d)&&!s(d)&&i(d)){const u=d.parents().find(h=>h.isInstanceOf("text"));u&&(l(u,p),setTimeout(()=>n.select(u),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const nf="rteTinyMce",of=F.startup,sf=`
804
+ `,traits:[{type:"select",name:f,label:"Shape",changeProp:!0,options:c.map(({id:y,label:v,value:k})=>({id:y,label:v,icon:{icon:k.replace("<svg ",'<svg style="width: 35px; height: 7px; fill: currentColor;"')}}))},{type:"checkbox",name:h,label:"Flip vertically",changeProp:!0},{type:"checkbox",name:g,label:"flip horizontally",changeProp:!0}]},init(){this.on(`change:${f}`,this.onShapeChange),this.on(`change:${g} change:${h}`,this.onFlip),this.onShapeChange()},onShapeChange(){const y=this.get(f),v=c.find(w=>w.id===y),k=(v==null?void 0:v.value)||this.getInnerHTML().trim();this.components(""),k&&this.set("content",k)},onFlip(){const y=this.get(h),v=this.get(g),k=["fl-v","fl-h","fl-v-h"].map(S=>`${a}--${S}`);let w;y&&v?w=k[2]:v?w=k[1]:y&&(w=k[0]),this.removeClass(k),w&&this.addClass(w),this.set("resizable",y?u:p)}}}),U({editor:n,licenseKey:e.licenseKey,plan:Nh,pluginName:la,cleanup:()=>{t.removeType(r),o.remove(r)}})},la),Ih=n=>n.dispatchEvent(new CustomEvent("input")),Dh=(n,e)=>{if(!e)return()=>{};const t="keydown",o=r=>{var s;r.key==="Escape"&&((s=n.getEditing())==null||s.trigger("disable"))},i=()=>document.removeEventListener(t,o);return n.onReady(()=>{document.addEventListener(t,o),n.on(n.events.destroy,i)}),i};function aa(n,e){if(!e)return()=>{};const t=n.Components.events,o=d=>n.getSelectedAll().includes(d),i=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),r=d=>d.isChildOf("text"),s=d=>n.getEditing()===d,l=(d,p={})=>{d.trigger("focus",p.event)},a=(d,p)=>{o(d)&&i(d)&&!s(d)&&l(d,p)},c=(d,p)=>{if(o(d)&&!i(d)&&r(d)){const u=d.parents().find(f=>f.isInstanceOf("text"));u&&(l(u,p),setTimeout(()=>n.select(u),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const ca="rteTinyMce",zh=F.startup,Rh=`
805
805
  .tox .tox-toolbar,
806
806
  .tox .tox-toolbar__overflow,
807
807
  .tox .tox-toolbar__primary,
@@ -904,26 +904,26 @@
904
904
  background-color: var(--gs-theme-cl-prm-bg1);
905
905
  border-color: var(--gs-theme-cl-prm-bg3);
906
906
  opacity: 0.75;
907
- }`,ti=new WeakMap,rf=(n,e)=>{ti.set(n,e)},lf=n=>{ti.delete(n)},ni=n=>ti.get(n),Do=n=>{const e=n.target,t=e.closest(".tox"),o=e.matches(".ephox-snooker-resizer-bar");(t||o)&&n.stopPropagation()},Fl=n=>{n.stopPropagation(),n.preventDefault()},af=(n,e)=>{const t=n.getDoc(),o=n.getWin();if(e!=null&&e.event){const{event:s}=e,{clientX:i,clientY:r}=s;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(i,r);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(i,r);l=t.createRange(),l==null||l.setStart(a.offsetNode,a.offset)}if(l){const a=o.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(l),n.selection.setRng(l)}}else n.execCommand("SelectAll")},cf=n=>{var c,d;const{el:e,editor:t,componentView:o}=n,s=t.runCommand(G.getStateTheme),i=o.model,r={target:e,inline:!0,skin:(s==null?void 0:s.theme)===Or.dark?"oxide-dark":"oxide",menubar:!1,image_advtab:!0,paste_data_images:!0,statusbar:!1,branding:!1,forced_root_block:"div",plugins:"advlist autolink lists link image media table",toolbar_mode:"sliding",toolbar:"bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"},l=((d=(c=n.pluginOpts)==null?void 0:c.loadConfig)==null?void 0:d.call(c,{config:r,editor:t,componentView:o,component:i}))||{};return{...r,...l}},_l=(n,e=document)=>new Promise((t,o)=>{const s=Array.isArray(n)?[...n]:[n],{head:i}=e,r=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=r.bind(null,l),a.onerror=o,i.appendChild(a)}else t()};r(s)}),df=W(function(n,e={}){const t={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...e},{cdnScript:o}=t,s=n.Canvas.events,i=!t.skipCustomTheme,r="gs-plg-tinymce-studio-theme",l=async(d,p)=>{const u=d.ownerDocument,h=u.defaultView,f=p==null?void 0:p.view;if(!h||!f){console.warn("Missing required data",{win:h,componentView:f});return}const m=cf({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(),u.body.addEventListener("mousedown",Do),document.body.addEventListener("mousedown",Do),b.on("Change",()=>ef(d)),b.on("blur",()=>b.ui.show()),b.on("OpenWindow",function(){var S;const v=(S=u.querySelector(".tox-dialog"))==null?void 0:S.closest(".tox");v&&(v==null?void 0:v.ownerDocument)!==document&&(document.body.appendChild(v),b.once("CloseWindow",()=>{v&&v.ownerDocument===document&&u.body.appendChild(v)}))}),d.addEventListener("dragstart",Fl,{capture:!0}),n.runCommand(G.setStateContextMenu,{enabled:!1}),af(b,p),{rteEditor:b,rteEditorShallow:y}},a=(d,p)=>{d.ownerDocument.body.removeEventListener("mousedown",Do),document.body.removeEventListener("mousedown",Do),d.removeEventListener("dragstart",Fl,{capture:!0}),n.runCommand(G.setStateContextMenu,{enabled:!0}),p.rteEditor.destroy(),p.rteEditorShallow.destroy()};n.on(s.frameLoad,async({window:d})=>{const p=d.document;_l(o,p)}),n.onReady(()=>{_l(o,document),i&&As(r,sf,{target:document.body})}),n.setCustomRte({parseContent:!0,async enable(d,p,u){const h=ni(d);if(h)return h.rteEditor;const f=await l(d,u);return f&&rf(d,f),f==null?void 0:f.rteEditor},disable(d){const p=ni(d);p&&(lf(d),a(d,p))},getContent(d,p,u){var m;const h=ni(d),f=h==null?void 0:h.rteEditor;return f&&!f.isDirty()?u.view.lastContent:f?(m=f.getContent)==null?void 0:m.call(f):d.innerHTML}});const c=Hl(n,t.enableOnClick);j({editor:n,licenseKey:t.licenseKey,plan:of,pluginName:nf,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),i=o.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new Q(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new 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(),i=o.find(n);return s.splice(i==-1?s.length:i,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 Gl(n,e,t){for(let o=0;;o++){if(o==n.childCount||o==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(o),i=e.child(o);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let r=0;s.text[r]==i.text[r];r++)t++;return t}if(s.content.size||i.content.size){let r=Gl(s.content,i.content,t+1);if(r!=null)return r}t+=s.nodeSize}}function Wl(n,e,t,o){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:o};let r=n.child(--s),l=e.child(--i),a=r.nodeSize;if(r==l){t-=a,o-=a;continue}if(!r.sameMarkup(l))return{a:t,b:o};if(r.isText&&r.text!=l.text){let c=0,d=Math.min(r.text.length,l.text.length);for(;c<d&&r.text[r.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,o--;return{a:t,b:o}}if(r.content.size||l.content.size){let c=Wl(r.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,i){for(let r=0,l=0;l<t;r++){let a=this.content[r],c=l+a.nodeSize;if(c>e&&o(a,s+l,i||null,r)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),o,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,o,s){let i="",r=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&o&&(r?r=!1:i+=o),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,o=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(o)&&(s[s.length-1]=t.withText(t.text+o.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new 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 i=0,r=0;r<t;i++){let l=this.content[i],a=r+l.nodeSize;a>e&&((r<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-r),Math.min(l.text.length,t-r)):l=l.cut(Math.max(0,e-r-1),Math.min(l.content.size,t-r-1))),o.push(l),s+=l.nodeSize),r=a}return new 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(),i=this.size+t.nodeSize-o.nodeSize;return s[e]=t,new T(s,i)}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 Gl(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return Wl(this,e,t,o)}findIndex(e,t=-1){if(e==0)return Lo(0,e);if(e==this.size)return Lo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let o=0,s=0;;o++){let i=this.child(o),r=s+i.nodeSize;if(r>=e)return r==e||t>0?Lo(o+1,r):Lo(o,s);s=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return 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 i=e[s];o+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new 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 oi={index:0,offset:0};function Lo(n,e){return oi.index=n,oi.offset=e,oi}function $o(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(!$o(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!$o(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 i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!o&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),o=!0),t&&t.push(i)}}return t||(t=e.slice()),o||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&$o(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 zo 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=ql(this.content,e+this.openStart,t);return o&&new A(o,this.openStart,this.openEnd)}removeBetween(e,t){return new A(jl(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 i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)o++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new A(e,o,s)}}A.empty=new A(T.empty,0,0);function jl(n,e,t){let{index:o,offset:s}=n.findIndex(e),i=n.maybeChild(o),{index:r,offset:l}=n.findIndex(t);if(s==e||i.isText){if(l!=t&&!n.child(r).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(o!=r)throw new RangeError("Removing non-flat range");return n.replaceChild(o,i.copy(jl(i.content,e-s-1,t-s-1)))}function ql(n,e,t,o){let{index:s,offset:i}=n.findIndex(e),r=n.maybeChild(s);if(i==e||r.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=ql(r.content,e-i-1,t);return l&&n.replaceChild(s,r.copy(l))}function pf(n,e,t){if(t.openStart>n.depth)throw new zo("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new zo("Inconsistent open depths");return Ul(n,e,t,0)}function Ul(n,e,t,o){let s=n.index(o),i=n.node(o);if(s==e.index(o)&&o<n.depth-t.openStart){let r=Ul(n,e,t,o+1);return i.copy(i.content.replaceChild(s,r))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let r=n.parent,l=r.content;return Nt(r,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:r,end:l}=uf(t,n);return Nt(i,Jl(n,r,l,e,o))}else return Nt(i,Bo(n,e,o))}function Kl(n,e){if(!e.type.compatibleContent(n.type))throw new zo("Cannot join "+e.type.name+" onto "+n.type.name)}function si(n,e,t){let o=n.node(t);return Kl(o,e.node(t)),o}function Pt(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 Ln(n,e,t,o){let s=(e||n).node(t),i=0,r=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(Pt(n.nodeAfter,o),i++));for(let l=i;l<r;l++)Pt(s.child(l),o);e&&e.depth==t&&e.textOffset&&Pt(e.nodeBefore,o)}function Nt(n,e){return n.type.checkContent(e),n.copy(e)}function Jl(n,e,t,o,s){let i=n.depth>s&&si(n,e,s+1),r=o.depth>s&&si(t,o,s+1),l=[];return Ln(null,n,s,l),i&&r&&e.index(s)==t.index(s)?(Kl(i,r),Pt(Nt(i,Jl(n,e,t,o,s+1)),l)):(i&&Pt(Nt(i,Bo(n,e,s+1)),l),Ln(e,t,s,l),r&&Pt(Nt(r,Bo(t,o,s+1)),l)),Ln(o,null,s,l),new T(l)}function Bo(n,e,t){let o=[];if(Ln(null,n,t,o),n.depth>t){let s=si(n,e,t+1);Pt(Nt(s,Bo(n,e,t+1)),o)}return Ln(e,null,t,o),new T(o)}function uf(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(T.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class $n{constructor(e,t,o){this.pos=e,this.path=t,this.parentOffset=o,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let o=this.pos-this.path[this.path.length-1],s=e.child(t);return o?e.child(t).cut(o):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let o=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)s+=o.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return 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 i=o.marks;for(var r=0;r<i.length;r++)i[r].type.spec.inclusive===!1&&(!s||!i[r].isInSet(s.marks))&&(i=i[r--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let o=t.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let o=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);o>=0;o--)if(e.pos<=this.end(o)&&(!t||t(this.node(o))))return new Vo(this,e,o);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let o=[],s=0,i=t;for(let r=e;;){let{index:l,offset:a}=r.content.findIndex(i),c=i-a;if(o.push(r,l,s+a),!c||(r=r.child(l),r.isText))break;i=c-1,s+=a+1}return new $n(t,o,i)}static resolveCached(e,t){let o=Zl.get(e);if(o)for(let i=0;i<o.elts.length;i++){let r=o.elts[i];if(r.pos==t)return r}else Zl.set(e,o=new hf);let s=o.elts[o.i]=$n.resolve(e,t);return o.i=(o.i+1)%ff,s}}class hf{constructor(){this.elts=[],this.i=0}}const ff=12,Zl=new WeakMap;class Vo{constructor(e,t,o){this.$from=e,this.$to=t,this.depth=o}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const mf=Object.create(null);let Ot=class Er{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&&$o(this.attrs,t||e.defaultAttrs||mf)&&H.sameSet(this.marks,o||H.none)}copy(e=null){return e==this.content?this:new Er(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Er(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),i=this.resolve(t),r=o?0:s.sharedDepth(t),l=s.start(r),c=s.node(r).content.cut(s.pos-l,i.pos-l);return new A(c,s.depth-r,i.depth-r)}replace(e,t,o){return pf(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 $n.resolveCached(this,e)}resolveNoCache(e){return $n.resolve(this,e)}rangeHasMark(e,t,o){let s=!1;return t>e&&this.nodesBetween(e,t,i=>(o.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Yl(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,i=o.childCount){let r=this.contentMatchAt(e).matchFragment(o,s,i),l=r&&r.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(o.child(a).marks))return!1;return!0}canReplaceWith(e,t,o,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(o),r=i&&i.matchFragment(this.content,t);return r?r.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=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),i=e.nodeType(t.type).create(t.attrs,s,o);return i.type.checkAttrs(i.attrs),i}};Ot.prototype.text=void 0;class Ho extends Ot{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):Yl(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 Ho(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Ho(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 Yl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class It{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new gf(e,t);if(o.next==null)return It.empty;let s=Xl(o);o.next&&o.err("Unexpected trailing text");let i=Cf(wf(s));return kf(i,o),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,o=e.childCount){let s=this;for(let i=t;s&&i<o;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let o=0;o<e.next.length;o++)if(this.next[t].type==e.next[o].type)return!0;return!1}fillBefore(e,t=!1,o=0){let s=[this];function i(r,l){let a=r.matchFragment(e,o);if(a&&(!t||a.validEnd))return T.from(l.map(c=>c.createAndFill()));for(let c=0;c<r.next.length;c++){let{type:d,next:p}=r.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(p)==-1){s.push(p);let u=i(p,l.concat(d));if(u)return u}}return null}return i(this,[])}findWrapping(e){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==e)return this.wrapCache[o+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let s=o.shift(),i=s.match;if(i.matchType(e)){let r=[];for(let l=s;l.type;l=l.via)r.push(l.type);return r.reverse()}for(let r=0;r<i.next.length;r++){let{type:l,next:a}=i.next[r];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(o.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(o){e.push(o);for(let s=0;s<o.next.length;s++)e.indexOf(o.next[s].next)==-1&&t(o.next[s].next)}return t(this),e.map((o,s)=>{let i=s+(o.validEnd?"*":" ")+" ";for(let r=0;r<o.next.length;r++)i+=(r?", ":"")+o.next[r].type.name+"->"+e.indexOf(o.next[r].next);return i}).join(`
908
- `)}}It.empty=new It(!0);class gf{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Xl(n){let e=[];do e.push(yf(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function yf(n){let e=[];do e.push(bf(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function bf(n){let e=xf(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=vf(n,e);else break;return e}function Ql(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function vf(n,e){let t=Ql(n),o=t;return n.eat(",")&&(n.next!="}"?o=Ql(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 i in t){let r=t[i];r.isInGroup(e)&&s.push(r)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function xf(n){if(n.eat("(")){let e=Xl(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=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 wf(n){let e=[[]];return s(i(n,0),t()),e;function t(){return e.push([])-1}function o(r,l,a){let c={term:a,to:l};return e[r].push(c),c}function s(r,l){r.forEach(a=>a.to=l)}function i(r,l){if(r.type=="choice")return r.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(r.type=="seq")for(let a=0;;a++){let c=i(r.exprs[a],l);if(a==r.exprs.length-1)return c;s(c,l=t())}else if(r.type=="star"){let a=t();return o(l,a),s(i(r.expr,a),a),[o(a)]}else if(r.type=="plus"){let a=t();return s(i(r.expr,l),a),s(i(r.expr,a),a),[o(a)]}else{if(r.type=="opt")return[o(l)].concat(i(r.expr,l));if(r.type=="range"){let a=l;for(let c=0;c<r.min;c++){let d=t();s(i(r.expr,a),d),a=d}if(r.max==-1)s(i(r.expr,a),a);else for(let c=r.min;c<r.max;c++){let d=t();o(a,d),s(i(r.expr,a),d),a=d}return[o(a)]}else{if(r.type=="name")return[o(l,void 0,r.value)];throw new Error("Unknown expr type")}}}}function ea(n,e){return e-n}function ta(n,e){let t=[];return o(e),t.sort(ea);function o(s){let i=n[s];if(i.length==1&&!i[0].term)return o(i[0].to);t.push(s);for(let r=0;r<i.length;r++){let{term:l,to:a}=i[r];!l&&t.indexOf(a)==-1&&o(a)}}}function Cf(n){let e=Object.create(null);return t(ta(n,0));function t(o){let s=[];o.forEach(r=>{n[r].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);ta(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[o.join(",")]=new It(o.indexOf(n.length-1)>-1);for(let r=0;r<s.length;r++){let l=s[r][1].sort(ea);i.next.push({type:s[r][0],next:e[l.join(",")]||t(l)})}return i}}function kf(n,e){for(let t=0,o=[n];t<o.length;t++){let s=o[t],i=!s.validEnd,r=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];r.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),o.indexOf(c)==-1&&o.push(c)}i&&e.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function na(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 oa(n,e){let t=Object.create(null);for(let o in n){let s=e&&e[o];if(s===void 0){let i=n[o];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+o)}t[o]=s}return t}function sa(n,e,t,o){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let i=n[s];i.validate&&i.validate(e[s])}}function ia(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new Tf(n,o,e[o]);return t}let ra=class Ep{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=ia(e,o.attrs),this.defaultAttrs=na(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==It.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:oa(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ot(this,this.computeAttrs(e),T.from(t),H.setFrom(o))}createChecked(e=null,t,o){return t=T.from(t),this.checkContent(t),new Ot(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 r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}let s=this.contentMatch.matchFragment(t),i=s&&s.fillBefore(T.empty,!0);return i?new Ot(this,e,t.append(i),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){sa(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((i,r)=>o[i]=new Ep(i,t,r));let s=t.spec.topNode||"doc";if(!o[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let i in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function Ef(n,e,t){let o=t.split("|");return s=>{let i=s===null?"null":typeof s;if(o.indexOf(i)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${n}, got ${i}`)}}class Tf{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?Ef(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class Fo{constructor(e,t,o,s){this.name=e,this.rank=t,this.schema=o,this.spec=s,this.attrs=ia(e,s.attrs),this.excluded=null;let i=na(this.attrs);this.instance=i?new H(this,i):null}create(e=null){return!e&&this.instance?this.instance:new H(this,oa(this.attrs,e))}static compile(e,t){let o=Object.create(null),s=0;return e.forEach((i,r)=>o[i]=new Fo(i,s++,t,r)),o}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){sa(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Mf{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=ra.compile(this.spec.nodes,this),this.marks=Fo.compile(this.spec.marks,this);let o=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],r=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=o[r]||(o[r]=It.parse(r,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?la(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],r=i.spec.excludes;i.excluded=r==null?[i]:r==""?[]:la(this,r.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,o,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ra){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 Ho(o,o.defaultAttrs,e,H.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Ot.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 la(n,e){let t=[];for(let o=0;o<e.length;o++){let s=e[o],i=n.marks[s],r=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(r=a)}if(!r)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function Af(n){return n.tag!=null}function Pf(n){return n.style!=null}class Rt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(s=>{if(Af(s))this.tags.push(s);else if(Pf(s)){let i=/[^=]*/.exec(s.style)[0];o.indexOf(i)<0&&o.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let o=new pa(this,t,!1);return o.addAll(e,H.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new pa(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 i=this.tags[s];if(If(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let r=i.getAttrs(e);if(r===!1)continue;i.attrs=r||void 0}return i}}}matchStyle(e,t,o,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let r=this.styles[i],l=r.style;if(!(l.indexOf(e)!=0||r.context&&!o.matchesContext(r.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(r.getAttrs){let a=r.getAttrs(t);if(a===!1)continue;r.attrs=a||void 0}return r}}}static schemaRules(e){let t=[];function o(s){let i=s.priority==null?50:s.priority,r=0;for(;r<t.length;r++){let l=t[r];if((l.priority==null?50:l.priority)<i)break}t.splice(r,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(r=>{o(r=ua(r)),r.mark||r.ignore||r.clearMark||(r.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(r=>{o(r=ua(r)),r.node||r.ignore||r.mark||(r.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Rt(e,Rt.schemaRules(e)))}}const aa={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},Nf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ca={ol:!0,ul:!0},_o=1,Go=2,zn=4;function da(n,e,t){return e!=null?(e?_o:0)|(e==="full"?Go:0):n&&n.whitespace=="pre"?_o|Go:t&~zn}class Wo{constructor(e,t,o,s,i,r){this.type=e,this.attrs=t,this.marks=o,this.solid=s,this.options=r,this.content=[],this.activeMarks=H.none,this.match=i||(r&zn?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 i=o;o.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=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&&!aa.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class pa{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0;let s=t.topNode,i,r=da(null,t.preserveWhitespace,0)|(o?zn:0);s?i=new Wo(s.type,s.attrs,H.none,!0,t.topMatch||s.type.contentMatch,r):o?i=new Wo(null,null,H.none,!0,null,r):i=new Wo(e.schema.topNodeType,null,H.none,!0,null,r),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let o=e.nodeValue,s=this.top;if(s.options&Go||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(s.options&_o)s.options&Go?o=o.replace(/\r\n?/g,`
909
- `):o=o.replace(/\r?\n|\r/g," ");else if(o=o.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(o)&&this.open==this.nodes.length-1){let i=s.content[s.content.length-1],r=e.previousSibling;(!i||r&&r.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(o=o.slice(1))}o&&this.insertNode(this.parser.schema.text(o),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,o){let s=e.nodeName.toLowerCase(),i;ca.hasOwnProperty(s)&&this.parser.normalizeLists&&Of(e);let r=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,o));if(r?r.ignore:Nf.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!r||r.skip||r.closeParent){r&&r.closeParent?this.open=Math.max(0,this.open-1):r&&r.skip.nodeType&&(e=r.skip);let l,a=this.top,c=this.needsBlock;if(aa.hasOwnProperty(s))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),l=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);return}let d=r&&r.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),l&&this.sync(a),this.needsBlock=c}else{let l=this.readStyles(e,t);l&&this.addElementByRule(e,r,l,r.consuming===!1?i:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
910
- `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let o=e.style;if(o&&o.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],r=o.getPropertyValue(i);if(r)for(let l=void 0;;){let a=this.parser.matchStyle(i,r,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,o,s){let i,r;if(t.node)if(r=this.parser.schema.nodes[t.node],r.isLeaf)this.insertNode(r.create(t.attrs),o)||this.leafFallback(e,o);else{let a=this.enter(r,t.attrs||null,o,t.preserveWhitespace);a&&(i=!0,o=a)}else{let a=this.parser.schema.marks[t.mark];o=o.concat(a.create(t.attrs))}let l=this.top;if(r&&r.isLeaf)this.findInside(e);else if(s)this.addElement(e,o,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,o));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,o),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,o,s){let i=o||0;for(let r=o?e.childNodes[o]:e.firstChild,l=s==null?null:e.childNodes[s];r!=l;r=r.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(r,t);this.findAtPoint(e,i)}findPlace(e,t){let o,s;for(let i=this.open;i>=0;i--){let r=this.nodes[i],l=r.findWrapping(e);if(l&&(!o||o.length>l.length)&&(o=l,s=r,!l.length)||r.solid)break}if(!o)return null;this.sync(s);for(let i=0;i<o.length;i++)t=this.enterInner(o[i],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let o=this.findPlace(e,t);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=H.none;for(let r of o.concat(e.marks))(s.type?s.type.allowsMarkType(r.type):ha(r.type,e.type))&&(i=r.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,t,o,s){let i=this.findPlace(e.create(t),o);return i&&(i=this.enterInner(e,t,o,!0,s)),i}enterInner(e,t,o,s=!1,i){this.closeExtra();let r=this.top;r.match=r.match&&r.match.matchType(e);let l=da(e,i,r.options);r.options&zn&&r.content.length==0&&(l|=zn);let a=H.none;return o=o.filter(c=>(r.type?r.type.allowsMarkType(c.type):ha(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Wo(e,t,a,s,null,l)),this.open++,o}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let o=this.nodes[t].content;for(let s=o.length-1;s>=0;s--)e+=o[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let o=0;o<this.find.length;o++)this.find[o].node==e&&this.find[o].offset==t&&(this.find[o].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,o){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(o?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),o=this.options.context,s=!this.isOpen&&(!o||o.parent.type==this.nodes[0].type),i=-(o?o.depth+1:0)+(s?0:1),r=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(r(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:o&&a>=i?o.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return r(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(o&&o.isTextblock&&o.defaultAttrs)return o}for(let t in this.parser.schema.nodes){let o=this.parser.schema.nodes[t];if(o.isTextblock&&o.defaultAttrs)return o}}}function Of(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&ca.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function If(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function ua(n){let e={};for(let t in n)e[t]=n[t];return e}function ha(n,e){let t=e.schema.nodes;for(let o in t){let s=t[o];if(!s.allowsMarkType(n))continue;let i=[],r=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&r(d))return!0}};if(r(s.contentMatch))return!0}}class Dt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=ii(t).createDocumentFragment());let s=o,i=[];return e.forEach(r=>{if(i.length||r.marks.length){let l=0,a=0;for(;l<i.length&&a<r.marks.length;){let c=r.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<r.marks.length;){let c=r.marks[a++],d=this.serializeMark(c,r.isInline,t);d&&(i.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(r,t))}),o}serializeNodeInner(e,t){let{dom:o,contentDOM:s}=jo(ii(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return o}serializeNode(e,t={}){let o=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(o),o=i.dom)}return o}serializeMark(e,t,o={}){let s=this.marks[e.type.name];return s&&jo(ii(o),s(e,t),null,e.attrs)}static renderSpec(e,t,o=null,s){return jo(e,t,o,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Dt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=fa(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return fa(e.marks)}}function fa(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function ii(n){return n.document||window.document}const ma=new WeakMap;function Rf(n){let e=ma.get(n);return e===void 0&&ma.set(n,e=Df(n)),e}function Df(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 jo(n,e,t,o){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(i=Rf(o))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let r=s.indexOf(" ");r>0&&(t=s.slice(0,r),s=s.slice(r+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let p in c)if(c[p]!=null){let u=p.indexOf(" ");u>0?a.setAttributeNS(p.slice(0,u),p.slice(u+1),c[p]):a.setAttribute(p,c[p])}}for(let p=d;p<e.length;p++){let u=e[p];if(u===0){if(p<e.length-1||p>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}=jo(n,u,t,o);if(a.appendChild(h),f){if(l)throw new RangeError("Multiple content holes");l=f}}}return{dom:a,contentDOM:l}}const ga=65535,ya=Math.pow(2,16);function Lf(n,e){return n+e*ya}function ba(n){return n&ga}function $f(n){return(n-(n&ga))/ya}const va=1,Sa=2,qo=4,xa=8;class ri{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&xa)>0}get deletedBefore(){return(this.delInfo&(va|qo))>0}get deletedAfter(){return(this.delInfo&(Sa|qo))>0}get deletedAcross(){return(this.delInfo&qo)>0}}class Se{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Se.empty)return Se.empty}recover(e){let t=0,o=ba(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+$f(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,o){let s=0,i=this.inverted?2:1,r=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+r],p=a+c;if(e<=p){let u=c?e==a?-1:e==p?1:t:t,h=a+s+(u<0?0:d);if(o)return h;let f=e==(t<0?a:p)?null:Lf(l/3,e-a),m=e==a?Sa:e==p?va:qo;return(t<0?e!=a:e!=p)&&(m|=xa),new ri(h,m,f)}s+=d-c}return o?e+s:new ri(e+s,0,null)}touches(e,t){let o=0,s=ba(t),i=this.inverted?2:1,r=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==s*3)return!0;o+=this.ranges[l+r]-c}return!1}forEach(e){let t=this.inverted?2:1,o=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let r=this.ranges[s],l=r-(this.inverted?i:0),a=r+(this.inverted?0:i),c=this.ranges[s+t],d=this.ranges[s+o];e(l,l+c,a,a+d),i+=d-c}}invert(){return new Se(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Se.empty:new Se(e<0?[0,-e,0]:[0,0,e])}}Se.empty=new Se([]);class cn{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 cn(this.maps,this.mirror,e,t)}copy(){return new cn(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 cn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let o=this.from;o<this.to;o++)e=this.maps[o].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,o){let s=0;for(let i=this.from;i<this.to;i++){let r=this.maps[i],l=r.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this.maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return o?e:new ri(e,s,null)}}const li=Object.create(null);class oe{getMap(){return Se.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=li[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 li)throw new RangeError("Duplicate use of step JSON ID "+e);return li[e]=t,t.prototype.jsonID=e,t}}class K{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new K(e,null)}static fail(e){return new K(null,e)}static fromReplace(e,t,o,s){try{return K.ok(e.replace(t,o,s))}catch(i){if(i instanceof zo)return K.fail(i.message);throw i}}}function ai(n,e,t){let o=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy(ai(i.content,e,i))),i.isInline&&(i=e(i,t,s)),o.push(i)}return T.fromArray(o)}class rt 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)),i=new A(ai(t.content,(r,l)=>!r.isAtom||!l.type.allowsMarkType(this.mark.type)?r:r.mark(this.mark.addToSet(r.marks)),s),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,i)}invert(){return new Ve(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 rt(t.pos,o.pos,this.mark)}merge(e){return e instanceof rt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rt(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 rt(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("addMark",rt);class Ve 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(ai(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,o)}invert(){return new rt(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 Ve(t.pos,o.pos,this.mark)}merge(e){return e instanceof Ve&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ve(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ve(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("removeMark",Ve);class lt extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return K.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 lt(this.pos,t.marks[s]);return new lt(this.pos,this.mark)}}return new dn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new lt(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 lt(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("addNodeMark",lt);class dn extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return K.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 lt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new dn(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 dn(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("removeNodeMark",dn);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&&ci(e,this.from,this.to)?K.fail("Structure replace would overwrite content"):K.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Se([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,i,r,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=s,this.slice=i,this.insert=r,this.structure=l}apply(e){if(this.structure&&(ci(e,this.from,this.gapFrom)||ci(e,this.gapTo,this.to)))return K.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return K.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,t.content);return o?K.fromReplace(e,this.from,this.to,o):K.fail("Content does not fit in gap")}getMap(){return new Se([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),i=this.to==this.gapTo?o.pos:e.map(this.gapTo,1);return t.deletedAcross&&o.deletedAcross||s<t.pos||i>o.pos?null:new ee(t.pos,o.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ee(t.from,t.to,t.gapFrom,t.gapTo,A.fromJSON(e,t.slice),t.insert,!!t.structure)}}oe.jsonID("replaceAround",ee);function ci(n,e,t){let o=n.resolve(e),s=t-e,i=o.depth;for(;s>0&&i>0&&o.indexAfter(i)==o.node(i).childCount;)i--,s--;if(s>0){let r=o.node(i).maybeChild(o.indexAfter(i));for(;s>0;){if(!r||r.isLeaf)return!0;r=r.firstChild,s--}}return!1}function zf(n,e,t,o){let s=[],i=[],r,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let p=a.marks;if(!o.isInSet(p)&&d.type.allowsMarkType(o.type)){let u=Math.max(c,e),h=Math.min(c+a.nodeSize,t),f=o.addToSet(p);for(let m=0;m<p.length;m++)p[m].isInSet(f)||(r&&r.to==u&&r.mark.eq(p[m])?r.to=h:s.push(r=new Ve(u,h,p[m])));l&&l.to==u?l.to=h:i.push(l=new rt(u,h,o))}}),s.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function Bf(n,e,t,o){let s=[],i=0;n.doc.nodesBetween(e,t,(r,l)=>{if(!r.isInline)return;i++;let a=null;if(o instanceof Fo){let c=r.marks,d;for(;d=o.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else o?o.isInSet(r.marks)&&(a=[o]):a=r.marks;if(a&&a.length){let c=Math.min(l+r.nodeSize,t);for(let d=0;d<a.length;d++){let p=a[d],u;for(let h=0;h<s.length;h++){let f=s[h];f.step==i-1&&p.eq(s[h].style)&&(u=f)}u?(u.to=c,u.step=i):s.push({style:p,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(r=>n.step(new Ve(r.from,r.to,r.style)))}function di(n,e,t,o=t.contentMatch,s=!0){let i=n.doc.nodeAt(e),r=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,p=o.matchType(c.type);if(!p)r.push(new se(l,d,A.empty));else{o=p;for(let u=0;u<c.marks.length;u++)t.allowsMarkType(c.marks[u].type)||n.step(new Ve(l,d,c.marks[u]));if(s&&c.isText&&t.whitespace!="pre"){let u,h=/\r?\n|\r/g,f;for(;u=h.exec(c.text);)f||(f=new A(T.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),r.push(new se(l+u.index,l+u.index+u[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=r.length-1;a>=0;a--)n.step(r[a])}function Vf(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Uo(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth;;--o){let s=n.$from.node(o),i=n.$from.index(o),r=n.$to.indexAfter(o);if(o<n.depth&&s.canReplace(i,r,t))return o;if(o==0||s.type.spec.isolating||!Vf(s,i,r))break}return null}function Hf(n,e,t){let{$from:o,$to:s,depth:i}=e,r=o.before(i+1),l=s.after(i+1),a=r,c=l,d=T.empty,p=0;for(let f=i,m=!1;f>t;f--)m||o.index(f)>0?(m=!0,d=T.from(o.node(f).copy(d)),p++):a--;let u=T.empty,h=0;for(let f=i,m=!1;f>t;f--)m||s.after(f+1)<s.end(f)?(m=!0,u=T.from(s.node(f).copy(u)),h++):c++;n.step(new ee(a,c,r,l,new A(d.append(u),p,h),d.size-p,!0))}function wa(n,e,t=null,o=n){let s=Ff(n,e),i=s&&_f(o,e);return i?s.map(Ca).concat({type:e,attrs:t}).concat(i.map(Ca)):null}function Ca(n){return{type:n,attrs:null}}function Ff(n,e){let{parent:t,startIndex:o,endIndex:s}=n,i=t.contentMatchAt(o).findWrapping(e);if(!i)return null;let r=i.length?i[0]:e;return t.canReplaceWith(o,s,r)?i:null}function _f(n,e){let{parent:t,startIndex:o,endIndex:s}=n,i=t.child(o),r=e.contentMatch.findWrapping(i.type);if(!r)return null;let a=(r.length?r[r.length-1]:e).contentMatch;for(let c=o;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:r}function Gf(n,e,t){let o=T.empty;for(let r=t.length-1;r>=0;r--){if(o.size){let l=t[r].type.contentMatch.matchFragment(o);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=T.from(t[r].type.create(t[r].attrs,o))}let s=e.start,i=e.end;n.step(new ee(s,i,s,i,new A(o,0,0),t.length,!0))}function Wf(n,e,t,o,s){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(r,l)=>{let a=typeof s=="function"?s(r):s;if(r.isTextblock&&!r.hasMarkup(o,a)&&jf(n.doc,n.mapping.slice(i).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&&Ea(n,r,l,i),di(n,n.mapping.slice(i).map(l,1),o,void 0,c===null);let d=n.mapping.slice(i),p=d.map(l,1),u=d.map(l+r.nodeSize,1);return n.step(new ee(p,u,p+1,u-1,new A(T.from(o.create(a,null,r.marks)),0,0),1,!0)),c===!0&&ka(n,r,l,i),!1}})}function ka(n,e,t,o){e.forEach((s,i)=>{if(s.isText){let r,l=/\r?\n|\r/g;for(;r=l.exec(s.text);){let a=n.mapping.slice(o).map(t+1+i+r.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Ea(n,e,t,o){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let r=n.mapping.slice(o).map(t+1+i);n.replaceWith(r,r+1,e.type.schema.text(`
911
- `))}})}function jf(n,e,t){let o=n.resolve(e),s=o.index();return o.parent.canReplaceWith(s,s+1,t)}function qf(n,e,t,o,s){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let r=t.create(o,null,s||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,r);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ee(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new A(T.from(r),0,0),1,!0))}function pn(n,e,t=1,o){let s=n.resolve(e),i=s.depth-t,r=o&&o[o.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!r.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>i;c--,d--){let p=s.node(c),u=s.index(c);if(p.type.spec.isolating)return!1;let h=p.content.cutByIndex(u,p.childCount),f=o&&o[d+1];f&&(h=h.replaceChild(0,f.type.create(f.attrs)));let m=o&&o[d]||p;if(!p.canReplace(u+1,p.childCount)||!m.type.validContent(h))return!1}let l=s.indexAfter(i),a=o&&o[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function Uf(n,e,t=1,o){let s=n.doc.resolve(e),i=T.empty,r=T.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){i=T.from(s.node(l).copy(i));let d=o&&o[c];r=T.from(d?d.type.create(d.attrs,r):s.node(l).copy(r))}n.step(new se(e,e,new A(i.append(r),t,t),!0))}function Ko(n,e){let t=n.resolve(e),o=t.index();return Jf(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function Kf(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:o}=n.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),r=i.type==o?n.type.schema.nodes.text:i.type;if(t=t.matchType(r),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function Jf(n,e){return!!(n&&e&&!n.isLeaf&&Kf(n,e))}function Zf(n,e,t){let o=null,{linebreakReplacement:s}=n.doc.type.schema,i=n.doc.resolve(e-t),r=i.node().type;if(s&&r.inlineContent){let d=r.whitespace=="pre",p=!!r.contentMatch.matchType(s);d&&!p?o=!1:!d&&p&&(o=!0)}let l=n.steps.length;if(o===!1){let d=n.doc.resolve(e+t);Ea(n,d.node(),d.before(),l)}r.inlineContent&&di(n,e+t-1,r,i.node().contentMatchAt(i.index()),o==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new se(c,a.map(e+t,-1),A.empty,!0)),o===!0){let d=n.doc.resolve(c);ka(n,d.node(),d.before(),n.steps.length)}return n}function Yf(n,e,t){let o=n.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),t))return e;if(o.parentOffset==0)for(let s=o.depth-1;s>=0;s--){let i=o.index(s);if(o.node(s).canReplaceWith(i,i,t))return o.before(s+1);if(i>0)return null}if(o.parentOffset==o.parent.content.size)for(let s=o.depth-1;s>=0;s--){let i=o.indexAfter(s);if(o.node(s).canReplaceWith(i,i,t))return o.after(s+1);if(i<o.node(s).childCount)return null}return null}function Xf(n,e,t){let o=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let i=0;i<t.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let r=o.depth;r>=0;r--){let l=r==o.depth?0:o.pos<=(o.start(r+1)+o.end(r+1))/2?-1:1,a=o.index(r)+(l>0?1:0),c=o.node(r),d=!1;if(i==1)d=c.canReplace(a,a,s);else{let p=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=p&&c.canReplaceWith(a,a,p[0])}if(d)return l==0?o.pos:l<0?o.before(r+1):o.after(r+1)}return null}function pi(n,e,t=e,o=A.empty){if(e==t&&!o.size)return null;let s=n.resolve(e),i=n.resolve(t);return Ta(s,i,o)?new se(e,t,o):new Qf(s,i,o).fit()}function Ta(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Qf{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 i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=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 i=this.placed,r=o.depth,l=s.depth;for(;r&&l&&i.childCount==1;)i=i.firstChild.content,r--,l--;let a=new A(i,r,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 i=t.firstChild;if(t.childCount>1&&(s=0),i.type.spec.isolating&&s<=o){e=o;break}t=i.content}for(let t=1;t<=2;t++)for(let o=t==1?e:this.unplaced.openStart;o>=0;o--){let s,i=null;o?(i=ui(this.unplaced.content,o-1).firstChild,s=i.content):s=this.unplaced.content;let r=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,p=null;if(t==1&&(r?c.matchType(r.type)||(p=c.fillBefore(T.from(r),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:o,frontierDepth:l,parent:i,inject:p};if(t==2&&r&&(d=c.findWrapping(r.type)))return{sliceDepth:o,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:o}=this.unplaced,s=ui(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=ui(e,t);if(s.childCount<=1&&t>0){let i=e.size-t<=t+s.size;this.unplaced=new A(Bn(e,t-1,1),t-1,i?t-1:o)}else this.unplaced=new A(Bn(e,t,1),t,o)}placeNodes({sliceDepth:e,frontierDepth:t,parent:o,inject:s,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let r=this.unplaced,l=o?o.content:r.content,a=r.openStart-e,c=0,d=[],{match:p,type:u}=this.frontier[t];if(s){for(let m=0;m<s.childCount;m++)d.push(s.child(m));p=p.matchFragment(s)}let h=l.size+e-(r.content.size-r.openEnd);for(;c<l.childCount;){let m=l.child(c),g=p.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(p=g,d.push(Ma(m.mark(u.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let f=c==l.childCount;f||(h=-1),this.placed=Vn(this.placed,t,T.from(d)),this.frontier[t].match=p,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(Bn(r.content,e-1,1),e-1,h<0?r.openEnd:e-1):new A(Bn(r.content,e,c),r.openStart,r.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!hi(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:o}=this.$to,s=this.$to.after(o);for(;o>1&&s==this.$to.end(--o);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:o,type:s}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),r=hi(e,t,s,o,i);if(r){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=hi(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:r,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Vn(this.placed,t.depth,t.fit)),e=t.move;for(let o=t.depth+1;o<=e.depth;o++){let s=e.node(o),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(o));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,t=null,o){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Vn(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=Vn(this.placed,this.frontier.length,t))}}function Bn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Bn(n.firstChild.content,e-1,t)))}function Vn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Vn(n.lastChild.content,e-1,t)))}function ui(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Ma(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,Ma(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 hi(n,e,t,o,s){let i=n.node(e),r=s?n.indexAfter(e):n.index(e);if(r==i.childCount&&!t.compatibleContent(i.type))return null;let l=o.fillBefore(i.content,!0,r);return l&&!em(t,i.content,r)?l:null}function em(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function tm(n){return n.spec.defining||n.spec.definingForContent}function nm(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),i=n.doc.resolve(t);if(Ta(s,i,o))return n.step(new se(e,t,o));let r=Pa(s,n.doc.resolve(t));r[r.length-1]==0&&r.pop();let l=-(s.depth+1);r.unshift(l);for(let u=s.depth,h=s.pos-1;u>0;u--,h--){let f=s.node(u).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;r.indexOf(u)>-1?l=u:s.before(u)==h&&r.splice(1,0,-u)}let a=r.indexOf(l),c=[],d=o.openStart;for(let u=o.content,h=0;;h++){let f=u.firstChild;if(c.push(f),h==o.openStart)break;u=f.content}for(let u=d-1;u>=0;u--){let h=c[u],f=tm(h.type);if(f&&!h.sameMarkup(s.node(Math.abs(l)-1)))d=u;else if(f||!h.type.isTextblock)break}for(let u=o.openStart;u>=0;u--){let h=(u+d+1)%(o.openStart+1),f=c[h];if(f)for(let m=0;m<r.length;m++){let g=r[(m+a)%r.length],b=!0;g<0&&(b=!1,g=-g);let w=s.node(g-1),y=s.index(g-1);if(w.canReplaceWith(y,y,f.type,f.marks))return n.replace(s.before(g),b?i.after(g):t,new A(Aa(o.content,0,o.openStart,h),h,o.openEnd))}}let p=n.steps.length;for(let u=r.length-1;u>=0&&(n.replace(e,t,o),!(n.steps.length>p));u--){let h=r[u];h<0||(e=s.before(h),t=i.after(h))}}function Aa(n,e,t,o,s){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(Aa(i.content,e+1,t,o,i)))}if(e>o){let i=s.contentMatchAt(0),r=i.fillBefore(n).append(n);n=r.append(i.matchFragment(r).fillBefore(T.empty,!0))}return n}function om(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=Yf(n.doc,e,o.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new A(T.from(o),0,0))}function sm(n,e,t){let o=n.doc.resolve(e),s=n.doc.resolve(t),i=Pa(o,s);for(let r=0;r<i.length;r++){let l=i[r],a=r==i.length-1;if(a&&l==0||o.node(l).type.contentMatch.validEnd)return n.delete(o.start(l),s.end(l));if(l>0&&(a||o.node(l-1).canReplace(o.index(l-1),s.indexAfter(l-1))))return n.delete(o.before(l),s.after(l))}for(let r=1;r<=o.depth&&r<=s.depth;r++)if(e-o.start(r)==o.depth-r&&t>o.end(r)&&s.end(r)-t!=s.depth-r&&o.start(r-1)==s.start(r-1)&&o.node(r-1).canReplace(o.index(r-1),s.index(r-1)))return n.delete(o.before(r),t);n.delete(e,t)}function Pa(n,e){let t=[],o=Math.min(n.depth,e.depth);for(let s=o;s>=0;s--){let i=n.start(s);if(i<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&t.push(s)}return t}class un 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 K.fail("No node at attribute step's position");let o=Object.create(null);for(let i in t.attrs)o[i]=t.attrs[i];o[this.attr]=this.value;let s=t.type.create(o,null,t.marks);return K.fromReplace(e,this.pos,this.pos+1,new A(T.from(s),0,t.isLeaf?0:1))}getMap(){return Se.empty}invert(e){return new un(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 un(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 un(t.pos,t.attr,t.value)}}oe.jsonID("attr",un);class Hn 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 K.ok(o)}getMap(){return Se.empty}invert(e){return new Hn(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 Hn(t.attr,t.value)}}oe.jsonID("docAttr",Hn);let hn=class extends Error{};hn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},hn.prototype=Object.create(Error.prototype),hn.prototype.constructor=hn,hn.prototype.name="TransformError";class Na{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new cn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new hn(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=pi(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 nm(this,e,t,o),this}replaceRangeWith(e,t,o){return om(this,e,t,o),this}deleteRange(e,t){return sm(this,e,t),this}lift(e,t){return Hf(this,e,t),this}join(e,t=1){return Zf(this,e,t),this}wrap(e,t){return Gf(this,e,t),this}setBlockType(e,t=e,o,s=null){return Wf(this,e,t,o,s),this}setNodeMarkup(e,t,o=null,s){return qf(this,e,t,o,s),this}setNodeAttribute(e,t,o){return this.step(new un(e,t,o)),this}setDocAttribute(e,t){return this.step(new Hn(e,t)),this}addNodeMark(e,t){return this.step(new lt(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 dn(e,t)),this}split(e,t=1,o){return Uf(this,e,t,o),this}addMark(e,t,o){return zf(this,e,t,o),this}removeMark(e,t,o){return Bf(this,e,t,o),this}clearIncompatible(e,t,o){return di(this,e,t,o),this}}const fi=Object.create(null);class L{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new Oa(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 i=e.steps.length,r=this.ranges;for(let l=0;l<r.length;l++){let{$from:a,$to:c}=r[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?A.empty:t),l==0&&Da(e,i,(o?o.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let o=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:r,$to:l}=s[i],a=e.mapping.slice(o),c=a.map(r.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),Da(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let s=e.parent.inlineContent?new $(e):fn(e.node(0),e.parent,e.pos,e.index(),t,o);if(s)return s;for(let i=e.depth-1;i>=0;i--){let r=t<0?fn(e.node(0),e.node(i),e.before(i+1),e.index(i),t,o):fn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,o);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new xe(e.node(0))}static atStart(e){return fn(e,e,0,0,1)||new xe(e)}static atEnd(e){return fn(e,e,e.content.size,e.childCount,-1)||new xe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let o=fi[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 fi)throw new RangeError("Duplicate use of selection JSON ID "+e);return fi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return $.between(this.$anchor,this.$head).getBookmark()}}L.prototype.visible=!0;class Oa{constructor(e,t){this.$from=e,this.$to=t}}let Ia=!1;function Ra(n){!Ia&&!n.parent.inlineContent&&(Ia=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class $ extends L{constructor(e,t=e){Ra(e),Ra(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 L.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 Jo(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 i=L.findFrom(t,o,!0)||L.findFrom(t,-o,!0);if(i)t=i.$head;else return L.near(t,o)}return e.parent.inlineContent||(s==0?e=t:(e=(L.findFrom(e,-o,!0)||L.findFrom(e,o,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new $(e,t)}}L.jsonID("text",$);class Jo{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Jo(e.map(this.anchor),e.map(this.head))}resolve(e){return $.between(e.resolve(this.anchor),e.resolve(this.head))}}class D extends L{constructor(e){let t=e.nodeAfter,o=e.node(0).resolve(e.pos+t.nodeSize);super(e,o),this.node=t}map(e,t){let{deleted:o,pos:s}=t.mapResult(this.anchor),i=e.resolve(s);return o?L.near(i):new D(i)}content(){return new A(T.from(this.node),0,0)}eq(e){return e instanceof D&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new mi(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new D(e.resolve(t.anchor))}static create(e,t){return new D(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}D.prototype.visible=!1,L.jsonID("node",D);class mi{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new Jo(o,o):new mi(o)}resolve(e){let t=e.resolve(this.anchor),o=t.nodeAfter;return o&&D.isSelectable(o)?new D(t):L.near(t)}}class xe extends L{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=L.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new xe(e)}map(e){return new xe(e)}eq(e){return e instanceof xe}getBookmark(){return im}}L.jsonID("all",xe);const im={map(){return this},resolve(n){return new xe(n)}};function fn(n,e,t,o,s,i=!1){if(e.inlineContent)return $.create(n,t);for(let r=o-(s>0?0:1);s>0?r<e.childCount:r>=0;r+=s){let l=e.child(r);if(l.isAtom){if(!i&&D.isSelectable(l))return D.create(n,t-(s<0?l.nodeSize:0))}else{let a=fn(n,l,t+s,s<0?l.childCount:0,s,i);if(a)return a}t+=l.nodeSize*s}return null}function Da(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 i=n.mapping.maps[o],r;i.forEach((l,a,c,d)=>{r==null&&(r=d)}),n.setSelection(L.near(n.doc.resolve(r),t))}const La=1,Zo=2,$a=4;class rm extends Na{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|La)&~Zo,this.storedMarks=null,this}get selectionSet(){return(this.updated&La)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Zo,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&Zo)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Zo,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 i=this.storedMarks;if(!i){let r=this.doc.resolve(t);i=o==t?r.marks():r.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(t,o,s.text(e,i)),this.selection.empty||this.setSelection(L.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|=$a,this}get scrolledIntoView(){return(this.updated&$a)>0}}function za(n,e){return!e||!n?n:n.bind(e)}class Fn{constructor(e,t,o){this.name=e,this.init=za(t.init,o),this.apply=za(t.apply,o)}}const lm=[new Fn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Fn("selection",{init(n,e){return n.selection||L.atStart(e.doc)},apply(n){return n.selection}}),new Fn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new Fn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class gi{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=lm.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 Fn(o.key,o.spec.state,o))})}}class mn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let o=0;o<this.config.plugins.length;o++)if(o!=t){let s=this.config.plugins[o];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],o=this.applyInner(e),s=null;for(;;){let i=!1;for(let r=0;r<this.config.plugins.length;r++){let l=this.config.plugins[r];if(l.spec.appendTransaction){let a=s?s[r].n:0,c=s?s[r].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,o);if(d&&o.filterTransaction(d,r)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let p=0;p<this.config.plugins.length;p++)s.push(p<r?{state:o,n:t.length}:{state:this,n:0})}t.push(d),o=o.applyInner(d),i=!0}s&&(s[r]={state:o,n:t.length})}}if(!i)return{state:o,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new mn(this.config),o=this.config.fields;for(let s=0;s<o.length;s++){let i=o[s];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new rm(this)}static create(e){let t=new gi(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new mn(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 gi(this.schema,e.plugins),o=t.fields,s=new mn(t);for(let i=0;i<o.length;i++){let r=o[i].name;s[r]=this.hasOwnProperty(r)?this[r]:o[i].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(o=>o.toJSON())),e&&typeof e=="object")for(let o in e){if(o=="doc"||o=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[o],i=s.spec.state;i&&i.toJSON&&(t[o]=i.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,o){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new gi(e.schema,e.plugins),i=new mn(s);return s.fields.forEach(r=>{if(r.name=="doc")i.doc=Ot.fromJSON(e.schema,t.doc);else if(r.name=="selection")i.selection=L.fromJSON(i.doc,t.selection);else if(r.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(o)for(let l in o){let a=o[l],c=a.spec.state;if(a.key==r.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[r.name]=c.fromJSON.call(a,e,t[l],i);return}}i[r.name]=r.init(e,i)}}),i}}function Ba(n,e,t){for(let o in n){let s=n[o];s instanceof Function?s=s.bind(e):o=="handleDOMEvents"&&(s=Ba(s,e,{})),t[o]=s}return t}class gn{constructor(e){this.spec=e,this.props={},e.props&&Ba(e.props,this,this.props),this.key=e.key?e.key.key:Va("plugin")}getState(e){return e[this.key]}}const yi=Object.create(null);function Va(n){return n in yi?n+"$"+ ++yi[n]:(yi[n]=0,n+"$")}class _n{constructor(e="key"){this.key=Va(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ha=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function am(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const cm=(n,e,t)=>{let o=am(n,t);if(!o)return!1;let s=Fa(o);if(!s){let r=o.blockRange(),l=r&&Uo(r);return l==null?!1:(e&&e(n.tr.lift(r,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(Ua(n,s,e,-1))return!0;if(o.parent.content.size==0&&(yn(i,"end")||D.isSelectable(i)))for(let r=o.depth;;r--){let l=pi(n.doc,o.before(r),o.after(r),A.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(yn(i,"end")?L.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):D.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(r==1||o.node(r-1).childCount>1)break}return i.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1};function yn(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 dm=(n,e,t)=>{let{$head:o,empty:s}=n.selection,i=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):o.parentOffset>0)return!1;i=Fa(o)}let r=i&&i.nodeBefore;return!r||!D.isSelectable(r)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,i.pos-r.nodeSize)).scrollIntoView()),!0)};function Fa(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 pm(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const um=(n,e,t)=>{let o=pm(n,t);if(!o)return!1;let s=_a(o);if(!s)return!1;let i=s.nodeAfter;if(Ua(n,s,e,1))return!0;if(o.parent.content.size==0&&(yn(i,"start")||D.isSelectable(i))){let r=pi(n.doc,o.before(),o.after(),A.empty);if(r&&r.slice.size<r.to-r.from){if(e){let l=n.tr.step(r);l.setSelection(yn(i,"start")?L.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):D.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==o.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},hm=(n,e,t)=>{let{$head:o,empty:s}=n.selection,i=o;if(!s)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):o.parentOffset<o.parent.content.size)return!1;i=_a(o)}let r=i&&i.nodeAfter;return!r||!D.isSelectable(r)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,i.pos)).scrollIntoView()),!0)};function _a(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 fm=(n,e)=>{let{$head:t,$anchor:o}=n.selection;return!t.parent.type.spec.code||!t.sameParent(o)?!1:(e&&e(n.tr.insertText(`
912
- `).scrollIntoView()),!0)};function bi(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 Ga=(n,e)=>{let{$head:t,$anchor:o}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(o))return!1;let s=t.node(-1),i=t.indexAfter(-1),r=bi(s.contentMatchAt(i));if(!r||!s.canReplaceWith(i,i,r))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,r.createAndFill());a.setSelection(L.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},mm=(n,e)=>{let t=n.selection,{$from:o,$to:s}=t;if(t instanceof xe||o.parent.inlineContent||s.parent.inlineContent)return!1;let i=bi(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let r=(!o.parentOffset&&s.index()<s.parent.childCount?o:s).pos,l=n.tr.insert(r,i.createAndFill());l.setSelection($.create(l.doc,r+1)),e(l.scrollIntoView())}return!0},Wa=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(pn(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let o=t.blockRange(),s=o&&Uo(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)};function ja(n){return(e,t)=>{let{$from:o,$to:s}=e.selection;if(e.selection instanceof D&&e.selection.node.isBlock)return!o.parentOffset||!pn(e.doc,o.pos)?!1:(t&&t(e.tr.split(o.pos).scrollIntoView()),!0);if(!o.depth)return!1;let i=[],r,l,a=!1,c=!1;for(let 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=bi(o.node(h-1).contentMatchAt(o.indexAfter(h-1)));let m=n&&n(s.parent,a,o);i.unshift(m||(a&&l?{type:l}:null)),r=h;break}else{if(h==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof $||e.selection instanceof xe)&&d.deleteSelection();let p=d.mapping.map(o.pos),u=pn(d.doc,p,i.length,i);if(u||(i[0]=l?{type:l}:null,u=pn(d.doc,p,i.length,i)),d.split(p,i.length,i),!a&&c&&o.node(r).type!=l){let h=d.mapping.map(o.before(r)),f=d.doc.resolve(h);l&&o.node(r-1).canReplaceWith(f.index(),f.index()+1,l)&&d.setNodeMarkup(d.mapping.map(o.before(r)),l)}return t&&t(d.scrollIntoView()),!0}}const gm=ja(),qa=(n,e)=>(e&&e(n.tr.setSelection(new xe(n.doc))),!0);function ym(n,e,t){let o=e.nodeBefore,s=e.nodeAfter,i=e.index();return!o||!s||!o.type.compatibleContent(s.type)?!1:!o.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||Ko(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Ua(n,e,t,o){let s=e.nodeBefore,i=e.nodeAfter,r,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&ym(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(r=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(r[0]||i.type).validEnd){if(t){let h=e.pos+i.nodeSize,f=T.empty;for(let b=r.length-1;b>=0;b--)f=T.from(r[b].create(null,f));f=T.from(s.copy(f));let m=n.tr.step(new ee(e.pos-1,h,e.pos,h,new A(f,1,0),r.length,!0)),g=m.doc.resolve(h+2*r.length);g.nodeAfter&&g.nodeAfter.type==s.type&&Ko(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||o>0&&a?null:L.findFrom(e,1),p=d&&d.$from.blockRange(d.$to),u=p&&Uo(p);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(p,u).scrollIntoView()),!0;if(c&&yn(i,"start",!0)&&yn(s,"end")){let h=s,f=[];for(;f.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let b=T.empty;for(let y=f.length-1;y>=0;y--)b=T.from(f[y].copy(b));let w=n.tr.step(new ee(e.pos-f.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new A(b,f.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function Ka(n){return function(e,t){let o=e.selection,s=n<0?o.$from:o.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(t&&t(e.tr.setSelection($.create(e.doc,n<0?s.start(i):s.end(i)))),!0):!1}}const bm=Ka(-1),vm=Ka(1);function Sm(n,e=null){return function(t,o){let s=!1;for(let i=0;i<t.selection.ranges.length&&!s;i++){let{$from:{pos:r},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(r,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let d=t.doc.resolve(c),p=d.index();s=d.parent.canReplaceWith(p,p+1,n)}})}if(!s)return!1;if(o){let i=t.tr;for(let r=0;r<t.selection.ranges.length;r++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[r];i.setBlockType(l,a,n,e)}o(i.scrollIntoView())}return!0}}function xm(n,e,t,o){for(let s=0;s<e.length;s++){let{$from:i,$to:r}=e[s],l=i.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(i.pos,r.pos,(a,c)=>{if(l||!o)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function Lt(n,e=null,t){let o=t!==!1;return function(s,i){let{empty:r,$cursor:l,ranges:a}=s.selection;if(r&&!l||!xm(s.doc,a,n,o))return!1;if(i)if(l)n.isInSet(s.storedMarks||l.marks())?i(s.tr.removeStoredMark(n)):i(s.tr.addStoredMark(n.create(e)));else{let c,d=s.tr;c=!a.some(p=>s.doc.rangeHasMark(p.$from.pos,p.$to.pos,n));for(let p=0;p<a.length;p++){let{$from:u,$to:h}=a[p];if(!c)d.removeMark(u.pos,h.pos,n);else{let f=u.pos,m=h.pos,g=u.nodeAfter,b=h.nodeBefore,w=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,y=b&&b.isText?/\s*$/.exec(b.text)[0].length:0;f+w<m&&(f+=w,m-=y),d.addMark(f,m,n.create(e))}}i(d.scrollIntoView())}return!0}}function Gn(...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 vi=Gn(Ha,cm,dm),Ja=Gn(Ha,um,hm);const Ze={Enter:Gn(fm,mm,Wa,gm),"Mod-Enter":Ga,Backspace:vi,"Mod-Backspace":vi,"Shift-Backspace":vi,Delete:Ja,"Mod-Delete":Ja,"Mod-a":qa},Za={"Ctrl-h":Ze.Backspace,"Alt-Backspace":Ze["Mod-Backspace"],"Ctrl-d":Ze.Delete,"Ctrl-Alt-Backspace":Ze["Mod-Delete"],"Alt-Delete":Ze["Mod-Delete"],"Alt-d":Ze["Mod-Delete"],"Ctrl-a":bm,"Ctrl-e":vm};for(let n in Ze)Za[n]=Ze[n];const wm=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?Za:Ze;var Yo=200,Z=function(){};Z.prototype.append=function(e){return e.length?(e=Z.from(e),!this.length&&e||e.length<Yo&&this.leafAppend(e)||this.length<Yo&&e.leafPrepend(this)||this.appendInner(e)):this},Z.prototype.prepend=function(e){return e.length?Z.from(e).append(this):this},Z.prototype.appendInner=function(e){return new Cm(this,e)},Z.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Z.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Z.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Z.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)},Z.prototype.map=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length);var s=[];return this.forEach(function(i,r){return s.push(e(i,r))},t,o),s},Z.from=function(e){return e instanceof Z?e:e&&e.length?new Ya(e):Z.empty};var Ya=function(n){function e(o){n.call(this),this.values=o}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,r,l){for(var a=i;a<r;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,r,l){for(var a=i-1;a>=r;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Yo)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Yo)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}(Z);Z.empty=new Ya([]);var Cm=function(n){function e(t,o){n.call(this),this.left=t,this.right=o,this.length=t.length+o.length,this.depth=Math.max(t.depth,o.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(o){return o<this.left.length?this.left.get(o):this.right.get(o-this.left.length)},e.prototype.forEachInner=function(o,s,i,r){var l=this.left.length;if(s<l&&this.left.forEachInner(o,s,Math.min(i,l),r)===!1||i>l&&this.right.forEachInner(o,Math.max(s-l,0),Math.min(this.length,i)-l,r+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,i,r){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(o,s-l,Math.max(i,l)-l,r+l)===!1||i<l&&this.left.forEachInvertedInner(o,Math.min(s,l),i,r)===!1)return!1},e.prototype.sliceInner=function(o,s){if(o==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(o,s):o>=i?this.right.slice(o-i,s-i):this.left.slice(o,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(o){var s=this.right.leafAppend(o);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(o){var s=this.left.leafPrepend(o);if(s)return new e(s,this.right)},e.prototype.appendInner=function(o){return this.left.depth>=Math.max(this.right.depth,o.depth)+1?new e(this.left,new e(this.right,o)):new e(this,o)},e}(Z);const km=500;class Ie{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}let s,i;t&&(s=this.remapping(o,this.items.length),i=s.maps.length);let r=e.tr,l,a,c=[],d=[];return this.items.forEach((p,u)=>{if(!p.step){s||(s=this.remapping(o,u+1),i=s.maps.length),i--,d.push(p);return}if(s){d.push(new He(p.map));let h=p.step.map(s.slice(i)),f;h&&r.maybeStep(h).doc&&(f=r.mapping.maps[r.mapping.maps.length-1],c.push(new He(f,void 0,void 0,c.length+d.length))),i--,f&&s.appendMap(f,i)}else r.maybeStep(p.step);if(p.selection)return l=s?p.selection.map(s.slice(i)):p.selection,a=new Ie(this.items.slice(0,o).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:r,selection:l}}addTransform(e,t,o,s){let i=[],r=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let p=e.steps[d].invert(e.docs[d]),u=new He(e.mapping.maps[d],p,t),h;(h=a&&a.merge(u))&&(u=h,d?i.pop():l=l.slice(0,l.length-1)),i.push(u),t&&(r++,t=void 0),s||(a=u)}let c=r-o.depth;return c>Tm&&(l=Em(l,c),r-=c),new Ie(l.append(i),r)}remapping(e,t){let o=new cn;return this.items.forEach((s,i)=>{let r=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?o.maps.length-s.mirrorOffset:void 0;o.appendMap(s.map,r)},e,t),o}addMaps(e){return this.eventCount==0?this:new Ie(this.items.append(e.map(t=>new He(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],s=Math.max(0,this.items.length-t),i=e.mapping,r=e.steps.length,l=this.eventCount;this.items.forEach(u=>{u.selection&&l--},s);let a=t;this.items.forEach(u=>{let h=i.getMirror(--a);if(h==null)return;r=Math.min(r,h);let f=i.maps[h];if(u.step){let m=e.steps[h].invert(e.docs[h]),g=u.selection&&u.selection.map(i.slice(a+1,h));g&&l++,o.push(new He(f,m,g))}else o.push(new He(f))},s);let c=[];for(let u=t;u<r;u++)c.push(new He(i.maps[u]));let d=this.items.slice(0,s).append(c).append(o),p=new Ie(d,l);return p.emptyItemCount()>km&&(p=p.compress(this.items.length-o.length)),p}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),o=t.maps.length,s=[],i=0;return this.items.forEach((r,l)=>{if(l>=e)s.push(r),r.selection&&i++;else if(r.step){let a=r.step.map(t.slice(o)),c=a&&a.getMap();if(o--,c&&t.appendMap(c,o),a){let d=r.selection&&r.selection.map(t.slice(o));d&&i++;let p=new He(c.invert(),a,d),u,h=s.length-1;(u=s.length&&s[h].merge(p))?s[h]=u:s.push(p)}}else r.map&&o--},this.items.length,0),new Ie(Z.from(s.reverse()),i)}}Ie.empty=new Ie(Z.empty,0);function Em(n,e){let t;return n.forEach((o,s)=>{if(o.selection&&e--==0)return t=s,!1}),n.slice(t)}class He{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 He(t.getMap().invert(),t,this.selection)}}}class at{constructor(e,t,o,s,i){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=s,this.prevComposition=i}}const Tm=20;function Mm(n,e,t,o){let s=t.getMeta($t),i;if(s)return s.historyState;t.getMeta(Nm)&&(n=new at(n.done,n.undone,null,0,-1));let r=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(r&&r.getMeta($t))return r.getMeta($t).redo?new at(n.done.addTransform(t,void 0,o,Xo(e)),n.undone,Xa(t.mapping.maps),n.prevTime,n.prevComposition):new at(n.done,n.undone.addTransform(t,void 0,o,Xo(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(r&&r.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!r&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!Am(t,n.prevRanges)),c=r?Si(n.prevRanges,t.mapping):Xa(t.mapping.maps);return new at(n.done.addTransform(t,a?e.selection.getBookmark():void 0,o,Xo(e)),Ie.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new at(n.done.rebased(t,i),n.undone.rebased(t,i),Si(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new at(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Si(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Am(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((o,s)=>{for(let i=0;i<e.length;i+=2)o<=e[i+1]&&s>=e[i]&&(t=!0)}),t}function Xa(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,s,i,r)=>e.push(i,r));return e}function Si(n,e){if(!n)return null;let t=[];for(let o=0;o<n.length;o+=2){let s=e.map(n[o],1),i=e.map(n[o+1],-1);s<=i&&t.push(s,i)}return t}function Pm(n,e,t){let o=Xo(e),s=$t.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,o);if(!i)return null;let r=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),s,o),a=new at(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(r).setMeta($t,{redo:t,historyState:a})}let xi=!1,Qa=null;function Xo(n){let e=n.plugins;if(Qa!=e){xi=!1,Qa=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){xi=!0;break}}return xi}const $t=new _n("history"),Nm=new _n("closeHistory");function Om(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new gn({key:$t,state:{init(){return new at(Ie.empty,Ie.empty,null,0,-1)},apply(e,t,o){return Mm(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,s=o=="historyUndo"?tc:o=="historyRedo"?wi:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function ec(n,e){return(t,o)=>{let s=$t.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(o){let i=Pm(s,t,n);i&&o(e?i.scrollIntoView():i)}return!0}}const tc=ec(!1,!0),wi=ec(!0,!0);for(var ct={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:'"'},Im=typeof navigator<"u"&&/Mac/.test(navigator.platform),Rm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),te=0;te<10;te++)ct[48+te]=ct[96+te]=String(te);for(var te=1;te<=24;te++)ct[te+111]="F"+te;for(var te=65;te<=90;te++)ct[te]=String.fromCharCode(te+32),Qo[te]=String.fromCharCode(te);for(var Ci in ct)Qo.hasOwnProperty(Ci)||(Qo[Ci]=ct[Ci]);function Dm(n){var e=Im&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Rm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Qo:ct)[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 Lm=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function $m(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let o,s,i,r;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))r=!0;else if(/^a(lt)?$/i.test(a))o=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Lm?r=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return o&&(t="Alt-"+t),s&&(t="Ctrl-"+t),r&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function zm(n){let e=Object.create(null);for(let t in n)e[$m(t)]=n[t];return e}function ki(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 Ei(n){return new gn({props:{handleKeyDown:nc(n)}})}function nc(n){let e=zm(n);return function(t,o){let s=Dm(o),i,r=e[ki(s,o)];if(r&&r(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(o.shiftKey){let l=e[ki(s,o,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((o.shiftKey||o.altKey||o.metaKey||s.charCodeAt(0)>127)&&(i=ct[o.keyCode])&&i!=s){let l=e[ki(i,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function oc(n,e=null){return function(t,o){let{$from:s,$to:i}=t.selection,r=s.blockRange(i),l=!1,a=r;if(!r)return!1;if(r.depth>=2&&s.node(r.depth-1).type.compatibleContent(n)&&r.startIndex==0){if(s.index(r.depth-1)==0)return!1;let d=t.doc.resolve(r.start-2);a=new Vo(d,d,r.depth),r.endIndex<r.parent.childCount&&(r=new Vo(s,t.doc.resolve(i.end(r.depth)),r.depth)),l=!0}let c=wa(a,n,e,r);return c?(o&&o(Bm(t.tr,r,c,l,n).scrollIntoView()),!0):!1}}function Bm(n,e,t,o,s){let i=T.empty;for(let d=t.length-1;d>=0;d--)i=T.from(t[d].type.create(t[d].attrs,i));n.step(new ee(e.start-(o?2:0),e.end,e.start,e.end,new A(i,0,0),t.length,!0));let r=0;for(let d=0;d<t.length;d++)t[d].type==s&&(r=d+1);let l=t.length-r,a=e.start+t.length-(o?2:0),c=e.parent;for(let d=e.startIndex,p=e.endIndex,u=!0;d<p;d++,u=!1)!u&&pn(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function Vm(n,e){return function(t,o){let{$from:s,$to:i,node:r}=t.selection;if(r&&r.isBlock||s.depth<2||!s.sameParent(i))return!1;let l=s.node(-1);if(l.type!=n)return!1;if(s.parent.content.size==0&&s.node(-1).childCount==s.indexAfter(-1)){if(s.depth==3||s.node(-3).type!=n||s.index(-2)!=s.node(-2).childCount-1)return!1;if(o){let p=T.empty,u=s.index(-1)?1:s.index(-2)?2:3;for(let b=s.depth-u;b>=s.depth-3;b--)p=T.from(s.node(b).copy(p));let h=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3;p=p.append(T.from(n.createAndFill()));let f=s.before(s.depth-(u-1)),m=t.tr.replace(f,s.after(-h),new A(p,4-u,0)),g=-1;m.doc.nodesBetween(f,m.doc.content.size,(b,w)=>{if(g>-1)return!1;b.isTextblock&&b.content.size==0&&(g=w+1)}),g>-1&&m.setSelection(L.near(m.doc.resolve(g))),o(m.scrollIntoView())}return!0}let a=i.pos==s.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(s.pos,i.pos),d=a?[null,{type:a}]:void 0;return pn(c.doc,s.pos,2,d)?(o&&o(c.split(s.pos,2,d).scrollIntoView()),!0):!1}}function Ti(n){return function(e,t){let{$from:o,$to:s}=e.selection,i=o.blockRange(s,r=>r.childCount>0&&r.firstChild.type==n);return i?t?o.node(i.depth-1).type==n?Hm(e,t,n,i):Fm(e,t,i):!0:!1}}function Hm(n,e,t,o){let s=n.tr,i=o.end,r=o.$to.end(o.depth);i<r&&(s.step(new ee(i-1,r,i,r,new A(T.from(t.create(null,o.parent.copy())),1,0),1,!0)),o=new Vo(s.doc.resolve(o.$from.pos),s.doc.resolve(r),o.depth));const l=Uo(o);if(l==null)return!1;s.lift(o,l);let a=s.mapping.map(i,-1)-1;return Ko(s.doc,a)&&s.join(a),e(s.scrollIntoView()),!0}function Fm(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 i=o.doc.resolve(t.start),r=i.nodeAfter;if(o.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,r.content.append(a?T.empty:T.from(s))))return!1;let p=i.pos,u=p+r.nodeSize;return o.step(new ee(p-(l?1:0),u+(a?1:0),p+1,u-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 _m(n){return function(e,t){let{$from:o,$to:s}=e.selection,i=o.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let r=i.startIndex;if(r==0)return!1;let l=i.parent,a=l.child(r-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=T.from(c?n.create():null),p=new A(T.from(n.create(null,T.from(l.type.create(null,d)))),c?3:1,0),u=i.start,h=i.end;t(e.tr.step(new ee(u-(c?3:1),h,u,h,p,1,!0)).scrollIntoView())}return!0}}const ne=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Wn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Mi=null;const Ye=function(n,e,t){let o=Mi||(Mi=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o},Gm=function(){Mi=null},zt=function(n,e,t,o){return t&&(sc(n,e,t,o,-1)||sc(n,e,t,o,1))},Wm=/^(img|br|input|textarea|hr)$/i;function sc(n,e,t,o,s){for(;;){if(n==t&&e==o)return!0;if(e==(s<0?0:Ee(n))){let i=n.parentNode;if(!i||i.nodeType!=1||jn(n)||Wm.test(n.nodeName)||n.contentEditable=="false")return!1;e=ne(n)+(s<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.contentEditable=="false")return!1;e=s<0?Ee(n):0}else return!1}}function Ee(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function jm(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=Ee(n)}else if(n.parentNode&&!jn(n))e=ne(n),n=n.parentNode;else return null}}function qm(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&&!jn(n))e=ne(n)+1,n=n.parentNode;else return null}}function Um(n,e,t){for(let o=e==0,s=e==Ee(n);o||s;){if(n==t)return!0;let i=ne(n);if(n=n.parentNode,!n)return!1;o=o&&i==0,s=s&&i==Ee(n)}}function jn(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 es=function(n){return n.focusNode&&zt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Bt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Km(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Jm(n,e,t){if(n.caretPositionFromPoint)try{let o=n.caretPositionFromPoint(e,t);if(o)return{node:o.offsetNode,offset:Math.min(Ee(o.offsetNode),o.offset)}}catch{}if(n.caretRangeFromPoint){let o=n.caretRangeFromPoint(e,t);if(o)return{node:o.startContainer,offset:Math.min(Ee(o.startContainer),o.startOffset)}}}const Fe=typeof navigator<"u"?navigator:null,ic=typeof document<"u"?document:null,dt=Fe&&Fe.userAgent||"",Ai=/Edge\/(\d+)/.exec(dt),rc=/MSIE \d/.exec(dt),Pi=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(dt),ge=!!(rc||Pi||Ai),pt=rc?document.documentMode:Pi?+Pi[1]:Ai?+Ai[1]:0,Re=!ge&&/gecko\/(\d+)/i.test(dt);Re&&+(/Firefox\/(\d+)/.exec(dt)||[0,0])[1];const Ni=!ge&&/Chrome\/(\d+)/.exec(dt),ie=!!Ni,lc=Ni?+Ni[1]:0,ae=!ge&&!!Fe&&/Apple Computer/.test(Fe.vendor),bn=ae&&(/Mobile\/\w+/.test(dt)||!!Fe&&Fe.maxTouchPoints>2),Te=bn||(Fe?/Mac/.test(Fe.platform):!1),Zm=Fe?/Win/.test(Fe.platform):!1,De=/Android \d/.test(dt),qn=!!ic&&"webkitFontSmoothing"in ic.documentElement.style,Ym=qn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Xm(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 Xe(n,e){return typeof n=="number"?n:n[e]}function Qm(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 ac(n,e,t){let o=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let r=t||n.dom;r;r=Wn(r)){if(r.nodeType!=1)continue;let l=r,a=l==i.body,c=a?Xm(i):Qm(l),d=0,p=0;if(e.top<c.top+Xe(o,"top")?p=-(c.top-e.top+Xe(s,"top")):e.bottom>c.bottom-Xe(o,"bottom")&&(p=e.bottom-e.top>c.bottom-c.top?e.top+Xe(s,"top")-c.top:e.bottom-c.bottom+Xe(s,"bottom")),e.left<c.left+Xe(o,"left")?d=-(c.left-e.left+Xe(s,"left")):e.right>c.right-Xe(o,"right")&&(d=e.right-c.right+Xe(s,"right")),d||p)if(a)i.defaultView.scrollBy(d,p);else{let u=l.scrollLeft,h=l.scrollTop;p&&(l.scrollTop+=p),d&&(l.scrollLeft+=d);let f=l.scrollLeft-u,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(r).position))break}}function eg(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),o,s;for(let i=(e.left+e.right)/2,r=t+1;r<Math.min(innerHeight,e.bottom);r+=5){let l=n.root.elementFromPoint(i,r);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){o=l,s=a.top;break}}return{refDOM:o,refTop:s,stack:cc(n.dom)}}function cc(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=Wn(o));return e}function tg({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;dc(t,o==0?0:o-e)}function dc(n,e){for(let t=0;t<n.length;t++){let{dom:o,top:s,left:i}=n[t];o.scrollTop!=s+e&&(o.scrollTop=s+e),o.scrollLeft!=i&&(o.scrollLeft=i)}}let vn=null;function ng(n){if(n.setActive)return n.setActive();if(vn)return n.focus(vn);let e=cc(n);n.focus(vn==null?{get preventScroll(){return vn={preventScroll:!0},!0}}:void 0),vn||(vn=!1,dc(e,0))}function pc(n,e){let t,o=2e8,s,i=0,r=e.top,l=e.top,a,c;for(let d=n.firstChild,p=0;d;d=d.nextSibling,p++){let u;if(d.nodeType==1)u=d.getClientRects();else if(d.nodeType==3)u=Ye(d).getClientRects();else continue;for(let h=0;h<u.length;h++){let f=u[h];if(f.top<=r&&f.bottom>=l){r=Math.max(f.bottom,r),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&&(i=p+(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)&&(i=p+1)}}return!t&&a&&(t=a,s=c,o=0),t&&t.nodeType==3?og(t,s):!t||o&&t.nodeType==1?{node:n,offset:i}:pc(t,s)}function og(n,e){let t=n.nodeValue.length,o=document.createRange();for(let s=0;s<t;s++){o.setEnd(n,s+1),o.setStart(n,s);let i=ut(o,1);if(i.top!=i.bottom&&Oi(e,i))return{node:n,offset:s+(e.left>=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function Oi(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function sg(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function ig(n,e,t){let{node:o,offset:s}=pc(e,t),i=-1;if(o.nodeType==1&&!o.firstChild){let r=o.getBoundingClientRect();i=r.left!=r.right&&t.left>(r.left+r.right)/2?1:-1}return n.docView.posFromDOM(o,s,i)}function rg(n,e,t,o){let s=-1;for(let i=e,r=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!r&&a.left>o.left||a.top>o.top?s=l.posBefore:(!r&&a.right<o.left||a.bottom<o.top)&&(s=l.posAfter),r=!0),!l.contentDOM&&s<0&&!l.node.isText)return(l.node.isBlock?o.top<(a.top+a.bottom)/2:o.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}i=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function uc(n,e,t){let o=n.childNodes.length;if(o&&t.top<t.bottom)for(let s=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-t.top)/(t.bottom-t.top))-2)),i=s;;){let r=n.childNodes[i];if(r.nodeType==1){let l=r.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Oi(e,c))return uc(r,e,c)}}if((i=(i+1)%o)==s)break}return n}function lg(n,e){let t=n.dom.ownerDocument,o,s=0,i=Jm(t,e.left,e.top);i&&({node:o,offset:s}=i);let r=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!r||!n.dom.contains(r.nodeType!=1?r.parentNode:r)){let c=n.dom.getBoundingClientRect();if(!Oi(e,c)||(r=uc(n.dom,e,c),!r))return null}if(ae)for(let c=r;o&&c;c=Wn(c))c.draggable&&(o=void 0);if(r=sg(r,e),o){if(Re&&o.nodeType==1&&(s=Math.min(s,o.childNodes.length),s<o.childNodes.length)){let d=o.childNodes[s],p;d.nodeName=="IMG"&&(p=d.getBoundingClientRect()).right<=e.left&&p.bottom>e.top&&s++}let c;qn&&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=rg(n,o,s,e))}l==null&&(l=ig(n,r,e));let a=n.docView.nearestDesc(r,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function hc(n){return n.top<n.bottom||n.left<n.right}function ut(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(hc(o))return o}return Array.prototype.find.call(t,hc)||n.getBoundingClientRect()}const ag=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function fc(n,e,t){let{node:o,offset:s,atom:i}=n.docView.domFromPos(e,t<0?-1:1),r=qn||Re;if(o.nodeType==3)if(r&&(ag.test(o.nodeValue)||(t<0?!s:s==o.nodeValue.length))){let a=ut(Ye(o,s,s),t);if(Re&&s&&/\s/.test(o.nodeValue[s-1])&&s<o.nodeValue.length){let c=ut(Ye(o,s-1,s-1),-1);if(c.top==a.top){let d=ut(Ye(o,s,s+1),-1);if(d.top!=a.top)return Un(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++,Un(ut(Ye(o,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(t<0||s==Ee(o))){let a=o.childNodes[s-1];if(a.nodeType==1)return Ii(a.getBoundingClientRect(),!1)}if(i==null&&s<Ee(o)){let a=o.childNodes[s];if(a.nodeType==1)return Ii(a.getBoundingClientRect(),!0)}return Ii(o.getBoundingClientRect(),t>=0)}if(i==null&&s&&(t<0||s==Ee(o))){let a=o.childNodes[s-1],c=a.nodeType==3?Ye(a,Ee(a)-(r?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Un(ut(c,1),!1)}if(i==null&&s<Ee(o)){let a=o.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ye(a,0,r?0:1):a.nodeType==1?a:null:null;if(c)return Un(ut(c,-1),!0)}return Un(ut(o.nodeType==3?Ye(o):o,-t),t>=0)}function Un(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 Ii(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 mc(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 cg(n,e,t){let o=e.selection,s=t=="up"?o.$from:o.$to;return mc(n,e,()=>{let{node:i}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let r=fc(n,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ye(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?r.top-d.top>(d.bottom-r.top)*2:d.bottom-r.bottom>(r.bottom-d.top)*2))return!1}}return!0})}const dg=/[\u0590-\u08ac]/;function pg(n,e,t){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let s=o.parentOffset,i=!s,r=s==o.parent.content.size,l=n.domSelection();return l?!dg.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:r:mc(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:p}=n.domSelectionRange(),u=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,p),a&&(a!=d||c!=p)&&l.extend&&l.extend(a,c)}catch{}return u!=null&&(l.caretBidiLevel=u),g}):o.pos==o.start()||o.pos==o.end()}let gc=null,yc=null,bc=!1;function ug(n,e,t){return gc==e&&yc==t?bc:(gc=e,yc=t,bc=t=="up"||t=="down"?cg(n,e,t):pg(n,e,t))}const Me=0,vc=1,Vt=2,_e=3;class Kn{constructor(e,t,o,s){this.parent=e,this.children=t,this.dom=o,this.contentDOM=s,this.dirty=Me,o.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,o){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,o=this.posAtStart;;t++){let s=this.children[t];if(s==e)return o;o+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,o){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(o<0){let i,r;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((r=i.pmViewDesc)&&r.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(r)+r.size:this.posAtStart}else{let i,r;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((r=i.pmViewDesc)&&r.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(r):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>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 i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??o>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let o=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),r;if(i&&(!t||i.node))if(o&&(r=i.nodeDOM)&&!(r.nodeType==1?r.contains(e.nodeType==1?e:e.parentNode):r==e))o=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let o=t;o;o=o.parent)if(o==this)return t}posFromDOM(e,t,o){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,t,o)}return-1}descAt(e){for(let t=0,o=0;t<this.children.length;t++){let s=this.children[t],i=o+s.size;if(o==e&&i!=o){for(;!s.border&&s.children.length;)s=s.children[0];return s}if(e<i)return s.descAt(e-o-s.border);o=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let o=0,s=0;for(let i=0;o<this.children.length;o++){let r=this.children[o],l=i+r.size;if(l>e||r instanceof wc){s=e-i;break}i=l}if(s)return this.children[o].domFromPos(s-this.children[o].border,t);for(let i;o&&!(i=this.children[o-1]).size&&i instanceof Sc&&i.side>=0;o--);if(t<=0){let i,r=!0;for(;i=o?this.children[o-1]:null,!(!i||i.dom.parentNode==this.contentDOM);o--,r=!1);return i&&t&&r&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?ne(i.dom)+1:0}}else{let i,r=!0;for(;i=o<this.children.length?this.children[o]:null,!(!i||i.dom.parentNode==this.contentDOM);o++,r=!1);return i&&r&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?ne(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,o=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let r=o,l=0;;l++){let a=this.children[l],c=r+a.size;if(s==-1&&e<=c){let d=r+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=r;for(let p=l;p>0;p--){let u=this.children[p-1];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(1)){s=ne(u.dom)+1;break}e-=u.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 p=this.children[d];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(-1)){i=ne(p.dom);break}t+=p.size}i==-1&&(i=this.contentDOM.childNodes.length);break}r=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:o}=this.domFromPos(e,0);if(t.nodeType!=1||o==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[o]}setSelection(e,t,o,s=!1){let i=Math.min(e,t),r=Math.max(e,t);for(let h=0,f=0;h<this.children.length;h++){let m=this.children[h],g=f+m.size;if(i>f&&r<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(),p=!1;if((Re||ae)&&e==t){let{node:h,offset:f}=l;if(h.nodeType==3){if(p=!!(f&&h.nodeValue[f-1]==`
913
- `),p&&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];p=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Re&&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||p&&ae)&&zt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&zt(a.node,a.offset,d.focusNode,d.focusOffset))return;let u=!1;if((c.extend||e==t)&&!p){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),u=!0}catch{}}if(!u){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 i=this.children[s],r=o+i.size;if(o==r?e<=r&&t>=o:e<r&&t>o){let l=o+i.border,a=r-i.border;if(e>=l&&t<=a){this.dirty=e==o||t==r?Vt:vc,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=_e:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Vt:_e}o=r}this.dirty=Vt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?Vt:vc;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Sc extends Kn{constructor(e,t,o,s){let i,r=t.type.toDOM;if(typeof r=="function"&&(r=r(o,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(r.nodeType!=1){let l=document.createElement("span");l.appendChild(r),r=l}r.contentEditable="false",r.classList.add("ProseMirror-widget")}super(e,[],r,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Me&&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 hg extends Kn{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 Ht extends Kn{constructor(e,t,o,s,i){super(e,[],o,s),this.mark=t,this.spec=i}static create(e,t,o,s){let i=s.nodeViews[t.type.name],r=i&&i(t,s,o);return(!r||!r.dom)&&(r=Dt.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new Ht(e,t,r.dom,r.contentDOM||r.dom,r)}parseRule(){return this.dirty&_e||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=_e&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Me){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=Me}}slice(e,t,o){let s=Ht.create(this.parent,this.mark,!0,o),i=this.children,r=this.size;t<r&&(i=Di(i,t,r,o)),e>0&&(i=Di(i,0,e,o));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class ht extends Kn{constructor(e,t,o,s,i,r,l,a,c){super(e,[],i,r),this.node=t,this.outerDeco=o,this.innerDeco=s,this.nodeDOM=l}static create(e,t,o,s,i,r){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return r;if(a.parent)return a.parent.posBeforeChild(a)},o,s),d=c&&c.dom,p=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:p}=Dt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!p&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let u=d;return d=Ec(d,o,t),c?a=new fg(e,t,o,s,d,p||null,u,c,i,r+1):t.isText?new ts(e,t,o,s,d,u,i):new ht(e,t,o,s,d,p||null,u,i,r+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let o=this.children[t];if(this.dom.contains(o.dom.parentNode)){e.contentElement=o.dom.parentNode;break}}e.contentElement||(e.getContent=()=>T.empty)}return e}matchesNode(e,t,o){return this.dirty==Me&&e.eq(this.node)&&ns(t,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let o=this.node.inlineContent,s=t,i=e.composing?this.localCompositionInfo(e,t):null,r=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new gg(this,r&&r.node,e);vg(this.node,this.innerDeco,(c,d,p)=>{c.spec.marks?a.syncToMarks(c.spec.marks,o,e):c.type.side>=0&&!p&&a.syncToMarks(d==this.node.childCount?H.none:this.node.child(d).marks,o,e),a.placeWidget(c,e,s)},(c,d,p,u)=>{a.syncToMarks(c.marks,o,e);let h;a.findNodeMatch(c,d,p,u)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,p,h,e)||a.updateNextNode(c,d,p,e,u,s)||a.addNode(c,d,p,e,s),s+=c.nodeSize}),a.syncToMarks([],o,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Vt)&&(r&&this.protectLocalComposition(e,r),Cc(this.contentDOM,this.children,e),bn&&Sg(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 i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let r=i.nodeValue,l=xg(this.node.content,r,o-t,s-t);return l<0?null:{node:i,pos:l,text:r}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:o,text:s}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let r=new hg(this,i,t,s);e.input.compositionNodes.push(r),this.children=Di(this.children,o,o+s.length,e,r)}update(e,t,o,s){return this.dirty==_e||!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=Me}updateOuterDeco(e){if(ns(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=kc(this.dom,this.nodeDOM,Ri(this.outerDeco,this.node,t),Ri(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 xc(n,e,t,o,s){Ec(o,e,n);let i=new ht(void 0,n,e,t,o,o,o,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class ts extends ht{constructor(e,t,o,s,i,r,l){super(e,t,o,s,i,null,r,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,o,s){return this.dirty==_e||this.dirty!=Me&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Me||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=Me,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,o){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,o)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,o){let s=this.node.cut(e,t),i=document.createTextNode(s.text);return new ts(this.parent,s,this.outerDeco,this.innerDeco,i,i,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=_e)}get domAtom(){return!1}isText(e){return this.node.text==e}}class wc extends Kn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Me&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class fg extends ht{constructor(e,t,o,s,i,r,l,a,c,d){super(e,t,o,s,i,r,l,c,d),this.spec=a}update(e,t,o,s){if(this.dirty==_e)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,o);return i&&this.updateInner(e,t,o,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,o,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,o,s){this.spec.setSelection?this.spec.setSelection(e,t,o.root):super.setSelection(e,t,o,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Cc(n,e,t){let o=n.firstChild,s=!1;for(let i=0;i<e.length;i++){let r=e[i],l=r.dom;if(l.parentNode==n){for(;l!=o;)o=Tc(o),s=!0;o=o.nextSibling}else s=!0,n.insertBefore(l,o);if(r instanceof Ht){let a=o?o.previousSibling:n.lastChild;Cc(r.contentDOM,r.children,t),o=a?a.nextSibling:n.firstChild}}for(;o;)o=Tc(o),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const Jn=function(n){n&&(this.nodeName=n)};Jn.prototype=Object.create(null);const Ft=[new Jn];function Ri(n,e,t){if(n.length==0)return Ft;let o=t?Ft[0]:new Jn,s=[o];for(let i=0;i<n.length;i++){let r=n[i].type.attrs;if(r){r.nodeName&&s.push(o=new Jn(r.nodeName));for(let l in r){let a=r[l];a!=null&&(t&&s.length==1&&s.push(o=new Jn(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 kc(n,e,t,o){if(t==Ft&&o==Ft)return e;let s=e;for(let i=0;i<o.length;i++){let r=o[i],l=t[i];if(i){let a;l&&l.nodeName==r.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==r.nodeName||(a=document.createElement(r.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=Ft[0]),s=a}mg(s,l||Ft[0],r)}return s}function mg(n,e,t){for(let o in e)o!="class"&&o!="style"&&o!="nodeName"&&!(o in t)&&n.removeAttribute(o);for(let o in t)o!="class"&&o!="style"&&o!="nodeName"&&t[o]!=e[o]&&n.setAttribute(o,t[o]);if(e.class!=t.class){let o=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<o.length;i++)s.indexOf(o[i])==-1&&n.classList.remove(o[i]);for(let i=0;i<s.length;i++)o.indexOf(s[i])==-1&&n.classList.add(s[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=o.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function Ec(n,e,t){return kc(n,n,Ft,Ri(e,t,n.nodeType!=1))}function ns(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 Tc(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class gg{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=yg(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let o=e;o<t;o++)this.top.children[o].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,o){let s=0,i=this.stack.length>>1,r=Math.min(i,e.length);for(;s<r&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=Me,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Ht.create(this.top,e[i],t,o);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,o,s){let i=-1,r;if(s>=this.preMatch.index&&(r=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,o))i=this.top.children.indexOf(r,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,o)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,o,s,i){let r=this.top.children[s];return r.dirty==_e&&r.dom==r.contentDOM&&(r.dirty=Vt),r.update(e,t,o,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let o=e.pmViewDesc;if(o){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==o)return s}return-1}e=t}}updateNextNode(e,t,o,s,i,r){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof ht){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,p,u=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=_e&&ns(t,a.outerDeco));if(!u&&a.update(e,t,o,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(p=this.recreateWrapper(a,e,t,o,s,r)))return this.destroyBetween(this.index,l),this.top.children[this.index]=p,p.contentDOM&&(p.dirty=Vt,p.updateChildren(s,r+1),p.dirty=Me),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,s,i,r){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ns(o,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=ht.create(this.top,t,o,s,i,r);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,o,s,i){let r=ht.create(this.top,e,t,o,s,i);r.contentDOM&&r.updateChildren(s,i+1),this.top.children.splice(this.index++,0,r),this.changed=!0}placeWidget(e,t,o){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new Sc(this.top,e,t,o);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ht;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof ts)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ae||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 wc(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 yg(n,e){let t=e,o=t.children.length,s=n.childCount,i=new Map,r=[];e:for(;s>0;){let l;for(;;)if(o){let c=t.children[o-1];if(c instanceof Ht)t=c,o=c.children.length;else{l=c,o--;break}}else{if(t==e)break e;o=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,i.set(l,s),r.push(l)}}return{index:s,matched:i,matches:r.reverse()}}function bg(n,e){return n.type.side-e.type.side}function vg(n,e,t,o){let s=e.locals(n),i=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);o(d,s,e.forChild(i,d),c),i+=d.nodeSize}return}let r=0,l=[],a=null;for(let c=0;;){let d,p;for(;r<s.length&&s[r].to==i;){let g=s[r++];g.widget&&(d?(p||(p=[d])).push(g):d=g)}if(d)if(p){p.sort(bg);for(let g=0;g<p.length;g++)t(p[g],c,!!a)}else t(d,c,!!a);let u,h;if(a)h=-1,u=a,a=null;else if(c<n.childCount)h=c,u=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;r<s.length&&s[r].from<=i&&s[r].to>i;)l.push(s[r++]);let f=i+u.nodeSize;if(u.isText){let g=f;r<s.length&&s[r].from<g&&(g=s[r].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<f&&(a=u.cut(g-i),u=u.cut(0,g-i),f=g,h=-1)}else for(;r<s.length&&s[r].to<f;)r++;let m=u.isInline&&!u.isLeaf?l.filter(g=>!g.inline):l.slice();o(u,m,e.forChild(i,u),h),i=f}}function Sg(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 xg(n,e,t,o){for(let s=0,i=0;s<n.childCount&&i<=o;){let r=n.child(s++),l=i;if(i+=r.nodeSize,!r.isText)continue;let a=r.text;for(;s<n.childCount;){let c=n.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=o&&a.slice(o-e.length-l,o-l)==e)return o-e.length;let c=l<o?a.lastIndexOf(e,o-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==o&&a.length>=o+e.length-l&&a.slice(o-l,o-l+e.length)==e)return o}}return-1}function Di(n,e,t,o,s){let i=[];for(let r=0,l=0;r<n.length;r++){let a=n[r],c=l,d=l+=a.size;c>=t||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,o)),s&&(i.push(s),s=void 0),d>t&&i.push(a.slice(t-c,a.size,o)))}return i}function Li(n,e=null){let t=n.domSelectionRange(),o=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),i=s&&s.size==0,r=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(r<0)return null;let l=o.resolve(r),a,c;if(es(t)){for(a=r;s&&!s.node;)s=s.parent;let p=s.node;if(s&&p.isAtom&&D.isSelectable(p)&&s.parent&&!(p.isInline&&Um(t.focusNode,t.focusOffset,s.dom))){let u=s.posBefore;c=new D(r==u?l:o.resolve(u))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let p=r,u=r;for(let h=0;h<t.rangeCount;h++){let f=t.getRangeAt(h);p=Math.min(p,n.docView.posFromDOM(f.startContainer,f.startOffset,1)),u=Math.max(u,n.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(p<0)return null;[a,r]=u==n.state.selection.anchor?[u,p]:[p,u],l=o.resolve(r)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=o.resolve(a);if(!c){let p=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=zi(n,d,l,p)}return c}function Mc(n){return n.editable?n.hasFocus():Dc(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Qe(n,e=!1){let t=n.state.selection;if(Oc(n,t),!!Mc(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ie){let o=n.domSelectionRange(),s=n.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&zt(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Cg(n);else{let{anchor:o,head:s}=t,i,r;Ac&&!(t instanceof $)&&(t.$from.parent.inlineContent||(i=Pc(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(r=Pc(n,t.to))),n.docView.setSelection(o,s,n,e),Ac&&(i&&Nc(i),r&&Nc(r)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&wg(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Ac=ae||ie&&lc<63;function Pc(n,e){let{node:t,offset:o}=n.docView.domFromPos(e,0),s=o<t.childNodes.length?t.childNodes[o]:null,i=o?t.childNodes[o-1]:null;if(ae&&s&&s.contentEditable=="false")return $i(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return $i(s);if(i)return $i(i)}}function $i(n){return n.contentEditable="true",ae&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Nc(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function wg(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(()=>{(!Mc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Cg(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&&ge&&pt<=11&&(o.disabled=!0,o.disabled=!1)}function Oc(n,e){if(e instanceof D){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Ic(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Ic(n)}function Ic(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function zi(n,e,t,o){return n.someProp("createSelectionBetween",s=>s(n,e,t))||$.between(e,t,o)}function Rc(n){return n.editable&&!n.hasFocus()?!1:Dc(n)}function Dc(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 kg(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return zt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Bi(n,e){let{$anchor:t,$head:o}=n.selection,s=e>0?t.max(o):t.min(o),i=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return i&&L.findFrom(i,e)}function ft(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Lc(n,e,t){let o=n.state.selection;if(o instanceof $)if(t.indexOf("s")>-1){let{$head:s}=o,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let r=n.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return ft(n,new $(o.$anchor,r))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=Bi(n.state,e);return s&&s instanceof D?ft(n,s):!1}else if(!(Te&&t.indexOf("m")>-1)){let s=o.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,r;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(r=n.docView.descAt(l))&&!r.contentDOM?D.isSelectable(i)?ft(n,new D(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):qn?ft(n,new $(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(o instanceof D&&o.node.isInline)return ft(n,new $(e>0?o.$to:o.$from));{let s=Bi(n.state,e);return s?ft(n,s):!1}}}function ss(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Zn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Sn(n,e){return e<0?Eg(n):Tg(n)}function Eg(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s,i,r=!1;for(Re&&t.nodeType==1&&o<ss(t)&&Zn(t.childNodes[o],-1)&&(r=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(Zn(l,-1))s=t,i=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if($c(t))break;{let l=t.previousSibling;for(;l&&Zn(l,-1);)s=t.parentNode,i=ne(l),l=l.previousSibling;if(l)t=l,o=ss(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}r?Vi(n,t,o):s&&Vi(n,s,i)}function Tg(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let s=ss(t),i,r;for(;;)if(o<s){if(t.nodeType!=1)break;let l=t.childNodes[o];if(Zn(l,1))i=t,r=++o;else break}else{if($c(t))break;{let l=t.nextSibling;for(;l&&Zn(l,1);)i=l.parentNode,r=ne(l)+1,l=l.nextSibling;if(l)t=l,o=0,s=ss(t);else{if(t=t.parentNode,t==n.dom)break;o=s=0}}}i&&Vi(n,i,r)}function $c(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Mg(n,e){for(;n&&e==n.childNodes.length&&!jn(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 Ag(n,e){for(;n&&!e&&!jn(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 Vi(n,e,t){if(e.nodeType!=3){let i,r;(r=Mg(e,t))?(e=r,t=0):(i=Ag(e,t))&&(e=i,t=i.nodeValue.length)}let o=n.domSelection();if(!o)return;if(es(o)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),o.removeAllRanges(),o.addRange(i)}else o.extend&&o.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&Qe(n)},50)}function zc(n,e){let t=n.state.doc.resolve(e);if(!(ie||Zm)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),r=(i.top+i.bottom)/2;if(r>s.top&&r<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),r=(i.top+i.bottom)/2;if(r>s.top&&r<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Bc(n,e,t){let o=n.state.selection;if(o instanceof $&&!o.empty||t.indexOf("s")>-1||Te&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=o;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let r=Bi(n.state,e);if(r&&r instanceof D)return ft(n,r)}if(!s.parent.inlineContent){let r=e<0?s:i,l=o instanceof xe?L.near(r,e):L.findFrom(r,e);return l?ft(n,l):!1}return!1}function Vc(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 i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let r=n.state.tr;return e<0?r.delete(t.pos-i.nodeSize,t.pos):r.delete(t.pos,t.pos+i.nodeSize),n.dispatch(r),!0}return!1}function Hc(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Pg(n){if(!ae||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;Hc(n,o,"true"),setTimeout(()=>Hc(n,o,"false"),20)}return!1}function Ng(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Og(n,e){let t=e.keyCode,o=Ng(e);if(t==8||Te&&t==72&&o=="c")return Vc(n,-1)||Sn(n,-1);if(t==46&&!e.shiftKey||Te&&t==68&&o=="c")return Vc(n,1)||Sn(n,1);if(t==13||t==27)return!0;if(t==37||Te&&t==66&&o=="c"){let s=t==37?zc(n,n.state.selection.from)=="ltr"?-1:1:-1;return Lc(n,s,o)||Sn(n,s)}else if(t==39||Te&&t==70&&o=="c"){let s=t==39?zc(n,n.state.selection.from)=="ltr"?1:-1:1;return Lc(n,s,o)||Sn(n,s)}else{if(t==38||Te&&t==80&&o=="c")return Bc(n,-1,o)||Sn(n,-1);if(t==40||Te&&t==78&&o=="c")return Pg(n)||Bc(n,1,o)||Sn(n,1);if(o==(Te?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Fc(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:o,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&o.childCount==1&&o.firstChild.childCount==1;){s--,i--;let h=o.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),o=h.content}let r=n.someProp("clipboardSerializer")||Dt.fromSchema(n.state.schema),l=Jc(),a=l.createElement("div");a.appendChild(r.serializeFragment(o,{document:l}));let c=a.firstChild,d,p=0;for(;c&&c.nodeType==1&&(d=Uc[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),p++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${p?` -${p}`:""} ${JSON.stringify(t)}`);let u=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
914
-
915
- `);return{dom:a,text:u,slice:e}}function _c(n,e,t,o,s){let i=s.parent.type.spec.code,r,l;if(!t&&!e)return null;let a=e&&(o||i||!t);if(a){if(n.someProp("transformPastedText",u=>{e=u(e,i||o,n)}),i)return e?new A(T.from(n.state.schema.text(e.replace(/\r\n?/g,`
916
- `))),0,0):A.empty;let p=n.someProp("clipboardTextParser",u=>u(e,s,o,n));if(p)l=p;else{let u=s.marks(),{schema:h}=n.state,f=Dt.fromSchema(h);r=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=r.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(h.text(m,u)))})}}else n.someProp("transformPastedHTML",p=>{t=p(t,n)}),r=Lg(t),qn&&$g(r);let c=r&&r.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let p=+d[3];p>0;p--){let u=r.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;r=u}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Rt.fromSchema(n.state.schema)).parseSlice(r,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!Ig.test(u.parentNode.nodeName)?{ignore:!0}:null}})),d)l=zg(qc(l,+d[1],+d[2]),d[4]);else if(l=A.maxOpen(Rg(l.content,s),!0),l.openStart||l.openEnd){let p=0,u=0;for(let h=l.content.firstChild;p<l.openStart&&!h.type.spec.isolating;p++,h=h.firstChild);for(let h=l.content.lastChild;u<l.openEnd&&!h.type.spec.isolating;u++,h=h.lastChild);l=qc(l,p,u)}return n.someProp("transformPasted",p=>{l=p(l,n)}),l}const Ig=/^(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 Rg(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,r=[];if(n.forEach(l=>{if(!r)return;let a=s.findWrapping(l.type),c;if(!a)return r=null;if(c=r.length&&i.length&&Wc(a,i,l,r[r.length-1],0))r[r.length-1]=c;else{r.length&&(r[r.length-1]=jc(r[r.length-1],i.length));let d=Gc(l,a);r.push(d),s=s.matchType(d.type),i=a}}),r)return T.from(r)}return n}function Gc(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,T.from(n));return n}function Wc(n,e,t,o,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let i=Wc(n,e,t,o.lastChild,s+1);if(i)return o.copy(o.content.replaceChild(o.childCount-1,i));if(o.contentMatchAt(o.childCount).matchType(s==n.length-1?t.type:n[s+1]))return o.copy(o.content.append(T.from(Gc(t,n,s+1))))}}function jc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,jc(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(T.empty,!0);return n.copy(t.append(o))}function Hi(n,e,t,o,s,i){let r=e<0?n.firstChild:n.lastChild,l=r.content;return n.childCount>1&&(i=0),s<o-1&&(l=Hi(l,e,t,o,s+1,i)),s>=t&&(l=e<0?r.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(r.contentMatchAt(r.childCount).fillBefore(T.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,r.copy(l))}function qc(n,e,t){return e<n.openStart&&(n=new A(Hi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(Hi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Uc={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 Kc=null;function Jc(){return Kc||(Kc=document.implementation.createHTMLDocument("title"))}let Fi=null;function Dg(n){let e=window.trustedTypes;return e?(Fi||(Fi=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Fi.createHTML(n)):n}function Lg(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Jc().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(n),s;if((s=o&&Uc[o[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=Dg(n),s)for(let i=0;i<s.length;i++)t=t.querySelector(s[i])||t;return t}function $g(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 zg(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,o;try{o=JSON.parse(e)}catch{return n}let{content:s,openStart:i,openEnd:r}=n;for(let l=o.length-2;l>=0;l-=2){let a=t.nodes[o[l]];if(!a||a.hasRequiredAttrs())break;s=T.from(a.create(o[l+1],s)),i++,r++}return new A(s,i,r)}const ce={},de={},Bg={touchstart:!0,touchmove:!0};class Vg{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 Hg(n){for(let e in ce){let t=ce[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{_g(n,o)&&!Gi(n,o)&&(n.editable||!(o.type in de))&&t(n,o)},Bg[e]?{passive:!0}:void 0)}ae&&n.dom.addEventListener("input",()=>null),_i(n)}function mt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Fg(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 _i(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>Gi(n,o))})}function Gi(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function _g(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 Gg(n,e){!Gi(n,e)&&ce[e.type]&&(n.editable||!(e.type in de))&&ce[e.type](n,e)}de.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Yc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(De&&ie&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),bn&&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,Bt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",o=>o(n,t))||Og(n,t)?t.preventDefault():mt(n,"key")},de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},de.keypress=(n,e)=>{let t=e;if(Yc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Te&&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",i=>i(n,o.$from.pos,o.$to.pos,s))&&n.dispatch(n.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function is(n){return{left:n.clientX,top:n.clientY}}function Wg(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function Wi(n,e,t,o,s){if(o==-1)return!1;let i=n.state.doc.resolve(o);for(let r=i.depth+1;r>0;r--)if(n.someProp(e,l=>r>i.depth?l(n,t,i.nodeAfter,i.before(r),s,!0):l(n,t,i.node(r),i.before(r),s,!1)))return!0;return!1}function xn(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 jg(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&D.isSelectable(o)?(xn(n,new D(t)),!0):!1}function qg(n,e){if(e==-1)return!1;let t=n.state.selection,o,s;t instanceof D&&(o=t.node);let i=n.state.doc.resolve(e);for(let r=i.depth+1;r>0;r--){let l=r>i.depth?i.nodeAfter:i.node(r);if(D.isSelectable(l)){o&&t.$from.depth>0&&r>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(r);break}}return s!=null?(xn(n,D.create(n.state.doc,s)),!0):!1}function Ug(n,e,t,o,s){return Wi(n,"handleClickOn",e,t,o)||n.someProp("handleClick",i=>i(n,e,o))||(s?qg(n,t):jg(n,t))}function Kg(n,e,t,o){return Wi(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",s=>s(n,e,o))}function Jg(n,e,t,o){return Wi(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",s=>s(n,e,o))||Zg(n,t,o)}function Zg(n,e,t){if(t.button!=0)return!1;let o=n.state.doc;if(e==-1)return o.inlineContent?(xn(n,$.create(o,0,o.content.size)),!0):!1;let s=o.resolve(e);for(let i=s.depth+1;i>0;i--){let r=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(r.inlineContent)xn(n,$.create(o,l+1,l+1+r.content.size));else if(D.isSelectable(r))xn(n,D.create(o,l));else continue;return!0}}function ji(n){return rs(n)}const Zc=Te?"metaKey":"ctrlKey";ce.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=ji(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&Wg(t,n.input.lastClick)&&!t[Zc]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i};let r=n.posAtCoords(is(t));r&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Yg(n,r,t,!!o)):(i=="doubleClick"?Kg:Jg)(n,r.pos,r.inside,t)?t.preventDefault():mt(n,"pointer"))};class Yg{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[Zc],this.allowDefault=o.shiftKey;let i,r;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),r=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,r=d.depth?d.before():0}const l=s?null:o.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(o.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof D&&c.from<=r&&c.to>r)&&(this.mightDrag={node:i,pos:r,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Re&&!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)),mt(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(()=>Qe(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(is(e))),this.updateAllowDefault(e),this.allowDefault||!t?mt(this.view,"pointer"):Ug(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ae&&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)?(xn(this.view,L.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):mt(this.view,"pointer")}move(e){this.updateAllowDefault(e),mt(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)}}ce.touchstart=n=>{n.input.lastTouch=Date.now(),ji(n),mt(n,"pointer")},ce.touchmove=n=>{n.input.lastTouch=Date.now(),mt(n,"pointer")},ce.contextmenu=n=>ji(n);function Yc(n,e){return n.composing?!0:ae&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Xg=De?5e3:-1;de.compositionstart=de.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(),rs(n,!0),n.markCursor=null;else if(rs(n,!e.selection.empty),Re&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let o=n.domSelectionRange();for(let s=o.focusNode,i=o.focusOffset;s&&s.nodeType==1&&i!=0;){let r=i<0?s.lastChild:s.childNodes[i-1];if(!r)break;if(r.nodeType==3){let l=n.domSelection();l&&l.collapse(r,r.nodeValue.length);break}else s=r,i=-1}}n.input.composing=!0}Xc(n,Xg)},de.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++,Xc(n,20))};function Xc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>rs(n),e))}function Qc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e1());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Qg(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=jm(e.focusNode,e.focusOffset),o=qm(e.focusNode,e.focusOffset);if(t&&o&&t!=o){let s=o.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||o==i)return i;if(!s||!s.isText(o.nodeValue))return o;if(n.input.compositionNode==o){let r=t.pmViewDesc;if(!(!r||!r.isText(t.nodeValue)))return o}}return t||o}function e1(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function rs(n,e=!1){if(!(De&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Qc(n),e||n.docView&&n.docView.dirty){let t=Li(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function t1(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 Yn=ge&&pt<15||bn&&Ym<604;ce.copy=de.cut=(n,e)=>{let t=e,o=n.state.selection,s=t.type=="cut";if(o.empty)return;let i=Yn?null:t.clipboardData,r=o.content(),{dom:l,text:a}=Fc(n,r);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):t1(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function n1(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function o1(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?Xn(n,o.value,null,s,e):Xn(n,o.textContent,o.innerHTML,s,e)},50)}function Xn(n,e,t,o,s){let i=_c(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,i||A.empty)))return!0;if(!i)return!1;let r=n1(i),l=r?n.state.tr.replaceSelectionWith(r,o):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ed(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," "):""}de.paste=(n,e)=>{let t=e;if(n.composing&&!De)return;let o=Yn?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&Xn(n,ed(o),o.getData("text/html"),s,t)?t.preventDefault():o1(n,t)};class td{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const nd=Te?"altKey":"ctrlKey";ce.dragstart=(n,e)=>{let t=e,o=n.input.mouseDown;if(o&&o.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(is(t)),r;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof D?s.to-1:s.to))){if(o&&o.mightDrag)r=D.create(n.state.doc,o.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let p=n.docView.nearestDesc(t.target,!0);p&&p.node.type.spec.draggable&&p!=n.docView&&(r=D.create(n.state.doc,p.posBefore))}}let l=(r||n.state.selection).content(),{dom:a,text:c,slice:d}=Fc(n,l);(!t.dataTransfer.files.length||!ie||lc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Yn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Yn||t.dataTransfer.setData("text/plain",c),n.dragging=new td(d,!t[nd],r)},ce.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},de.dragover=de.dragenter=(n,e)=>e.preventDefault(),de.drop=(n,e)=>{let t=e,o=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(is(t));if(!s)return;let i=n.state.doc.resolve(s.pos),r=o&&o.slice;r?n.someProp("transformPasted",f=>{r=f(r,n)}):r=_c(n,ed(t.dataTransfer),Yn?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(o&&!t[nd]);if(n.someProp("handleDrop",f=>f(n,t,r||A.empty,l))){t.preventDefault();return}if(!r)return;t.preventDefault();let a=r?Xf(n.state.doc,i.pos,r):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:f}=o;f?f.replace(c):c.deleteSelection()}let d=c.mapping.map(a),p=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,u=c.doc;if(p?c.replaceRangeWith(d,d,r.content.firstChild):c.replaceRange(d,d,r),c.doc.eq(u))return;let h=c.doc.resolve(d);if(p&&D.isSelectable(r.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(r.content.firstChild))c.setSelection(new D(h));else{let f=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,w)=>f=w),c.setSelection(zi(n,h,c.doc.resolve(f)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},ce.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())&&Qe(n)},20))},ce.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)},ce.beforeinput=(n,e)=>{if(ie&&De&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:o}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=o||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,Bt(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 de)ce[n]=de[n];function Qn(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 ls{constructor(e,t){this.toDOM=e,this.spec=t||_t,this.side=this.spec.side||0}map(e,t,o,s){let{pos:i,deleted:r}=e.mapResult(t.from+s,this.side<0?-1:1);return r?null:new ye(i-o,i-o,this)}valid(){return!0}eq(e){return this==e||e instanceof ls&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Qn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class gt{constructor(e,t){this.attrs=e,this.spec=t||_t}map(e,t,o,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-o,r=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-o;return i>=r?null:new ye(i,r,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof gt&&Qn(this.attrs,e.attrs)&&Qn(this.spec,e.spec)}static is(e){return e.type instanceof gt}destroy(){}}class qi{constructor(e,t){this.attrs=e,this.spec=t||_t}map(e,t,o,s){let i=e.mapResult(t.from+s,1);if(i.deleted)return null;let r=e.mapResult(t.to+s,-1);return r.deleted||r.pos<=i.pos?null:new ye(i.pos-o,r.pos-o,this)}valid(e,t){let{index:o,offset:s}=e.content.findIndex(t.from),i;return s==t.from&&!(i=e.child(o)).isText&&s+i.nodeSize==t.to}eq(e){return this==e||e instanceof qi&&Qn(this.attrs,e.attrs)&&Qn(this.spec,e.spec)}destroy(){}}class ye{constructor(e,t,o){this.from=e,this.to=t,this.type=o}copy(e,t){return new ye(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 ye(e,e,new ls(t,o))}static inline(e,t,o,s){return new ye(e,t,new gt(o,s))}static node(e,t,o,s){return new ye(e,t,new qi(o,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof gt}get widget(){return this.type instanceof ls}}const wn=[],_t={};class U{constructor(e,t){this.local=e.length?e:wn,this.children=t.length?t:wn}static create(e,t){return t.length?as(t,e,0,_t):re}find(e,t,o){let s=[];return this.findInner(e??0,t??1e9,s,0,o),s}findInner(e,t,o,s,i){for(let r=0;r<this.local.length;r++){let l=this.local[r];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&o.push(l.copy(l.from+s,l.to+s))}for(let r=0;r<this.children.length;r+=3)if(this.children[r]<t&&this.children[r+1]>e){let l=this.children[r]+1;this.children[r+2].findInner(e-l,t-l,o,s+l,i)}}map(e,t,o){return this==re||e.maps.length==0?this:this.mapInner(e,t,0,0,o||_t)}mapInner(e,t,o,s,i){let r;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,o,s);a&&a.type.valid(t,a)?(r||(r=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?s1(this.children,r||[],e,t,o,s,i):r?new U(r.sort(Gt),wn):re}add(e,t){return t.length?this==re?U.create(e,t):this.addInner(e,t,0):this}addInner(e,t,o){let s,i=0;e.forEach((l,a)=>{let c=a+o,d;if(d=sd(t,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,d,c+1):s.splice(i,0,a,a+l.nodeSize,as(d,l,c+1,_t)),i+=3}});let r=od(i?id(t):t,-o);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||r.splice(l--,1);return new U(r.length?this.local.concat(r).sort(Gt):this.local,s||this.children)}remove(e){return e.length==0||this==re?this:this.removeInner(e,0)}removeInner(e,t){let o=this.children,s=this.local;for(let i=0;i<o.length;i+=3){let r,l=o[i]+t,a=o[i+1]+t;for(let d=0,p;d<e.length;d++)(p=e[d])&&p.from>l&&p.to<a&&(e[d]=null,(r||(r=[])).push(p));if(!r)continue;o==this.children&&(o=this.children.slice());let c=o[i+2].removeInner(r,l+1);c!=re?o[i+2]=c:(o.splice(i,3),i-=3)}if(s.length){for(let i=0,r;i<e.length;i++)if(r=e[i])for(let l=0;l<s.length;l++)s[l].eq(r,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return o==this.children&&s==this.local?this:s.length||o.length?new U(s,o):re}forChild(e,t){if(this==re)return this;if(t.isLeaf)return U.empty;let o,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(o=this.children[l+2]);break}let i=e+1,r=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<r&&a.to>i&&a.type instanceof gt){let c=Math.max(i,a.from)-i,d=Math.min(r,a.to)-i;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new U(s.sort(Gt),wn);return o?new yt([l,o]):l}return o||re}eq(e){if(this==e)return!0;if(!(e instanceof U)||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 Ui(this.localsInner(e))}localsInner(e){if(this==re)return wn;if(e.inlineContent||!this.local.some(gt.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof gt||t.push(this.local[o]);return t}forEachSet(e){e(this)}}U.empty=new U([],[]),U.removeOverlap=Ui;const re=U.empty;class yt{constructor(e){this.members=e}map(e,t){const o=this.members.map(s=>s.map(e,t,_t));return yt.from(o)}forChild(e,t){if(t.isLeaf)return U.empty;let o=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,t);i!=re&&(i instanceof yt?o=o.concat(i.members):o.push(i))}return yt.from(o)}eq(e){if(!(e instanceof yt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,o=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!t)t=i;else{o&&(t=t.slice(),o=!1);for(let r=0;r<i.length;r++)t.push(i[r])}}return t?Ui(o?t:t.sort(Gt)):wn}static from(e){switch(e.length){case 0:return re;case 1:return e[0];default:return new yt(e.every(t=>t instanceof U)?e:e.reduce((t,o)=>t.concat(o instanceof U?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function s1(n,e,t,o,s,i,r){let l=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let p=0;t.maps[c].forEach((u,h,f,m)=>{let g=m-f-(h-u);for(let b=0;b<l.length;b+=3){let w=l[b+1];if(w<0||u>w+d-p)continue;let y=l[b]+d-p;h>=y?l[b+1]=u<=y?-2:-1:u>=d&&g&&(l[b]+=g,l[b+1]+=g)}p+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+i),p=d-s;if(p<0||p>=o.content.size){a=!0;continue}let u=t.map(n[c+1]+i,-1),h=u-s,{index:f,offset:m}=o.content.findIndex(p),g=o.maybeChild(f);if(g&&m==p&&m+g.nodeSize==h){let b=l[c+2].mapInner(t,g,d+1,n[c]+i+1,r);b!=re?(l[c]=p,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=i1(l,n,e,t,s,i,r),d=as(c,o,0,r);e=d.local;for(let p=0;p<l.length;p+=3)l[p+1]<0&&(l.splice(p,3),p-=3);for(let p=0,u=0;p<d.children.length;p+=3){let h=d.children[p];for(;u<l.length&&l[u]<h;)u+=3;l.splice(u,0,d.children[p],d.children[p+1],d.children[p+2])}}return new U(e.sort(Gt),l)}function od(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 ye(s.from+e,s.to+e,s.type))}return t}function i1(n,e,t,o,s,i,r){function l(a,c){for(let d=0;d<a.local.length;d++){let p=a.local[d].map(o,s,c);p?t.push(p):r.onRemove&&r.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function sd(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,s=null;for(let i=0,r;i<n.length;i++)(r=n[i])&&r.from>t&&r.to<o&&((s||(s=[])).push(r),n[i]=null);return s}function id(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function as(n,e,t,o){let s=[],i=!1;e.forEach((l,a)=>{let c=sd(n,l,a+t);if(c){i=!0;let d=as(c,l,t+a+1,o);d!=re&&s.push(a,a+l.nodeSize,d)}});let r=od(i?id(n):n,-t).sort(Gt);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||(o.onRemove&&o.onRemove(r[l].spec),r.splice(l--,1));return r.length||s.length?new U(r,s):re}function Gt(n,e){return n.from-e.from||n.to-e.to}function Ui(n){let e=n;for(let t=0;t<e.length-1;t++){let o=e[t];if(o.from!=o.to)for(let s=t+1;s<e.length;s++){let i=e[s];if(i.from==o.from){i.to!=o.to&&(e==n&&(e=n.slice()),e[s]=i.copy(i.from,o.to),rd(e,s+1,i.copy(o.to,i.to)));continue}else{i.from<o.to&&(e==n&&(e=n.slice()),e[t]=o.copy(o.from,i.from),rd(e,s,o.copy(i.from,o.to)));break}}}return e}function rd(n,e,t){for(;e<n.length&&Gt(t,n[e])>0;)e++;n.splice(e,0,t)}function Ki(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=re&&e.push(o)}),n.cursorWrapper&&e.push(U.create(n.state.doc,[n.cursorWrapper.deco])),yt.from(e)}const r1={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},l1=ge&&pt<=11;class a1{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 c1{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new a1,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]);ge&&pt<=11&&o.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),l1&&(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,r1)),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(Rc(this.view)){if(this.suppressingSelectionUpdates)return Qe(this.view);if(ge&&pt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&zt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,o;for(let i=e.focusNode;i;i=Wn(i))t.add(i);for(let i=e.anchorNode;i;i=Wn(i))if(t.has(i)){o=i;break}let s=o&&this.view.docView.nearestDesc(o);if(s&&s.ignoreMutation({type:"selection",target:o.nodeType==3?o.parentNode:o}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let o=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&Rc(e)&&!this.ignoreSelectionChange(o),i=-1,r=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let p=this.registerMutation(t[d],a);p&&(i=i<0?p.from:Math.min(p.from,i),r=r<0?p.to:Math.max(p.to,r),p.typeOver&&(l=!0))}if(Re&&a.length){let d=a.filter(p=>p.nodeName=="BR");if(d.length==2){let[p,u]=d;p.parentNode&&p.parentNode.parentNode==u.parentNode?u.remove():p.remove()}else{let{focusNode:p}=this.currentSelection;for(let u of d){let h=u.parentNode;h&&h.nodeName=="LI"&&(!p||u1(e,p)!=h)&&u.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&es(o)&&(c=Li(e))&&c.eq(L.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Qe(e),this.currentSelection.set(o),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,r),d1(e)),this.handleDOMChange(i,r,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(o)||Qe(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 p=e.addedNodes[d];t.push(p),p.nodeType==3&&(this.lastChangedTextNode=p)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return{from:o.posBefore,to:o.posAfter};let s=e.previousSibling,i=e.nextSibling;if(ge&&pt<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:p,nextSibling:u}=e.addedNodes[d];(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(s=p),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u)}let r=s&&s.parentNode==e.target?ne(s)+1:0,l=o.localPosFromDOM(e.target,r,-1),a=i&&i.parentNode==e.target?ne(i):e.target.childNodes.length,c=o.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}:(this.lastChangedTextNode=e.target,{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let ld=new WeakMap,ad=!1;function d1(n){if(!ld.has(n)&&(ld.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Re,ad)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."),ad=!0}}function cd(n,e){let t=e.startContainer,o=e.startOffset,s=e.endContainer,i=e.endOffset,r=n.domAtPos(n.state.selection.anchor);return zt(r.node,r.offset,s,i)&&([t,o,s,i]=[s,i,t,o]),{anchorNode:t,anchorOffset:o,focusNode:s,focusOffset:i}}function p1(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return cd(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?cd(n,t):null}function u1(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 h1(n,e,t){let{node:o,fromOffset:s,toOffset:i,from:r,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],es(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ie&&n.input.lastKeyCode===8)for(let g=i;g>s;g--){let b=o.childNodes[g-1],w=b.pmViewDesc;if(b.nodeName=="BR"&&!w){i=g;break}if(!w||w.size)break}let p=n.state.doc,u=n.someProp("domParser")||Rt.fromSchema(n.state.schema),h=p.resolve(r),f=null,m=u.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:f1,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+r,head:b+r}}return{doc:m,sel:f,from:r,to:l}}function f1(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ae&&/^(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||ae&&/^(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 m1=/^(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 g1(n,e,t,o,s){let i=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=Li(n,k);if(M&&!n.state.selection.eq(M)){if(ie&&De&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",N=>N(n,Bt(13,"Enter"))))return;let P=n.state.tr.setSelection(M);k=="pointer"?P.setMeta("pointer",!0):k=="key"&&P.scrollIntoView(),i&&P.setMeta("composition",i),n.dispatch(P)}return}let r=n.state.doc.resolve(e),l=r.sharedDepth(t);e=r.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=h1(n,e,t),d=n.state.doc,p=d.slice(c.from,c.to),u,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,h="end"):(u=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let f=v1(p.content,c.doc.content,c.from,u,h);if(f&&n.input.domChangeCount++,(bn&&n.input.lastIOSEnter>Date.now()-225||De)&&s.some(k=>k.nodeType==1&&!m1.test(k.nodeName))&&(!f||f.endA>=f.endB)&&n.someProp("handleKeyDown",k=>k(n,Bt(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=dd(n,n.state.doc,c.sel);if(k&&!k.eq(n.state.selection)){let M=n.state.tr.setSelection(k);i&&M.setMeta("composition",i),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)),ge&&pt<=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),w=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=f.endA,y;if((bn&&n.input.lastIOSEnter>Date.now()-225&&(!w||s.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!w&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(y=L.findFrom(c.doc.resolve(m.pos+1),1,!0))&&y.head==g.pos)&&n.someProp("handleKeyDown",k=>k(n,Bt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>f.start&&b1(d,f.start,f.endA,m,g)&&n.someProp("handleKeyDown",k=>k(n,Bt(8,"Backspace")))){De&&ie&&n.domObserver.suppressSelectionUpdates();return}ie&&De&&f.endB==f.start&&(n.input.lastAndroidDelete=Date.now()),De&&!w&&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,Bt(13,"Enter"))})},20));let v=f.start,C=f.endA,S,x,E;if(w){if(m.pos==g.pos)ge&&pt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Qe(n),20)),S=n.state.tr.delete(v,C),x=d.resolve(f.start).marksAcross(d.resolve(f.endA));else if(f.endA==f.endB&&(E=y1(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start()))))S=n.state.tr,E.type=="add"?S.addMark(v,C,E.mark):S.removeMark(v,C,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,v,C,k)))return;S=n.state.tr.insertText(k,v,C)}}if(S||(S=n.state.tr.replace(v,C,c.doc.slice(f.start-c.from,f.endB-c.from))),c.sel){let k=dd(n,S.doc,c.sel);k&&!(ie&&De&&n.composing&&k.empty&&(f.start!=f.endB||n.input.lastAndroidDelete<Date.now()-100)&&(k.head==v||k.head==S.mapping.map(C)-1)||ge&&k.empty&&k.head==v)&&S.setSelection(k)}x&&S.ensureMarks(x),i&&S.setMeta("composition",i),n.dispatch(S.scrollIntoView())}function dd(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:zi(n,e.resolve(t.anchor),e.resolve(t.head))}function y1(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,s=t,i=o,r,l,a;for(let d=0;d<o.length;d++)s=o[d].removeFromSet(s);for(let d=0;d<t.length;d++)i=t[d].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],r="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&i.length==1)l=i[0],r="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(T.from(c).eq(n))return{mark:l,type:r}}function b1(n,e,t,o,s){if(t-e<=s.pos-o.pos||Ji(o,!0,!1)<s.pos)return!1;let i=n.resolve(e);if(!o.parent.isTextblock){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let r=n.resolve(Ji(i,!0,!0));return!r.parent.isTextblock||r.pos>t||Ji(r,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(r.parent.content)}function Ji(n,e,t){let o=n.depth,s=e?n.end():n.pos;for(;o>0&&(e||n.indexAfter(o)==n.node(o).childCount);)o--,s++,e=!1;if(t){let i=n.node(o).maybeChild(n.indexAfter(o));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function v1(n,e,t,o,s){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:r,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,i-Math.min(r,l));o-=r+a-i}if(r<i&&n.size<e.size){let a=o<=i&&o>=r?i-o:0;i-=a,i&&i<e.size&&pd(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-r),r=i}else if(l<i){let a=o<=i&&o>=l?i-o:0;i-=a,i&&i<n.size&&pd(n.textBetween(i-1,i+1))&&(i+=a?1:-1),r=i+(r-l),l=i}return{start:i,endA:r,endB:l}}function pd(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 S1{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 Vg,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(gd),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=fd(this),hd(this),this.nodeViews=md(this),this.docView=xc(this.state.doc,ud(this),Ki(this),this.dom,this),this.domObserver=new c1(this,(o,s,i,r)=>g1(this,o,s,i,r)),this.domObserver.start(),Hg(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&&_i(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(gd),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let o in this._props)t[o]=this._props[o];t.state=this.state;for(let o in e)t[o]=e[o];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var o;let s=this.state,i=!1,r=!1;e.storedMarks&&this.composing&&(Qc(this),r=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=md(this);w1(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&_i(this),this.editable=fd(this),hd(this);let a=Ki(this),c=ud(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",p=i||!this.docView.matchesNode(e.doc,c,a);(p||!e.selection.eq(s.selection))&&(r=!0);let u=d=="preserve"&&r&&this.dom.style.overflowAnchor==null&&eg(this);if(r){this.domObserver.stop();let h=p&&(ge||ie)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&x1(s.selection,e.selection);if(p){let f=ie?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Qg(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=xc(e.doc,c,a,this.dom,this)),f&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&kg(this))?Qe(this,h):(Oc(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():u&&tg(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof D){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ac(this,t.getBoundingClientRect(),e)}else ac(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let o=this.directPlugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let o=this.state.plugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let o=this.pluginViews[t];o.update&&o.update(this,e)}}updateDraggedNode(e,t){let o=e.node,s=-1;if(this.state.doc.nodeAt(o.from)==o.node)s=o.from;else{let i=o.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==o.node&&(s=i)}this.dragging=new td(e.slice,e.move,s<0?void 0:D.create(this.state.doc,s))}someProp(e,t){let o=this._props&&this._props[e],s;if(o!=null&&(s=t?t(o):o))return s;for(let r=0;r<this.directPlugins.length;r++){let l=this.directPlugins[r].props[e];if(l!=null&&(s=t?t(l):l))return s}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let l=i[r].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(ge){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&&ng(this.dom),Qe(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 lg(this,e)}coordsAtPos(e,t=1){return fc(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 ug(this,t||this.state,e)}pasteHTML(e,t){return Xn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Xn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Fg(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ki(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Gm())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Gg(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?ae&&this.root.nodeType===11&&Km(this.dom.ownerDocument)==this.dom&&p1(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function ud(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"),[ye.node(0,n.state.doc.content.size,e)]}function hd(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:ye.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function fd(n){return!n.someProp("editable",e=>e(n.state)===!1)}function x1(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 md(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 w1(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 gd(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 Zi,Yi;if(typeof WeakMap<"u"){let n=new WeakMap;Zi=e=>n.get(e),Yi=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Zi=o=>{for(let s=0;s<n.length;s+=2)if(n[s]==o)return n[s+1]},Yi=(o,s)=>(t==10&&(t=0),n[t++]=o,n[t++]=s)}var J=class{constructor(n,e,t,o){this.width=n,this.height=e,this.map=t,this.problems=o}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const o=e%this.width,s=e/this.width|0;let i=o+1,r=s+1;for(let l=1;i<this.width&&this.map[e+l]==t;l++)i++;for(let l=1;r<this.height&&this.map[e+this.width*l]==t;l++)r++;return{left:o,top:s,right:i,bottom:r}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:o,right:s,top:i,bottom:r}=this.findCell(n);return e=="horiz"?(t<0?o==0:s==this.width)?null:this.map[i*this.width+(t<0?o-1:s)]:(t<0?i==0:r==this.height)?null:this.map[o+this.width*(t<0?i-1:r)]}rectBetween(n,e){const{left:t,right:o,top:s,bottom:i}=this.findCell(n),{left:r,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,r),top:Math.min(s,a),right:Math.max(o,l),bottom:Math.max(i,c)}}cellsInRect(n){const e=[],t={};for(let o=n.top;o<n.bottom;o++)for(let s=n.left;s<n.right;s++){const i=o*this.width+s,r=this.map[i];t[r]||(t[r]=!0,!(s==n.left&&s&&this.map[i-1]==r||o==n.top&&o&&this.map[i-this.width]==r)&&e.push(r))}return e}positionAt(n,e,t){for(let o=0,s=0;;o++){const i=s+t.child(o).nodeSize;if(o==n){let r=e+n*this.width;const l=(n+1)*this.width;for(;r<l&&this.map[r]<s;)r++;return r==l?i-1:this.map[r]}s=i}}static get(n){return Zi(n)||Yi(n,C1(n))}};function C1(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=k1(n),t=n.childCount,o=[];let s=0,i=null;const r=[];for(let c=0,d=e*t;c<d;c++)o[c]=0;for(let c=0,d=0;c<t;c++){const p=n.child(c);d++;for(let f=0;;f++){for(;s<o.length&&o[s]!=0;)s++;if(f==p.childCount)break;const m=p.child(f),{colspan:g,rowspan:b,colwidth:w}=m.attrs;for(let y=0;y<b;y++){if(y+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:b-y});break}const v=s+y*e;for(let C=0;C<g;C++){o[v+C]==0?o[v+C]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:g-C});const S=w&&w[C];if(S){const x=(v+C)%e*2,E=r[x];E==null||E!=S&&r[x+1]==1?(r[x]=S,r[x+1]=1):E==S&&r[x+1]++}}}s+=g,d+=m.nodeSize}const u=(c+1)*e;let h=0;for(;s<u;)o[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),d++}const l=new J(e,t,o,i);let a=!1;for(let c=0;!a&&c<r.length;c+=2)r[c]!=null&&r[c+1]<t&&(a=!0);return a&&E1(l,r,n),l}function k1(n){let e=-1,t=!1;for(let o=0;o<n.childCount;o++){const s=n.child(o);let i=0;if(t)for(let r=0;r<o;r++){const l=n.child(r);for(let a=0;a<l.childCount;a++){const c=l.child(a);r+c.attrs.rowspan>o&&(i+=c.attrs.colspan)}}for(let r=0;r<s.childCount;r++){const l=s.child(r);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function E1(n,e,t){n.problems||(n.problems=[]);const o={};for(let s=0;s<n.map.length;s++){const i=n.map[s];if(o[i])continue;o[i]=!0;const r=t.nodeAt(i);if(!r)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=r.attrs;for(let c=0;c<a.colspan;c++){const d=(s+c)%n.width,p=e[d*2];p!=null&&(!a.colwidth||a.colwidth[c]!=p)&&((l||(l=T1(a)))[c]=p)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function T1(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function yd(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),o=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(r=>Number(r)):null,s=Number(n.getAttribute("colspan")||1),i={colspan:s,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:o&&o.length==s?o:null};for(const r in e){const l=e[r].getFromDOM,a=l&&l(n);a!=null&&(i[r]=a)}return i}function bd(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 M1(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=>yd(o,e)}],toDOM(o){return["td",bd(o,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:o=>yd(o,e)}],toDOM(o){return["th",bd(o,e),0]}}}}function Ge(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 bt=new _n("selectingCells");function eo(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 cs(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 Xi(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=eo(e.$head)||A1(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function A1(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 Qi(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function P1(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function er(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function vd(n,e,t){const o=n.node(-1),s=J.get(o),i=n.start(-1),r=s.nextCell(n.pos-i,e,t);return r==null?null:n.node(0).resolve(i+r)}function Cn(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 Y=class nt extends L{constructor(e,t=e){const o=e.node(-1),s=J.get(o),i=e.start(-1),r=s.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=s.cellsInRect(r).filter(d=>d!=t.pos-i);a.unshift(t.pos-i);const c=a.map(d=>{const p=o.nodeAt(d);if(!p)throw RangeError(`No cell with offset ${d} found`);const u=i+d+1;return new Oa(l.resolve(u),l.resolve(u+p.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(Qi(o)&&Qi(s)&&er(o,s)){const i=this.$anchorCell.node(-1)!=o.node(-1);return i&&this.isRowSelection()?nt.rowSelection(o,s):i&&this.isColSelection()?nt.colSelection(o,s):new nt(o,s)}return $.between(o,s)}content(){const e=this.$anchorCell.node(-1),t=J.get(e),o=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),i={},r=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let d=a*t.width+s.left,p=s.left;p<s.right;p++,d++){const u=t.map[d];if(i[u])continue;i[u]=!0;const h=t.findCell(u);let f=e.nodeAt(u);if(!f)throw RangeError(`No cell with offset ${u} 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=Cn(b,0,m)),g>0&&(b=Cn(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)}r.push(e.child(a).copy(T.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:r;return new A(T.from(l),1,1)}replace(e,t=A.empty){const o=e.steps.length,s=this.ranges;for(let r=0;r<s.length;r++){const{$from:l,$to:a}=s[r],c=e.mapping.slice(o);e.replace(c.map(l.pos),c.map(a.pos),r?A.empty:t)}const i=L.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new A(T.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),o=J.get(t),s=this.$anchorCell.start(-1),i=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let r=0;r<i.length;r++)e(t.nodeAt(i[r]),s+i[r])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const o=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const o=e.node(-1),s=J.get(o),i=e.start(-1),r=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return r.top<=l.top?(r.top>0&&(e=a.resolve(i+s.map[r.left])),l.bottom<s.height&&(t=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+s.map[l.left])),r.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+r.right-1]))),new nt(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=J.get(e),o=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-o),i=t.colCount(this.$headCell.pos-o);if(Math.min(s,i)>0)return!1;const r=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(r,l)==t.width}eq(e){return e instanceof nt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const o=e.node(-1),s=J.get(o),i=e.start(-1),r=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return r.left<=l.left?(r.left>0&&(e=a.resolve(i+s.map[r.top*s.width])),l.right<s.width&&(t=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+s.map[l.top*s.width])),r.right<s.width&&(e=a.resolve(i+s.map[s.width*(r.top+1)-1]))),new nt(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new nt(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){return new nt(e.resolve(t),e.resolve(o))}getBookmark(){return new N1(this.$anchorCell.pos,this.$headCell.pos)}};Y.prototype.visible=!1,L.jsonID("cell",Y);var N1=class Tp{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Tp(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&&er(t,o)?new Y(t,o):L.near(o,1)}};function O1(n){if(!(n.selection instanceof Y))return null;const e=[];return n.selection.forEachCell((t,o)=>{e.push(ye.node(o,o+t.nodeSize,{class:"selectedCell"}))}),U.create(n.doc,e)}function I1({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,o=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,o--);return t==o&&/row|table/.test(n.node(s).type.spec.tableRole)}function R1({$from:n,$to:e}){let t,o;for(let s=n.depth;s>0;s--){const i=n.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){o=i;break}}return t!==o&&e.parentOffset===0}function D1(n,e,t){const o=(e||n).selection,s=(e||n).doc;let i,r;if(o instanceof D&&(r=o.node.type.spec.tableRole)){if(r=="cell"||r=="header_cell")i=Y.create(s,o.from);else if(r=="row"){const l=s.resolve(o.from+1);i=Y.rowSelection(l,l)}else if(!t){const l=J.get(o.node),a=o.from+1,c=a+l.map[l.width*l.height-1];i=Y.create(s,a+1,c)}}else o instanceof $&&I1(o)?i=$.create(s,o.from):o instanceof $&&R1(o)&&(i=$.create(s,o.$from.start(),o.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var L1=new _n("fix-tables");function Sd(n,e,t,o){const s=n.childCount,i=e.childCount;e:for(let r=0,l=0;r<i;r++){const a=e.child(r);for(let c=l,d=Math.min(s,r+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}o(a,t),l<s&&n.child(l).sameMarkup(a)?Sd(n.child(l),a,t+1,o):a.nodesBetween(0,a.content.size,o,t+1),t+=a.nodeSize}}function $1(n,e){let t;const o=(s,i)=>{s.type.spec.tableRole=="table"&&(t=z1(n,s,i,t))};return e?e.doc!=n.doc&&Sd(e.doc,n.doc,0,o):n.doc.descendants(o),t}function z1(n,e,t,o){const s=J.get(e);if(!s.problems)return o;o||(o=n.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const p=d.attrs;for(let u=0;u<p.rowspan;u++)i[c.row+u]+=c.n;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,Cn(p,p.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}}let r,l;for(let a=0;a<i.length;a++)i[a]&&(r==null&&(r=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const d=e.child(a),p=c+d.nodeSize,u=i[a];if(u>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const f=[];for(let g=0;g<u;g++){const b=Ge(n.schema)[h].createAndFill();b&&f.push(b)}const m=(a==0||r==a-1)&&l==a?c+1:p-1;o.insert(o.mapping.map(m),f)}c=p}return o.setMeta(L1,{fixTables:!0})}function xd(n){const e=n.selection,t=Xi(n),o=t.node(-1),s=t.start(-1),i=J.get(o);return{...e instanceof Y?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(t.pos-s),tableStart:s,map:i,table:o}}function B1(n){return function(e,t){if(!cs(e))return!1;if(t){const o=Ge(e.schema),s=xd(e),i=e.tr,r=s.map.cellsInRect(n=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:n=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=r.map(a=>s.table.nodeAt(a));for(let a=0;a<r.length;a++)l[a].type==o.header_cell&&i.setNodeMarkup(s.tableStart+r[a],o.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<r.length;a++)i.setNodeMarkup(s.tableStart+r[a],o.header_cell,l[a].attrs);t(i)}return!0}}function wd(n,e,t){const o=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<o.length;s++){const i=e.table.nodeAt(o[s]);if(i&&i.type!==t.header_cell)return!1}return!0}function tr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?B1(n):function(t,o){if(!cs(t))return!1;if(o){const s=Ge(t.schema),i=xd(t),r=t.tr,l=wd("row",i,s),a=wd("column",i,s),d=(n==="column"?l:n==="row"?a:!1)?1:0,p=n=="column"?{left:0,top:d,right:1,bottom:i.map.height}:n=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,u=n=="column"?a?s.cell:s.header_cell:n=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(p).forEach(h=>{const f=h+i.tableStart,m=r.doc.nodeAt(f);m&&r.setNodeMarkup(f,u,m.attrs)}),o(r)}return!0}}tr("row",{useDeprecatedLogic:!0}),tr("column",{useDeprecatedLogic:!0}),tr("cell",{useDeprecatedLogic:!0});function V1(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let o=n.index(-1)-1,s=n.before();o>=0;o--){const i=n.node(-1).child(o),r=i.lastChild;if(r)return s-1-r.nodeSize;s-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let o=n.indexAfter(-1),s=n.after();o<t.childCount;o++){const i=t.child(o);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Cd(n){return function(e,t){if(!cs(e))return!1;const o=V1(Xi(e),n);if(o==null)return!1;if(t){const s=e.doc.resolve(o);t(e.tr.setSelection($.between(s,P1(s))).scrollIntoView())}return!0}}function ds(n,e){const t=n.selection;if(!(t instanceof Y))return!1;if(e){const o=n.tr,s=Ge(n.schema).cell.createAndFill().content;t.forEachCell((i,r)=>{i.content.eq(s)||o.replace(o.mapping.map(r+1),o.mapping.map(r+i.nodeSize-1),new A(s,0,0))}),o.docChanged&&e(o)}return!0}function H1(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:o}=n;for(;e.childCount==1&&(t>0&&o>0||e.child(0).type.spec.tableRole=="table");)t--,o--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,r=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),p=a<e.childCount-1?0:Math.max(0,o-1);(d||p)&&(c=nr(Ge(r).row,new A(c,d,p)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||o?nr(Ge(r).row,new A(e,t,o)).content:e);else return null;return F1(r,l)}function F1(n,e){const t=[];for(let s=0;s<e.length;s++){const i=e[s];for(let r=i.childCount-1;r>=0;r--){const{rowspan:l,colspan:a}=i.child(r).attrs;for(let c=s;c<s+l;c++)t[c]=(t[c]||0)+a}}let o=0;for(let s=0;s<t.length;s++)o=Math.max(o,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(T.empty),t[s]<o){const i=Ge(n).cell.createAndFill(),r=[];for(let l=t[s];l<o;l++)r.push(i);e[s]=e[s].append(T.from(r))}return{height:e.length,width:o,rows:e}}function nr(n,e){const t=n.createAndFill();return new Na(t).replace(0,t.content.size,e).doc}function _1({width:n,height:e,rows:t},o,s){if(n!=o){const i=[],r=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=i[l]||0,p=0;d<o;p++){let u=a.child(p%a.childCount);d+u.attrs.colspan>o&&(u=u.type.createChecked(Cn(u.attrs,u.attrs.colspan,d+u.attrs.colspan-o),u.content)),c.push(u),d+=u.attrs.colspan;for(let h=1;h<u.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+u.attrs.colspan}r.push(T.from(c))}t=r,n=o}if(e!=s){const i=[];for(let r=0,l=0;r<s;r++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let p=c.child(d);r+p.attrs.rowspan>s&&(p=p.type.create({...p.attrs,rowspan:Math.max(1,s-p.attrs.rowspan)},p.content)),a.push(p)}i.push(T.from(a))}t=i,e=s}return{width:n,height:e,rows:t}}function G1(n,e,t,o,s,i,r){const l=n.doc.type.schema,a=Ge(l);let c,d;if(s>e.width)for(let p=0,u=0;p<e.height;p++){const h=t.child(p);u+=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(r).map(u-1+o),f)}if(i>e.height){const p=[];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;p.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const u=a.row.create(null,T.from(p)),h=[];for(let f=e.height;f<i;f++)h.push(u);n.insert(n.mapping.slice(r).map(o+t.nodeSize-2),h)}return!!(c||d)}function kd(n,e,t,o,s,i,r,l){if(r==0||r==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const d=r*e.width+c,p=e.map[d];if(e.map[d-e.width]==p){a=!0;const u=t.nodeAt(p),{top:h,left:f}=e.findCell(p);n.setNodeMarkup(n.mapping.slice(l).map(p+o),null,{...u.attrs,rowspan:r-h}),n.insert(n.mapping.slice(l).map(e.positionAt(r,f,t)),u.type.createAndFill({...u.attrs,rowspan:h+u.attrs.rowspan-r})),c+=u.attrs.colspan-1}}return a}function Ed(n,e,t,o,s,i,r,l){if(r==0||r==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const d=c*e.width+r,p=e.map[d];if(e.map[d-1]==p){a=!0;const u=t.nodeAt(p),h=e.colCount(p),f=n.mapping.slice(l).map(p+o);n.setNodeMarkup(f,null,Cn(u.attrs,r-h,u.attrs.colspan-(r-h))),n.insert(f+u.nodeSize,u.type.createAndFill(Cn(u.attrs,0,r-h))),c+=u.attrs.rowspan-1}}return a}function Td(n,e,t,o,s){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let r=J.get(i);const{top:l,left:a}=o,c=a+s.width,d=l+s.height,p=n.tr;let u=0;function h(){if(i=t?p.doc.nodeAt(t-1):p.doc,!i)throw new Error("No table found");r=J.get(i),u=p.mapping.maps.length}G1(p,r,i,t,c,d,u)&&h(),kd(p,r,i,t,a,c,l,u)&&h(),kd(p,r,i,t,a,c,d,u)&&h(),Ed(p,r,i,t,l,d,a,u)&&h(),Ed(p,r,i,t,l,d,c,u)&&h();for(let f=l;f<d;f++){const m=r.positionAt(f,a,i),g=r.positionAt(f,c,i);p.replace(p.mapping.slice(u).map(m+t),p.mapping.slice(u).map(g+t),new A(s.rows[f-l],0,0))}h(),p.setSelection(new Y(p.doc.resolve(t+r.positionAt(l,a,i)),p.doc.resolve(t+r.positionAt(d-1,c-1,i)))),e(p)}var W1=nc({ArrowLeft:us("horiz",-1),ArrowRight:us("horiz",1),ArrowUp:us("vert",-1),ArrowDown:us("vert",1),"Shift-ArrowLeft":hs("horiz",-1),"Shift-ArrowRight":hs("horiz",1),"Shift-ArrowUp":hs("vert",-1),"Shift-ArrowDown":hs("vert",1),Backspace:ds,"Mod-Backspace":ds,Delete:ds,"Mod-Delete":ds});function ps(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function us(n,e){return(t,o,s)=>{if(!s)return!1;const i=t.selection;if(i instanceof Y)return ps(t,o,L.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const r=Md(s,n,e);if(r==null)return!1;if(n=="horiz")return ps(t,o,L.near(t.doc.resolve(i.head+e),e));{const l=t.doc.resolve(r),a=vd(l,n,e);let c;return a?c=L.near(a,1):e<0?c=L.near(t.doc.resolve(l.before(-1)),-1):c=L.near(t.doc.resolve(l.after(-1)),1),ps(t,o,c)}}}function hs(n,e){return(t,o,s)=>{if(!s)return!1;const i=t.selection;let r;if(i instanceof Y)r=i;else{const a=Md(s,n,e);if(a==null)return!1;r=new Y(t.doc.resolve(a))}const l=vd(r.$headCell,n,e);return l?ps(t,o,new Y(r.$anchorCell,l)):!1}}function j1(n,e){const t=n.state.doc,o=eo(t.resolve(e));return o?(n.dispatch(n.state.tr.setSelection(new Y(o))),!0):!1}function q1(n,e,t){if(!cs(n.state))return!1;let o=H1(t);const s=n.state.selection;if(s instanceof Y){o||(o={width:1,height:1,rows:[T.from(nr(Ge(n.state.schema).cell,t))]});const i=s.$anchorCell.node(-1),r=s.$anchorCell.start(-1),l=J.get(i).rectBetween(s.$anchorCell.pos-r,s.$headCell.pos-r);return o=_1(o,l.right-l.left,l.bottom-l.top),Td(n.state,n.dispatch,r,l,o),!0}else if(o){const i=Xi(n.state),r=i.start(-1);return Td(n.state,n.dispatch,r,J.get(i.node(-1)).findCell(i.pos-r),o),!0}else return!1}function U1(n,e){var t;if(e.ctrlKey||e.metaKey)return;const o=Ad(n,e.target);let s;if(e.shiftKey&&n.state.selection instanceof Y)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(s=eo(n.state.selection.$anchor))!=null&&((t=or(n,e))==null?void 0:t.pos)!=s.pos)i(s,e),e.preventDefault();else if(!o)return;function i(a,c){let d=or(n,c);const p=bt.getState(n.state)==null;if(!d||!er(a,d))if(p)d=a;else return;const u=new Y(a,d);if(p||!n.state.selection.eq(u)){const h=n.state.tr.setSelection(u);p&&h.setMeta(bt,a.pos),n.dispatch(h)}}function r(){n.root.removeEventListener("mouseup",r),n.root.removeEventListener("dragstart",r),n.root.removeEventListener("mousemove",l),bt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(bt,-1))}function l(a){const c=a,d=bt.getState(n.state);let p;if(d!=null)p=n.state.doc.resolve(d);else if(Ad(n,c.target)!=o&&(p=or(n,e),!p))return r();p&&i(p,c)}n.root.addEventListener("mouseup",r),n.root.addEventListener("dragstart",r),n.root.addEventListener("mousemove",l)}function Md(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 i=o.node(s);if((t<0?o.index(s):o.indexAfter(s))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=o.before(s),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Ad(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function or(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?eo(n.state.doc.resolve(t.pos)):null}var K1=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")),sr(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,sr(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function sr(n,e,t,o,s,i){var r;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let p=0,u=0;p<d.childCount;p++){const{colspan:h,colwidth:f}=d.child(p).attrs;for(let m=0;m<h;m++,u++){const g=s==u?i: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 w=document.createElement("col");w.style.width=b,e.appendChild(w)}}}for(;c;){const p=c.nextSibling;(r=c.parentNode)==null||r.removeChild(c),c=p}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var we=new _n("tableColumnResizing");function J1({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:o=K1,lastColumnResizable:s=!0}={}){const i=new gn({key:we,state:{init(r,l){var a,c;const d=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,p=Ge(l.schema).table.name;return o&&d&&(d[p]=(u,h)=>new o(u,t,h)),new Z1(-1,!1)},apply(r,l){return l.apply(r)}},props:{attributes:r=>{const l=we.getState(r);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(r,l)=>{Y1(r,l,n,s)},mouseleave:r=>{X1(r)},mousedown:(r,l)=>{Q1(r,l,e,t)}},decorations:r=>{const l=we.getState(r);if(l&&l.activeHandle>-1)return s0(r,l.activeHandle)},nodeViews:{}}});return i}var Z1=class Es{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,o=e.getMeta(we);if(o&&o.setHandle!=null)return new Es(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new Es(t.activeHandle,o.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);return Qi(e.doc.resolve(s))||(s=-1),new Es(s,t.dragging)}return t}};function Y1(n,e,t,o){const s=we.getState(n.state);if(s&&!s.dragging){const i=t0(e.target);let r=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?r=Pd(n,e,"left",t):a-e.clientX<=t&&(r=Pd(n,e,"right",t))}if(r!=s.activeHandle){if(!o&&r!==-1){const l=n.state.doc.resolve(r),a=l.node(-1),c=J.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Od(n,r)}}}function X1(n){const e=we.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Od(n,-1)}function Q1(n,e,t,o){var s;const i=(s=n.dom.ownerDocument.defaultView)!=null?s:window,r=we.getState(n.state);if(!r||r.activeHandle==-1||r.dragging)return!1;const l=n.state.doc.nodeAt(r.activeHandle),a=e0(n,r.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(we,{setDragging:{startX:e.clientX,startWidth:a}}));function c(p){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const u=we.getState(n.state);u!=null&&u.dragging&&(n0(n,u.activeHandle,Nd(u.dragging,p,t)),n.dispatch(n.state.tr.setMeta(we,{setDragging:null})))}function d(p){if(!p.which)return c(p);const u=we.getState(n.state);if(u&&u.dragging){const h=Nd(u.dragging,p,t);Id(n,u.activeHandle,h,o)}}return Id(n,r.activeHandle,a,o),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function e0(n,e,{colspan:t,colwidth:o}){const s=o&&o[o.length-1];if(s)return s;const i=n.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=t;if(o)for(let c=0;c<t;c++)o[c]&&(l-=o[c],a--);return l/a}function t0(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Pd(n,e,t,o){const s=t=="right"?-o:o,i=n.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:r}=i,l=eo(n.state.doc.resolve(r));if(!l)return-1;if(t=="right")return l.pos;const a=J.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 Nd(n,e,t){const o=e.clientX-n.startX;return Math.max(t,n.startWidth+o)}function Od(n,e){n.dispatch(n.state.tr.setMeta(we,{setHandle:e}))}function n0(n,e,t){const o=n.state.doc.resolve(e),s=o.node(-1),i=J.get(s),r=o.start(-1),l=i.colCount(o.pos-r)+o.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){const d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;const p=i.map[d],u=s.nodeAt(p).attrs,h=u.colspan==1?0:l-i.colCount(p);if(u.colwidth&&u.colwidth[h]==t)continue;const f=u.colwidth?u.colwidth.slice():o0(u.colspan);f[h]=t,a.setNodeMarkup(r+p,null,{...u,colwidth:f})}a.docChanged&&n.dispatch(a)}function Id(n,e,t,o){const s=n.state.doc.resolve(e),i=s.node(-1),r=s.start(-1),l=J.get(i).colCount(s.pos-r)+s.nodeAfter.attrs.colspan-1;let a=n.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&sr(i,a.firstChild,a,o,l,t)}function o0(n){return Array(n).fill(0)}function s0(n,e){var t;const o=[],s=n.doc.resolve(e),i=s.node(-1);if(!i)return U.empty;const r=J.get(i),l=s.start(-1),a=r.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<r.height;c++){const d=a+c*r.width;if((a==r.width-1||r.map[d]!=r.map[d+1])&&(c==0||r.map[d]!=r.map[d-r.width])){const p=r.map[d],u=l+p+i.nodeAt(p).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(t=we.getState(n))!=null&&t.dragging&&o.push(ye.node(l+p,l+p+i.nodeAt(p).nodeSize,{class:"column-resize-dragging"})),o.push(ye.widget(u,h))}}return U.create(n.doc,o)}function i0({allowTableNodeSelection:n=!1}={}){return new gn({key:bt,state:{init(){return null},apply(e,t){const o=e.getMeta(bt);if(o!=null)return o==-1?null:o;if(t==null||!e.docChanged)return t;const{deleted:s,pos:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:O1,handleDOMEvents:{mousedown:U1},createSelectionBetween(e){return bt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:j1,handleKeyDown:W1,handlePaste:q1},appendTransaction(e,t,o){return D1(o,$1(o,t),n)}})}const to=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},ir=n=>{const{key:e,cssProperty:t,tagName:o="span"}=n,s="value";return{attrs:{...ms,[s]:{default:null}},parseDOM:[{tag:`${o}[${e}]`,getAttrs:i=>({...gs(i),[s]:i.style.getPropertyValue(t)||null})}],toDOM(i){const{[s]:r}=i.attrs,l={...qe(i),[e]:""};return r&&(l.style=`${t}: ${r}`),[o,l,0]}}},Rd="data-gs-mrk-fs",r0="data-gs-mrk-color",l0="data-gs-mrk-bgcolor",Dd="data-gs-mrk-wrap",fs="data-gs-ifrg",et="attrs",ms={[et]:{default:"{}"}},We={[et]:{default:{}}},gs=n=>({[et]:JSON.stringify(to(n))}),je=n=>({attrs:to(n)}),no=n=>e=>[n,e.attrs.attrs,0],qe=n=>n.attrs[et]?JSON.parse(n.attrs[et]):{},a0={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${fs}]`,getAttrs:je}],toDOM:()=>["span",{[fs]:""},0]},div:{group:"block",content:"inline*",attrs:We,parseDOM:[{tag:"div",getAttrs:je}],toDOM:no("div")},paragraph:{group:"block",content:"inline*",attrs:We,parseDOM:[{tag:"p",getAttrs:je}],toDOM:no("p")},orderedList:{group:"block",content:"listItem+",attrs:We,parseDOM:[{tag:"ol",getAttrs:je}],toDOM:no("ol")},bulletList:{group:"block",content:"listItem+",attrs:We,parseDOM:[{tag:"ul",getAttrs:je}],toDOM:no("ul")},listItem:{content:"block*",group:"block",attrs:We,parseDOM:[{tag:"li",getAttrs:je}],toDOM:no("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:We,parseDOM:[{tag:"pre",getAttrs:je}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:We,parseDOM:[{tag:"img[src]",getAttrs:je}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,attrs:We,parseDOM:[{tag:"br",getAttrs:je}],toDOM:n=>["br",{...n.attrs.attrs}]},hardBreak:{inline:!0,group:"inline",selectable:!1,attrs:We,parseDOM:[{tag:"br",getAttrs:je}],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:to(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...M1({tableGroup:"block",cellContent:"block+",cellAttributes:{[et]:{default:We[et].default,getFromDOM:to,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:to(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},oo=(n,e)=>({attrs:ms,parseDOM:n.map(t=>({tag:t,getAttrs:gs})),toDOM:e}),c0=n=>({attrs:{...ms},parseDOM:[{tag:`span[${n}]`,getAttrs:e=>({...gs(e)})}],toDOM(e){return["span",{...qe(e),[n]:!0},0]}}),d0={strong:oo(["strong","b"],n=>["b",qe(n)]),link:oo(["a"],n=>["a",qe(n),0]),em:oo(["em","i"],n=>["em",qe(n)]),underline:oo(["u"],n=>["u",qe(n),0]),strikethrough:oo(["s"],n=>["s",qe(n),0]),wrapStyle:c0(Dd),font_size:{attrs:{...ms,size:{default:null}},parseDOM:[{tag:`span[${Rd}]`,getAttrs:n=>({...gs(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...qe(n),[Rd]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}},color:ir({key:r0,cssProperty:"color"}),bgColor:ir({key:l0,cssProperty:"background-color"})},Ld=new Mf({nodes:a0,marks:d0}),so=new WeakMap,rr=new WeakMap,p0=(n,e,t)=>{so.set(n,{view:e,gjsView:t,initialDoc:e.state.doc}),rr.set(e,{el:n,gjsView:t})},u0=(n,e)=>{so.delete(n),rr.delete(e)},ys=n=>so.get(n),$d=n=>rr.get(n),zd=n=>{const e=ys(n),t=e==null?void 0:e.view,o=e==null?void 0:e.initialDoc;return!(t&&o&&o.eq(t.state.doc))},lr=n=>{var e,t;return(t=(e=$d(n))==null?void 0:e.gjsView)==null?void 0:t.model},h0=n=>n.dispatchEvent(new CustomEvent("input"));function f0(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(fs)){if(t.getAttribute("style")){t.removeAttribute(fs);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)}const Bd=n=>{n.childNodes.forEach(e=>{if(e.nodeName==="BR"){const{nextSibling:t}=e,o=n.lastChild===e,s=(t==null?void 0:t.nodeType)===Node.ELEMENT_NODE&&(t==null?void 0:t.nodeName)!=="BR";(o||s)&&e.remove()}else Bd(e)})},m0=(n,e)=>{const t=Vd(n);return t&&M0(t)?y0(n,e):t?ja(()=>({type:n.schema.nodes.div}))(n,e):!1},g0=(n,e)=>(t,o)=>{var l;const s=Vd(t),i=so.get(n.el).view,r=(l=e.onEnter)==null?void 0:l.call(e,{...n,node:s,commands:dr(i,n.editor,e),proseMirror:{view:i,dispatch:o}});return r!==void 0?r:m0(t,o)};function Vd(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 y0(n,e){const{selection:t,schema:o,tr:s}=n;s.split(t.from,1);const i=t.from+1,r=s.doc.nodeAt(i),l={...r.attrs.attrs,id:void 0},a=r.textContent.length>0,c=r.textContent.length||0,d=r.textContent||" ",p=o.text(d),u=o.nodes.div.create(l,a?p:[],[]);return s.replaceRangeWith(i,i+c+2,u),s.setSelection($.create(s.doc,i+1)),e==null||e(s.scrollIntoView()),!0}function b0(n,e,t){const{state:o,dispatch:s}=n,{selection:i,tr:r}=o,l=(a,c,d)=>{const p={};return a.split(";").forEach(u=>{const[h,f]=u.split(":").map(m=>m.trim());h&&(p[h]=f)}),p[c]=d,Object.entries(p).map(([u,h])=>`${u}: ${h}`).join("; ")};if(!i.empty||t)r.doc.nodesBetween(i.from,i.to,(a,c)=>{var d,p;if(a.type===o.schema.nodes.image){const u=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}else if(a.type.isBlock){const u=l(((p=a.attrs.attrs)==null?void 0:p.style)||"","text-align",e);Hd(a)?r.setBlockType(i.from,void 0,o.schema.nodes.div,{attrs:{style:u}}):r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}});else{const a=o.doc.resolve(i.from),c=a.start(a.depth),d=o.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const p=l(d.attrs.style||"","text-align",e);r.setNodeMarkup(c,void 0,{...d.attrs,style:p})}}r.docChanged&&s(r.scrollIntoView())}const io=(n,e)=>{const{from:t,to:o}=n.selection;let s=!1;return n.doc.nodesBetween(t,o,i=>{if(s)return!1;i.marks.some(r=>r.type===e)&&(s=!0)}),s};function v0(n){var p,u;const{view:e,href:t,options:o,target:s="_blank"}=n,{state:i,dispatch:r}=e,{schema:l,selection:a,tr:c}=i,d=l.marks.link;try{const h={href:t,target:s},f=((u=(p=o.commandAttrs)==null?void 0:p.link)==null?void 0:u.call(p,h))||h,m=d.create({[et]:JSON.stringify(f)});c.addMark(a.from,a.to,m),r(c.scrollIntoView())}catch(h){console.error("Error applying link mark:",h)}}function S0(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:i}=t;if(s.empty)return;const r=t.schema.marks.font_size;if(!r){console.error("Font size mark is not defined in the schema.");return}i.addMark(s.from,s.to,r.create({size:e})),o(i.scrollIntoView())}function x0(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:i}=t;if(s.empty)return;const r=t.schema.marks.color;if(!r){console.error("Color mark is not defined in the schema.");return}i.addMark(s.from,s.to,r.create({value:e})),o(i.scrollIntoView())}function w0(n,e){const{state:t,dispatch:o}=n,{selection:s,tr:i}=t;if(s.empty)return;const r=t.schema.marks.bgColor;if(!r){console.error("Background color mark is not defined in the schema.");return}i.addMark(s.from,s.to,r.create({value:e})),o(i.scrollIntoView())}const Wt=(n,e)=>{const{doc:t,selection:o}=n.state,s=t.resolve(o.from);for(let i=s.depth;i>0;i--){const r=s.node(i);if(e(r))return{pos:i>0?s.before(i):0,start:s.start(i),depth:i,node:r}}},C0=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 k0(...n){return(e,t)=>{const o=r=>{e=e.apply(r),t==null||t(r)},s=n.pop();return n.reduce((r,l)=>r||l(e,o),!1)&&s!==void 0&&s(e,t)}}const E0=(n,e)=>{const{state:t,dispatch:o}=n;if(e!=null&&e.event){const{event:s}=e,i=n.posAtCoords({left:s.clientX,top:s.clientY});i!=null&&i.pos&&o(t.tr.setSelection($.create(t.doc,i.pos)))}else qa(t,o);setTimeout(()=>setTimeout(()=>n.focus()))},ar=n=>n.isBlock,Hd=n=>n.type.name==="inlineFragment",T0=n=>ar(n)&&!Hd(n),Fd=n=>n.type.name==="bulletList",_d=n=>n.type.name==="orderedList",M0=n=>n.type.name==="heading",A0=n=>Fd(n)||_d(n),Gd=(n,e)=>{var i,r;const t=(i=Wt(n,l=>l.type===e))==null?void 0:i.node,o=n.state.schema.nodes.listItem;let s;return t?s=Ti(o):(r=Wt(n,A0))!=null&&r.node?s=k0(Ti(o),oc(e)):s=oc(e),s(n.state,n.dispatch)},Wd=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(o=>o.type.name===e)},P0=n=>{var r;const{view:e,prop:t,editor:o,propCSS:s}=n,i=(r=Wt(e,T0))==null?void 0:r.node;if(i){const l=i.attrs.attrs||{},a=C0(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""},cr=n=>{const{view:e,prop:t,markName:o,editor:s,propCSS:i}=n,r=Wd(e,o);if(r){const l=r.attrs;if(l[t])return l[t];if(l[et]){const a=qe(r).id;if(a){const c=s.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[i]||""}}}return""},dr=(n,e,t)=>{const{dispatch:o}=n,{nodes:s,marks:i}=n.state.schema,r={text:{selected:()=>{const{selection:l,doc:a}=n.state;return a.textBetween(l.from,l.to," ")},replace:(l,a={})=>{const{state:c}=n,{from:d}=c.selection;let p=c.tr.replaceSelectionWith(c.schema.text(l));a.select&&(p=p.setSelection($.create(p.doc,d,d+l.length))),o==null||o(p)},replaceHtml:l=>{const{schema:a,selection:c,tr:d}=n.state,p=document.createElement("div");p.innerHTML=l;const u=Rt.fromSchema(a).parse(p),{from:h,to:f}=c;return o==null?void 0:o(d.replaceRangeWith(h,f,u).scrollIntoView())},wrapStyle:()=>{const l=lr(n),a=r.text.selected(),c=`i${e.Components._createId().slice(0,4)}`;r.text.replaceHtml(`<span id="${c}" ${Dd}>${a}</span>`),l==null||l.trigger("disable"),setTimeout(()=>{const d=l==null?void 0:l.find(`#${c}`)[0];d&&e.select(d)})},createBreak:()=>{const{state:l}=n,a=l.tr.replaceSelectionWith(s.inlineBreak.create()).scrollIntoView();return o==null?void 0:o(a)}},bold:{toggle:()=>Lt(i.strong)(n.state,o),isActive:()=>io(n.state,i.strong)},italic:{toggle:()=>Lt(i.em)(n.state,o),isActive:()=>io(n.state,i.em)},underline:{toggle:()=>Lt(i.underline)(n.state,o),isActive:()=>io(n.state,i.underline)},strikethrough:{toggle:()=>Lt(i.strikethrough)(n.state,o),isActive:()=>io(n.state,i.strikethrough)},link:{get:()=>{const l=lr(n),a=l==null?void 0:l.getTrait("href");if(l!=null&&l.is("link"))return l.getAttributes();if(a)return{href:a.getValue()};{const c=Wd(n,"link");return c?qe(c):{}}},toggle:()=>Lt(i.link)(n.state,o),isActive:()=>io(n.state,i.link),create:l=>{const a=lr(n),c=a==null?void 0:a.getTrait("href"),{url:d,target:p}=l,u=()=>{var f,m;const h=(m=(f=$d(n))==null?void 0:f.gjsView)==null?void 0:m.el;h&&h.contentEditable!=="true"&&(h.contentEditable="true"),n.focus()};a!=null&&a.is("link")?(a.addAttributes({href:d,target:p}),u()):c?(a==null||a.addAttributes({[c.getName()]:d}),u()):v0({view:n,href:d,target:p,options:t})}},alignText:{get:()=>P0({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:l=>b0(n,l.value,!0)},fontSize:{get:()=>cr({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:l=>S0(n,l.value)},color:{get:()=>cr({view:n,editor:e,markName:"color",prop:"value",propCSS:"color"}),set:l=>x0(n,l.value)},bgColor:{get:()=>cr({view:n,editor:e,markName:"bgColor",prop:"value",propCSS:"background-color"}),set:l=>w0(n,l.value)},image:{open(){const l="assetLayout",{state:a,dispatch:c}=n,{selection:d,doc:p}=a,u=p.textBetween(d.from,d.to," "),h={id:l,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:f=>{const m={alt:u,src:f.asset.getSrc()};c(a.tr.replaceSelectionWith(s.image.createAndFill({attrs:m})))}}};e.runCommand(G.layoutToggle,h)}},heading:{get:()=>{var a;const l=(a=Wt(n,ar))==null?void 0:a.node;return`${(l==null?void 0:l.attrs.level)||""}`},set:({value:l})=>{var d;const{state:a}=n,c=(d=Wt(n,ar))==null?void 0:d.node;Sm(a.schema.nodes.heading,{attrs:c==null?void 0:c.attrs.attrs,level:l?parseInt(l,10):0})(a,o)}},listBullet:{isActive:()=>{var l;return!!((l=Wt(n,Fd))!=null&&l.node)},toggle:()=>Gd(n,s.bulletList)},listOrdered:{isActive:()=>{var l;return!!((l=Wt(n,_d))!=null&&l.node)},toggle:()=>Gd(n,s.orderedList)}};return r};class vt{constructor(e,t,o={}){this.match=e,this.match=e,this.handler=typeof t=="string"?N0(t):t,this.undoable=o.undoable!==!1,this.inCode=o.inCode||!1}}function N0(n){return function(e,t,o,s){let i=n;if(t[1]){let r=t[0].lastIndexOf(t[1]);i+=t[0].slice(r+t[1].length),o+=r;let l=o-s;l>0&&(i=t[0].slice(r-l,r)+i,o=s)}return e.tr.insertText(i,o,s)}}const O0=500;function I0({rules:n}){let e=new gn({state:{init(){return null},apply(t,o){let s=t.getMeta(this);return s||(t.selectionSet||t.docChanged?null:o)}},props:{handleTextInput(t,o,s,i){return jd(t,o,s,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:o}=t.state.selection;o&&jd(t,o.pos,o.pos,"",n,e)})}}},isInputRules:!0});return e}function jd(n,e,t,o,s,i){if(n.composing)return!1;let r=n.state,l=r.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-O0),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 p=d.match.exec(a),u=p&&d.handler(r,p,e-(p[0].length-o.length),t);if(u)return d.undoable&&u.setMeta(i,{transform:u,from:e,to:t,text:o}),n.dispatch(u),!0}return!1}const R0=new vt(/--$/,"—"),D0=new vt(/\.\.\.$/,"…"),L0=new vt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),$0=new vt(/"$/,"”"),z0=new vt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),B0=new vt(/'$/,"’"),V0=[L0,$0,z0,B0];function pr(n,e,t=null,o){return new vt(n,(s,i,r,l)=>{let a=t instanceof Function?t(i):t,c=s.tr.delete(r,l),d=c.doc.resolve(r),p=d.blockRange(),u=p&&wa(p,e,a);if(!u)return null;c.wrap(p,u);let h=c.doc.resolve(r-1).nodeBefore;return h&&h.type==e&&Ko(c.doc,r-1)&&(!o||o(i,h))&&c.join(r-1),c})}function qd(n,e,t=null){return new vt(n,(o,s,i,r)=>{let l=o.doc.resolve(i),a=t instanceof Function?t(s):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?o.tr.delete(i,r).setBlockType(i,i,e,a):null})}function H0(n){return pr(/^\s*>\s$/,n)}function F0(n){return pr(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function _0(n){return pr(/^\s*([-+*])\s$/,n)}function G0(n){return qd(/^```$/,n)}function W0(n,e){return qd(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function j0(n){const e=V0.concat(D0,R0);let t;return(t=n.nodes.blockquote)&&e.push(H0(t)),(t=n.nodes.orderedList)&&e.push(F0(t)),(t=n.nodes.bulletList)&&e.push(_0(t)),(t=n.nodes.codeBlock)&&e.push(G0(t)),(t=n.nodes.heading)&&e.push(W0(t,6)),I0({rules:e})}const q0="rteProseMirror",U0=F.free,pe="rte:selectionchange",X={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>',color:'<svg viewBox="0 0 24 24"><path d="M9.62,12L12,5.67L14.37,12M11,3L5.5,17H7.75L8.87,14H15.12L16.25,17H18.5L13,3H11Z" /></svg>',bgColor:'<svg viewBox="0 0 24 24"><path d="M19,11.5C19,11.5 17,13.67 17,15A2,2 0 0,0 19,17A2,2 0 0,0 21,15C21,13.67 19,11.5 19,11.5M5.21,10L10,5.21L14.79,10M16.56,8.94L7.62,0L6.21,1.41L8.59,3.79L3.44,8.94C2.85,9.5 2.85,10.47 3.44,11.06L8.94,16.56C9.23,16.85 9.62,17 10,17C10.38,17 10.77,16.85 11.06,16.56L16.56,11.06C17.15,10.47 17.15,9.5 16.56,8.94Z" /></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>'},Ud=n=>({state:e})=>({type:"column",style:{alignItems:"center",background:"none"},children:[{type:"icon",icon:n,size:16},{type:"row",style:{width:16,height:2,backgroundColor:e.value||"currentColor",borderRadius:1}}]}),K0=(n,e)=>{var a;const{editor:t,el:o}=n,s=so.get(o).view,i=dr(s,t,e),r={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},wrapStyle:{id:"wrapper",type:"button",icon:"tag",tooltip:"Wrap for styling",editorEvents:{[pe]:({setState:c})=>{c({disabled:s.state.selection.empty})}},onClick:()=>i.text.wrapStyle()},bold:{id:"bold",icon:X.bold,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.bold.isActive()})}},onClick:({setState:c})=>{i.bold.toggle(),c({active:i.bold.isActive()})}},italic:{id:"italic",icon:X.italic,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.italic.isActive()})}},onClick:({setState:c})=>{i.italic.toggle(),c({active:i.italic.isActive()})}},underline:{id:"underline",icon:X.underline,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.underline.isActive()})}},onClick:({setState:c})=>{i.underline.toggle(),c({active:i.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:X.strikethrough,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.strikethrough.isActive()})}},onClick:({setState:c})=>{i.strikethrough.toggle(),c({active:i.strikethrough.isActive()})}},image:{id:"image",icon:X.image,size:"s",type:"button",onClick:()=>i.image.open()},link:{id:"link",icon:X.link,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.link.isActive(),disabled:s.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,p="linkLayout",u=()=>t.runCommand(G.layoutRemove,{id:p}),h=i.link.get(),f={id:p,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,target:d},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:m=>{m.preventDefault();const g=new FormData(m.currentTarget);i.link.create({url:g.get("url"),target:g.get("target")}),u()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(h==null?void 0:h.href)||"",onChange:({value:m,setState:g})=>g({value:m})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(h==null?void 0:h.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:m,setState:g})=>g({value:m})},{type:"row",style:{gap:10,justifyContent:"end"},children:[i.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{i.link.toggle(),u()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(G.layoutToggle,f)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:X.alignTextLeft},{id:"center",icon:X.alignTextCenter},{id:"right",icon:X.alignTextRight},{id:"justify",icon:X.alignTextJustify}],editorEvents:{[pe]:({setState:c})=>{c({value:i.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.alignText.set({value:c})}},alignTextMenu:{id:"alignTextMenu",type:"buttonMenu",size:"s",value:"",options:[{id:"left",icon:X.alignTextLeft},{id:"center",icon:X.alignTextCenter},{id:"right",icon:X.alignTextRight},{id:"justify",icon:X.alignTextJustify}],editorEvents:{[pe]:({setState:c})=>{c({value:i.alignText.get()})}},onOptionSelect:({option:c,state:d,setState:p})=>{const u=c.id===d.value?"":c.id;p({value:u}),i.alignText.set({value:u})},onClick:({state:c})=>{c.value&&i.alignText.set({value:c.value})}},listBullet:{id:"listBullet",icon:X.listBullet,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.listBullet.isActive()})}},onClick:({setState:c})=>{i.listBullet.toggle(),c({active:i.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:X.listOrdered,size:"s",type:"button",editorEvents:{[pe]:({setState:c})=>{c({active:i.listOrdered.isActive()})}},onClick:({setState:c})=>{i.listOrdered.toggle(),c({active:i.listOrdered.isActive()})}},heading:{id:"heading",type:"selectField",size:"s",value:"",emptyState:"Heading",options:[{id:"",label:"Normal"},{id:"1",label:"Heading 1"},{id:"2",label:"Heading 2"},{id:"3",label:"Heading 3"},{id:"4",label:"Heading 4"},{id:"5",label:"Heading 5"},{id:"6",label:"Heading 6"}],editorEvents:{[pe]:({setState:c})=>{c({value:i.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.heading.set({value:c}),s.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"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:i.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.fontSize.set({value:c}),s.focus()}},color:{id:"color",type:"buttonMenu",size:"s",value:"",label:Ud(X.color),editorEvents:{[pe]:({setState:c})=>{c({disabled:s.state.selection.empty})}},children:({state:c,setState:d})=>({type:"colorPicker",value:c.value||"",onChange:p=>{const{value:u}=p;d({value:u}),p.setState({value:u}),i.color.set({value:u}),s.focus()}}),onClick:({state:c})=>{c.value&&(i.color.set({value:c.value}),s.focus())}},bgColor:{id:"bgColor",type:"buttonMenu",size:"s",value:"",label:Ud(X.bgColor),editorEvents:{[pe]:({setState:c})=>{c({disabled:s.state.selection.empty})}},children:({state:c,setState:d})=>({type:"colorPicker",value:c.value||"",onChange:p=>{const{value:u}=p;d({value:u}),p.setState({value:u}),i.bgColor.set({value:u}),s.focus()}}),onClick:({state:c})=>{c.value&&(i.bgColor.set({value:c.value}),s.focus())}}},l=[r.bold,r.italic,r.underline,r.strikethrough,r.image,r.link,r.listBullet,r.listOrdered,r.color,r.bgColor,r.alignTextMenu,r.heading,r.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:i,layouts:r,proseMirror:{view:s},items:l}))||l};class J0{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;dr(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 Z0=W(function(n,e={}){const t={plugins:l=>l.plugins,...e},o=(l,a)=>{var g,b;const c=((g=t.schema)==null?void 0:g.call(t,{editor:n,schema:Ld,createCustomMark:ir}))||Ld,{nodes:d,marks:p}=c,u={...a,component:a.view.model,editor:n,el:l};Bd(l);const h=Rt.fromSchema(c).parse(l),f=mn.create({doc:h,schema:c,plugins:(b=t.plugins)==null?void 0:b.call(t,{editor:n,Plugin:gn,plugins:[J1(),i0(),j0(c),Om(),Ei({Tab:Cd(1),"Shift-Tab":Cd(-1)}),Ei({Enter:Gn(Wa,Vm(d.listItem),g0(u,t)),"Shift-Enter":Gn(Ga,(w,y)=>(y&&y(w.tr.replaceSelectionWith(d.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":tc,"Mod-y":wi,"Mod-Shift-z":wi,"Mod-b":Lt(p.strong),"Mod-i":Lt(p.em),"Shift-Tab":Ti(d.listItem),Tab:_m(d.listItem)}),Ei(wm)]})}),m=new S1({mount:l},{state:f,dispatchTransaction(w){var x;const{state:y}=m,v=y.apply(w),C=!y.doc.eq(v.doc);m.updateState(v);const S=!y.selection.eq(v.selection);C&&(h0(((x=a==null?void 0:a.view)==null?void 0:x.el)||l),m.focus()),(S||C)&&n.trigger(pe)}});return l.__rteView=m,m.setProps({nodeViews:{image(w){return new J0(w,m,n)}}}),m},s=l=>K0(l,t);n.setCustomRte({toolbar:s,parseContent:!0,async enable(l,a,c){const d=ys(l);if(d)return d;const p=o(l,c);return p0(l,p,c.view),E0(p,c),p},disable(l){const a=ys(l),c=a==null?void 0:a.view;if(c){const d=zd(l);return u0(l,c),d||n.once(n.RichTextEditor.events.disable,()=>{a.gjsView.model.trigger("rerender")}),c.destroy(),{forceSync:d}}},getContent(l,a,c){var p;const d=(p=ys(l))==null?void 0:p.view;if(d){const{schema:u,doc:h}=d.state;if(!zd(l))return c.view.lastContent;const f=document.createElement("div"),m=Dt.fromSchema(u).serializeFragment(h.content);return m.childNodes.forEach(g=>{var b;g.nodeType===Node.ELEMENT_NODE&&(g.innerHTML===""?g.innerHTML="<br/>":((b=g.lastChild)==null?void 0:b.nodeName)==="BR"&&g.appendChild(document.createElement("br")))}),f.appendChild(m),f0(f),l.classList.remove("ProseMirror-focused"),f.innerHTML}return l.innerHTML}});const i=Hl(n,t.enableOnClick),r=tf(n,t.disableOnEsc);j({editor:n,licenseKey:t.licenseKey,plan:U0,pluginName:q0,cleanup:()=>{n.RichTextEditor.customRte=void 0,i(),r()}})}),Y0="canvasEmptyState",X0=F.startup,Q0=W(function(n,e={}){const t=new WeakMap,o=new WeakMap,s=new WeakMap,i=new Set,r=new WeakMap,l={emptyStates:[],...e},a=(y,v)=>{let C=!1;const{isValid:S}=v;return Array.isArray(S)?C=S.some(x=>y.is(x)):xt(S)?C=S({component:y,editor:n}):C=y.is(S),C},c=y=>{const v=t.get(y);t.delete(y),v==null||v()},d=y=>{y.views.forEach(v=>c(v)),s.delete(y)},p=y=>{if(!(!y||i.has(y)))try{i.add(y);const v=y.components().length>0,C=s.get(y);if(v&&C)d(y);else if(!v&&!C){const S=r.has(y)?r.get(y):l.emptyStates.find(x=>a(y,x));if(r.set(y,S),!S)return;y.views.forEach(x=>{const E=S.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,()=>{E==null||E();const k=o.get(x);k==null||k.remove()})})}}finally{i.delete(y)}},u=y=>{s.has(y)&&d(y)},h=({model:y})=>{p(y.getComponent())},f=n.Components.events,m=`${f.update}:components`,g="component:mount",b=n.Canvas.events.frameLoadBody,w=f.removed;n.on(m,p),n.on(g,p),n.on(w,u),n.on(b,h),j({editor:n,licenseKey:l.licenseKey,plan:X0,pluginName:Y0,cleanup:()=>{n.off(m,p),n.off(g,p),n.off(w,u),n.off(b,h)}})}),Kd="canvasFullSize",ey=F.startup,ty=(n,e)=>{const{rule:t,ruleView:o}=e,{style:s}=t.attributes;if(s&&s[n]){const i=s[n],r=/([0-9.]+)(vh|dvh|lvh|svh)/g,l=r.test(i),a=o.frameView.model;if(l&&a.hasAutoHeight()){const c=i.replace(r,(p,u)=>`${window.innerHeight*(parseFloat(u)/100)}px`),d=t.toCSS({style:{...s,[n]:c}});e.css=d}}},ny=n=>{["height","min-height","max-height"].forEach(e=>ty(e,n))},oy=W(function(n,e={}){const{Canvas:t,Commands:o,Devices:s,Css:i}=n,r={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:l,canvasOffsetX:a,canvasTransition:c,deviceMaxWidth:d,deviceMinHeigth:p,deviceFixedHeight:u,frameBorderRadius:h,frameTransition:f}=r,m=`${p}px`,g=t.events,b="core:preview",w=`${o.events.stopCommand}${b}`,y=t.getConfig(),v=`${Kd}:disable`,C=s.getAll().map(B=>({...B.attributes})),S=c*1e3,x={x:a,y:l};let E={},k,M;y.scrollableCanvas=!u,s.getAll().map(B=>{!B.get("width")&&B.set("width",`${d}px`),!B.get("height")&&B.set("height",u?"100vh":"auto"),!B.get("minHeight")&&B.set("minHeight",m)});const P=B=>{const be=`${go}canvas-full-size`,ve=document.querySelector(`style[${be}]`);if(B&&ve)return ve.remove();const Ke=ve||document.createElement("style"),Cs=t.getZoomMultiplier();Ke.setAttribute(be,"true"),Ke.innerHTML=`
917
- .gjs-frame-wrapper { transition: width ${f}s !important; }
918
- .gjs-frame-wrapper__bottom { height: ${l*Cs}px }
919
- .gjs-frame { border-radius: ${h}px }
920
- `,!ve&&document.body.appendChild(Ke)};n.on(g.frameLoadHead,B=>{if(!y.scrollableCanvas)return;const{window:be}=B,ve=be.document,Ke=ve.head,Cs=`${go}canvas-full-size-wrappers`,ks=Ke.querySelector(`style[${Cs}]`)||ve.createElement("style");ks.setAttribute(Cs,"true"),ks.innerHTML=`
907
+ }`,rr=new WeakMap,Lh=(n,e)=>{rr.set(n,e)},Bh=n=>{rr.delete(n)},sr=n=>rr.get(n),Lo=n=>{const e=n.target,t=e.closest(".tox"),o=e.matches(".ephox-snooker-resizer-bar");(t||o)&&n.stopPropagation()},da=n=>{n.stopPropagation(),n.preventDefault()},Vh=(n,e)=>{const t=n.getDoc(),o=n.getWin();if(e!=null&&e.event){const{event:i}=e,{clientX:r,clientY:s}=i;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(r,s);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(r,s);l=t.createRange(),l==null||l.setStart(a.offsetNode,a.offset)}if(l){const a=o.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(l),n.selection.setRng(l)}}else n.execCommand("SelectAll")},Hh=n=>{var c,d;const{el:e,editor:t,componentView:o}=n,i=t.runCommand(W.getStateTheme),r=o.model,s={target:e,inline:!0,skin:(i==null?void 0:i.theme)===Fs.dark?"oxide-dark":"oxide",menubar:!1,image_advtab:!0,paste_data_images:!0,statusbar:!1,branding:!1,forced_root_block:"div",plugins:"advlist autolink lists link image media table",toolbar_mode:"sliding",toolbar:"bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"},l=((d=(c=n.pluginOpts)==null?void 0:c.loadConfig)==null?void 0:d.call(c,{config:s,editor:t,componentView:o,component:r}))||{};return{...s,...l}},pa=(n,e=document)=>new Promise((t,o)=>{const i=Array.isArray(n)?[...n]:[n],{head:r}=e,s=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=s.bind(null,l),a.onerror=o,r.appendChild(a)}else t()};s(i)}),Fh=q(function(n,e={}){const t={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...e},{cdnScript:o}=t,i=n.Canvas.events,r=!t.skipCustomTheme,s="gs-plg-tinymce-studio-theme",l=async(d,p)=>{const u=d.ownerDocument,f=u.defaultView,h=p==null?void 0:p.view;if(!f||!h){console.warn("Missing required data",{win:f,componentView:h});return}const g=Hh({el:d,editor:n,componentView:h,pluginOpts:t}),x=(await f.tinymce.init(g))[0];if(!x)return;const y=(await window.tinymce.init({...g,target:document.createElement("div")}))[0];return x.ui.show(),u.body.addEventListener("mousedown",Lo),document.body.addEventListener("mousedown",Lo),x.on("Change",()=>Ih(d)),x.on("blur",()=>x.ui.show()),x.on("OpenWindow",function(){var w;const v=(w=u.querySelector(".tox-dialog"))==null?void 0:w.closest(".tox");v&&(v==null?void 0:v.ownerDocument)!==document&&(document.body.appendChild(v),x.once("CloseWindow",()=>{v&&v.ownerDocument===document&&u.body.appendChild(v)}))}),d.addEventListener("dragstart",da,{capture:!0}),n.runCommand(W.setStateContextMenu,{enabled:!1}),Vh(x,p),{rteEditor:x,rteEditorShallow:y}},a=(d,p)=>{d.ownerDocument.body.removeEventListener("mousedown",Lo),document.body.removeEventListener("mousedown",Lo),d.removeEventListener("dragstart",da,{capture:!0}),n.runCommand(W.setStateContextMenu,{enabled:!0}),p.rteEditor.destroy(),p.rteEditorShallow.destroy()};n.on(i.frameLoad,async({window:d})=>{const p=d.document;pa(o,p)}),n.onReady(()=>{pa(o,document),r&&Ni(s,Rh,{target:document.body})}),n.setCustomRte({parseContent:!0,async enable(d,p,u){const f=sr(d);if(f)return f.rteEditor;const h=await l(d,u);return h&&Lh(d,h),h==null?void 0:h.rteEditor},disable(d){const p=sr(d);p&&(Bh(d),a(d,p))},getContent(d,p,u){var g;const f=sr(d),h=f==null?void 0:f.rteEditor;return h&&!h.isDirty()?u.view.lastContent:h?(g=h.getContent)==null?void 0:g.call(h):d.innerHTML}});const c=aa(n,t.enableOnClick);U({editor:n,licenseKey:t.licenseKey,plan:zh,pluginName:ca,cleanup:()=>{n.RichTextEditor.customRte=void 0,c()}})},ca);function te(n){this.content=n}te.prototype={constructor:te,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var o=t&&t!=n?this.remove(t):this,i=o.find(n),r=o.content.slice();return i==-1?r.push(t||n,e):(r[i+1]=e,t&&(r[i]=t)),new te(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 te(t)},addToStart:function(n,e){return new te([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new te(t)},addBefore:function(n,e,t){var o=this.remove(e),i=o.content.slice(),r=o.find(n);return i.splice(r==-1?i.length:r,0,e,t),new te(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=te.from(n),n.size?new te(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=te.from(n),n.size?new te(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=te.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},te.from=function(n){if(n instanceof te)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new te(e)};function ua(n,e,t){for(let o=0;;o++){if(o==n.childCount||o==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(o),r=e.child(o);if(i==r){t+=i.nodeSize;continue}if(!i.sameMarkup(r))return t;if(i.isText&&i.text!=r.text){for(let s=0;i.text[s]==r.text[s];s++)t++;return t}if(i.content.size||r.content.size){let s=ua(i.content,r.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function fa(n,e,t,o){for(let i=n.childCount,r=e.childCount;;){if(i==0||r==0)return i==r?null:{a:t,b:o};let s=n.child(--i),l=e.child(--r),a=s.nodeSize;if(s==l){t-=a,o-=a;continue}if(!s.sameMarkup(l))return{a:t,b:o};if(s.isText&&s.text!=l.text){let c=0,d=Math.min(s.text.length,l.text.length);for(;c<d&&s.text[s.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,o--;return{a:t,b:o}}if(s.content.size||l.content.size){let c=fa(s.content,l.content,t-1,o-1);if(c)return c}t-=a,o-=a}}class M{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,i=0,r){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&o(a,i+l,r||null,s)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),o,i+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,o,i){let r="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&o&&(s?s=!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,i=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(o)&&(i[i.length-1]=t.withText(t.text+o.text),r=1);r<e.content.length;r++)i.push(e.content[r]);return new M(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let o=[],i=0;if(t>e)for(let r=0,s=0;s<t;r++){let l=this.content[r],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),o.push(l),i+=l.nodeSize),s=a}return new M(o,i)}cutByIndex(e,t){return e==t?M.empty:e==0&&t==this.content.length?this:new M(this.content.slice(e,t))}replaceChild(e,t){let o=this.content[e];if(o==t)return this;let i=this.content.slice(),r=this.size+t.nodeSize-o.nodeSize;return i[e]=t,new M(i,r)}addToStart(e){return new M([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new M(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 i=this.content[t];e(i,o,t),o+=i.nodeSize}}findDiffStart(e,t=0){return ua(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return fa(this,e,t,o)}findIndex(e,t=-1){if(e==0)return Bo(0,e);if(e==this.size)return Bo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let o=0,i=0;;o++){let r=this.child(o),s=i+r.nodeSize;if(s>=e)return s==e||t>0?Bo(o+1,s):Bo(o,i);i=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return M.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new M(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return M.empty;let t,o=0;for(let i=0;i<e.length;i++){let r=e[i];o+=r.nodeSize,i&&r.isText&&e[i-1].sameMarkup(r)?(t||(t=e.slice(0,i)),t[t.length-1]=r.withText(t[t.length-1].text+r.text)):t&&t.push(r)}return new M(t||e,o)}static from(e){if(!e)return M.empty;if(e instanceof M)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new M([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}M.empty=new M([],0);const lr={index:0,offset:0};function Bo(n,e){return lr.index=n,lr.offset=e,lr}function Vo(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(!Vo(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!Vo(n[o],e[o]))return!1;for(let o in e)if(!(o in n))return!1}return!0}class _{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,o=!1;for(let i=0;i<e.length;i++){let r=e[i];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,i));else{if(r.type.excludes(this.type))return e;!o&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),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&&Vo(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 i=o.create(t.attrs);return o.checkAttrs(i.attrs),i}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 _.none;if(e instanceof _)return[e];let t=e.slice();return t.sort((o,i)=>o.type.rank-i.type.rank),t}}_.none=[];class Ho extends Error{}class j{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=ma(this.content,e+this.openStart,t);return o&&new j(o,this.openStart,this.openEnd)}removeBetween(e,t){return new j(ha(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 j.empty;let o=t.openStart||0,i=t.openEnd||0;if(typeof o!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new j(M.fromJSON(e,t.content),o,i)}static maxOpen(e,t=!0){let o=0,i=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)i++;return new j(e,o,i)}}j.empty=new j(M.empty,0,0);function ha(n,e,t){let{index:o,offset:i}=n.findIndex(e),r=n.maybeChild(o),{index:s,offset:l}=n.findIndex(t);if(i==e||r.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(o!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(o,r.copy(ha(r.content,e-i-1,t-i-1)))}function ma(n,e,t,o){let{index:i,offset:r}=n.findIndex(e),s=n.maybeChild(i);if(r==e||s.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=ma(s.content,e-r-1,t);return l&&n.replaceChild(i,s.copy(l))}function _h(n,e,t){if(t.openStart>n.depth)throw new Ho("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Ho("Inconsistent open depths");return ga(n,e,t,0)}function ga(n,e,t,o){let i=n.index(o),r=n.node(o);if(i==e.index(o)&&o<n.depth-t.openStart){let s=ga(n,e,t,o+1);return r.copy(r.content.replaceChild(i,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let s=n.parent,l=s.content;return Nt(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=Gh(t,n);return Nt(r,ya(n,s,l,e,o))}else return Nt(r,Fo(n,e,o))}function ba(n,e){if(!e.type.compatibleContent(n.type))throw new Ho("Cannot join "+e.type.name+" onto "+n.type.name)}function ar(n,e,t){let o=n.node(t);return ba(o,e.node(t)),o}function Pt(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 Ln(n,e,t,o){let i=(e||n).node(t),r=0,s=e?e.index(t):i.childCount;n&&(r=n.index(t),n.depth>t?r++:n.textOffset&&(Pt(n.nodeAfter,o),r++));for(let l=r;l<s;l++)Pt(i.child(l),o);e&&e.depth==t&&e.textOffset&&Pt(e.nodeBefore,o)}function Nt(n,e){return n.type.checkContent(e),n.copy(e)}function ya(n,e,t,o,i){let r=n.depth>i&&ar(n,e,i+1),s=o.depth>i&&ar(t,o,i+1),l=[];return Ln(null,n,i,l),r&&s&&e.index(i)==t.index(i)?(ba(r,s),Pt(Nt(r,ya(n,e,t,o,i+1)),l)):(r&&Pt(Nt(r,Fo(n,e,i+1)),l),Ln(e,t,i,l),s&&Pt(Nt(s,Fo(t,o,i+1)),l)),Ln(o,null,i,l),new M(l)}function Fo(n,e,t){let o=[];if(Ln(null,n,t,o),n.depth>t){let i=ar(n,e,t+1);Pt(Nt(i,Fo(n,e,t+1)),o)}return Ln(e,null,t,o),new M(o)}function Gh(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let r=t-1;r>=0;r--)i=e.node(r).copy(M.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Bn{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],i=e.child(t);return o?e.child(t).cut(o):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let o=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let r=0;r<e;r++)i+=o.child(r).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return _.none;if(this.textOffset)return e.child(t).marks;let o=e.maybeChild(t-1),i=e.maybeChild(t);if(!o){let l=o;o=i,i=l}let r=o.marks;for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let o=t.marks,i=e.parent.maybeChild(e.index());for(var r=0;r<o.length;r++)o[r].type.spec.inclusive===!1&&(!i||!o[r].isInSet(i.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 _o(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=[],i=0,r=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(r),c=r-a;if(o.push(s,l,i+a),!c||(s=s.child(l),s.isText))break;r=c-1,i+=a+1}return new Bn(t,o,r)}static resolveCached(e,t){let o=xa.get(e);if(o)for(let r=0;r<o.elts.length;r++){let s=o.elts[r];if(s.pos==t)return s}else xa.set(e,o=new Wh);let i=o.elts[o.i]=Bn.resolve(e,t);return o.i=(o.i+1)%qh,i}}class Wh{constructor(){this.elts=[],this.i=0}}const qh=12,xa=new WeakMap;class _o{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 Uh=Object.create(null);let Ot=class Ds{constructor(e,t,o,i=_.none){this.type=e,this.attrs=t,this.marks=i,this.content=o||M.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,o,i=0){this.content.nodesBetween(e,t,o,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,o,i){return this.content.textBetween(e,t,o,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,o){return this.type==e&&Vo(this.attrs,t||e.defaultAttrs||Uh)&&_.sameSet(this.marks,o||_.none)}copy(e=null){return e==this.content?this:new Ds(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Ds(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 j.empty;let i=this.resolve(e),r=this.resolve(t),s=o?0:i.sharedDepth(t),l=i.start(s),c=i.node(s).content.cut(i.pos-l,r.pos-l);return new j(c,i.depth-s,r.depth-s)}replace(e,t,o){return _h(this.resolve(e),this.resolve(t),o)}nodeAt(e){for(let t=this;;){let{index:o,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(o),!t)return null;if(i==e||t.isText)return t;e-=i+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 i=this.content.child(t-1);return{node:i,index:t-1,offset:o-i.nodeSize}}resolve(e){return Bn.resolveCached(this,e)}resolveNoCache(e){return Bn.resolve(this,e)}rangeHasMark(e,t,o){let i=!1;return t>e&&this.nodesBetween(e,t,r=>(o.isInSet(r.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),va(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=M.empty,i=0,r=o.childCount){let s=this.contentMatchAt(e).matchFragment(o,i,r),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<r;a++)if(!this.type.allowsMarks(o.child(a).marks))return!1;return!0}canReplaceWith(e,t,o,i){if(i&&!this.type.allowsMarks(i))return!1;let r=this.contentMatchAt(e).matchType(o),s=r&&r.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=_.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(!_.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 i=M.fromJSON(e,t.content),r=e.nodeType(t.type).create(t.attrs,i,o);return r.type.checkAttrs(r.attrs),r}};Ot.prototype.text=void 0;class Go extends Ot{constructor(e,t,o,i){if(super(e,t,null,i),!o)throw new RangeError("Empty text nodes are not allowed");this.text=o}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):va(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 Go(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Go(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 va(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class It{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new Kh(e,t);if(o.next==null)return It.empty;let i=wa(o);o.next&&o.err("Unexpected trailing text");let r=tm(em(i));return nm(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 i=this;for(let r=t;i&&r<o;r++)i=i.matchType(e.child(r).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let 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 i=[this];function r(s,l){let a=s.matchFragment(e,o);if(a&&(!t||a.validEnd))return M.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:d,next:p}=s.next[c];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(p)==-1){i.push(p);let u=r(p,l.concat(d));if(u)return u}}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 i=o.shift(),r=i.match;if(r.matchType(e)){let s=[];for(let l=i;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<r.next.length;s++){let{type:l,next:a}=r.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(o.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(o){e.push(o);for(let i=0;i<o.next.length;i++)e.indexOf(o.next[i].next)==-1&&t(o.next[i].next)}return t(this),e.map((o,i)=>{let r=i+(o.validEnd?"*":" ")+" ";for(let s=0;s<o.next.length;s++)r+=(s?", ":"")+o.next[s].type.name+"->"+e.indexOf(o.next[s].next);return r}).join(`
908
+ `)}}It.empty=new It(!0);class Kh{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 wa(n){let e=[];do e.push(Jh(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Jh(n){let e=[];do e.push(Yh(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Yh(n){let e=Qh(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=Zh(n,e);else break;return e}function Sa(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Zh(n,e){let t=Sa(n),o=t;return n.eat(",")&&(n.next!="}"?o=Sa(n):o=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:o,expr:e}}function Xh(n,e){let t=n.nodeTypes,o=t[e];if(o)return[o];let i=[];for(let r in t){let s=t[r];s.isInGroup(e)&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function Qh(n){if(n.eat("(")){let e=wa(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=Xh(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 em(n){let e=[[]];return i(r(n,0),t()),e;function t(){return e.push([])-1}function o(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function i(s,l){s.forEach(a=>a.to=l)}function r(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(r(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=r(s.exprs[a],l);if(a==s.exprs.length-1)return c;i(c,l=t())}else if(s.type=="star"){let a=t();return o(l,a),i(r(s.expr,a),a),[o(a)]}else if(s.type=="plus"){let a=t();return i(r(s.expr,l),a),i(r(s.expr,a),a),[o(a)]}else{if(s.type=="opt")return[o(l)].concat(r(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let d=t();i(r(s.expr,a),d),a=d}if(s.max==-1)i(r(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let d=t();o(a,d),i(r(s.expr,a),d),a=d}return[o(a)]}else{if(s.type=="name")return[o(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Ca(n,e){return e-n}function ka(n,e){let t=[];return o(e),t.sort(Ca);function o(i){let r=n[i];if(r.length==1&&!r[0].term)return o(r[0].to);t.push(i);for(let s=0;s<r.length;s++){let{term:l,to:a}=r[s];!l&&t.indexOf(a)==-1&&o(a)}}}function tm(n){let e=Object.create(null);return t(ka(n,0));function t(o){let i=[];o.forEach(s=>{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<i.length;d++)i[d][0]==l&&(c=i[d][1]);ka(n,a).forEach(d=>{c||i.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let r=e[o.join(",")]=new It(o.indexOf(n.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(Ca);r.next.push({type:i[s][0],next:e[l.join(",")]||t(l)})}return r}}function nm(n,e){for(let t=0,o=[n];t<o.length;t++){let i=o[t],r=!i.validEnd,s=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];s.push(a.name),r&&!(a.isText||a.hasRequiredAttrs())&&(r=!1),o.indexOf(c)==-1&&o.push(c)}r&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ta(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 Ea(n,e){let t=Object.create(null);for(let o in n){let i=e&&e[o];if(i===void 0){let r=n[o];if(r.hasDefault)i=r.default;else throw new RangeError("No value supplied for attribute "+o)}t[o]=i}return t}function Ma(n,e,t,o){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let r=n[i];r.validate&&r.validate(e[i])}}function Aa(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new im(n,o,e[o]);return t}let ja=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=Aa(e,o.attrs),this.defaultAttrs=Ta(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==It.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:Ea(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ot(this,this.computeAttrs(e),M.from(t),_.setFrom(o))}createChecked(e=null,t,o){return t=M.from(t),this.checkContent(t),new Ot(this,this.computeAttrs(e),t,_.setFrom(o))}createAndFill(e=null,t,o){if(e=this.computeAttrs(e),t=M.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let i=this.contentMatch.matchFragment(t),r=i&&i.fillBefore(M.empty,!0);return r?new Ot(this,e,t.append(r),_.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){Ma(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:_.none:e}static compile(e,t){let o=Object.create(null);e.forEach((r,s)=>o[r]=new fu(r,t,s));let i=t.spec.topNode||"doc";if(!o[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");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 om(n,e,t){let o=t.split("|");return i=>{let r=i===null?"null":typeof i;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${n}, got ${r}`)}}class im{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?om(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class Wo{constructor(e,t,o,i){this.name=e,this.rank=t,this.schema=o,this.spec=i,this.attrs=Aa(e,i.attrs),this.excluded=null;let r=Ta(this.attrs);this.instance=r?new _(this,r):null}create(e=null){return!e&&this.instance?this.instance:new _(this,Ea(this.attrs,e))}static compile(e,t){let o=Object.create(null),i=0;return e.forEach((r,s)=>o[r]=new Wo(r,i++,t,s)),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){Ma(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class rm{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=te.from(e.nodes),t.marks=te.from(e.marks||{}),this.nodes=ja.compile(this.spec.nodes,this),this.marks=Wo.compile(this.spec.marks,this);let o=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let r=this.nodes[i],s=r.spec.content||"",l=r.spec.marks;if(r.contentMatch=o[s]||(o[s]=It.parse(s,this.nodes)),r.inlineContent=r.contentMatch.inlineContent,r.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!r.isInline||!r.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=r}r.markSet=l=="_"?null:l?$a(this,l.split(" ")):l==""||!r.inlineContent?[]:null}for(let i in this.marks){let r=this.marks[i],s=r.spec.excludes;r.excluded=s==null?[r]:s==""?[]:$a(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,o,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ja){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,i)}text(e,t){let o=this.nodes.text;return new Go(o,o.defaultAttrs,e,_.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Ot.fromJSON(this,e)}markFromJSON(e){return _.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function $a(n,e){let t=[];for(let o=0;o<e.length;o++){let i=e[o],r=n.marks[i],s=r;if(r)t.push(r);else for(let l in n.marks){let a=n.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function sm(n){return n.tag!=null}function lm(n){return n.style!=null}class Dt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(i=>{if(sm(i))this.tags.push(i);else if(lm(i)){let r=/[^=]*/.exec(i.style)[0];o.indexOf(r)<0&&o.push(r),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let r=e.nodes[i.node];return r.contentMatch.matchType(r)})}parse(e,t={}){let o=new Ia(this,t,!1);return o.addAll(e,_.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new Ia(this,t,!0);return o.addAll(e,_.none,t.from,t.to),j.maxOpen(o.finish())}matchTag(e,t,o){for(let i=o?this.tags.indexOf(o)+1:0;i<this.tags.length;i++){let r=this.tags[i];if(dm(e,r.tag)&&(r.namespace===void 0||e.namespaceURI==r.namespace)&&(!r.context||t.matchesContext(r.context))){if(r.getAttrs){let s=r.getAttrs(e);if(s===!1)continue;r.attrs=s||void 0}return r}}}matchStyle(e,t,o,i){for(let r=i?this.styles.indexOf(i)+1:0;r<this.styles.length;r++){let s=this.styles[r],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!o.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function o(i){let r=i.priority==null?50:i.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<r)break}t.splice(s,0,i)}for(let i in e.marks){let r=e.marks[i].spec.parseDOM;r&&r.forEach(s=>{o(s=Da(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let r=e.nodes[i].spec.parseDOM;r&&r.forEach(s=>{o(s=Da(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Dt(e,Dt.schemaRules(e)))}}const Pa={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},am={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Na={ol:!0,ul:!0},qo=1,Uo=2,Vn=4;function Oa(n,e,t){return e!=null?(e?qo:0)|(e==="full"?Uo:0):n&&n.whitespace=="pre"?qo|Uo:t&~Vn}class Ko{constructor(e,t,o,i,r,s){this.type=e,this.attrs=t,this.marks=o,this.solid=i,this.options=s,this.content=[],this.activeMarks=_.none,this.match=r||(s&Vn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(M.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let o=this.type.contentMatch,i;return(i=o.findWrapping(e.type))?(this.match=o,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&qo)){let o=this.content[this.content.length-1],i;if(o&&o.isText&&(i=/[ \t\r\n\u000c]+$/.exec(o.text))){let r=o;o.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-i[0].length))}}let t=M.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(M.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Pa.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ia{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0;let i=t.topNode,r,s=Oa(null,t.preserveWhitespace,0)|(o?Vn:0);i?r=new Ko(i.type,i.attrs,_.none,!0,t.topMatch||i.type.contentMatch,s):o?r=new Ko(null,null,_.none,!0,null,s):r=new Ko(e.schema.topNodeType,null,_.none,!0,null,s),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let o=e.nodeValue,i=this.top;if(i.options&Uo||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(i.options&qo)i.options&Uo?o=o.replace(/\r\n?/g,`
909
+ `):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=i.content[i.content.length-1],s=e.previousSibling;(!r||s&&s.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 i=e.nodeName.toLowerCase(),r;Na.hasOwnProperty(i)&&this.parser.normalizeLists&&cm(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(r=this.parser.matchTag(e,this,o));if(s?s.ignore:am.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let l,a=this.top,c=this.needsBlock;if(Pa.hasOwnProperty(i))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),l=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);return}let d=s&&s.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),l&&this.sync(a),this.needsBlock=c}else{let l=this.readStyles(e,t);l&&this.addElementByRule(e,s,l,s.consuming===!1?r:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
910
+ `),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 i=0;i<this.parser.matchedStyles.length;i++){let r=this.parser.matchedStyles[i],s=o.getPropertyValue(r);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(r,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,o,i){let r,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),o)||this.leafFallback(e,o);else{let a=this.enter(s,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(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,o,i);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,i){let r=o||0;for(let s=o?e.childNodes[o]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(s,t);this.findAtPoint(e,r)}findPlace(e,t){let o,i;for(let r=this.open;r>=0;r--){let s=this.nodes[r],l=s.findWrapping(e);if(l&&(!o||o.length>l.length)&&(o=l,i=s,!l.length)||s.solid)break}if(!o)return null;this.sync(i);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 i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let o=this.findPlace(e,t);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let r=_.none;for(let s of o.concat(e.marks))(i.type?i.type.allowsMarkType(s.type):za(s.type,e.type))&&(r=s.addToSet(r));return i.content.push(e.mark(r)),!0}return!1}enter(e,t,o,i){let r=this.findPlace(e.create(t),o);return r&&(r=this.enterInner(e,t,o,!0,i)),r}enterInner(e,t,o,i=!1,r){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=Oa(e,r,s.options);s.options&Vn&&s.content.length==0&&(l|=Vn);let a=_.none;return o=o.filter(c=>(s.type?s.type.allowsMarkType(c.type):za(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Ko(e,t,a,i,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 i=o.length-1;i>=0;i--)e+=o[i].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 i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(o?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),o=this.options.context,i=!this.isOpen&&(!o||o.parent.type==this.nodes[0].type),r=-(o?o.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=r;a--)if(s(l-1,a))return!0;return!1}else{let d=a>0||a==0&&i?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 s(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 cm(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&Na.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function dm(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Da(n){let e={};for(let t in n)e[t]=n[t];return e}function za(n,e){let t=e.schema.nodes;for(let o in t){let i=t[o];if(!i.allowsMarkType(n))continue;let r=[],s=l=>{r.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||r.indexOf(d)<0&&s(d))return!0}};if(s(i.contentMatch))return!0}}class zt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=cr(t).createDocumentFragment());let i=o,r=[];return e.forEach(s=>{if(r.length||s.marks.length){let l=0,a=0;for(;l<r.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(r[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<r.length;)i=r.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],d=this.serializeMark(c,s.isInline,t);d&&(r.push([c,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(s,t))}),o}serializeNodeInner(e,t){let{dom:o,contentDOM:i}=Jo(cr(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return o}serializeNode(e,t={}){let o=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let r=this.serializeMark(e.marks[i],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(o),o=r.dom)}return o}serializeMark(e,t,o={}){let i=this.marks[e.type.name];return i&&Jo(cr(o),i(e,t),null,e.attrs)}static renderSpec(e,t,o=null,i){return Jo(e,t,o,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new zt(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 cr(n){return n.document||window.document}const La=new WeakMap;function pm(n){let e=La.get(n);return e===void 0&&La.set(n,e=um(n)),e}function um(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 i=0;i<o.length;i++)t(o[i]);else for(let i in o)t(o[i])}return t(n),e}function Jo(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 i=e[0],r;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=pm(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 s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let p in c)if(c[p]!=null){let u=p.indexOf(" ");u>0?a.setAttributeNS(p.slice(0,u),p.slice(u+1),c[p]):a.setAttribute(p,c[p])}}for(let p=d;p<e.length;p++){let u=e[p];if(u===0){if(p<e.length-1||p>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:h}=Jo(n,u,t,o);if(a.appendChild(f),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}const Ba=65535,Va=Math.pow(2,16);function fm(n,e){return n+e*Va}function Ha(n){return n&Ba}function hm(n){return(n-(n&Ba))/Va}const Fa=1,_a=2,Yo=4,Ga=8;class dr{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&Ga)>0}get deletedBefore(){return(this.delInfo&(Fa|Yo))>0}get deletedAfter(){return(this.delInfo&(_a|Yo))>0}get deletedAcross(){return(this.delInfo&Yo)>0}}class Se{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Se.empty)return Se.empty}recover(e){let t=0,o=Ha(e);if(!this.inverted)for(let i=0;i<o;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[o*3]+t+hm(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 i=0,r=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+r],d=this.ranges[l+s],p=a+c;if(e<=p){let u=c?e==a?-1:e==p?1:t:t,f=a+i+(u<0?0:d);if(o)return f;let h=e==(t<0?a:p)?null:fm(l/3,e-a),g=e==a?_a:e==p?Fa:Yo;return(t<0?e!=a:e!=p)&&(g|=Ga),new dr(f,g,h)}i+=d-c}return o?e+i:new dr(e+i,0,null)}touches(e,t){let o=0,i=Ha(t),r=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+r],d=a+c;if(e<=d&&l==i*3)return!0;o+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,o=this.inverted?1:2;for(let i=0,r=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?r:0),a=s+(this.inverted?0:r),c=this.ranges[i+t],d=this.ranges[i+o];e(l,l+c,a,a+d),r+=d-c}}invert(){return new Se(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Se.empty:new Se(e<0?[0,-e,0]:[0,0,e])}}Se.empty=new Se([]);class un{constructor(e=[],t,o=0,i=e.length){this.maps=e,this.mirror=t,this.from=o,this.to=i}slice(e=0,t=this.maps.length){return new un(this.maps,this.mirror,e,t)}copy(){return new un(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 i=e.getMirror(t);this.appendMap(e.maps[t],i!=null&&i<t?o+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,o=this.maps.length+e.maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?o-i-1:void 0)}}invert(){let e=new un;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 i=0;for(let r=this.from;r<this.to;r++){let s=this.maps[r],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(r);if(a!=null&&a>r&&a<this.to){r=a,e=this.maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return o?e:new dr(e,i,null)}}const pr=Object.create(null);class re{getMap(){return Se.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=pr[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 pr)throw new RangeError("Duplicate use of step JSON ID "+e);return pr[e]=t,t.prototype.jsonID=e,t}}class Y{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Y(e,null)}static fail(e){return new Y(null,e)}static fromReplace(e,t,o,i){try{return Y.ok(e.replace(t,o,i))}catch(r){if(r instanceof Ho)return Y.fail(r.message);throw r}}}function ur(n,e,t){let o=[];for(let i=0;i<n.childCount;i++){let r=n.child(i);r.content.size&&(r=r.copy(ur(r.content,e,r))),r.isInline&&(r=e(r,t,i)),o.push(r)}return M.fromArray(o)}class ct extends re{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),i=o.node(o.sharedDepth(this.to)),r=new j(ur(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return Y.fromReplace(e,this.from,this.to,r)}invert(){return new Fe(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 ct(t.pos,o.pos,this.mark)}merge(e){return e instanceof ct&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ct(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 ct(t.from,t.to,e.markFromJSON(t.mark))}}re.jsonID("addMark",ct);class Fe extends re{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 j(ur(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Y.fromReplace(e,this.from,this.to,o)}invert(){return new ct(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 Fe(t.pos,o.pos,this.mark)}merge(e){return e instanceof Fe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Fe(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 Fe(t.from,t.to,e.markFromJSON(t.mark))}}re.jsonID("removeMark",Fe);class dt extends re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Y.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Y.fromReplace(e,this.pos,this.pos+1,new j(M.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 i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(o))return new dt(this.pos,t.marks[i]);return new dt(this.pos,this.mark)}}return new fn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new dt(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 dt(t.pos,e.markFromJSON(t.mark))}}re.jsonID("addNodeMark",dt);class fn extends re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Y.fail("No node at mark step's position");let o=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Y.fromReplace(e,this.pos,this.pos+1,new j(M.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new dt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new fn(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 fn(t.pos,e.markFromJSON(t.mark))}}re.jsonID("removeNodeMark",fn);class se extends re{constructor(e,t,o,i=!1){super(),this.from=e,this.to=t,this.slice=o,this.structure=i}apply(e){return this.structure&&fr(e,this.from,this.to)?Y.fail("Structure replace would overwrite content"):Y.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Se([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?j.empty:new j(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?j.empty:new j(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,j.fromJSON(e,t.slice),!!t.structure)}}re.jsonID("replace",se);class ne extends re{constructor(e,t,o,i,r,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=i,this.slice=r,this.insert=s,this.structure=l}apply(e){if(this.structure&&(fr(e,this.from,this.gapFrom)||fr(e,this.gapTo,this.to)))return Y.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Y.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,t.content);return o?Y.fromReplace(e,this.from,this.to,o):Y.fail("Content does not fit in gap")}getMap(){return new Se([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 ne(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),i=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||i<t.pos||r>o.pos?null:new ne(t.pos,o.pos,i,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 ne(t.from,t.to,t.gapFrom,t.gapTo,j.fromJSON(e,t.slice),t.insert,!!t.structure)}}re.jsonID("replaceAround",ne);function fr(n,e,t){let o=n.resolve(e),i=t-e,r=o.depth;for(;i>0&&r>0&&o.indexAfter(r)==o.node(r).childCount;)r--,i--;if(i>0){let s=o.node(r).maybeChild(o.indexAfter(r));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function mm(n,e,t,o){let i=[],r=[],s,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let p=a.marks;if(!o.isInSet(p)&&d.type.allowsMarkType(o.type)){let u=Math.max(c,e),f=Math.min(c+a.nodeSize,t),h=o.addToSet(p);for(let g=0;g<p.length;g++)p[g].isInSet(h)||(s&&s.to==u&&s.mark.eq(p[g])?s.to=f:i.push(s=new Fe(u,f,p[g])));l&&l.to==u?l.to=f:r.push(l=new ct(u,f,o))}}),i.forEach(a=>n.step(a)),r.forEach(a=>n.step(a))}function gm(n,e,t,o){let i=[],r=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;r++;let a=null;if(o instanceof Wo){let c=s.marks,d;for(;d=o.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else o?o.isInSet(s.marks)&&(a=[o]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let d=0;d<a.length;d++){let p=a[d],u;for(let f=0;f<i.length;f++){let h=i[f];h.step==r-1&&p.eq(i[f].style)&&(u=h)}u?(u.to=c,u.step=r):i.push({style:p,from:Math.max(l,e),to:c,step:r})}}}),i.forEach(s=>n.step(new Fe(s.from,s.to,s.style)))}function hr(n,e,t,o=t.contentMatch,i=!0){let r=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<r.childCount;a++){let c=r.child(a),d=l+c.nodeSize,p=o.matchType(c.type);if(!p)s.push(new se(l,d,j.empty));else{o=p;for(let u=0;u<c.marks.length;u++)t.allowsMarkType(c.marks[u].type)||n.step(new Fe(l,d,c.marks[u]));if(i&&c.isText&&t.whitespace!="pre"){let u,f=/\r?\n|\r/g,h;for(;u=f.exec(c.text);)h||(h=new j(M.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new se(l+u.index,l+u.index+u[0].length,h))}}l=d}if(!o.validEnd){let a=o.fillBefore(M.empty,!0);n.replace(l,l,new j(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function bm(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Zo(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth;;--o){let i=n.$from.node(o),r=n.$from.index(o),s=n.$to.indexAfter(o);if(o<n.depth&&i.canReplace(r,s,t))return o;if(o==0||i.type.spec.isolating||!bm(i,r,s))break}return null}function ym(n,e,t){let{$from:o,$to:i,depth:r}=e,s=o.before(r+1),l=i.after(r+1),a=s,c=l,d=M.empty,p=0;for(let h=r,g=!1;h>t;h--)g||o.index(h)>0?(g=!0,d=M.from(o.node(h).copy(d)),p++):a--;let u=M.empty,f=0;for(let h=r,g=!1;h>t;h--)g||i.after(h+1)<i.end(h)?(g=!0,u=M.from(i.node(h).copy(u)),f++):c++;n.step(new ne(a,c,s,l,new j(d.append(u),p,f),d.size-p,!0))}function Wa(n,e,t=null,o=n){let i=xm(n,e),r=i&&vm(o,e);return r?i.map(qa).concat({type:e,attrs:t}).concat(r.map(qa)):null}function qa(n){return{type:n,attrs:null}}function xm(n,e){let{parent:t,startIndex:o,endIndex:i}=n,r=t.contentMatchAt(o).findWrapping(e);if(!r)return null;let s=r.length?r[0]:e;return t.canReplaceWith(o,i,s)?r:null}function vm(n,e){let{parent:t,startIndex:o,endIndex:i}=n,r=t.child(o),s=e.contentMatch.findWrapping(r.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=o;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function wm(n,e,t){let o=M.empty;for(let s=t.length-1;s>=0;s--){if(o.size){let l=t[s].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=M.from(t[s].type.create(t[s].attrs,o))}let i=e.start,r=e.end;n.step(new ne(i,r,i,r,new j(o,0,0),t.length,!0))}function Sm(n,e,t,o,i){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let r=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(o,a)&&Cm(n.doc,n.mapping.slice(r).map(l),o)){let c=null;if(o.schema.linebreakReplacement){let f=o.whitespace=="pre",h=!!o.contentMatch.matchType(o.schema.linebreakReplacement);f&&!h?c=!1:!f&&h&&(c=!0)}c===!1&&Ka(n,s,l,r),hr(n,n.mapping.slice(r).map(l,1),o,void 0,c===null);let d=n.mapping.slice(r),p=d.map(l,1),u=d.map(l+s.nodeSize,1);return n.step(new ne(p,u,p+1,u-1,new j(M.from(o.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Ua(n,s,l,r),!1}})}function Ua(n,e,t,o){e.forEach((i,r)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=n.mapping.slice(o).map(t+1+r+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Ka(n,e,t,o){e.forEach((i,r)=>{if(i.type==i.type.schema.linebreakReplacement){let s=n.mapping.slice(o).map(t+1+r);n.replaceWith(s,s+1,e.type.schema.text(`
911
+ `))}})}function Cm(n,e,t){let o=n.resolve(e),i=o.index();return o.parent.canReplaceWith(i,i+1,t)}function km(n,e,t,o,i){let r=n.doc.nodeAt(e);if(!r)throw new RangeError("No node at given position");t||(t=r.type);let s=t.create(o,null,i||r.marks);if(r.isLeaf)return n.replaceWith(e,e+r.nodeSize,s);if(!t.validContent(r.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ne(e,e+r.nodeSize,e+1,e+r.nodeSize-1,new j(M.from(s),0,0),1,!0))}function hn(n,e,t=1,o){let i=n.resolve(e),r=i.depth-t,s=o&&o[o.length-1]||i.parent;if(r<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,d=t-2;c>r;c--,d--){let p=i.node(c),u=i.index(c);if(p.type.spec.isolating)return!1;let f=p.content.cutByIndex(u,p.childCount),h=o&&o[d+1];h&&(f=f.replaceChild(0,h.type.create(h.attrs)));let g=o&&o[d]||p;if(!p.canReplace(u+1,p.childCount)||!g.type.validContent(f))return!1}let l=i.indexAfter(r),a=o&&o[0];return i.node(r).canReplaceWith(l,l,a?a.type:i.node(r+1).type)}function Tm(n,e,t=1,o){let i=n.doc.resolve(e),r=M.empty,s=M.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){r=M.from(i.node(l).copy(r));let d=o&&o[c];s=M.from(d?d.type.create(d.attrs,s):i.node(l).copy(s))}n.step(new se(e,e,new j(r.append(s),t,t),!0))}function Xo(n,e){let t=n.resolve(e),o=t.index();return Mm(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function Em(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:o}=n.type.schema;for(let i=0;i<e.childCount;i++){let r=e.child(i),s=r.type==o?n.type.schema.nodes.text:r.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(r.marks))return!1}return t.validEnd}function Mm(n,e){return!!(n&&e&&!n.isLeaf&&Em(n,e))}function Am(n,e,t){let o=null,{linebreakReplacement:i}=n.doc.type.schema,r=n.doc.resolve(e-t),s=r.node().type;if(i&&s.inlineContent){let d=s.whitespace=="pre",p=!!s.contentMatch.matchType(i);d&&!p?o=!1:!d&&p&&(o=!0)}let l=n.steps.length;if(o===!1){let d=n.doc.resolve(e+t);Ka(n,d.node(),d.before(),l)}s.inlineContent&&hr(n,e+t-1,s,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),j.empty,!0)),o===!0){let d=n.doc.resolve(c);Ua(n,d.node(),d.before(),n.steps.length)}return n}function jm(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 i=o.depth-1;i>=0;i--){let r=o.index(i);if(o.node(i).canReplaceWith(r,r,t))return o.before(i+1);if(r>0)return null}if(o.parentOffset==o.parent.content.size)for(let i=o.depth-1;i>=0;i--){let r=o.indexAfter(i);if(o.node(i).canReplaceWith(r,r,t))return o.after(i+1);if(r<o.node(i).childCount)return null}return null}function $m(n,e,t){let o=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let r=0;r<t.openStart;r++)i=i.firstChild.content;for(let r=1;r<=(t.openStart==0&&t.size?2:1);r++)for(let s=o.depth;s>=0;s--){let l=s==o.depth?0:o.pos<=(o.start(s+1)+o.end(s+1))/2?-1:1,a=o.index(s)+(l>0?1:0),c=o.node(s),d=!1;if(r==1)d=c.canReplace(a,a,i);else{let p=c.contentMatchAt(a).findWrapping(i.firstChild.type);d=p&&c.canReplaceWith(a,a,p[0])}if(d)return l==0?o.pos:l<0?o.before(s+1):o.after(s+1)}return null}function mr(n,e,t=e,o=j.empty){if(e==t&&!o.size)return null;let i=n.resolve(e),r=n.resolve(t);return Ja(i,r,o)?new se(e,t,o):new Pm(i,r,o).fit()}function Ja(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Pm{constructor(e,t,o){this.$from=e,this.$to=t,this.unplaced=o,this.frontier=[],this.placed=M.empty;for(let i=0;i<=e.depth;i++){let r=e.node(i);this.frontier.push({type:r.type,match:r.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=M.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,o=this.$from,i=this.close(e<0?this.$to:o.doc.resolve(e));if(!i)return null;let r=this.placed,s=o.depth,l=i.depth;for(;s&&l&&r.childCount==1;)r=r.firstChild.content,s--,l--;let a=new j(r,s,l);return e>-1?new ne(o.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||o.pos!=this.$to.pos?new se(o.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,o=0,i=this.unplaced.openEnd;o<e;o++){let r=t.firstChild;if(t.childCount>1&&(i=0),r.type.spec.isolating&&i<=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 i,r=null;o?(r=gr(this.unplaced.content,o-1).firstChild,i=r.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,p=null;if(t==1&&(s?c.matchType(s.type)||(p=c.fillBefore(M.from(s),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:o,frontierDepth:l,parent:r,inject:p};if(t==2&&s&&(d=c.findWrapping(s.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,i=gr(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new j(e,t+1,Math.max(o,i.size+t>=e.size-o?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:o}=this.unplaced,i=gr(e,t);if(i.childCount<=1&&t>0){let r=e.size-t<=t+i.size;this.unplaced=new j(Hn(e,t-1,1),t-1,r?t-1:o)}else this.unplaced=new j(Hn(e,t,1),t,o)}placeNodes({sliceDepth:e,frontierDepth:t,parent:o,inject:i,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let g=0;g<r.length;g++)this.openFrontierNode(r[g]);let s=this.unplaced,l=o?o.content:s.content,a=s.openStart-e,c=0,d=[],{match:p,type:u}=this.frontier[t];if(i){for(let g=0;g<i.childCount;g++)d.push(i.child(g));p=p.matchFragment(i)}let f=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let g=l.child(c),b=p.matchType(g.type);if(!b)break;c++,(c>1||a==0||g.content.size)&&(p=b,d.push(Ya(g.mark(u.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?f:-1)))}let h=c==l.childCount;h||(f=-1),this.placed=Fn(this.placed,t,M.from(d)),this.frontier[t].match=p,h&&f<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,b=l;g<f;g++){let x=b.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),b=x.content}this.unplaced=h?e==0?j.empty:new j(Hn(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new j(Hn(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!br(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,i=this.$to.after(o);for(;o>1&&i==this.$to.end(--o);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:o,type:i}=this.frontier[t],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=br(e,t,i,o,r);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=br(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:s,move:r?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Fn(this.placed,t.depth,t.fit)),e=t.move;for(let o=t.depth+1;o<=e.depth;o++){let i=e.node(o),r=i.type.contentMatch.fillBefore(i.content,!0,e.index(o));this.openFrontierNode(i.type,i.attrs,r)}return e}openFrontierNode(e,t=null,o){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Fn(this.placed,this.depth,M.from(e.create(t,o))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(M.empty,!0);t.childCount&&(this.placed=Fn(this.placed,this.frontier.length,t))}}function Hn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Hn(n.firstChild.content,e-1,t)))}function Fn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Fn(n.lastChild.content,e-1,t)))}function gr(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Ya(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,Ya(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(M.empty,!0)))),n.copy(o)}function br(n,e,t,o,i){let r=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==r.childCount&&!t.compatibleContent(r.type))return null;let l=o.fillBefore(r.content,!0,s);return l&&!Nm(t,r.content,s)?l:null}function Nm(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function Om(n){return n.spec.defining||n.spec.definingForContent}function Im(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),r=n.doc.resolve(t);if(Ja(i,r,o))return n.step(new se(e,t,o));let s=Xa(i,n.doc.resolve(t));s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let u=i.depth,f=i.pos-1;u>0;u--,f--){let h=i.node(u).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(u)>-1?l=u:i.before(u)==f&&s.splice(1,0,-u)}let a=s.indexOf(l),c=[],d=o.openStart;for(let u=o.content,f=0;;f++){let h=u.firstChild;if(c.push(h),f==o.openStart)break;u=h.content}for(let u=d-1;u>=0;u--){let f=c[u],h=Om(f.type);if(h&&!f.sameMarkup(i.node(Math.abs(l)-1)))d=u;else if(h||!f.type.isTextblock)break}for(let u=o.openStart;u>=0;u--){let f=(u+d+1)%(o.openStart+1),h=c[f];if(h)for(let g=0;g<s.length;g++){let b=s[(g+a)%s.length],x=!0;b<0&&(x=!1,b=-b);let C=i.node(b-1),y=i.index(b-1);if(C.canReplaceWith(y,y,h.type,h.marks))return n.replace(i.before(b),x?r.after(b):t,new j(Za(o.content,0,o.openStart,f),f,o.openEnd))}}let p=n.steps.length;for(let u=s.length-1;u>=0&&(n.replace(e,t,o),!(n.steps.length>p));u--){let f=s[u];f<0||(e=i.before(f),t=r.after(f))}}function Za(n,e,t,o,i){if(e<t){let r=n.firstChild;n=n.replaceChild(0,r.copy(Za(r.content,e+1,t,o,r)))}if(e>o){let r=i.contentMatchAt(0),s=r.fillBefore(n).append(n);n=s.append(r.matchFragment(s).fillBefore(M.empty,!0))}return n}function Dm(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=jm(n.doc,e,o.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new j(M.from(o),0,0))}function zm(n,e,t){let o=n.doc.resolve(e),i=n.doc.resolve(t),r=Xa(o,i);for(let s=0;s<r.length;s++){let l=r[s],a=s==r.length-1;if(a&&l==0||o.node(l).type.contentMatch.validEnd)return n.delete(o.start(l),i.end(l));if(l>0&&(a||o.node(l-1).canReplace(o.index(l-1),i.indexAfter(l-1))))return n.delete(o.before(l),i.after(l))}for(let s=1;s<=o.depth&&s<=i.depth;s++)if(e-o.start(s)==o.depth-s&&t>o.end(s)&&i.end(s)-t!=i.depth-s&&o.start(s-1)==i.start(s-1)&&o.node(s-1).canReplace(o.index(s-1),i.index(s-1)))return n.delete(o.before(s),t);n.delete(e,t)}function Xa(n,e){let t=[],o=Math.min(n.depth,e.depth);for(let i=o;i>=0;i--){let r=n.start(i);if(r<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(r==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==r-1)&&t.push(i)}return t}class mn extends re{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 Y.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 i=t.type.create(o,null,t.marks);return Y.fromReplace(e,this.pos,this.pos+1,new j(M.from(i),0,t.isLeaf?0:1))}getMap(){return Se.empty}invert(e){return new mn(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 mn(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 mn(t.pos,t.attr,t.value)}}re.jsonID("attr",mn);class _n extends re{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let o=e.type.create(t,e.content,e.marks);return Y.ok(o)}getMap(){return Se.empty}invert(e){return new _n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new _n(t.attr,t.value)}}re.jsonID("docAttr",_n);let gn=class extends Error{};gn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},gn.prototype=Object.create(Error.prototype),gn.prototype.constructor=gn,gn.prototype.name="TransformError";class Qa{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new un}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new gn(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=j.empty){let i=mr(this.doc,e,t,o);return i&&this.step(i),this}replaceWith(e,t,o){return this.replace(e,t,new j(M.from(o),0,0))}delete(e,t){return this.replace(e,t,j.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,o){return Im(this,e,t,o),this}replaceRangeWith(e,t,o){return Dm(this,e,t,o),this}deleteRange(e,t){return zm(this,e,t),this}lift(e,t){return ym(this,e,t),this}join(e,t=1){return Am(this,e,t),this}wrap(e,t){return wm(this,e,t),this}setBlockType(e,t=e,o,i=null){return Sm(this,e,t,o,i),this}setNodeMarkup(e,t,o=null,i){return km(this,e,t,o,i),this}setNodeAttribute(e,t,o){return this.step(new mn(e,t,o)),this}setDocAttribute(e,t){return this.step(new _n(e,t)),this}addNodeMark(e,t){return this.step(new dt(e,t)),this}removeNodeMark(e,t){if(!(t instanceof _)){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 fn(e,t)),this}split(e,t=1,o){return Tm(this,e,t,o),this}addMark(e,t,o){return mm(this,e,t,o),this}removeMark(e,t,o){return gm(this,e,t,o),this}clearIncompatible(e,t,o){return hr(this,e,t,o),this}}const yr=Object.create(null);class z{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new ec(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=j.empty){let o=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=o,o=o.lastChild;let r=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],d=e.mapping.slice(r);e.replaceRange(d.map(a.pos),d.map(c.pos),l?j.empty:t),l==0&&oc(e,r,(o?o.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let o=e.steps.length,i=this.ranges;for(let r=0;r<i.length;r++){let{$from:s,$to:l}=i[r],a=e.mapping.slice(o),c=a.map(s.pos),d=a.map(l.pos);r?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),oc(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let i=e.parent.inlineContent?new R(e):bn(e.node(0),e.parent,e.pos,e.index(),t,o);if(i)return i;for(let r=e.depth-1;r>=0;r--){let s=t<0?bn(e.node(0),e.node(r),e.before(r+1),e.index(r),t,o):bn(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,o);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Ce(e.node(0))}static atStart(e){return bn(e,e,0,0,1)||new Ce(e)}static atEnd(e){return bn(e,e,e.content.size,e.childCount,-1)||new Ce(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let o=yr[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 yr)throw new RangeError("Duplicate use of selection JSON ID "+e);return yr[e]=t,t.prototype.jsonID=e,t}getBookmark(){return R.between(this.$anchor,this.$head).getBookmark()}}z.prototype.visible=!0;class ec{constructor(e,t){this.$from=e,this.$to=t}}let tc=!1;function nc(n){!tc&&!n.parent.inlineContent&&(tc=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class R extends z{constructor(e,t=e){nc(e),nc(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 z.near(o);let i=e.resolve(t.map(this.anchor));return new R(i.parent.inlineContent?i:o,o)}replace(e,t=j.empty){if(super.replace(e,t),t==j.empty){let o=this.$from.marksAcross(this.$to);o&&e.ensureMarks(o)}}eq(e){return e instanceof R&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Qo(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new R(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){let i=e.resolve(t);return new this(i,o==t?i:e.resolve(o))}static between(e,t,o){let i=e.pos-t.pos;if((!o||i)&&(o=i>=0?1:-1),!t.parent.inlineContent){let r=z.findFrom(t,o,!0)||z.findFrom(t,-o,!0);if(r)t=r.$head;else return z.near(t,o)}return e.parent.inlineContent||(i==0?e=t:(e=(z.findFrom(e,-o,!0)||z.findFrom(e,o,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new R(e,t)}}z.jsonID("text",R);class Qo{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Qo(e.map(this.anchor),e.map(this.head))}resolve(e){return R.between(e.resolve(this.anchor),e.resolve(this.head))}}class D extends z{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:i}=t.mapResult(this.anchor),r=e.resolve(i);return o?z.near(r):new D(r)}content(){return new j(M.from(this.node),0,0)}eq(e){return e instanceof D&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new xr(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new D(e.resolve(t.anchor))}static create(e,t){return new D(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}D.prototype.visible=!1,z.jsonID("node",D);class xr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new Qo(o,o):new xr(o)}resolve(e){let t=e.resolve(this.anchor),o=t.nodeAfter;return o&&D.isSelectable(o)?new D(t):z.near(t)}}class Ce extends z{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=j.empty){if(t==j.empty){e.delete(0,e.doc.content.size);let o=z.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ce(e)}map(e){return new Ce(e)}eq(e){return e instanceof Ce}getBookmark(){return Rm}}z.jsonID("all",Ce);const Rm={map(){return this},resolve(n){return new Ce(n)}};function bn(n,e,t,o,i,r=!1){if(e.inlineContent)return R.create(n,t);for(let s=o-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!r&&D.isSelectable(l))return D.create(n,t-(i<0?l.nodeSize:0))}else{let a=bn(n,l,t+i,i<0?l.childCount:0,i,r);if(a)return a}t+=l.nodeSize*i}return null}function oc(n,e,t){let o=n.steps.length-1;if(o<e)return;let i=n.steps[o];if(!(i instanceof se||i instanceof ne))return;let r=n.mapping.maps[o],s;r.forEach((l,a,c,d)=>{s==null&&(s=d)}),n.setSelection(z.near(n.doc.resolve(s),t))}const ic=1,ei=2,rc=4;class Lm extends Qa{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|ic)&~ei,this.storedMarks=null,this}get selectionSet(){return(this.updated&ic)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ei,this}ensureMarks(e){return _.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&ei)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~ei,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)||_.none))),o.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,o){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.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 s=this.doc.resolve(t);r=o==t?s.marks():s.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(t,o,i.text(e,r)),this.selection.empty||this.setSelection(z.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|=rc,this}get scrolledIntoView(){return(this.updated&rc)>0}}function sc(n,e){return!e||!n?n:n.bind(e)}class Gn{constructor(e,t,o){this.name=e,this.init=sc(t.init,o),this.apply=sc(t.apply,o)}}const Bm=[new Gn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Gn("selection",{init(n,e){return n.selection||z.atStart(e.doc)},apply(n){return n.selection}}),new Gn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new Gn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class vr{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Bm.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 Gn(o.key,o.spec.state,o))})}}class yn{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 i=this.config.plugins[o];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],o=this.applyInner(e),i=null;for(;;){let r=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=i?i[s].n:0,c=i?i[s].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,o);if(d&&o.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let p=0;p<this.config.plugins.length;p++)i.push(p<s?{state:o,n:t.length}:{state:this,n:0})}t.push(d),o=o.applyInner(d),r=!0}i&&(i[s]={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 yn(this.config),o=this.config.fields;for(let i=0;i<o.length;i++){let r=o[i];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new Lm(this)}static create(e){let t=new vr(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new yn(t);for(let i=0;i<t.fields.length;i++)o[t.fields[i].name]=t.fields[i].init(e,o);return o}reconfigure(e){let t=new vr(this.schema,e.plugins),o=t.fields,i=new yn(t);for(let r=0;r<o.length;r++){let s=o[r].name;i[s]=this.hasOwnProperty(s)?this[s]:o[r].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(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 i=e[o],r=i.spec.state;r&&r.toJSON&&(t[o]=r.toJSON.call(i,this[i.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 i=new vr(e.schema,e.plugins),r=new yn(i);return i.fields.forEach(s=>{if(s.name=="doc")r.doc=Ot.fromJSON(e.schema,t.doc);else if(s.name=="selection")r.selection=z.fromJSON(r.doc,t.selection);else if(s.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==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){r[s.name]=c.fromJSON.call(a,e,t[l],r);return}}r[s.name]=s.init(e,r)}}),r}}function lc(n,e,t){for(let o in n){let i=n[o];i instanceof Function?i=i.bind(e):o=="handleDOMEvents"&&(i=lc(i,e,{})),t[o]=i}return t}class xn{constructor(e){this.spec=e,this.props={},e.props&&lc(e.props,this,this.props),this.key=e.key?e.key.key:ac("plugin")}getState(e){return e[this.key]}}const wr=Object.create(null);function ac(n){return n in wr?n+"$"+ ++wr[n]:(wr[n]=0,n+"$")}class Wn{constructor(e="key"){this.key=ac(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const cc=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Vm(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Hm=(n,e,t)=>{let o=Vm(n,t);if(!o)return!1;let i=dc(o);if(!i){let s=o.blockRange(),l=s&&Zo(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let r=i.nodeBefore;if(gc(n,i,e,-1))return!0;if(o.parent.content.size==0&&(vn(r,"end")||D.isSelectable(r)))for(let s=o.depth;;s--){let l=mr(n.doc,o.before(s),o.after(s),j.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(vn(r,"end")?z.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):D.create(a.doc,i.pos-r.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||o.node(s-1).childCount>1)break}return r.isAtom&&i.depth==o.depth-1?(e&&e(n.tr.delete(i.pos-r.nodeSize,i.pos).scrollIntoView()),!0):!1};function vn(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 Fm=(n,e,t)=>{let{$head:o,empty:i}=n.selection,r=o;if(!i)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):o.parentOffset>0)return!1;r=dc(o)}let s=r&&r.nodeBefore;return!s||!D.isSelectable(s)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,r.pos-s.nodeSize)).scrollIntoView()),!0)};function dc(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 _m(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Gm=(n,e,t)=>{let o=_m(n,t);if(!o)return!1;let i=pc(o);if(!i)return!1;let r=i.nodeAfter;if(gc(n,i,e,1))return!0;if(o.parent.content.size==0&&(vn(r,"start")||D.isSelectable(r))){let s=mr(n.doc,o.before(),o.after(),j.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=n.tr.step(s);l.setSelection(vn(r,"start")?z.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):D.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return r.isAtom&&i.depth==o.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+r.nodeSize).scrollIntoView()),!0):!1},Wm=(n,e,t)=>{let{$head:o,empty:i}=n.selection,r=o;if(!i)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):o.parentOffset<o.parent.content.size)return!1;r=pc(o)}let s=r&&r.nodeAfter;return!s||!D.isSelectable(s)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,r.pos)).scrollIntoView()),!0)};function pc(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 qm=(n,e)=>{let{$head:t,$anchor:o}=n.selection;return!t.parent.type.spec.code||!t.sameParent(o)?!1:(e&&e(n.tr.insertText(`
912
+ `).scrollIntoView()),!0)};function Sr(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 uc=(n,e)=>{let{$head:t,$anchor:o}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(o))return!1;let i=t.node(-1),r=t.indexAfter(-1),s=Sr(i.contentMatchAt(r));if(!s||!i.canReplaceWith(r,r,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(z.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Um=(n,e)=>{let t=n.selection,{$from:o,$to:i}=t;if(t instanceof Ce||o.parent.inlineContent||i.parent.inlineContent)return!1;let r=Sr(i.parent.contentMatchAt(i.indexAfter()));if(!r||!r.isTextblock)return!1;if(e){let s=(!o.parentOffset&&i.index()<i.parent.childCount?o:i).pos,l=n.tr.insert(s,r.createAndFill());l.setSelection(R.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},fc=(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(hn(n.doc,r))return e&&e(n.tr.split(r).scrollIntoView()),!0}let o=t.blockRange(),i=o&&Zo(o);return i==null?!1:(e&&e(n.tr.lift(o,i).scrollIntoView()),!0)};function hc(n){return(e,t)=>{let{$from:o,$to:i}=e.selection;if(e.selection instanceof D&&e.selection.node.isBlock)return!o.parentOffset||!hn(e.doc,o.pos)?!1:(t&&t(e.tr.split(o.pos).scrollIntoView()),!0);if(!o.depth)return!1;let r=[],s,l,a=!1,c=!1;for(let f=o.depth;;f--)if(o.node(f).isBlock){a=o.end(f)==o.pos+(o.depth-f),c=o.start(f)==o.pos-(o.depth-f),l=Sr(o.node(f-1).contentMatchAt(o.indexAfter(f-1)));let g=n&&n(i.parent,a,o);r.unshift(g||(a&&l?{type:l}:null)),s=f;break}else{if(f==1)return!1;r.unshift(null)}let d=e.tr;(e.selection instanceof R||e.selection instanceof Ce)&&d.deleteSelection();let p=d.mapping.map(o.pos),u=hn(d.doc,p,r.length,r);if(u||(r[0]=l?{type:l}:null,u=hn(d.doc,p,r.length,r)),d.split(p,r.length,r),!a&&c&&o.node(s).type!=l){let f=d.mapping.map(o.before(s)),h=d.doc.resolve(f);l&&o.node(s-1).canReplaceWith(h.index(),h.index()+1,l)&&d.setNodeMarkup(d.mapping.map(o.before(s)),l)}return t&&t(d.scrollIntoView()),!0}}const Km=hc(),mc=(n,e)=>(e&&e(n.tr.setSelection(new Ce(n.doc))),!0);function Jm(n,e,t){let o=e.nodeBefore,i=e.nodeAfter,r=e.index();return!o||!i||!o.type.compatibleContent(i.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)||!(i.isTextblock||Xo(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function gc(n,e,t,o){let i=e.nodeBefore,r=e.nodeAfter,s,l,a=i.type.spec.isolating||r.type.spec.isolating;if(!a&&Jm(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(r.type))&&l.matchType(s[0]||r.type).validEnd){if(t){let f=e.pos+r.nodeSize,h=M.empty;for(let x=s.length-1;x>=0;x--)h=M.from(s[x].create(null,h));h=M.from(i.copy(h));let g=n.tr.step(new ne(e.pos-1,f,e.pos,f,new j(h,1,0),s.length,!0)),b=g.doc.resolve(f+2*s.length);b.nodeAfter&&b.nodeAfter.type==i.type&&Xo(g.doc,b.pos)&&g.join(b.pos),t(g.scrollIntoView())}return!0}let d=r.type.spec.isolating||o>0&&a?null:z.findFrom(e,1),p=d&&d.$from.blockRange(d.$to),u=p&&Zo(p);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(p,u).scrollIntoView()),!0;if(c&&vn(r,"start",!0)&&vn(i,"end")){let f=i,h=[];for(;h.push(f),!f.isTextblock;)f=f.lastChild;let g=r,b=1;for(;!g.isTextblock;g=g.firstChild)b++;if(f.canReplace(f.childCount,f.childCount,g.content)){if(t){let x=M.empty;for(let y=h.length-1;y>=0;y--)x=M.from(h[y].copy(x));let C=n.tr.step(new ne(e.pos-h.length,e.pos+r.nodeSize,e.pos+b,e.pos+r.nodeSize-b,new j(x,h.length,0),0,!0));t(C.scrollIntoView())}return!0}}return!1}function bc(n){return function(e,t){let o=e.selection,i=n<0?o.$from:o.$to,r=i.depth;for(;i.node(r).isInline;){if(!r)return!1;r--}return i.node(r).isTextblock?(t&&t(e.tr.setSelection(R.create(e.doc,n<0?i.start(r):i.end(r)))),!0):!1}}const Ym=bc(-1),Zm=bc(1);function Xm(n,e=null){return function(t,o){let i=!1;for(let r=0;r<t.selection.ranges.length&&!i;r++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[r];t.doc.nodesBetween(s,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let d=t.doc.resolve(c),p=d.index();i=d.parent.canReplaceWith(p,p+1,n)}})}if(!i)return!1;if(o){let r=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[s];r.setBlockType(l,a,n,e)}o(r.scrollIntoView())}return!0}}function Qm(n,e,t,o){for(let i=0;i<e.length;i++){let{$from:r,$to:s}=e[i],l=r.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(r.pos,s.pos,(a,c)=>{if(l||!o)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function Rt(n,e=null,t){let o=t!==!1;return function(i,r){let{empty:s,$cursor:l,ranges:a}=i.selection;if(s&&!l||!Qm(i.doc,a,n,o))return!1;if(r)if(l)n.isInSet(i.storedMarks||l.marks())?r(i.tr.removeStoredMark(n)):r(i.tr.addStoredMark(n.create(e)));else{let c,d=i.tr;c=!a.some(p=>i.doc.rangeHasMark(p.$from.pos,p.$to.pos,n));for(let p=0;p<a.length;p++){let{$from:u,$to:f}=a[p];if(!c)d.removeMark(u.pos,f.pos,n);else{let h=u.pos,g=f.pos,b=u.nodeAfter,x=f.nodeBefore,C=b&&b.isText?/^\s*/.exec(b.text)[0].length:0,y=x&&x.isText?/\s*$/.exec(x.text)[0].length:0;h+C<g&&(h+=C,g-=y),d.addMark(h,g,n.create(e))}}r(d.scrollIntoView())}return!0}}function qn(...n){return function(e,t,o){for(let i=0;i<n.length;i++)if(n[i](e,t,o))return!0;return!1}}let Cr=qn(cc,Hm,Fm),yc=qn(cc,Gm,Wm);const Qe={Enter:qn(qm,Um,fc,Km),"Mod-Enter":uc,Backspace:Cr,"Mod-Backspace":Cr,"Shift-Backspace":Cr,Delete:yc,"Mod-Delete":yc,"Mod-a":mc},xc={"Ctrl-h":Qe.Backspace,"Alt-Backspace":Qe["Mod-Backspace"],"Ctrl-d":Qe.Delete,"Ctrl-Alt-Backspace":Qe["Mod-Delete"],"Alt-Delete":Qe["Mod-Delete"],"Alt-d":Qe["Mod-Delete"],"Ctrl-a":Ym,"Ctrl-e":Zm};for(let n in Qe)xc[n]=Qe[n];const eg=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?xc:Qe;var ti=200,X=function(){};X.prototype.append=function(e){return e.length?(e=X.from(e),!this.length&&e||e.length<ti&&this.leafAppend(e)||this.length<ti&&e.leafPrepend(this)||this.appendInner(e)):this},X.prototype.prepend=function(e){return e.length?X.from(e).append(this):this},X.prototype.appendInner=function(e){return new tg(this,e)},X.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?X.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},X.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},X.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)},X.prototype.map=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length);var i=[];return this.forEach(function(r,s){return i.push(e(r,s))},t,o),i},X.from=function(e){return e instanceof X?e:e&&e.length?new vc(e):X.empty};var vc=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(i,r){return i==0&&r==this.length?this:new e(this.values.slice(i,r))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,r,s,l){for(var a=r;a<s;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,r,s,l){for(var a=r-1;a>=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=ti)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=ti)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(X);X.empty=new vc([]);var tg=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,i,r,s){var l=this.left.length;if(i<l&&this.left.forEachInner(o,i,Math.min(r,l),s)===!1||r>l&&this.right.forEachInner(o,Math.max(i-l,0),Math.min(this.length,r)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,r,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(o,i-l,Math.max(r,l)-l,s+l)===!1||r<l&&this.left.forEachInvertedInner(o,Math.min(i,l),r,s)===!1)return!1},e.prototype.sliceInner=function(o,i){if(o==0&&i==this.length)return this;var r=this.left.length;return i<=r?this.left.slice(o,i):o>=r?this.right.slice(o-r,i-r):this.left.slice(o,r).append(this.right.slice(0,i-r))},e.prototype.leafAppend=function(o){var i=this.right.leafAppend(o);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(o){var i=this.left.leafPrepend(o);if(i)return new e(i,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}(X);const ng=500;class Ie{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 i,r;t&&(i=this.remapping(o,this.items.length),r=i.maps.length);let s=e.tr,l,a,c=[],d=[];return this.items.forEach((p,u)=>{if(!p.step){i||(i=this.remapping(o,u+1),r=i.maps.length),r--,d.push(p);return}if(i){d.push(new _e(p.map));let f=p.step.map(i.slice(r)),h;f&&s.maybeStep(f).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],c.push(new _e(h,void 0,void 0,c.length+d.length))),r--,h&&i.appendMap(h,r)}else s.maybeStep(p.step);if(p.selection)return l=i?p.selection.map(i.slice(r)):p.selection,a=new Ie(this.items.slice(0,o).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,o,i){let r=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let p=e.steps[d].invert(e.docs[d]),u=new _e(e.mapping.maps[d],p,t),f;(f=a&&a.merge(u))&&(u=f,d?r.pop():l=l.slice(0,l.length-1)),r.push(u),t&&(s++,t=void 0),i||(a=u)}let c=s-o.depth;return c>ig&&(l=og(l,c),s-=c),new Ie(l.append(r),s)}remapping(e,t){let o=new un;return this.items.forEach((i,r)=>{let s=i.mirrorOffset!=null&&r-i.mirrorOffset>=e?o.maps.length-i.mirrorOffset:void 0;o.appendMap(i.map,s)},e,t),o}addMaps(e){return this.eventCount==0?this:new Ie(this.items.append(e.map(t=>new _e(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let o=[],i=Math.max(0,this.items.length-t),r=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(u=>{u.selection&&l--},i);let a=t;this.items.forEach(u=>{let f=r.getMirror(--a);if(f==null)return;s=Math.min(s,f);let h=r.maps[f];if(u.step){let g=e.steps[f].invert(e.docs[f]),b=u.selection&&u.selection.map(r.slice(a+1,f));b&&l++,o.push(new _e(h,g,b))}else o.push(new _e(h))},i);let c=[];for(let u=t;u<s;u++)c.push(new _e(r.maps[u]));let d=this.items.slice(0,i).append(c).append(o),p=new Ie(d,l);return p.emptyItemCount()>ng&&(p=p.compress(this.items.length-o.length)),p}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,i=[],r=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&r++;else if(s.step){let a=s.step.map(t.slice(o)),c=a&&a.getMap();if(o--,c&&t.appendMap(c,o),a){let d=s.selection&&s.selection.map(t.slice(o));d&&r++;let p=new _e(c.invert(),a,d),u,f=i.length-1;(u=i.length&&i[f].merge(p))?i[f]=u:i.push(p)}}else s.map&&o--},this.items.length,0),new Ie(X.from(i.reverse()),r)}}Ie.empty=new Ie(X.empty,0);function og(n,e){let t;return n.forEach((o,i)=>{if(o.selection&&e--==0)return t=i,!1}),n.slice(t)}class _e{constructor(e,t,o,i){this.map=e,this.step=t,this.selection=o,this.mirrorOffset=i}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 pt{constructor(e,t,o,i,r){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=i,this.prevComposition=r}}const ig=20;function rg(n,e,t,o){let i=t.getMeta(Lt),r;if(i)return i.historyState;t.getMeta(ag)&&(n=new pt(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(Lt))return s.getMeta(Lt).redo?new pt(n.done.addTransform(t,void 0,o,ni(e)),n.undone,wc(t.mapping.maps),n.prevTime,n.prevComposition):new pt(n.done,n.undone.addTransform(t,void 0,o,ni(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!sg(t,n.prevRanges)),c=s?kr(n.prevRanges,t.mapping):wc(t.mapping.maps);return new pt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,o,ni(e)),Ie.empty,c,t.time,l??n.prevComposition)}else return(r=t.getMeta("rebased"))?new pt(n.done.rebased(t,r),n.undone.rebased(t,r),kr(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new pt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),kr(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function sg(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((o,i)=>{for(let r=0;r<e.length;r+=2)o<=e[r+1]&&i>=e[r]&&(t=!0)}),t}function wc(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,i,r,s)=>e.push(r,s));return e}function kr(n,e){if(!n)return null;let t=[];for(let o=0;o<n.length;o+=2){let i=e.map(n[o],1),r=e.map(n[o+1],-1);i<=r&&t.push(i,r)}return t}function lg(n,e,t){let o=ni(e),i=Lt.get(e).spec.config,r=(t?n.undone:n.done).popEvent(e,o);if(!r)return null;let s=r.selection.resolve(r.transform.doc),l=(t?n.done:n.undone).addTransform(r.transform,e.selection.getBookmark(),i,o),a=new pt(t?l:r.remaining,t?r.remaining:l,null,0,-1);return r.transform.setSelection(s).setMeta(Lt,{redo:t,historyState:a})}let Tr=!1,Sc=null;function ni(n){let e=n.plugins;if(Sc!=e){Tr=!1,Sc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Tr=!0;break}}return Tr}const Lt=new Wn("history"),ag=new Wn("closeHistory");function cg(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new xn({key:Lt,state:{init(){return new pt(Ie.empty,Ie.empty,null,0,-1)},apply(e,t,o){return rg(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,i=o=="historyUndo"?kc:o=="historyRedo"?Er:null;return i?(t.preventDefault(),i(e.state,e.dispatch)):!1}}}})}function Cc(n,e){return(t,o)=>{let i=Lt.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(o){let r=lg(i,t,n);r&&o(e?r.scrollIntoView():r)}return!0}}const kc=Cc(!1,!0),Er=Cc(!0,!0);for(var ut={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:"'"},oi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},dg=typeof navigator<"u"&&/Mac/.test(navigator.platform),pg=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),oe=0;oe<10;oe++)ut[48+oe]=ut[96+oe]=String(oe);for(var oe=1;oe<=24;oe++)ut[oe+111]="F"+oe;for(var oe=65;oe<=90;oe++)ut[oe]=String.fromCharCode(oe+32),oi[oe]=String.fromCharCode(oe);for(var Mr in ut)oi.hasOwnProperty(Mr)||(oi[Mr]=ut[Mr]);function ug(n){var e=dg&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||pg&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?oi:ut)[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 fg=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function hg(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let o,i,r,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))o=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))r=!0;else if(/^mod$/i.test(a))fg?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return o&&(t="Alt-"+t),i&&(t="Ctrl-"+t),s&&(t="Meta-"+t),r&&(t="Shift-"+t),t}function mg(n){let e=Object.create(null);for(let t in n)e[hg(t)]=n[t];return e}function Ar(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 jr(n){return new xn({props:{handleKeyDown:Tc(n)}})}function Tc(n){let e=mg(n);return function(t,o){let i=ug(o),r,s=e[Ar(i,o)];if(s&&s(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(o.shiftKey){let l=e[Ar(i,o,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((o.shiftKey||o.altKey||o.metaKey||i.charCodeAt(0)>127)&&(r=ut[o.keyCode])&&r!=i){let l=e[Ar(r,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function Ec(n,e=null){return function(t,o){let{$from:i,$to:r}=t.selection,s=i.blockRange(r),l=!1,a=s;if(!s)return!1;if(s.depth>=2&&i.node(s.depth-1).type.compatibleContent(n)&&s.startIndex==0){if(i.index(s.depth-1)==0)return!1;let d=t.doc.resolve(s.start-2);a=new _o(d,d,s.depth),s.endIndex<s.parent.childCount&&(s=new _o(i,t.doc.resolve(r.end(s.depth)),s.depth)),l=!0}let c=Wa(a,n,e,s);return c?(o&&o(gg(t.tr,s,c,l,n).scrollIntoView()),!0):!1}}function gg(n,e,t,o,i){let r=M.empty;for(let d=t.length-1;d>=0;d--)r=M.from(t[d].type.create(t[d].attrs,r));n.step(new ne(e.start-(o?2:0),e.end,e.start,e.end,new j(r,0,0),t.length,!0));let s=0;for(let d=0;d<t.length;d++)t[d].type==i&&(s=d+1);let l=t.length-s,a=e.start+t.length-(o?2:0),c=e.parent;for(let d=e.startIndex,p=e.endIndex,u=!0;d<p;d++,u=!1)!u&&hn(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function bg(n,e){return function(t,o){let{$from:i,$to:r,node:s}=t.selection;if(s&&s.isBlock||i.depth<2||!i.sameParent(r))return!1;let l=i.node(-1);if(l.type!=n)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=n||i.index(-2)!=i.node(-2).childCount-1)return!1;if(o){let p=M.empty,u=i.index(-1)?1:i.index(-2)?2:3;for(let x=i.depth-u;x>=i.depth-3;x--)p=M.from(i.node(x).copy(p));let f=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;p=p.append(M.from(n.createAndFill()));let h=i.before(i.depth-(u-1)),g=t.tr.replace(h,i.after(-f),new j(p,4-u,0)),b=-1;g.doc.nodesBetween(h,g.doc.content.size,(x,C)=>{if(b>-1)return!1;x.isTextblock&&x.content.size==0&&(b=C+1)}),b>-1&&g.setSelection(z.near(g.doc.resolve(b))),o(g.scrollIntoView())}return!0}let a=r.pos==i.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(i.pos,r.pos),d=a?[null,{type:a}]:void 0;return hn(c.doc,i.pos,2,d)?(o&&o(c.split(i.pos,2,d).scrollIntoView()),!0):!1}}function $r(n){return function(e,t){let{$from:o,$to:i}=e.selection,r=o.blockRange(i,s=>s.childCount>0&&s.firstChild.type==n);return r?t?o.node(r.depth-1).type==n?yg(e,t,n,r):xg(e,t,r):!0:!1}}function yg(n,e,t,o){let i=n.tr,r=o.end,s=o.$to.end(o.depth);r<s&&(i.step(new ne(r-1,s,r,s,new j(M.from(t.create(null,o.parent.copy())),1,0),1,!0)),o=new _o(i.doc.resolve(o.$from.pos),i.doc.resolve(s),o.depth));const l=Zo(o);if(l==null)return!1;i.lift(o,l);let a=i.mapping.map(r,-1)-1;return Xo(i.doc,a)&&i.join(a),e(i.scrollIntoView()),!0}function xg(n,e,t){let o=n.tr,i=t.parent;for(let f=t.end,h=t.endIndex-1,g=t.startIndex;h>g;h--)f-=i.child(h).nodeSize,o.delete(f-1,f+1);let r=o.doc.resolve(t.start),s=r.nodeAfter;if(o.mapping.map(t.end)!=t.start+r.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=r.node(-1),d=r.index(-1);if(!c.canReplace(d+(l?0:1),d+1,s.content.append(a?M.empty:M.from(i))))return!1;let p=r.pos,u=p+s.nodeSize;return o.step(new ne(p-(l?1:0),u+(a?1:0),p+1,u-1,new j((l?M.empty:M.from(i.copy(M.empty))).append(a?M.empty:M.from(i.copy(M.empty))),l?0:1,a?0:1),l?0:1)),e(o.scrollIntoView()),!0}function vg(n){return function(e,t){let{$from:o,$to:i}=e.selection,r=o.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!r)return!1;let s=r.startIndex;if(s==0)return!1;let l=r.parent,a=l.child(s-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=M.from(c?n.create():null),p=new j(M.from(n.create(null,M.from(l.type.create(null,d)))),c?3:1,0),u=r.start,f=r.end;t(e.tr.step(new ne(u-(c?3:1),f,u,f,p,1,!0)).scrollIntoView())}return!0}}const ie=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Un=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Pr=null;const et=function(n,e,t){let o=Pr||(Pr=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o},wg=function(){Pr=null},Bt=function(n,e,t,o){return t&&(Mc(n,e,t,o,-1)||Mc(n,e,t,o,1))},Sg=/^(img|br|input|textarea|hr)$/i;function Mc(n,e,t,o,i){for(;;){if(n==t&&e==o)return!0;if(e==(i<0?0:Me(n))){let r=n.parentNode;if(!r||r.nodeType!=1||Kn(n)||Sg.test(n.nodeName)||n.contentEditable=="false")return!1;e=ie(n)+(i<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?Me(n):0}else return!1}}function Me(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Cg(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=Me(n)}else if(n.parentNode&&!Kn(n))e=ie(n),n=n.parentNode;else return null}}function kg(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&&!Kn(n))e=ie(n)+1,n=n.parentNode;else return null}}function Tg(n,e,t){for(let o=e==0,i=e==Me(n);o||i;){if(n==t)return!0;let r=ie(n);if(n=n.parentNode,!n)return!1;o=o&&r==0,i=i&&r==Me(n)}}function Kn(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 ii=function(n){return n.focusNode&&Bt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Vt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Eg(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Mg(n,e,t){if(n.caretPositionFromPoint)try{let o=n.caretPositionFromPoint(e,t);if(o)return{node:o.offsetNode,offset:Math.min(Me(o.offsetNode),o.offset)}}catch{}if(n.caretRangeFromPoint){let o=n.caretRangeFromPoint(e,t);if(o)return{node:o.startContainer,offset:Math.min(Me(o.startContainer),o.startOffset)}}}const Ge=typeof navigator<"u"?navigator:null,Ac=typeof document<"u"?document:null,ft=Ge&&Ge.userAgent||"",Nr=/Edge\/(\d+)/.exec(ft),jc=/MSIE \d/.exec(ft),Or=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ft),ye=!!(jc||Or||Nr),ht=jc?document.documentMode:Or?+Or[1]:Nr?+Nr[1]:0,De=!ye&&/gecko\/(\d+)/i.test(ft);De&&+(/Firefox\/(\d+)/.exec(ft)||[0,0])[1];const Ir=!ye&&/Chrome\/(\d+)/.exec(ft),le=!!Ir,$c=Ir?+Ir[1]:0,de=!ye&&!!Ge&&/Apple Computer/.test(Ge.vendor),wn=de&&(/Mobile\/\w+/.test(ft)||!!Ge&&Ge.maxTouchPoints>2),Ae=wn||(Ge?/Mac/.test(Ge.platform):!1),Ag=Ge?/Win/.test(Ge.platform):!1,ze=/Android \d/.test(ft),Jn=!!Ac&&"webkitFontSmoothing"in Ac.documentElement.style,jg=Jn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function $g(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 tt(n,e){return typeof n=="number"?n:n[e]}function Pg(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 Pc(n,e,t){let o=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,r=n.dom.ownerDocument;for(let s=t||n.dom;s;s=Un(s)){if(s.nodeType!=1)continue;let l=s,a=l==r.body,c=a?$g(r):Pg(l),d=0,p=0;if(e.top<c.top+tt(o,"top")?p=-(c.top-e.top+tt(i,"top")):e.bottom>c.bottom-tt(o,"bottom")&&(p=e.bottom-e.top>c.bottom-c.top?e.top+tt(i,"top")-c.top:e.bottom-c.bottom+tt(i,"bottom")),e.left<c.left+tt(o,"left")?d=-(c.left-e.left+tt(i,"left")):e.right>c.right-tt(o,"right")&&(d=e.right-c.right+tt(i,"right")),d||p)if(a)r.defaultView.scrollBy(d,p);else{let u=l.scrollLeft,f=l.scrollTop;p&&(l.scrollTop+=p),d&&(l.scrollLeft+=d);let h=l.scrollLeft-u,g=l.scrollTop-f;e={left:e.left-h,top:e.top-g,right:e.right-h,bottom:e.bottom-g}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function Ng(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),o,i;for(let r=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(r,s);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){o=l,i=a.top;break}}return{refDOM:o,refTop:i,stack:Nc(n.dom)}}function Nc(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=Un(o));return e}function Og({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;Oc(t,o==0?0:o-e)}function Oc(n,e){for(let t=0;t<n.length;t++){let{dom:o,top:i,left:r}=n[t];o.scrollTop!=i+e&&(o.scrollTop=i+e),o.scrollLeft!=r&&(o.scrollLeft=r)}}let Sn=null;function Ig(n){if(n.setActive)return n.setActive();if(Sn)return n.focus(Sn);let e=Nc(n);n.focus(Sn==null?{get preventScroll(){return Sn={preventScroll:!0},!0}}:void 0),Sn||(Sn=!1,Oc(e,0))}function Ic(n,e){let t,o=2e8,i,r=0,s=e.top,l=e.top,a,c;for(let d=n.firstChild,p=0;d;d=d.nextSibling,p++){let u;if(d.nodeType==1)u=d.getClientRects();else if(d.nodeType==3)u=et(d).getClientRects();else continue;for(let f=0;f<u.length;f++){let h=u[f];if(h.top<=s&&h.bottom>=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let g=h.left>e.left?h.left-e.left:h.right<e.left?e.left-h.right:0;if(g<o){t=d,o=g,i=g&&t.nodeType==3?{left:h.right<e.left?h.right:h.left,top:e.top}:e,d.nodeType==1&&g&&(r=p+(e.left>=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=d,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(r=p+1)}}return!t&&a&&(t=a,i=c,o=0),t&&t.nodeType==3?Dg(t,i):!t||o&&t.nodeType==1?{node:n,offset:r}:Ic(t,i)}function Dg(n,e){let t=n.nodeValue.length,o=document.createRange();for(let i=0;i<t;i++){o.setEnd(n,i+1),o.setStart(n,i);let r=mt(o,1);if(r.top!=r.bottom&&Dr(e,r))return{node:n,offset:i+(e.left>=(r.left+r.right)/2?1:0)}}return{node:n,offset:0}}function Dr(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function zg(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Rg(n,e,t){let{node:o,offset:i}=Ic(e,t),r=-1;if(o.nodeType==1&&!o.firstChild){let s=o.getBoundingClientRect();r=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(o,i,r)}function Lg(n,e,t,o){let i=-1;for(let r=e,s=!1;r!=n.dom;){let l=n.docView.nearestDesc(r,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!s&&a.left>o.left||a.top>o.top?i=l.posBefore:(!s&&a.right<o.left||a.bottom<o.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<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 i>-1?i:n.docView.posFromDOM(e,t,-1)}function Dc(n,e,t){let o=n.childNodes.length;if(o&&t.top<t.bottom)for(let i=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-t.top)/(t.bottom-t.top))-2)),r=i;;){let s=n.childNodes[r];if(s.nodeType==1){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Dr(e,c))return Dc(s,e,c)}}if((r=(r+1)%o)==i)break}return n}function Bg(n,e){let t=n.dom.ownerDocument,o,i=0,r=Mg(t,e.left,e.top);r&&({node:o,offset:i}=r);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=n.dom.getBoundingClientRect();if(!Dr(e,c)||(s=Dc(n.dom,e,c),!s))return null}if(de)for(let c=s;o&&c;c=Un(c))c.draggable&&(o=void 0);if(s=zg(s,e),o){if(De&&o.nodeType==1&&(i=Math.min(i,o.childNodes.length),i<o.childNodes.length)){let d=o.childNodes[i],p;d.nodeName=="IMG"&&(p=d.getBoundingClientRect()).right<=e.left&&p.bottom>e.top&&i++}let c;Jn&&i&&o.nodeType==1&&(c=o.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,o==n.dom&&i==o.childNodes.length-1&&o.lastChild.nodeType==1&&e.top>o.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||o.nodeType!=1||o.childNodes[i-1].nodeName!="BR")&&(l=Lg(n,o,i,e))}l==null&&(l=Rg(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function zc(n){return n.top<n.bottom||n.left<n.right}function mt(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(zc(o))return o}return Array.prototype.find.call(t,zc)||n.getBoundingClientRect()}const Vg=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Rc(n,e,t){let{node:o,offset:i,atom:r}=n.docView.domFromPos(e,t<0?-1:1),s=Jn||De;if(o.nodeType==3)if(s&&(Vg.test(o.nodeValue)||(t<0?!i:i==o.nodeValue.length))){let a=mt(et(o,i,i),t);if(De&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){let c=mt(et(o,i-1,i-1),-1);if(c.top==a.top){let d=mt(et(o,i,i+1),-1);if(d.top!=a.top)return Yn(d,d.left<c.left)}}return a}else{let a=i,c=i,d=t<0?1:-1;return t<0&&!i?(c++,d=-1):t>=0&&i==o.nodeValue.length?(a--,d=1):t<0?a--:c++,Yn(mt(et(o,a,c),d),d<0)}if(!n.state.doc.resolve(e-(r||0)).parent.inlineContent){if(r==null&&i&&(t<0||i==Me(o))){let a=o.childNodes[i-1];if(a.nodeType==1)return zr(a.getBoundingClientRect(),!1)}if(r==null&&i<Me(o)){let a=o.childNodes[i];if(a.nodeType==1)return zr(a.getBoundingClientRect(),!0)}return zr(o.getBoundingClientRect(),t>=0)}if(r==null&&i&&(t<0||i==Me(o))){let a=o.childNodes[i-1],c=a.nodeType==3?et(a,Me(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Yn(mt(c,1),!1)}if(r==null&&i<Me(o)){let a=o.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?et(a,0,s?0:1):a.nodeType==1?a:null:null;if(c)return Yn(mt(c,-1),!0)}return Yn(mt(o.nodeType==3?et(o):o,-t),t>=0)}function Yn(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 zr(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,i=n.root.activeElement;o!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{o!=e&&n.updateState(o),i!=n.dom&&i&&i.focus()}}function Hg(n,e,t){let o=e.selection,i=t=="up"?o.$from:o.$to;return Lc(n,e,()=>{let{node:r}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(r,!0);if(!l)break;if(l.node.isBlock){r=l.contentDOM||l.dom;break}r=l.dom.parentNode}let s=Rc(n,i.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=et(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}const Fg=/[\u0590-\u08ac]/;function _g(n,e,t){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let i=o.parentOffset,r=!i,s=i==o.parent.content.size,l=n.domSelection();return l?!Fg.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?r:s:Lc(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:p}=n.domSelectionRange(),u=l.caretBidiLevel;l.modify("move",t,"character");let f=o.depth?n.docView.domAfterPos(o.before()):n.dom,{focusNode:h,focusOffset:g}=n.domSelectionRange(),b=h&&!f.contains(h.nodeType==1?h:h.parentNode)||a==h&&c==g;try{l.collapse(d,p),a&&(a!=d||c!=p)&&l.extend&&l.extend(a,c)}catch{}return u!=null&&(l.caretBidiLevel=u),b}):o.pos==o.start()||o.pos==o.end()}let Bc=null,Vc=null,Hc=!1;function Gg(n,e,t){return Bc==e&&Vc==t?Hc:(Bc=e,Vc=t,Hc=t=="up"||t=="down"?Hg(n,e,t):_g(n,e,t))}const je=0,Fc=1,Ht=2,We=3;class Zn{constructor(e,t,o,i){this.parent=e,this.children=t,this.dom=o,this.contentDOM=i,this.dirty=je,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 i=this.children[t];if(i==e)return o;o+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,o){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(o<0){let r,s;if(e==this.contentDOM)r=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.previousSibling}for(;r&&!((s=r.pmViewDesc)&&s.parent==this);)r=r.previousSibling;return r?this.posBeforeChild(s)+s.size:this.posAtStart}else{let r,s;if(e==this.contentDOM)r=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;r=e.nextSibling}for(;r&&!((s=r.pmViewDesc)&&s.parent==this);)r=r.nextSibling;return r?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>ie(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let r=e;;r=r.parentNode){if(r==this.dom){i=!1;break}if(r.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let r=e;;r=r.parentNode){if(r==this.dom){i=!0;break}if(r.nextSibling)break}}return i??o>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let o=!0,i=e;i;i=i.parentNode){let r=this.getDesc(i),s;if(r&&(!t||r.node))if(o&&(s=r.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==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 i=e;i;i=i.parentNode){let r=this.getDesc(i);if(r)return r.localPosFromDOM(e,t,o)}return-1}descAt(e){for(let t=0,o=0;t<this.children.length;t++){let i=this.children[t],r=o+i.size;if(o==e&&r!=o){for(;!i.border&&i.children.length;)i=i.children[0];return i}if(e<r)return i.descAt(e-o-i.border);o=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let o=0,i=0;for(let r=0;o<this.children.length;o++){let s=this.children[o],l=r+s.size;if(l>e||s instanceof Wc){i=e-r;break}r=l}if(i)return this.children[o].domFromPos(i-this.children[o].border,t);for(let r;o&&!(r=this.children[o-1]).size&&r instanceof _c&&r.side>=0;o--);if(t<=0){let r,s=!0;for(;r=o?this.children[o-1]:null,!(!r||r.dom.parentNode==this.contentDOM);o--,s=!1);return r&&t&&s&&!r.border&&!r.domAtom?r.domFromPos(r.size,t):{node:this.contentDOM,offset:r?ie(r.dom)+1:0}}else{let r,s=!0;for(;r=o<this.children.length?this.children[o]:null,!(!r||r.dom.parentNode==this.contentDOM);o++,s=!1);return r&&s&&!r.border&&!r.domAtom?r.domFromPos(0,t):{node:this.contentDOM,offset:r?ie(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 i=-1,r=-1;for(let s=o,l=0;;l++){let a=this.children[l],c=s+a.size;if(i==-1&&e<=c){let d=s+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=s;for(let p=l;p>0;p--){let u=this.children[p-1];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(1)){i=ie(u.dom)+1;break}e-=u.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let p=this.children[d];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(-1)){r=ie(p.dom);break}t+=p.size}r==-1&&(r=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,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,i=!1){let r=Math.min(e,t),s=Math.max(e,t);for(let f=0,h=0;f<this.children.length;f++){let g=this.children[f],b=h+g.size;if(r>h&&s<b)return g.setSelection(e-h-g.border,t-h-g.border,o,i);h=b}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(),p=!1;if((De||de)&&e==t){let{node:f,offset:h}=l;if(f.nodeType==3){if(p=!!(h&&f.nodeValue[h-1]==`
913
+ `),p&&h==f.nodeValue.length)for(let g=f,b;g;g=g.parentNode){if(b=g.nextSibling){b.nodeName=="BR"&&(l=a={node:b.parentNode,offset:ie(b)+1});break}let x=g.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let g=f.childNodes[h-1];p=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(De&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let f=d.focusNode.childNodes[d.focusOffset];f&&f.contentEditable=="false"&&(i=!0)}if(!(i||p&&de)&&Bt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Bt(a.node,a.offset,d.focusNode,d.focusOffset))return;let u=!1;if((c.extend||e==t)&&!p){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),u=!0}catch{}}if(!u){if(e>t){let h=l;l=a,a=h}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let o=0,i=0;i<this.children.length;i++){let r=this.children[i],s=o+r.size;if(o==s?e<=s&&t>=o:e<s&&t>o){let l=o+r.border,a=s-r.border;if(e>=l&&t<=a){this.dirty=e==o||t==s?Ht:Fc,e==l&&t==a&&(r.contentLost||r.dom.parentNode!=this.contentDOM)?r.dirty=We:r.markDirty(e-l,t-l);return}else r.dirty=r.dom==r.contentDOM&&r.dom.parentNode==this.contentDOM&&!r.children.length?Ht:We}o=s}this.dirty=Ht}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let o=e==1?Ht:Fc;t.dirty<o&&(t.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class _c extends Zn{constructor(e,t,o,i){let r,s=t.type.toDOM;if(typeof s=="function"&&(s=s(o,()=>{if(!r)return i;if(r.parent)return r.parent.posBeforeChild(r)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==je&&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 Wg extends Zn{constructor(e,t,o,i){super(e,[],t,null),this.textDOM=o,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Ft extends Zn{constructor(e,t,o,i,r){super(e,[],o,i),this.mark=t,this.spec=r}static create(e,t,o,i){let r=i.nodeViews[t.type.name],s=r&&r(t,i,o);return(!s||!s.dom)&&(s=zt.renderSpec(document,t.type.spec.toDOM(t,o),null,t.attrs)),new Ft(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&We||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=We&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=je){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=je}}slice(e,t,o){let i=Ft.create(this.parent,this.mark,!0,o),r=this.children,s=this.size;t<s&&(r=Lr(r,t,s,o)),e>0&&(r=Lr(r,0,e,o));for(let l=0;l<r.length;l++)r[l].parent=i;return i.children=r,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class gt extends Zn{constructor(e,t,o,i,r,s,l,a,c){super(e,[],r,s),this.node=t,this.outerDeco=o,this.innerDeco=i,this.nodeDOM=l}static create(e,t,o,i,r,s){let l=r.nodeViews[t.type.name],a,c=l&&l(t,r,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},o,i),d=c&&c.dom,p=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:p}=zt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!p&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let u=d;return d=Kc(d,o,t),c?a=new qg(e,t,o,i,d,p||null,u,c,r,s+1):t.isText?new ri(e,t,o,i,d,u,r):new gt(e,t,o,i,d,p||null,u,r,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let o=this.children[t];if(this.dom.contains(o.dom.parentNode)){e.contentElement=o.dom.parentNode;break}}e.contentElement||(e.getContent=()=>M.empty)}return e}matchesNode(e,t,o){return this.dirty==je&&e.eq(this.node)&&si(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,i=t,r=e.composing?this.localCompositionInfo(e,t):null,s=r&&r.pos>-1?r:null,l=r&&r.pos<0,a=new Kg(this,s&&s.node,e);Zg(this.node,this.innerDeco,(c,d,p)=>{c.spec.marks?a.syncToMarks(c.spec.marks,o,e):c.type.side>=0&&!p&&a.syncToMarks(d==this.node.childCount?_.none:this.node.child(d).marks,o,e),a.placeWidget(c,e,i)},(c,d,p,u)=>{a.syncToMarks(c.marks,o,e);let f;a.findNodeMatch(c,d,p,u)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(f=a.findIndexWithChild(r.node))>-1&&a.updateNodeAt(c,d,p,f,e)||a.updateNextNode(c,d,p,e,u,i)||a.addNode(c,d,p,e,i),i+=c.nodeSize}),a.syncToMarks([],o,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Ht)&&(s&&this.protectLocalComposition(e,s),qc(this.contentDOM,this.children,e),wn&&Xg(this.dom))}localCompositionInfo(e,t){let{from:o,to:i}=e.state.selection;if(!(e.state.selection instanceof R)||o<t||i>t+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let s=r.nodeValue,l=Qg(this.node.content,s,o-t,i-t);return l<0?null:{node:r,pos:l,text:s}}else return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:o,text:i}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let s=new Wg(this,r,t,i);e.input.compositionNodes.push(s),this.children=Lr(this.children,o,o+i.length,e,s)}update(e,t,o,i){return this.dirty==We||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,o,i),!0)}updateInner(e,t,o,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=o,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=je}updateOuterDeco(e){if(si(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=Uc(this.dom,this.nodeDOM,Rr(this.outerDeco,this.node,t),Rr(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 Gc(n,e,t,o,i){Kc(o,e,n);let r=new gt(void 0,n,e,t,o,o,o,i,0);return r.contentDOM&&r.updateChildren(i,0),r}class ri extends gt{constructor(e,t,o,i,r,s,l){super(e,t,o,i,r,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,o,i){return this.dirty==We||this.dirty!=je&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=je||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=je,!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 i=this.node.cut(e,t),r=document.createTextNode(i.text);return new ri(this.parent,i,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=We)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Wc extends Zn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==je&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class qg extends gt{constructor(e,t,o,i,r,s,l,a,c,d){super(e,t,o,i,r,s,l,c,d),this.spec=a}update(e,t,o,i){if(this.dirty==We)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,i),r}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,o,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,o,i){this.spec.setSelection?this.spec.setSelection(e,t,o.root):super.setSelection(e,t,o,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function qc(n,e,t){let o=n.firstChild,i=!1;for(let r=0;r<e.length;r++){let s=e[r],l=s.dom;if(l.parentNode==n){for(;l!=o;)o=Jc(o),i=!0;o=o.nextSibling}else i=!0,n.insertBefore(l,o);if(s instanceof Ft){let a=o?o.previousSibling:n.lastChild;qc(s.contentDOM,s.children,t),o=a?a.nextSibling:n.firstChild}}for(;o;)o=Jc(o),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const Xn=function(n){n&&(this.nodeName=n)};Xn.prototype=Object.create(null);const _t=[new Xn];function Rr(n,e,t){if(n.length==0)return _t;let o=t?_t[0]:new Xn,i=[o];for(let r=0;r<n.length;r++){let s=n[r].type.attrs;if(s){s.nodeName&&i.push(o=new Xn(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&i.length==1&&i.push(o=new Xn(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 i}function Uc(n,e,t,o){if(t==_t&&o==_t)return e;let i=e;for(let r=0;r<o.length;r++){let s=o[r],l=t[r];if(r){let a;l&&l.nodeName==s.nodeName&&i!=n&&(a=i.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=_t[0]),i=a}Ug(i,l||_t[0],s)}return i}function Ug(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):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let r=0;r<o.length;r++)i.indexOf(o[r])==-1&&n.classList.remove(o[r]);for(let r=0;r<i.length;r++)o.indexOf(i[r])==-1&&n.classList.add(i[r]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=o.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function Kc(n,e,t){return Uc(n,n,_t,Rr(e,t,n.nodeType!=1))}function si(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 Jc(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Kg{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Jg(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 i=0,r=this.stack.length>>1,s=Math.min(r,e.length);for(;i<s&&(i==r-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<r;)this.destroyRest(),this.top.dirty=je,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=Ft.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,i){let r=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,o))r=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,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,i,r){let s=this.top.children[i];return s.dirty==We&&s.dom==s.contentDOM&&(s.dirty=Ht),s.update(e,t,o,r)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let o=e.pmViewDesc;if(o){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==o)return i}return-1}e=t}}updateNextNode(e,t,o,i,r,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof gt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=r)return!1;let d=a.dom,p,u=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=We&&si(t,a.outerDeco));if(!u&&a.update(e,t,o,i))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(p=this.recreateWrapper(a,e,t,o,i,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=p,p.contentDOM&&(p.dirty=Ht,p.updateChildren(i,s+1),p.dirty=je),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,i,r,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!si(o,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=gt.create(this.top,t,o,i,r,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,o,i,r){let s=gt.create(this.top,e,t,o,i,r);s.contentDOM&&s.updateChildren(i,r+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,o){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let r=new _c(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 Ft;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof ri)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((de||le)&&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 i=new Wc(this.top,[],o,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Jg(n,e){let t=e,o=t.children.length,i=n.childCount,r=new Map,s=[];e:for(;i>0;){let l;for(;;)if(o){let c=t.children[o-1];if(c instanceof Ft)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(i-1))break;--i,r.set(l,i),s.push(l)}}return{index:i,matched:r,matches:s.reverse()}}function Yg(n,e){return n.type.side-e.type.side}function Zg(n,e,t,o){let i=e.locals(n),r=0;if(i.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);o(d,i,e.forChild(r,d),c),r+=d.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,p;for(;s<i.length&&i[s].to==r;){let b=i[s++];b.widget&&(d?(p||(p=[d])).push(b):d=b)}if(d)if(p){p.sort(Yg);for(let b=0;b<p.length;b++)t(p[b],c,!!a)}else t(d,c,!!a);let u,f;if(a)f=-1,u=a,a=null;else if(c<n.childCount)f=c,u=n.child(c++);else break;for(let b=0;b<l.length;b++)l[b].to<=r&&l.splice(b--,1);for(;s<i.length&&i[s].from<=r&&i[s].to>r;)l.push(i[s++]);let h=r+u.nodeSize;if(u.isText){let b=h;s<i.length&&i[s].from<b&&(b=i[s].from);for(let x=0;x<l.length;x++)l[x].to<b&&(b=l[x].to);b<h&&(a=u.cut(b-r),u=u.cut(0,b-r),h=b,f=-1)}else for(;s<i.length&&i[s].to<h;)s++;let g=u.isInline&&!u.isLeaf?l.filter(b=>!b.inline):l.slice();o(u,g,e.forChild(r,u),f),r=h}}function Xg(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 Qg(n,e,t,o){for(let i=0,r=0;i<n.childCount&&r<=o;){let s=n.child(i++),l=r;if(r+=s.nodeSize,!s.isText)continue;let a=s.text;for(;i<n.childCount;){let c=n.child(i++);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 Lr(n,e,t,o,i){let r=[];for(let s=0,l=0;s<n.length;s++){let a=n[s],c=l,d=l+=a.size;c>=t||d<=e?r.push(a):(c<e&&r.push(a.slice(0,e-c,o)),i&&(r.push(i),i=void 0),d>t&&r.push(a.slice(t-c,a.size,o)))}return r}function Br(n,e=null){let t=n.domSelectionRange(),o=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),r=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=o.resolve(s),a,c;if(ii(t)){for(a=s;i&&!i.node;)i=i.parent;let p=i.node;if(i&&p.isAtom&&D.isSelectable(p)&&i.parent&&!(p.isInline&&Tg(t.focusNode,t.focusOffset,i.dom))){let u=i.posBefore;c=new D(s==u?l:o.resolve(u))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let p=s,u=s;for(let f=0;f<t.rangeCount;f++){let h=t.getRangeAt(f);p=Math.min(p,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),u=Math.max(u,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(p<0)return null;[a,s]=u==n.state.selection.anchor?[u,p]:[p,u],l=o.resolve(s)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=o.resolve(a);if(!c){let p=e=="pointer"||n.state.selection.head<l.pos&&!r?1:-1;c=Hr(n,d,l,p)}return c}function Yc(n){return n.editable?n.hasFocus():od(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function nt(n,e=!1){let t=n.state.selection;if(ed(n,t),!!Yc(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&le){let o=n.domSelectionRange(),i=n.domObserver.currentSelection;if(o.anchorNode&&i.anchorNode&&Bt(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)t0(n);else{let{anchor:o,head:i}=t,r,s;Zc&&!(t instanceof R)&&(t.$from.parent.inlineContent||(r=Xc(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(s=Xc(n,t.to))),n.docView.setSelection(o,i,n,e),Zc&&(r&&Qc(r),s&&Qc(s)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&e0(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Zc=de||le&&$c<63;function Xc(n,e){let{node:t,offset:o}=n.docView.domFromPos(e,0),i=o<t.childNodes.length?t.childNodes[o]:null,r=o?t.childNodes[o-1]:null;if(de&&i&&i.contentEditable=="false")return Vr(i);if((!i||i.contentEditable=="false")&&(!r||r.contentEditable=="false")){if(i)return Vr(i);if(r)return Vr(r)}}function Vr(n){return n.contentEditable="true",de&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Qc(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function e0(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),o=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=o||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Yc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function t0(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let o=n.cursorWrapper.dom,i=o.nodeName=="IMG";i?t.setStart(o.parentNode,ie(o)+1):t.setStart(o,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&ye&&ht<=11&&(o.disabled=!0,o.disabled=!1)}function ed(n,e){if(e instanceof D){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(td(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else td(n)}function td(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Hr(n,e,t,o){return n.someProp("createSelectionBetween",i=>i(n,e,t))||R.between(e,t,o)}function nd(n){return n.editable&&!n.hasFocus()?!1:od(n)}function od(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 n0(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Bt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Fr(n,e){let{$anchor:t,$head:o}=n.selection,i=e>0?t.max(o):t.min(o),r=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return r&&z.findFrom(r,e)}function bt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function id(n,e,t){let o=n.state.selection;if(o instanceof R)if(t.indexOf("s")>-1){let{$head:i}=o,r=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let s=n.state.doc.resolve(i.pos+r.nodeSize*(e<0?-1:1));return bt(n,new R(o.$anchor,s))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Fr(n.state,e);return i&&i instanceof D?bt(n,i):!1}else if(!(Ae&&t.indexOf("m")>-1)){let i=o.$head,r=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!r||r.isText)return!1;let l=e<0?i.pos-r.nodeSize:i.pos;return r.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?D.isSelectable(r)?bt(n,new D(e<0?n.state.doc.resolve(i.pos-r.nodeSize):i)):Jn?bt(n,new R(n.state.doc.resolve(e<0?l:l+r.nodeSize))):!1:!1}}else return!1;else{if(o instanceof D&&o.node.isInline)return bt(n,new R(e>0?o.$to:o.$from));{let i=Fr(n.state,e);return i?bt(n,i):!1}}}function li(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Qn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Cn(n,e){return e<0?o0(n):i0(n)}function o0(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let i,r,s=!1;for(De&&t.nodeType==1&&o<li(t)&&Qn(t.childNodes[o],-1)&&(s=!0);;)if(o>0){if(t.nodeType!=1)break;{let l=t.childNodes[o-1];if(Qn(l,-1))i=t,r=--o;else if(l.nodeType==3)t=l,o=t.nodeValue.length;else break}}else{if(rd(t))break;{let l=t.previousSibling;for(;l&&Qn(l,-1);)i=t.parentNode,r=ie(l),l=l.previousSibling;if(l)t=l,o=li(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}s?_r(n,t,o):i&&_r(n,i,r)}function i0(n){let e=n.domSelectionRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let i=li(t),r,s;for(;;)if(o<i){if(t.nodeType!=1)break;let l=t.childNodes[o];if(Qn(l,1))r=t,s=++o;else break}else{if(rd(t))break;{let l=t.nextSibling;for(;l&&Qn(l,1);)r=l.parentNode,s=ie(l)+1,l=l.nextSibling;if(l)t=l,o=0,i=li(t);else{if(t=t.parentNode,t==n.dom)break;o=i=0}}}r&&_r(n,r,s)}function rd(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function r0(n,e){for(;n&&e==n.childNodes.length&&!Kn(n);)e=ie(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 s0(n,e){for(;n&&!e&&!Kn(n);)e=ie(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 _r(n,e,t){if(e.nodeType!=3){let r,s;(s=r0(e,t))?(e=s,t=0):(r=s0(e,t))&&(e=r,t=r.nodeValue.length)}let o=n.domSelection();if(!o)return;if(ii(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:i}=n;setTimeout(()=>{n.state==i&&nt(n)},50)}function sd(n,e){let t=n.state.doc.resolve(e);if(!(le||Ag)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let r=n.coordsAtPos(e-1),s=(r.top+r.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(r.left-i.left)>1)return r.left<i.left?"ltr":"rtl"}if(e<t.end()){let r=n.coordsAtPos(e+1),s=(r.top+r.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(r.left-i.left)>1)return r.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function ld(n,e,t){let o=n.state.selection;if(o instanceof R&&!o.empty||t.indexOf("s")>-1||Ae&&t.indexOf("m")>-1)return!1;let{$from:i,$to:r}=o;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Fr(n.state,e);if(s&&s instanceof D)return bt(n,s)}if(!i.parent.inlineContent){let s=e<0?i:r,l=o instanceof Ce?z.near(s,e):z.findFrom(s,e);return l?bt(n,l):!1}return!1}function ad(n,e){if(!(n.state.selection instanceof R))return!0;let{$head:t,$anchor:o,empty:i}=n.state.selection;if(!t.sameParent(o))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let r=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(r&&!r.isText){let s=n.state.tr;return e<0?s.delete(t.pos-r.nodeSize,t.pos):s.delete(t.pos,t.pos+r.nodeSize),n.dispatch(s),!0}return!1}function cd(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function l0(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;cd(n,o,"true"),setTimeout(()=>cd(n,o,"false"),20)}return!1}function a0(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function c0(n,e){let t=e.keyCode,o=a0(e);if(t==8||Ae&&t==72&&o=="c")return ad(n,-1)||Cn(n,-1);if(t==46&&!e.shiftKey||Ae&&t==68&&o=="c")return ad(n,1)||Cn(n,1);if(t==13||t==27)return!0;if(t==37||Ae&&t==66&&o=="c"){let i=t==37?sd(n,n.state.selection.from)=="ltr"?-1:1:-1;return id(n,i,o)||Cn(n,i)}else if(t==39||Ae&&t==70&&o=="c"){let i=t==39?sd(n,n.state.selection.from)=="ltr"?1:-1:1;return id(n,i,o)||Cn(n,i)}else{if(t==38||Ae&&t==80&&o=="c")return ld(n,-1,o)||Cn(n,-1);if(t==40||Ae&&t==78&&o=="c")return l0(n)||ld(n,1,o)||Cn(n,1);if(o==(Ae?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function dd(n,e){n.someProp("transformCopied",f=>{e=f(e,n)});let t=[],{content:o,openStart:i,openEnd:r}=e;for(;i>1&&r>1&&o.childCount==1&&o.firstChild.childCount==1;){i--,r--;let f=o.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),o=f.content}let s=n.someProp("clipboardSerializer")||zt.fromSchema(n.state.schema),l=yd(),a=l.createElement("div");a.appendChild(s.serializeFragment(o,{document:l}));let c=a.firstChild,d,p=0;for(;c&&c.nodeType==1&&(d=gd[c.nodeName.toLowerCase()]);){for(let f=d.length-1;f>=0;f--){let h=l.createElement(d[f]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),p++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${r}${p?` -${p}`:""} ${JSON.stringify(t)}`);let u=n.someProp("clipboardTextSerializer",f=>f(e,n))||e.content.textBetween(0,e.content.size,`
914
+
915
+ `);return{dom:a,text:u,slice:e}}function pd(n,e,t,o,i){let r=i.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=e&&(o||r||!t);if(a){if(n.someProp("transformPastedText",u=>{e=u(e,r||o,n)}),r)return e?new j(M.from(n.state.schema.text(e.replace(/\r\n?/g,`
916
+ `))),0,0):j.empty;let p=n.someProp("clipboardTextParser",u=>u(e,i,o,n));if(p)l=p;else{let u=i.marks(),{schema:f}=n.state,h=zt.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let b=s.appendChild(document.createElement("p"));g&&b.appendChild(h.serializeNode(f.text(g,u)))})}}else n.someProp("transformPastedHTML",p=>{t=p(t,n)}),s=f0(t),Jn&&h0(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let p=+d[3];p>0;p--){let u=s.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;s=u}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Dt.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||d),context:i,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!d0.test(u.parentNode.nodeName)?{ignore:!0}:null}})),d)l=m0(md(l,+d[1],+d[2]),d[4]);else if(l=j.maxOpen(p0(l.content,i),!0),l.openStart||l.openEnd){let p=0,u=0;for(let f=l.content.firstChild;p<l.openStart&&!f.type.spec.isolating;p++,f=f.firstChild);for(let f=l.content.lastChild;u<l.openEnd&&!f.type.spec.isolating;u++,f=f.lastChild);l=md(l,p,u)}return n.someProp("transformPasted",p=>{l=p(l,n)}),l}const d0=/^(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 p0(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),r,s=[];if(n.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&r.length&&fd(a,r,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=hd(s[s.length-1],r.length));let d=ud(l,a);s.push(d),i=i.matchType(d.type),r=a}}),s)return M.from(s)}return n}function ud(n,e,t=0){for(let o=e.length-1;o>=t;o--)n=e[o].create(null,M.from(n));return n}function fd(n,e,t,o,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let r=fd(n,e,t,o.lastChild,i+1);if(r)return o.copy(o.content.replaceChild(o.childCount-1,r));if(o.contentMatchAt(o.childCount).matchType(i==n.length-1?t.type:n[i+1]))return o.copy(o.content.append(M.from(ud(t,n,i+1))))}}function hd(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,hd(n.lastChild,e-1)),o=n.contentMatchAt(n.childCount).fillBefore(M.empty,!0);return n.copy(t.append(o))}function Gr(n,e,t,o,i,r){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(r=0),i<o-1&&(l=Gr(l,e,t,o,i+1,r)),i>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,r<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(M.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function md(n,e,t){return e<n.openStart&&(n=new j(Gr(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new j(Gr(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const gd={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 bd=null;function yd(){return bd||(bd=document.implementation.createHTMLDocument("title"))}let Wr=null;function u0(n){let e=window.trustedTypes;return e?(Wr||(Wr=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Wr.createHTML(n)):n}function f0(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=yd().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(n),i;if((i=o&&gd[o[1].toLowerCase()])&&(n=i.map(r=>"<"+r+">").join("")+n+i.map(r=>"</"+r+">").reverse().join("")),t.innerHTML=u0(n),i)for(let r=0;r<i.length;r++)t=t.querySelector(i[r])||t;return t}function h0(n){let e=n.querySelectorAll(le?"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 m0(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:i,openStart:r,openEnd:s}=n;for(let l=o.length-2;l>=0;l-=2){let a=t.nodes[o[l]];if(!a||a.hasRequiredAttrs())break;i=M.from(a.create(o[l+1],i)),r++,s++}return new j(i,r,s)}const pe={},ue={},g0={touchstart:!0,touchmove:!0};class b0{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 y0(n){for(let e in pe){let t=pe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{v0(n,o)&&!Ur(n,o)&&(n.editable||!(o.type in ue))&&t(n,o)},g0[e]?{passive:!0}:void 0)}de&&n.dom.addEventListener("input",()=>null),qr(n)}function yt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function x0(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 qr(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>Ur(n,o))})}function Ur(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function v0(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 w0(n,e){!Ur(n,e)&&pe[e.type]&&(n.editable||!(e.type in ue))&&pe[e.type](n,e)}ue.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!vd(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ze&&le&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),wn&&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",i=>i(n,Vt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",o=>o(n,t))||c0(n,t)?t.preventDefault():yt(n,"key")},ue.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},ue.keypress=(n,e)=>{let t=e;if(vd(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ae&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let o=n.state.selection;if(!(o instanceof R)||!o.$from.sameParent(o.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",r=>r(n,o.$from.pos,o.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function ai(n){return{left:n.clientX,top:n.clientY}}function S0(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function Kr(n,e,t,o,i){if(o==-1)return!1;let r=n.state.doc.resolve(o);for(let s=r.depth+1;s>0;s--)if(n.someProp(e,l=>s>r.depth?l(n,t,r.nodeAfter,r.before(s),i,!0):l(n,t,r.node(s),r.before(s),i,!1)))return!0;return!1}function kn(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 C0(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&D.isSelectable(o)?(kn(n,new D(t)),!0):!1}function k0(n,e){if(e==-1)return!1;let t=n.state.selection,o,i;t instanceof D&&(o=t.node);let r=n.state.doc.resolve(e);for(let s=r.depth+1;s>0;s--){let l=s>r.depth?r.nodeAfter:r.node(s);if(D.isSelectable(l)){o&&t.$from.depth>0&&s>=t.$from.depth&&r.before(t.$from.depth+1)==t.$from.pos?i=r.before(t.$from.depth):i=r.before(s);break}}return i!=null?(kn(n,D.create(n.state.doc,i)),!0):!1}function T0(n,e,t,o,i){return Kr(n,"handleClickOn",e,t,o)||n.someProp("handleClick",r=>r(n,e,o))||(i?k0(n,t):C0(n,t))}function E0(n,e,t,o){return Kr(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",i=>i(n,e,o))}function M0(n,e,t,o){return Kr(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",i=>i(n,e,o))||A0(n,t,o)}function A0(n,e,t){if(t.button!=0)return!1;let o=n.state.doc;if(e==-1)return o.inlineContent?(kn(n,R.create(o,0,o.content.size)),!0):!1;let i=o.resolve(e);for(let r=i.depth+1;r>0;r--){let s=r>i.depth?i.nodeAfter:i.node(r),l=i.before(r);if(s.inlineContent)kn(n,R.create(o,l+1,l+1+s.content.size));else if(D.isSelectable(s))kn(n,D.create(o,l));else continue;return!0}}function Jr(n){return ci(n)}const xd=Ae?"metaKey":"ctrlKey";pe.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let o=Jr(n),i=Date.now(),r="singleClick";i-n.input.lastClick.time<500&&S0(t,n.input.lastClick)&&!t[xd]&&(n.input.lastClick.type=="singleClick"?r="doubleClick":n.input.lastClick.type=="doubleClick"&&(r="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:r};let s=n.posAtCoords(ai(t));s&&(r=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new j0(n,s,t,!!o)):(r=="doubleClick"?E0:M0)(n,s.pos,s.inside,t)?t.preventDefault():yt(n,"pointer"))};class j0{constructor(e,t,o,i){this.view=e,this.pos=t,this.event=o,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!o[xd],this.allowDefault=o.shiftKey;let r,s;if(t.inside>-1)r=e.state.doc.nodeAt(t.inside),s=t.inside;else{let d=e.state.doc.resolve(t.pos);r=d.parent,s=d.depth?d.before():0}const l=i?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 D&&c.from<=s&&c.to>s)&&(this.mightDrag={node:r,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&De&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),yt(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(()=>nt(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(ai(e))),this.updateAllowDefault(e),this.allowDefault||!t?yt(this.view,"pointer"):T0(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||de&&this.mightDrag&&!this.mightDrag.node.isAtom||le&&!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)?(kn(this.view,z.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):yt(this.view,"pointer")}move(e){this.updateAllowDefault(e),yt(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)}}pe.touchstart=n=>{n.input.lastTouch=Date.now(),Jr(n),yt(n,"pointer")},pe.touchmove=n=>{n.input.lastTouch=Date.now(),yt(n,"pointer")},pe.contextmenu=n=>Jr(n);function vd(n,e){return n.composing?!0:de&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const $0=ze?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 R&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),ci(n,!0),n.markCursor=null;else if(ci(n,!e.selection.empty),De&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let o=n.domSelectionRange();for(let i=o.focusNode,r=o.focusOffset;i&&i.nodeType==1&&r!=0;){let s=r<0?i.lastChild:i.childNodes[r-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,r=-1}}n.input.composing=!0}wd(n,$0)},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++,wd(n,20))};function wd(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>ci(n),e))}function Sd(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=N0());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function P0(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Cg(e.focusNode,e.focusOffset),o=kg(e.focusNode,e.focusOffset);if(t&&o&&t!=o){let i=o.pmViewDesc,r=n.domObserver.lastChangedTextNode;if(t==r||o==r)return r;if(!i||!i.isText(o.nodeValue))return o;if(n.input.compositionNode==o){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return o}}return t||o}function N0(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function ci(n,e=!1){if(!(ze&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Sd(n),e||n.docView&&n.docView.dirty){let t=Br(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 O0(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(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),o.removeAllRanges(),o.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const eo=ye&&ht<15||wn&&jg<604;pe.copy=ue.cut=(n,e)=>{let t=e,o=n.state.selection,i=t.type=="cut";if(o.empty)return;let r=eo?null:t.clipboardData,s=o.content(),{dom:l,text:a}=dd(n,s);r?(t.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",a)):O0(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function I0(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function D0(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 i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),o.parentNode&&o.parentNode.removeChild(o),t?to(n,o.value,null,i,e):to(n,o.textContent,o.innerHTML,i,e)},50)}function to(n,e,t,o,i){let r=pd(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,r||j.empty)))return!0;if(!r)return!1;let s=I0(r),l=s?n.state.tr.replaceSelectionWith(s,o):n.state.tr.replaceSelection(r);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Cd(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&&!ze)return;let o=eo?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&to(n,Cd(o),o.getData("text/html"),i,t)?t.preventDefault():D0(n,t)};class kd{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}}const Td=Ae?"altKey":"ctrlKey";pe.dragstart=(n,e)=>{let t=e,o=n.input.mouseDown;if(o&&o.done(),!t.dataTransfer)return;let i=n.state.selection,r=i.empty?null:n.posAtCoords(ai(t)),s;if(!(r&&r.pos>=i.from&&r.pos<=(i instanceof D?i.to-1:i.to))){if(o&&o.mightDrag)s=D.create(n.state.doc,o.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let p=n.docView.nearestDesc(t.target,!0);p&&p.node.type.spec.draggable&&p!=n.docView&&(s=D.create(n.state.doc,p.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:d}=dd(n,l);(!t.dataTransfer.files.length||!le||$c>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(eo?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",eo||t.dataTransfer.setData("text/plain",c),n.dragging=new kd(d,!t[Td],s)},pe.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 i=n.posAtCoords(ai(t));if(!i)return;let r=n.state.doc.resolve(i.pos),s=o&&o.slice;s?n.someProp("transformPasted",h=>{s=h(s,n)}):s=pd(n,Cd(t.dataTransfer),eo?null:t.dataTransfer.getData("text/html"),!1,r);let l=!!(o&&!t[Td]);if(n.someProp("handleDrop",h=>h(n,t,s||j.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?$m(n.state.doc,r.pos,s):r.pos;a==null&&(a=r.pos);let c=n.state.tr;if(l){let{node:h}=o;h?h.replace(c):c.deleteSelection()}let d=c.mapping.map(a),p=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,u=c.doc;if(p?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(u))return;let f=c.doc.resolve(d);if(p&&D.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new D(f));else{let h=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((g,b,x,C)=>h=C),c.setSelection(Hr(n,f,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},pe.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())&&nt(n)},20))},pe.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)},pe.beforeinput=(n,e)=>{if(le&&ze&&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,Vt(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in ue)pe[n]=ue[n];function no(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 di{constructor(e,t){this.toDOM=e,this.spec=t||Gt,this.side=this.spec.side||0}map(e,t,o,i){let{pos:r,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new xe(r-o,r-o,this)}valid(){return!0}eq(e){return this==e||e instanceof di&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&no(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class xt{constructor(e,t){this.attrs=e,this.spec=t||Gt}map(e,t,o,i){let r=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-o,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-o;return r>=s?null:new xe(r,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof xt&&no(this.attrs,e.attrs)&&no(this.spec,e.spec)}static is(e){return e.type instanceof xt}destroy(){}}class Yr{constructor(e,t){this.attrs=e,this.spec=t||Gt}map(e,t,o,i){let r=e.mapResult(t.from+i,1);if(r.deleted)return null;let s=e.mapResult(t.to+i,-1);return s.deleted||s.pos<=r.pos?null:new xe(r.pos-o,s.pos-o,this)}valid(e,t){let{index:o,offset:i}=e.content.findIndex(t.from),r;return i==t.from&&!(r=e.child(o)).isText&&i+r.nodeSize==t.to}eq(e){return this==e||e instanceof Yr&&no(this.attrs,e.attrs)&&no(this.spec,e.spec)}destroy(){}}class xe{constructor(e,t,o){this.from=e,this.to=t,this.type=o}copy(e,t){return new xe(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 xe(e,e,new di(t,o))}static inline(e,t,o,i){return new xe(e,t,new xt(o,i))}static node(e,t,o,i){return new xe(e,t,new Yr(o,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof xt}get widget(){return this.type instanceof di}}const Tn=[],Gt={};class J{constructor(e,t){this.local=e.length?e:Tn,this.children=t.length?t:Tn}static create(e,t){return t.length?pi(t,e,0,Gt):ae}find(e,t,o){let i=[];return this.findInner(e??0,t??1e9,i,0,o),i}findInner(e,t,o,i,r){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!r||r(l.spec))&&o.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,o,i+l,r)}}map(e,t,o){return this==ae||e.maps.length==0?this:this.mapInner(e,t,0,0,o||Gt)}mapInner(e,t,o,i,r){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,o,i);a&&a.type.valid(t,a)?(s||(s=[])).push(a):r.onRemove&&r.onRemove(this.local[l].spec)}return this.children.length?z0(this.children,s||[],e,t,o,i,r):s?new J(s.sort(Wt),Tn):ae}add(e,t){return t.length?this==ae?J.create(e,t):this.addInner(e,t,0):this}addInner(e,t,o){let i,r=0;e.forEach((l,a)=>{let c=a+o,d;if(d=Md(t,l,c)){for(i||(i=this.children.slice());r<i.length&&i[r]<a;)r+=3;i[r]==a?i[r+2]=i[r+2].addInner(l,d,c+1):i.splice(r,0,a,a+l.nodeSize,pi(d,l,c+1,Gt)),r+=3}});let s=Ed(r?Ad(t):t,-o);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new J(s.length?this.local.concat(s).sort(Wt):this.local,i||this.children)}remove(e){return e.length==0||this==ae?this:this.removeInner(e,0)}removeInner(e,t){let o=this.children,i=this.local;for(let r=0;r<o.length;r+=3){let s,l=o[r]+t,a=o[r+1]+t;for(let d=0,p;d<e.length;d++)(p=e[d])&&p.from>l&&p.to<a&&(e[d]=null,(s||(s=[])).push(p));if(!s)continue;o==this.children&&(o=this.children.slice());let c=o[r+2].removeInner(s,l+1);c!=ae?o[r+2]=c:(o.splice(r,3),r-=3)}if(i.length){for(let r=0,s;r<e.length;r++)if(s=e[r])for(let l=0;l<i.length;l++)i[l].eq(s,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return o==this.children&&i==this.local?this:i.length||o.length?new J(i,o):ae}forChild(e,t){if(this==ae)return this;if(t.isLeaf)return J.empty;let o,i;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,s=r+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>r&&a.type instanceof xt){let c=Math.max(r,a.from)-r,d=Math.min(s,a.to)-r;c<d&&(i||(i=[])).push(a.copy(c,d))}}if(i){let l=new J(i.sort(Wt),Tn);return o?new vt([l,o]):l}return o||ae}eq(e){if(this==e)return!0;if(!(e instanceof J)||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 Zr(this.localsInner(e))}localsInner(e){if(this==ae)return Tn;if(e.inlineContent||!this.local.some(xt.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof xt||t.push(this.local[o]);return t}forEachSet(e){e(this)}}J.empty=new J([],[]),J.removeOverlap=Zr;const ae=J.empty;class vt{constructor(e){this.members=e}map(e,t){const o=this.members.map(i=>i.map(e,t,Gt));return vt.from(o)}forChild(e,t){if(t.isLeaf)return J.empty;let o=[];for(let i=0;i<this.members.length;i++){let r=this.members[i].forChild(e,t);r!=ae&&(r instanceof vt?o=o.concat(r.members):o.push(r))}return vt.from(o)}eq(e){if(!(e instanceof vt)||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 i=0;i<this.members.length;i++){let r=this.members[i].localsInner(e);if(r.length)if(!t)t=r;else{o&&(t=t.slice(),o=!1);for(let s=0;s<r.length;s++)t.push(r[s])}}return t?Zr(o?t:t.sort(Wt)):Tn}static from(e){switch(e.length){case 0:return ae;case 1:return e[0];default:return new vt(e.every(t=>t instanceof J)?e:e.reduce((t,o)=>t.concat(o instanceof J?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function z0(n,e,t,o,i,r,s){let l=n.slice();for(let c=0,d=r;c<t.maps.length;c++){let p=0;t.maps[c].forEach((u,f,h,g)=>{let b=g-h-(f-u);for(let x=0;x<l.length;x+=3){let C=l[x+1];if(C<0||u>C+d-p)continue;let y=l[x]+d-p;f>=y?l[x+1]=u<=y?-2:-1:u>=d&&b&&(l[x]+=b,l[x+1]+=b)}p+=b}),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),p=d-i;if(p<0||p>=o.content.size){a=!0;continue}let u=t.map(n[c+1]+r,-1),f=u-i,{index:h,offset:g}=o.content.findIndex(p),b=o.maybeChild(h);if(b&&g==p&&g+b.nodeSize==f){let x=l[c+2].mapInner(t,b,d+1,n[c]+r+1,s);x!=ae?(l[c]=p,l[c+1]=f,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=R0(l,n,e,t,i,r,s),d=pi(c,o,0,s);e=d.local;for(let p=0;p<l.length;p+=3)l[p+1]<0&&(l.splice(p,3),p-=3);for(let p=0,u=0;p<d.children.length;p+=3){let f=d.children[p];for(;u<l.length&&l[u]<f;)u+=3;l.splice(u,0,d.children[p],d.children[p+1],d.children[p+2])}}return new J(e.sort(Wt),l)}function Ed(n,e){if(!e||!n.length)return n;let t=[];for(let o=0;o<n.length;o++){let i=n[o];t.push(new xe(i.from+e,i.to+e,i.type))}return t}function R0(n,e,t,o,i,r,s){function l(a,c){for(let d=0;d<a.local.length;d++){let p=a.local[d].map(o,i,c);p?t.push(p):s.onRemove&&s.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+r+1);return t}function Md(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,i=null;for(let r=0,s;r<n.length;r++)(s=n[r])&&s.from>t&&s.to<o&&((i||(i=[])).push(s),n[r]=null);return i}function Ad(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function pi(n,e,t,o){let i=[],r=!1;e.forEach((l,a)=>{let c=Md(n,l,a+t);if(c){r=!0;let d=pi(c,l,t+a+1,o);d!=ae&&i.push(a,a+l.nodeSize,d)}});let s=Ed(r?Ad(n):n,-t).sort(Wt);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(o.onRemove&&o.onRemove(s[l].spec),s.splice(l--,1));return s.length||i.length?new J(s,i):ae}function Wt(n,e){return n.from-e.from||n.to-e.to}function Zr(n){let e=n;for(let t=0;t<e.length-1;t++){let o=e[t];if(o.from!=o.to)for(let i=t+1;i<e.length;i++){let r=e[i];if(r.from==o.from){r.to!=o.to&&(e==n&&(e=n.slice()),e[i]=r.copy(r.from,o.to),jd(e,i+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),jd(e,i,o.copy(r.from,o.to)));break}}}return e}function jd(n,e,t){for(;e<n.length&&Wt(t,n[e])>0;)e++;n.splice(e,0,t)}function Xr(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=ae&&e.push(o)}),n.cursorWrapper&&e.push(J.create(n.state.doc,[n.cursorWrapper.deco])),vt.from(e)}const L0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},B0=ye&&ht<=11;class V0{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 H0{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new V0,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(o=>{for(let i=0;i<o.length;i++)this.queue.push(o[i]);ye&&ht<=11&&o.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),B0&&(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,L0)),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(nd(this.view)){if(this.suppressingSelectionUpdates)return nt(this.view);if(ye&&ht<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Bt(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=Un(r))t.add(r);for(let r=e.anchorNode;r;r=Un(r))if(t.has(r)){o=r;break}let i=o&&this.view.docView.nearestDesc(o);if(i&&i.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(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&nd(e)&&!this.ignoreSelectionChange(o),r=-1,s=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let p=this.registerMutation(t[d],a);p&&(r=r<0?p.from:Math.min(p.from,r),s=s<0?p.to:Math.max(p.to,s),p.typeOver&&(l=!0))}if(De&&a.length){let d=a.filter(p=>p.nodeName=="BR");if(d.length==2){let[p,u]=d;p.parentNode&&p.parentNode.parentNode==u.parentNode?u.remove():p.remove()}else{let{focusNode:p}=this.currentSelection;for(let u of d){let f=u.parentNode;f&&f.nodeName=="LI"&&(!p||G0(e,p)!=f)&&u.remove()}}}let c=null;r<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&ii(o)&&(c=Br(e))&&c.eq(z.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,nt(e),this.currentSelection.set(o),e.scrollToSelection()):(r>-1||i)&&(r>-1&&(e.docView.markDirty(r,s),F0(e)),this.handleDOMChange(r,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(o)||nt(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 p=e.addedNodes[d];t.push(p),p.nodeType==3&&(this.lastChangedTextNode=p)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return{from:o.posBefore,to:o.posAfter};let i=e.previousSibling,r=e.nextSibling;if(ye&&ht<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:p,nextSibling:u}=e.addedNodes[d];(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(i=p),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(r=u)}let s=i&&i.parentNode==e.target?ie(i)+1:0,l=o.localPosFromDOM(e.target,s,-1),a=r&&r.parentNode==e.target?ie(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 $d=new WeakMap,Pd=!1;function F0(n){if(!$d.has(n)&&($d.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=De,Pd)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."),Pd=!0}}function Nd(n,e){let t=e.startContainer,o=e.startOffset,i=e.endContainer,r=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return Bt(s.node,s.offset,i,r)&&([t,o,i,r]=[i,r,t,o]),{anchorNode:t,anchorOffset:o,focusNode:i,focusOffset:r}}function _0(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Nd(n,i)}let t;function o(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",o,!0),t?Nd(n,t):null}function G0(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 W0(n,e,t){let{node:o,fromOffset:i,toOffset:r,from:s,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],ii(a)||c.push({node:a.focusNode,offset:a.focusOffset})),le&&n.input.lastKeyCode===8)for(let b=r;b>i;b--){let x=o.childNodes[b-1],C=x.pmViewDesc;if(x.nodeName=="BR"&&!C){r=b;break}if(!C||C.size)break}let p=n.state.doc,u=n.someProp("domParser")||Dt.fromSchema(n.state.schema),f=p.resolve(s),h=null,g=u.parse(o,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:i,to:r,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:q0,context:f});if(c&&c[0].pos!=null){let b=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=b),h={anchor:b+s,head:x+s}}return{doc:g,sel:h,from:s,to:l}}function q0(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 U0=/^(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 K0(n,e,t,o,i){let r=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,A=Br(n,T);if(A&&!n.state.selection.eq(A)){if(le&&ze&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",P=>P(n,Vt(13,"Enter"))))return;let $=n.state.tr.setSelection(A);T=="pointer"?$.setMeta("pointer",!0):T=="key"&&$.scrollIntoView(),r&&$.setMeta("composition",r),n.dispatch($)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=W0(n,e,t),d=n.state.doc,p=d.slice(c.from,c.to),u,f;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,f="end"):(u=n.state.selection.from,f="start"),n.input.lastKeyCode=null;let h=Z0(p.content,c.doc.content,c.from,u,f);if(h&&n.input.domChangeCount++,(wn&&n.input.lastIOSEnter>Date.now()-225||ze)&&i.some(T=>T.nodeType==1&&!U0.test(T.nodeName))&&(!h||h.endA>=h.endB)&&n.someProp("handleKeyDown",T=>T(n,Vt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!h)if(o&&a instanceof R&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=Od(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let A=n.state.tr.setSelection(T);r&&A.setMeta("composition",r),n.dispatch(A)}}return}n.state.selection.from<n.state.selection.to&&h.start==h.endB&&n.state.selection instanceof R&&(h.start>n.state.selection.from&&h.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?h.start=n.state.selection.from:h.endA<n.state.selection.to&&h.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(h.endB+=n.state.selection.to-h.endA,h.endA=n.state.selection.to)),ye&&ht<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>c.from&&c.doc.textBetween(h.start-c.from-1,h.start-c.from+1)=="  "&&(h.start--,h.endA--,h.endB--);let g=c.doc.resolveNoCache(h.start-c.from),b=c.doc.resolveNoCache(h.endB-c.from),x=d.resolve(h.start),C=g.sameParent(b)&&g.parent.inlineContent&&x.end()>=h.endA,y;if((wn&&n.input.lastIOSEnter>Date.now()-225&&(!C||i.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!C&&g.pos<c.doc.content.size&&!g.sameParent(b)&&(y=z.findFrom(c.doc.resolve(g.pos+1),1,!0))&&y.head==b.pos)&&n.someProp("handleKeyDown",T=>T(n,Vt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>h.start&&Y0(d,h.start,h.endA,g,b)&&n.someProp("handleKeyDown",T=>T(n,Vt(8,"Backspace")))){ze&&le&&n.domObserver.suppressSelectionUpdates();return}le&&ze&&h.endB==h.start&&(n.input.lastAndroidDelete=Date.now()),ze&&!C&&g.start()!=b.start()&&b.parentOffset==0&&g.depth==b.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,b=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,Vt(13,"Enter"))})},20));let v=h.start,k=h.endA,w,S,E;if(C){if(g.pos==b.pos)ye&&ht<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>nt(n),20)),w=n.state.tr.delete(v,k),S=d.resolve(h.start).marksAcross(d.resolve(h.endA));else if(h.endA==h.endB&&(E=J0(g.parent.content.cut(g.parentOffset,b.parentOffset),x.parent.content.cut(x.parentOffset,h.endA-x.start()))))w=n.state.tr,E.type=="add"?w.addMark(v,k,E.mark):w.removeMark(v,k,E.mark);else if(g.parent.child(g.index()).isText&&g.index()==b.index()-(b.textOffset?0:1)){let T=g.parent.textBetween(g.parentOffset,b.parentOffset);if(n.someProp("handleTextInput",A=>A(n,v,k,T)))return;w=n.state.tr.insertText(T,v,k)}}if(w||(w=n.state.tr.replace(v,k,c.doc.slice(h.start-c.from,h.endB-c.from))),c.sel){let T=Od(n,w.doc,c.sel);T&&!(le&&ze&&n.composing&&T.empty&&(h.start!=h.endB||n.input.lastAndroidDelete<Date.now()-100)&&(T.head==v||T.head==w.mapping.map(k)-1)||ye&&T.empty&&T.head==v)&&w.setSelection(T)}S&&w.ensureMarks(S),r&&w.setMeta("composition",r),n.dispatch(w.scrollIntoView())}function Od(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Hr(n,e.resolve(t.anchor),e.resolve(t.head))}function J0(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,i=t,r=o,s,l,a;for(let d=0;d<o.length;d++)i=o[d].removeFromSet(i);for(let d=0;d<t.length;d++)r=t[d].removeFromSet(r);if(i.length==1&&r.length==0)l=i[0],s="add",a=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&r.length==1)l=r[0],s="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(M.from(c).eq(n))return{mark:l,type:s}}function Y0(n,e,t,o,i){if(t-e<=i.pos-o.pos||Qr(o,!0,!1)<i.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 s=n.resolve(Qr(r,!0,!0));return!s.parent.isTextblock||s.pos>t||Qr(s,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(s.parent.content)}function Qr(n,e,t){let o=n.depth,i=e?n.end():n.pos;for(;o>0&&(e||n.indexAfter(o)==n.node(o).childCount);)o--,i++,e=!1;if(t){let r=n.node(o).maybeChild(n.indexAfter(o));for(;r&&!r.isLeaf;)r=r.firstChild,i++}return i}function Z0(n,e,t,o,i){let r=n.findDiffStart(e,t);if(r==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,r-Math.min(s,l));o-=s+a-r}if(s<r&&n.size<e.size){let a=o<=r&&o>=s?r-o:0;r-=a,r&&r<e.size&&Id(e.textBetween(r-1,r+1))&&(r+=a?1:-1),l=r+(l-s),s=r}else if(l<r){let a=o<=r&&o>=l?r-o:0;r-=a,r&&r<n.size&&Id(n.textBetween(r-1,r+1))&&(r+=a?1:-1),s=r+(s-l),l=r}return{start:r,endA:s,endB:l}}function Id(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 X0{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 b0,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Bd),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),zd(this),this.nodeViews=Ld(this),this.docView=Gc(this.state.doc,Dd(this),Xr(this),this.dom,this),this.domObserver=new H0(this,(o,i,r,s)=>K0(this,o,i,r,s)),this.domObserver.start(),y0(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&&qr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Bd),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 i=this.state,r=!1,s=!1;e.storedMarks&&this.composing&&(Sd(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=Ld(this);e1(f,this.nodeViews)&&(this.nodeViews=f,r=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&qr(this),this.editable=Rd(this),zd(this);let a=Xr(this),c=Dd(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",p=r||!this.docView.matchesNode(e.doc,c,a);(p||!e.selection.eq(i.selection))&&(s=!0);let u=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Ng(this);if(s){this.domObserver.stop();let f=p&&(ye||le)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Q0(i.selection,e.selection);if(p){let h=le?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=P0(this)),(r||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Gc(e.doc,c,a,this.dom,this)),h&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&n0(this))?nt(this,f):(ed(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((o=this.dragging)===null||o===void 0)&&o.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():u&&Og(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof D){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Pc(this,t.getBoundingClientRect(),e)}else Pc(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,i=-1;if(this.state.doc.nodeAt(o.from)==o.node)i=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&&(i=r)}this.dragging=new kd(e.slice,e.move,i<0?void 0:D.create(this.state.doc,i))}someProp(e,t){let o=this._props&&this._props[e],i;if(o!=null&&(i=t?t(o):o))return i;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(i=t?t(l):l))return i}let r=this.state.plugins;if(r)for(let s=0;s<r.length;s++){let l=r[s].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(ye){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&&Ig(this.dom),nt(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 Bg(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 i=this.docView.posFromDOM(e,t,o);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Gg(this,t||this.state,e)}pasteHTML(e,t){return to(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return to(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(x0(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Xr(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,wg())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return w0(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&&Eg(this.dom.ownerDocument)==this.dom&&_0(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Dd(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"),[xe.node(0,n.state.doc.content.size,e)]}function zd(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:xe.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 Q0(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 i in o)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=o[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function e1(n,e){let t=0,o=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)o++;return t!=o}function Bd(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 es,ts;if(typeof WeakMap<"u"){let n=new WeakMap;es=e=>n.get(e),ts=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;es=o=>{for(let i=0;i<n.length;i+=2)if(n[i]==o)return n[i+1]},ts=(o,i)=>(t==10&&(t=0),n[t++]=o,n[t++]=i)}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,i=e/this.width|0;let r=o+1,s=i+1;for(let l=1;r<this.width&&this.map[e+l]==t;l++)r++;for(let l=1;s<this.height&&this.map[e+this.width*l]==t;l++)s++;return{left:o,top:i,right:r,bottom:s}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:o,right:i,top:r,bottom:s}=this.findCell(n);return e=="horiz"?(t<0?o==0:i==this.width)?null:this.map[r*this.width+(t<0?o-1:i)]:(t<0?r==0:s==this.height)?null:this.map[o+this.width*(t<0?r-1:s)]}rectBetween(n,e){const{left:t,right:o,top:i,bottom:r}=this.findCell(n),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,s),top:Math.min(i,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 i=n.left;i<n.right;i++){const r=o*this.width+i,s=this.map[r];t[s]||(t[s]=!0,!(i==n.left&&i&&this.map[r-1]==s||o==n.top&&o&&this.map[r-this.width]==s)&&e.push(s))}return e}positionAt(n,e,t){for(let o=0,i=0;;o++){const r=i+t.child(o).nodeSize;if(o==n){let s=e+n*this.width;const l=(n+1)*this.width;for(;s<l&&this.map[s]<i;)s++;return s==l?r-1:this.map[s]}i=r}}static get(n){return es(n)||ts(n,t1(n))}};function t1(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=n1(n),t=n.childCount,o=[];let i=0,r=null;const s=[];for(let c=0,d=e*t;c<d;c++)o[c]=0;for(let c=0,d=0;c<t;c++){const p=n.child(c);d++;for(let h=0;;h++){for(;i<o.length&&o[i]!=0;)i++;if(h==p.childCount)break;const g=p.child(h),{colspan:b,rowspan:x,colwidth:C}=g.attrs;for(let y=0;y<x;y++){if(y+c>=t){(r||(r=[])).push({type:"overlong_rowspan",pos:d,n:x-y});break}const v=i+y*e;for(let k=0;k<b;k++){o[v+k]==0?o[v+k]=d:(r||(r=[])).push({type:"collision",row:c,pos:d,n:b-k});const w=C&&C[k];if(w){const S=(v+k)%e*2,E=s[S];E==null||E!=w&&s[S+1]==1?(s[S]=w,s[S+1]=1):E==w&&s[S+1]++}}}i+=b,d+=g.nodeSize}const u=(c+1)*e;let f=0;for(;i<u;)o[i++]==0&&f++;f&&(r||(r=[])).push({type:"missing",row:c,n:f}),d++}const l=new Z(e,t,o,r);let a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<t&&(a=!0);return a&&o1(l,s,n),l}function n1(n){let e=-1,t=!1;for(let o=0;o<n.childCount;o++){const i=n.child(o);let r=0;if(t)for(let s=0;s<o;s++){const l=n.child(s);for(let a=0;a<l.childCount;a++){const c=l.child(a);s+c.attrs.rowspan>o&&(r+=c.attrs.colspan)}}for(let s=0;s<i.childCount;s++){const l=i.child(s);r+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=r:e!=r&&(e=Math.max(e,r))}return e}function o1(n,e,t){n.problems||(n.problems=[]);const o={};for(let i=0;i<n.map.length;i++){const r=n.map[i];if(o[r])continue;o[r]=!0;const s=t.nodeAt(r);if(!s)throw new RangeError(`No cell with offset ${r} found`);let l=null;const a=s.attrs;for(let c=0;c<a.colspan;c++){const d=(i+c)%n.width,p=e[d*2];p!=null&&(!a.colwidth||a.colwidth[c]!=p)&&((l||(l=i1(a)))[c]=p)}l&&n.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:l})}}function i1(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Vd(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),o=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(s=>Number(s)):null,i=Number(n.getAttribute("colspan")||1),r={colspan:i,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:o&&o.length==i?o:null};for(const s in e){const l=e[s].getFromDOM,a=l&&l(n);a!=null&&(r[s]=a)}return r}function Hd(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 i=e[o].setDOMAttr;i&&i(n.attrs[o],t)}return t}function r1(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=>Vd(o,e)}],toDOM(o){return["td",Hd(o,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:o=>Vd(o,e)}],toDOM(o){return["th",Hd(o,e),0]}}}}function qe(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const o=n.nodes[t],i=o.spec.tableRole;i&&(e[i]=o)}}return e}var wt=new Wn("selectingCells");function oo(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 ui(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 ns(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=oo(e.$head)||s1(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function s1(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 is(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function l1(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function rs(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Fd(n,e,t){const o=n.node(-1),i=Z.get(o),r=n.start(-1),s=i.nextCell(n.pos-r,e,t);return s==null?null:n.node(0).resolve(r+s)}function En(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(i=>i>0)||(o.colwidth=null)),o}var Q=class rt extends z{constructor(e,t=e){const o=e.node(-1),i=Z.get(o),r=e.start(-1),s=i.rectBetween(e.pos-r,t.pos-r),l=e.node(0),a=i.cellsInRect(s).filter(d=>d!=t.pos-r);a.unshift(t.pos-r);const c=a.map(d=>{const p=o.nodeAt(d);if(!p)throw RangeError(`No cell with offset ${d} found`);const u=r+d+1;return new ec(l.resolve(u),l.resolve(u+p.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)),i=e.resolve(t.map(this.$headCell.pos));if(is(o)&&is(i)&&rs(o,i)){const r=this.$anchorCell.node(-1)!=o.node(-1);return r&&this.isRowSelection()?rt.rowSelection(o,i):r&&this.isColSelection()?rt.colSelection(o,i):new rt(o,i)}return R.between(o,i)}content(){const e=this.$anchorCell.node(-1),t=Z.get(e),o=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),r={},s=[];for(let a=i.top;a<i.bottom;a++){const c=[];for(let d=a*t.width+i.left,p=i.left;p<i.right;p++,d++){const u=t.map[d];if(r[u])continue;r[u]=!0;const f=t.findCell(u);let h=e.nodeAt(u);if(!h)throw RangeError(`No cell with offset ${u} found`);const g=i.left-f.left,b=f.right-i.right;if(g>0||b>0){let x=h.attrs;if(g>0&&(x=En(x,0,g)),b>0&&(x=En(x,x.colspan-b,b)),f.left<i.left){if(h=h.type.createAndFill(x),!h)throw RangeError(`Could not create cell with attrs ${JSON.stringify(x)}`)}else h=h.type.create(x,h.content)}if(f.top<i.top||f.bottom>i.bottom){const x={...h.attrs,rowspan:Math.min(f.bottom,i.bottom)-Math.max(f.top,i.top)};f.top<i.top?h=h.type.createAndFill(x):h=h.type.create(x,h.content)}c.push(h)}s.push(e.child(a).copy(M.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:s;return new j(M.from(l),1,1)}replace(e,t=j.empty){const o=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){const{$from:l,$to:a}=i[s],c=e.mapping.slice(o);e.replace(c.map(l.pos),c.map(a.pos),s?j.empty:t)}const r=z.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,t){this.replace(e,new j(M.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),o=Z.get(t),i=this.$anchorCell.start(-1),r=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let s=0;s<r.length;s++)e(t.nodeAt(r[s]),i+r[s])}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,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const o=e.node(-1),i=Z.get(o),r=e.start(-1),s=i.findCell(e.pos-r),l=i.findCell(t.pos-r),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(r+i.map[s.left])),l.bottom<i.height&&(t=a.resolve(r+i.map[i.width*(i.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(r+i.map[l.left])),s.bottom<i.height&&(e=a.resolve(r+i.map[i.width*(i.height-1)+s.right-1]))),new rt(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=Z.get(e),o=this.$anchorCell.start(-1),i=t.colCount(this.$anchorCell.pos-o),r=t.colCount(this.$headCell.pos-o);if(Math.min(i,r)>0)return!1;const s=i+this.$anchorCell.nodeAfter.attrs.colspan,l=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==t.width}eq(e){return e instanceof rt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const o=e.node(-1),i=Z.get(o),r=e.start(-1),s=i.findCell(e.pos-r),l=i.findCell(t.pos-r),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(r+i.map[s.top*i.width])),l.right<i.width&&(t=a.resolve(r+i.map[i.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(r+i.map[l.top*i.width])),s.right<i.width&&(e=a.resolve(r+i.map[i.width*(s.top+1)-1]))),new rt(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new rt(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){return new rt(e.resolve(t),e.resolve(o))}getBookmark(){return new a1(this.$anchorCell.pos,this.$headCell.pos)}};Q.prototype.visible=!1,z.jsonID("cell",Q);var a1=class hu{constructor(e,t){this.anchor=e,this.head=t}map(e){return new hu(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&&rs(t,o)?new Q(t,o):z.near(o,1)}};function c1(n){if(!(n.selection instanceof Q))return null;const e=[];return n.selection.forEachCell((t,o)=>{e.push(xe.node(o,o+t.nodeSize,{class:"selectedCell"}))}),J.create(n.doc,e)}function d1({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,o=e.pos,i=n.depth;for(;i>=0&&!(n.after(i+1)<n.end(i));i--,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(i).type.spec.tableRole)}function p1({$from:n,$to:e}){let t,o;for(let i=n.depth;i>0;i--){const r=n.node(i);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){t=r;break}}for(let i=e.depth;i>0;i--){const r=e.node(i);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){o=r;break}}return t!==o&&e.parentOffset===0}function u1(n,e,t){const o=(e||n).selection,i=(e||n).doc;let r,s;if(o instanceof D&&(s=o.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")r=Q.create(i,o.from);else if(s=="row"){const l=i.resolve(o.from+1);r=Q.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=Q.create(i,a+1,c)}}else o instanceof R&&d1(o)?r=R.create(i,o.from):o instanceof R&&p1(o)&&(r=R.create(i,o.$from.start(),o.$from.end()));return r&&(e||(e=n.tr)).setSelection(r),e}var f1=new Wn("fix-tables");function _d(n,e,t,o){const i=n.childCount,r=e.childCount;e:for(let s=0,l=0;s<r;s++){const a=e.child(s);for(let c=l,d=Math.min(i,s+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}o(a,t),l<i&&n.child(l).sameMarkup(a)?_d(n.child(l),a,t+1,o):a.nodesBetween(0,a.content.size,o,t+1),t+=a.nodeSize}}function h1(n,e){let t;const o=(i,r)=>{i.type.spec.tableRole=="table"&&(t=m1(n,i,r,t))};return e?e.doc!=n.doc&&_d(e.doc,n.doc,0,o):n.doc.descendants(o),t}function m1(n,e,t,o){const i=Z.get(e);if(!i.problems)return o;o||(o=n.tr);const r=[];for(let a=0;a<i.height;a++)r.push(0);for(let a=0;a<i.problems.length;a++){const c=i.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const p=d.attrs;for(let u=0;u<p.rowspan;u++)r[c.row+u]+=c.n;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,En(p,p.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 s,l;for(let a=0;a<r.length;a++)r[a]&&(s==null&&(s=a),l=a);for(let a=0,c=t+1;a<i.height;a++){const d=e.child(a),p=c+d.nodeSize,u=r[a];if(u>0){let f="cell";d.firstChild&&(f=d.firstChild.type.spec.tableRole);const h=[];for(let b=0;b<u;b++){const x=qe(n.schema)[f].createAndFill();x&&h.push(x)}const g=(a==0||s==a-1)&&l==a?c+1:p-1;o.insert(o.mapping.map(g),h)}c=p}return o.setMeta(f1,{fixTables:!0})}function Gd(n){const e=n.selection,t=ns(n),o=t.node(-1),i=t.start(-1),r=Z.get(o);return{...e instanceof Q?r.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):r.findCell(t.pos-i),tableStart:i,map:r,table:o}}function g1(n){return function(e,t){if(!ui(e))return!1;if(t){const o=qe(e.schema),i=Gd(e),r=e.tr,s=i.map.cellsInRect(n=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:n=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),l=s.map(a=>i.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==o.header_cell&&r.setNodeMarkup(i.tableStart+s[a],o.cell,l[a].attrs);if(r.steps.length==0)for(let a=0;a<s.length;a++)r.setNodeMarkup(i.tableStart+s[a],o.header_cell,l[a].attrs);t(r)}return!0}}function Wd(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 i=0;i<o.length;i++){const r=e.table.nodeAt(o[i]);if(r&&r.type!==t.header_cell)return!1}return!0}function ss(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?g1(n):function(t,o){if(!ui(t))return!1;if(o){const i=qe(t.schema),r=Gd(t),s=t.tr,l=Wd("row",r,i),a=Wd("column",r,i),d=(n==="column"?l:n==="row"?a:!1)?1:0,p=n=="column"?{left:0,top:d,right:1,bottom:r.map.height}:n=="row"?{left:d,top:0,right:r.map.width,bottom:1}:r,u=n=="column"?a?i.cell:i.header_cell:n=="row"?l?i.cell:i.header_cell:i.cell;r.map.cellsInRect(p).forEach(f=>{const h=f+r.tableStart,g=s.doc.nodeAt(h);g&&s.setNodeMarkup(h,u,g.attrs)}),o(s)}return!0}}ss("row",{useDeprecatedLogic:!0}),ss("column",{useDeprecatedLogic:!0}),ss("cell",{useDeprecatedLogic:!0});function b1(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let o=n.index(-1)-1,i=n.before();o>=0;o--){const r=n.node(-1).child(o),s=r.lastChild;if(s)return i-1-s.nodeSize;i-=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),i=n.after();o<t.childCount;o++){const r=t.child(o);if(r.childCount)return i+1;i+=r.nodeSize}}return null}function qd(n){return function(e,t){if(!ui(e))return!1;const o=b1(ns(e),n);if(o==null)return!1;if(t){const i=e.doc.resolve(o);t(e.tr.setSelection(R.between(i,l1(i))).scrollIntoView())}return!0}}function fi(n,e){const t=n.selection;if(!(t instanceof Q))return!1;if(e){const o=n.tr,i=qe(n.schema).cell.createAndFill().content;t.forEachCell((r,s)=>{r.content.eq(i)||o.replace(o.mapping.map(s+1),o.mapping.map(s+r.nodeSize-1),new j(i,0,0))}),o.docChanged&&e(o)}return!0}function y1(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 i=e.child(0),r=i.type.spec.tableRole,s=i.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),p=a<e.childCount-1?0:Math.max(0,o-1);(d||p)&&(c=ls(qe(s).row,new j(c,d,p)).content),l.push(c)}else if(r=="cell"||r=="header_cell")l.push(t||o?ls(qe(s).row,new j(e,t,o)).content:e);else return null;return x1(s,l)}function x1(n,e){const t=[];for(let i=0;i<e.length;i++){const r=e[i];for(let s=r.childCount-1;s>=0;s--){const{rowspan:l,colspan:a}=r.child(s).attrs;for(let c=i;c<i+l;c++)t[c]=(t[c]||0)+a}}let o=0;for(let i=0;i<t.length;i++)o=Math.max(o,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(M.empty),t[i]<o){const r=qe(n).cell.createAndFill(),s=[];for(let l=t[i];l<o;l++)s.push(r);e[i]=e[i].append(M.from(s))}return{height:e.length,width:o,rows:e}}function ls(n,e){const t=n.createAndFill();return new Qa(t).replace(0,t.content.size,e).doc}function v1({width:n,height:e,rows:t},o,i){if(n!=o){const r=[],s=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=r[l]||0,p=0;d<o;p++){let u=a.child(p%a.childCount);d+u.attrs.colspan>o&&(u=u.type.createChecked(En(u.attrs,u.attrs.colspan,d+u.attrs.colspan-o),u.content)),c.push(u),d+=u.attrs.colspan;for(let f=1;f<u.attrs.rowspan;f++)r[l+f]=(r[l+f]||0)+u.attrs.colspan}s.push(M.from(c))}t=s,n=o}if(e!=i){const r=[];for(let s=0,l=0;s<i;s++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let p=c.child(d);s+p.attrs.rowspan>i&&(p=p.type.create({...p.attrs,rowspan:Math.max(1,i-p.attrs.rowspan)},p.content)),a.push(p)}r.push(M.from(a))}t=r,e=i}return{width:n,height:e,rows:t}}function w1(n,e,t,o,i,r,s){const l=n.doc.type.schema,a=qe(l);let c,d;if(i>e.width)for(let p=0,u=0;p<e.height;p++){const f=t.child(p);u+=f.nodeSize;const h=[];let g;f.lastChild==null||f.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=d||(d=a.header_cell.createAndFill());for(let b=e.width;b<i;b++)h.push(g);n.insert(n.mapping.slice(s).map(u-1+o),h)}if(r>e.height){const p=[];for(let h=0,g=(e.height-1)*e.width;h<Math.max(e.width,i);h++){const b=h>=e.width?!1:t.nodeAt(e.map[g+h]).type==a.header_cell;p.push(b?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const u=a.row.create(null,M.from(p)),f=[];for(let h=e.height;h<r;h++)f.push(u);n.insert(n.mapping.slice(s).map(o+t.nodeSize-2),f)}return!!(c||d)}function Ud(n,e,t,o,i,r,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=i;c<r;c++){const d=s*e.width+c,p=e.map[d];if(e.map[d-e.width]==p){a=!0;const u=t.nodeAt(p),{top:f,left:h}=e.findCell(p);n.setNodeMarkup(n.mapping.slice(l).map(p+o),null,{...u.attrs,rowspan:s-f}),n.insert(n.mapping.slice(l).map(e.positionAt(s,h,t)),u.type.createAndFill({...u.attrs,rowspan:f+u.attrs.rowspan-s})),c+=u.attrs.colspan-1}}return a}function Kd(n,e,t,o,i,r,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=i;c<r;c++){const d=c*e.width+s,p=e.map[d];if(e.map[d-1]==p){a=!0;const u=t.nodeAt(p),f=e.colCount(p),h=n.mapping.slice(l).map(p+o);n.setNodeMarkup(h,null,En(u.attrs,s-f,u.attrs.colspan-(s-f))),n.insert(h+u.nodeSize,u.type.createAndFill(En(u.attrs,0,s-f))),c+=u.attrs.rowspan-1}}return a}function Jd(n,e,t,o,i){let r=t?n.doc.nodeAt(t-1):n.doc;if(!r)throw new Error("No table found");let s=Z.get(r);const{top:l,left:a}=o,c=a+i.width,d=l+i.height,p=n.tr;let u=0;function f(){if(r=t?p.doc.nodeAt(t-1):p.doc,!r)throw new Error("No table found");s=Z.get(r),u=p.mapping.maps.length}w1(p,s,r,t,c,d,u)&&f(),Ud(p,s,r,t,a,c,l,u)&&f(),Ud(p,s,r,t,a,c,d,u)&&f(),Kd(p,s,r,t,l,d,a,u)&&f(),Kd(p,s,r,t,l,d,c,u)&&f();for(let h=l;h<d;h++){const g=s.positionAt(h,a,r),b=s.positionAt(h,c,r);p.replace(p.mapping.slice(u).map(g+t),p.mapping.slice(u).map(b+t),new j(i.rows[h-l],0,0))}f(),p.setSelection(new Q(p.doc.resolve(t+s.positionAt(l,a,r)),p.doc.resolve(t+s.positionAt(d-1,c-1,r)))),e(p)}var S1=Tc({ArrowLeft:mi("horiz",-1),ArrowRight:mi("horiz",1),ArrowUp:mi("vert",-1),ArrowDown:mi("vert",1),"Shift-ArrowLeft":gi("horiz",-1),"Shift-ArrowRight":gi("horiz",1),"Shift-ArrowUp":gi("vert",-1),"Shift-ArrowDown":gi("vert",1),Backspace:fi,"Mod-Backspace":fi,Delete:fi,"Mod-Delete":fi});function hi(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function mi(n,e){return(t,o,i)=>{if(!i)return!1;const r=t.selection;if(r instanceof Q)return hi(t,o,z.near(r.$headCell,e));if(n!="horiz"&&!r.empty)return!1;const s=Yd(i,n,e);if(s==null)return!1;if(n=="horiz")return hi(t,o,z.near(t.doc.resolve(r.head+e),e));{const l=t.doc.resolve(s),a=Fd(l,n,e);let c;return a?c=z.near(a,1):e<0?c=z.near(t.doc.resolve(l.before(-1)),-1):c=z.near(t.doc.resolve(l.after(-1)),1),hi(t,o,c)}}}function gi(n,e){return(t,o,i)=>{if(!i)return!1;const r=t.selection;let s;if(r instanceof Q)s=r;else{const a=Yd(i,n,e);if(a==null)return!1;s=new Q(t.doc.resolve(a))}const l=Fd(s.$headCell,n,e);return l?hi(t,o,new Q(s.$anchorCell,l)):!1}}function C1(n,e){const t=n.state.doc,o=oo(t.resolve(e));return o?(n.dispatch(n.state.tr.setSelection(new Q(o))),!0):!1}function k1(n,e,t){if(!ui(n.state))return!1;let o=y1(t);const i=n.state.selection;if(i instanceof Q){o||(o={width:1,height:1,rows:[M.from(ls(qe(n.state.schema).cell,t))]});const r=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),l=Z.get(r).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return o=v1(o,l.right-l.left,l.bottom-l.top),Jd(n.state,n.dispatch,s,l,o),!0}else if(o){const r=ns(n.state),s=r.start(-1);return Jd(n.state,n.dispatch,s,Z.get(r.node(-1)).findCell(r.pos-s),o),!0}else return!1}function T1(n,e){var t;if(e.ctrlKey||e.metaKey)return;const o=Zd(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof Q)r(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(i=oo(n.state.selection.$anchor))!=null&&((t=as(n,e))==null?void 0:t.pos)!=i.pos)r(i,e),e.preventDefault();else if(!o)return;function r(a,c){let d=as(n,c);const p=wt.getState(n.state)==null;if(!d||!rs(a,d))if(p)d=a;else return;const u=new Q(a,d);if(p||!n.state.selection.eq(u)){const f=n.state.tr.setSelection(u);p&&f.setMeta(wt,a.pos),n.dispatch(f)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",l),wt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(wt,-1))}function l(a){const c=a,d=wt.getState(n.state);let p;if(d!=null)p=n.state.doc.resolve(d);else if(Zd(n,c.target)!=o&&(p=as(n,e),!p))return s();p&&r(p,c)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",l)}function Yd(n,e,t){if(!(n.state.selection instanceof R))return null;const{$head:o}=n.state.selection;for(let i=o.depth-1;i>=0;i--){const r=o.node(i);if((t<0?o.index(i):o.indexAfter(i))!=(t<0?0:r.childCount))return null;if(r.type.spec.tableRole=="cell"||r.type.spec.tableRole=="header_cell"){const l=o.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Zd(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function as(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?oo(n.state.doc.resolve(t.pos)):null}var E1=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")),cs(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,cs(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function cs(n,e,t,o,i,r){var s;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let p=0,u=0;p<d.childCount;p++){const{colspan:f,colwidth:h}=d.child(p).attrs;for(let g=0;g<f;g++,u++){const b=i==u?r:h&&h[g],x=b?b+"px":"";if(l+=b||o,b||(a=!1),c)c.style.width!=x&&(c.style.width=x),c=c.nextSibling;else{const C=document.createElement("col");C.style.width=x,e.appendChild(C)}}}for(;c;){const p=c.nextSibling;(s=c.parentNode)==null||s.removeChild(c),c=p}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var ke=new Wn("tableColumnResizing");function M1({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:o=E1,lastColumnResizable:i=!0}={}){const r=new xn({key:ke,state:{init(s,l){var a,c;const d=(c=(a=r.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,p=qe(l.schema).table.name;return o&&d&&(d[p]=(u,f)=>new o(u,t,f)),new A1(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{const l=ke.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{j1(s,l,n,i)},mouseleave:s=>{$1(s)},mousedown:(s,l)=>{P1(s,l,e,t)}},decorations:s=>{const l=ke.getState(s);if(l&&l.activeHandle>-1)return z1(s,l.activeHandle)},nodeViews:{}}});return r}var A1=class ji{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,o=e.getMeta(ke);if(o&&o.setHandle!=null)return new ji(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new ji(t.activeHandle,o.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return is(e.doc.resolve(i))||(i=-1),new ji(i,t.dragging)}return t}};function j1(n,e,t,o){const i=ke.getState(n.state);if(i&&!i.dragging){const r=O1(e.target);let s=-1;if(r){const{left:l,right:a}=r.getBoundingClientRect();e.clientX-l<=t?s=Xd(n,e,"left",t):a-e.clientX<=t&&(s=Xd(n,e,"right",t))}if(s!=i.activeHandle){if(!o&&s!==-1){const l=n.state.doc.resolve(s),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}ep(n,s)}}}function $1(n){const e=ke.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&ep(n,-1)}function P1(n,e,t,o){var i;const r=(i=n.dom.ownerDocument.defaultView)!=null?i:window,s=ke.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const l=n.state.doc.nodeAt(s.activeHandle),a=N1(n,s.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ke,{setDragging:{startX:e.clientX,startWidth:a}}));function c(p){r.removeEventListener("mouseup",c),r.removeEventListener("mousemove",d);const u=ke.getState(n.state);u!=null&&u.dragging&&(I1(n,u.activeHandle,Qd(u.dragging,p,t)),n.dispatch(n.state.tr.setMeta(ke,{setDragging:null})))}function d(p){if(!p.which)return c(p);const u=ke.getState(n.state);if(u&&u.dragging){const f=Qd(u.dragging,p,t);tp(n,u.activeHandle,f,o)}}return tp(n,s.activeHandle,a,o),r.addEventListener("mouseup",c),r.addEventListener("mousemove",d),e.preventDefault(),!0}function N1(n,e,{colspan:t,colwidth:o}){const i=o&&o[o.length-1];if(i)return i;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 O1(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 i=t=="right"?-o:o,r=n.posAtCoords({left:e.clientX+i,top:e.clientY});if(!r)return-1;const{pos:s}=r,l=oo(n.state.doc.resolve(s));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 Qd(n,e,t){const o=e.clientX-n.startX;return Math.max(t,n.startWidth+o)}function ep(n,e){n.dispatch(n.state.tr.setMeta(ke,{setHandle:e}))}function I1(n,e,t){const o=n.state.doc.resolve(e),i=o.node(-1),r=Z.get(i),s=o.start(-1),l=r.colCount(o.pos-s)+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 p=r.map[d],u=i.nodeAt(p).attrs,f=u.colspan==1?0:l-r.colCount(p);if(u.colwidth&&u.colwidth[f]==t)continue;const h=u.colwidth?u.colwidth.slice():D1(u.colspan);h[f]=t,a.setNodeMarkup(s+p,null,{...u,colwidth:h})}a.docChanged&&n.dispatch(a)}function tp(n,e,t,o){const i=n.state.doc.resolve(e),r=i.node(-1),s=i.start(-1),l=Z.get(r).colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;let a=n.domAtPos(i.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&cs(r,a.firstChild,a,o,l,t)}function D1(n){return Array(n).fill(0)}function z1(n,e){var t;const o=[],i=n.doc.resolve(e),r=i.node(-1);if(!r)return J.empty;const s=Z.get(r),l=i.start(-1),a=s.colCount(i.pos-l)+i.nodeAfter.attrs.colspan-1;for(let c=0;c<s.height;c++){const d=a+c*s.width;if((a==s.width-1||s.map[d]!=s.map[d+1])&&(c==0||s.map[d]!=s.map[d-s.width])){const p=s.map[d],u=l+p+r.nodeAt(p).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(t=ke.getState(n))!=null&&t.dragging&&o.push(xe.node(l+p,l+p+r.nodeAt(p).nodeSize,{class:"column-resize-dragging"})),o.push(xe.widget(u,f))}}return J.create(n.doc,o)}function R1({allowTableNodeSelection:n=!1}={}){return new xn({key:wt,state:{init(){return null},apply(e,t){const o=e.getMeta(wt);if(o!=null)return o==-1?null:o;if(t==null||!e.docChanged)return t;const{deleted:i,pos:r}=e.mapping.mapResult(t);return i?null:r}},props:{decorations:c1,handleDOMEvents:{mousedown:T1},createSelectionBetween(e){return wt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:C1,handleKeyDown:S1,handlePaste:k1},appendTransaction(e,t,o){return u1(o,h1(o,t),n)}})}const io=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},ds=n=>{const{key:e,cssProperty:t,tagName:o="span"}=n,i="value";return{attrs:{...yi,[i]:{default:null}},parseDOM:[{tag:`${o}[${e}]`,getAttrs:r=>({...xi(r),[i]:r.style.getPropertyValue(t)||null})}],toDOM(r){const{[i]:s}=r.attrs,l={...Je(r),[e]:""};return s&&(l.style=`${t}: ${s}`),[o,l,0]}}},np="data-gs-mrk-fs",L1="data-gs-mrk-color",B1="data-gs-mrk-bgcolor",op="data-gs-mrk-wrap",bi="data-gs-ifrg",ot="attrs",yi={[ot]:{default:"{}"}},Ue={[ot]:{default:{}}},xi=n=>({[ot]:JSON.stringify(io(n))}),Ke=n=>({attrs:io(n)}),ro=n=>e=>[n,e.attrs.attrs,0],Je=n=>n.attrs[ot]?JSON.parse(n.attrs[ot]):{},V1={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${bi}]`,getAttrs:Ke}],toDOM:()=>["span",{[bi]:""},0]},div:{group:"block",content:"inline*",attrs:Ue,parseDOM:[{tag:"div",getAttrs:Ke}],toDOM:ro("div")},paragraph:{group:"block",content:"inline*",attrs:Ue,parseDOM:[{tag:"p",getAttrs:Ke}],toDOM:ro("p")},orderedList:{group:"block",content:"listItem+",attrs:Ue,parseDOM:[{tag:"ol",getAttrs:Ke}],toDOM:ro("ol")},bulletList:{group:"block",content:"listItem+",attrs:Ue,parseDOM:[{tag:"ul",getAttrs:Ke}],toDOM:ro("ul")},listItem:{content:"block*",group:"block",attrs:Ue,parseDOM:[{tag:"li",getAttrs:Ke}],toDOM:ro("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:Ue,parseDOM:[{tag:"pre",getAttrs:Ke}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:Ue,parseDOM:[{tag:"img[src]",getAttrs:Ke}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,attrs:Ue,parseDOM:[{tag:"br",getAttrs:Ke}],toDOM:n=>["br",{...n.attrs.attrs}]},hardBreak:{inline:!0,group:"inline",selectable:!1,attrs:Ue,parseDOM:[{tag:"br",getAttrs:Ke}],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:io(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...r1({tableGroup:"block",cellContent:"block+",cellAttributes:{[ot]:{default:Ue[ot].default,getFromDOM:io,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:io(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},so=(n,e)=>({attrs:yi,parseDOM:n.map(t=>({tag:t,getAttrs:xi})),toDOM:e}),H1=n=>({attrs:{...yi},parseDOM:[{tag:`span[${n}]`,getAttrs:e=>({...xi(e)})}],toDOM(e){return["span",{...Je(e),[n]:!0},0]}}),F1={strong:so(["strong","b"],n=>["b",Je(n)]),link:so(["a"],n=>["a",Je(n),0]),em:so(["em","i"],n=>["em",Je(n)]),underline:so(["u"],n=>["u",Je(n),0]),strikethrough:so(["s"],n=>["s",Je(n),0]),wrapStyle:H1(op),font_size:{attrs:{...yi,size:{default:null}},parseDOM:[{tag:`span[${np}]`,getAttrs:n=>({...xi(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...Je(n),[np]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}},color:ds({key:L1,cssProperty:"color"}),bgColor:ds({key:B1,cssProperty:"background-color"})},ip=new rm({nodes:V1,marks:F1}),lo=new WeakMap,ps=new WeakMap,_1=(n,e,t)=>{lo.set(n,{view:e,gjsView:t,initialDoc:e.state.doc}),ps.set(e,{el:n,gjsView:t})},G1=(n,e)=>{lo.delete(n),ps.delete(e)},vi=n=>lo.get(n),rp=n=>ps.get(n),sp=n=>{const e=vi(n),t=e==null?void 0:e.view,o=e==null?void 0:e.initialDoc;return!(t&&o&&o.eq(t.state.doc))},us=n=>{var e,t;return(t=(e=rp(n))==null?void 0:e.gjsView)==null?void 0:t.model},W1=n=>n.dispatchEvent(new CustomEvent("input"));function q1(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(bi)){if(t.getAttribute("style")){t.removeAttribute(bi);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)}const lp=n=>{n.childNodes.forEach(e=>{if(e.nodeName==="BR"){const{nextSibling:t}=e,o=n.lastChild===e,i=(t==null?void 0:t.nodeType)===Node.ELEMENT_NODE&&(t==null?void 0:t.nodeName)!=="BR";(o||i)&&e.remove()}else lp(e)})},U1=(n,e)=>{const t=ap(n);return t&&rb(t)?J1(n,e):t?hc(()=>({type:n.schema.nodes.div}))(n,e):!1},K1=(n,e)=>(t,o)=>{var l;const i=ap(t),r=lo.get(n.el).view,s=(l=e.onEnter)==null?void 0:l.call(e,{...n,node:i,commands:ms(r,n.editor,e),proseMirror:{view:r,dispatch:o}});return s!==void 0?s:U1(t,o)};function ap(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 J1(n,e){const{selection:t,schema:o,tr:i}=n;i.split(t.from,1);const r=t.from+1,s=i.doc.nodeAt(r),l={...s.attrs.attrs,id:void 0},a=s.textContent.length>0,c=s.textContent.length||0,d=s.textContent||" ",p=o.text(d),u=o.nodes.div.create(l,a?p:[],[]);return i.replaceRangeWith(r,r+c+2,u),i.setSelection(R.create(i.doc,r+1)),e==null||e(i.scrollIntoView()),!0}function Y1(n,e,t){const{state:o,dispatch:i}=n,{selection:r,tr:s}=o,l=(a,c,d)=>{const p={};return a.split(";").forEach(u=>{const[f,h]=u.split(":").map(g=>g.trim());f&&(p[f]=h)}),p[c]=d,Object.entries(p).map(([u,f])=>`${u}: ${f}`).join("; ")};if(!r.empty||t)s.doc.nodesBetween(r.from,r.to,(a,c)=>{var d,p;if(a.type===o.schema.nodes.image){const u=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);s.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}else if(a.type.isBlock){const u=l(((p=a.attrs.attrs)==null?void 0:p.style)||"","text-align",e);cp(a)?s.setBlockType(r.from,void 0,o.schema.nodes.div,{attrs:{style:u}}):s.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}});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 p=l(d.attrs.style||"","text-align",e);s.setNodeMarkup(c,void 0,{...d.attrs,style:p})}}s.docChanged&&i(s.scrollIntoView())}const ao=(n,e)=>{const{from:t,to:o}=n.selection;let i=!1;return n.doc.nodesBetween(t,o,r=>{if(i)return!1;r.marks.some(s=>s.type===e)&&(i=!0)}),i};function Z1(n){var p,u;const{view:e,href:t,options:o,target:i="_blank"}=n,{state:r,dispatch:s}=e,{schema:l,selection:a,tr:c}=r,d=l.marks.link;try{const f={href:t,target:i},h=((u=(p=o.commandAttrs)==null?void 0:p.link)==null?void 0:u.call(p,f))||f,g=d.create({[ot]:JSON.stringify(h)});c.addMark(a.from,a.to,g),s(c.scrollIntoView())}catch(f){console.error("Error applying link mark:",f)}}function X1(n,e){const{state:t,dispatch:o}=n,{selection:i,tr:r}=t;if(i.empty)return;const s=t.schema.marks.font_size;if(!s){console.error("Font size mark is not defined in the schema.");return}r.addMark(i.from,i.to,s.create({size:e})),o(r.scrollIntoView())}function Q1(n,e){const{state:t,dispatch:o}=n,{selection:i,tr:r}=t;if(i.empty)return;const s=t.schema.marks.color;if(!s){console.error("Color mark is not defined in the schema.");return}r.addMark(i.from,i.to,s.create({value:e})),o(r.scrollIntoView())}function eb(n,e){const{state:t,dispatch:o}=n,{selection:i,tr:r}=t;if(i.empty)return;const s=t.schema.marks.bgColor;if(!s){console.error("Background color mark is not defined in the schema.");return}r.addMark(i.from,i.to,s.create({value:e})),o(r.scrollIntoView())}const qt=(n,e)=>{const{doc:t,selection:o}=n.state,i=t.resolve(o.from);for(let r=i.depth;r>0;r--){const s=i.node(r);if(e(s))return{pos:r>0?i.before(r):0,start:i.start(r),depth:r,node:s}}},tb=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,o])=>(t=t.replace(/-./g,i=>i.toUpperCase()[1]).trim(),e[t]=`${o}`.trim(),e),{});function nb(...n){return(e,t)=>{const o=s=>{e=e.apply(s),t==null||t(s)},i=n.pop();return n.reduce((s,l)=>s||l(e,o),!1)&&i!==void 0&&i(e,t)}}const ob=(n,e)=>{const{state:t,dispatch:o}=n;if(e!=null&&e.event){const{event:i}=e,r=n.posAtCoords({left:i.clientX,top:i.clientY});r!=null&&r.pos&&o(t.tr.setSelection(R.create(t.doc,r.pos)))}else mc(t,o);setTimeout(()=>setTimeout(()=>n.focus()))},fs=n=>n.isBlock,cp=n=>n.type.name==="inlineFragment",ib=n=>fs(n)&&!cp(n),dp=n=>n.type.name==="bulletList",pp=n=>n.type.name==="orderedList",rb=n=>n.type.name==="heading",sb=n=>dp(n)||pp(n),up=(n,e)=>{var r,s;const t=(r=qt(n,l=>l.type===e))==null?void 0:r.node,o=n.state.schema.nodes.listItem;let i;return t?i=$r(o):(s=qt(n,sb))!=null&&s.node?i=nb($r(o),Ec(e)):i=Ec(e),i(n.state,n.dispatch)},fp=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(o=>o.type.name===e)},lb=n=>{var s;const{view:e,prop:t,editor:o,propCSS:i}=n,r=(s=qt(e,ib))==null?void 0:s.node;if(r){const l=r.attrs.attrs||{},a=tb(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())||{})[i]||""}}return""},hs=n=>{const{view:e,prop:t,markName:o,editor:i,propCSS:r}=n,s=fp(e,o);if(s){const l=s.attrs;if(l[t])return l[t];if(l[ot]){const a=Je(s).id;if(a){const c=i.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[r]||""}}}return""},ms=(n,e,t)=>{const{dispatch:o}=n,{nodes:i,marks:r}=n.state.schema,s={text:{selected:()=>{const{selection:l,doc:a}=n.state;return a.textBetween(l.from,l.to," ")},replace:(l,a={})=>{const{state:c}=n,{from:d}=c.selection;let p=c.tr.replaceSelectionWith(c.schema.text(l));a.select&&(p=p.setSelection(R.create(p.doc,d,d+l.length))),o==null||o(p)},replaceHtml:l=>{const{schema:a,selection:c,tr:d}=n.state,p=document.createElement("div");p.innerHTML=l;const u=Dt.fromSchema(a).parse(p),{from:f,to:h}=c;return o==null?void 0:o(d.replaceRangeWith(f,h,u).scrollIntoView())},wrapStyle:()=>{const l=us(n),a=s.text.selected(),c=`i${e.Components._createId().slice(0,4)}`;s.text.replaceHtml(`<span id="${c}" ${op}>${a}</span>`),l==null||l.trigger("disable"),setTimeout(()=>{const d=l==null?void 0:l.find(`#${c}`)[0];d&&e.select(d)})},createBreak:()=>{const{state:l}=n,a=l.tr.replaceSelectionWith(i.inlineBreak.create()).scrollIntoView();return o==null?void 0:o(a)}},bold:{toggle:()=>Rt(r.strong)(n.state,o),isActive:()=>ao(n.state,r.strong)},italic:{toggle:()=>Rt(r.em)(n.state,o),isActive:()=>ao(n.state,r.em)},underline:{toggle:()=>Rt(r.underline)(n.state,o),isActive:()=>ao(n.state,r.underline)},strikethrough:{toggle:()=>Rt(r.strikethrough)(n.state,o),isActive:()=>ao(n.state,r.strikethrough)},link:{get:()=>{const l=us(n),a=l==null?void 0:l.getTrait("href");if(l!=null&&l.is("link"))return l.getAttributes();if(a)return{href:a.getValue()};{const c=fp(n,"link");return c?Je(c):{}}},toggle:()=>Rt(r.link)(n.state,o),isActive:()=>ao(n.state,r.link),create:l=>{const a=us(n),c=a==null?void 0:a.getTrait("href"),{url:d,target:p}=l,u=()=>{var h,g;const f=(g=(h=rp(n))==null?void 0:h.gjsView)==null?void 0:g.el;f&&f.contentEditable!=="true"&&(f.contentEditable="true"),n.focus()};a!=null&&a.is("link")?(a.addAttributes({href:d,target:p}),u()):c?(a==null||a.addAttributes({[c.getName()]:d}),u()):Z1({view:n,href:d,target:p,options:t})}},alignText:{get:()=>lb({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:l=>Y1(n,l.value,!0)},fontSize:{get:()=>hs({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:l=>X1(n,l.value)},color:{get:()=>hs({view:n,editor:e,markName:"color",prop:"value",propCSS:"color"}),set:l=>Q1(n,l.value)},bgColor:{get:()=>hs({view:n,editor:e,markName:"bgColor",prop:"value",propCSS:"background-color"}),set:l=>eb(n,l.value)},image:{open(){const l="assetLayout",{state:a,dispatch:c}=n,{selection:d,doc:p}=a,u=p.textBetween(d.from,d.to," "),f={id:l,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:h=>{const g={alt:u,src:h.asset.getSrc()};c(a.tr.replaceSelectionWith(i.image.createAndFill({attrs:g})))}}};e.runCommand(W.layoutToggle,f)}},heading:{get:()=>{var a;const l=(a=qt(n,fs))==null?void 0:a.node;return`${(l==null?void 0:l.attrs.level)||""}`},set:({value:l})=>{var d;const{state:a}=n,c=(d=qt(n,fs))==null?void 0:d.node;Xm(a.schema.nodes.heading,{attrs:c==null?void 0:c.attrs.attrs,level:l?parseInt(l,10):0})(a,o)}},listBullet:{isActive:()=>{var l;return!!((l=qt(n,dp))!=null&&l.node)},toggle:()=>up(n,i.bulletList)},listOrdered:{isActive:()=>{var l;return!!((l=qt(n,pp))!=null&&l.node)},toggle:()=>up(n,i.orderedList)}};return s};class St{constructor(e,t,o={}){this.match=e,this.match=e,this.handler=typeof t=="string"?ab(t):t,this.undoable=o.undoable!==!1,this.inCode=o.inCode||!1}}function ab(n){return function(e,t,o,i){let r=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);r+=t[0].slice(s+t[1].length),o+=s;let l=o-i;l>0&&(r=t[0].slice(s-l,s)+r,o=i)}return e.tr.insertText(r,o,i)}}const cb=500;function db({rules:n}){let e=new xn({state:{init(){return null},apply(t,o){let i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:o)}},props:{handleTextInput(t,o,i,r){return hp(t,o,i,r,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:o}=t.state.selection;o&&hp(t,o.pos,o.pos,"",n,e)})}}},isInputRules:!0});return e}function hp(n,e,t,o,i,r){if(n.composing)return!1;let s=n.state,l=s.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-cb),l.parentOffset,null,"")+o;for(let c=0;c<i.length;c++){let d=i[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let p=d.match.exec(a),u=p&&d.handler(s,p,e-(p[0].length-o.length),t);if(u)return d.undoable&&u.setMeta(r,{transform:u,from:e,to:t,text:o}),n.dispatch(u),!0}return!1}const pb=new St(/--$/,"—"),ub=new St(/\.\.\.$/,"…"),fb=new St(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),hb=new St(/"$/,"”"),mb=new St(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),gb=new St(/'$/,"’"),bb=[fb,hb,mb,gb];function gs(n,e,t=null,o){return new St(n,(i,r,s,l)=>{let a=t instanceof Function?t(r):t,c=i.tr.delete(s,l),d=c.doc.resolve(s),p=d.blockRange(),u=p&&Wa(p,e,a);if(!u)return null;c.wrap(p,u);let f=c.doc.resolve(s-1).nodeBefore;return f&&f.type==e&&Xo(c.doc,s-1)&&(!o||o(r,f))&&c.join(s-1),c})}function mp(n,e,t=null){return new St(n,(o,i,r,s)=>{let l=o.doc.resolve(r),a=t instanceof Function?t(i):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?o.tr.delete(r,s).setBlockType(r,r,e,a):null})}function yb(n){return gs(/^\s*>\s$/,n)}function xb(n){return gs(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function vb(n){return gs(/^\s*([-+*])\s$/,n)}function wb(n){return mp(/^```$/,n)}function Sb(n,e){return mp(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function Cb(n){const e=bb.concat(ub,pb);let t;return(t=n.nodes.blockquote)&&e.push(yb(t)),(t=n.nodes.orderedList)&&e.push(xb(t)),(t=n.nodes.bulletList)&&e.push(vb(t)),(t=n.nodes.codeBlock)&&e.push(wb(t)),(t=n.nodes.heading)&&e.push(Sb(t,6)),db({rules:e})}const gp="rteProseMirror",kb=F.free,fe="rte:selectionchange",ee={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>',color:'<svg viewBox="0 0 24 24"><path d="M9.62,12L12,5.67L14.37,12M11,3L5.5,17H7.75L8.87,14H15.12L16.25,17H18.5L13,3H11Z" /></svg>',bgColor:'<svg viewBox="0 0 24 24"><path d="M19,11.5C19,11.5 17,13.67 17,15A2,2 0 0,0 19,17A2,2 0 0,0 21,15C21,13.67 19,11.5 19,11.5M5.21,10L10,5.21L14.79,10M16.56,8.94L7.62,0L6.21,1.41L8.59,3.79L3.44,8.94C2.85,9.5 2.85,10.47 3.44,11.06L8.94,16.56C9.23,16.85 9.62,17 10,17C10.38,17 10.77,16.85 11.06,16.56L16.56,11.06C17.15,10.47 17.15,9.5 16.56,8.94Z" /></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>'},bp=n=>({state:e})=>({type:"column",style:{alignItems:"center",background:"none"},children:[{type:"icon",icon:n,size:16},{type:"row",style:{width:16,height:2,backgroundColor:e.value||"currentColor",borderRadius:1}}]}),Tb=(n,e)=>{var a;const{editor:t,el:o}=n,i=lo.get(o).view,r=ms(i,t,e),s={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},wrapStyle:{id:"wrapper",type:"button",icon:"tag",tooltip:"Wrap for styling",editorEvents:{[fe]:({setState:c})=>{c({disabled:i.state.selection.empty})}},onClick:()=>r.text.wrapStyle()},bold:{id:"bold",icon:ee.bold,size:"s",type:"button",editorEvents:{[fe]:({setState:c})=>{c({active:r.bold.isActive()})}},onClick:({setState:c})=>{r.bold.toggle(),c({active:r.bold.isActive()})}},italic:{id:"italic",icon:ee.italic,size:"s",type:"button",editorEvents:{[fe]:({setState:c})=>{c({active:r.italic.isActive()})}},onClick:({setState:c})=>{r.italic.toggle(),c({active:r.italic.isActive()})}},underline:{id:"underline",icon:ee.underline,size:"s",type:"button",editorEvents:{[fe]:({setState:c})=>{c({active:r.underline.isActive()})}},onClick:({setState:c})=>{r.underline.toggle(),c({active:r.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:ee.strikethrough,size:"s",type:"button",editorEvents:{[fe]:({setState:c})=>{c({active:r.strikethrough.isActive()})}},onClick:({setState:c})=>{r.strikethrough.toggle(),c({active:r.strikethrough.isActive()})}},image:{id:"image",icon:ee.image,size:"s",type:"button",onClick:()=>r.image.open()},link:{id:"link",icon:ee.link,size:"s",type:"button",editorEvents:{[fe]:({setState:c})=>{c({active:r.link.isActive(),disabled:i.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,p="linkLayout",u=()=>t.runCommand(W.layoutRemove,{id:p}),f=r.link.get(),h={id:p,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,target:d},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:g=>{g.preventDefault();const b=new FormData(g.currentTarget);r.link.create({url:b.get("url"),target:b.get("target")}),u()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(f==null?void 0:f.href)||"",onChange:({value:g,setState:b})=>b({value:g})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(f==null?void 0:f.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:g,setState:b})=>b({value:g})},{type:"row",style:{gap:10,justifyContent:"end"},children:[r.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{r.link.toggle(),u()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(W.layoutToggle,h)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:ee.alignTextLeft},{id:"center",icon:ee.alignTextCenter},{id:"right",icon:ee.alignTextRight},{id:"justify",icon:ee.alignTextJustify}],editorEvents:{[fe]:({setState:c})=>{c({value:r.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.alignText.set({value:c})}},alignTextMenu:{id:"alignTextMenu",type:"buttonMenu",size:"s",value:"",options:[{id:"left",icon:ee.alignTextLeft},{id:"center",icon:ee.alignTextCenter},{id:"right",icon:ee.alignTextRight},{id:"justify",icon:ee.alignTextJustify}],editorEvents:{[fe]:({setState:c})=>{c({value:r.alignText.get()})}},onOptionSelect:({option:c,state:d,setState:p})=>{const u=c.id===d.value?"":c.id;p({value:u}),r.alignText.set({value:u})},onClick:({state:c})=>{c.value&&r.alignText.set({value:c.value})}},listBullet:{id:"listBullet",icon:ee.listBullet,size:"s",type:"button",editorEvents:{[fe]:({setState:c})=>{c({active:r.listBullet.isActive()})}},onClick:({setState:c})=>{r.listBullet.toggle(),c({active:r.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:ee.listOrdered,size:"s",type:"button",editorEvents:{[fe]:({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:{[fe]:({setState:c})=>{c({value:r.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.heading.set({value:c}),i.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"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:{[fe]:({setState:c})=>{c({value:r.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),r.fontSize.set({value:c}),i.focus()}},color:{id:"color",type:"buttonMenu",size:"s",value:"",label:bp(ee.color),editorEvents:{[fe]:({setState:c})=>{c({disabled:i.state.selection.empty})}},children:({state:c,setState:d})=>({type:"colorPicker",value:c.value||"",onChange:p=>{const{value:u}=p;d({value:u}),p.setState({value:u}),r.color.set({value:u}),i.focus()}}),onClick:({state:c})=>{c.value&&(r.color.set({value:c.value}),i.focus())}},bgColor:{id:"bgColor",type:"buttonMenu",size:"s",value:"",label:bp(ee.bgColor),editorEvents:{[fe]:({setState:c})=>{c({disabled:i.state.selection.empty})}},children:({state:c,setState:d})=>({type:"colorPicker",value:c.value||"",onChange:p=>{const{value:u}=p;d({value:u}),p.setState({value:u}),r.bgColor.set({value:u}),i.focus()}}),onClick:({state:c})=>{c.value&&(r.bgColor.set({value:c.value}),i.focus())}}},l=[s.bold,s.italic,s.underline,s.strikethrough,s.image,s.link,s.listBullet,s.listOrdered,s.color,s.bgColor,s.alignTextMenu,s.heading,s.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:r,layouts:s,proseMirror:{view:i},items:l}))||l};class Eb{constructor(e,t,o){this.editor=o,this.node=e,this.dom=document.createElement("img"),this.view=t,Object.keys(e.attrs.attrs).forEach(i=>{this.dom.setAttribute(i,e.attrs.attrs[i])}),this.dom.addEventListener("dblclick",i=>this.handleDoubleClick(i))}handleDoubleClick(e){const{editor:t,view:o}=this;ms(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 Mb=q(function(n,e={}){const t={plugins:l=>l.plugins,...e},o=(l,a)=>{var b,x;const c=((b=t.schema)==null?void 0:b.call(t,{editor:n,schema:ip,createCustomMark:ds}))||ip,{nodes:d,marks:p}=c,u={...a,component:a.view.model,editor:n,el:l};lp(l);const f=Dt.fromSchema(c).parse(l),h=yn.create({doc:f,schema:c,plugins:(x=t.plugins)==null?void 0:x.call(t,{editor:n,Plugin:xn,plugins:[M1(),R1(),Cb(c),cg(),jr({Tab:qd(1),"Shift-Tab":qd(-1)}),jr({Enter:qn(fc,bg(d.listItem),K1(u,t)),"Shift-Enter":qn(uc,(C,y)=>(y&&y(C.tr.replaceSelectionWith(d.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":kc,"Mod-y":Er,"Mod-Shift-z":Er,"Mod-b":Rt(p.strong),"Mod-i":Rt(p.em),"Shift-Tab":$r(d.listItem),Tab:vg(d.listItem)}),jr(eg)]})}),g=new X0({mount:l},{state:h,dispatchTransaction(C){var S;const{state:y}=g,v=y.apply(C),k=!y.doc.eq(v.doc);g.updateState(v);const w=!y.selection.eq(v.selection);k&&(W1(((S=a==null?void 0:a.view)==null?void 0:S.el)||l),g.focus()),(w||k)&&n.trigger(fe)}});return l.__rteView=g,g.setProps({nodeViews:{image(C){return new Eb(C,g,n)}}}),g},i=l=>Tb(l,t);n.setCustomRte({toolbar:i,parseContent:!0,async enable(l,a,c){const d=vi(l);if(d)return d;const p=o(l,c);return _1(l,p,c.view),ob(p,c),p},disable(l){const a=vi(l),c=a==null?void 0:a.view;if(c){const d=sp(l);return G1(l,c),d||n.once(n.RichTextEditor.events.disable,()=>{a.gjsView.model.trigger("rerender")}),c.destroy(),{forceSync:d}}},getContent(l,a,c){var p;const d=(p=vi(l))==null?void 0:p.view;if(d){const{schema:u,doc:f}=d.state;if(!sp(l))return c.view.lastContent;const h=document.createElement("div"),g=zt.fromSchema(u).serializeFragment(f.content);return g.childNodes.forEach(b=>{var x;b.nodeType===Node.ELEMENT_NODE&&(b.innerHTML===""?b.innerHTML="<br/>":((x=b.lastChild)==null?void 0:x.nodeName)==="BR"&&b.appendChild(document.createElement("br")))}),h.appendChild(g),q1(h),l.classList.remove("ProseMirror-focused"),h.innerHTML}return l.innerHTML}});const r=aa(n,t.enableOnClick),s=Dh(n,t.disableOnEsc);U({editor:n,licenseKey:t.licenseKey,plan:kb,pluginName:gp,cleanup:()=>{n.RichTextEditor.customRte=void 0,r(),s()}})},gp),yp="canvasEmptyState",Ab=F.startup,jb=q(function(n,e={}){const t=new WeakMap,o=new WeakMap,i=new WeakMap,r=new Set,s=new WeakMap,l={emptyStates:[],...e},a=(y,v)=>{let k=!1;const{isValid:w}=v;return Array.isArray(w)?k=w.some(S=>y.is(S)):Le(w)?k=w({component:y,editor:n}):k=y.is(w),k},c=y=>{const v=t.get(y);t.delete(y),v==null||v()},d=y=>{y.views.forEach(v=>c(v)),i.delete(y)},p=y=>{if(!(!y||r.has(y)))try{r.add(y);const v=y.components().length>0,k=i.get(y);if(v&&k)d(y);else if(!v&&!k){const w=s.has(y)?s.get(y):l.emptyStates.find(S=>a(y,S));if(s.set(y,w),!w)return;y.views.forEach(S=>{const E=w.render({editor:n,component:y,componentView:S,mount:T=>{o.set(S,T),i.set(y,!0);const A=S.getChildrenContainer();A==null||A.appendChild(T)},unmount:()=>c(S)});t.set(S,()=>{E==null||E();const T=o.get(S);T==null||T.remove()})})}}finally{r.delete(y)}},u=y=>{i.has(y)&&d(y)},f=({model:y})=>{p(y.getComponent())},h=n.Components.events,g=`${h.update}:components`,b="component:mount",x=n.Canvas.events.frameLoadBody,C=h.removed;n.on(g,p),n.on(b,p),n.on(C,u),n.on(x,f),U({editor:n,licenseKey:l.licenseKey,plan:Ab,pluginName:yp,cleanup:()=>{n.off(g,p),n.off(b,p),n.off(C,u),n.off(x,f)}})},yp),bs="canvasFullSize",$b=F.startup,Pb=(n,e)=>{const{rule:t,ruleView:o}=e,{style:i}=t.attributes;if(i&&i[n]){const r=i[n],s=/([0-9.]+)(vh|dvh|lvh|svh)/g,l=s.test(r),a=o.frameView.model;if(l&&a.hasAutoHeight()){const c=r.replace(s,(p,u)=>`${window.innerHeight*(parseFloat(u)/100)}px`),d=t.toCSS({style:{...i,[n]:c}});e.css=d}}},Nb=n=>{["height","min-height","max-height"].forEach(e=>Pb(e,n))},Ob=q(function(n,e={}){const{Canvas:t,Commands:o,Devices:i,Css:r}=n,s={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:l,canvasOffsetX:a,canvasTransition:c,deviceMaxWidth:d,deviceMinHeigth:p,deviceFixedHeight:u,frameBorderRadius:f,frameTransition:h}=s,g=`${p}px`,b=t.events,x="core:preview",C=`${o.events.stopCommand}${x}`,y=t.getConfig(),v=`${bs}:disable`,k=i.getAll().map(H=>({...H.attributes})),w=c*1e3,S={x:a,y:l};let E={},T,A;y.scrollableCanvas=!u,i.getAll().map(H=>{!H.get("width")&&H.set("width",`${d}px`),!H.get("height")&&H.set("height",u?"100vh":"auto"),!H.get("minHeight")&&H.set("minHeight",g)});const $=H=>{const ve=`${vo}canvas-full-size`,we=document.querySelector(`style[${ve}]`);if(H&&we)return we.remove();const Ze=we||document.createElement("style"),Mi=t.getZoomMultiplier();Ze.setAttribute(ve,"true"),Ze.innerHTML=`
917
+ .gjs-frame-wrapper { transition: width ${h}s !important; }
918
+ .gjs-frame-wrapper__bottom { height: ${l*Mi}px }
919
+ .gjs-frame { border-radius: ${f}px }
920
+ `,!we&&document.body.appendChild(Ze)};n.on(b.frameLoadHead,H=>{if(!y.scrollableCanvas)return;const{window:ve}=H,we=ve.document,Ze=we.head,Mi=`${vo}canvas-full-size-wrappers`,Ai=Ze.querySelector(`style[${Mi}]`)||we.createElement("style");Ai.setAttribute(Mi,"true"),Ai.innerHTML=`
921
921
  body { height: auto !important; }
922
- [data-gjs-type="wrapper"] { min-height: ${m} !important; }
923
- [data-gjs-type="mjml"] { min-height: ${m} !important; }
924
- [data-gjs-type="mj-body"] { min-height: ${m} !important; }
925
- `,!Ke.contains(ks)&&Ke.appendChild(ks)});const N=()=>k.style.display="none",O=()=>k.style.display="",R=()=>{var Ke;if(!u)return;const B=t.getZoomMultiplier(),ve=t.getRect().height*B-l*2;(Ke=s.getSelected())==null||Ke.set("height",`${Math.max(ve,p)}px`),t.fitViewport({zoom:t.getZoom(),gap:x})},_=En(()=>{t.fitViewport({zoom:B=>B>100?100:B,ignoreHeight:!0,gap:x}),R(),P(),setTimeout(()=>{var be,ve;const{em:B}=n;B.destroyed||((ve=(be=n.getSelected())==null?void 0:be.getEl())==null||ve.scrollIntoView({block:"nearest"}),n.refresh({tools:!0}),O(),o.isActive(b)?B.stopDefault():B.runDefault())},S)},100),ue=(B={})=>{B.options&&B.options.from!=="fitViewport"&&t.fitViewport({zoom:t.getZoom(),ignoreHeight:!0,gap:x})},he=()=>{N(),_()},tt=()=>{E.overflowX="hidden",E.overflowY="auto"},Ce=()=>{M==null||M.disconnect(),_.clear()},Ae=[[s.events.select,he],[g.zoom,ue],[w,tt],[n.events.destroy,Ce],[i.events.mountBefore,ny]];o.add(v,()=>{s.devices.reset(C),y.scrollableCanvas=!1,t.getModel().updateDevice(),t.setZoom(100),t.setCoords(0,0),E.overflowY="hidden",P(!0),Ae.forEach(([B,be])=>n.off(B,be)),Ce(),o.run("studio:canvasReload")}),Ae.forEach(([B,be])=>n.on(B,be)),n.onReady(()=>{const B=t.getElement(),be=t.getFramesEl(),ve=t.getCanvasView();k=t.getSpotsEl(),E=B.style,E.overflowX="hidden",be.style.transition=`transform ${c}s`,document.removeEventListener("keypress",ve.onKeyPress),P(),M=new ResizeObserver(()=>{N(),_()}),M.observe(B.parentElement),_()}),j({editor:n,licenseKey:r.licenseKey,plan:ey,pluginName:Kd,cleanup:()=>{n.runCommand(v)}})}),ur="canvasGridMode",sy=F.startup,hr="component-grid-mode",ro="grid-mode",lo="gjs-drag-grid-spot",Jd=`${lo}__grid-item`,Zd=`${lo}__grid-target`,Yd=`${lo}__snapped`,iy=`${lo}__container`,ry=()=>{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=`
926
- .${Jd} {
922
+ [data-gjs-type="wrapper"] { min-height: ${g} !important; }
923
+ [data-gjs-type="mjml"] { min-height: ${g} !important; }
924
+ [data-gjs-type="mj-body"] { min-height: ${g} !important; }
925
+ `,!Ze.contains(Ai)&&Ze.appendChild(Ai)});const P=()=>T.style.display="none",N=()=>T.style.display="",I=()=>{var Ze;if(!u)return;const H=t.getZoomMultiplier(),we=t.getRect().height*H-l*2;(Ze=i.getSelected())==null||Ze.set("height",`${Math.max(we,p)}px`),t.fitViewport({zoom:t.getZoom(),gap:S})},G=An(()=>{t.fitViewport({zoom:H=>H>100?100:H,ignoreHeight:!0,gap:S}),I(),$(),setTimeout(()=>{var ve,we;const{em:H}=n;H.destroyed||((we=(ve=n.getSelected())==null?void 0:ve.getEl())==null||we.scrollIntoView({block:"nearest"}),n.refresh({tools:!0}),N(),o.isActive(x)?H.stopDefault():H.runDefault())},w)},100),he=(H={})=>{H.options&&H.options.from!=="fitViewport"&&t.fitViewport({zoom:t.getZoom(),ignoreHeight:!0,gap:S})},me=()=>{P(),G()},it=()=>{E.overflowX="hidden",E.overflowY="auto"},Te=()=>{A==null||A.disconnect(),G.clear()},$e=[[i.events.select,me],[b.zoom,he],[C,it],[n.events.destroy,Te],[r.events.mountBefore,Nb]];o.add(v,()=>{i.devices.reset(k),y.scrollableCanvas=!1,t.getModel().updateDevice(),t.setZoom(100),t.setCoords(0,0),E.overflowY="hidden",$(!0),$e.forEach(([H,ve])=>n.off(H,ve)),Te(),o.run("studio:canvasReload")}),$e.forEach(([H,ve])=>n.on(H,ve)),n.onReady(()=>{const H=t.getElement(),ve=t.getFramesEl(),we=t.getCanvasView();T=t.getSpotsEl(),E=H.style,E.overflowX="hidden",ve.style.transition=`transform ${c}s`,document.removeEventListener("keypress",we.onKeyPress),$(),A=new ResizeObserver(()=>{P(),G()}),A.observe(H.parentElement),G()}),U({editor:n,licenseKey:s.licenseKey,plan:$b,pluginName:bs,cleanup:()=>{n.runCommand(v)}})},bs),wi="canvasGridMode",Ib=F.startup,ys="component-grid-mode",co="grid-mode",po="gjs-drag-grid-spot",xp=`${po}__grid-item`,vp=`${po}__grid-target`,wp=`${po}__snapped`,Db=`${po}__container`,zb=()=>{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))",i=e.querySelector(`style[${n}]`)||e.createElement("style");i.setAttribute(n,"true"),i.innerHTML=`
926
+ .${xp} {
927
927
  outline: 2px solid ${o};
928
928
  background: ${t};
929
929
  outline-offset: -2px;
@@ -932,14 +932,14 @@
932
932
  height: 100%;
933
933
  opacity: 0.1;
934
934
  }
935
- .${Yd} {
935
+ .${wp} {
936
936
  width: 100%;
937
937
  height: 100%;
938
938
  outline: 2px solid ${o};
939
939
  outline-offset: -2px;
940
940
  position: absolute;
941
941
  }
942
- .${Zd} {
942
+ .${vp} {
943
943
  position: absolute;
944
944
  z-index: -1;
945
945
  background: ${t};
@@ -947,14 +947,14 @@
947
947
  outline-offset: -1px;
948
948
  opacity: 0.35;
949
949
  }
950
- `,e.head.appendChild(s)};function Xd(n){const{editor:e,type:t}=n,o=py(e,n.component),s=fr(e,o.component);if(!uy(e,o,s,t))return{target:o,container:s,startScroll:np(e).scroll,shadowContainerEl:document.createElement("div"),shadowSnappedEl:document.createElement("div"),shadowTargetEl:document.createElement("div"),spot:e.Canvas.addSpot({type:ro,component:s.component})}}function Qd(n){const{editor:e,shadowTargetEl:t,shadowSnappedEl:o,shadowContainerEl:s,spotEl:i,target:r,container:l}=n,{Canvas:a}=e,c=e.config.stylePrefix;i==null||i.appendChild(s),s==null||s.appendChild(t),s==null||s.appendChild(o),ly(s,l),ay(t,r,l),cy(o,r),dy(s,l.el),r.el.style.opacity="0";const d=a.getSpots().filter(p=>p.type!==ro);e.em.stopDefault({preserveSelected:!0}),a.removeSpots(d),a.startAutoscroll(),a.getBody().classList.add(`${c}is__grabbing`)}function ep(n){const{editor:e,shadowSnappedEl:t,shadowContainerEl:o,target:s,cancelled:i}=n,{Canvas:r}=e,l=e.config.stylePrefix,{component:a}=s;if(!i){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}),r.stopAutoscroll(),r.getBody().classList.remove(`${l}is__grabbing`),r.removeSpots({type:ro}),e.select(a)}function ly(n,{rows:e,columns:t}){const o=[];for(let s=0;s<t.length;s++){o[s]=[];for(let i=0;i<e.length;i++){const r=document.createElement("div");r.className=Jd,r.style.gridArea=`${i+1} / ${s+1}`,o[s][i]=r,n.appendChild(r)}}return o}function ay(n,e,t){return n.className=Zd,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 cy(n,e){const t=sp(e.el,e.computedStyles);return n.className=Yd,n.style.gridArea=`${t.row.start} / ${t.column.start} / ${t.row.end} / ${t.column.end}`,n}function dy(n,e){const t=window.getComputedStyle(e);n.className=iy,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 tp(n,e){if(e){if(Array.isArray(e))return[...e].pop()}else return[...n.getSelectedAll()].pop();return e}function py(n,e){const t=tp(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 fr(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(r=>parseFloat(r)),rows:s.gridTemplateRows.split(" ").map(r=>parseFloat(r)),gap:{column:parseInt(s.columnGap),row:parseInt(s.rowGap)}}}function St(n,e,t,o,s=1){let i=0;for(let r=e;r<=n.length;r++){if(i+(n[r-1]+o)*s>t)return r;i+=o+n[r-1]}return n.length+1}function np(n){const{scrollY:e,scrollX:t}=n.Canvas.getWindow();return{scroll:{top:e,left:t}}}function uy(n,e,t,o){const s=i=>n.em.logWarning(i);return o==="draggable"&&e.component.get(o)===!1?(s(`[${ur}] The element is not ${o}`),!0):t.computedStyles.display!=="grid"?(s(`[${ur}] The container does not have style display:grid`),!0):!1}function mr(n,e,t={}){const o=tp(n,e),s=o==null?void 0:o.parent(),i=s==null?void 0:s.getEl();if(!s||!i)return!1;const{enableGrid:r}=t,l=window.getComputedStyle(i).display==="grid";return xt(r)?r({component:o,parent:s,isParentGrid:l}):l}const op=n=>n.split(" ").map(e=>parseFloat(e));function sp(n,e){const t=n.ownerDocument.defaultView,o=e||t.getComputedStyle(n),s=o.gridArea.split("/").some(S=>isNaN(parseInt(S.trim()))),i={isComputed:s,raw:o.gridArea},r={...i,row:{start:parseInt(o.gridRowStart)||1,end:parseInt(o.gridRowEnd)||2},column:{start:parseInt(o.gridColumnStart)||1,end:parseInt(o.gridColumnEnd)||2}};if(!s)return r;const l=n.parentElement;if(!l)return r;const a=t.getComputedStyle(l),c=parseFloat(a.columnGap)||0,d=parseFloat(a.rowGap)||0,p=op(a.gridTemplateColumns),u=op(a.gridTemplateRows),h=parseFloat(a.paddingLeft)||0,f=parseFloat(a.paddingTop)||0,m=l.getBoundingClientRect(),g=n.getBoundingClientRect(),b=(S,x,E,k,M)=>{let P=1,N=k+M;for(let O=0;O<x.length;O++){const R=x[O],_=N+R;if(S>=N&&S<_)return P;N=_+E,P++}return-1},w=b(g.left,p,c,m.left,h),y=b(g.right-1,p,c,m.left,h)+1,v=b(g.top,u,d,m.top,f),C=b(g.bottom-1,u,d,m.top,f)+1;return{...i,row:{start:v,end:C},column:{start:w,end:y}}}function hy(n){n.Commands.add(hr,{stop(){},run(e,t,o={}){const s=Xd({editor:e,component:o.target,type:"draggable"});if(!s){this.stopCommand();return}const{spot:i,target:r,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c,startScroll:d}=s;let{container:p}=s,u;new e.Utils.Dragger({doc:r.el.ownerDocument,onStart:()=>{u=setTimeout(()=>{Qd({editor:e,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:r,container:p}),p=fr(e,r.component)},10)},onEnd:(f,m,{cancelled:g})=>{clearTimeout(u),ep({editor:e,shadowSnappedEl:a,shadowContainerEl:l,target:r,cancelled:g}),this.stopCommand(),e.em.set("_cmpDrag",1)},setPosition:({x:f,y:m})=>{const{scroll:g}=np(e),{columns:b,rows:w,gap:y,offset:v,padding:C}=p,{offset:S,margin:x}=r,E=S.top-v.top-C.top-x.top+m-d.top+g.top,k=S.left-v.left-C.left-x.left+f-d.left+g.left,M=Math.min(St(b,1,k,y.column,.5),b.length),P=Math.min(St(w,1,E,y.row,.5),w.length),N=Math.min(St(b,M,S.width,y.column)+1,b.length+1),O=Math.min(St(w,P,S.height,y.row)+1,w.length+1);a.style.gridArea=`${P} / ${M} / ${O} / ${N}`,c.style.top=`${E+C.top}px`,c.style.left=`${k+C.left}px`}}).start(o.event)}})}function fy(n,e){const t=Xd({editor:n,component:e.component,type:"resizable"});if(!t)return;const{onMove:o,onEnd:s}=e.options||{},{spot:i,target:r,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c}=t;let{container:d}=t,p="",u=!1,h;return{onStart:f=>{p=f.target.dataset.gjsHandler||"",u=!1,h=setTimeout(()=>{Qd({editor:n,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:r,container:d}),d=fr(n,r.component),u=!0},10),n.trigger("component:resize",{...r||{},type:"start"})},onEnd:(f,m)=>{const{startDim:g,rectDim:b}=m.resizer,w=JSON.stringify(g)===JSON.stringify(b);clearTimeout(h),u&&ep({editor:n,shadowSnappedEl:a,shadowContainerEl:l,target:r,cancelled:w}),u=!1,s==null||s(f,m)},onMove:(f,m)=>{if(!u||!a.parentElement)return;const g=sp(a),b=r.margin.left,w=r.margin.top,y=r.margin.bottom,v=r.margin.right,{w:C,t:S,l:x,h:E}=m.resizer.rectDim,k={t:S-w,l:x-b,h:E+w+y,w:C+b+v};p.endsWith("l")&&(g.column.start=St(d.columns,1,k.l-d.offset.left-d.padding.left,d.gap.column,.5)),p.startsWith("t")&&(g.row.start=St(d.rows,1,k.t-d.offset.top-d.padding.top,d.gap.row,.5)),p.endsWith("r")&&(g.column.end=Math.max(St(d.columns,g.column.start,k.w,d.gap.column,.5),g.column.start+1)),p.startsWith("b")&&(g.row.end=Math.max(St(d.rows,g.row.start,k.h,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=`${k.w}px`,c.style.height=`${k.h}px`,c.style.left=`${k.l-d.offset.left}px`,c.style.top=`${k.t-d.offset.top}px`,o==null||o(f,m)}}}const ip=["px","%","em","rem","vw","vh"],my=(n,e)=>{const t=n.Styles.getSectors().find(o=>!!o.getProperty(e));return{sector:t,property:t?t.getProperty(e):void 0}},gy=(n,e)=>my(n,e),yy=(n,{x:e,y:t,mergable:o}={})=>{const s={property:`${n}-x`,type:"integer",units:ip,...e},i={property:`${n}-y`,type:"integer",units:ip,...t};return{property:n,type:"composite",properties:[s,i],...o&&{fromStyle(r,{name:l,separator:a,property:c}){const[d,p]=c.getProperties(),[u,h]=(r[l]||"").split(a);return{[d.getId()]:r[d.getName()]||u||"",[p.getId()]:r[p.getName()]||h||u||""}},toStyle(r,{name:l,property:a}){const[c,d]=a.getProperties(),p=r[c.getId()],u=r[d.getId()];return{[l]:p===u?p:`${p} ${u}`}}}}},gr={display:["grid"]};function by(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),i=o[2];let r=i,l=i;const a=i.match(t);return a&&(r=a[1],l=a[2]),{total:s,min:r===l?"":r,max:l}}function vy(n={}){let e="",t="",o="",s="";const i=m=>m.split("/").map(g=>g.trim()).filter(Boolean),r=n["grid-area"]||"",l=n["grid-column"]||"",a=n["grid-row"]||"",c=i(r),d=i(l),p=i(a),u=c.length,h=d.length,f=p.length;return u===4?(o=c[0],e=c[1],s=c[2],t=c[3]):u===3?(o=c[0],e=c[1],s=c[2]):u===2?(o=c[0],e=c[1]):u===1&&(o=c[0]),h===2?(e=d[0],t=d[1]):h===1&&(e=d[0]),f===2?(o=p[0],s=p[1]):f===1&&(o=p[0]),{columnStart:e,columnEnd:t,rowStart:o,rowEnd:s}}function rp(n){const{property:e,label:t}=n,o="1",s="1fr";return{property:e,label:t,type:"composite",requires:gr,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(i,r){const{name:l,property:a}=r,[c,d,p]=a.getProperties(),u=i[l],h=by(u),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)??"",[p.id]:f===s?"":f}},toStyle(i,{name:r,property:l}){const[a,c,d]=l.getProperties(),p=i[a.id],u=i[c.id],h=i[d.id]||s,f=u&&h?`minmax(${u}, ${h})`:h;return{[r]:`repeat(${p||o}, ${f})`}}}}function Sy(n,e){if(!e.styleableGrid)return;const{property:t,...o}=gy(n,"display");if(!t)return;const s=t.getOption("grid"),i=o.sector;s||t.addOption({id:"grid",label:"Grid"}),i.addProperty(rp({label:"Columns",property:"grid-template-columns"}),{}),i.addProperty(rp({label:"Rows",property:"grid-template-rows"}),{}),i.addProperty({id:"grid-gap",requires:gr,...yy("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})},{}),i.addProperty({type:"composite",property:"grid-area",label:"Grid area",requiresParent:gr,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(r){const l=vy(r);return{"grid-column-start":r["grid-column-start"]||l.columnStart,"grid-column-end":r["grid-column-end"]||l.columnEnd,"grid-row-start":r["grid-row-start"]||l.rowStart,"grid-row-end":r["grid-row-end"]||l.rowEnd}},toStyle(r,{name:l}){const a=r["grid-row-start"]||"auto",c=r["grid-row-end"]||"auto",d=r["grid-column-start"]||"auto",p=r["grid-column-end"]||"auto";return{[l]:`${a} / ${d} / ${c} / ${p}`}}},{})}const xy=W(function(n,e={}){const t={itemResizable:!0,...e},{Canvas:o,Commands:s,Components:i}=n,{itemResizable:r}=t,l=o.events,a=s.events,c=i.events,d=`${a.runBeforeCommand}tlb-move`,p=`${a.runBeforeCommand}resize`;let u;hy(n);const h=({options:y})=>{mr(n,y.target,t)&&(n.runCommand(hr,{...y}),y.abort=!0)},f=y=>{const{options:v}=y;mr(n,v.component,t)&&(v.options=Object.assign(v.options||{},fy(n,v)))},m=()=>{const y=o.getSpots({type:ro}).pop();if(!y)return;let v=y.attributes.spotEl;v||(v=document.createElement("div"),v.className=lo,y.set({spotEl:v})),Object.entries(y.getStyle()).forEach(([C,S])=>v.style.setProperty(C,S)),u==null||u.appendChild(v)},g=({spot:y})=>{const v=y.attributes.spotEl;y.type!==ro||!v||u==null||u.removeChild(v)};if(r){const y=v=>{const C=xt(r)?r({component:v}):r;return typeof C=="boolean"?C:{tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1,...C}};n.on(c.resizeInit,v=>{const{component:C}=v;if(mr(n,C,t)){const S=y(C);v.resizable=S}})}const b=[[d,h],[p,f],[l.spot,m],[l.spotRemove,g]];b.forEach(([y,v])=>{n.on(y,v)}),n.onReady(()=>{u=o.getSpotsEl(),ry(),Sy(n,t)});const w=()=>{delete n.Commands.commands[hr],b.forEach(([y,v])=>{n.off(y,v)})};j({editor:n,licenseKey:t.licenseKey,plan:sy,pluginName:ur,cleanup:w})}),wy="canvasScreenshot",Cy=F.startup;var lp=(n=>(n.screenshot="studioPlugin:screenshot",n))(lp||{});const ky=async n=>await Np([{id:"html-to-image",src:n}]),Ey=async(n,e={},t={})=>{const{cdnScript:o}=t;if(!window.htmlToImage){if(!o)return;await ky(o)}return new Promise((s,i)=>{(async()=>{try{const{canvasWidth:l,canvasHeight:a,width:c,height:d,type:p,quality:u,addOptions:h}=e,f={pixelRatio:1,width:c,height:d,canvasWidth:l,canvasHeight:a},m=(h==null?void 0:h(f))||f,b=await window.htmlToImage.toCanvas(n,m);b.toBlob(w=>{w?s({file:w,canvas:b}):i(new Error("Failed to create file from canvas"))},p,u)}catch(l){i(l)}})()})},yr=lp.screenshot,Ty=W(function(n,e={}){const{Commands:t,Canvas:o,Storage:s}=n,i=s.events.afterStore,r={cdnScript:"https://cdnjs.cloudflare.com/ajax/libs/html-to-image/1.11.13/html-to-image.min.js",...e};t.add(yr,async(c,d,p)=>{const{el:u,...h}=p;return await Ey(u,h,r)});const l=async()=>{var d;const c=o.getBody();if(!c)return n.log("Canvas element not found");try{const p=await n.runCommand(yr,{el:c,canvasWidth:400,canvasHeight:225,width:1200,height:675,type:"image/jpeg"});(d=r.screenshotOnSave)==null||d.call(r,{...p,editor:n})}catch(p){console.error("Screenshot error",p)}};r.screenshotOnSave&&n.on(i,l);const a=()=>{delete t.commands[yr],n.off(i,l)};j({editor:n,licenseKey:e.licenseKey,plan:Cy,pluginName:wy,cleanup:a})});var Ue=(n=>(n.panelBlocks="panelBlocks",n.panelPagesLayers="panelPagesLayers",n.panelGlobalStyles="panelGlobalStyles",n.panelSidebarTabs="panelSidebarTabs",n.panelAssets="panelAssets",n.aiChatPanel="aiChatPanel",n.panelDataSources="panelDataSources",n))(Ue||{});const ap="sidebarButtonsTarget",bs=(n,e)=>{const{id:t,icon:o,label:s,tooltip:i,className:r,skipSelfClose:l,removeLayouts:a,layoutComponent:c,layoutCommand:d}=n,{pluginOpts:p,breakpointProps:u}=e,h=t;return{id:cp(t),type:"button",icon:o,tooltip:s||i,className:r,editorEvents:{[`${Nr.layoutToggleId}${h}`]:({fromEvent:f,setState:m,editor:g})=>{m({active:f.isOpen}),setTimeout(()=>g.refresh({tools:!0}),20)}},onClick:({editor:f,state:m})=>{var C;if(m.active&&l)return;const g=(d==null?void 0:d.placer)||{type:"static",layoutId:ap},b={...g,skipCleanup:g.type==="static"},w=a||Object.keys(Ue).filter(S=>S!==h);dp(f,{removeLayouts:w,layout:{placer:b}});const y={id:h,placer:g,header:(d==null?void 0:d.header)??{label:s,close:!l},layout:c,style:{width:280,height:"100%",borderRightWidth:1,...d==null?void 0:d.style}},v=((C=p==null?void 0:p.sidebarLayoutCommand)==null?void 0:C.call(p,{...u,layoutCommand:y,sidebarButtonProps:n}))||y;f.runCommand(G.layoutToggle,{...v})}}},cp=n=>`button__${n}`,dp=(n,e={})=>{(e.removeLayouts||Object.keys(Ue)).forEach(o=>n.runCommand(G.layoutRemove,{id:o,layout:e.layout}))},pp=n=>{const e=(n==null?void 0:n.breakpointTablet)??1024,t=(n==null?void 0:n.breakpointMobile)??768,o={},s=[{id:Ue.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:Ue.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:Ue.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:Ue.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 w;const m=f.getSelected(),g={type:"image",src:h.src};let b;if(m!=null&&m.is("image"))return m.set("src",h.src);m&&f.Components.canMove(m,g)?b=m.append(g)[0]:m||(b=(w=f.getWrapper())==null?void 0:w.append(g)[0]),b&&f.select(b,{scroll:!0})}}}],i=[...s,{id:Ue.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"}}],r={id:ap,type:"column",className:"gs-cmp-layout-sidebar-target",style:{overflow:"hidden"}},l={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},a={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},c=h=>({breakpoint:h,breakpointTablet:e,breakpointMobile:t}),d=(h,f,m)=>{const g=c(f),b={pluginOpts:n,breakpointProps:g},w=h.map(v=>{const C=bs(v,b);return n!=null&&n.sidebarButton?n.sidebarButton({id:v.id,buttonIds:Ue,buttonProps:C,sidebarButtonProps:v,...g,createSidebarButton:S=>bs({...v,...S},b)}):C}).filter(Boolean);return(n!=null&&n.sidebarButtons?n==null?void 0:n.sidebarButtons({buttonIds:Ue,sidebarButtons:w,...g,createSidebarButton:v=>bs({...v,layoutCommand:{...m==null?void 0:m.layoutCommand,...v.layoutCommand}},b)}):w).filter(Boolean)},p=(h,f,m)=>{var w;const g=c(m),b={pluginOpts:n,breakpointProps:g};return((w=n==null?void 0:n.rootLayout)==null?void 0:w.call(n,{sidebarButtons:f,rootLayout:h,layoutSidebarLeft:l,layoutSidebarTarget:r,...g,createSidebarButton:y=>bs({...y},b)}))??h};if(e){const h=d(i,e);o[e]=p({type:"row",style:{height:"100%"},children:[{...l,children:h},r,a]},h,e)}if(t){const h={placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}},f=i.map(g=>({...g,layoutCommand:h})),m=d(f,t,{layoutCommand:h});o[t]=p({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas",grow:!0},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:m}]},m,t)}const u=d(s,0);return{default:p({type:"row",style:{height:"100%"},children:[{...l,children:u},r,a,{type:"sidebarRight"}]},u,0),responsive:o}},up="layoutSidebarButtons",My=F.free,hp=W(function(n,e={}){const{Commands:t}=n,o=t.events,s={...e};(()=>{if(n.runCommand(G.layoutConfigGet)||s.skipLayoutConfig===!0)return;const l=pp(s);n.runCommand(G.layoutConfigSet,{...l})})(),t.add(`${up}:toggleButton`,(r,l,a)=>{const c=document.getElementById(cp(a==null?void 0:a.id));c==null||c.click()}),n.on(`${o.runCommand}core:preview`,()=>{dp(n)}),j({editor:n,licenseKey:s.licenseKey,plan:My,pluginName:up,cleanup:()=>{n.runCommand(G.layoutConfigSet)}})});hp.createLayoutConfig=n=>pp(n);const jt="page-break";var Le=(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))(Le||{});function br(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 Ay=(n,e)=>{const{name:t,id:o,width:s,height:i,unit:r}=n,{fixedHeight:l}=e,a=`${s}${r}`,c=`${i}${r}`;return{id:o||t.toLowerCase().replace(/\s/g,"-"),name:`${t} (${a} x ${c})`,sizeH:i,sizeW:s,sizeUnit:r,widthMedia:"",width:a,minHeight:l?"0":`${br(i,r)}px`,height:l?c:void 0}},vr="page-breaks",vs="gjs-page-breaks-spot",Sr=n=>n.type===vr;function Py(n){const{Devices:e}=n,{height:t,minHeight:o}=e.getSelected().attributes,i=parseFloat(`${t&&t!=="auto"?t:o}`),r=n.getWrapper(),l=r==null?void 0:r.getEl(),a=[];if(!r||!l)return a;const c=l.getBoundingClientRect().height,p=r.findType(jt).map(h=>h.getEl()).filter(Boolean).map(h=>({top:h.offsetTop,height:h.offsetHeight}));let u=0;for(;u<c;){const h=p.find(f=>f.top>u&&f.top<u+i);h?(u=h.top+h.height,a.push(h.top)):(u+=i,u<c&&a.push(u))}return a}function Ny(n,e){const{Canvas:t}=n,o=t.events,s=n.events;let i;const r=()=>{As(`${go}preset-printable-spots`,`.${vs} {
950
+ `,e.head.appendChild(i)};function Sp(n){const{editor:e,type:t}=n,o=Hb(e,n.component),i=xs(e,o.component);if(!Fb(e,o,i,t))return{target:o,container:i,startScroll:Ep(e).scroll,shadowContainerEl:document.createElement("div"),shadowSnappedEl:document.createElement("div"),shadowTargetEl:document.createElement("div"),spot:e.Canvas.addSpot({type:co,component:i.component})}}function Cp(n){const{editor:e,shadowTargetEl:t,shadowSnappedEl:o,shadowContainerEl:i,spotEl:r,target:s,container:l}=n,{Canvas:a}=e,c=e.config.stylePrefix;r==null||r.appendChild(i),i==null||i.appendChild(t),i==null||i.appendChild(o),Rb(i,l),Lb(t,s,l),Bb(o,s),Vb(i,l.el),s.el.style.opacity="0";const d=a.getSpots().filter(p=>p.type!==co);e.em.stopDefault({preserveSelected:!0}),a.removeSpots(d),a.startAutoscroll(),a.getBody().classList.add(`${c}is__grabbing`)}function kp(n){const{editor:e,shadowSnappedEl:t,shadowContainerEl:o,target:i,cancelled:r}=n,{Canvas:s}=e,l=e.config.stylePrefix,{component:a}=i;if(!r){const c=window.getComputedStyle(t);a.addStyle({"grid-area":c.gridArea,width:"",height:""})}i.el.style.opacity="",o.contains(t)&&(o==null||o.removeChild(t)),e.getModel().runDefault({preserveSelected:1}),s.stopAutoscroll(),s.getBody().classList.remove(`${l}is__grabbing`),s.removeSpots({type:co}),e.select(a)}function Rb(n,{rows:e,columns:t}){const o=[];for(let i=0;i<t.length;i++){o[i]=[];for(let r=0;r<e.length;r++){const s=document.createElement("div");s.className=xp,s.style.gridArea=`${r+1} / ${i+1}`,o[i][r]=s,n.appendChild(s)}}return o}function Lb(n,e,t){return n.className=vp,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 Bb(n,e){const t=Ap(e.el,e.computedStyles);return n.className=wp,n.style.gridArea=`${t.row.start} / ${t.column.start} / ${t.row.end} / ${t.column.end}`,n}function Vb(n,e){const t=window.getComputedStyle(e);n.className=Db,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 Tp(n,e){if(e){if(Array.isArray(e))return[...e].pop()}else return[...n.getSelectedAll()].pop();return e}function Hb(n,e){const t=Tp(n,e),o=t.getEl(),i=window.getComputedStyle(o);return{component:t,el:o,offset:n.Canvas.offset(o),margin:{top:parseFloat(i.marginTop),right:parseFloat(i.marginRight),bottom:parseFloat(i.marginBottom),left:parseFloat(i.marginLeft)},computedStyles:i}}function xs(n,e){const t=e.parent(),o=t.getEl(),i=window.getComputedStyle(o);return{component:t,el:o,offset:n.Canvas.offset(o),computedStyles:i,padding:{top:parseFloat(i.paddingTop),right:parseFloat(i.paddingRight),bottom:parseFloat(i.paddingBottom),left:parseFloat(i.paddingLeft)},columns:i.gridTemplateColumns.split(" ").map(s=>parseFloat(s)),rows:i.gridTemplateRows.split(" ").map(s=>parseFloat(s)),gap:{column:parseInt(i.columnGap),row:parseInt(i.rowGap)}}}function Ct(n,e,t,o,i=1){let r=0;for(let s=e;s<=n.length;s++){if(r+(n[s-1]+o)*i>t)return s;r+=o+n[s-1]}return n.length+1}function Ep(n){const{scrollY:e,scrollX:t}=n.Canvas.getWindow();return{scroll:{top:e,left:t}}}function Fb(n,e,t,o){const i=r=>n.em.logWarning(r);return o==="draggable"&&e.component.get(o)===!1?(i(`[${wi}] The element is not ${o}`),!0):t.computedStyles.display!=="grid"?(i(`[${wi}] The container does not have style display:grid`),!0):!1}function vs(n,e,t={}){const o=Tp(n,e),i=o==null?void 0:o.parent(),r=i==null?void 0:i.getEl();if(!i||!r)return!1;const{enableGrid:s}=t,l=window.getComputedStyle(r).display==="grid";return Le(s)?s({component:o,parent:i,isParentGrid:l}):l}const Mp=n=>n.split(" ").map(e=>parseFloat(e));function Ap(n,e){const t=n.ownerDocument.defaultView,o=e||t.getComputedStyle(n),i=o.gridArea.split("/").some(w=>isNaN(parseInt(w.trim()))),r={isComputed:i,raw:o.gridArea},s={...r,row:{start:parseInt(o.gridRowStart)||1,end:parseInt(o.gridRowEnd)||2},column:{start:parseInt(o.gridColumnStart)||1,end:parseInt(o.gridColumnEnd)||2}};if(!i)return s;const l=n.parentElement;if(!l)return s;const a=t.getComputedStyle(l),c=parseFloat(a.columnGap)||0,d=parseFloat(a.rowGap)||0,p=Mp(a.gridTemplateColumns),u=Mp(a.gridTemplateRows),f=parseFloat(a.paddingLeft)||0,h=parseFloat(a.paddingTop)||0,g=l.getBoundingClientRect(),b=n.getBoundingClientRect(),x=(w,S,E,T,A)=>{let $=1,P=T+A;for(let N=0;N<S.length;N++){const I=S[N],G=P+I;if(w>=P&&w<G)return $;P=G+E,$++}return-1},C=x(b.left,p,c,g.left,f),y=x(b.right-1,p,c,g.left,f)+1,v=x(b.top,u,d,g.top,h),k=x(b.bottom-1,u,d,g.top,h)+1;return{...r,row:{start:v,end:k},column:{start:C,end:y}}}function _b(n){n.Commands.add(ys,{stop(){},run(e,t,o={}){const i=Sp({editor:e,component:o.target,type:"draggable"});if(!i){this.stopCommand();return}const{spot:r,target:s,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c,startScroll:d}=i;let{container:p}=i,u;new e.Utils.Dragger({doc:s.el.ownerDocument,onStart:()=>{u=setTimeout(()=>{Cp({editor:e,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:r.attributes.spotEl,target:s,container:p}),p=xs(e,s.component)},10)},onEnd:(h,g,{cancelled:b})=>{clearTimeout(u),kp({editor:e,shadowSnappedEl:a,shadowContainerEl:l,target:s,cancelled:b}),this.stopCommand(),e.em.set("_cmpDrag",1)},setPosition:({x:h,y:g})=>{const{scroll:b}=Ep(e),{columns:x,rows:C,gap:y,offset:v,padding:k}=p,{offset:w,margin:S}=s,E=w.top-v.top-k.top-S.top+g-d.top+b.top,T=w.left-v.left-k.left-S.left+h-d.left+b.left,A=Math.min(Ct(x,1,T,y.column,.5),x.length),$=Math.min(Ct(C,1,E,y.row,.5),C.length),P=Math.min(Ct(x,A,w.width,y.column)+1,x.length+1),N=Math.min(Ct(C,$,w.height,y.row)+1,C.length+1);a.style.gridArea=`${$} / ${A} / ${N} / ${P}`,c.style.top=`${E+k.top}px`,c.style.left=`${T+k.left}px`}}).start(o.event)}})}function Gb(n,e){const t=Sp({editor:n,component:e.component,type:"resizable"});if(!t)return;const{onMove:o,onEnd:i}=e.options||{},{spot:r,target:s,shadowContainerEl:l,shadowSnappedEl:a,shadowTargetEl:c}=t;let{container:d}=t,p="",u=!1,f;return{onStart:h=>{p=h.target.dataset.gjsHandler||"",u=!1,f=setTimeout(()=>{Cp({editor:n,shadowTargetEl:c,shadowSnappedEl:a,shadowContainerEl:l,spotEl:r.attributes.spotEl,target:s,container:d}),d=xs(n,s.component),u=!0},10),n.trigger("component:resize",{...s||{},type:"start"})},onEnd:(h,g)=>{const{startDim:b,rectDim:x}=g.resizer,C=JSON.stringify(b)===JSON.stringify(x);clearTimeout(f),u&&kp({editor:n,shadowSnappedEl:a,shadowContainerEl:l,target:s,cancelled:C}),u=!1,i==null||i(h,g)},onMove:(h,g)=>{if(!u||!a.parentElement)return;const b=Ap(a),x=s.margin.left,C=s.margin.top,y=s.margin.bottom,v=s.margin.right,{w:k,t:w,l:S,h:E}=g.resizer.rectDim,T={t:w-C,l:S-x,h:E+C+y,w:k+x+v};p.endsWith("l")&&(b.column.start=Ct(d.columns,1,T.l-d.offset.left-d.padding.left,d.gap.column,.5)),p.startsWith("t")&&(b.row.start=Ct(d.rows,1,T.t-d.offset.top-d.padding.top,d.gap.row,.5)),p.endsWith("r")&&(b.column.end=Math.max(Ct(d.columns,b.column.start,T.w,d.gap.column,.5),b.column.start+1)),p.startsWith("b")&&(b.row.end=Math.max(Ct(d.rows,b.row.start,T.h,d.gap.row,.5),b.row.start+1)),a.style.gridArea=`${b.row.start} / ${b.column.start} / ${b.row.end} / ${b.column.end}`,c.style.width=`${T.w}px`,c.style.height=`${T.h}px`,c.style.left=`${T.l-d.offset.left}px`,c.style.top=`${T.t-d.offset.top}px`,o==null||o(h,g)}}}const jp=["px","%","em","rem","vw","vh"],Wb=(n,e)=>{const t=n.Styles.getSectors().find(o=>!!o.getProperty(e));return{sector:t,property:t?t.getProperty(e):void 0}},qb=(n,e)=>Wb(n,e),Ub=(n,{x:e,y:t,mergable:o}={})=>{const i={property:`${n}-x`,type:"integer",units:jp,...e},r={property:`${n}-y`,type:"integer",units:jp,...t};return{property:n,type:"composite",properties:[i,r],...o&&{fromStyle(s,{name:l,separator:a,property:c}){const[d,p]=c.getProperties(),[u,f]=(s[l]||"").split(a);return{[d.getId()]:s[d.getName()]||u||"",[p.getId()]:s[p.getName()]||f||u||""}},toStyle(s,{name:l,property:a}){const[c,d]=a.getProperties(),p=s[c.getId()],u=s[d.getId()];return{[l]:p===u?p:`${p} ${u}`}}}}},ws={display:["grid"]};function Kb(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 i=parseInt(o[1],10),r=o[2];let s=r,l=r;const a=r.match(t);return a&&(s=a[1],l=a[2]),{total:i,min:s===l?"":s,max:l}}function Jb(n={}){let e="",t="",o="",i="";const r=g=>g.split("/").map(b=>b.trim()).filter(Boolean),s=n["grid-area"]||"",l=n["grid-column"]||"",a=n["grid-row"]||"",c=r(s),d=r(l),p=r(a),u=c.length,f=d.length,h=p.length;return u===4?(o=c[0],e=c[1],i=c[2],t=c[3]):u===3?(o=c[0],e=c[1],i=c[2]):u===2?(o=c[0],e=c[1]):u===1&&(o=c[0]),f===2?(e=d[0],t=d[1]):f===1&&(e=d[0]),h===2?(o=p[0],i=p[1]):h===1&&(o=p[0]),{columnStart:e,columnEnd:t,rowStart:o,rowEnd:i}}function $p(n){const{property:e,label:t}=n,o="1",i="1fr";return{property:e,label:t,type:"composite",requires:ws,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,s){const{name:l,property:a}=s,[c,d,p]=a.getProperties(),u=r[l],f=Kb(u),h=(f==null?void 0:f.max)??i;return{[c.id]:(f==null?void 0:f.total)??o,[d.id]:(f==null?void 0:f.min)??"",[p.id]:h===i?"":h}},toStyle(r,{name:s,property:l}){const[a,c,d]=l.getProperties(),p=r[a.id],u=r[c.id],f=r[d.id]||i,h=u&&f?`minmax(${u}, ${f})`:f;return{[s]:`repeat(${p||o}, ${h})`}}}}function Yb(n,e){if(!e.styleableGrid)return;const{property:t,...o}=qb(n,"display");if(!t)return;const i=t.getOption("grid"),r=o.sector;i||t.addOption({id:"grid",label:"Grid"}),r.addProperty($p({label:"Columns",property:"grid-template-columns"}),{}),r.addProperty($p({label:"Rows",property:"grid-template-rows"}),{}),r.addProperty({id:"grid-gap",requires:ws,...Ub("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:ws,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(s){const l=Jb(s);return{"grid-column-start":s["grid-column-start"]||l.columnStart,"grid-column-end":s["grid-column-end"]||l.columnEnd,"grid-row-start":s["grid-row-start"]||l.rowStart,"grid-row-end":s["grid-row-end"]||l.rowEnd}},toStyle(s,{name:l}){const a=s["grid-row-start"]||"auto",c=s["grid-row-end"]||"auto",d=s["grid-column-start"]||"auto",p=s["grid-column-end"]||"auto";return{[l]:`${a} / ${d} / ${c} / ${p}`}}},{})}const Zb=q(function(n,e={}){const t={itemResizable:!0,...e},{Canvas:o,Commands:i,Components:r}=n,{itemResizable:s}=t,l=o.events,a=i.events,c=r.events,d=`${a.runBeforeCommand}tlb-move`,p=`${a.runBeforeCommand}resize`;let u;_b(n);const f=({options:y})=>{vs(n,y.target,t)&&(n.runCommand(ys,{...y}),y.abort=!0)},h=y=>{const{options:v}=y;vs(n,v.component,t)&&(v.options=Object.assign(v.options||{},Gb(n,v)))},g=()=>{const y=o.getSpots({type:co}).pop();if(!y)return;let v=y.attributes.spotEl;v||(v=document.createElement("div"),v.className=po,y.set({spotEl:v})),Object.entries(y.getStyle()).forEach(([k,w])=>v.style.setProperty(k,w)),u==null||u.appendChild(v)},b=({spot:y})=>{const v=y.attributes.spotEl;y.type!==co||!v||u==null||u.removeChild(v)};if(s){const y=v=>{const k=Le(s)?s({component:v}):s;return typeof k=="boolean"?k:{tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1,...k}};n.on(c.resizeInit,v=>{const{component:k}=v;if(vs(n,k,t)){const w=y(k);v.resizable=w}})}const x=[[d,f],[p,h],[l.spot,g],[l.spotRemove,b]];x.forEach(([y,v])=>{n.on(y,v)}),n.onReady(()=>{u=o.getSpotsEl(),zb(),Yb(n,t)});const C=()=>{delete n.Commands.commands[ys],x.forEach(([y,v])=>{n.off(y,v)})};U({editor:n,licenseKey:t.licenseKey,plan:Ib,pluginName:wi,cleanup:C})},wi),Pp="canvasScreenshot",Xb=F.startup;var Np=(n=>(n.screenshot="studioPlugin:screenshot",n))(Np||{});const Qb=async n=>await yu([{id:"html-to-image",src:n}]),ey=async(n,e={},t={})=>{const{cdnScript:o}=t;if(!window.htmlToImage){if(!o)return;await Qb(o)}return new Promise((i,r)=>{(async()=>{try{const{canvasWidth:l,canvasHeight:a,width:c,height:d,type:p,quality:u,addOptions:f}=e,h={pixelRatio:1,width:c,height:d,canvasWidth:l,canvasHeight:a},g=(f==null?void 0:f(h))||h,x=await window.htmlToImage.toCanvas(n,g);x.toBlob(C=>{C?i({file:C,canvas:x}):r(new Error("Failed to create file from canvas"))},p,u)}catch(l){r(l)}})()})},Ss=Np.screenshot,ty=q(function(n,e={}){const{Commands:t,Canvas:o,Storage:i}=n,r=i.events.afterStore,s={cdnScript:"https://cdnjs.cloudflare.com/ajax/libs/html-to-image/1.11.13/html-to-image.min.js",...e};t.add(Ss,async(c,d,p)=>{const{el:u,...f}=p;return await ey(u,f,s)});const l=async()=>{var d;const c=o.getBody();if(!c)return n.log("Canvas element not found");try{const p=await n.runCommand(Ss,{el:c,canvasWidth:400,canvasHeight:225,width:1200,height:675,type:"image/jpeg"});(d=s.screenshotOnSave)==null||d.call(s,{...p,editor:n})}catch(p){console.error("Screenshot error",p)}};s.screenshotOnSave&&n.on(r,l);const a=()=>{delete t.commands[Ss],n.off(r,l)};U({editor:n,licenseKey:e.licenseKey,plan:Xb,pluginName:Pp,cleanup:a})},Pp);var Ye=(n=>(n.panelBlocks="panelBlocks",n.panelPagesLayers="panelPagesLayers",n.panelGlobalStyles="panelGlobalStyles",n.panelSidebarTabs="panelSidebarTabs",n.panelAssets="panelAssets",n.aiChatPanel="aiChatPanel",n.panelDataSources="panelDataSources",n))(Ye||{});const Op="sidebarButtonsTarget",Si=(n,e)=>{const{id:t,icon:o,label:i,tooltip:r,className:s,skipSelfClose:l,removeLayouts:a,layoutComponent:c,layoutCommand:d}=n,{pluginOpts:p,breakpointProps:u}=e,f=t;return{id:Ip(t),type:"button",icon:o,tooltip:i||r,className:s,editorEvents:{[`${Hs.layoutToggleId}${f}`]:({fromEvent:h,setState:g,editor:b})=>{g({active:h.isOpen}),setTimeout(()=>b.refresh({tools:!0}),20)}},onClick:({editor:h,state:g})=>{var k;if(g.active&&l)return;const b=(d==null?void 0:d.placer)||{type:"static",layoutId:Op},x={...b,skipCleanup:b.type==="static"},C=a||Object.keys(Ye).filter(w=>w!==f);Dp(h,{removeLayouts:C,layout:{placer:x}});const y={id:f,placer:b,header:(d==null?void 0:d.header)??{label:i,close:!l},layout:c,style:{width:280,height:"100%",borderRightWidth:1,...d==null?void 0:d.style}},v=((k=p==null?void 0:p.sidebarLayoutCommand)==null?void 0:k.call(p,{...u,layoutCommand:y,sidebarButtonProps:n}))||y;h.runCommand(W.layoutToggle,{...v})}}},Ip=n=>`button__${n}`,Dp=(n,e={})=>{(e.removeLayouts||Object.keys(Ye)).forEach(o=>n.runCommand(W.layoutRemove,{id:o,layout:e.layout}))},zp=n=>{const e=(n==null?void 0:n.breakpointTablet)??1024,t=(n==null?void 0:n.breakpointMobile)??768,o={},i=[{id:Ye.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:Ye.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:Ye.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:Ye.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:f,editor:h})=>{var C;const g=h.getSelected(),b={type:"image",src:f.src};let x;if(g!=null&&g.is("image"))return g.set("src",f.src);g&&h.Components.canMove(g,b)?x=g.append(b)[0]:g||(x=(C=h.getWrapper())==null?void 0:C.append(b)[0]),x&&h.select(x,{scroll:!0})}}}],r=[...i,{id:Ye.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"}}],s={id:Op,type:"column",className:"gs-cmp-layout-sidebar-target",style:{overflow:"hidden"}},l={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},a={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},c=f=>({breakpoint:f,breakpointTablet:e,breakpointMobile:t}),d=(f,h,g)=>{const b=c(h),x={pluginOpts:n,breakpointProps:b},C=f.map(v=>{const k=Si(v,x);return n!=null&&n.sidebarButton?n.sidebarButton({id:v.id,buttonIds:Ye,buttonProps:k,sidebarButtonProps:v,...b,createSidebarButton:w=>Si({...v,...w},x)}):k}).filter(Boolean);return(n!=null&&n.sidebarButtons?n==null?void 0:n.sidebarButtons({buttonIds:Ye,sidebarButtons:C,...b,createSidebarButton:v=>Si({...v,layoutCommand:{...g==null?void 0:g.layoutCommand,...v.layoutCommand}},x)}):C).filter(Boolean)},p=(f,h,g)=>{var C;const b=c(g),x={pluginOpts:n,breakpointProps:b};return((C=n==null?void 0:n.rootLayout)==null?void 0:C.call(n,{sidebarButtons:h,rootLayout:f,layoutSidebarLeft:l,layoutSidebarTarget:s,...b,createSidebarButton:y=>Si({...y},x)}))??f};if(e){const f=d(r,e);o[e]=p({type:"row",style:{height:"100%"},children:[{...l,children:f},s,a]},f,e)}if(t){const f={placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}},h=r.map(b=>({...b,layoutCommand:f})),g=d(h,t,{layoutCommand:f});o[t]=p({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas",grow:!0},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:g}]},g,t)}const u=d(i,0);return{default:p({type:"row",style:{height:"100%"},children:[{...l,children:u},s,a,{type:"sidebarRight"}]},u,0),responsive:o}},Cs="layoutSidebarButtons",ny=F.free,Rp=q(function(n,e={}){const{Commands:t}=n,o=t.events,i={...e};(()=>{if(n.runCommand(W.layoutConfigGet)||i.skipLayoutConfig===!0)return;const l=zp(i);n.runCommand(W.layoutConfigSet,{...l})})(),t.add(`${Cs}:toggleButton`,(s,l,a)=>{const c=document.getElementById(Ip(a==null?void 0:a.id));c==null||c.click()}),n.on(`${o.runCommand}core:preview`,()=>{Dp(n)}),U({editor:n,licenseKey:i.licenseKey,plan:ny,pluginName:Cs,cleanup:()=>{n.runCommand(W.layoutConfigSet)}})},Cs);Rp.createLayoutConfig=n=>zp(n);const Ut="page-break";var Re=(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))(Re||{});function ks(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 oy=(n,e)=>{const{name:t,id:o,width:i,height:r,unit:s}=n,{fixedHeight:l}=e,a=`${i}${s}`,c=`${r}${s}`;return{id:o||t.toLowerCase().replace(/\s/g,"-"),name:`${t} (${a} x ${c})`,sizeH:r,sizeW:i,sizeUnit:s,widthMedia:"",width:a,minHeight:l?"0":`${ks(r,s)}px`,height:l?c:void 0}},Ts="page-breaks",Ci="gjs-page-breaks-spot",Es=n=>n.type===Ts;function iy(n){const{Devices:e}=n,{height:t,minHeight:o}=e.getSelected().attributes,r=parseFloat(`${t&&t!=="auto"?t:o}`),s=n.getWrapper(),l=s==null?void 0:s.getEl(),a=[];if(!s||!l)return a;const c=l.getBoundingClientRect().height,p=s.findType(Ut).map(f=>f.getEl()).filter(Boolean).map(f=>({top:f.offsetTop,height:f.offsetHeight}));let u=0;for(;u<c;){const f=p.find(h=>h.top>u&&h.top<u+r);f?(u=f.top+f.height,a.push(f.top)):(u+=r,u<c&&a.push(u))}return a}function ry(n,e){const{Canvas:t}=n,o=t.events,i=n.events;let r;const s=()=>{Ni(`${vo}preset-printable-spots`,`.${Ci} {
951
951
  position: absolute;
952
952
  left: 0;
953
953
  width: 100%;
954
954
  border-top: 1px dashed var(--gs-theme-cl-cmp-bg2, var(--gjs-color-blue));
955
955
  color: var(--gs-theme-cl-prm-txt, var(--gjs-font-color));
956
956
  }
957
- .${vs}::after {
957
+ .${Ci}::after {
958
958
  background-color: var(--gs-theme-cl-cmp-bg1, var(--gjs-color-highlight));
959
959
  content: attr(data-page-number);
960
960
  display: block;
@@ -965,9 +965,9 @@
965
965
  right: 0;
966
966
  transform: translate(100%, -50%);
967
967
  }
968
- `,{target:window.document.head})},l=()=>{if(e.enablePageBreaksSpot===!1)return;const g={id:vr,type:vr,component:n.getWrapper()};return t.getSpots(g).pop()||t.addSpot(g)},a=({spot:g})=>{const{spotEl:b}=g.attributes;!Sr(g)||!b||!i||i.removeChild(b)},c=({spot:g})=>{if(!Sr(g)||!i)return;let{spotEl:b}=g.attributes;b||(b=document.createElement("div"),b.className=`${vs}__items`,g.set({spotEl:b})),i.appendChild(b)},d=({spot:g})=>{const{spotEl:b,pageBreaks:w=[]}=g.attributes;!Sr(g)||!b||!i||(Object.entries(g.getStyle()).forEach(([y,v])=>b.style.setProperty(y,v)),b.innerHTML="",w.forEach((y,v)=>{const C=document.createElement("div");C.setAttribute("data-page-number",`${v+2}`),C.className=vs,C.style.top=`${y}px`,b.appendChild(C)}))},p=En(()=>{if(n.em.destroyed)return;const g=l();g&&g.set({pageBreaks:Py(n),up:(g.attributes.up||0)+1})},150),u=En(p,200),h=()=>{i=t.getSpotsEl(),l()},f=()=>{const g=l();g&&g.set({up:(g.attributes.up||0)+1})},m=[["component:input",p],["frame:scroll",f],[s.update,p],[o.spotAdd,c],[o.spotUpdate,d],[o.spotRemove,a],[o.frameLoadBody,h]];return m.forEach(([g,b])=>n.on(g,b)),n.onReady(()=>{r(),new ResizeObserver(f).observe(t.getElement().parentElement)}),()=>{m.forEach(([g,b])=>n.off(g,b)),p.clear(),u.clear()}}var xr=(n=>(n.print="presetPrintable:print",n))(xr||{});const fp=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 Oy(n,e){const{Commands:t,Pages:o}=n;return t.add(xr.print,async(s,i,r={})=>{const l={page:r.allPages?void 0:o.getSelected(),styles:"inline",optionsHtml:{exporter:null}},c=(await t.run(G.projectFiles,l)).filter(u=>u.filename.endsWith(".html")),d=c.map(u=>u.content).join('<div style="break-before: page;"></div>'),p=[];if(r.separatePrints)for(const u of c)p.push(await fp(u));else p.push(await fp({content:d,filename:"",mimeType:""}));for(const u of p){const h=u.contentWindow;h.focus(),h.print()}setTimeout(()=>p.forEach(u=>u.remove()),1e3)}),t.add("presetPrintable:exp",async s=>{await Ts("https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"),await Ts("https://cdn.jsdelivr.net/npm/jspdf@3.0.0/dist/jspdf.umd.min.js");const{Devices:i,Canvas:r}=s,{sizeW:l,sizeH:a,sizeUnit:c}=i.getSelected().attributes,d=r.getFrameEl().contentDocument,p="px",u=[br(l,c),br(a,c)],h=new window.jspdf.jsPDF({unit:p,format:u}),f=d.body;h.html(f,{callback:m=>m.save()})}),()=>{delete n.Commands.commands[xr.print]}}function Iy(n,e){const{blockPageBreak:t={}}=e,{Components:o,Blocks:s}=n,i="Page Break",r=`${ke}${jt}`;return o.addType(jt,{block:t&&{label:i,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:$e(jt),model:{defaults:{name:i,classes:r,attributes:{[Pe]:jt},emptyState:!0,stylable:!1,droppable:!1,draggable:Ms("wrapper"),styles:`.${r} { break-before: page; }`,traits:[]}}}),()=>{o.removeType(jt),s.remove(jt)}}const Ry="presetPrintable",Dy=F.free,Ly=W(function(n,e={}){var S;const t={selectedDevice:Le.A4,...e},{Canvas:o,Devices:s,Blocks:i}=n,r=o.events,l=n.events,a=t.selectedDevice||s.getConfig().default,c=[{id:Le.A5,name:"A5",width:148,height:210,unit:"mm"},{id:Le.A5Portrait,name:"A5 Portrait",width:210,height:148,unit:"mm"},{id:Le.A4,name:"A4",width:210,height:297,unit:"mm"},{id:Le.A3,name:"A3",width:297,height:420,unit:"mm"},{id:Le.B5,name:"B5",width:176,height:250,unit:"mm"},{id:Le.B4,name:"B4",width:250,height:353,unit:"mm"},{id:Le.letter,name:"Letter",width:8.5,height:11,unit:"in"},{id:Le.legal,name:"Legal",width:8.5,height:14,unit:"in"},{id:Le.ledger,name:"Ledger",width:11,height:17,unit:"in"}],p=(((S=t.devices)==null?void 0:S.call(t,{items:c}))||c).map(x=>Ay(x,t));s.devices.reset(p);const u=a&&s.get(a)||s.getAll().at(0);s.select(u),["map","video"].forEach(x=>i.remove(x));const f=(x={})=>{const E="page-rule",{rules:k}=n.Css,{width:M,height:P,minHeight:N}=s.getSelected().attributes,O=P&&P!=="auto"?P:N,R=k.where({id:E}).pop(),_=R||k.add({id:E,selectors:[],selectorsAdd:"@page"},{at:0});(x.fromDeviceChange||!R)&&_.addStyle({size:`${M} ${O}`,...!R&&{margin:"0"}})},m=(x,E={})=>{const k=x.document,{minHeight:M}=s.getSelected().attributes,N=`
969
- ${!!parseFloat(`${M}`)?`
970
- [data-gjs-type="wrapper"] { min-height: ${M}; }
968
+ `,{target:window.document.head})},l=()=>{if(e.enablePageBreaksSpot===!1)return;const b={id:Ts,type:Ts,component:n.getWrapper()};return t.getSpots(b).pop()||t.addSpot(b)},a=({spot:b})=>{const{spotEl:x}=b.attributes;!Es(b)||!x||!r||r.removeChild(x)},c=({spot:b})=>{if(!Es(b)||!r)return;let{spotEl:x}=b.attributes;x||(x=document.createElement("div"),x.className=`${Ci}__items`,b.set({spotEl:x})),r.appendChild(x)},d=({spot:b})=>{const{spotEl:x,pageBreaks:C=[]}=b.attributes;!Es(b)||!x||!r||(Object.entries(b.getStyle()).forEach(([y,v])=>x.style.setProperty(y,v)),x.innerHTML="",C.forEach((y,v)=>{const k=document.createElement("div");k.setAttribute("data-page-number",`${v+2}`),k.className=Ci,k.style.top=`${y}px`,x.appendChild(k)}))},p=An(()=>{if(n.em.destroyed)return;const b=l();b&&b.set({pageBreaks:iy(n),up:(b.attributes.up||0)+1})},150),u=An(p,200),f=()=>{r=t.getSpotsEl(),l()},h=()=>{const b=l();b&&b.set({up:(b.attributes.up||0)+1})},g=[["component:input",p],["frame:scroll",h],[i.update,p],[o.spotAdd,c],[o.spotUpdate,d],[o.spotRemove,a],[o.frameLoadBody,f]];return g.forEach(([b,x])=>n.on(b,x)),n.onReady(()=>{s(),new ResizeObserver(h).observe(t.getElement().parentElement)}),()=>{g.forEach(([b,x])=>n.off(b,x)),p.clear(),u.clear()}}var Ms=(n=>(n.print="presetPrintable:print",n))(Ms||{});const Lp=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 sy(n,e){const{Commands:t,Pages:o}=n;return t.add(Ms.print,async(i,r,s={})=>{const l={page:s.allPages?void 0:o.getSelected(),styles:"inline",optionsHtml:{exporter:null}},c=(await t.run(W.projectFiles,l)).filter(u=>u.filename.endsWith(".html")),d=c.map(u=>u.content).join('<div style="break-before: page;"></div>'),p=[];if(s.separatePrints)for(const u of c)p.push(await Lp(u));else p.push(await Lp({content:d,filename:"",mimeType:""}));for(const u of p){const f=u.contentWindow;f.focus(),f.print()}setTimeout(()=>p.forEach(u=>u.remove()),1e3)}),t.add("presetPrintable:exp",async i=>{await $i("https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"),await $i("https://cdn.jsdelivr.net/npm/jspdf@3.0.0/dist/jspdf.umd.min.js");const{Devices:r,Canvas:s}=i,{sizeW:l,sizeH:a,sizeUnit:c}=r.getSelected().attributes,d=s.getFrameEl().contentDocument,p="px",u=[ks(l,c),ks(a,c)],f=new window.jspdf.jsPDF({unit:p,format:u}),h=d.body;f.html(h,{callback:g=>g.save()})}),()=>{delete n.Commands.commands[Ms.print]}}function ly(n,e){const{blockPageBreak:t={}}=e,{Components:o,Blocks:i}=n,r="Page Break",s=`${Ee}${Ut}`;return o.addType(Ut,{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:Be(Ut),model:{defaults:{name:r,classes:s,attributes:{[Pe]:Ut},emptyState:!0,stylable:!1,droppable:!1,draggable:Pi("wrapper"),styles:`.${s} { break-before: page; }`,traits:[]}}}),()=>{o.removeType(Ut),i.remove(Ut)}}const Bp="presetPrintable",ay=F.free,cy=q(function(n,e={}){var w;const t={selectedDevice:Re.A4,...e},{Canvas:o,Devices:i,Blocks:r}=n,s=o.events,l=n.events,a=t.selectedDevice||i.getConfig().default,c=[{id:Re.A5,name:"A5",width:148,height:210,unit:"mm"},{id:Re.A5Portrait,name:"A5 Portrait",width:210,height:148,unit:"mm"},{id:Re.A4,name:"A4",width:210,height:297,unit:"mm"},{id:Re.A3,name:"A3",width:297,height:420,unit:"mm"},{id:Re.B5,name:"B5",width:176,height:250,unit:"mm"},{id:Re.B4,name:"B4",width:250,height:353,unit:"mm"},{id:Re.letter,name:"Letter",width:8.5,height:11,unit:"in"},{id:Re.legal,name:"Legal",width:8.5,height:14,unit:"in"},{id:Re.ledger,name:"Ledger",width:11,height:17,unit:"in"}],p=(((w=t.devices)==null?void 0:w.call(t,{items:c}))||c).map(S=>oy(S,t));i.devices.reset(p);const u=a&&i.get(a)||i.getAll().at(0);i.select(u),["map","video"].forEach(S=>r.remove(S));const h=(S={})=>{const E="page-rule",{rules:T}=n.Css,{width:A,height:$,minHeight:P}=i.getSelected().attributes,N=$&&$!=="auto"?$:P,I=T.where({id:E}).pop(),G=I||T.add({id:E,selectors:[],selectorsAdd:"@page"},{at:0});(S.fromDeviceChange||!I)&&G.addStyle({size:`${A} ${N}`,...!I&&{margin:"0"}})},g=(S,E={})=>{const T=S.document,{minHeight:A}=i.getSelected().attributes,P=`
969
+ ${!!parseFloat(`${A}`)?`
970
+ [data-gjs-type="wrapper"] { min-height: ${A}; }
971
971
  `:`
972
972
  body {
973
973
  overflow: hidden;
@@ -978,33 +978,921 @@
978
978
  height: 100dvh;
979
979
  }
980
980
  `}
981
- `;As(`${go}preset-printable`,N,{doc:k,target:k.head}),f(E)};n.on(r.frameLoadBody,x=>{const E=x.window;if(m(E),t.fixedHeight){const M=x.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 x=(E=o.getFrameEl().contentDocument)==null?void 0:E.defaultView;x&&m(x,{fromDeviceChange:!0})});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(([x,E])=>n.on(x,E));const w=Ny(n,t),y=Oy(n),v=Iy(n,t);n.onReady(()=>{n.UndoManager.clear()});const C=()=>{b.forEach(([x,E])=>n.off(x,E)),w(),y(),v()};n.on(l.destroy,C),j({editor:n,licenseKey:t.licenseKey,plan:Dy,pluginName:Ry,cleanup:C})}),$y=n=>{const e=n;return e.logicalOperator==="and"||e.logicalOperator==="or"},mp=(n,e)=>(n.config.optsHtml={...n.config.optsHtml,exporter:e},()=>{n.config.optsHtml.exporter=void 0}),gp=(n,e)=>{const t=s=>{const{input:i}=s,{contains:r}=e;(!r||i.includes(r))&&(s.input=e.importer.import(i))},o=n.Parser.events.htmlBefore;return n.on(o,t),()=>{n.off(o,t)}};class zy{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:i}=e,r=(o==null?void 0:o.path)||t||"",l=this._sanitizeVariableName(t);let a="";if(s!==void 0||i!==void 0){const c=s??0,d=i!==void 0?i:"";a=`.slice(${c}${d!==""?`, ${d}`:""})`}return`<% ${r}${a}.forEach(function(currentItem, index, arr) {
982
- const startIndex = parseInt(${s??0}, 10);
981
+ `;Ni(`${vo}preset-printable`,P,{doc:T,target:T.head}),h(E)};n.on(s.frameLoadBody,S=>{const E=S.window;if(g(E),t.fixedHeight){const A=S.model.getComponent().getEl();A==null||A.addEventListener("scroll",$=>{const P=$.target;P.scrollTop>0&&P.scrollTo(0,0)})}}),n.on(i.events.select,()=>{var E;const S=(E=o.getFrameEl().contentDocument)==null?void 0:E.defaultView;S&&g(S,{fromDeviceChange:!0})});const b=()=>{const E=n.Css.getRules().filter(T=>T.selectorsToString()==="body").pop();E==null||E.addStyle({"margin-top":"","margin-right":"","margin-bottom":"","margin-left":"",margin:"0"})},x=[[l.projectLoad,b]];x.forEach(([S,E])=>n.on(S,E));const C=ry(n,t),y=sy(n),v=ly(n,t);n.onReady(()=>{n.UndoManager.clear()});const k=()=>{x.forEach(([S,E])=>n.off(S,E)),C(),y(),v()};n.on(l.destroy,k),U({editor:n,licenseKey:t.licenseKey,plan:ay,pluginName:Bp,cleanup:k})},Bp);var Vp=(n=>(n.globalStyles="globalStyles",n.globalData="globalData",n))(Vp||{});const Hp="presetBlockLibrary",dy=F.startup,py=n=>{var e;return n.is("mj-body")&&!!((e=n.parent())!=null&&e.is("mjml"))},L={header:{id:"preset-block-library-header",open:!1,label:"Header",icon:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M21 3a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm-1 2H4v14h16zm-2 2v2H6V7z"/></svg>'},hero:{id:"preset-block-library-hero",open:!1,label:"Hero",icon:'<svg viewBox="0 0 24 24"><path d="M4 20h16a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2m0-9h16v7H4z"/></svg>'},content:{id:"preset-block-library-content",open:!1,label:"Content",icon:'<svg viewBox="0 0 24 24"><path d="M21 3H3c-.6 0-1 .4-1 1v6c0 .6.4 1 1 1h18c.6 0 1-.4 1-1V4c0-.6-.4-1-1-1m0 10H3c-.6 0-1 .4-1 1v6c0 .6.4 1 1 1h18c.6 0 1-.4 1-1v-6c0-.6-.4-1-1-1"/></svg>'},cta:{id:"preset-block-library-cta",open:!1,label:"Call to Action",icon:'<svg viewBox="0 0 24 24"><path d="M13 5a4 4 0 0 1 2 7.46v-1.22A3.01 3.01 0 0 0 13 6a3 3 0 0 0-2 5.24v1.22A4 4 0 0 1 13 5m7 15.5a1.55 1.55 0 0 1-1.5 1.5H13q-.59 0-1-.43l-4-4.2.74-.77a1 1 0 0 1 .76-.32h.2L12 18V9c0-.55.45-1 1-1s1 .45 1 1v4.47l1.21.13 3.94 2.19c.53.24.85.77.85 1.35zM20 2H4a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4v-2H4V4h16v8h-2v2h2v-.04l.04.04c1.09 0 1.96-.91 1.96-2V4a2 2 0 0 0-2-2"/></svg>'},gallery:{id:"preset-block-library-gallery",open:!1,label:"Gallery",icon:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M4 5h7v14H4V5m9 0h7v6h-7V5m0 8h7v6h-7v-6Z"/></svg>'},people:{id:"preset-block-library-people",open:!1,label:"People",icon:'<svg viewBox="0 0 24 24"><path d="M16 17v2H2v-2s0-4 7-4 7 4 7 4m-3.5-9.5A3.5 3.5 0 1 0 9 11a3.5 3.5 0 0 0 3.5-3.5m3.44 5.5A5.3 5.3 0 0 1 18 17v2h4v-2s0-3.63-6.06-4M15 4a3.4 3.4 0 0 0-1.93.59 5 5 0 0 1 0 5.82A3.4 3.4 0 0 0 15 11a3.5 3.5 0 0 0 0-7"/></svg>'},footer:{id:"preset-block-library-footer",open:!1,label:"Footer",icon:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M21 3a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm-1 2H4v14h16zm-2 10v2H6v-2z"/></svg>'}},Fp=({editor:n,content:e},t)=>{var a;if(typeof e!="string"||!Bs(n))return;const o=n.getWrapper(),i=o==null?void 0:o.findFirstType("mj-head"),r=o==null?void 0:o.findFirstType(py),s=!!(t!=null&&t.withGlobalStyles),l=s?` ${((a=r==null?void 0:r.__attrToString)==null?void 0:a.call(r))||""}`:' background-color="#E7E7E7"';return{mjml:`<mjml>${s&&(i==null?void 0:i.toHTML())||""}<mj-body${l}>${e}</mj-body></mjml>`,width:700}},_p={id:"preset-block-library",label:"Preset Blocks",icon:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M13,3V9H21V3M13,21H21V11H13M3,21H11V15H3M3,13H11V3H3V13Z" /></svg>',preview:n=>Fp(n)},uy=n=>n.withGlobalStyles?{..._p,preview:e=>Fp(e,n)}:_p,Kt=vu({width:320,height:96,text:"Logo",bg:"e2e8f0",fg:"334155"}),fy=({id:n,label:e,category:t,library:o})=>({id:n,label:e,category:t,library:o,select:!0,full:!0,media:t.icon}),m={spacing:{section:"10px 0px 10px 0px"},colors:{primary:"#cf549e",secondary:"#7c3aed",white:"#ffffff",text:{heading:"#0f172a",body:"#475569"},bg:{section:"#ffffff",transparent:"#00000000"}},radii:{s:"8px",m:"16px",l:"32px",card:"10px",pill:"999px"},buttons:{primary:'background-color="#cf549e" color="#ffffff"',secondary:'background-color="#7c3aed" color="#ffffff"'},attrs:{bgTransparent:'background-color="#00000000"',bgSection:'background-color="#ffffff"'}},hy="https://images.unsplash.com/photo-1713171158509-f2a6582581a0?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3w3NzE5NjR8MHwxfHNlYXJjaHw0MXx8YWJzdHJhY3QlMjBwdXJwbGUlMjB3YXZlc3xlbnwwfHx8fDE3ODAxNjIzNTd8MA&ixlib=rb-4.1.0&q=80&w=1080",my="https://images.unsplash.com/photo-1637611331620-51149c7ceb94?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3w3NzE5NjR8MHwxfHNlYXJjaHw3M3x8YWJzdHJhY3QlMjBwdXJwbGV8ZW58MHx8fHwxNzgwMjk5NDUxfDA&ixlib=rb-4.1.0&q=80&w=1080",uo="https://images.unsplash.com/photo-1670189577367-2c6ef31a4b8c?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3w3NzE5NjR8MHwxfHNlYXJjaHwxNXx8YWJzdHJhY3QlMjBwdXJwbGV8ZW58MHx8fHwxNzgwMjk5NDMyfDA&ixlib=rb-4.1.0&q=80&w=1080",gy="https://images.unsplash.com/photo-1607371059636-720f2c169e82?q=80&w=928&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",Gp="https://images.unsplash.com/photo-1674247489394-524fef63c0ff?q=80&w=928&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",As="https://images.unsplash.com/photo-1729119578980-91838d6014d9?q=80&w=1160&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",Wp="https://images.unsplash.com/photo-1729119579013-decd9c61c395?q=80&w=1160&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",by="https://images.unsplash.com/photo-1729119578960-45095ebc3b8a?q=80&w=1160&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",yy="https://images.unsplash.com/photo-1729119578920-240c46516e91?q=80&w=1160&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",qp="https://images.unsplash.com/photo-1659468525744-314c75acdd38?q=80&w=2064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",xy="https://images.unsplash.com/photo-1739978291558-6dbdd5b9f9f8?q=80&w=2064&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",vy="https://images.unsplash.com/photo-1698429894924-ee93fc16279a?q=80&w=2200&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",wy="https://images.unsplash.com/photo-1698430484227-006b70bc83cb?q=80&w=2000&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",Sy="https://images.unsplash.com/photo-1698429894931-fa699270a2fa?q=80&w=2200&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",js="https://images.unsplash.com/photo-1638248308805-d488b66ea854?q=80&w=1160&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",Up="https://images.unsplash.com/photo-1706720097169-b4120bb97a30?q=80&w=1160&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",Kp="https://images.unsplash.com/photo-1706720093772-be76963b01a3?q=80&w=1160&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",$s="https://images.unsplash.com/photo-1716032936139-33cb6cd84dc0?q=80&w=1160&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",Ps="https://images.unsplash.com/photo-1566319743996-123ad0f44a68?q=80&w=1160&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",Jp="https://images.unsplash.com/photo-1706466615511-18622e5ef756?q=80&w=1160&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",Yp="https://images.unsplash.com/photo-1527980965255-d3b416303d12?q=80&w=1160&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",Zp="https://images.unsplash.com/photo-1485893086445-ed75865251e0?q=80&w=1160&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",Cy="https://images.unsplash.com/photo-1586299485759-f62264d6b63f?q=80&w=1160&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",ky="https://images.unsplash.com/photo-1595897950118-1037962bc920?q=80&w=1160&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",Ty="https://images.unsplash.com/photo-1642060603505-e716140d45d2?q=80&w=1160&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",Ey=n=>{const e=t=>n.withGlobalStyles?"":` ${t}`;return{presetEmailHeaderLogo:{label:"Centered Logo",category:L.header,getContent:({getImageUrl:t})=>`<mj-section background-color="${m.colors.bg.section}" padding="${m.spacing.section}">
982
+ <mj-column>
983
+ <mj-image src="${t(Kt)}" alt="Brand logo" width="160px"/>
984
+ </mj-column>
985
+ </mj-section>`},presetEmailHeaderLogoNav:{label:"Logo + Menu",category:L.header,getContent:({getImageUrl:t})=>`<mj-section background-color="${m.colors.bg.section}" padding="${m.spacing.section}">
986
+ <mj-column width="35%" vertical-align="middle">
987
+ <mj-image src="${t(Kt)}" alt="Brand logo" width="107px" align="left" />
988
+ </mj-column>
989
+ <mj-column width="65%" vertical-align="middle">
990
+ <mj-navbar align="right" base-url="https://example.com">
991
+ <mj-navbar-link color="#475569" font-size="13px" href="/shop">Shop</mj-navbar-link>
992
+ <mj-navbar-link color="#475569" font-size="13px" href="/stories">Stories</mj-navbar-link>
993
+ <mj-navbar-link color="#475569" font-size="13px" href="/support">Support</mj-navbar-link>
994
+ </mj-navbar>
995
+ </mj-column>
996
+ </mj-section>`},presetEmailHeaderLogoCta:{label:"Logo + Button",category:L.header,getContent:({getImageUrl:t})=>`<mj-section background-color="${m.colors.bg.section}" padding="${m.spacing.section}">
997
+ <mj-column vertical-align="middle">
998
+ <mj-image src="${t(Kt)}" alt="Brand logo" width="120px" align="left" />
999
+ </mj-column>
1000
+ <mj-column vertical-align="middle">
1001
+ <mj-button align="right" ${m.buttons.secondary}>
1002
+ Get started
1003
+ </mj-button>
1004
+ </mj-column>
1005
+ </mj-section>`},presetEmailHeaderSocialLogo:{label:"Logo + Socials",category:L.header,getContent:({getImageUrl:t})=>`<mj-section background-color="${m.colors.bg.section}" padding="${m.spacing.section}">
1006
+ <mj-column vertical-align="middle">
1007
+ <mj-social align="left" mode="horizontal">
1008
+ <mj-social-element name="facebook" background-color="${m.colors.secondary}"></mj-social-element>
1009
+ <mj-social-element name="linkedin" background-color="${m.colors.secondary}"></mj-social-element>
1010
+ <mj-social-element name="youtube" background-color="${m.colors.secondary}"></mj-social-element>
1011
+ </mj-social>
1012
+ </mj-column>
1013
+ <mj-column vertical-align="middle">
1014
+ <mj-image src="${t(Kt)}" alt="Brand logo" width="95px" align="right"/>
1015
+ </mj-column>
1016
+ </mj-section>`},presetEmailHeaderStackedMenu:{label:"Stacked Logo + Menu",category:L.header,getContent:({getImageUrl:t})=>`<mj-wrapper>
1017
+ <mj-section background-color="#ffffff" padding="0px">
1018
+ <mj-column>
1019
+ <mj-image src="${t(Kt)}" alt="Brand logo" width="160px" align="center" />
1020
+ <mj-divider border-width="1px" border-color="#e7e7e7"></mj-divider>
1021
+ </mj-column>
1022
+ </mj-section>
1023
+ <mj-section background-color="#ffffff" padding="0px">
1024
+ <mj-column>
1025
+ <mj-navbar align="center" base-url="https://example.com">
1026
+ <mj-navbar-link color="#475569" font-size="13px" href="/shop">Shop</mj-navbar-link>
1027
+ <mj-navbar-link color="#475569" font-size="13px" href="/stories">Stories</mj-navbar-link>
1028
+ <mj-navbar-link color="#475569" font-size="13px" href="/support">Support</mj-navbar-link>
1029
+ </mj-navbar>
1030
+ </mj-column>
1031
+ </mj-section>
1032
+ </mj-wrapper>`},presetEmailHeroCenteredCta:{label:"Centered Hero + CTA",category:L.hero,getContent:()=>`<mj-section padding="${m.spacing.section}">
1033
+ <mj-column padding="40px 20px" border-radius="20px"${e('background-color="#ffffff"')}>
1034
+ <mj-text padding="5px 0" align="center" font-size="12px" font-weight="700" text-transform="uppercase" letter-spacing="1px"${e('color="#1e293b"')}>
1035
+ Fresh release
1036
+ </mj-text>
1037
+ <mj-text align="center" font-size="32px" font-weight="700" line-height="40px"${e('color="#0f172a"')}>
1038
+ Launch polished campaigns
1039
+ </mj-text>
1040
+ <mj-text align="center" font-size="16px" line-height="24px"${e('color="#334155"')}>
1041
+ Start with ready-made sections, swap in your content, and ship a clean newsletter without building every block from scratch.
1042
+ </mj-text>
1043
+ <mj-spacer height="30px"></mj-spacer>
1044
+ <mj-button align="center" font-weight="700" padding="0" inner-padding="14px 28px" ${e('background-color="#8b5cf6" color="#ffffff" border-radius="999px"')}>
1045
+ Explore the collection
1046
+ </mj-button>
1047
+ </mj-column>
1048
+ </mj-section>`},presetEmailHeroBackground:{label:"Background Hero",category:L.hero,getContent:({getImageUrl:t})=>`<mj-wrapper>
1049
+ <mj-section
1050
+ background-url="${t(hy)}"
1051
+ background-size="cover"
1052
+ background-repeat="no-repeat"
1053
+ background-color="#c7a5c9"
1054
+ padding="110px 24px 96px 24px"
1055
+ border-radius="${m.radii.card}"
1056
+ >
1057
+ <mj-column background-color="#00000000">
1058
+ <mj-text color="#ffffff" align="center" font-weight="700" font-size="12px" line-height="30px" letter-spacing="2px" padding="0">
1059
+ SEASONAL LAUNCH
1060
+ </mj-text>
1061
+ <mj-text align="center" color="#9767c4" font-size="50px" font-weight="700" line-height="52px" letter-spacing="1px" padding="10px 0">
1062
+ UP TO 70% OFF
1063
+ </mj-text>
1064
+ <mj-text color="#ffffff" align="center" font-size="24px" line-height="32px" padding="0">
1065
+ Limited-time collection
1066
+ </mj-text>
1067
+ <mj-button font-size="16px" border-radius="999px" padding="30px 0 0 0" inner-padding="20px 40px" font-weight="700" letter-spacing="1px" background-color="#9767c4" color="#ffffff">
1068
+ SHOP NOW
1069
+ </mj-button>
1070
+ </mj-column>
1071
+ </mj-section>
1072
+ </mj-wrapper>`},presetEmailHeroSplitBackground:{label:"Split Background Hero",category:L.hero,getContent:({getImageUrl:t})=>`<mj-wrapper>
1073
+ <mj-section
1074
+ padding="48px 24px"
1075
+ background-url="${t(my)}"
1076
+ background-color="#c7a5c9"
1077
+ background-size="cover"
1078
+ background-repeat="no-repeat"
1079
+ background-color="#1e293b"
1080
+ border-radius="${m.radii.card}"
1081
+ >
1082
+ <mj-column ${m.attrs.bgTransparent}></mj-column>
1083
+ <mj-column ${m.attrs.bgTransparent}>
1084
+ <mj-text font-size="40px" line-height="48px" color="#ffffff" font-weight="700" padding="0">
1085
+ Spend & Save
1086
+ </mj-text>
1087
+ <mj-text padding="20px 0" color="#ffffff" line-height="24px">
1088
+ Spotlight a campaign with image-led energy while keeping the key message and CTA anchored in a readable column.
1089
+ </mj-text>
1090
+ <mj-button background-color="#ffffff" color="#cf549e" width="100%" border-radius="999px" padding="30px 0 0 0" font-weight="700" letter-spacing="1px">
1091
+ SHOP NOW
1092
+ </mj-button>
1093
+ </mj-column>
1094
+ </mj-section>
1095
+ </mj-wrapper>`},presetEmailHeroImageCopy:{label:"Image + Copy Hero",category:L.hero,getContent:({getImageUrl:t})=>`<mj-wrapper>
1096
+ <mj-section background-color="#ffffff" padding="5px" border-radius="20px">
1097
+ <mj-column vertical-align="middle">
1098
+ <mj-image src="${t(uo)}" alt="Campaign preview" padding="0" border-radius="18px" />
1099
+ </mj-column>
1100
+ <mj-column vertical-align="middle" padding="0 20px">
1101
+ <mj-text color="#0f172a" font-size="28px" font-weight="700" line-height="36px" padding="12px 0">
1102
+ Put your next story front
1103
+ </mj-text>
1104
+ <mj-text color="#475569" line-height="23px" padding="10px 0 20px 0">
1105
+ Combine imagery, concise copy, and a single call to action to guide subscribers toward your most important announcement.
1106
+ </mj-text>
1107
+ <mj-button align="left" background-color="#0f172a" color="#ffffff" border-radius="999px" inner-padding="14px 26px" padding="20px 0 0 0">
1108
+ Read the update
1109
+ </mj-button>
1110
+ </mj-column>
1111
+ </mj-section>
1112
+ </mj-wrapper>`},presetEmailHeroMenuBottom:{label:"Hero + Menu Bottom",category:L.hero,getContent:({getImageUrl:t})=>`<mj-wrapper>
1113
+ <mj-section padding="0" background-color="#8b5cf6" border-radius="10px 10px 0px 0px">
1114
+ <mj-column ${m.attrs.bgTransparent} vertical-align="middle" padding="40px 30px">
1115
+ <mj-image align="left" src="${t(Kt)}" alt="Brand logo" width="100px" padding="0"></mj-image>
1116
+ <mj-text padding="25px 0 0 0" align="left" font-size="52px" font-weight="700" line-height="60px" color="#ffffff">
1117
+ 50% OFF
1118
+ </mj-text>
1119
+ <mj-text padding="0" align="left" font-size="32px" line-height="42px" font-weight="700" color="#ffffff">
1120
+ selected products this week
1121
+ </mj-text>
1122
+ </mj-column>
1123
+ <mj-column ${m.attrs.bgTransparent}>
1124
+ <mj-image src="${t(gy)}" alt="Promotional image" padding="0"></mj-image>
1125
+ </mj-column>
1126
+ </mj-section>
1127
+ <mj-section padding="0">
1128
+ <mj-column border-radius="0px 0px 10px 10px" background-color="#7c3aed">
1129
+ <mj-navbar base-url="https://example.com" align="center">
1130
+ <mj-navbar-link font-weight="700" text-transform="uppercase" padding="20px 15px" color="#ffffff" href="/home">Home</mj-navbar-link>
1131
+ <mj-navbar-link font-weight="700" text-transform="uppercase" padding="20px 15px" color="#ffffff" href="/blog">Blog</mj-navbar-link>
1132
+ <mj-navbar-link font-weight="700" text-transform="uppercase" padding="20px 15px" color="#ffffff" href="/contact">Contact</mj-navbar-link>
1133
+ </mj-navbar>
1134
+ </mj-column>
1135
+ </mj-section>
1136
+ </mj-wrapper>`},presetEmailHeroMenuTop:{label:"Hero + Menu Top",category:L.hero,getContent:({getImageUrl:t})=>`<mj-wrapper>
1137
+ <mj-section padding="20px 24px" background-color="#ffffff" border-radius="10px 10px 0px 0px">
1138
+ <mj-column vertical-align="middle" width="22%">
1139
+ <mj-image src="${t(Kt)}" alt="Brand logo" padding="0"></mj-image>
1140
+ </mj-column>
1141
+ <mj-column ${m.attrs.bgTransparent} vertical-align="middle" width="50%">
1142
+ <mj-navbar align="center">
1143
+ <mj-navbar-link color="#101828" font-size="14px" font-weight="700" href="/home">Home</mj-navbar-link>
1144
+ <mj-navbar-link color="#101828" font-size="14px" font-weight="700" href="/about">About</mj-navbar-link>
1145
+ <mj-navbar-link color="#101828" font-size="14px" font-weight="700" href="/services">Services</mj-navbar-link>
1146
+ </mj-navbar>
1147
+ </mj-column>
1148
+ <mj-column vertical-align="middle" width="28%">
1149
+ <mj-text padding="10px 15px" align="center" font-size="14px" font-weight="700" color="#ffffff" container-background-color="#414141">
1150
+ UPDATES
1151
+ </mj-text>
1152
+ </mj-column>
1153
+ </mj-section>
1154
+ <mj-section padding="0" background-color="#f4f2f8" border-radius="0px 0px 10px 10px">
1155
+ <mj-column ${m.attrs.bgTransparent}>
1156
+ <mj-image src="${t(uo)}" alt="Campaign image" padding="0"></mj-image>
1157
+ </mj-column>
1158
+ <mj-column ${m.attrs.bgTransparent} vertical-align="middle" padding="40px 30px">
1159
+ <mj-text padding="0" align="left" font-size="44px" line-height="48px" color="#d0549e" font-weight="700">
1160
+ Digital
1161
+ </mj-text>
1162
+ <mj-text padding="0" align="left" font-size="38px" line-height="42px" font-weight="700">
1163
+ Marketing
1164
+ </mj-text>
1165
+ <mj-text padding="20px 0" align="left" font-size="14px" line-height="24px">
1166
+ Pair a navigational masthead with a crisp two-column hero for agency intros, event emails, or editorial launches.
1167
+ </mj-text>
1168
+ <mj-button font-size="16px" font-weight="700" padding="10px 0" align="left" inner-padding="15px 30px" background-color="#d0549e" color="#ffffff">
1169
+ Get started
1170
+ </mj-button>
1171
+ </mj-column>
1172
+ </mj-section>
1173
+ </mj-wrapper>`},presetEmailHeroFullWidthBg:{label:"Full Width Background Hero",category:L.hero,getContent:({getImageUrl:t})=>`<mj-section
1174
+ padding="48px 12px"
1175
+ background-url="${t(uo)}"
1176
+ background-size="cover"
1177
+ background-repeat="no-repeat"
1178
+ background-color="#cfaac4"
1179
+ full-width="full-width"
1180
+ >
1181
+ <mj-column background-color="#ffffffab" padding="40px 30px" border-radius="10px" border="2px solid #f4d9eb" width="90%">
1182
+ <mj-text padding="0px 0px 20px 0px" align="left" font-size="38px" line-height="50px" font-weight="700">
1183
+ Your <span style="color: #d0549e;">Conference</span>
1184
+ </mj-text>
1185
+ <mj-text padding="10px 0" align="left" font-size="30px" line-height="36px" font-weight="700">
1186
+ 22-23 September
1187
+ </mj-text>
1188
+ <mj-text padding="0 0 20px 0" align="left" font-size="16px" line-height="24px">
1189
+ Don't miss out on these limited-time events happening across the city!<br/>
1190
+ Grand Horizon Hotel, 123 Innovation Boulevard, Tech City.
1191
+ </mj-text>
1192
+ <mj-button ${m.buttons.primary} align="left" font-size="16px" padding="10px 0" border-radius="999px" inner-padding="15px 30px">
1193
+ Purchase ticket
1194
+ </mj-button>
1195
+ </mj-column>
1196
+ </mj-section>`},presetEmailContentIntro:{label:"Content Intro",category:L.content,getContent:()=>`<mj-section background-color="#ffffff" padding="24px">
1197
+ <mj-column ${m.attrs.bgTransparent}>
1198
+ <mj-text color="${m.colors.primary}" font-size="26px" font-weight="700" line-height="32px" padding="0">
1199
+ A simple intro section
1200
+ </mj-text>
1201
+ <mj-text color="${m.colors.text.body}" line-height="30px" padding="0 0 12px 0">
1202
+ Use this section to set the tone, explain what changed, or frame the key message before readers move into product details and supporting content.
1203
+ </mj-text>
1204
+ <mj-divider border-color="#dbe4f0" border-width="1px" padding="12px 0 0 0" />
1205
+ </mj-column>
1206
+ </mj-section>`},presetEmailContentTwoColumn:{label:"Content Two Column",category:L.content,getContent:()=>`<mj-section background-color="#ffffff" padding="24px">
1207
+ <mj-column ${m.attrs.bgTransparent} padding="0 12px 12px 0">
1208
+ <mj-text color="${m.colors.primary}" font-size="14px" font-weight="700" line-height="28px" padding="0">Label 1</mj-text>
1209
+ <mj-text color="${m.colors.text.heading}" font-size="20px" font-weight="700" line-height="28px" padding="0 0 10px 0">
1210
+ Editorial note
1211
+ </mj-text>
1212
+ <mj-text color="${m.colors.text.body}" font-size="15px" line-height="24px" padding="0">
1213
+ Share context, a product update, or a short story that helps readers understand why this message matters right now.
1214
+ </mj-text>
1215
+ </mj-column>
1216
+ <mj-column ${m.attrs.bgTransparent} padding="0">
1217
+ <mj-text color="${m.colors.primary}" font-size="14px" font-weight="700" line-height="28px" padding="0">Label 2</mj-text>
1218
+ <mj-text color="${m.colors.text.heading}" font-size="20px" font-weight="700" line-height="28px" padding="0 0 10px 0">
1219
+ Key takeaway
1220
+ </mj-text>
1221
+ <mj-text color="${m.colors.text.body}" font-size="15px" line-height="24px" padding="0">
1222
+ Pair it with supporting details, release notes, customer-facing benefits, or a concise summary that encourages the next click.
1223
+ </mj-text>
1224
+ </mj-column>
1225
+ </mj-section>`},presetEmailContentCenterImageColumns:{label:"Center Image Columns",category:L.content,getContent:({getImageUrl:t})=>`<mj-section padding="50px 24px 24px" background-color="#ffffff">
1226
+ <mj-column width="33%">
1227
+ <mj-text color="${m.colors.text.heading}" padding="0 15px 5px" align="right" font-size="16px" font-weight="600">
1228
+ 24/7 support
1229
+ </mj-text>
1230
+ <mj-text color="${m.colors.text.body}" padding="0 15px 30px" align="right" font-size="13px" line-height="22px">
1231
+ Explain one service or capability on the left to frame the main visual.
1232
+ </mj-text>
1233
+ <mj-text color="${m.colors.text.heading}" padding="0 15px 5px" align="right" font-size="16px" font-weight="600">
1234
+ Cloud sync
1235
+ </mj-text>
1236
+ <mj-text color="${m.colors.text.body}" padding="0 15px 30px" align="right" font-size="13px" line-height="22px">
1237
+ A second supporting point balances the composition.
1238
+ </mj-text>
1239
+ </mj-column>
1240
+ <mj-column width="34%">
1241
+ <mj-image src="${t(uo)}" alt="Feature" padding="0 0 30px" border-radius="${m.radii.s}"></mj-image>
1242
+ </mj-column>
1243
+ <mj-column width="33%">
1244
+ <mj-text color="${m.colors.text.heading}" padding="0 15px 5px" align="left" font-size="16px" font-weight="600">
1245
+ Free updates
1246
+ </mj-text>
1247
+ <mj-text color="${m.colors.text.body}" padding="0 15px 30px" align="left" font-size="13px" line-height="22px">
1248
+ The right column works well for platform highlights and benefits.
1249
+ </mj-text>
1250
+ <mj-text color="${m.colors.text.heading}" padding="0 15px 5px" align="left" font-size="16px" font-weight="600">
1251
+ Multi-platform
1252
+ </mj-text>
1253
+ <mj-text color="${m.colors.text.body}" padding="0 15px" align="left" font-size="13px" line-height="22px">
1254
+ Keep each paragraph short so the layout stays clean and easy to scan.
1255
+ </mj-text>
1256
+ </mj-column>
1257
+ </mj-section>`},presetEmailContentRowImageArticle:{label:"Row Image Article",category:L.content,getContent:({getImageUrl:t})=>`<mj-wrapper>
1258
+ <mj-section ${m.attrs.bgSection} padding="0" border-radius="${m.radii.m}">
1259
+ <mj-column ${m.attrs.bgTransparent} width="40%">
1260
+ <mj-image src="${t(As)}" alt="Article" padding="0"></mj-image>
1261
+ </mj-column>
1262
+ <mj-column ${m.attrs.bgTransparent} vertical-align="top" width="60%" padding="20px">
1263
+ <mj-text color="${m.colors.secondary}" font-size="12px" font-weight="700" letter-spacing="1px" padding="0">
1264
+ LABEL
1265
+ </mj-text>
1266
+ <mj-text color="${m.colors.text.heading}" padding="10px 0" align="left" font-size="24px" line-height="34px" font-weight="600">
1267
+ Article heading
1268
+ </mj-text>
1269
+ <mj-text color="${m.colors.text.body}" align="left" font-size="14px" line-height="26px" padding="0">
1270
+ Use the article row for updates, editorial roundups, or product explainers.
1271
+ </mj-text>
1272
+ <mj-button ${m.attrs.bgTransparent} color="${m.colors.text.heading}" font-weight="700" font-size="12px" align="left"
1273
+ border="2px solid ${m.colors.text.heading}" padding="40px 0px 0px 0px">VIEW DETAILS →</mj-button>
1274
+ </mj-column>
1275
+ </mj-section>
1276
+ </mj-wrapper>`},presetEmailContentAlternatingRowImageArticles:{label:"Alternating Row Image Articles",category:L.content,getContent:({getImageUrl:t})=>`<mj-wrapper gap="12px">
1277
+ <mj-section padding="16px 0" border-radius="${m.radii.m}" ${m.attrs.bgSection}>
1278
+ <mj-column ${m.attrs.bgTransparent} width="40%" vertical-align="top" padding="10px 20px">
1279
+ <mj-image src="${t(Wp)}" border-radius="${m.radii.m}" padding="0" alt="Article visual"></mj-image>
1280
+ </mj-column>
1281
+ <mj-column ${m.attrs.bgTransparent} width="60%" vertical-align="top" padding="10px 20px">
1282
+ <mj-text color="${m.colors.secondary}" font-size="12px" font-weight="700" letter-spacing="1px" padding="0">
1283
+ FEATURE STORY
1284
+ </mj-text>
1285
+ <mj-text color="${m.colors.text.heading}" padding="10px 0" align="left" font-size="24px" line-height="34px" font-weight="600">
1286
+ First Article
1287
+ </mj-text>
1288
+ <mj-text color="${m.colors.text.body}" align="left" font-size="14px" line-height="26px" padding="0">
1289
+ Use alternating article rows for updates, editorial roundups, or product explainers that need more room than a standard card.
1290
+ </mj-text>
1291
+ <mj-button ${m.attrs.bgTransparent} color="${m.colors.text.heading}" font-weight="700" font-size="12px" align="left" padding="40px 0px 0px 0px" inner-padding="0">
1292
+ READ MORE →
1293
+ </mj-button>
1294
+ </mj-column>
1295
+ </mj-section>
1296
+ <mj-section padding="16px 0" border-radius="${m.radii.m}" ${m.attrs.bgSection}>
1297
+ <mj-column ${m.attrs.bgTransparent} width="60%" vertical-align="top" padding="10px 20px">
1298
+ <mj-text color="${m.colors.secondary}" font-size="12px" font-weight="700" letter-spacing="1px" padding="0">
1299
+ UPDATE
1300
+ </mj-text>
1301
+ <mj-text color="${m.colors.text.heading}" padding="10px 0" align="left" font-size="24px" line-height="34px" font-weight="600">
1302
+ Second Article
1303
+ </mj-text>
1304
+ <mj-text color="${m.colors.text.body}" align="left" font-size="14px" line-height="26px" padding="0">
1305
+ The mirrored second row keeps longer campaign emails from feeling repetitive while preserving a consistent structure.
1306
+ </mj-text>
1307
+ <mj-button ${m.attrs.bgTransparent} color="${m.colors.text.heading}" font-weight="700" font-size="12px" align="left" padding="40px 0px 0px 0px" inner-padding="0">
1308
+ READ MORE →
1309
+ </mj-button>
1310
+ </mj-column>
1311
+ <mj-column ${m.attrs.bgTransparent} width="40%" vertical-align="top" padding="10px 20px">
1312
+ <mj-image src="${t(As)}" border-radius="${m.radii.m}" padding="0" alt="Article visual"></mj-image>
1313
+ </mj-column>
1314
+ </mj-section>
1315
+ </mj-wrapper>`},presetEmailContentGridArticles:{label:"Grid Articles",category:L.content,getContent:({getImageUrl:t})=>`<mj-wrapper>
1316
+ <mj-section padding="0" border-radius="${m.radii.m} ${m.radii.m} 0 0" ${m.attrs.bgSection}>
1317
+ <mj-column vertical-align="middle">
1318
+ <mj-image src="${t(by)}" alt="Destination one" padding="0"></mj-image>
1319
+ </mj-column>
1320
+ <mj-column ${m.attrs.bgTransparent} vertical-align="middle" padding="34px 24px">
1321
+ <mj-text color="${m.colors.secondary}" font-size="12px" font-weight="700" letter-spacing="1px" padding="0 0 10px">
1322
+ LABEL ONE
1323
+ </mj-text>
1324
+ <mj-text align="left" font-size="22px" line-height="28px" letter-spacing="1px" padding="0">
1325
+ First Article
1326
+ </mj-text>
1327
+ <mj-text padding="8px 0 10px" align="left" font-size="14px" line-height="24px">
1328
+ Pair each image with a short destination, story, or offer summary inside a balanced half-and-half layout.
1329
+ </mj-text>
1330
+ <mj-button border-radius="${m.radii.m}" background-color="${m.colors.secondary}" font-size="12px" font-weight="700" letter-spacing="1px" align="left" padding="30px 0 0 0" width="100%">
1331
+ Book now
1332
+ </mj-button>
1333
+ </mj-column>
1334
+ </mj-section>
1335
+ <mj-section padding="0" border-radius="0 0 ${m.radii.m} ${m.radii.m}" ${m.attrs.bgSection}>
1336
+ <mj-column ${m.attrs.bgTransparent} vertical-align="middle" padding="34px 24px">
1337
+ <mj-text color="${m.colors.secondary}" font-size="12px" font-weight="700" letter-spacing="1px" padding="0 0 10px">
1338
+ LABEL TWO
1339
+ </mj-text>
1340
+ <mj-text align="left" font-size="22px" line-height="28px" letter-spacing="1px" padding="0">
1341
+ Second Article
1342
+ </mj-text>
1343
+ <mj-text padding="8px 0 10px" align="left" font-size="14px" line-height="24px">
1344
+ The second row can invert the order to create a tidy editorial grid without needing a dedicated card component.
1345
+ </mj-text>
1346
+ <mj-button border-radius="${m.radii.m}" background-color="${m.colors.secondary}" font-size="12px" font-weight="700" letter-spacing="1px" align="left" padding="30px 0 0 0" width="100%">
1347
+ Explore the offer
1348
+ </mj-button>
1349
+ </mj-column>
1350
+ <mj-column vertical-align="middle">
1351
+ <mj-image src="${t(yy)}" alt="Destination two" padding="0"></mj-image>
1352
+ </mj-column>
1353
+ </mj-section>
1354
+ </mj-wrapper>`},presetEmailContentSplitArticles:{label:"Split Articles",category:L.content,getContent:({getImageUrl:t})=>`<mj-wrapper>
1355
+ <mj-section padding="0" ${m.attrs.bgSection}>
1356
+ <mj-column ${m.attrs.bgTransparent}>
1357
+ <mj-image src="${t(uo)}" alt="Feature image" padding="0 0 30px"></mj-image>
1358
+ <mj-text padding="0px 10px 10px 10px" color="${m.colors.primary}" font-size="12px" font-weight="700" letter-spacing="1px">
1359
+ LABEL TWO
1360
+ </mj-text>
1361
+ <mj-text padding="0 10px" align="left" font-size="30px" line-height="36px" font-weight="700">
1362
+ Your studio
1363
+ </mj-text>
1364
+ <mj-text padding="15px 10px" align="left" font-size="14px" line-height="24px">
1365
+ Combine image-led storytelling and a short CTA inside a split layout that still feels more editorial than a standard promo row.
1366
+ </mj-text>
1367
+ <mj-button border-radius="${m.radii.m}" background-color="${m.colors.primary}" font-size="14px" font-weight="700" align="left" padding="10px">
1368
+ Read more
1369
+ </mj-button>
1370
+ </mj-column>
1371
+ <mj-column ${m.attrs.bgTransparent} padding="30px 0 0">
1372
+ <mj-text padding="0px 10px 10px 10px" color="${m.colors.primary}" font-size="12px" font-weight="700" letter-spacing="1px">
1373
+ LABEL ONE
1374
+ </mj-text>
1375
+ <mj-text padding="0 10px" align="left" font-size="30px" line-height="36px" font-weight="700">
1376
+ Creative team
1377
+ </mj-text>
1378
+ <mj-text padding="15px 10px" align="left" font-size="14px" line-height="24px">
1379
+ The mirrored second half lets you highlight another department, service, or offer while keeping the section cohesive.
1380
+ </mj-text>
1381
+ <mj-button border-radius="${m.radii.m}" background-color="${m.colors.primary}" font-size="14px" font-weight="700" align="left" padding="10px">
1382
+ Explore more
1383
+ </mj-button>
1384
+ <mj-image src="${t(Gp)}" alt="Image" padding="30px 0 0"></mj-image>
1385
+ </mj-column>
1386
+ </mj-section>
1387
+ </mj-wrapper>`},presetEmailContentColumnImageArticle:{label:"Column Image Article",category:L.content,getContent:({getImageUrl:t})=>`<mj-wrapper>
1388
+ <mj-section padding="5px" border-radius="${m.radii.m}" ${m.attrs.bgSection}>
1389
+ <mj-column ${m.attrs.bgTransparent}>
1390
+ <mj-image src="${t(qp)}" border-radius="${m.radii.m}" padding="0" alt="Article"/>
1391
+ <mj-text padding="24px 12px 12px" font-size="12px" font-weight="700" letter-spacing="1px" color="${m.colors.primary}">
1392
+ LABEL ONE
1393
+ </mj-text>
1394
+ <mj-text color="${m.colors.text.heading}" padding="0px 12px" font-size="28px" font-weight="700" line-height="36px">
1395
+ Put your next story front
1396
+ </mj-text>
1397
+ <mj-text padding="12px 12px 24px" color="${m.colors.text.body}" line-height="26px">
1398
+ Combine imagery, concise copy, and a single call to action to guide subscribers toward your most important announcement.
1399
+ </mj-text>
1400
+ <mj-button align="left" border-radius="999px" padding="12px 12px 24px" inner-padding="12px 32px" ${m.buttons.primary}>
1401
+ READ THE UPDATE
1402
+ </mj-button>
1403
+ </mj-column>
1404
+ </mj-section>
1405
+ </mj-wrapper>`},presetEmailContentTwoColumnImageArticles:{label:"Two Column Image Articles",category:L.content,getContent:({getImageUrl:t})=>`<mj-section padding="16px 0">
1406
+ <mj-column border-radius="${m.radii.s}" padding="${m.radii.s}" width="49%" ${m.attrs.bgSection}>
1407
+ <mj-image src="${t(qp)}" border-radius="${m.radii.s}" padding="0" alt="Article"/>
1408
+ <mj-text color="${m.colors.primary}" padding="24px 12px 12px" font-size="12px" font-weight="700" letter-spacing="1px">
1409
+ LABEL ONE
1410
+ </mj-text>
1411
+ <mj-text color="${m.colors.text.heading}" padding="0px 12px" font-size="18px" font-weight="700" line-height="36px">
1412
+ First Article
1413
+ </mj-text>
1414
+ <mj-text color="${m.colors.text.body}" padding="12px 12px 24px 12px" line-height="26px">
1415
+ Combine imagery, concise copy, and a single call to action to guide subscribers.
1416
+ </mj-text>
1417
+ <mj-button border-radius="${m.radii.s}" align="center" inner-padding="12px 32px" padding="12px" ${m.buttons.primary}>
1418
+ Read the update
1419
+ </mj-button>
1420
+ </mj-column>
1421
+ <mj-column border-radius="${m.radii.s}" padding="${m.radii.s}" width="2%" ${m.attrs.bgTransparent}></mj-column>
1422
+ <mj-column border-radius="${m.radii.s}" padding="${m.radii.s}" width="49%" ${m.attrs.bgSection}>
1423
+ <mj-image src="${t(xy)}" border-radius="${m.radii.s}" padding="0" alt="Article"/>
1424
+ <mj-text color="${m.colors.primary}" padding="24px 12px 12px" font-size="12px" font-weight="700" letter-spacing="1px">
1425
+ LABEL TWO
1426
+ </mj-text>
1427
+ <mj-text color="${m.colors.text.heading}" padding="0px 12px" font-size="18px" font-weight="700" line-height="36px">
1428
+ Second Article
1429
+ </mj-text>
1430
+ <mj-text color="${m.colors.text.body}" padding="12px 12px 24px 12px" line-height="26px">
1431
+ Product update, or a short story that helps readers understand why this message.
1432
+ </mj-text>
1433
+ <mj-button border-radius="${m.radii.s}" align="center" inner-padding="12px 32px" padding="12px" ${m.buttons.primary}>
1434
+ Read the update
1435
+ </mj-button>
1436
+ </mj-column>
1437
+ </mj-section>`},presetEmailContentThreeColumnImageArticles:{label:"Three Column Image Articles",category:L.content,getContent:({getImageUrl:t})=>`<mj-section padding="16px 0">
1438
+ <mj-column border-radius="${m.radii.s}" padding="${m.radii.s}" width="32%" ${m.attrs.bgSection}>
1439
+ <mj-image src="${t(vy)}" border-radius="${m.radii.s}" padding="0" alt="Article"/>
1440
+ <mj-text color="${m.colors.secondary}" padding="12px 12px 8px" font-size="10px" font-weight="700" letter-spacing="1px">
1441
+ LABEL ONE
1442
+ </mj-text>
1443
+ <mj-text color="${m.colors.text.heading}" padding="0px 12px" font-size="16px" font-weight="700" line-height="24px">
1444
+ First Article
1445
+ </mj-text>
1446
+ <mj-text color="${m.colors.text.body}" padding="12px" line-height="24px" font-size="14px">
1447
+ Combine imagery, concise copy, and a single call to action.
1448
+ </mj-text>
1449
+ <mj-button border-radius="${m.radii.l}" align="center" inner-padding="${m.radii.s}" padding="${m.radii.s}" width="100%" ${m.buttons.secondary}>
1450
+ OPEN
1451
+ </mj-button>
1452
+ </mj-column>
1453
+ <mj-column border-radius="${m.radii.s}" padding="${m.radii.s}" width="2%" ${m.attrs.bgTransparent}></mj-column>
1454
+ <mj-column border-radius="${m.radii.s}" padding="${m.radii.s}" width="32%" ${m.attrs.bgSection}>
1455
+ <mj-image src="${t(wy)}" border-radius="${m.radii.s}" padding="0" alt="Article"/>
1456
+ <mj-text color="${m.colors.secondary}" padding="12px 12px 8px" font-size="10px" font-weight="700" letter-spacing="1px">
1457
+ LABEL TWO
1458
+ </mj-text>
1459
+ <mj-text color="${m.colors.text.heading}" padding="0px 12px" font-size="16px" font-weight="700" line-height="24px">
1460
+ Second Article
1461
+ </mj-text>
1462
+ <mj-text color="${m.colors.text.body}" padding="12px" line-height="24px" font-size="14px">
1463
+ Short story that helps understand the message.
1464
+ </mj-text>
1465
+ <mj-button border-radius="${m.radii.l}" align="center" inner-padding="${m.radii.s}" padding="${m.radii.s}" width="100%" ${m.buttons.secondary}>
1466
+ READ
1467
+ </mj-button>
1468
+ </mj-column>
1469
+ <mj-column border-radius="${m.radii.s}" padding="${m.radii.s}" width="2%" ${m.attrs.bgTransparent}></mj-column>
1470
+ <mj-column border-radius="${m.radii.s}" padding="${m.radii.s}" width="32%" ${m.attrs.bgSection}>
1471
+ <mj-image src="${t(Sy)}" border-radius="${m.radii.s}" padding="0" alt="Article"/>
1472
+ <mj-text color="${m.colors.secondary}" padding="12px 12px 8px" font-size="10px" font-weight="700" letter-spacing="1px">
1473
+ LABEL THREE
1474
+ </mj-text>
1475
+ <mj-text color="${m.colors.text.heading}" padding="0px 12px" font-size="16px" font-weight="700" line-height="24px">
1476
+ Third Article
1477
+ </mj-text>
1478
+ <mj-text color="${m.colors.text.body}" padding="12px" line-height="24px" font-size="14px">
1479
+ Round out the trio with the last supporting point.
1480
+ </mj-text>
1481
+ <mj-button border-radius="${m.radii.l}" align="center" inner-padding="${m.radii.s}" padding="${m.radii.s}" width="100%" ${m.buttons.secondary}>
1482
+ MORE
1483
+ </mj-button>
1484
+ </mj-column>
1485
+ </mj-section>`},presetEmailTwoColumnProducts:{label:"Two Column Products",category:L.content,getContent:({getImageUrl:t})=>`<mj-section padding="12px" ${m.attrs.bgSection}>
1486
+ <mj-column padding="15px" ${m.attrs.bgTransparent}>
1487
+ <mj-image src="${t(As)}" alt="Product" border-radius="${m.radii.s}" padding="${m.radii.s}"></mj-image>
1488
+ <mj-text padding="15px 10px 5px" align="left" line-height="24px" letter-spacing="1px">
1489
+ <b style="background-color:${m.colors.secondary};border-radius:${m.radii.l};color:white;padding:6px 12px;font-size:10px;">Category</b>
1490
+ </mj-text>
1491
+ <mj-text padding="0 10px" align="left" font-size="26px" line-height="34px" color="${m.colors.text.heading}" font-weight="900">
1492
+ Product one
1493
+ </mj-text>
1494
+ <mj-text padding="10px" align="left" font-size="14px" line-height="24px" color="${m.colors.text.body}">
1495
+ Use this format for featured products, bundles, or collections.
1496
+ </mj-text>
1497
+ <mj-text padding="0 10px 5px" align="left" font-size="14px" color="${m.colors.text.body}">FROM</mj-text>
1498
+ <mj-text padding="0 10px 20px" align="left" font-size="28px" line-height="32px" color="${m.colors.secondary}" font-weight="700">
1499
+ $129 <s style="font-size:16px;font-weight:300;color:${m.colors.text.body}">$289</s>
1500
+ </mj-text>
1501
+ <mj-button background-color="${m.colors.text.heading}" color="#ffffff" font-size="14px" font-weight="700" letter-spacing="1px" padding="0 10px" width="100%" border-radius="${m.radii.s}">
1502
+ Buy now
1503
+ </mj-button>
1504
+ </mj-column>
1505
+ <mj-column padding="15px" ${m.attrs.bgTransparent}>
1506
+ <mj-image src="${t(Wp)}" alt="Product" border-radius="${m.radii.s}" padding="${m.radii.s}"></mj-image>
1507
+ <mj-text padding="15px 10px 5px" align="left" line-height="24px" letter-spacing="1px">
1508
+ <b style="background-color:${m.colors.secondary};border-radius:${m.radii.l};color:white;padding:6px 12px;font-size:10px;">Category</b>
1509
+ </mj-text>
1510
+ <mj-text padding="0 10px" align="left" font-size="26px" line-height="34px" color="${m.colors.text.heading}" font-weight="900">
1511
+ Product two
1512
+ </mj-text>
1513
+ <mj-text padding="10px" align="left" font-size="14px" line-height="24px" color="${m.colors.text.body}">
1514
+ The second card mirrors the first so you can build compact sections.
1515
+ </mj-text>
1516
+ <mj-text padding="0 10px 5px" align="left" font-size="14px" color="${m.colors.text.body}">FROM</mj-text>
1517
+ <mj-text padding="0 10px 20px" align="left" font-size="28px" line-height="32px" color="${m.colors.secondary}" font-weight="700">
1518
+ $89 <s style="font-size:16px;font-weight:300;color:${m.colors.text.body}">$189</s>
1519
+ </mj-text>
1520
+ <mj-button background-color="${m.colors.text.heading}" color="#ffffff" font-size="14px" font-weight="700" letter-spacing="1px" padding="0 10px" width="100%" border-radius="${m.radii.s}">
1521
+ Buy now
1522
+ </mj-button>
1523
+ </mj-column>
1524
+ </mj-section>`},presetEmailThreePricingCards:{label:"Three Pricing Cards",category:L.content,getContent:()=>`<mj-section padding="24px 0" ${m.attrs.bgTransparent}>
1525
+ <mj-column width="32%" border-radius="4px" padding="10px" ${m.attrs.bgSection}>
1526
+ <mj-text padding="20px 0 10px 0" align="center" color="${m.colors.secondary}" font-size="16px">Starter pass</mj-text>
1527
+ <mj-text padding="10px 0 20px 0" align="center" font-size="36px" font-weight="700">$49</mj-text>
1528
+ <mj-divider border-style="dashed" border-width="4px" border-color="#47556955"></mj-divider>
1529
+ <mj-text padding="15px 0" align="center" line-height="24px" font-size="12px">
1530
+ Workshops<br/>
1531
+ Keynotes<br/>
1532
+ Community access
1533
+ </mj-text>
1534
+ <mj-button width="100%" font-size="12px" padding="10px 0" border-radius="${m.radii.s}" ${m.buttons.secondary}>Purchase</mj-button>
1535
+ </mj-column>
1536
+ <mj-column padding="${m.radii.s}" width="2%" ${m.attrs.bgTransparent}></mj-column>
1537
+ <mj-column width="32%" border-radius="4px" padding="10px" ${m.attrs.bgSection}>
1538
+ <mj-text padding="20px 0 10px 0" align="center" color="${m.colors.secondary}" font-size="16px">Full pass</mj-text>
1539
+ <mj-text padding="10px 0 20px 0" align="center" font-size="36px" font-weight="700">$149</mj-text>
1540
+ <mj-divider border-style="dashed" border-width="4px" border-color="#47556955"></mj-divider>
1541
+ <mj-text padding="15px 0" align="center" line-height="24px" font-size="12px">
1542
+ All sessions<br/>
1543
+ Workshops<br/>
1544
+ Networking events
1545
+ </mj-text>
1546
+ <mj-button width="100%" font-size="12px" padding="10px 0" border-radius="${m.radii.s}" ${m.buttons.secondary}>Purchase</mj-button>
1547
+ </mj-column>
1548
+ <mj-column padding="${m.radii.s}" width="2%" ${m.attrs.bgTransparent}></mj-column>
1549
+ <mj-column width="32%" border-radius="4px" padding="10px" ${m.attrs.bgSection}>
1550
+ <mj-text padding="20px 0 10px 0" align="center" color="${m.colors.secondary}" font-size="16px">VIP pass</mj-text>
1551
+ <mj-text padding="10px 0 20px 0" align="center" font-size="36px" font-weight="700">$249</mj-text>
1552
+ <mj-divider border-style="dashed" border-width="4px" border-color="#47556955"></mj-divider>
1553
+ <mj-text padding="15px 0" align="center" line-height="24px" font-size="12px">
1554
+ Priority seating<br/>
1555
+ Private sessions<br/>
1556
+ Speaker lounge
1557
+ </mj-text>
1558
+ <mj-button width="100%" font-size="12px" padding="10px 0" border-radius="${m.radii.s}" ${m.buttons.secondary}>Purchase</mj-button>
1559
+ </mj-column>
1560
+ </mj-section>`},presetEmailGridGallery:{label:"Grid Gallery",category:L.gallery,getContent:({getImageUrl:t})=>`<mj-wrapper>
1561
+ <mj-section padding="16px 24px" border-radius="${m.radii.s} ${m.radii.s} 0 0" ${m.attrs.bgSection}>
1562
+ <mj-column>
1563
+ <mj-text color="${m.colors.text.heading}" align="center" font-size="24px" line-height="35px" letter-spacing="1px">
1564
+ Grid Gallery
1565
+ </mj-text>
1566
+ </mj-column>
1567
+ </mj-section>
1568
+ <mj-section padding="0 24px" ${m.attrs.bgSection}>
1569
+ <mj-column width="33.33%" ${m.attrs.bgTransparent}><mj-image src="${t(js)}" alt="Image" padding="5px" border-radius="${m.radii.s}"></mj-image></mj-column>
1570
+ <mj-column width="33.33%" ${m.attrs.bgTransparent}><mj-image src="${t(Up)}" alt="Image" padding="5px" border-radius="${m.radii.s}"></mj-image></mj-column>
1571
+ <mj-column width="33.33%" ${m.attrs.bgTransparent}><mj-image src="${t(Kp)}" alt="Image" padding="5px" border-radius="${m.radii.s}"></mj-image></mj-column>
1572
+ </mj-section>
1573
+ <mj-section padding="0 24px" ${m.attrs.bgSection}>
1574
+ <mj-column width="33.33%" ${m.attrs.bgTransparent}><mj-image src="${t($s)}" alt="Image" padding="5px" border-radius="${m.radii.s}"></mj-image></mj-column>
1575
+ <mj-column width="33.33%" ${m.attrs.bgTransparent}><mj-image src="${t(Ps)}" alt="Image" padding="5px" border-radius="${m.radii.s}"></mj-image></mj-column>
1576
+ <mj-column width="33.33%" ${m.attrs.bgTransparent}><mj-image src="${t(Jp)}" alt="Image" padding="5px" border-radius="${m.radii.s}"></mj-image></mj-column>
1577
+ </mj-section>
1578
+ <mj-section padding="0px 24px 8px 24px" border-radius="0 0 ${m.radii.s} ${m.radii.s}" ${m.attrs.bgSection}>
1579
+ <mj-column>
1580
+ <mj-spacer/>
1581
+ </mj-column>
1582
+ </mj-section>
1583
+ </mj-wrapper>`},presetEmailSplitImageGallery:{label:"Split Image Gallery",category:L.gallery,getContent:({getImageUrl:t})=>`<mj-wrapper>
1584
+ <mj-section padding="24px" border-radius="${m.radii.s} ${m.radii.s} 0 0" ${m.attrs.bgSection}>
1585
+ <mj-column width="66.66%" ${m.attrs.bgTransparent}>
1586
+ <mj-image src="${t(js)}" alt="Image" padding="5px" border-radius="${m.radii.s}"></mj-image>
1587
+ </mj-column>
1588
+ <mj-column width="33.33%" ${m.attrs.bgTransparent}>
1589
+ <mj-image src="${t($s)}" alt="Image" padding="5px" border-radius="${m.radii.s}"></mj-image>
1590
+ <mj-image src="${t(Ps)}" alt="Image" padding="5px" border-radius="${m.radii.s}"></mj-image>
1591
+ </mj-column>
1592
+ </mj-section>
1593
+ <mj-section padding="0 24px 8px 24px" border-radius="0 0 ${m.radii.s} ${m.radii.s}" ${m.attrs.bgSection}>
1594
+ <mj-column ${m.attrs.bgTransparent}>
1595
+ <mj-text padding="0 0 12px 0" line-height="30px" align="center" font-size="16px" color="${m.colors.text.body}">
1596
+ Use this section to set the tone, explain what changed, or frame the key message into product details and supporting content.
1597
+ </mj-text>
1598
+ <mj-button padding="12px 12px 24px" inner-padding="12px 48px" border-radius="${m.radii.l}" ${m.buttons.primary}>
1599
+ VIEW MORE
1600
+ </mj-button>
1601
+ </mj-column>
1602
+ </mj-section>
1603
+ </mj-wrapper>`},presetEmailMasonryGallery:{label:"Masonry Gallery",category:L.gallery,getContent:({getImageUrl:t})=>`<mj-wrapper>
1604
+ <mj-section padding="16px 24px" border-radius="${m.radii.s} ${m.radii.s} 0 0" ${m.attrs.bgSection}>
1605
+ <mj-column>
1606
+ <mj-text color="${m.colors.primary}" align="center" font-size="24px" line-height="35px" letter-spacing="1px">
1607
+ Masonry Gallery
1608
+ </mj-text>
1609
+ <mj-text padding="0 0 12px 0" line-height="30px" align="center" font-size="16px" color="${m.colors.text.body}">
1610
+ Use this section to set the tone, explain what changed, or frame the key message into product details and supporting content.
1611
+ </mj-text>
1612
+ </mj-column>
1613
+ </mj-section>
1614
+ <mj-section padding="0" ${m.attrs.bgSection}>
1615
+ <mj-column width="33.33%" ${m.attrs.bgTransparent}>
1616
+ <mj-image src="${t(js)}" alt="Image" padding="0"></mj-image>
1617
+ <mj-image src="${t(Up)}" alt="Image" padding="0"></mj-image>
1618
+ </mj-column>
1619
+ <mj-column width="66.66%" ${m.attrs.bgTransparent}>
1620
+ <mj-image src="${t(Kp)}" alt="Image" padding="0"></mj-image>
1621
+ </mj-column>
1622
+ </mj-section>
1623
+ <mj-section padding="0" ${m.attrs.bgSection}>
1624
+ <mj-column width="33.33%" ${m.attrs.bgTransparent}><mj-image src="${t($s)}" alt="Image" padding="0"></mj-image></mj-column>
1625
+ <mj-column width="33.33%" ${m.attrs.bgTransparent}><mj-image src="${t(Ps)}" alt="Image" padding="0"></mj-image></mj-column>
1626
+ <mj-column width="33.33%" ${m.attrs.bgTransparent}><mj-image src="${t(Jp)}" alt="Image" padding="0"></mj-image></mj-column>
1627
+ </mj-section>
1628
+ <mj-section padding="0 24px 8px" border-radius="0 0 ${m.radii.s} ${m.radii.s}" ${m.attrs.bgSection}>
1629
+ <mj-column ${m.attrs.bgTransparent}>
1630
+ <mj-button padding="36px 24px 12px" inner-padding="12px 48px" border-radius="${m.radii.l}" ${m.buttons.primary}>
1631
+ VIEW MORE
1632
+ </mj-button>
1633
+ </mj-column>
1634
+ </mj-section>
1635
+ </mj-wrapper>`},presetEmailCtaPromoBanner:{label:"Promo Banner",category:L.cta,getContent:()=>`<mj-wrapper>
1636
+ <mj-section padding="32px 24px" background-color="${m.colors.secondary}" border-radius="${m.radii.m}">
1637
+ <mj-column vertical-align="middle" width="65%" ${m.attrs.bgTransparent}>
1638
+ <mj-text padding="0 0 8px 0" color="#ffffff" font-size="26px" font-weight="700" line-height="34px">
1639
+ Save your strongest CTA
1640
+ </mj-text>
1641
+ <mj-text padding="0px 0px 12px 0px" color="#ffffffde" font-size="15px" line-height="23px">
1642
+ Great for a launch push, limited-time campaign, or any section.
1643
+ </mj-text>
1644
+ </mj-column>
1645
+ <mj-column vertical-align="middle" width="35%" ${m.attrs.bgTransparent}>
1646
+ <mj-button align="right" background-color="#ffffff" color="${m.colors.secondary}" border-radius="${m.radii.l}" font-weight="700" inner-padding="14px 38px" padding="0px">
1647
+ CLAIM OFFER
1648
+ </mj-button>
1649
+ </mj-column>
1650
+ </mj-section>
1651
+ </mj-wrapper>`},presetEmailCtaOfferBanner:{label:"Offer Banner",category:L.cta,getContent:({getImageUrl:t})=>`<mj-wrapper>
1652
+ <mj-section padding="64px 32px" background-color="${m.colors.primary}" border-radius="${m.radii.m}"
1653
+ background-url="${t(Gp)}" background-size="cover" background-repeat="no-repeat" border="2px solid #e59fc9"
1654
+ >
1655
+ <mj-column ${m.attrs.bgTransparent}>
1656
+ <mj-text padding="0px 0px 8px 0px" font-weight="700" letter-spacing="1px" align="center">
1657
+ <b style="background-color:${m.colors.primary};color:white;padding:6px 12px;border-radius:${m.radii.m};font-size:8px;">
1658
+ LIMITED-TIME CODE
1659
+ </b>
1660
+ </mj-text>
1661
+ <mj-text padding="12px 0" color="#8c3469" font-size="20px" line-height="26px" align="center">
1662
+ Use <span style="font-weight:700;">WELCOME20</span> to unlock a launch offer before Friday.
1663
+ </mj-text>
1664
+ <mj-button background-color="#ffffff" color="${m.colors.primary}" border-radius="${m.radii.l}" inner-padding="12px 38px" padding="20px 0 0 0" font-weight="700" font-size="18px">
1665
+ REDEEM NOW
1666
+ </mj-button>
1667
+ </mj-column>
1668
+ </mj-section>
1669
+ </mj-wrapper>`},presetEmailThreeTeamProfiles:{label:"Three Team Profiles",category:L.people,getContent:({getImageUrl:t})=>`<mj-wrapper>
1670
+ <mj-section padding="24px 32px 12px" border-radius="${m.radii.m} ${m.radii.m} 0 0" ${m.attrs.bgSection}>
1671
+ <mj-column ${m.attrs.bgTransparent}>
1672
+ <mj-text padding="12px 0 0 " color="#0f172977" font-size="22px">Event speakers</mj-text>
1673
+ <mj-text padding="12px 0 10px 0" font-size="42px" line-height="50px" font-weight="700" color="${m.colors.text.heading}">
1674
+ Meet our speakers
1675
+ </mj-text>
1676
+ <mj-divider border-width="1px" border-color="#0f172933" padding="12px 0"></mj-divider>
1677
+ </mj-column>
1678
+ </mj-section>
1679
+ <mj-section padding="20px 12px 40px" border-radius="0 0 ${m.radii.m} ${m.radii.m}" ${m.attrs.bgSection}>
1680
+ <mj-column width="33.33%" ${m.attrs.bgTransparent}>
1681
+ <mj-image src="${t(Yp)}" border-radius="50%" alt="Speaker"></mj-image>
1682
+ <mj-text align="center" font-weight="700" font-size="16px" padding-top="10px" color="${m.colors.text.heading}">James Doe</mj-text>
1683
+ <mj-text align="center" font-size="12px" color="${m.colors.text.body}">Advertiser</mj-text>
1684
+ </mj-column>
1685
+ <mj-column width="33.33%" ${m.attrs.bgTransparent}>
1686
+ <mj-image src="${t(Zp)}" border-radius="50%" alt="Speaker"></mj-image>
1687
+ <mj-text align="center" font-weight="700" font-size="16px" padding-top="10px" color="${m.colors.text.heading}">Mia Dolce</mj-text>
1688
+ <mj-text align="center" font-size="12px" color="${m.colors.text.body}">UX Designer</mj-text>
1689
+ </mj-column>
1690
+ <mj-column width="33.33%" ${m.attrs.bgTransparent}>
1691
+ <mj-image src="${t(Cy)}" border-radius="50%" alt="Speaker"></mj-image>
1692
+ <mj-text align="center" font-weight="700" font-size="16px" padding-top="10px" color="${m.colors.text.heading}">Sophia Evans</mj-text>
1693
+ <mj-text align="center" font-size="12px" color="${m.colors.text.body}">Designer</mj-text>
1694
+ </mj-column>
1695
+ </mj-section>
1696
+ </mj-wrapper>`},presetEmailTeamAlternatingTeamCards:{label:"Alternating Team Cards",category:L.people,getContent:({getImageUrl:t})=>`<mj-wrapper gap="20px" padding="20px 20px 40px" ${m.attrs.bgSection}>
1697
+ <mj-section padding="0" ${m.attrs.bgTransparent}>
1698
+ <mj-column ${m.attrs.bgTransparent}>
1699
+ <mj-text align="center" font-size="26px" line-height="36px" font-weight="600" letter-spacing="1px">
1700
+ Our experts
1701
+ </mj-text>
1702
+ </mj-column>
1703
+ </mj-section>
1704
+ <mj-section padding="0" background-color="${m.colors.text.heading}">
1705
+ <mj-column width="40%" padding="0">
1706
+ <mj-image src="${t(Yp)}" alt="Expert" padding="0"></mj-image>
1707
+ </mj-column>
1708
+ <mj-column vertical-align="middle" width="60%" padding="20px" ${m.attrs.bgTransparent}>
1709
+ <mj-text padding="0 0 5px 0" align="left" font-size="18px" line-height="28px" font-weight="600" letter-spacing="1px" color="#ffffff">
1710
+ James Mitchell
1711
+ </mj-text>
1712
+ <mj-text padding="0 0 5px 0" align="left" font-size="12px" line-height="22px" font-weight="600" letter-spacing="1px" color="#ffffff">
1713
+ Founder &amp; Lead Designer
1714
+ </mj-text>
1715
+ <mj-text padding="0 0 5px 0" align="left" font-size="14px" line-height="24px" color="#ffffffad">
1716
+ Pair portrait photography with a short bio and social row for studio intros, speaker features, or team highlights.
1717
+ </mj-text>
1718
+ <mj-social align="left" icon-size="25px" mode="horizontal" padding="10px 0 0 0">
1719
+ <mj-social-element name="facebook" ${m.attrs.bgTransparent}></mj-social-element>
1720
+ <mj-social-element name="linkedin" ${m.attrs.bgTransparent}></mj-social-element>
1721
+ <mj-social-element name="instagram" ${m.attrs.bgTransparent}></mj-social-element>
1722
+ </mj-social>
1723
+ </mj-column>
1724
+ </mj-section>
1725
+ <mj-section padding="0" background-color="${m.colors.text.heading}">
1726
+ <mj-column width="60%" padding="20px" ${m.attrs.bgTransparent}>
1727
+ <mj-text padding="0 0 5px 0" align="left" font-size="18px" line-height="28px" font-weight="600" letter-spacing="1px" color="#ffffff">
1728
+ Sophia White
1729
+ </mj-text>
1730
+ <mj-text padding="0 0 5px 0" align="left" font-size="12px" line-height="22px" font-weight="600" letter-spacing="1px" color="#ffffff">
1731
+ Senior Interior Architect
1732
+ </mj-text>
1733
+ <mj-text padding="0 0 5px 0" align="left" font-size="14px" line-height="24px" color="#ffffffad">
1734
+ The alternating second row keeps the layout dynamic while still using the same reusable content pattern.
1735
+ </mj-text>
1736
+ <mj-social align="left" icon-size="25px" mode="horizontal" padding="10px 0 0 0">
1737
+ <mj-social-element name="facebook" ${m.attrs.bgTransparent}></mj-social-element>
1738
+ <mj-social-element name="linkedin" ${m.attrs.bgTransparent}></mj-social-element>
1739
+ <mj-social-element name="instagram" ${m.attrs.bgTransparent}></mj-social-element>
1740
+ </mj-social>
1741
+ </mj-column>
1742
+ <mj-column width="40%" padding="0">
1743
+ <mj-image src="${t(Zp)}" alt="Expert" padding="0"></mj-image>
1744
+ </mj-column>
1745
+ </mj-section>
1746
+ </mj-wrapper>`},presetEmailTestimonialsTwoRows:{label:"Testimonials Two Rows",category:L.people,getContent:({getImageUrl:t})=>`<mj-wrapper>
1747
+ <mj-section padding="20px 0" ${m.attrs.bgSection}>
1748
+ <mj-column ${m.attrs.bgTransparent}>
1749
+ <mj-text align="center" font-size="26px" line-height="36px" font-weight="600" letter-spacing="1px">
1750
+ Client testimonials
1751
+ </mj-text>
1752
+ </mj-column>
1753
+ </mj-section>
1754
+ <mj-section padding="20px 24px 0px 24px" ${m.attrs.bgSection}>
1755
+ <mj-column background-color="#4755690f" border-radius="${m.radii.s}">
1756
+ <mj-text padding="25px" font-size="16px" line-height="24px" font-style="italic" letter-spacing="1px" color="${m.colors.text.body}" align="left">
1757
+ “This layout is perfect for highlighting short testimonials without taking over the whole campaign.”
1758
+ </mj-text>
1759
+ </mj-column>
1760
+ </mj-section>
1761
+ <mj-section padding="0" ${m.attrs.bgSection}>
1762
+ <mj-column vertical-align="middle" width="20%" ${m.attrs.bgTransparent}>
1763
+ <mj-image src="${t(Ty)}" alt="Customer" border-radius="50%"></mj-image>
1764
+ </mj-column>
1765
+ <mj-column vertical-align="middle" ${m.attrs.bgTransparent} width="80%" padding="10px 10px 10px 15px">
1766
+ <mj-text padding="0" align="left" font-size="16px" line-height="26px" font-weight="600" letter-spacing="1px" color="${m.colors.text.heading}">Marcus Rivera</mj-text>
1767
+ <mj-text padding="0" align="left" font-size="12px" line-height="22px" font-weight="600" letter-spacing="1px" color="${m.colors.text.body}">Architect</mj-text>
1768
+ </mj-column>
1769
+ </mj-section>
1770
+ <mj-section padding="0" ${m.attrs.bgSection}>
1771
+ <mj-column ${m.attrs.bgTransparent}>
1772
+ <mj-divider border-width="1px" border-style="solid" border-color="#4755692e"></mj-divider>
1773
+ </mj-column>
1774
+ </mj-section>
1775
+ <mj-section padding="20px 24px 0px 24px" ${m.attrs.bgSection}>
1776
+ <mj-column background-color="#4755690f" border-radius="${m.radii.s}">
1777
+ <mj-text padding="25px" font-size="16px" line-height="24px" font-style="italic" letter-spacing="1px" color="${m.colors.text.body}" align="right">
1778
+ “Use it for customer proof, partner quotes, or event feedback where symmetry matters.”
1779
+ </mj-text>
1780
+ </mj-column>
1781
+ </mj-section>
1782
+ <mj-section padding="0 0 30px" ${m.attrs.bgSection}>
1783
+ <mj-column vertical-align="middle" ${m.attrs.bgTransparent} width="80%" padding="10px 15px 10px 10px">
1784
+ <mj-text padding="0" align="right" font-size="16px" line-height="26px" font-weight="600" letter-spacing="1px" color="${m.colors.text.heading}">Elena Kowalski</mj-text>
1785
+ <mj-text padding="0" align="right" font-size="12px" line-height="22px" font-weight="600" letter-spacing="1px" color="${m.colors.text.body}">Project Manager</mj-text>
1786
+ </mj-column>
1787
+ <mj-column vertical-align="middle" width="20%" ${m.attrs.bgTransparent}>
1788
+ <mj-image src="${t(ky)}" alt="Customer" border-radius="50%"></mj-image>
1789
+ </mj-column>
1790
+ </mj-section>
1791
+ </mj-wrapper>`},presetEmailFooterSocial:{label:"Social Footer",category:L.footer,getContent:()=>`<mj-section background-color="${m.colors.text.heading}" padding="40px 24px">
1792
+ <mj-column ${m.attrs.bgTransparent}>
1793
+ <mj-text align="center" color="#ffffff" font-size="18px" font-weight="700" padding="0 0 12px">Stay in the loop</mj-text>
1794
+ <mj-social font-size="12px" icon-size="20px" mode="horizontal" padding="0" inner-padding="7px">
1795
+ <mj-social-element name="facebook" ${m.attrs.bgTransparent}></mj-social-element>
1796
+ <mj-social-element name="linkedin" ${m.attrs.bgTransparent}></mj-social-element>
1797
+ <mj-social-element name="instagram" ${m.attrs.bgTransparent}></mj-social-element>
1798
+ </mj-social>
1799
+ <mj-text padding="12px 0 0 0" align="center" color="#ffffff88" font-size="12px" line-height="18px">
1800
+ 123 Example Street, Suite 400, <br/>
1801
+ San Francisco, CA
1802
+ </mj-text>
1803
+ <mj-text padding="12px 0 0" align="center" color="#47556994" font-size="12px" line-height="20px">
1804
+ <a href="#" style="color:${m.colors.secondary};text-decoration:none;font-weight:700;">Unsubscribe</a>
1805
+ </mj-text>
1806
+ </mj-column>
1807
+ </mj-section>`},presetEmailTwoColumnFooter:{label:"Two Column Footer",category:L.footer,getContent:()=>`<mj-wrapper padding="0">
1808
+ <mj-section padding="32px 24px 0px 24px" ${m.attrs.bgSection}>
1809
+ <mj-column>
1810
+ <mj-text align="left" font-size="18px" font-weight="700" color="${m.colors.text.heading}" padding="10px 0px 10px 0px">Follow Us
1811
+ </mj-text>
1812
+ <mj-text padding="0 0 20px" font-size="12px" line-height="22px" color="${m.colors.text.body}">Follow us on social for more updates</mj-text>
1813
+ <mj-social align="left" font-size="12px" icon-size="18px" mode="horizontal" padding="0" inner-padding="5px">
1814
+ <mj-social-element name="facebook" background-color="${m.colors.text.heading}"></mj-social-element>
1815
+ <mj-social-element name="linkedin" background-color="${m.colors.text.heading}"></mj-social-element>
1816
+ <mj-social-element name="instagram" background-color="${m.colors.text.heading}"></mj-social-element>
1817
+ </mj-social>
1818
+ </mj-column>
1819
+ <mj-column>
1820
+ <mj-text padding="10px 0px" align="left" font-size="18px" font-weight="700" color="${m.colors.text.heading}">Contact Us</mj-text>
1821
+ <mj-text padding="0 0 20px" font-size="12px" line-height="22px" color="${m.colors.text.body}">
1822
+ 245 Design Avenue, Suite 100<br/>
1823
+ San Francisco, CA 94102<br/><a href="tel:+1-555-321-9870"
1824
+ style="color:${m.colors.secondary};font-weight:700;">+1-555-321-9870</a></mj-text>
1825
+ </mj-column>
1826
+ </mj-section>
1827
+ <mj-section ${m.attrs.bgSection} padding="12px 24px 24px">
1828
+ <mj-column width="100%">
1829
+ <mj-divider border-color="#e2e8f0" border-width="1px" padding="0 0 16px 0"></mj-divider>
1830
+ <mj-text padding="0" align="center" color="#47556994" font-size="12px" line-height="20px">You are receiving this
1831
+ email because you subscribed from our site. <a href="#" style="color:${m.colors.secondary};font-weight:700;text-decoration:none;">Unsubscribe</a></mj-text>
1832
+ </mj-column>
1833
+ </mj-section>
1834
+ </mj-wrapper>`},presetEmailThreeColumnFooter:{label:"Three Column Footer",category:L.footer,getContent:()=>`<mj-section padding="30px 24px" background-color="${m.colors.text.heading}" full-width="full-width">
1835
+ <mj-column width="30%" padding="0 0 20px" ${m.attrs.bgTransparent}>
1836
+ <mj-text padding="0 0 15px" font-size="14px" font-weight="700" line-height="24px" color="#ffffff">About us</mj-text>
1837
+ <mj-text padding="0" font-size="12px" color="#ffffff99" line-height="22px">
1838
+ <a style="color:#ffffff99;">About us</a><br/>
1839
+ <a style="color:#ffffff99;">Contact us</a><br/>
1840
+ <a style="color:#ffffff99;">Team</a><br/>
1841
+ <a style="color:#ffffff99;">Blog</a>
1842
+ </mj-text>
1843
+ </mj-column>
1844
+ <mj-column width="30%" padding="0 0 20px" ${m.attrs.bgTransparent}>
1845
+ <mj-text padding="0 0 15px" font-size="14px" font-weight="700" line-height="24px" color="#ffffff">Links
1846
+ </mj-text>
1847
+ <mj-text padding="0" font-size="12px" color="#ffffff99" line-height="22px">
1848
+ <a style="color:#ffffff99;">Shop</a><br/>
1849
+ <a style="color:#ffffff99;">Terms</a><br/>
1850
+ <a style="color:#ffffff99;">Privacy</a><br/>
1851
+ <a style="color:#ffffff99;">Reviews</a>
1852
+ </mj-text>
1853
+ </mj-column>
1854
+ <mj-column width="40%" ${m.attrs.bgTransparent}>
1855
+ <mj-text padding="0 0 15px" font-size="14px" font-weight="700" line-height="24px" color="#ffffff">Our location</mj-text>
1856
+ <mj-text padding="0 0 20px" font-size="12px" line-height="22px" color="#ffffff">
1857
+ 245 Design Avenue, Suite 100<br/>
1858
+ San Francisco, CA 94102<br/>
1859
+ <a href="tel:+1-555-321-9870" style="color:#ffffff99;">+1-555-321-9870</a>
1860
+ </mj-text>
1861
+ <mj-text padding="0" font-size="14px" font-weight="700" line-height="24px" color="#ffffff">Socials</mj-text>
1862
+ <mj-social font-size="12px" icon-size="24px" mode="horizontal" padding="0" align="left">
1863
+ <mj-social-element name="facebook" ${m.attrs.bgTransparent}></mj-social-element>
1864
+ <mj-social-element name="linkedin" ${m.attrs.bgTransparent}></mj-social-element>
1865
+ <mj-social-element name="instagram" ${m.attrs.bgTransparent}></mj-social-element>
1866
+ <mj-social-element name="youtube" ${m.attrs.bgTransparent}></mj-social-element>
1867
+ </mj-social>
1868
+ </mj-column>
1869
+ </mj-section>`}}},My=({library:n,options:e})=>Object.entries(Ey(e)).map(([t,o])=>{const i=fy({id:t,label:o.label,category:o.category,library:n}),r=o.getContent({getImageUrl:s=>{var l;return((l=e.getImageUrl)==null?void 0:l.call(e,{block:i}))||s}});return{...i,content:r}}),Ay=(n={})=>{const e=uy(n),t=Le(n.defaultLibrary)?n.defaultLibrary({...e})||void 0:e,o=My({library:t,options:n}),i=n.categories?new Set(n.categories):null,r=new Map;return o.flatMap(s=>{const l=typeof s.category=="string"?void 0:s.category;if(i&&l&&!i.has(l.id))return[];let a=l;if(l&&Le(n.category)){if(!r.has(l.id)){const u=n.category({...l});r.set(l.id,u===!1?!1:u||l)}const p=r.get(l.id);if(p===!1)return[];a=p||l}const c=a!==s.category?{...s,category:a}:s;if(!Le(n.block))return[c];const d=n.block({...c});return d?[d||c]:[]})};function jy(n,e){const{Blocks:t}=n,o=Ay(e);return o.forEach(i=>i.id&&t.add(i.id,i)),{blocks:o}}const $y=q(function(n,e={}){var s,l;const t={...e};if(!Bs(n))return;const{blocks:o}=jy(n,t),i=t.selectLibrary?(l=(s=o.find(a=>a.library))==null?void 0:s.library)==null?void 0:l.id:void 0,r=[];return i&&n.runCommand(W.setBlocksPanel,{selectedLibrary:i}),t.withGlobalStyles&&r.push((()=>{const a=`${n.DataSources.events.pathSource}:${Vp.globalStyles}`,c=()=>n.runCommand(W.setBlocksPanel,{previewCache:new Map});return n.on(a,c),()=>n.off(a,c)})()),U({editor:n,licenseKey:t.licenseKey,plan:dy,pluginName:Hp,cleanup:$u}),({cleanup:a})=>{a(),r.forEach(c=>c())}},Hp),Py=n=>{const e=n;return e.logicalOperator==="and"||e.logicalOperator==="or"},Xp=(n,e)=>(n.config.optsHtml={...n.config.optsHtml,exporter:e},()=>{n.config.optsHtml.exporter=void 0}),Qp=(n,e)=>{const t=i=>{const{input:r}=i,{contains:s}=e;(!s||r.includes(s))&&(i.input=e.importer.import(r))},o=n.Parser.events.htmlBefore;return n.on(o,t),()=>{n.off(o,t)}};class Ny{getVariableSyntax({dataResolver:e}){const{defaultValue:t}=e,o=this.getFullPath(e),i=t?` || \`${t}\``:"";return`<%= ${o}${i} %>`}getCollectionStartSyntax({dataResolver:e}){const{collectionId:t,dataSource:o,startIndex:i,endIndex:r}=e,s=(o==null?void 0:o.path)||t||"",l=this._sanitizeVariableName(t);let a="";if(i!==void 0||r!==void 0){const c=i??0,d=r!==void 0?r:"";a=`.slice(${c}${d!==""?`, ${d}`:""})`}return`<% ${s}${a}.forEach(function(currentItem, index, arr) {
1870
+ const startIndex = parseInt(${i??0}, 10);
983
1871
  const endIndex = startIndex + arr.length;
984
- 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($y(e)){const t=e.statements.map(i=>this._parseCondition(i)),o=By[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 By={and:"&&",or:"||",xor:"^"},Vy=["===","==","!==","!=","<=",">=","<",">","&&","||"],Hy={"===":"=","==":"=","!==":"!=","!=":"!=","<=":"<=",">=":">=","<":"<",">":">","&&":"&&","||":"||"};class Fy{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 i=e.indexOf("%>",s);if(i===-1)throw new Error("Unclosed EJS tag");const r=e.slice(s+2,i).trim();if(o=i+2,r.startsWith("=")||r.startsWith("-")){const l=r.slice(1).trim();t.push(this.createAppendExpression(l))}else{if(r.startsWith("#"))continue;if(r.startsWith("if")){const l=this.parseIfStatement(r,e,o);t.push(l),o=l.endPos||o}else if(r.startsWith("for")){const l=this.parseForStatement(r,e,o);t.push(l),o=l.endPos||o}else{const l=r.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: ${r}`)}}}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 i=this.parseJsExpression(s[1]),{body:r,endPos:l}=this.parseTemplateBlock(t,o);let a=null,c=l;const d=t.indexOf("<%",c);if(d===c){const p=t.indexOf("%>",d);if(p!==-1){const u=t.slice(d+2,p).trim(),h=p+2-d;if(u.startsWith("} else if")){c=d+h;const f=u.substring(u.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(u.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 u==="}"&&(c=d+h)}}return{type:"IfStatement",test:i,consequent:{type:"BlockStatement",body:r},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 i=s[1].split("of");if(i.length!==2)throw new Error("Only for...of loops are supported");const r=i[0].trim().replace(/^let\s+|^const\s+|^var\s+/,""),l=i[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:r},init:this.parseJsExpression(l)}]},test:null,update:null,body:{type:"BlockStatement",body:a},endPos:(()=>{const d=t.indexOf("<%",c),p=t.indexOf("%>",d);return d===c&&t.slice(d+2,p).trim()==="}"?p+2:c})()}}parseForEachStatement(e,t,o,s){const{body:i,endPos:r}=this.parseTemplateBlock(o,s);return{type:"ForEachStatement",collection:this.parseJsExpression(e),itemIdentifier:{type:"Identifier",name:t},body:{type:"BlockStatement",body:i},endPos:(()=>{const l=o.indexOf("<%",r),a=o.indexOf("%>",l);return l===r&&o.slice(l+2,a).trim()==="}"?a+2:r})()}}parseTemplateBlock(e,t){const o=[];let s=t;for(;s<e.length;){const i=e.indexOf("<%",s);if(i===-1){s<e.length&&o.push(this.createAppendLiteral(e.slice(s))),s=e.length;break}i>s&&o.push(this.createAppendLiteral(e.slice(s,i)));const r=e.indexOf("%>",i);if(r===-1)throw new Error("Unclosed EJS tag within block");const l=e.slice(i+2,r).trim();if(l==="}"||l.startsWith("} else")){s=i;break}if(s=r+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],p=this.parseForEachStatement(c,d,e,s);o.push(p),s=p.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 Vy){const i=e.lastIndexOf(s);if(i>0&&e[i-1]!=="!"&&e[i-1]!=="="&&e[i-1]!=="<"&&e[i-1]!==">")return{type:s==="&&"||s==="||"?"LogicalExpression":"BinaryExpression",operator:Hy[s],left:this.parseJsExpression(e.slice(0,i).trim()),right:this.parseJsExpression(e.slice(i+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 i,r,l=!1;if(s===t)i=e.slice(0,t),r={type:"Identifier",name:e.slice(t+1)},l=!1;else{i=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);r=/^(['"]).*\1$/.test(c)||/^-?\d+(\.\d+)?$/.test(c)?this.parseJsExpression(c):{type:"Identifier",name:c},l=!0}return{type:"MemberExpression",object:this.parseJsExpression(i),property:r,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)),`
1872
+ 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(Py(e)){const t=e.statements.map(r=>this._parseCondition(r)),o=Oy[e.logicalOperator];let i=t.length>1?`(${t.join(`)${o}(`)})`:t[0];return e.logicalOperator==="xor"&&(i=`!!(${i})`),i}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 Oy={and:"&&",or:"||",xor:"^"},Iy=["===","==","!==","!=","<=",">=","<",">","&&","||"],Dy={"===":"=","==":"=","!==":"!=","!=":"!=","<=":"<=",">=":">=","<":"<",">":">","&&":"&&","||":"||"};class zy{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 i=e.indexOf("<%",o);if(i===-1){o<e.length&&t.push(this.createAppendLiteral(e.slice(o)));break}i>o&&t.push(this.createAppendLiteral(e.slice(o,i)));const r=e.indexOf("%>",i);if(r===-1)throw new Error("Unclosed EJS tag");const s=e.slice(i+2,r).trim();if(o=r+2,s.startsWith("=")||s.startsWith("-")){const l=s.slice(1).trim();t.push(this.createAppendExpression(l))}else{if(s.startsWith("#"))continue;if(s.startsWith("if")){const l=this.parseIfStatement(s,e,o);t.push(l),o=l.endPos||o}else if(s.startsWith("for")){const l=this.parseForStatement(s,e,o);t.push(l),o=l.endPos||o}else{const l=s.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: ${s}`)}}}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 i=e.match(/if\s*\((.*)\)\s*\{?/);if(!i)throw new Error("Invalid if statement syntax");const r=this.parseJsExpression(i[1]),{body:s,endPos:l}=this.parseTemplateBlock(t,o);let a=null,c=l;const d=t.indexOf("<%",c);if(d===c){const p=t.indexOf("%>",d);if(p!==-1){const u=t.slice(d+2,p).trim(),f=p+2-d;if(u.startsWith("} else if")){c=d+f;const h=u.substring(u.indexOf("if")).trim(),g=this.parseIfStatement(h,t,c);a={type:"IfStatement",test:g.test,consequent:g.consequent,alternate:g.alternate},c=g.endPos}else if(u.startsWith("} else")){c=d+f;const{body:h,endPos:g}=this.parseTemplateBlock(t,c);a={type:"BlockStatement",body:h},c=g;const b=t.indexOf("<%",c),x=t.indexOf("%>",b);b===c&&t.slice(b+2,x).trim()==="}"&&(c=x+2)}else u==="}"&&(c=d+f)}}return{type:"IfStatement",test:r,consequent:{type:"BlockStatement",body:s},alternate:a,endPos:c}}parseForStatement(e,t,o){const i=e.match(/for\s*\((.*)\)\s*\{?/);if(!i)throw new Error("Invalid for statement syntax");const r=i[1].split("of");if(r.length!==2)throw new Error("Only for...of loops are supported");const s=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:s},init:this.parseJsExpression(l)}]},test:null,update:null,body:{type:"BlockStatement",body:a},endPos:(()=>{const d=t.indexOf("<%",c),p=t.indexOf("%>",d);return d===c&&t.slice(d+2,p).trim()==="}"?p+2:c})()}}parseForEachStatement(e,t,o,i){const{body:r,endPos:s}=this.parseTemplateBlock(o,i);return{type:"ForEachStatement",collection:this.parseJsExpression(e),itemIdentifier:{type:"Identifier",name:t},body:{type:"BlockStatement",body:r},endPos:(()=>{const l=o.indexOf("<%",s),a=o.indexOf("%>",l);return l===s&&o.slice(l+2,a).trim()==="}"?a+2:s})()}}parseTemplateBlock(e,t){const o=[];let i=t;for(;i<e.length;){const r=e.indexOf("<%",i);if(r===-1){i<e.length&&o.push(this.createAppendLiteral(e.slice(i))),i=e.length;break}r>i&&o.push(this.createAppendLiteral(e.slice(i,r)));const s=e.indexOf("%>",r);if(s===-1)throw new Error("Unclosed EJS tag within block");const l=e.slice(r+2,s).trim();if(l==="}"||l.startsWith("} else")){i=r;break}if(i=s+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,i);o.push(a),i=a.endPos||i}else if(l.startsWith("for")){const a=this.parseForStatement(l,e,i);o.push(a),i=a.endPos||i}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],p=this.parseForEachStatement(c,d,e,i);o.push(p),i=p.endPos||i}else this.addMessage("info",`Unsupported scriptlet content within block: ${l}`)}}}return{body:o,endPos:i}}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 i of Iy){const r=e.lastIndexOf(i);if(r>0&&e[r-1]!=="!"&&e[r-1]!=="="&&e[r-1]!=="<"&&e[r-1]!==">")return{type:i==="&&"||i==="||"?"LogicalExpression":"BinaryExpression",operator:Dy[i],left:this.parseJsExpression(e.slice(0,r).trim()),right:this.parseJsExpression(e.slice(r+i.length).trim())}}const t=e.indexOf("."),o=e.indexOf("[");if(t>0&&(o===-1||t<o)||o>0&&(t===-1||o<t)){const i=t>0&&(o===-1||t<o)?t:o;let r,s,l=!1;if(i===t)r=e.slice(0,t),s={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);s=/^(['"]).*\1$/.test(c)||/^-?\d+(\.\d+)?$/.test(c)?this.parseJsExpression(c):{type:"Identifier",name:c},l=!0}return{type:"MemberExpression",object:this.parseJsExpression(r),property:s,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 i="";return e.alternate&&(i=this.astToGrapesJS(e.alternate)),`
985
1873
  <data-condition data-gjs-data-resolver='${JSON.stringify({condition:t})}'>
986
1874
  <data-condition-true-content>${o}</data-condition-true-content>
987
- <data-condition-false-content>${s}</data-condition-false-content>
1875
+ <data-condition-false-content>${i}</data-condition-false-content>
988
1876
  </data-condition>
989
- `}handleForStatement(e){var l;if(((l=e.init)==null?void 0:l.type)!=="VariableDeclaration"||e.init.declarations.length===0)return this.addMessage("warning","Unsupported for loop init format"),"";const t=e.init.declarations[0];if(t.id.type!=="Identifier")return this.addMessage("warning","Unsupported for loop variable declaration id"),"";let o="";if(t.init)o=this.getExpressionString(t.init);else return this.addMessage("warning","For loop collection is undefined"),"";const s=t.id.name,i=s;this.collectionStack.push(s);const r=this.astToGrapesJS(e.body);return this.collectionStack.pop(),`
990
- <data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:o},collectionId:i})}'>
1877
+ `}handleForStatement(e){var l;if(((l=e.init)==null?void 0:l.type)!=="VariableDeclaration"||e.init.declarations.length===0)return this.addMessage("warning","Unsupported for loop init format"),"";const t=e.init.declarations[0];if(t.id.type!=="Identifier")return this.addMessage("warning","Unsupported for loop variable declaration id"),"";let o="";if(t.init)o=this.getExpressionString(t.init);else return this.addMessage("warning","For loop collection is undefined"),"";const i=t.id.name,r=i;this.collectionStack.push(i);const s=this.astToGrapesJS(e.body);return this.collectionStack.pop(),`
1878
+ <data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:o},collectionId:r})}'>
991
1879
  <data-collection-item>
992
- ${r}
1880
+ ${s}
993
1881
  </data-collection-item>
994
1882
  </data-collection>
995
- `}handleForEachStatement(e){const t=this.getExpressionString(e.collection),o=e.itemIdentifier.name,s=o;this.collectionStack.push(o);const i=this.astToGrapesJS(e.body);return this.collectionStack.pop(),`
996
- <data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:t},collectionId:s})}'>
1883
+ `}handleForEachStatement(e){const t=this.getExpressionString(e.collection),o=e.itemIdentifier.name,i=o;this.collectionStack.push(o);const r=this.astToGrapesJS(e.body);return this.collectionStack.pop(),`
1884
+ <data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:t},collectionId:i})}'>
997
1885
  <data-collection-item>
998
- ${i}
1886
+ ${r}
999
1887
  </data-collection-item>
1000
1888
  </data-collection>
1001
- `}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 i=this.collectionStack[this.collectionStack.length-1];let r=e;const l=[];for(;r.type==="MemberExpression";)r.property.type==="Identifier"&&!r.computed?l.unshift(r.property.name):r.property.type==="Literal"&&r.computed?l.unshift(String(r.property.value)):l.unshift(this.getExpressionString(r.property)),r=r.object;if(r.type==="Identifier"&&r.name===i){const a=l.join(".");s={...t,collectionId:i,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 _y="dataSourceEjs",Gy=F.startup,Wy=W(function(n,e={}){const t=mp(n,new zy),o=gp(n,{contains:"<%",importer:new Fy});j({editor:n,licenseKey:e.licenseKey,plan:Gy,pluginName:_y,cleanup:()=>{t(),o()}})}),yp={equals:"equals",isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue"},jy={...yp,...{">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq"},...{contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"}};class qy{getHelperId(e){return jy[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 i="";if(e.startIndex!==void 0||e.endIndex!==void 0){const c=e.startIndex??0,d=e.endIndex!==void 0?e.endIndex:"";d!==""?i=` (slice ${s} ${c} ${d})`:i=` (slice ${s} ${c})`}const l=` as |${this._sanitizeVariableName(t)}|`;return`{{#each ${i||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:i}=s,r=s.logicalOperator,l=i.map(c=>this._parseCondition(c)).join(" ");return`{{#if ${i.length>1?`(${r} ${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,i=o.logicalOperator,r=o.statements.map(l=>this._parseCondition(l)).join(" ");return s.length>1?`(${i} ${r})`:r}else{const s=t.operator,i=this.getHelperId(s),r=this._parseValue(t.left),l=this._parseValue(t.right);return this.getExpressionStr(i,r,l)}}getExpressionStr(e,t,o){return yp[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 Uy{constructor(){this.messages=[],this.collectionStack=[]}import(e){this.messages=[],this.collectionStack=[];const t=this.parse(e);return this.astToGrapesJS(t)}parse(e){try{return kn.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,i=t.message.match(/column (\d+)/),r=i?parseInt(i[1]):0;throw new Error(`Handlebars syntax error at line ${s}, column ${r}: ${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("/"),i=s.join(".");this.collectionStack.includes(o)?this.setCurrentItemResolver(o,i,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=wr(e),{parentLevel:s,remainingPathParts:i}=this.calculateParentLevel(o),r=i.join("."),l=this.collectionStack.length-1-s;l>=0&&l<this.collectionStack.length?this.resolveRelativePath(r,l,t):t.path=i.join(".")}calculateParentLevel(e){const t=this.collectionStack.findLastIndex(i=>i===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=wr(e),{parentLevel:s,remainingPathParts:i}=this.calculateParentLevel(o),r=i.join("."),l=this.collectionStack.length-1-s;l>=0&&l<this.collectionStack.length?this.resolveRelativePath(r,l,t):t.path=i.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 i={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(e.params[0])},operator:t==="unless"?"isFalsy":"isTruthy"}]},r=this.handleProgram(e.program),l=e.inverse?this.handleProgram(e.inverse):"";return`
1002
- <data-condition data-gjs-data-resolver='${JSON.stringify({condition:i})}'>
1003
- <data-condition-true-content>${r}</data-condition-true-content>
1889
+ `}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 i={path:this.getExpressionString(e),...t};if(this.collectionStack.length>0){const r=this.collectionStack[this.collectionStack.length-1];let s=e;const l=[];for(;s.type==="MemberExpression";)s.property.type==="Identifier"&&!s.computed?l.unshift(s.property.name):s.property.type==="Literal"&&s.computed?l.unshift(String(s.property.value)):l.unshift(this.getExpressionString(s.property)),s=s.object;if(s.type==="Identifier"&&s.name===r){const a=l.join(".");i={...t,collectionId:r,variableType:"currentItem",path:a}}}return`<data-variable data-gjs-data-resolver='${JSON.stringify(i)}'></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 eu="dataSourceEjs",Ry=F.startup,Ly=q(function(n,e={}){const t=Xp(n,new Ny),o=Qp(n,{contains:"<%",importer:new zy});U({editor:n,licenseKey:e.licenseKey,plan:Ry,pluginName:eu,cleanup:()=>{t(),o()}})},eu),tu={equals:"equals",isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue"},By={...tu,...{">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq"},...{contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"}};class Vy{getHelperId(e){return By[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,i=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 ${i} ${c} ${d})`:r=` (slice ${i} ${c})`}const l=` as |${this._sanitizeVariableName(t)}|`;return`{{#each ${r||i}${l}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax({dataResolver:e}){const t=e.condition;if(!t)return"";const o=t,i=t;if(i.statements&&i.logicalOperator==="and"||i.logicalOperator==="or"){const{statements:r}=i,s=i.logicalOperator,l=r.map(c=>this._parseCondition(c)).join(" ");return`{{#if ${r.length>1?`(${s} ${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:i}=o,r=o.logicalOperator,s=o.statements.map(l=>this._parseCondition(l)).join(" ");return i.length>1?`(${r} ${s})`:s}else{const i=t.operator,r=this.getHelperId(i),s=this._parseValue(t.left),l=this._parseValue(t.right);return this.getExpressionStr(r,s,l)}}getExpressionStr(e,t,o){return tu[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 Hy{constructor(){this.messages=[],this.collectionStack=[]}import(e){this.messages=[],this.collectionStack=[];const t=this.parse(e);return this.astToGrapesJS(t)}parse(e){try{return Mn.parse(e)}catch(t){if(t instanceof Error&&t.message.includes("Parse error")){const o=t.message.match(/line (\d+)/),i=o?parseInt(o[1]):0,r=t.message.match(/column (\d+)/),s=r?parseInt(r[1]):0;throw new Error(`Handlebars syntax error at line ${i}, column ${s}: ${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),i={...t};return this.collectionStack.length>0?this.processPathWithCollectionContext(o,i):i.path=o,`<data-variable data-gjs-data-resolver='${JSON.stringify(i)}'></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,...i]=e.substring(1).split("/"),r=i.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 i={index:"currentIndex","@index":"currentIndex",key:"currentKey","@key":"currentKey"};o.variableType=i[t]}setCurrentItemResolver(e,t,o){o.collectionId=e,o.variableType="currentItem",t&&(o.path=t)}handleRelativePathReference(e,t){const o=Ns(e),{parentLevel:i,remainingPathParts:r}=this.calculateParentLevel(o),s=r.join("."),l=this.collectionStack.length-1-i;l>=0&&l<this.collectionStack.length?this.resolveRelativePath(s,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 i=[...e];for(;i[0]==="..";)o++,i.shift();return{parentLevel:o,remainingPathParts:i}}resolveRelativePath(e,t,o){const i=this.collectionStack[t];o.collectionId=i,o.variableType="currentItem",e!=="this"&&(o.path=e.startsWith("this.")?e.split(".").slice(1).join("."):e)}handleParentReferenceFallback(e,t){const o=Ns(e),{parentLevel:i,remainingPathParts:r}=this.calculateParentLevel(o),s=r.join("."),l=this.collectionStack.length-1-i;l>=0&&l<this.collectionStack.length?this.resolveRelativePath(s,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"}]},s=this.handleProgram(e.program),l=e.inverse?this.handleProgram(e.inverse):"";return`
1890
+ <data-condition data-gjs-data-resolver='${JSON.stringify({condition:r})}'>
1891
+ <data-condition-true-content>${s}</data-condition-true-content>
1004
1892
  <data-condition-false-content>${l}</data-condition-false-content>
1005
1893
  </data-condition>
1006
- `}handleEachBlock(e){var i,r,l;const t=this.getExpressionString(e.params[0]);let o;e.params.length>=3&&e.params[1]==="as"&&((i=e.params[2])==null?void 0:i.type)==="PathExpression"?o=e.params[2].original:(l=(r=e.program)==null?void 0:r.blockParams)!=null&&l.length?o=e.program.blockParams[0]:o=`collection-${Math.random().toString(36).substring(2,10)}`,this.collectionStack.push(o);const s=this.handleProgram(e.program);return this.collectionStack.pop(),`
1894
+ `}handleEachBlock(e){var r,s,l;const t=this.getExpressionString(e.params[0]);let o;e.params.length>=3&&e.params[1]==="as"&&((r=e.params[2])==null?void 0:r.type)==="PathExpression"?o=e.params[2].original:(l=(s=e.program)==null?void 0:s.blockParams)!=null&&l.length?o=e.program.blockParams[0]:o=`collection-${Math.random().toString(36).substring(2,10)}`,this.collectionStack.push(o);const i=this.handleProgram(e.program);return this.collectionStack.pop(),`
1007
1895
  <data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:t},collectionId:o})}'>
1008
- <data-collection-item>${s}</data-collection-item>
1896
+ <data-collection-item>${i}</data-collection-item>
1009
1897
  </data-collection>
1010
- `}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 wr=n=>{if(n==null||n==="")return[];if(n===".")return["this"];if(n===".."||n==="../")return[".."];if(n.startsWith("../")){const r=n.substring(3);return["..",...wr(r)]}const e=[];let t=0,o=n.replace(/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,(r,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("."),i=[];for(const r of s){const l=/^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(r);if(l){const a=parseInt(l[1],10);i.push(e[a])}else r!==""&&i.push(r)}return i},Ky="dataSourceHandlebars",Jy=F.startup,Zy=W(function(n,e={}){const t=mp(n,new qy),o=gp(n,{contains:"{{",importer:new Uy});j({editor:n,licenseKey:e.licenseKey,plan:Jy,pluginName:Ky,cleanup:()=>{t(),o()}})}),Yy=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)},bp="youtube-video",Xy=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:o="high"}=n,s=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=Yy(l);return`${c}?${d}`},i=l=>{var a,c,d;return((a=l[o])==null?void 0:a.url)||((c=l.high)==null?void 0:c.url)||((d=l.medium)==null?void 0:d.url)||l.default.url},r=l=>{const a=i(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,type:bp,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:[bp],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}),p={...c,...d};p.part?p.part.includes("snippet")||p.part.push("snippet"):p.part=["snippet"];const h=await(await fetch(s(p))).json();return(m=h.items)!=null&&m.length?{items:h.items.map(r),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}}]})}},Qy={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},eb="youtubeAssetProvider",tb=F.startup,nb=W(function(n,e){var c;const{skipVideoComponent:t,i18n:o={}}=e,s=Xy(e);n.runCommand(G.assetProviderAdd,{provider:s});const i="search-on-youtube",r="video",l=(c=n.Components.getType(r))==null?void 0:c.model.prototype,a=d=>{n.Assets.open({modalTitle:n.I18n.t("youtubeAssetProvider.modalTitle"),providerId:s.id,typeId:s.types[0],providers:[],types:[],select:p=>{n.Assets.close(),d.set({videoId:p.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){const[d,...p]=l.getYoutubeTraits.apply(this);return[d,{id:i,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...p]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:d}=this,p=d.get("provider")||"";p!=null&&p.startsWith("yt")&&a(d)}}}),n.I18n.addMessages({en:Qy,...o}),j({editor:n,licenseKey:e.licenseKey,plan:tb,pluginName:eb,cleanup:()=>{n.runCommand(G.assetProviderRemove,{id:s.id}),!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==i)}}})}})}),ao=n=>n.replaceAll('"',"").replaceAll("'",""),Cr=n=>n.includes(",")?n:/\s/.test(n)?`'${ao(n)}'`:ao(n),vp=(n,e,t)=>({family:n,variant:e,...t}),Sp=(n,e)=>{n=Cr(n);const{menuVariant:t,variants:o}=e;return{family:n,familyLabel:ao(n),menuVariant:t&&vp(Cr(`menuFont-${ao(n)}`),"regular",t),variants:Object.assign({},...Object.entries(o).map(([s,i])=>({[s]:vp(n,s,i)})))}},xp=(n,e)=>{var l;const t=Sp(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:i}=o,r=ao(o.family);if(!e){const a=new FontFace(r,`url("${s}")`,i),c=Array.from(document.fonts.values()).filter(d=>d.family===r);for(const d of c)document.fonts.delete(d);document.fonts.add(a),a.load().catch(()=>{})}return Cr(r)},ob=n=>{const{family:e,menu:t,axes:o}=n,s=!!o,i=Object.assign({},...n.variants.map(r=>{var d,p;let l,a;if(s){const u=o.find(h=>h.tag==="wght");if(u){const{start:h,end:f}=u;l=`${h} ${f}`}}return l||(l=((d=r.match(/\d+/))==null?void 0:d[0])??"400"),a=((p=r.match(/[a-zA-Z]+/))==null?void 0:p[0])==="italic"?"italic":void 0,{[r]:{source:n.files[r],descriptors:{style:a,weight:l}}}}));return Sp(e,{menuVariant:{source:t},variants:i})},sb=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:ob(n),needsLoading:!0}}),ib=n=>{const{font:e}=n.customData;return n.customData.needsLoading?(n.customData.needsLoading=!1,xp(e)):xp(e,!0)};let co;const rb=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)},lb=n=>{const{apiKey:e,searchParams:t}=n,o=(s={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",r=rb(s);return`${i}?${r}`};return{id:"google-fonts",types:["font"],label:({editor:s})=>s.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var c;if(co)return co;const s={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=t==null?void 0:t(),r={...s,...i},a=await(await fetch(o(r))).json();return(c=a.items)!=null&&c.length?(co=a.items.map(sb),co):[]},itemLayout:s=>{const i=co.find(l=>l.id===s.assetProps.id),r=ib(i);return{type:"column",onClick:()=>s.onSelect(i),htmlAttrs:{title:i.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:r,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}},{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"16px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},ab={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},cb="googleFontsAssetProvider",db=F.startup,pb=W(function(n,e){const{i18n:t={}}=e,o=lb(e);n.runCommand(G.assetProviderAdd,{provider:o}),n.I18n.addMessages({en:ab,...t}),j({editor:n,licenseKey:e.licenseKey,plan:db,pluginName:cb,cleanup:()=>{n.runCommand(G.assetProviderRemove,{id:o.id})}})}),ub="canvasAbsoluteMode",hb=F.startup,fb=(n,e,t)=>{var c,d;const o=t.enableAbsolute??(p=>p.hasAbsolute),i=(Array.isArray(e)?e:e?[e]:[...n.getSelectedAll()])[0],r=((d=(c=i==null?void 0:i.delegate)==null?void 0:c.move)==null?void 0:d.call(c,i))||i;if(!r)return;const l=r.getEl();return{result:xt(o)?o({component:r,hasAbsolute:!!l&&getComputedStyle(l).position==="absolute"}):!1,component:r,dmode:r.get("dmode")}};function Ss({guideMatched:n,canvasView:e}){var M;const t=n.guide.x===void 0?"y":"x";let o=0,s=0,i=0,r=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),p=c.y,u=c.y+c.height,h=c.x,f=c.x+c.width,m=d.y,g=d.y+d.height,b=d.x,w=d.x+d.width,y=Math.max(0,p-g),v=Math.max(0,m-u),C=Math.max(0,h-w),S=Math.max(0,b-f),x=y>v,E=C>S,k=l.type;return t==="x"&&(k==="l"?(o=h,x?(s=g,i=y):(s=u,i=v)):k==="r"?(o=f,x?(s=g,i=y):(s=u,i=v)):k==="x"&&(o=h-(h-f)/2,x?(s=g,i=y):(s=u,i=v))),t==="y"&&(k==="t"?(s=p,E?(o=w,r=C):(o=f,r=S)):k==="b"?(s=u,E?(o=w,r=C):(o=f,r=S)):k==="y"&&(s=p-(p-u)/2,E?(o=w,r=C):(o=f,r=S))),{axis:t,x:o,y:s,width:r,height:i}}function mb({guideMatched:n,component:e,canvasView:t}){const o=n.guide.x===void 0?"x":"y",{guide:s,matched:i}=n,r=s.type,l=i.type,a=t.getElementPos(s.componentView.el).rect,c=t.getElementPos(i.componentView.el).rect;if(o==="x"){const d=a.height,p=c.top,u=c.top+c.height;let h=0;r==="t"?l==="t"?h=p-d:l==="b"?h=u-d:l==="y"&&(h=p-d-(p-u)/2):r==="b"?l==="t"?h=p-d*2:l==="b"?h=u-d*2:l==="y"&&(h=p-d*2-(p-u)/2):r==="y"&&(l==="t"?h=p-d*1.5:l==="b"?h=u-d*1.5:l==="y"&&(h=p-d*1.5-(p-u)/2)),e.addStyle({top:`${h-5}px`},{partial:!0})}if(o==="y"){const d=a.width,p=c.left,u=c.left+c.width;let h=0;r==="l"?l==="l"?h=p:l==="r"?h=u:l==="x"&&(h=p-(p-u)/2):r==="r"?l==="l"?h=p-d:l==="r"?h=u-d:l==="x"&&(h=p-d-(p-u)/2):r==="x"&&(l==="l"?h=p-d/2:l==="r"&&(h=u-d/2)),e.addStyle({left:`${h}px`},{partial:!0})}}function wp({snapping:n,editor:e,props:t}){var P,N;const{command:o,guidesMatched:s}=t,i=t.component,r=i.getEl(),l=e.Canvas.getCanvasView(),{x:a,y:c}=n??{x:10,y:10},d=o.opts.event,p=d.clientX,u=d.clientY;if(!i.__lastSnappedPosition){const O=l.getElBoxRect(r),R=p-O.x,_=u-O.y;i.__lastSnappedPosition={left:O.x,top:O.y},i.__dragOffset={x:R,y:_}}const h=((P=i.__dragOffset)==null?void 0:P.x)||0,f=((N=i.__dragOffset)==null?void 0:N.y)||0,m=i.__lastSnappedPosition,g=p-m.left-h,b=u-m.top-f;let w=m.left,y=m.top;const v=s==null?void 0:s[0],C=(v==null?void 0:v.guide.type)==="l",S=(v==null?void 0:v.guide.type)==="x",x=(v==null?void 0:v.guide.type)==="r",E=(v==null?void 0:v.guide.type)==="t",k=(v==null?void 0:v.guide.type)==="b",M=(v==null?void 0:v.guide.type)==="y";if(v){const{x:O,y:R}=Ss({guideMatched:v,canvasView:l}),_=r.offsetWidth,ue=r.offsetHeight;C?w=O:x?w=O-_:S?w=O-_/2:E?y=R:k?y=R-ue:M&&(y=R-ue/2),i.__lastSnappedGuideMatched=v}else Math.abs(g)>=a&&(w=Math.round((m.left+g)/a)*a,i.__lastSnappedGuideMatched=null),Math.abs(b)>=c&&(y=Math.round((m.top+b)/c)*c,i.__lastSnappedGuideMatched=null);return i.addStyle({left:`${w}px`,top:`${y}px`},{partial:!0}),i.__lastSnappedPosition={left:w,top:y},{x:w,y,guideMatched:i.__lastSnappedGuideMatched}}function gb({snapping:n,props:e,editor:t}){const{x:o,y:s}=wp({snapping:n,props:e,editor:t}),i=e.component;i.addStyle({left:`${o}px`,top:`${s}px`}),delete i.__lastSnappedPosition,delete i.__lastSnappedGuideMatched}const yb="core:component-drag",bb="studio:setDragAbsolute",vb="dmode:start",Cp="dmode:move",kp="dmode:end",kr="dragAbsolute",Sb="select",xb="hover",wb="spacing",Cb=W(function(n,e={}){const{Commands:t}=n,o=t.events,s=t.getConfig().defaultOptions??{},i=`${o.runBeforeCommand}tlb-move`;s[yb]={run:x=>({...x,skipGuidesRender:!0})};const{snapping:r,locking:l,globalAbsolute:a=!0}=e;a&&n.setDragMode("absolute");const c=!!(r!=null&&r.x||r!=null&&r.y),d=!!(l!=null&&l.x||l!=null&&l.y),{Canvas:p}=n;let u=null;const h=x=>{const{component:E,guidesMatched:k,command:M}=x,P=E.view,N=n.Canvas.getCanvasView(),O=E.getEl();let R=k.map(he=>he.matched.componentEl),_=k.map(he=>Ss({guideMatched:he,canvasView:N}));if(c){const{guideMatched:he}=wp({snapping:r,props:x,editor:n});he?(R=[he.matched.componentEl],_=[Ss({guideMatched:he,canvasView:N})]):(R=[],_=[])}if(d)if(M.opts.event.shiftKey)if(!u)u=k[0];else{const tt=u,Ce=tt.guide.x===void 0?"x":"y";(Ce==="x"&&(l==null?void 0:l.x)||Ce==="y"&&(l==null?void 0:l.y))&&(mb({guideMatched:tt,component:E,canvasView:N}),R=[tt.matched.componentEl],_=[Ss({guideMatched:tt,canvasView:N})])}else u=null;const ue={id:kr,type:kr,component:E,componentView:P,originComponent:O,matchedComponents:R,originMatchedDistances:_};p.addSpot(ue)},f=({enabled:x})=>{n.runCommand(bb,{enabled:x})},m=({type:x})=>{p.removeSpots({type:x})},g=()=>{m({type:Sb}),m({type:xb}),m({type:wb})},b=x=>{f({enabled:!0}),h(x),g()},w=x=>{h(x),g()},y=x=>{m({type:kr}),c&&gb({snapping:r,props:x,editor:n}),f({enabled:!1})},S=[[vb,x=>{b(x),n.on(Cp,w);const E=()=>{y(x),n.off(Cp,w),n.off(kp,E)};n.on(kp,E)}],[i,x=>{if(a)return;const E=x.options.target,k=fb(n,E,e);k!=null&&k.result&&!k.dmode&&(x.options.mode="absolute")}]];S.forEach(([x,E])=>n.on(x,E)),j({editor:n,licenseKey:e.licenseKey,plan:hb,pluginName:ub,cleanup:()=>{f({enabled:!1}),S.forEach(([x,E])=>n.off(x,E))}})});V.accordionComponent=Sh,V.animationComponent=Zh,V.canvasAbsoluteMode=Cb,V.canvasEmptyState=Q0,V.canvasFullSize=oy,V.canvasGridMode=xy,V.canvasScreenshot=Ty,V.dataSourceEjs=Wy,V.dataSourceHandlebars=Zy,V.dialogComponent=jp,V.flexComponent=Fh,V.fsLightboxComponent=Hu,V.googleFontsAssetProvider=pb,V.iconifyComponent=su,V.layoutSidebarButtons=hp,V.lightGalleryComponent=Zu,V.listPagesComponent=$u,V.presetPrintable=Ly,V.rteProseMirror=Z0,V.rteTinyMce=df,V.shapeDividerComponent=Qh,V.swiperComponent=ph,V.tableComponent=Pu,V.youtubeAssetProvider=nb,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});
1898
+ `}handleCommentStatement(e){return`<!--${e.value}-->`}handleElementNode(e){let t="";if(e.attributes)for(const i of e.attributes)i.value.type==="TextNode"?t+=` ${i.name}="${i.value.chars}"`:(this.addMessage("warning",`Complex attribute values not fully supported: ${i.name}`,e.loc),t+=` ${i.name}="${this.getExpressionString(i.value)}"`);let o="";if(e.children)for(const i of e.children)o+=this.astToGrapesJS(i);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 Ns=n=>{if(n==null||n==="")return[];if(n===".")return["this"];if(n===".."||n==="../")return[".."];if(n.startsWith("../")){const s=n.substring(3);return["..",...Ns(s)]}const e=[];let t=0,o=n.replace(/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,(s,l,a,c)=>{const d=a!==void 0?a:c||"";return e[t]=d,`__HANDLEBARS_PLACEHOLDER_${t++}__`});o=o.replace(/\//g,".");const i=o.split("."),r=[];for(const s of i){const l=/^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(s);if(l){const a=parseInt(l[1],10);r.push(e[a])}else s!==""&&r.push(s)}return r},nu="dataSourceHandlebars",Fy=F.startup,_y=q(function(n,e={}){const t=Xp(n,new Vy),o=Qp(n,{contains:"{{",importer:new Hy});U({editor:n,licenseKey:e.licenseKey,plan:Fy,pluginName:nu,cleanup:()=>{t(),o()}})},nu),Gy=n=>{const e={};for(const t of Object.keys(n)){let o=n[t];o&&(Array.isArray(o)?o=o.map(i=>i.toString()).join(","):o=o.toString(),e[t]=o)}return new URLSearchParams(e)},ou="youtube-video",Wy=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:o="high"}=n,i=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=Gy(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},s=l=>{const a=r(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,type:ou,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:[ou],label:({editor:l})=>l.I18n.t("youtubeAssetProvider.providerLabel"),search:{reloadOnInput:!0,debounceMs:1e3},async onLoad({searchValue:l,pageCustomData:a}){var g;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}),p={...c,...d};p.part?p.part.includes("snippet")||p.part.push("snippet"):p.part=["snippet"];const f=await(await fetch(i(p))).json();return(g=f.items)!=null&&g.length?{items:f.items.map(s),nextPageCustomData:{token:f.nextPageToken},isLastPage:!f.nextPageToken}:{items:[],isLastPage:!0}},itemLayout:({assetProps:l,onSelect:a})=>({type:"column",onClick:()=>a(l),htmlAttrs:{title:l.name},style:{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}}]})}},qy={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},iu="youtubeAssetProvider",Uy=F.startup,Ky=q(function(n,e){var c;const{skipVideoComponent:t,i18n:o={}}=e,i=Wy(e);n.runCommand(W.assetProviderAdd,{provider:i});const r="search-on-youtube",s="video",l=(c=n.Components.getType(s))==null?void 0:c.model.prototype,a=d=>{n.Assets.open({modalTitle:n.I18n.t("youtubeAssetProvider.modalTitle"),providerId:i.id,typeId:i.types[0],providers:[],types:[],select:p=>{n.Assets.close(),d.set({videoId:p.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!t&&l&&n.Components.addType(s,{model:{getYoutubeTraits(){const[d,...p]=l.getYoutubeTraits.apply(this);return[d,{id:r,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...p]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:d}=this,p=d.get("provider")||"";p!=null&&p.startsWith("yt")&&a(d)}}}),n.I18n.addMessages({en:qy,...o}),U({editor:n,licenseKey:e.licenseKey,plan:Uy,pluginName:iu,cleanup:()=>{n.runCommand(W.assetProviderRemove,{id:i.id}),!t&&l&&n.Components.addType(s,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==r)}}})}})},iu),fo=n=>n.replaceAll('"',"").replaceAll("'",""),Os=n=>n.includes(",")?n:/\s/.test(n)?`'${fo(n)}'`:fo(n),ru=(n,e,t)=>({family:n,variant:e,...t}),su=(n,e)=>{n=Os(n);const{menuVariant:t,variants:o}=e;return{family:n,familyLabel:fo(n),menuVariant:t&&ru(Os(`menuFont-${fo(n)}`),"regular",t),variants:Object.assign({},...Object.entries(o).map(([i,r])=>({[i]:ru(n,i,r)})))}},lu=(n,e)=>{var l;const t=su(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:i,descriptors:r}=o,s=fo(o.family);if(!e){const a=new FontFace(s,`url("${i}")`,r),c=Array.from(document.fonts.values()).filter(d=>d.family===s);for(const d of c)document.fonts.delete(d);document.fonts.add(a),a.load().catch(()=>{})}return Os(s)},Jy=n=>{const{family:e,menu:t,axes:o}=n,i=!!o,r=Object.assign({},...n.variants.map(s=>{var d,p;let l,a;if(i){const u=o.find(f=>f.tag==="wght");if(u){const{start:f,end:h}=u;l=`${f} ${h}`}}return l||(l=((d=s.match(/\d+/))==null?void 0:d[0])??"400"),a=((p=s.match(/[a-zA-Z]+/))==null?void 0:p[0])==="italic"?"italic":void 0,{[s]:{source:n.files[s],descriptors:{style:a,weight:l}}}}));return su(e,{menuVariant:{source:t},variants:r})},Yy=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:Jy(n),needsLoading:!0}}),Zy=n=>{const{font:e}=n.customData;return n.customData.needsLoading?(n.customData.needsLoading=!1,lu(e)):lu(e,!0)};let ho;const Xy=n=>{const e=[];for(const t of Object.keys(n)){let o=n[t];o&&(Array.isArray(o)?e.push(...o.map(i=>[t,i.toString()])):(o=o.toString(),e.push([t,o])))}return new URLSearchParams(e)},Qy=n=>{const{apiKey:e,searchParams:t}=n,o=(i={})=>{const r="https://www.googleapis.com/webfonts/v1/webfonts",s=Xy(i);return`${r}?${s}`};return{id:"google-fonts",types:["font"],label:({editor:i})=>i.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var c;if(ho)return ho;const i={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},r=t==null?void 0:t(),s={...i,...r},a=await(await fetch(o(s))).json();return(c=a.items)!=null&&c.length?(ho=a.items.map(Yy),ho):[]},itemLayout:i=>{const r=ho.find(l=>l.id===i.assetProps.id),s=Zy(r);return{type:"column",onClick:()=>i.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:s,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}},{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"16px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},ex={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},au="googleFontsAssetProvider",tx=F.startup,nx=q(function(n,e){const{i18n:t={}}=e,o=Qy(e);n.runCommand(W.assetProviderAdd,{provider:o}),n.I18n.addMessages({en:ex,...t}),U({editor:n,licenseKey:e.licenseKey,plan:tx,pluginName:au,cleanup:()=>{n.runCommand(W.assetProviderRemove,{id:o.id})}})},au),cu="canvasAbsoluteMode",ox=F.startup,ix=(n,e,t)=>{var c,d;const o=t.enableAbsolute??(p=>p.hasAbsolute),r=(Array.isArray(e)?e:e?[e]:[...n.getSelectedAll()])[0],s=((d=(c=r==null?void 0:r.delegate)==null?void 0:c.move)==null?void 0:d.call(c,r))||r;if(!s)return;const l=s.getEl();return{result:Le(o)?o({component:s,hasAbsolute:!!l&&getComputedStyle(l).position==="absolute"}):!1,component:s,dmode:s.get("dmode")}};function ki({guideMatched:n,canvasView:e}){var A;const t=n.guide.x===void 0?"y":"x";let o=0,i=0,r=0,s=0;const{guide:l,matched:a}=n,c=e.getElBoxRect(l.componentView.el),d=e.getElBoxRect(((A=a.componentView)==null?void 0:A.el)||a.componentEl),p=c.y,u=c.y+c.height,f=c.x,h=c.x+c.width,g=d.y,b=d.y+d.height,x=d.x,C=d.x+d.width,y=Math.max(0,p-b),v=Math.max(0,g-u),k=Math.max(0,f-C),w=Math.max(0,x-h),S=y>v,E=k>w,T=l.type;return t==="x"&&(T==="l"?(o=f,S?(i=b,r=y):(i=u,r=v)):T==="r"?(o=h,S?(i=b,r=y):(i=u,r=v)):T==="x"&&(o=f-(f-h)/2,S?(i=b,r=y):(i=u,r=v))),t==="y"&&(T==="t"?(i=p,E?(o=C,s=k):(o=h,s=w)):T==="b"?(i=u,E?(o=C,s=k):(o=h,s=w)):T==="y"&&(i=p-(p-u)/2,E?(o=C,s=k):(o=h,s=w))),{axis:t,x:o,y:i,width:s,height:r}}function rx({guideMatched:n,component:e,canvasView:t}){const o=n.guide.x===void 0?"x":"y",{guide:i,matched:r}=n,s=i.type,l=r.type,a=t.getElementPos(i.componentView.el).rect,c=t.getElementPos(r.componentView.el).rect;if(o==="x"){const d=a.height,p=c.top,u=c.top+c.height;let f=0;s==="t"?l==="t"?f=p-d:l==="b"?f=u-d:l==="y"&&(f=p-d-(p-u)/2):s==="b"?l==="t"?f=p-d*2:l==="b"?f=u-d*2:l==="y"&&(f=p-d*2-(p-u)/2):s==="y"&&(l==="t"?f=p-d*1.5:l==="b"?f=u-d*1.5:l==="y"&&(f=p-d*1.5-(p-u)/2)),e.addStyle({top:`${f-5}px`},{partial:!0})}if(o==="y"){const d=a.width,p=c.left,u=c.left+c.width;let f=0;s==="l"?l==="l"?f=p:l==="r"?f=u:l==="x"&&(f=p-(p-u)/2):s==="r"?l==="l"?f=p-d:l==="r"?f=u-d:l==="x"&&(f=p-d-(p-u)/2):s==="x"&&(l==="l"?f=p-d/2:l==="r"&&(f=u-d/2)),e.addStyle({left:`${f}px`},{partial:!0})}}function du({snapping:n,editor:e,props:t}){var $,P;const{command:o,guidesMatched:i}=t,r=t.component,s=r.getEl(),l=e.Canvas.getCanvasView(),{x:a,y:c}=n??{x:10,y:10},d=o.opts.event,p=d.clientX,u=d.clientY;if(!r.__lastSnappedPosition){const N=l.getElBoxRect(s),I=p-N.x,G=u-N.y;r.__lastSnappedPosition={left:N.x,top:N.y},r.__dragOffset={x:I,y:G}}const f=(($=r.__dragOffset)==null?void 0:$.x)||0,h=((P=r.__dragOffset)==null?void 0:P.y)||0,g=r.__lastSnappedPosition,b=p-g.left-f,x=u-g.top-h;let C=g.left,y=g.top;const v=i==null?void 0:i[0],k=(v==null?void 0:v.guide.type)==="l",w=(v==null?void 0:v.guide.type)==="x",S=(v==null?void 0:v.guide.type)==="r",E=(v==null?void 0:v.guide.type)==="t",T=(v==null?void 0:v.guide.type)==="b",A=(v==null?void 0:v.guide.type)==="y";if(v){const{x:N,y:I}=ki({guideMatched:v,canvasView:l}),G=s.offsetWidth,he=s.offsetHeight;k?C=N:S?C=N-G:w?C=N-G/2:E?y=I:T?y=I-he:A&&(y=I-he/2),r.__lastSnappedGuideMatched=v}else Math.abs(b)>=a&&(C=Math.round((g.left+b)/a)*a,r.__lastSnappedGuideMatched=null),Math.abs(x)>=c&&(y=Math.round((g.top+x)/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 sx({snapping:n,props:e,editor:t}){const{x:o,y:i}=du({snapping:n,props:e,editor:t}),r=e.component;r.addStyle({left:`${o}px`,top:`${i}px`}),delete r.__lastSnappedPosition,delete r.__lastSnappedGuideMatched}const lx="core:component-drag",ax="studio:setDragAbsolute",cx="dmode:start",pu="dmode:move",uu="dmode:end",Is="dragAbsolute",dx="select",px="hover",ux="spacing",fx=q(function(n,e={}){const{Commands:t}=n,o=t.events,i=t.getConfig().defaultOptions??{},r=`${o.runBeforeCommand}tlb-move`;i[lx]={run:S=>({...S,skipGuidesRender:!0})};const{snapping:s,locking:l,globalAbsolute:a=!0}=e;a&&n.setDragMode("absolute");const c=!!(s!=null&&s.x||s!=null&&s.y),d=!!(l!=null&&l.x||l!=null&&l.y),{Canvas:p}=n;let u=null;const f=S=>{const{component:E,guidesMatched:T,command:A}=S,$=E.view,P=n.Canvas.getCanvasView(),N=E.getEl();let I=T.map(me=>me.matched.componentEl),G=T.map(me=>ki({guideMatched:me,canvasView:P}));if(c){const{guideMatched:me}=du({snapping:s,props:S,editor:n});me?(I=[me.matched.componentEl],G=[ki({guideMatched:me,canvasView:P})]):(I=[],G=[])}if(d)if(A.opts.event.shiftKey)if(!u)u=T[0];else{const it=u,Te=it.guide.x===void 0?"x":"y";(Te==="x"&&(l==null?void 0:l.x)||Te==="y"&&(l==null?void 0:l.y))&&(rx({guideMatched:it,component:E,canvasView:P}),I=[it.matched.componentEl],G=[ki({guideMatched:it,canvasView:P})])}else u=null;const he={id:Is,type:Is,component:E,componentView:$,originComponent:N,matchedComponents:I,originMatchedDistances:G};p.addSpot(he)},h=({enabled:S})=>{n.runCommand(ax,{enabled:S})},g=({type:S})=>{p.removeSpots({type:S})},b=()=>{g({type:dx}),g({type:px}),g({type:ux})},x=S=>{h({enabled:!0}),f(S),b()},C=S=>{f(S),b()},y=S=>{g({type:Is}),c&&sx({snapping:s,props:S,editor:n}),h({enabled:!1})},w=[[cx,S=>{x(S),n.on(pu,C);const E=()=>{y(S),n.off(pu,C),n.off(uu,E)};n.on(uu,E)}],[r,S=>{if(a)return;const E=S.options.target,T=ix(n,E,e);T!=null&&T.result&&!T.dmode&&(S.options.mode="absolute")}]];w.forEach(([S,E])=>n.on(S,E)),U({editor:n,licenseKey:e.licenseKey,plan:ox,pluginName:cu,cleanup:()=>{h({enabled:!1}),w.forEach(([S,E])=>n.off(S,E))}})},cu);B.accordionComponent=oh,B.animationComponent=Ph,B.canvasAbsoluteMode=fx,B.canvasEmptyState=jb,B.canvasFullSize=Ob,B.canvasGridMode=Zb,B.canvasScreenshot=ty,B.dataSourceEjs=Ly,B.dataSourceHandlebars=_y,B.dialogComponent=Iu,B.flexComponent=Ch,B.fsLightboxComponent=Ef,B.googleFontsAssetProvider=nx,B.iconifyComponent=qu,B.layoutSidebarButtons=Rp,B.lightGalleryComponent=Df,B.listPagesComponent=Cf,B.presetBlockLibrary=$y,B.presetPrintable=cy,B.rteProseMirror=Mb,B.rteTinyMce=Fh,B.shapeDividerComponent=Oh,B.swiperComponent=Jf,B.tableComponent=bf,B.youtubeAssetProvider=Ky,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});